diff --git a/packages/feature-flag-client/src/client.ts b/packages/feature-flag-client/src/client.ts index 7de5b93c..360021d1 100644 --- a/packages/feature-flag-client/src/client.ts +++ b/packages/feature-flag-client/src/client.ts @@ -54,8 +54,13 @@ export function createFeatureFlagClient(config: FeatureFlagClientConfig): Featur const parts = [`platform=${encodeURIComponent(platform)}`]; if (userId) parts.push(`userId=${encodeURIComponent(userId)}`); + const requestId = + typeof globalThis.crypto?.randomUUID === 'function' + ? globalThis.crypto.randomUUID() + : `${Date.now()}-${Math.random().toString(36).slice(2, 10)}`; + const res = await globalThis.fetch(`${baseUrl}/flags/poll?${parts.join('&')}`, { - headers: { 'x-product-id': productId }, + headers: { 'x-product-id': productId, 'x-request-id': requestId }, }); if (!res.ok) return; diff --git a/packages/kill-switch-client/src/index.ts b/packages/kill-switch-client/src/index.ts index c8ebd2f3..e41339d5 100644 --- a/packages/kill-switch-client/src/index.ts +++ b/packages/kill-switch-client/src/index.ts @@ -44,10 +44,15 @@ export function createKillSwitchClient(config: KillSwitchClientConfig): KillSwit async function check(): Promise { try { + const requestId = + typeof globalThis.crypto?.randomUUID === 'function' + ? globalThis.crypto.randomUUID() + : `${Date.now()}-${Math.random().toString(36).slice(2, 10)}`; + const res = await globalThis.fetch( `${baseUrl}/flags/kill-switch?platform=${encodeURIComponent(platform)}`, { - headers: { 'x-product-id': productId }, + headers: { 'x-product-id': productId, 'x-request-id': requestId }, } );