mirror of
https://github.com/gristlabs/grist-core.git
synced 2026-03-02 04:09:24 +00:00
(core) Add optional telemetry to grist-core
Summary: Adds support for optional telemetry to grist-core. A new environment variable, GRIST_TELEMETRY_LEVEL, controls the level of telemetry collected. Test Plan: Server and unit tests. Reviewers: paulfitz Reviewed By: paulfitz Subscribers: dsagal, anaisconce Differential Revision: https://phab.getgrist.com/D3880
This commit is contained in:
@@ -7,6 +7,7 @@ import uuidv4 from 'uuid/v4';
|
||||
import {AbortSignal} from 'node-abort-controller';
|
||||
|
||||
import {EngineCode} from 'app/common/DocumentSettings';
|
||||
import {TelemetryMetadataByLevel} from 'app/common/Telemetry';
|
||||
import log from 'app/server/lib/log';
|
||||
import {OpenMode, SQLiteDB} from 'app/server/lib/SQLiteDB';
|
||||
import {getDocSessionAccessOrNull, getDocSessionUser, OptDocSession} from './DocSession';
|
||||
@@ -166,14 +167,18 @@ export function getLogMetaFromDocSession(docSession: OptDocSession) {
|
||||
/**
|
||||
* Extract telemetry metadata from session.
|
||||
*/
|
||||
export function getTelemetryMetaFromDocSession(docSession: OptDocSession) {
|
||||
export function getTelemetryMetaFromDocSession(docSession: OptDocSession): TelemetryMetadataByLevel {
|
||||
const client = docSession.client;
|
||||
const access = getDocSessionAccessOrNull(docSession);
|
||||
const user = getDocSessionUser(docSession);
|
||||
return {
|
||||
access,
|
||||
...(user ? {userId: user.id} : {}),
|
||||
...(client ? client.getFullTelemetryMeta() : {}), // Client if present will repeat and add to user info.
|
||||
limited: {
|
||||
access,
|
||||
},
|
||||
full: {
|
||||
...(user ? {userId: user.id} : {}),
|
||||
...(client ? client.getFullTelemetryMeta() : {}), // Client if present will repeat and add to user info.
|
||||
},
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user