Repository navigation
[FFL-3355] Add JavaScript tracking hooks for DatadogCoreProvider #1467
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Closed
Closed
Changes from all commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
8b8066f
fix(rum): ignore flagging intake requests in resource tracking (FFL-3…
greghuels 8720eea
feat(openfeature): add JavaScript tracking hooks for DatadogCoreProvi…
greghuels 41b1f06
feat(openfeature): send dd-evp-origin-version with intake requests (F…
greghuels fabca77
fix(rum): only ignore flagging uploads sent by the OpenFeature hooks …
greghuels 260ff6d
fix(openfeature): use the default interval for non-finite tracking in…
greghuels a42f0c4
chore(openfeature): add version module artifacts to release content (…
greghuels 7fd0356
fix(openfeature): bound tracking batches by payload size (FFL-3355)
greghuels 97d5560
fix(openfeature): track failed flag evaluations in the finally stage …
greghuels File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
41 changes: 41 additions & 0 deletions
41
...g/requestProxy/XHRProxy/DatadogRumResource/__tests__/flaggingIntakeResourceFilter.test.ts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,41 @@ | ||
| /* | ||
| * Unless explicitly stated otherwise all files in this repository are licensed under the Apache License Version 2.0. | ||
| * This product includes software developed at Datadog (https://www.datadoghq.com/). | ||
| * Copyright 2016-Present Datadog, Inc. | ||
| */ | ||
|
|
||
| import { filterFlaggingIntakeResource } from '../../../common/flaggingIntakeResourceFilter'; | ||
|
|
||
| import { ResourceMockFactory } from './__utils__/ResourceMockFactory'; | ||
|
|
||
| const resourceMockFactory = new ResourceMockFactory(); | ||
|
|
||
| const resourceWithUrl = (url: string) => | ||
| resourceMockFactory.getCustomResource({ | ||
| request: { method: 'POST', url, kind: 'fetch' } | ||
| }); | ||
|
|
||
| describe('filterFlaggingIntakeResource', () => { | ||
| it.each([ | ||
| 'https://browser-intake-datadoghq.com/api/v2/exposures?ddsource=react-native&dd-api-key=token', | ||
| 'https://browser-intake-us3-datadoghq.com/api/v2/flagevaluation?ddsource=react-native&dd-api-key=token', | ||
| 'https://browser-intake-datadoghq.eu/api/v2/exposures?ddsource=react-native&dd-api-key=token', | ||
| 'https://proxy.example.com/intake?ddforward=%2Fapi%2Fv2%2Fexposures%3Fddsource%3Dreact-native%26dd-api-key%3Dtoken', | ||
| 'https://proxy.example.com/intake?ddforward=%2Fapi%2Fv2%2Fflagevaluation%3Fddsource%3Dreact-native%26dd-api-key%3Dtoken' | ||
| ])('returns null for the flagging intake request %s', url => { | ||
| expect(filterFlaggingIntakeResource(resourceWithUrl(url))).toBeNull(); | ||
| }); | ||
|
|
||
| it.each([ | ||
| 'https://browser-intake-datadoghq.com/api/v2/rum?ddsource=react-native', | ||
| 'https://api.example.com/api/v2/exposures?ddsource=react-native', | ||
| 'https://browser-intake-datadoghq.com.example.com/other/api/v2/exposures?x=1', | ||
| 'https://proxy.example.com/intake?ddforward=%2Fapi%2Fv2%2Frum%3Fddsource%3Dbrowser', | ||
| 'https://browser-intake-custom.example/api/v2/exposures?customer=1', | ||
| 'https://browser-intake-datadoghq.com/api/v2/flagevaluation?ddsource=browser&dd-api-key=token', | ||
| 'https://proxy.example.com/intake?ddforward=%2Fapi%2Fv2%2Fexposures%3Fcustomer%3D1' | ||
| ])('returns the resource for %s', url => { | ||
| const resource = resourceWithUrl(url); | ||
| expect(filterFlaggingIntakeResource(resource)).toBe(resource); | ||
| }); | ||
| }); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
31 changes: 31 additions & 0 deletions
31
.../rum/instrumentation/resourceTracking/requestProxy/common/flaggingIntakeResourceFilter.ts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,31 @@ | ||
| /* | ||
| * Unless explicitly stated otherwise all files in this repository are licensed under the Apache License Version 2.0. | ||
| * This product includes software developed at Datadog (https://www.datadoghq.com/). | ||
| * Copyright 2016-Present Datadog, Inc. | ||
| */ | ||
|
|
||
| import type { RUMResource } from '../interfaces/RumResource'; | ||
|
|
||
| // The OpenFeature package's JavaScript tracking hooks send exposures and flag evaluations | ||
| // to these intake paths, either directly or through a `ddforward` proxy. They always put | ||
| // `ddsource=react-native` first, so other requests to the same paths are still tracked. | ||
| const FLAGGING_INTAKE_REGEX = new RegExp( | ||
| '^https://browser-intake-[^/?#]+/api/v2/(exposures|flagevaluation)\\?ddsource=react-native&' | ||
| ); | ||
|
|
||
| const FLAGGING_INTAKE_PROXY_REGEX = new RegExp( | ||
| '[?&]ddforward=%2Fapi%2Fv2%2F(exposures|flagevaluation)%3Fddsource%3Dreact-native%26' | ||
| ); | ||
|
|
||
| export const filterFlaggingIntakeResource = ( | ||
| resource: RUMResource | ||
| ): RUMResource | null => { | ||
| const url = resource.request.url; | ||
| if ( | ||
| FLAGGING_INTAKE_REGEX.test(url) || | ||
| FLAGGING_INTAKE_PROXY_REGEX.test(url) | ||
| ) { | ||
| return null; | ||
| } | ||
| return resource; | ||
| }; | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.