chore(telemetry): add tracing headers to flush + .env.example
This commit is contained in:
parent
1f18c53b76
commit
8ad31af72a
5
web/.env.example
Normal file
5
web/.env.example
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
# ChronoMind Web — Environment Configuration
|
||||||
|
# Copy to .env.local and fill in values
|
||||||
|
|
||||||
|
# Platform Service (backend API for sync, auth, telemetry)
|
||||||
|
NEXT_PUBLIC_PLATFORM_SERVICE_URL=http://localhost:4003/api
|
||||||
1
web/.gitignore
vendored
1
web/.gitignore
vendored
@ -35,6 +35,7 @@ yarn-error.log*
|
|||||||
|
|
||||||
# env files (can opt-in for committing if needed)
|
# env files (can opt-in for committing if needed)
|
||||||
.env*
|
.env*
|
||||||
|
!.env.example
|
||||||
|
|
||||||
# vercel
|
# vercel
|
||||||
.vercel
|
.vercel
|
||||||
|
|||||||
@ -121,16 +121,20 @@ export function flush(): void {
|
|||||||
const body = JSON.stringify({ productId: PRODUCT_ID, events });
|
const body = JSON.stringify({ productId: PRODUCT_ID, events });
|
||||||
const url = `${baseUrl}/telemetry/events`;
|
const url = `${baseUrl}/telemetry/events`;
|
||||||
|
|
||||||
|
const headers: Record<string, string> = {
|
||||||
|
'Content-Type': 'application/json',
|
||||||
|
'x-product-id': PRODUCT_ID,
|
||||||
|
'x-request-id': uuid(),
|
||||||
|
};
|
||||||
|
|
||||||
try {
|
try {
|
||||||
const sent = navigator.sendBeacon(url, body);
|
// sendBeacon doesn't support custom headers — use fetch with keepalive
|
||||||
if (!sent) {
|
fetch(url, {
|
||||||
fetch(url, {
|
method: 'POST',
|
||||||
method: 'POST',
|
headers,
|
||||||
headers: { 'Content-Type': 'application/json' },
|
body,
|
||||||
body,
|
keepalive: true,
|
||||||
keepalive: true,
|
}).catch(() => {});
|
||||||
}).catch(() => {});
|
|
||||||
}
|
|
||||||
} catch {
|
} catch {
|
||||||
// Best effort — telemetry is non-critical
|
// Best effort — telemetry is non-critical
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user