Skip to content

Commit 5cb9a76

Browse files
committed
feat(browser): include SDK metadata in rules requests
1 parent 498050d commit 5cb9a76

2 files changed

Lines changed: 7 additions & 2 deletions

File tree

packages/browser/src/transport/fetchConfiguration.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,11 @@ export function buildConfigurationUrl(options: ConfigurationFetchOptions, endpoi
6565
}
6666

6767
url.searchParams.set('dd_env', options.env || '')
68+
if (endpoint === 'rules') {
69+
for (const [name, value] of Object.entries(sourcePayload)) {
70+
url.searchParams.set(name, value)
71+
}
72+
}
6873
return url
6974
}
7075

packages/browser/test/transport/fetchConfiguration.spec.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -384,7 +384,7 @@ describe('createFlagsConfigurationFetcher', () => {
384384
)
385385
})
386386

387-
it('decodes a rules configuration response', async () => {
387+
it('decodes a rules configuration response and includes source query parameters', async () => {
388388
const bytes = Uint8Array.from(Buffer.from(rulesWire.rules.response, 'base64'))
389389
mockFetch.mockResolvedValue({
390390
ok: true,
@@ -400,7 +400,7 @@ describe('createFlagsConfigurationFetcher', () => {
400400
response: { environmentName: 'prod' },
401401
})
402402
expect(mockFetch).toHaveBeenCalledWith(
403-
'https://proxy.example.com/?dd_env=test',
403+
'https://proxy.example.com/?dd_env=test&sdk_name=browser&sdk_version=1.0.0-test',
404404
expect.objectContaining({
405405
method: 'GET',
406406
headers: {

0 commit comments

Comments
 (0)