Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 20 additions & 0 deletions migration/r4.4/analytics.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
create table useranalytics (
id serial not null primary key,
userid int not null,
year int not null,
month int not null
);
create unique index ux_useranalytics on useranalytics(userid, year, month);
grant all on useranalytics to transcriber;
grant all on useranalytics_id_seq to transcriber;


create table countryanalytics (
id serial not null primary key,
country text not null,
year int not null,
month int not null
);
create unique index ux_countryanalytics on countryanalytics(country, year, month);
grant all on countryanalytics to transcriber;
grant all on countryanalytics_id_seq to transcriber;
2 changes: 2 additions & 0 deletions src/renderer/src/Sources.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ import { updateBackTranslationType } from './crud/updateBackTranslationType';
import { updateConsultantWorkflowStep } from './crud/updateConsultantWorkflowStep';
import { serializersSettings } from './serializers/serializersFor';
import { requestedSchema } from './schema';
import { logLoginAnalytics } from './crud/logLoginAnalytics';
import { orbitReset } from './crud/orbitReset';
type StategyError = (...args: unknown[]) => unknown;

Expand Down Expand Up @@ -442,6 +443,7 @@ export const Sources = async (
await forceDataChanges();
console.log(`Forcing complete`);
}
logLoginAnalytics(tokenState.accessToken);
}
const user = localStorage.getItem(LocalKey.userId) as string;
setUser(user);
Expand Down
1 change: 1 addition & 0 deletions src/renderer/src/crud/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ export * from './getOrgs';
export * from './groupmembership';
export * from './hasAnyRelated';
export * from './loadData';
export * from './logLoginAnalytics';
export * from './media';
export * from './offlineError';
export * from './passage';
Expand Down
9 changes: 9 additions & 0 deletions src/renderer/src/crud/logLoginAnalytics.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
import { axiosPost } from '../utils/axios';
export async function logLoginAnalytics(token?: string | null): Promise<void> {
if (!token) return;
try {
await axiosPost('useranalytics/track', undefined, token);
} catch (error) {
console.error('logLoginAnalytics', error);
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if you use logError, this would post to bugsnag. Do you want failures posted to bugsnag?

}
}
13 changes: 13 additions & 0 deletions src/renderer/src/model/countryAnalytics.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import { InitializedRecord, UninitializedRecord } from '@orbit/records';

export interface CountryAnalytics extends UninitializedRecord {
attributes: {
country: string;
year: number;
month: number;
};
}

export type CountryAnalyticsD = CountryAnalytics & InitializedRecord;

export default CountryAnalytics;
2 changes: 2 additions & 0 deletions src/renderer/src/model/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -68,5 +68,7 @@ export * from './organizationBible';
export * from './paratextProject';
export * from './intellectualProperty';
export * from './vwchecksum';
export * from './userAnalytics';
export * from './countryAnalytics';
export * from './IExecResult';
export * from './SectionArray';
13 changes: 13 additions & 0 deletions src/renderer/src/model/userAnalytics.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import { InitializedRecord, UninitializedRecord } from '@orbit/records';

export interface UserAnalytics extends UninitializedRecord {
attributes: {
userId: number;
year: number;
month: number;
};
}

export type UserAnalyticsD = UserAnalytics & InitializedRecord;

export default UserAnalytics;
19 changes: 19 additions & 0 deletions src/renderer/src/schema.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -1035,6 +1035,25 @@ if (requestedSchema > 9 && schemaDefinition.models) {
};
schemaDefinition.version = 10;
}
if (requestedSchema > 10 && schemaDefinition.models) {
schemaDefinition.models.useranalytics = {
keys: { remoteId: {} },
attributes: {
userId: { type: 'number' },
year: { type: 'number' },
month: { type: 'number' },
},
};
schemaDefinition.models.countryanalytics = {
keys: { remoteId: {} },
attributes: {
country: { type: 'string' },
year: { type: 'number' },
month: { type: 'number' },
},
};
schemaDefinition.version = 11;
}

export const schema = new RecordSchema(schemaDefinition);

Expand Down
Loading