@datadog/mobile-react-native-apollo-client 2.0.0-rc.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +201 -0
- package/README.md +93 -0
- package/lib/commonjs/DatadogLink.js +44 -0
- package/lib/commonjs/DatadogLink.js.map +1 -0
- package/lib/commonjs/helpers.js +58 -0
- package/lib/commonjs/helpers.js.map +1 -0
- package/lib/commonjs/index.js +14 -0
- package/lib/commonjs/index.js.map +1 -0
- package/lib/module/DatadogLink.js +32 -0
- package/lib/module/DatadogLink.js.map +1 -0
- package/lib/module/helpers.js +44 -0
- package/lib/module/helpers.js.map +1 -0
- package/lib/module/index.js +7 -0
- package/lib/module/index.js.map +1 -0
- package/lib/typescript/core/src/DdSdkReactNative.d.ts +66 -0
- package/lib/typescript/core/src/DdSdkReactNativeConfiguration.d.ts +269 -0
- package/lib/typescript/core/src/InternalLog.d.ts +12 -0
- package/lib/typescript/core/src/ProxyConfiguration.d.ts +56 -0
- package/lib/typescript/core/src/SdkVerbosity.d.ts +9 -0
- package/lib/typescript/core/src/TrackingConsent.d.ts +8 -0
- package/lib/typescript/core/src/index.d.ts +13 -0
- package/lib/typescript/core/src/logs/DdLogs.d.ts +22 -0
- package/lib/typescript/core/src/logs/eventMapper.d.ts +11 -0
- package/lib/typescript/core/src/logs/types.d.ts +80 -0
- package/lib/typescript/core/src/nativeModulesTypes.d.ts +92 -0
- package/lib/typescript/core/src/rum/DdRum.d.ts +38 -0
- package/lib/typescript/core/src/rum/eventMappers/actionEventMapper.d.ts +21 -0
- package/lib/typescript/core/src/rum/eventMappers/errorEventMapper.d.ts +21 -0
- package/lib/typescript/core/src/rum/eventMappers/resourceEventMapper.d.ts +24 -0
- package/lib/typescript/core/src/rum/instrumentation/DdRumErrorTracking.d.ts +16 -0
- package/lib/typescript/core/src/rum/instrumentation/interactionTracking/DdEventsInterceptor.d.ts +15 -0
- package/lib/typescript/core/src/rum/instrumentation/interactionTracking/DdRumUserInteractionTracking.d.ts +21 -0
- package/lib/typescript/core/src/rum/instrumentation/interactionTracking/EventsInterceptor.d.ts +3 -0
- package/lib/typescript/core/src/rum/instrumentation/interactionTracking/NoOpEventsInterceptor.d.ts +4 -0
- package/lib/typescript/core/src/rum/instrumentation/interactionTracking/ShallowObjectEqualityChecker.d.ts +7 -0
- package/lib/typescript/core/src/rum/instrumentation/interactionTracking/getJsxRuntime.d.ts +1 -0
- package/lib/typescript/core/src/rum/instrumentation/resourceTracking/DdRumResourceTracking.d.ts +16 -0
- package/lib/typescript/core/src/rum/instrumentation/resourceTracking/distributedTracing/distributedTracing.d.ts +45 -0
- package/lib/typescript/core/src/rum/instrumentation/resourceTracking/distributedTracing/distributedTracingHeaders.d.ts +21 -0
- package/lib/typescript/core/src/rum/instrumentation/resourceTracking/distributedTracing/firstPartyHosts.d.ts +8 -0
- package/lib/typescript/core/src/rum/instrumentation/resourceTracking/graphql/graphqlHeaders.d.ts +4 -0
- package/lib/typescript/core/src/rum/instrumentation/resourceTracking/requestProxy/XHRProxy/DatadogRumResource/ResourceReporter.d.ts +8 -0
- package/lib/typescript/core/src/rum/instrumentation/resourceTracking/requestProxy/XHRProxy/DatadogRumResource/internalDevResourceBlocklist.d.ts +6 -0
- package/lib/typescript/core/src/rum/instrumentation/resourceTracking/requestProxy/XHRProxy/DatadogRumResource/resourceTiming.d.ts +17 -0
- package/lib/typescript/core/src/rum/instrumentation/resourceTracking/requestProxy/XHRProxy/URLHostParser.d.ts +6 -0
- package/lib/typescript/core/src/rum/instrumentation/resourceTracking/requestProxy/XHRProxy/XHRProxy.d.ts +20 -0
- package/lib/typescript/core/src/rum/instrumentation/resourceTracking/requestProxy/XHRProxy/responseSize.d.ts +2 -0
- package/lib/typescript/core/src/rum/instrumentation/resourceTracking/requestProxy/interfaces/RequestProxy.d.ts +13 -0
- package/lib/typescript/core/src/rum/instrumentation/resourceTracking/requestProxy/interfaces/RumResource.d.ts +27 -0
- package/lib/typescript/core/src/rum/types.d.ts +131 -0
- package/lib/typescript/core/src/sdk/AttributesSingleton/AttributesSingleton.d.ts +12 -0
- package/lib/typescript/core/src/sdk/AttributesSingleton/types.d.ts +3 -0
- package/lib/typescript/core/src/sdk/DatadogProvider/Buffer/BoundedBuffer.d.ts +15 -0
- package/lib/typescript/core/src/sdk/DatadogProvider/Buffer/BufferSingleton.d.ts +7 -0
- package/lib/typescript/core/src/sdk/DatadogProvider/Buffer/DatadogBuffer.d.ts +20 -0
- package/lib/typescript/core/src/sdk/DatadogProvider/Buffer/PassThroughBuffer.d.ts +7 -0
- package/lib/typescript/core/src/sdk/DatadogProvider/Buffer/bufferNativeCall.d.ts +3 -0
- package/lib/typescript/core/src/sdk/DatadogProvider/DatadogProvider.d.ts +26 -0
- package/lib/typescript/core/src/sdk/DdSdk.d.ts +3 -0
- package/lib/typescript/core/src/sdk/EventMappers/EventMapper.d.ts +24 -0
- package/lib/typescript/core/src/sdk/EventMappers/utils/deepClone.d.ts +10 -0
- package/lib/typescript/core/src/sdk/UserInfoSingleton/UserInfoSingleton.d.ts +12 -0
- package/lib/typescript/core/src/sdk/UserInfoSingleton/types.d.ts +6 -0
- package/lib/typescript/core/src/specs/NativeDdLogs.d.ts +69 -0
- package/lib/typescript/core/src/specs/NativeDdRum.d.ts +92 -0
- package/lib/typescript/core/src/specs/NativeDdSdk.d.ts +46 -0
- package/lib/typescript/core/src/specs/NativeDdTrace.d.ts +23 -0
- package/lib/typescript/core/src/trace/DdTrace.d.ts +3 -0
- package/lib/typescript/core/src/types.d.ts +81 -0
- package/lib/typescript/core/src/utils/TimeProvider.d.ts +20 -0
- package/lib/typescript/core/src/utils/Timer.d.ts +21 -0
- package/lib/typescript/core/src/utils/errorUtils.d.ts +14 -0
- package/lib/typescript/core/src/utils/jsUtils.d.ts +1 -0
- package/lib/typescript/core/src/utils/longTasksUtils.d.ts +6 -0
- package/lib/typescript/core/src/version.d.ts +1 -0
- package/lib/typescript/react-native-apollo-client/src/DatadogLink.d.ts +4 -0
- package/lib/typescript/react-native-apollo-client/src/helpers.d.ts +7 -0
- package/lib/typescript/react-native-apollo-client/src/index.d.ts +1 -0
- package/package.json +82 -0
- package/src/DatadogLink.ts +46 -0
- package/src/__tests__/__utils__/createCat.json +125 -0
- package/src/__tests__/__utils__/getCountries.json +103 -0
- package/src/__tests__/__utils__/getCountry.json +96 -0
- package/src/__tests__/__utils__/operationMock.ts +32 -0
- package/src/__tests__/helpers.test.ts +65 -0
- package/src/helpers.ts +54 -0
- package/src/index.ts +7 -0
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
{
|
|
2
|
+
"variables": {},
|
|
3
|
+
"extensions": {},
|
|
4
|
+
"query": {
|
|
5
|
+
"kind": "Document",
|
|
6
|
+
"definitions": [
|
|
7
|
+
{
|
|
8
|
+
"kind": "OperationDefinition",
|
|
9
|
+
"operation": "query",
|
|
10
|
+
"variableDefinitions": [],
|
|
11
|
+
"directives": [],
|
|
12
|
+
"selectionSet": {
|
|
13
|
+
"kind": "SelectionSet",
|
|
14
|
+
"selections": [
|
|
15
|
+
{
|
|
16
|
+
"kind": "Field",
|
|
17
|
+
"name": { "kind": "Name", "value": "countries" },
|
|
18
|
+
"arguments": [
|
|
19
|
+
{
|
|
20
|
+
"kind": "Argument",
|
|
21
|
+
"name": {
|
|
22
|
+
"kind": "Name",
|
|
23
|
+
"value": "filter"
|
|
24
|
+
},
|
|
25
|
+
"value": {
|
|
26
|
+
"kind": "ObjectValue",
|
|
27
|
+
"fields": [
|
|
28
|
+
{
|
|
29
|
+
"kind": "ObjectField",
|
|
30
|
+
"name": {
|
|
31
|
+
"kind": "Name",
|
|
32
|
+
"value": "continent"
|
|
33
|
+
},
|
|
34
|
+
"value": {
|
|
35
|
+
"kind": "ObjectValue",
|
|
36
|
+
"fields": [
|
|
37
|
+
{
|
|
38
|
+
"kind": "ObjectField",
|
|
39
|
+
"name": {
|
|
40
|
+
"kind": "Name",
|
|
41
|
+
"value": "eq"
|
|
42
|
+
},
|
|
43
|
+
"value": {
|
|
44
|
+
"kind": "StringValue",
|
|
45
|
+
"value": "EU",
|
|
46
|
+
"block": false
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
]
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
]
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
],
|
|
56
|
+
"directives": [],
|
|
57
|
+
"selectionSet": {
|
|
58
|
+
"kind": "SelectionSet",
|
|
59
|
+
"selections": [
|
|
60
|
+
{
|
|
61
|
+
"kind": "Field",
|
|
62
|
+
"name": {
|
|
63
|
+
"kind": "Name",
|
|
64
|
+
"value": "name"
|
|
65
|
+
},
|
|
66
|
+
"arguments": [],
|
|
67
|
+
"directives": []
|
|
68
|
+
},
|
|
69
|
+
{
|
|
70
|
+
"kind": "Field",
|
|
71
|
+
"name": {
|
|
72
|
+
"kind": "Name",
|
|
73
|
+
"value": "emoji"
|
|
74
|
+
},
|
|
75
|
+
"arguments": [],
|
|
76
|
+
"directives": []
|
|
77
|
+
},
|
|
78
|
+
{
|
|
79
|
+
"kind": "Field",
|
|
80
|
+
"name": {
|
|
81
|
+
"kind": "Name",
|
|
82
|
+
"value": "code"
|
|
83
|
+
},
|
|
84
|
+
"arguments": [],
|
|
85
|
+
"directives": []
|
|
86
|
+
},
|
|
87
|
+
{
|
|
88
|
+
"kind": "Field",
|
|
89
|
+
"name": {
|
|
90
|
+
"kind": "Name",
|
|
91
|
+
"value": "__typename"
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
]
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
]
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
],
|
|
101
|
+
"loc": { "start": 0, "end": 98 }
|
|
102
|
+
}
|
|
103
|
+
}
|
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
{
|
|
2
|
+
"variables": { "code": "BE" },
|
|
3
|
+
"extensions": {},
|
|
4
|
+
"operationName": "CountryDetails",
|
|
5
|
+
"query": {
|
|
6
|
+
"kind": "Document",
|
|
7
|
+
"definitions": [
|
|
8
|
+
{
|
|
9
|
+
"kind": "OperationDefinition",
|
|
10
|
+
"operation": "query",
|
|
11
|
+
"name": { "kind": "Name", "value": "CountryDetails" },
|
|
12
|
+
"variableDefinitions": [
|
|
13
|
+
{
|
|
14
|
+
"kind": "VariableDefinition",
|
|
15
|
+
"variable": {
|
|
16
|
+
"kind": "Variable",
|
|
17
|
+
"name": { "kind": "Name", "value": "code" }
|
|
18
|
+
},
|
|
19
|
+
"type": {
|
|
20
|
+
"kind": "NonNullType",
|
|
21
|
+
"type": {
|
|
22
|
+
"kind": "NamedType",
|
|
23
|
+
"name": { "kind": "Name", "value": "ID" }
|
|
24
|
+
}
|
|
25
|
+
},
|
|
26
|
+
"directives": []
|
|
27
|
+
}
|
|
28
|
+
],
|
|
29
|
+
"directives": [],
|
|
30
|
+
"selectionSet": {
|
|
31
|
+
"kind": "SelectionSet",
|
|
32
|
+
"selections": [
|
|
33
|
+
{
|
|
34
|
+
"kind": "Field",
|
|
35
|
+
"name": { "kind": "Name", "value": "country" },
|
|
36
|
+
"arguments": [
|
|
37
|
+
{
|
|
38
|
+
"kind": "Argument",
|
|
39
|
+
"name": { "kind": "Name", "value": "code" },
|
|
40
|
+
"value": {
|
|
41
|
+
"kind": "Variable",
|
|
42
|
+
"name": {
|
|
43
|
+
"kind": "Name",
|
|
44
|
+
"value": "code"
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
],
|
|
49
|
+
"directives": [],
|
|
50
|
+
"selectionSet": {
|
|
51
|
+
"kind": "SelectionSet",
|
|
52
|
+
"selections": [
|
|
53
|
+
{
|
|
54
|
+
"kind": "Field",
|
|
55
|
+
"name": {
|
|
56
|
+
"kind": "Name",
|
|
57
|
+
"value": "name"
|
|
58
|
+
},
|
|
59
|
+
"arguments": [],
|
|
60
|
+
"directives": []
|
|
61
|
+
},
|
|
62
|
+
{
|
|
63
|
+
"kind": "Field",
|
|
64
|
+
"name": {
|
|
65
|
+
"kind": "Name",
|
|
66
|
+
"value": "emoji"
|
|
67
|
+
},
|
|
68
|
+
"arguments": [],
|
|
69
|
+
"directives": []
|
|
70
|
+
},
|
|
71
|
+
{
|
|
72
|
+
"kind": "Field",
|
|
73
|
+
"name": {
|
|
74
|
+
"kind": "Name",
|
|
75
|
+
"value": "capital"
|
|
76
|
+
},
|
|
77
|
+
"arguments": [],
|
|
78
|
+
"directives": []
|
|
79
|
+
},
|
|
80
|
+
{
|
|
81
|
+
"kind": "Field",
|
|
82
|
+
"name": {
|
|
83
|
+
"kind": "Name",
|
|
84
|
+
"value": "__typename"
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
]
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
]
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
],
|
|
94
|
+
"loc": { "start": 0, "end": 112 }
|
|
95
|
+
}
|
|
96
|
+
}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Unless explicitly stated otherwise all files in this repository are licensed under the Apache License Version 2.0.
|
|
3
|
+
* This product includes software developed at Datadog (https://www.datadoghq.com/).
|
|
4
|
+
* Copyright 2016-Present Datadog, Inc.
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
import type { Operation } from '@apollo/client';
|
|
8
|
+
|
|
9
|
+
import createCat from './createCat.json';
|
|
10
|
+
import getCountries from './getCountries.json';
|
|
11
|
+
import getCountry from './getCountry.json';
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
* - operation type: `"query"`
|
|
15
|
+
* - operation name: `"CountryDetails"`
|
|
16
|
+
* - variables: `{ "code": "BE" }`
|
|
17
|
+
*/
|
|
18
|
+
export const getCountryOperation = (getCountry as unknown) as Operation;
|
|
19
|
+
|
|
20
|
+
/**
|
|
21
|
+
* - operation type: `"query"`
|
|
22
|
+
* - operation name: `undefined`
|
|
23
|
+
* - variables: `{}`
|
|
24
|
+
*/
|
|
25
|
+
export const getCountriesOperation = (getCountries as unknown) as Operation;
|
|
26
|
+
|
|
27
|
+
/**
|
|
28
|
+
* - operation type: `"mutation"`
|
|
29
|
+
* - operation name: `CreateCat`
|
|
30
|
+
* - variables: `{ "name": "Croute", "age": 22 }`
|
|
31
|
+
*/
|
|
32
|
+
export const createCatOperation = (createCat as unknown) as Operation;
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Unless explicitly stated otherwise all files in this repository are licensed under the Apache License Version 2.0.
|
|
3
|
+
* This product includes software developed at Datadog (https://www.datadoghq.com/).
|
|
4
|
+
* Copyright 2016-Present Datadog, Inc.
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
import { getOperationName, getVariables, getOperationType } from '../helpers';
|
|
8
|
+
|
|
9
|
+
import {
|
|
10
|
+
createCatOperation,
|
|
11
|
+
getCountriesOperation,
|
|
12
|
+
getCountryOperation
|
|
13
|
+
} from './__utils__/operationMock';
|
|
14
|
+
|
|
15
|
+
describe('helpers', () => {
|
|
16
|
+
describe('getOperationName', () => {
|
|
17
|
+
it('returns operation name if it exists', () => {
|
|
18
|
+
expect(getOperationName(getCountryOperation)).toBe(
|
|
19
|
+
'CountryDetails'
|
|
20
|
+
);
|
|
21
|
+
});
|
|
22
|
+
it('returns null if the query is unnamed', () => {
|
|
23
|
+
expect(getOperationName(getCountriesOperation)).toBeNull();
|
|
24
|
+
});
|
|
25
|
+
});
|
|
26
|
+
|
|
27
|
+
describe('getVariables', () => {
|
|
28
|
+
it('returns variables as a string if they exist', () => {
|
|
29
|
+
expect(getVariables(getCountryOperation)).toBe('{"code":"BE"}');
|
|
30
|
+
expect(getVariables(getCountriesOperation)).toBe('{}');
|
|
31
|
+
});
|
|
32
|
+
it('returns null if there are no variables', () => {
|
|
33
|
+
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
34
|
+
// @ts-ignore
|
|
35
|
+
expect(getVariables({})).toBeNull();
|
|
36
|
+
});
|
|
37
|
+
it('does not crash if the variables are not serializable', () => {
|
|
38
|
+
// Case of circular reference
|
|
39
|
+
const root = {};
|
|
40
|
+
const child = { root };
|
|
41
|
+
root['circular'] = child;
|
|
42
|
+
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
43
|
+
// @ts-ignore
|
|
44
|
+
expect(getVariables({ variables: { root } })).toBeNull();
|
|
45
|
+
});
|
|
46
|
+
});
|
|
47
|
+
|
|
48
|
+
describe('getOperationType', () => {
|
|
49
|
+
it('returns operation type for a query', () => {
|
|
50
|
+
expect(getOperationType(getCountryOperation)).toBe('query');
|
|
51
|
+
expect(getOperationType(getCountriesOperation)).toBe('query');
|
|
52
|
+
});
|
|
53
|
+
it('returns operation type for a mutation', () => {
|
|
54
|
+
expect(getOperationType(createCatOperation)).toBe('mutation');
|
|
55
|
+
});
|
|
56
|
+
it('does not crash if there is no operation type', () => {
|
|
57
|
+
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
58
|
+
// @ts-ignore
|
|
59
|
+
expect(getOperationType({})).toBeNull();
|
|
60
|
+
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
61
|
+
// @ts-ignore
|
|
62
|
+
expect(getOperationType({ query: { definitions: [] } })).toBeNull();
|
|
63
|
+
});
|
|
64
|
+
});
|
|
65
|
+
});
|
package/src/helpers.ts
ADDED
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Unless explicitly stated otherwise all files in this repository are licensed under the Apache License Version 2.0.
|
|
3
|
+
* This product includes software developed at Datadog (https://www.datadoghq.com/).
|
|
4
|
+
* Copyright 2016-Present Datadog, Inc.
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* NOTE: Do not import from '@apollo/client/utilities' as the package does not exist in Apollo Client < v3.
|
|
9
|
+
*/
|
|
10
|
+
|
|
11
|
+
import type { Operation } from '@apollo/client';
|
|
12
|
+
import type { DefinitionNode, OperationDefinitionNode } from 'graphql';
|
|
13
|
+
|
|
14
|
+
export const getVariables = (operation: Operation): string | null => {
|
|
15
|
+
if (operation.variables) {
|
|
16
|
+
try {
|
|
17
|
+
return JSON.stringify(operation.variables);
|
|
18
|
+
} catch (e) {
|
|
19
|
+
// TODO RUM-1206: telemetry
|
|
20
|
+
return null;
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
return null;
|
|
24
|
+
};
|
|
25
|
+
|
|
26
|
+
export const getOperationName = (operation: Operation): string | null => {
|
|
27
|
+
if (operation.operationName) {
|
|
28
|
+
return operation.operationName;
|
|
29
|
+
}
|
|
30
|
+
return null;
|
|
31
|
+
};
|
|
32
|
+
|
|
33
|
+
const getOperationDefinitionNode = (
|
|
34
|
+
definition: DefinitionNode
|
|
35
|
+
): definition is OperationDefinitionNode => {
|
|
36
|
+
return definition.kind === 'OperationDefinition' && !!definition.operation;
|
|
37
|
+
};
|
|
38
|
+
|
|
39
|
+
export const getOperationType = (
|
|
40
|
+
operation: Operation
|
|
41
|
+
): 'query' | 'mutation' | 'subscription' | null => {
|
|
42
|
+
try {
|
|
43
|
+
return (
|
|
44
|
+
operation.query.definitions
|
|
45
|
+
.filter(getOperationDefinitionNode)
|
|
46
|
+
.map(operationDefinitionNode => {
|
|
47
|
+
return operationDefinitionNode.operation;
|
|
48
|
+
})[0] || null
|
|
49
|
+
);
|
|
50
|
+
} catch (e) {
|
|
51
|
+
// TODO RUM-1206: telemetry
|
|
52
|
+
return null;
|
|
53
|
+
}
|
|
54
|
+
};
|
package/src/index.ts
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Unless explicitly stated otherwise all files in this repository are licensed under the Apache License Version 2.0.
|
|
3
|
+
* This product includes software developed at Datadog (https://www.datadoghq.com/).
|
|
4
|
+
* Copyright 2016-Present Datadog, Inc.
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
export { DatadogLink } from './DatadogLink';
|