-
Notifications
You must be signed in to change notification settings - Fork 42
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
louiszawadzki
committed
Sep 20, 2023
1 parent
b34cdd1
commit 30ef307
Showing
5 changed files
with
100 additions
and
8 deletions.
There are no files selected for viewing
This file contains 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
22 changes: 22 additions & 0 deletions
22
...es/core/src/rum/instrumentation/resourceTracking/graphql/__tests__/graphqlHeaders.test.ts
This file contains 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,22 @@ | ||
import { | ||
DATADOG_GRAPH_QL_OPERATION_NAME_HEADER, | ||
DATADOG_GRAPH_QL_OPERATION_TYPE_HEADER, | ||
DATADOG_GRAPH_QL_VARIABLES_HEADER, | ||
isDatadogCustomHeader | ||
} from '../graphqlHeaders'; | ||
|
||
describe('GraphQL custom headers', () => { | ||
it.each([ | ||
DATADOG_GRAPH_QL_OPERATION_NAME_HEADER, | ||
DATADOG_GRAPH_QL_OPERATION_TYPE_HEADER, | ||
DATADOG_GRAPH_QL_VARIABLES_HEADER | ||
])('%s matches the custom header pattern', header => { | ||
expect(isDatadogCustomHeader(header)).toBeTruthy(); | ||
}); | ||
|
||
describe('isDatadogCustomHeader', () => { | ||
it('returns false for non-custom headers', () => { | ||
expect(isDatadogCustomHeader('non-custom-header')).toBeFalsy(); | ||
}); | ||
}); | ||
}); |
9 changes: 9 additions & 0 deletions
9
packages/core/src/rum/instrumentation/resourceTracking/graphql/graphqlHeaders.ts
This file contains 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,9 @@ | ||
const DATADOG_CUSTOM_HEADER_PREFIX = '_dd-custom-header'; | ||
|
||
export const DATADOG_GRAPH_QL_OPERATION_NAME_HEADER = `${DATADOG_CUSTOM_HEADER_PREFIX}-graph-ql-operation-name`; | ||
export const DATADOG_GRAPH_QL_VARIABLES_HEADER = `${DATADOG_CUSTOM_HEADER_PREFIX}-graph-ql-variables`; | ||
export const DATADOG_GRAPH_QL_OPERATION_TYPE_HEADER = `${DATADOG_CUSTOM_HEADER_PREFIX}-graph-ql-operation-type`; | ||
|
||
export const isDatadogCustomHeader = (header: string) => { | ||
return header.match(new RegExp(`^${DATADOG_CUSTOM_HEADER_PREFIX}`)); | ||
}; |
This file contains 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 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