fix(ts-clients): add x-request-id header to feature-flag-client and kill-switch-client
This commit is contained in:
parent
f953c2b0bc
commit
2518e1a92e
@ -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;
|
||||
|
||||
@ -44,10 +44,15 @@ export function createKillSwitchClient(config: KillSwitchClientConfig): KillSwit
|
||||
|
||||
async function check(): Promise<KillSwitchResult> {
|
||||
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 },
|
||||
}
|
||||
);
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user