mirror of
https://github.com/gristlabs/grist-core.git
synced 2024-10-27 20:44:07 +00:00
1e873b4203
Summary: Adjusts the level of telemetry collected from Grist SaaS. Test Plan: Tested manually. Reviewers: paulfitz Reviewed By: paulfitz Subscribers: paulfitz Differential Revision: https://phab.getgrist.com/D3899
24 lines
671 B
TypeScript
24 lines
671 B
TypeScript
import {logError} from 'app/client/models/errors';
|
|
import {TelemetryEventName} from 'app/common/Telemetry';
|
|
import {fetchFromHome, pageHasHome} from 'app/common/urlUtils';
|
|
|
|
export function logTelemetryEvent(name: TelemetryEventName, metadata?: Record<string, any>) {
|
|
if (!pageHasHome()) { return; }
|
|
|
|
fetchFromHome('/api/telemetry', {
|
|
method: 'POST',
|
|
body: JSON.stringify({
|
|
name,
|
|
metadata,
|
|
}),
|
|
credentials: 'include',
|
|
headers: {
|
|
'Content-Type': 'application/json',
|
|
'X-Requested-With': 'XMLHttpRequest',
|
|
},
|
|
}).catch((e: Error) => {
|
|
console.warn(`Failed to log telemetry event ${name}`, e);
|
|
logError(e);
|
|
});
|
|
}
|