PluginProbe
Extendify / 3.1.0
Extendify v3.1.0
3.2.1 3.2.0 3.1.6 3.1.5 3.1.4 3.1.3 3.1.2 3.1.1 3.1.0 3.0.6 3.0.5 3.0.4 trunk 0.1.0 0.10.0 0.10.1 0.10.2 0.11.0 0.11.1 0.2.0 0.3.0 0.3.1 0.4.0 0.5.0 0.6.0 All 127 releases
extendify / src / QuickEdit / lib / insights.js

insights.js in Extendify 3.1.0, at src/QuickEdit/lib/insights.js

35 lines 769 B
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 // keepalive: true so events queued right before navigation (e.g. an
2 // undo-driven reload) still ship.
3 import { INSIGHTS_HOST } from '@constants';
4 import { reqDataBasics } from '@shared/lib/data';
5
6 const HEADERS = {
7 'Content-type': 'application/json',
8 Accept: 'application/json',
9 'X-Extendify': 'true',
10 };
11
12 const ENDPOINT = `${INSIGHTS_HOST}/api/v1/quick-edit`;
13
14 // event: snake_case. props: flat key/value, no PII.
15 export const track = (event, props = {}) => {
16 if (!INSIGHTS_HOST || !event) return;
17 try {
18 fetch(ENDPOINT, {
19 method: 'POST',
20 headers: HEADERS,
21 keepalive: true,
22 body: JSON.stringify({
23 ...reqDataBasics,
24 event,
25 props,
26 ts: Date.now(),
27 }),
28 }).catch(() => {
29 /* swallow */
30 });
31 } catch (_e) {
32 /* swallow */
33 }
34 };
35