MCPcopy Index your code
hub / github.com/ChatLab/ChatLab / track

Method track

packages/node-runtime/src/services/analytics.ts:65–94  ·  view source on GitHub ↗
(eventName: string, props?: Record<string, string | number>)

Source from the content-addressed store, hash-verified

63 }
64
65 async track(eventName: string, props?: Record<string, string | number>): Promise<boolean> {
66 if (!this.endpoint) return false
67 if (!this.getEnabled()) return false
68 try {
69 const resp = await fetch(this.endpoint, {
70 method: 'POST',
71 headers: { 'Content-Type': 'application/json', 'App-Key': this.appKey },
72 body: JSON.stringify({
73 timestamp: new Date().toISOString(),
74 sessionId: this.sessionId,
75 eventName,
76 systemProps: {
77 isDebug: false,
78 locale: '',
79 osName: process.platform,
80 osVersion: '',
81 engineName: 'Node.js',
82 engineVersion: process.versions.node,
83 appVersion: this.appVersion,
84 sdkVersion: 'chatlab@1',
85 },
86 props,
87 }),
88 })
89 return resp.ok
90 } catch (e) {
91 console.error(`[Analytics] Failed to track ${eventName}:`, e)
92 return false
93 }
94 }
95
96 async trackDailyActive(props?: Record<string, string | number>): Promise<void> {
97 if (!this.endpoint) return

Callers 3

trackDailyActiveMethod · 0.95
registerTelemetryRoutesFunction · 0.80
trackAppEventFunction · 0.80

Calls 2

getEnabledMethod · 0.95
errorMethod · 0.65

Tested by

no test coverage detected