mirror of
https://github.com/streetwriters/notesnook.git
synced 2025-12-23 23:19:40 +01:00
core: monographs stats -> monograph analytics
This commit is contained in:
@@ -37,8 +37,8 @@ type EncryptedMonograph = MonographApiRequestBase & {
|
|||||||
type MonographApiRequest = (UnencryptedMonograph | EncryptedMonograph) & {
|
type MonographApiRequest = (UnencryptedMonograph | EncryptedMonograph) & {
|
||||||
userId: string;
|
userId: string;
|
||||||
};
|
};
|
||||||
export type MonographStats = {
|
export type MonographAnalytics = {
|
||||||
viewCount: number;
|
totalViews: number;
|
||||||
};
|
};
|
||||||
|
|
||||||
export type PublishOptions = { password?: string; selfDestruct?: boolean };
|
export type PublishOptions = { password?: string; selfDestruct?: boolean };
|
||||||
@@ -191,16 +191,12 @@ export class Monographs {
|
|||||||
return this.db.storage().decrypt(monographPasswordsKey, password);
|
return this.db.storage().decrypt(monographPasswordsKey, password);
|
||||||
}
|
}
|
||||||
|
|
||||||
async stats(monographId: string) {
|
async analytics(monographId: string) {
|
||||||
const token = await this.db.tokenManager.getAccessToken();
|
const token = await this.db.tokenManager.getAccessToken();
|
||||||
const { viewCount } = (await http.get(
|
const analytics = (await http.get(
|
||||||
`${Constants.API_HOST}/monographs/${monographId}/stats`,
|
`${Constants.API_HOST}/monographs/${monographId}/analytics`,
|
||||||
token
|
token
|
||||||
)) as MonographStats;
|
)) as MonographAnalytics;
|
||||||
await this.db.monographsCollection.add({
|
return analytics;
|
||||||
id: monographId,
|
|
||||||
viewCount
|
|
||||||
});
|
|
||||||
return { viewCount };
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -62,7 +62,6 @@ export class Monographs implements ICollection {
|
|||||||
datePublished: merged.datePublished,
|
datePublished: merged.datePublished,
|
||||||
selfDestruct: merged.selfDestruct,
|
selfDestruct: merged.selfDestruct,
|
||||||
password: merged.password,
|
password: merged.password,
|
||||||
viewCount: merged.viewCount || 0,
|
|
||||||
type: "monograph"
|
type: "monograph"
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -404,14 +404,6 @@ export class NNMigrationProvider implements MigrationProvider {
|
|||||||
.addColumn("password", "text")
|
.addColumn("password", "text")
|
||||||
.execute();
|
.execute();
|
||||||
}
|
}
|
||||||
},
|
|
||||||
"a-2025-11-05": {
|
|
||||||
async up(db) {
|
|
||||||
await db.schema
|
|
||||||
.alterTable("monographs")
|
|
||||||
.addColumn("viewCount", "integer")
|
|
||||||
.execute();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -498,7 +498,6 @@ export interface Monograph extends BaseItem<"monograph"> {
|
|||||||
datePublished: number;
|
datePublished: number;
|
||||||
selfDestruct: boolean;
|
selfDestruct: boolean;
|
||||||
password?: Cipher<"base64">;
|
password?: Cipher<"base64">;
|
||||||
viewCount?: number;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
export type Match = {
|
export type Match = {
|
||||||
|
|||||||
Reference in New Issue
Block a user