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) & {
|
||||
userId: string;
|
||||
};
|
||||
export type MonographStats = {
|
||||
viewCount: number;
|
||||
export type MonographAnalytics = {
|
||||
totalViews: number;
|
||||
};
|
||||
|
||||
export type PublishOptions = { password?: string; selfDestruct?: boolean };
|
||||
@@ -191,16 +191,12 @@ export class Monographs {
|
||||
return this.db.storage().decrypt(monographPasswordsKey, password);
|
||||
}
|
||||
|
||||
async stats(monographId: string) {
|
||||
async analytics(monographId: string) {
|
||||
const token = await this.db.tokenManager.getAccessToken();
|
||||
const { viewCount } = (await http.get(
|
||||
`${Constants.API_HOST}/monographs/${monographId}/stats`,
|
||||
const analytics = (await http.get(
|
||||
`${Constants.API_HOST}/monographs/${monographId}/analytics`,
|
||||
token
|
||||
)) as MonographStats;
|
||||
await this.db.monographsCollection.add({
|
||||
id: monographId,
|
||||
viewCount
|
||||
});
|
||||
return { viewCount };
|
||||
)) as MonographAnalytics;
|
||||
return analytics;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user