(core) Add telemetry for AI Assistant

Summary: Also fixes a few bugs with some telemetry events not being recorded.

Test Plan: Manual.

Reviewers: paulfitz

Reviewed By: paulfitz

Differential Revision: https://phab.getgrist.com/D3960
This commit is contained in:
George Gevoian
2023-07-20 10:25:26 -04:00
parent 0040716006
commit 0a34292536
8 changed files with 467 additions and 59 deletions

View File

@@ -164,6 +164,7 @@ where c.colId = ? and t.tableId = ?
formula = colInfo?.formula;
const result = await sendForCompletion(session, activeDoc, {
conversationId: 'conversationId',
context: {type: 'formula', tableId, colId},
state: history,
text: followUp || description,

View File

@@ -111,6 +111,7 @@ describe('Telemetry', function() {
eventSource: `grist-${deploymentType}`,
docIdDigest: 'dige:Vq9L3nCkeufQ8euzDkXtM2Fl1cnsALqakjEeM6QlbXQ=',
isPublic: false,
installationId,
}
]);
}
@@ -133,6 +134,7 @@ describe('Telemetry', function() {
docIdDigest: 'dige:Vq9L3nCkeufQ8euzDkXtM2Fl1cnsALqakjEeM6QlbXQ=',
isPublic: false,
userId: 1,
installationId,
}
]);
}
@@ -239,6 +241,7 @@ describe('Telemetry', function() {
eventName: 'watchedVideoTour',
eventSource: `grist-${deploymentType}`,
watchTimeSeconds: 30,
installationId,
});
} else {
assert.containsAllKeys(metadata, [
@@ -298,14 +301,10 @@ describe('Telemetry', function() {
assert.equal(event, 'watchedVideoTour');
if (telemetryLevel === 'limited') {
assert.deepEqual(metadata, {
eventSource: `grist-${deploymentType}`,
installationId,
watchTimeSeconds: 30,
});
} else {
assert.containsAllKeys(metadata, [
'eventSource',
'installationId',
'watchTimeSeconds',
'userId',
'altSessionId',