(core) Add earliestDocCreatedAt to telemetry

Summary: This tracks the earliest document creation time, if any, for each site.

Test Plan: Server tests.

Reviewers: jarek

Reviewed By: jarek

Differential Revision: https://phab.getgrist.com/D3991
This commit is contained in:
George Gevoian 2023-08-08 00:26:28 -07:00
parent efb5fc63d7
commit 24bbf375f9
4 changed files with 9 additions and 0 deletions

View File

@ -761,6 +761,10 @@ export const TelemetryContracts: TelemetryContracts = {
description: 'A timestamp of the most recent update made to a site document.', description: 'A timestamp of the most recent update made to a site document.',
dataType: 'date', dataType: 'date',
}, },
earliestDocCreatedAt: {
description: 'A timestamp of the earliest non-deleted document creation time.',
dataType: 'date',
},
}, },
}, },
tutorialProgressChanged: { tutorialProgressChanged: {

View File

@ -137,6 +137,7 @@ export const ThemeColors = t.iface([], {
"selection-opaque-fg": "string", "selection-opaque-fg": "string",
"selection-opaque-bg": "string", "selection-opaque-bg": "string",
"selection-opaque-dark-bg": "string", "selection-opaque-dark-bg": "string",
"selection-header": "string",
"widget-bg": "string", "widget-bg": "string",
"widget-border": "string", "widget-border": "string",
"widget-active-border": "string", "widget-active-border": "string",

View File

@ -186,6 +186,7 @@ export class Housekeeper {
numWorkspaces: Number(summary.num_workspaces), numWorkspaces: Number(summary.num_workspaces),
numMembers: Number(summary.num_members), numMembers: Number(summary.num_members),
lastActivity: summary.last_activity, lastActivity: summary.last_activity,
earliestDocCreatedAt: summary.earliest_doc_created_at,
}, },
full: { full: {
stripePlanId: summary.stripe_plan_id, stripePlanId: summary.stripe_plan_id,
@ -324,6 +325,7 @@ export class Housekeeper {
.addSelect('COUNT(DISTINCT workspaces.id)', 'num_workspaces') .addSelect('COUNT(DISTINCT workspaces.id)', 'num_workspaces')
.addSelect('COUNT(DISTINCT org_member_users.id)', 'num_members') .addSelect('COUNT(DISTINCT org_member_users.id)', 'num_members')
.addSelect('MAX(docs.updated_at)', 'last_activity') .addSelect('MAX(docs.updated_at)', 'last_activity')
.addSelect('MIN(docs.created_at)', 'earliest_doc_created_at')
.from(Organization, 'orgs') .from(Organization, 'orgs')
.leftJoin('orgs.workspaces', 'workspaces') .leftJoin('orgs.workspaces', 'workspaces')
.leftJoin('workspaces.docs', 'docs') .leftJoin('workspaces.docs', 'docs')

View File

@ -23,6 +23,7 @@ describe('Telemetry', function() {
numWorkspaces: 1, numWorkspaces: 1,
numMembers: 1, numMembers: 1,
lastActivity: new Date('2022-12-30T01:23:45'), lastActivity: new Date('2022-12-30T01:23:45'),
earliestDocCreatedAt: new Date('2022-12-29T00:01:02'),
})); }));
assert.doesNotThrow(() => checker('watchedVideoTour', { assert.doesNotThrow(() => checker('watchedVideoTour', {
watchTimeSeconds: 30, watchTimeSeconds: 30,
@ -54,6 +55,7 @@ describe('Telemetry', function() {
numWorkspaces: 1, numWorkspaces: 1,
numMembers: 1, numMembers: 1,
lastActivity: new Date('2022-12-30T01:23:45'), lastActivity: new Date('2022-12-30T01:23:45'),
earliestDocCreatedAt: new Date('2022-12-29T00:01:02'),
})); }));
assert.doesNotThrow(() => checker('watchedVideoTour', { assert.doesNotThrow(() => checker('watchedVideoTour', {
watchTimeSeconds: 30, watchTimeSeconds: 30,