@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.
Files changed (87) hide show
  1. package/LICENSE +201 -0
  2. package/README.md +93 -0
  3. package/lib/commonjs/DatadogLink.js +44 -0
  4. package/lib/commonjs/DatadogLink.js.map +1 -0
  5. package/lib/commonjs/helpers.js +58 -0
  6. package/lib/commonjs/helpers.js.map +1 -0
  7. package/lib/commonjs/index.js +14 -0
  8. package/lib/commonjs/index.js.map +1 -0
  9. package/lib/module/DatadogLink.js +32 -0
  10. package/lib/module/DatadogLink.js.map +1 -0
  11. package/lib/module/helpers.js +44 -0
  12. package/lib/module/helpers.js.map +1 -0
  13. package/lib/module/index.js +7 -0
  14. package/lib/module/index.js.map +1 -0
  15. package/lib/typescript/core/src/DdSdkReactNative.d.ts +66 -0
  16. package/lib/typescript/core/src/DdSdkReactNativeConfiguration.d.ts +269 -0
  17. package/lib/typescript/core/src/InternalLog.d.ts +12 -0
  18. package/lib/typescript/core/src/ProxyConfiguration.d.ts +56 -0
  19. package/lib/typescript/core/src/SdkVerbosity.d.ts +9 -0
  20. package/lib/typescript/core/src/TrackingConsent.d.ts +8 -0
  21. package/lib/typescript/core/src/index.d.ts +13 -0
  22. package/lib/typescript/core/src/logs/DdLogs.d.ts +22 -0
  23. package/lib/typescript/core/src/logs/eventMapper.d.ts +11 -0
  24. package/lib/typescript/core/src/logs/types.d.ts +80 -0
  25. package/lib/typescript/core/src/nativeModulesTypes.d.ts +92 -0
  26. package/lib/typescript/core/src/rum/DdRum.d.ts +38 -0
  27. package/lib/typescript/core/src/rum/eventMappers/actionEventMapper.d.ts +21 -0
  28. package/lib/typescript/core/src/rum/eventMappers/errorEventMapper.d.ts +21 -0
  29. package/lib/typescript/core/src/rum/eventMappers/resourceEventMapper.d.ts +24 -0
  30. package/lib/typescript/core/src/rum/instrumentation/DdRumErrorTracking.d.ts +16 -0
  31. package/lib/typescript/core/src/rum/instrumentation/interactionTracking/DdEventsInterceptor.d.ts +15 -0
  32. package/lib/typescript/core/src/rum/instrumentation/interactionTracking/DdRumUserInteractionTracking.d.ts +21 -0
  33. package/lib/typescript/core/src/rum/instrumentation/interactionTracking/EventsInterceptor.d.ts +3 -0
  34. package/lib/typescript/core/src/rum/instrumentation/interactionTracking/NoOpEventsInterceptor.d.ts +4 -0
  35. package/lib/typescript/core/src/rum/instrumentation/interactionTracking/ShallowObjectEqualityChecker.d.ts +7 -0
  36. package/lib/typescript/core/src/rum/instrumentation/interactionTracking/getJsxRuntime.d.ts +1 -0
  37. package/lib/typescript/core/src/rum/instrumentation/resourceTracking/DdRumResourceTracking.d.ts +16 -0
  38. package/lib/typescript/core/src/rum/instrumentation/resourceTracking/distributedTracing/distributedTracing.d.ts +45 -0
  39. package/lib/typescript/core/src/rum/instrumentation/resourceTracking/distributedTracing/distributedTracingHeaders.d.ts +21 -0
  40. package/lib/typescript/core/src/rum/instrumentation/resourceTracking/distributedTracing/firstPartyHosts.d.ts +8 -0
  41. package/lib/typescript/core/src/rum/instrumentation/resourceTracking/graphql/graphqlHeaders.d.ts +4 -0
  42. package/lib/typescript/core/src/rum/instrumentation/resourceTracking/requestProxy/XHRProxy/DatadogRumResource/ResourceReporter.d.ts +8 -0
  43. package/lib/typescript/core/src/rum/instrumentation/resourceTracking/requestProxy/XHRProxy/DatadogRumResource/internalDevResourceBlocklist.d.ts +6 -0
  44. package/lib/typescript/core/src/rum/instrumentation/resourceTracking/requestProxy/XHRProxy/DatadogRumResource/resourceTiming.d.ts +17 -0
  45. package/lib/typescript/core/src/rum/instrumentation/resourceTracking/requestProxy/XHRProxy/URLHostParser.d.ts +6 -0
  46. package/lib/typescript/core/src/rum/instrumentation/resourceTracking/requestProxy/XHRProxy/XHRProxy.d.ts +20 -0
  47. package/lib/typescript/core/src/rum/instrumentation/resourceTracking/requestProxy/XHRProxy/responseSize.d.ts +2 -0
  48. package/lib/typescript/core/src/rum/instrumentation/resourceTracking/requestProxy/interfaces/RequestProxy.d.ts +13 -0
  49. package/lib/typescript/core/src/rum/instrumentation/resourceTracking/requestProxy/interfaces/RumResource.d.ts +27 -0
  50. package/lib/typescript/core/src/rum/types.d.ts +131 -0
  51. package/lib/typescript/core/src/sdk/AttributesSingleton/AttributesSingleton.d.ts +12 -0
  52. package/lib/typescript/core/src/sdk/AttributesSingleton/types.d.ts +3 -0
  53. package/lib/typescript/core/src/sdk/DatadogProvider/Buffer/BoundedBuffer.d.ts +15 -0
  54. package/lib/typescript/core/src/sdk/DatadogProvider/Buffer/BufferSingleton.d.ts +7 -0
  55. package/lib/typescript/core/src/sdk/DatadogProvider/Buffer/DatadogBuffer.d.ts +20 -0
  56. package/lib/typescript/core/src/sdk/DatadogProvider/Buffer/PassThroughBuffer.d.ts +7 -0
  57. package/lib/typescript/core/src/sdk/DatadogProvider/Buffer/bufferNativeCall.d.ts +3 -0
  58. package/lib/typescript/core/src/sdk/DatadogProvider/DatadogProvider.d.ts +26 -0
  59. package/lib/typescript/core/src/sdk/DdSdk.d.ts +3 -0
  60. package/lib/typescript/core/src/sdk/EventMappers/EventMapper.d.ts +24 -0
  61. package/lib/typescript/core/src/sdk/EventMappers/utils/deepClone.d.ts +10 -0
  62. package/lib/typescript/core/src/sdk/UserInfoSingleton/UserInfoSingleton.d.ts +12 -0
  63. package/lib/typescript/core/src/sdk/UserInfoSingleton/types.d.ts +6 -0
  64. package/lib/typescript/core/src/specs/NativeDdLogs.d.ts +69 -0
  65. package/lib/typescript/core/src/specs/NativeDdRum.d.ts +92 -0
  66. package/lib/typescript/core/src/specs/NativeDdSdk.d.ts +46 -0
  67. package/lib/typescript/core/src/specs/NativeDdTrace.d.ts +23 -0
  68. package/lib/typescript/core/src/trace/DdTrace.d.ts +3 -0
  69. package/lib/typescript/core/src/types.d.ts +81 -0
  70. package/lib/typescript/core/src/utils/TimeProvider.d.ts +20 -0
  71. package/lib/typescript/core/src/utils/Timer.d.ts +21 -0
  72. package/lib/typescript/core/src/utils/errorUtils.d.ts +14 -0
  73. package/lib/typescript/core/src/utils/jsUtils.d.ts +1 -0
  74. package/lib/typescript/core/src/utils/longTasksUtils.d.ts +6 -0
  75. package/lib/typescript/core/src/version.d.ts +1 -0
  76. package/lib/typescript/react-native-apollo-client/src/DatadogLink.d.ts +4 -0
  77. package/lib/typescript/react-native-apollo-client/src/helpers.d.ts +7 -0
  78. package/lib/typescript/react-native-apollo-client/src/index.d.ts +1 -0
  79. package/package.json +82 -0
  80. package/src/DatadogLink.ts +46 -0
  81. package/src/__tests__/__utils__/createCat.json +125 -0
  82. package/src/__tests__/__utils__/getCountries.json +103 -0
  83. package/src/__tests__/__utils__/getCountry.json +96 -0
  84. package/src/__tests__/__utils__/operationMock.ts +32 -0
  85. package/src/__tests__/helpers.test.ts +65 -0
  86. package/src/helpers.ts +54 -0
  87. package/src/index.ts +7 -0
package/LICENSE ADDED
@@ -0,0 +1,201 @@
1
+ Apache License
2
+ Version 2.0, January 2004
3
+ http://www.apache.org/licenses/
4
+
5
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
6
+
7
+ 1. Definitions.
8
+
9
+ "License" shall mean the terms and conditions for use, reproduction,
10
+ and distribution as defined by Sections 1 through 9 of this document.
11
+
12
+ "Licensor" shall mean the copyright owner or entity authorized by
13
+ the copyright owner that is granting the License.
14
+
15
+ "Legal Entity" shall mean the union of the acting entity and all
16
+ other entities that control, are controlled by, or are under common
17
+ control with that entity. For the purposes of this definition,
18
+ "control" means (i) the power, direct or indirect, to cause the
19
+ direction or management of such entity, whether by contract or
20
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
21
+ outstanding shares, or (iii) beneficial ownership of such entity.
22
+
23
+ "You" (or "Your") shall mean an individual or Legal Entity
24
+ exercising permissions granted by this License.
25
+
26
+ "Source" form shall mean the preferred form for making modifications,
27
+ including but not limited to software source code, documentation
28
+ source, and configuration files.
29
+
30
+ "Object" form shall mean any form resulting from mechanical
31
+ transformation or translation of a Source form, including but
32
+ not limited to compiled object code, generated documentation,
33
+ and conversions to other media types.
34
+
35
+ "Work" shall mean the work of authorship, whether in Source or
36
+ Object form, made available under the License, as indicated by a
37
+ copyright notice that is included in or attached to the work
38
+ (an example is provided in the Appendix below).
39
+
40
+ "Derivative Works" shall mean any work, whether in Source or Object
41
+ form, that is based on (or derived from) the Work and for which the
42
+ editorial revisions, annotations, elaborations, or other modifications
43
+ represent, as a whole, an original work of authorship. For the purposes
44
+ of this License, Derivative Works shall not include works that remain
45
+ separable from, or merely link (or bind by name) to the interfaces of,
46
+ the Work and Derivative Works thereof.
47
+
48
+ "Contribution" shall mean any work of authorship, including
49
+ the original version of the Work and any modifications or additions
50
+ to that Work or Derivative Works thereof, that is intentionally
51
+ submitted to Licensor for inclusion in the Work by the copyright owner
52
+ or by an individual or Legal Entity authorized to submit on behalf of
53
+ the copyright owner. For the purposes of this definition, "submitted"
54
+ means any form of electronic, verbal, or written communication sent
55
+ to the Licensor or its representatives, including but not limited to
56
+ communication on electronic mailing lists, source code control systems,
57
+ and issue tracking systems that are managed by, or on behalf of, the
58
+ Licensor for the purpose of discussing and improving the Work, but
59
+ excluding communication that is conspicuously marked or otherwise
60
+ designated in writing by the copyright owner as "Not a Contribution."
61
+
62
+ "Contributor" shall mean Licensor and any individual or Legal Entity
63
+ on behalf of whom a Contribution has been received by Licensor and
64
+ subsequently incorporated within the Work.
65
+
66
+ 2. Grant of Copyright License. Subject to the terms and conditions of
67
+ this License, each Contributor hereby grants to You a perpetual,
68
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
69
+ copyright license to reproduce, prepare Derivative Works of,
70
+ publicly display, publicly perform, sublicense, and distribute the
71
+ Work and such Derivative Works in Source or Object form.
72
+
73
+ 3. Grant of Patent License. Subject to the terms and conditions of
74
+ this License, each Contributor hereby grants to You a perpetual,
75
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
76
+ (except as stated in this section) patent license to make, have made,
77
+ use, offer to sell, sell, import, and otherwise transfer the Work,
78
+ where such license applies only to those patent claims licensable
79
+ by such Contributor that are necessarily infringed by their
80
+ Contribution(s) alone or by combination of their Contribution(s)
81
+ with the Work to which such Contribution(s) was submitted. If You
82
+ institute patent litigation against any entity (including a
83
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
84
+ or a Contribution incorporated within the Work constitutes direct
85
+ or contributory patent infringement, then any patent licenses
86
+ granted to You under this License for that Work shall terminate
87
+ as of the date such litigation is filed.
88
+
89
+ 4. Redistribution. You may reproduce and distribute copies of the
90
+ Work or Derivative Works thereof in any medium, with or without
91
+ modifications, and in Source or Object form, provided that You
92
+ meet the following conditions:
93
+
94
+ (a) You must give any other recipients of the Work or
95
+ Derivative Works a copy of this License; and
96
+
97
+ (b) You must cause any modified files to carry prominent notices
98
+ stating that You changed the files; and
99
+
100
+ (c) You must retain, in the Source form of any Derivative Works
101
+ that You distribute, all copyright, patent, trademark, and
102
+ attribution notices from the Source form of the Work,
103
+ excluding those notices that do not pertain to any part of
104
+ the Derivative Works; and
105
+
106
+ (d) If the Work includes a "NOTICE" text file as part of its
107
+ distribution, then any Derivative Works that You distribute must
108
+ include a readable copy of the attribution notices contained
109
+ within such NOTICE file, excluding those notices that do not
110
+ pertain to any part of the Derivative Works, in at least one
111
+ of the following places: within a NOTICE text file distributed
112
+ as part of the Derivative Works; within the Source form or
113
+ documentation, if provided along with the Derivative Works; or,
114
+ within a display generated by the Derivative Works, if and
115
+ wherever such third-party notices normally appear. The contents
116
+ of the NOTICE file are for informational purposes only and
117
+ do not modify the License. You may add Your own attribution
118
+ notices within Derivative Works that You distribute, alongside
119
+ or as an addendum to the NOTICE text from the Work, provided
120
+ that such additional attribution notices cannot be construed
121
+ as modifying the License.
122
+
123
+ You may add Your own copyright statement to Your modifications and
124
+ may provide additional or different license terms and conditions
125
+ for use, reproduction, or distribution of Your modifications, or
126
+ for any such Derivative Works as a whole, provided Your use,
127
+ reproduction, and distribution of the Work otherwise complies with
128
+ the conditions stated in this License.
129
+
130
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
131
+ any Contribution intentionally submitted for inclusion in the Work
132
+ by You to the Licensor shall be under the terms and conditions of
133
+ this License, without any additional terms or conditions.
134
+ Notwithstanding the above, nothing herein shall supersede or modify
135
+ the terms of any separate license agreement you may have executed
136
+ with Licensor regarding such Contributions.
137
+
138
+ 6. Trademarks. This License does not grant permission to use the trade
139
+ names, trademarks, service marks, or product names of the Licensor,
140
+ except as required for reasonable and customary use in describing the
141
+ origin of the Work and reproducing the content of the NOTICE file.
142
+
143
+ 7. Disclaimer of Warranty. Unless required by applicable law or
144
+ agreed to in writing, Licensor provides the Work (and each
145
+ Contributor provides its Contributions) on an "AS IS" BASIS,
146
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
147
+ implied, including, without limitation, any warranties or conditions
148
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
149
+ PARTICULAR PURPOSE. You are solely responsible for determining the
150
+ appropriateness of using or redistributing the Work and assume any
151
+ risks associated with Your exercise of permissions under this License.
152
+
153
+ 8. Limitation of Liability. In no event and under no legal theory,
154
+ whether in tort (including negligence), contract, or otherwise,
155
+ unless required by applicable law (such as deliberate and grossly
156
+ negligent acts) or agreed to in writing, shall any Contributor be
157
+ liable to You for damages, including any direct, indirect, special,
158
+ incidental, or consequential damages of any character arising as a
159
+ result of this License or out of the use or inability to use the
160
+ Work (including but not limited to damages for loss of goodwill,
161
+ work stoppage, computer failure or malfunction, or any and all
162
+ other commercial damages or losses), even if such Contributor
163
+ has been advised of the possibility of such damages.
164
+
165
+ 9. Accepting Warranty or Additional Liability. While redistributing
166
+ the Work or Derivative Works thereof, You may choose to offer,
167
+ and charge a fee for, acceptance of support, warranty, indemnity,
168
+ or other liability obligations and/or rights consistent with this
169
+ License. However, in accepting such obligations, You may act only
170
+ on Your own behalf and on Your sole responsibility, not on behalf
171
+ of any other Contributor, and only if You agree to indemnify,
172
+ defend, and hold each Contributor harmless for any liability
173
+ incurred by, or claims asserted against, such Contributor by reason
174
+ of your accepting any such warranty or additional liability.
175
+
176
+ END OF TERMS AND CONDITIONS
177
+
178
+ APPENDIX: How to apply the Apache License to your work.
179
+
180
+ To apply the Apache License to your work, attach the following
181
+ boilerplate notice, with the fields enclosed by brackets "{}"
182
+ replaced with your own identifying information. (Don't include
183
+ the brackets!) The text should be enclosed in the appropriate
184
+ comment syntax for the file format. We also recommend that a
185
+ file or class name and description of purpose be included on the
186
+ same "printed page" as the copyright notice for easier
187
+ identification within third-party archives.
188
+
189
+ Copyright 2017 Datadog, Inc.
190
+
191
+ Licensed under the Apache License, Version 2.0 (the "License");
192
+ you may not use this file except in compliance with the License.
193
+ You may obtain a copy of the License at
194
+
195
+ http://www.apache.org/licenses/LICENSE-2.0
196
+
197
+ Unless required by applicable law or agreed to in writing, software
198
+ distributed under the License is distributed on an "AS IS" BASIS,
199
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
200
+ See the License for the specific language governing permissions and
201
+ limitations under the License.
package/README.md ADDED
@@ -0,0 +1,93 @@
1
+ # React-Native Monitoring for @apollo/client
2
+
3
+ ## Notice: this integration is not ready for production
4
+
5
+ Adding the GraphQL integration does not change any existing features. The information is not surfaced on the Datadog platform yet.
6
+
7
+ ## Overview
8
+
9
+ Monitor your GraphQL resources with Real User Monitoring (RUM) and perform the following:
10
+
11
+ - Identify GraphQL queries and mutations
12
+ - Identify GraphQL variables used in queries and mutations
13
+
14
+ RUM supports GraphQL requests created using [@apollo/client][2].
15
+
16
+ ## Setup
17
+
18
+ ### Prerequisites
19
+
20
+ Set up the RUM React Native SDK on your mobile React Native application. For more information, see [RUM React Native Monitoring][1].
21
+
22
+ Add `@apollo/client` to your application following the [official installation documentation][3].
23
+
24
+ ### Instrument your ApolloClient
25
+
26
+ #### Migrate to HttpLink
27
+
28
+ If you initialize your ApolloClient with the `uri` parameter, initialize it with a `HttpLink`:
29
+
30
+ ```javascript
31
+ import { ApolloClient, HttpLink } from '@apollo/client';
32
+
33
+ // before
34
+ const apolloClient = new ApolloClient({
35
+ uri: 'https://my.api.com/graphql'
36
+ });
37
+
38
+ // after
39
+ const apolloClient = new ApolloClient({
40
+ link: new HttpLink({ uri: 'https://my.api.com/graphql' })
41
+ });
42
+ ```
43
+
44
+ #### Use the Datadog Apollo Client Link to collect information
45
+
46
+ Import `DatadogLink` from `@datadog/mobile-react-native-apollo-client` and use it in your ApolloClient initialization:
47
+
48
+ ```javascript
49
+ import { ApolloClient, from, HttpLink } from '@apollo/client';
50
+ import { DatadogLink } from '@datadog/mobile-react-native-apollo-client';
51
+
52
+ const apolloClient = new ApolloClient({
53
+ link: from([
54
+ new DatadogLink(),
55
+ new HttpLink({ uri: 'https://my.api.com/graphql' }) // always in last position
56
+ ])
57
+ });
58
+ ```
59
+
60
+ For more information on Apollo Client Links, refer to the [official documentation][4].
61
+
62
+ ### Removing GraphQL information
63
+
64
+ Use a `resourceEventMapper` in your Datadog configuration to remove sensitive data from GraphQL variables:
65
+
66
+ ```javascript
67
+ const datadogConfiguration = new DatadogProviderConfiguration(
68
+ '<CLIENT_TOKEN>',
69
+ '<ENVIRONMENT_NAME>',
70
+ '<RUM_APPLICATION_ID>',
71
+ true,
72
+ true,
73
+ true
74
+ );
75
+
76
+ datadogConfiguration.resourceEventMapper = event => {
77
+ // Variables are stored in event.context['_dd.graphql.variables'] as a JSON string when present
78
+ if (event.context['_dd.graphql.variables']) {
79
+ const variables = JSON.parse(event.context['_dd.graphql.variables']);
80
+ if (variables.password) {
81
+ variables.password = '***';
82
+ }
83
+ event.context['_dd.graphql.variables'] = JSON.stringify(variables);
84
+ }
85
+
86
+ return event;
87
+ };
88
+ ```
89
+
90
+ [1]: https://docs.datadoghq.com/real_user_monitoring/reactnative/
91
+ [2]: https://www.apollographql.com/docs/react/
92
+ [3]: https://www.apollographql.com/docs/react/get-started
93
+ [4]: https://www.apollographql.com/docs/react/api/link/introduction/
@@ -0,0 +1,44 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.DatadogLink = void 0;
7
+
8
+ var _client = require("@apollo/client");
9
+
10
+ var _mobileReactNative = require("@datadog/mobile-react-native");
11
+
12
+ var _helpers = require("./helpers");
13
+
14
+ /*
15
+ * Unless explicitly stated otherwise all files in this repository are licensed under the Apache License Version 2.0.
16
+ * This product includes software developed at Datadog (https://www.datadoghq.com/).
17
+ * Copyright 2016-Present Datadog, Inc.
18
+ */
19
+ class DatadogLink extends _client.ApolloLink {
20
+ constructor() {
21
+ super((operation, forward) => {
22
+ const operationName = (0, _helpers.getOperationName)(operation);
23
+ const formattedVariables = (0, _helpers.getVariables)(operation);
24
+ const operationType = (0, _helpers.getOperationType)(operation);
25
+ operation.setContext(({
26
+ headers = {}
27
+ }) => {
28
+ const newHeaders = { ...headers
29
+ };
30
+ newHeaders[_mobileReactNative.DATADOG_GRAPH_QL_OPERATION_TYPE_HEADER] = operationType;
31
+ newHeaders[_mobileReactNative.DATADOG_GRAPH_QL_OPERATION_NAME_HEADER] = operationName;
32
+ newHeaders[_mobileReactNative.DATADOG_GRAPH_QL_VARIABLES_HEADER] = formattedVariables;
33
+ return {
34
+ headers: newHeaders
35
+ };
36
+ });
37
+ return forward(operation);
38
+ });
39
+ }
40
+
41
+ }
42
+
43
+ exports.DatadogLink = DatadogLink;
44
+ //# sourceMappingURL=DatadogLink.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["DatadogLink.ts"],"names":["DatadogLink","ApolloLink","constructor","operation","forward","operationName","formattedVariables","operationType","setContext","headers","newHeaders","DATADOG_GRAPH_QL_OPERATION_TYPE_HEADER","DATADOG_GRAPH_QL_OPERATION_NAME_HEADER","DATADOG_GRAPH_QL_VARIABLES_HEADER"],"mappings":";;;;;;;AAMA;;AACA;;AAMA;;AAbA;AACA;AACA;AACA;AACA;AAWO,MAAMA,WAAN,SAA0BC,kBAA1B,CAAqC;AACxCC,EAAAA,WAAW,GAAG;AACV,UAAM,CAACC,SAAD,EAAYC,OAAZ,KAAwB;AAC1B,YAAMC,aAAa,GAAG,+BAAiBF,SAAjB,CAAtB;AACA,YAAMG,kBAAkB,GAAG,2BAAaH,SAAb,CAA3B;AACA,YAAMI,aAAa,GAAG,+BAAiBJ,SAAjB,CAAtB;AAEAA,MAAAA,SAAS,CAACK,UAAV,CAAqB,CAAC;AAAEC,QAAAA,OAAO,GAAG;AAAZ,OAAD,KAAsB;AACvC,cAAMC,UAAyC,GAAG,EAC9C,GAAGD;AAD2C,SAAlD;AAIAC,QAAAA,UAAU,CACNC,yDADM,CAAV,GAEIJ,aAFJ;AAGAG,QAAAA,UAAU,CACNE,yDADM,CAAV,GAEIP,aAFJ;AAGAK,QAAAA,UAAU,CACNG,oDADM,CAAV,GAEIP,kBAFJ;AAIA,eAAO;AACHG,UAAAA,OAAO,EAAEC;AADN,SAAP;AAGH,OAlBD;AAoBA,aAAON,OAAO,CAACD,SAAD,CAAd;AACH,KA1BD;AA2BH;;AA7BuC","sourcesContent":["/*\n * Unless explicitly stated otherwise all files in this repository are licensed under the Apache License Version 2.0.\n * This product includes software developed at Datadog (https://www.datadoghq.com/).\n * Copyright 2016-Present Datadog, Inc.\n */\n\nimport { ApolloLink } from '@apollo/client';\nimport {\n DATADOG_GRAPH_QL_OPERATION_TYPE_HEADER,\n DATADOG_GRAPH_QL_OPERATION_NAME_HEADER,\n DATADOG_GRAPH_QL_VARIABLES_HEADER\n} from '@datadog/mobile-react-native';\n\nimport { getOperationName, getVariables, getOperationType } from './helpers';\n\nexport class DatadogLink extends ApolloLink {\n constructor() {\n super((operation, forward) => {\n const operationName = getOperationName(operation);\n const formattedVariables = getVariables(operation);\n const operationType = getOperationType(operation);\n\n operation.setContext(({ headers = {} }) => {\n const newHeaders: Record<string, string | null> = {\n ...headers\n };\n\n newHeaders[\n DATADOG_GRAPH_QL_OPERATION_TYPE_HEADER\n ] = operationType;\n newHeaders[\n DATADOG_GRAPH_QL_OPERATION_NAME_HEADER\n ] = operationName;\n newHeaders[\n DATADOG_GRAPH_QL_VARIABLES_HEADER\n ] = formattedVariables;\n\n return {\n headers: newHeaders\n };\n });\n\n return forward(operation);\n });\n }\n}\n"]}
@@ -0,0 +1,58 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.getOperationType = exports.getOperationName = exports.getVariables = void 0;
7
+
8
+ /*
9
+ * Unless explicitly stated otherwise all files in this repository are licensed under the Apache License Version 2.0.
10
+ * This product includes software developed at Datadog (https://www.datadoghq.com/).
11
+ * Copyright 2016-Present Datadog, Inc.
12
+ */
13
+
14
+ /**
15
+ * NOTE: Do not import from '@apollo/client/utilities' as the package does not exist in Apollo Client < v3.
16
+ */
17
+ const getVariables = operation => {
18
+ if (operation.variables) {
19
+ try {
20
+ return JSON.stringify(operation.variables);
21
+ } catch (e) {
22
+ // TODO RUM-1206: telemetry
23
+ return null;
24
+ }
25
+ }
26
+
27
+ return null;
28
+ };
29
+
30
+ exports.getVariables = getVariables;
31
+
32
+ const getOperationName = operation => {
33
+ if (operation.operationName) {
34
+ return operation.operationName;
35
+ }
36
+
37
+ return null;
38
+ };
39
+
40
+ exports.getOperationName = getOperationName;
41
+
42
+ const getOperationDefinitionNode = definition => {
43
+ return definition.kind === 'OperationDefinition' && !!definition.operation;
44
+ };
45
+
46
+ const getOperationType = operation => {
47
+ try {
48
+ return operation.query.definitions.filter(getOperationDefinitionNode).map(operationDefinitionNode => {
49
+ return operationDefinitionNode.operation;
50
+ })[0] || null;
51
+ } catch (e) {
52
+ // TODO RUM-1206: telemetry
53
+ return null;
54
+ }
55
+ };
56
+
57
+ exports.getOperationType = getOperationType;
58
+ //# sourceMappingURL=helpers.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["helpers.ts"],"names":["getVariables","operation","variables","JSON","stringify","e","getOperationName","operationName","getOperationDefinitionNode","definition","kind","getOperationType","query","definitions","filter","map","operationDefinitionNode"],"mappings":";;;;;;;AAAA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AAKO,MAAMA,YAAY,GAAIC,SAAD,IAAyC;AACjE,MAAIA,SAAS,CAACC,SAAd,EAAyB;AACrB,QAAI;AACA,aAAOC,IAAI,CAACC,SAAL,CAAeH,SAAS,CAACC,SAAzB,CAAP;AACH,KAFD,CAEE,OAAOG,CAAP,EAAU;AACR;AACA,aAAO,IAAP;AACH;AACJ;;AACD,SAAO,IAAP;AACH,CAVM;;;;AAYA,MAAMC,gBAAgB,GAAIL,SAAD,IAAyC;AACrE,MAAIA,SAAS,CAACM,aAAd,EAA6B;AACzB,WAAON,SAAS,CAACM,aAAjB;AACH;;AACD,SAAO,IAAP;AACH,CALM;;;;AAOP,MAAMC,0BAA0B,GAC5BC,UAD+B,IAES;AACxC,SAAOA,UAAU,CAACC,IAAX,KAAoB,qBAApB,IAA6C,CAAC,CAACD,UAAU,CAACR,SAAjE;AACH,CAJD;;AAMO,MAAMU,gBAAgB,GACzBV,SAD4B,IAEmB;AAC/C,MAAI;AACA,WACIA,SAAS,CAACW,KAAV,CAAgBC,WAAhB,CACKC,MADL,CACYN,0BADZ,EAEKO,GAFL,CAESC,uBAAuB,IAAI;AAC5B,aAAOA,uBAAuB,CAACf,SAA/B;AACH,KAJL,EAIO,CAJP,KAIa,IALjB;AAOH,GARD,CAQE,OAAOI,CAAP,EAAU;AACR;AACA,WAAO,IAAP;AACH;AACJ,CAfM","sourcesContent":["/*\n * Unless explicitly stated otherwise all files in this repository are licensed under the Apache License Version 2.0.\n * This product includes software developed at Datadog (https://www.datadoghq.com/).\n * Copyright 2016-Present Datadog, Inc.\n */\n\n/**\n * NOTE: Do not import from '@apollo/client/utilities' as the package does not exist in Apollo Client < v3.\n */\n\nimport type { Operation } from '@apollo/client';\nimport type { DefinitionNode, OperationDefinitionNode } from 'graphql';\n\nexport const getVariables = (operation: Operation): string | null => {\n if (operation.variables) {\n try {\n return JSON.stringify(operation.variables);\n } catch (e) {\n // TODO RUM-1206: telemetry\n return null;\n }\n }\n return null;\n};\n\nexport const getOperationName = (operation: Operation): string | null => {\n if (operation.operationName) {\n return operation.operationName;\n }\n return null;\n};\n\nconst getOperationDefinitionNode = (\n definition: DefinitionNode\n): definition is OperationDefinitionNode => {\n return definition.kind === 'OperationDefinition' && !!definition.operation;\n};\n\nexport const getOperationType = (\n operation: Operation\n): 'query' | 'mutation' | 'subscription' | null => {\n try {\n return (\n operation.query.definitions\n .filter(getOperationDefinitionNode)\n .map(operationDefinitionNode => {\n return operationDefinitionNode.operation;\n })[0] || null\n );\n } catch (e) {\n // TODO RUM-1206: telemetry\n return null;\n }\n};\n"]}
@@ -0,0 +1,14 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ Object.defineProperty(exports, "DatadogLink", {
7
+ enumerable: true,
8
+ get: function () {
9
+ return _DatadogLink.DatadogLink;
10
+ }
11
+ });
12
+
13
+ var _DatadogLink = require("./DatadogLink");
14
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["index.ts"],"names":[],"mappings":";;;;;;;;;;;;AAMA","sourcesContent":["/*\n * Unless explicitly stated otherwise all files in this repository are licensed under the Apache License Version 2.0.\n * This product includes software developed at Datadog (https://www.datadoghq.com/).\n * Copyright 2016-Present Datadog, Inc.\n */\n\nexport { DatadogLink } from './DatadogLink';\n"]}
@@ -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
+ import { ApolloLink } from '@apollo/client';
7
+ import { DATADOG_GRAPH_QL_OPERATION_TYPE_HEADER, DATADOG_GRAPH_QL_OPERATION_NAME_HEADER, DATADOG_GRAPH_QL_VARIABLES_HEADER } from '@datadog/mobile-react-native';
8
+ import { getOperationName, getVariables, getOperationType } from './helpers';
9
+ export class DatadogLink extends ApolloLink {
10
+ constructor() {
11
+ super((operation, forward) => {
12
+ const operationName = getOperationName(operation);
13
+ const formattedVariables = getVariables(operation);
14
+ const operationType = getOperationType(operation);
15
+ operation.setContext(({
16
+ headers = {}
17
+ }) => {
18
+ const newHeaders = { ...headers
19
+ };
20
+ newHeaders[DATADOG_GRAPH_QL_OPERATION_TYPE_HEADER] = operationType;
21
+ newHeaders[DATADOG_GRAPH_QL_OPERATION_NAME_HEADER] = operationName;
22
+ newHeaders[DATADOG_GRAPH_QL_VARIABLES_HEADER] = formattedVariables;
23
+ return {
24
+ headers: newHeaders
25
+ };
26
+ });
27
+ return forward(operation);
28
+ });
29
+ }
30
+
31
+ }
32
+ //# sourceMappingURL=DatadogLink.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["DatadogLink.ts"],"names":["ApolloLink","DATADOG_GRAPH_QL_OPERATION_TYPE_HEADER","DATADOG_GRAPH_QL_OPERATION_NAME_HEADER","DATADOG_GRAPH_QL_VARIABLES_HEADER","getOperationName","getVariables","getOperationType","DatadogLink","constructor","operation","forward","operationName","formattedVariables","operationType","setContext","headers","newHeaders"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AAEA,SAASA,UAAT,QAA2B,gBAA3B;AACA,SACIC,sCADJ,EAEIC,sCAFJ,EAGIC,iCAHJ,QAIO,8BAJP;AAMA,SAASC,gBAAT,EAA2BC,YAA3B,EAAyCC,gBAAzC,QAAiE,WAAjE;AAEA,OAAO,MAAMC,WAAN,SAA0BP,UAA1B,CAAqC;AACxCQ,EAAAA,WAAW,GAAG;AACV,UAAM,CAACC,SAAD,EAAYC,OAAZ,KAAwB;AAC1B,YAAMC,aAAa,GAAGP,gBAAgB,CAACK,SAAD,CAAtC;AACA,YAAMG,kBAAkB,GAAGP,YAAY,CAACI,SAAD,CAAvC;AACA,YAAMI,aAAa,GAAGP,gBAAgB,CAACG,SAAD,CAAtC;AAEAA,MAAAA,SAAS,CAACK,UAAV,CAAqB,CAAC;AAAEC,QAAAA,OAAO,GAAG;AAAZ,OAAD,KAAsB;AACvC,cAAMC,UAAyC,GAAG,EAC9C,GAAGD;AAD2C,SAAlD;AAIAC,QAAAA,UAAU,CACNf,sCADM,CAAV,GAEIY,aAFJ;AAGAG,QAAAA,UAAU,CACNd,sCADM,CAAV,GAEIS,aAFJ;AAGAK,QAAAA,UAAU,CACNb,iCADM,CAAV,GAEIS,kBAFJ;AAIA,eAAO;AACHG,UAAAA,OAAO,EAAEC;AADN,SAAP;AAGH,OAlBD;AAoBA,aAAON,OAAO,CAACD,SAAD,CAAd;AACH,KA1BD;AA2BH;;AA7BuC","sourcesContent":["/*\n * Unless explicitly stated otherwise all files in this repository are licensed under the Apache License Version 2.0.\n * This product includes software developed at Datadog (https://www.datadoghq.com/).\n * Copyright 2016-Present Datadog, Inc.\n */\n\nimport { ApolloLink } from '@apollo/client';\nimport {\n DATADOG_GRAPH_QL_OPERATION_TYPE_HEADER,\n DATADOG_GRAPH_QL_OPERATION_NAME_HEADER,\n DATADOG_GRAPH_QL_VARIABLES_HEADER\n} from '@datadog/mobile-react-native';\n\nimport { getOperationName, getVariables, getOperationType } from './helpers';\n\nexport class DatadogLink extends ApolloLink {\n constructor() {\n super((operation, forward) => {\n const operationName = getOperationName(operation);\n const formattedVariables = getVariables(operation);\n const operationType = getOperationType(operation);\n\n operation.setContext(({ headers = {} }) => {\n const newHeaders: Record<string, string | null> = {\n ...headers\n };\n\n newHeaders[\n DATADOG_GRAPH_QL_OPERATION_TYPE_HEADER\n ] = operationType;\n newHeaders[\n DATADOG_GRAPH_QL_OPERATION_NAME_HEADER\n ] = operationName;\n newHeaders[\n DATADOG_GRAPH_QL_VARIABLES_HEADER\n ] = formattedVariables;\n\n return {\n headers: newHeaders\n };\n });\n\n return forward(operation);\n });\n }\n}\n"]}
@@ -0,0 +1,44 @@
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
+ export const getVariables = operation => {
11
+ if (operation.variables) {
12
+ try {
13
+ return JSON.stringify(operation.variables);
14
+ } catch (e) {
15
+ // TODO RUM-1206: telemetry
16
+ return null;
17
+ }
18
+ }
19
+
20
+ return null;
21
+ };
22
+ export const getOperationName = operation => {
23
+ if (operation.operationName) {
24
+ return operation.operationName;
25
+ }
26
+
27
+ return null;
28
+ };
29
+
30
+ const getOperationDefinitionNode = definition => {
31
+ return definition.kind === 'OperationDefinition' && !!definition.operation;
32
+ };
33
+
34
+ export const getOperationType = operation => {
35
+ try {
36
+ return operation.query.definitions.filter(getOperationDefinitionNode).map(operationDefinitionNode => {
37
+ return operationDefinitionNode.operation;
38
+ })[0] || null;
39
+ } catch (e) {
40
+ // TODO RUM-1206: telemetry
41
+ return null;
42
+ }
43
+ };
44
+ //# sourceMappingURL=helpers.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["helpers.ts"],"names":["getVariables","operation","variables","JSON","stringify","e","getOperationName","operationName","getOperationDefinitionNode","definition","kind","getOperationType","query","definitions","filter","map","operationDefinitionNode"],"mappings":"AAAA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AAKA,OAAO,MAAMA,YAAY,GAAIC,SAAD,IAAyC;AACjE,MAAIA,SAAS,CAACC,SAAd,EAAyB;AACrB,QAAI;AACA,aAAOC,IAAI,CAACC,SAAL,CAAeH,SAAS,CAACC,SAAzB,CAAP;AACH,KAFD,CAEE,OAAOG,CAAP,EAAU;AACR;AACA,aAAO,IAAP;AACH;AACJ;;AACD,SAAO,IAAP;AACH,CAVM;AAYP,OAAO,MAAMC,gBAAgB,GAAIL,SAAD,IAAyC;AACrE,MAAIA,SAAS,CAACM,aAAd,EAA6B;AACzB,WAAON,SAAS,CAACM,aAAjB;AACH;;AACD,SAAO,IAAP;AACH,CALM;;AAOP,MAAMC,0BAA0B,GAC5BC,UAD+B,IAES;AACxC,SAAOA,UAAU,CAACC,IAAX,KAAoB,qBAApB,IAA6C,CAAC,CAACD,UAAU,CAACR,SAAjE;AACH,CAJD;;AAMA,OAAO,MAAMU,gBAAgB,GACzBV,SAD4B,IAEmB;AAC/C,MAAI;AACA,WACIA,SAAS,CAACW,KAAV,CAAgBC,WAAhB,CACKC,MADL,CACYN,0BADZ,EAEKO,GAFL,CAESC,uBAAuB,IAAI;AAC5B,aAAOA,uBAAuB,CAACf,SAA/B;AACH,KAJL,EAIO,CAJP,KAIa,IALjB;AAOH,GARD,CAQE,OAAOI,CAAP,EAAU;AACR;AACA,WAAO,IAAP;AACH;AACJ,CAfM","sourcesContent":["/*\n * Unless explicitly stated otherwise all files in this repository are licensed under the Apache License Version 2.0.\n * This product includes software developed at Datadog (https://www.datadoghq.com/).\n * Copyright 2016-Present Datadog, Inc.\n */\n\n/**\n * NOTE: Do not import from '@apollo/client/utilities' as the package does not exist in Apollo Client < v3.\n */\n\nimport type { Operation } from '@apollo/client';\nimport type { DefinitionNode, OperationDefinitionNode } from 'graphql';\n\nexport const getVariables = (operation: Operation): string | null => {\n if (operation.variables) {\n try {\n return JSON.stringify(operation.variables);\n } catch (e) {\n // TODO RUM-1206: telemetry\n return null;\n }\n }\n return null;\n};\n\nexport const getOperationName = (operation: Operation): string | null => {\n if (operation.operationName) {\n return operation.operationName;\n }\n return null;\n};\n\nconst getOperationDefinitionNode = (\n definition: DefinitionNode\n): definition is OperationDefinitionNode => {\n return definition.kind === 'OperationDefinition' && !!definition.operation;\n};\n\nexport const getOperationType = (\n operation: Operation\n): 'query' | 'mutation' | 'subscription' | null => {\n try {\n return (\n operation.query.definitions\n .filter(getOperationDefinitionNode)\n .map(operationDefinitionNode => {\n return operationDefinitionNode.operation;\n })[0] || null\n );\n } catch (e) {\n // TODO RUM-1206: telemetry\n return null;\n }\n};\n"]}
@@ -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
+ export { DatadogLink } from './DatadogLink';
7
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["index.ts"],"names":["DatadogLink"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AAEA,SAASA,WAAT,QAA4B,eAA5B","sourcesContent":["/*\n * Unless explicitly stated otherwise all files in this repository are licensed under the Apache License Version 2.0.\n * This product includes software developed at Datadog (https://www.datadoghq.com/).\n * Copyright 2016-Present Datadog, Inc.\n */\n\nexport { DatadogLink } from './DatadogLink';\n"]}
@@ -0,0 +1,66 @@
1
+ import { DdSdkReactNativeConfiguration } from './DdSdkReactNativeConfiguration';
2
+ import type { DatadogProviderConfiguration, PartialInitializationConfiguration, AutoInstrumentationConfiguration } from './DdSdkReactNativeConfiguration';
3
+ import type { TrackingConsent } from './TrackingConsent';
4
+ import type { Attributes } from './sdk/AttributesSingleton/types';
5
+ import type { UserInfo } from './sdk/UserInfoSingleton/types';
6
+ /**
7
+ * This class initializes the Datadog SDK, and sets up communication with the server.
8
+ */
9
+ export declare class DdSdkReactNative {
10
+ private static readonly DD_SOURCE_KEY;
11
+ private static readonly DD_SDK_VERSION;
12
+ private static readonly DD_SERVICE_NAME;
13
+ private static readonly DD_SDK_VERBOSITY_KEY;
14
+ private static readonly DD_NATIVE_VIEW_TRACKING_KEY;
15
+ private static readonly DD_NATIVE_INTERACTION_TRACKING_KEY;
16
+ private static readonly DD_VERSION;
17
+ private static readonly DD_VERSION_SUFFIX;
18
+ private static readonly DD_PROXY_TYPE_KEY;
19
+ private static readonly DD_PROXY_ADDRESS_KEY;
20
+ private static readonly DD_PROXY_PORT_KEY;
21
+ private static readonly DD_PROXY_USERNAME_KEY;
22
+ private static readonly DD_PROXY_PASSWORD_KEY;
23
+ private static wasInitialized;
24
+ private static wasAutoInstrumented;
25
+ private static features?;
26
+ /**
27
+ * Initializes the Datadog SDK.
28
+ * @param configuration the configuration for the SDK library
29
+ * @returns a Promise.
30
+ */
31
+ static initialize: (configuration: DdSdkReactNativeConfiguration) => Promise<void>;
32
+ private static initializeNativeSDK;
33
+ /**
34
+ * FOR INTERNAL USE ONLY.
35
+ */
36
+ static _initializeFromDatadogProvider(configuration: DatadogProviderConfiguration): Promise<void>;
37
+ /**
38
+ * FOR INTERNAL USE ONLY.
39
+ */
40
+ static _enableFeaturesFromDatadogProvider(features: AutoInstrumentationConfiguration): Promise<void>;
41
+ /**
42
+ * FOR INTERNAL USE ONLY.
43
+ */
44
+ static _initializeFromDatadogProviderWithConfigurationAsync: (configuration: PartialInitializationConfiguration) => Promise<void>;
45
+ /**
46
+ * Adds a set of attributes to the global context attached with all future Logs, Spans and RUM events.
47
+ * To remove an attribute, set it to `undefined` in a call to `setAttributes`.
48
+ * @param attributes: The global context attributes.
49
+ * @returns a Promise.
50
+ */
51
+ static setAttributes: (attributes: Attributes) => Promise<void>;
52
+ /**
53
+ * Set the user information.
54
+ * @param user: The user object (use builtin attributes: 'id', 'email', 'name', and/or any custom attribute).
55
+ * @returns a Promise.
56
+ */
57
+ static setUser: (user: UserInfo) => Promise<void>;
58
+ /**
59
+ * Set the tracking consent regarding the data collection.
60
+ * @param trackingConsent: One of TrackingConsent values.
61
+ * @returns a Promise.
62
+ */
63
+ static setTrackingConsent: (consent: TrackingConsent) => Promise<void>;
64
+ private static buildConfiguration;
65
+ private static enableFeatures;
66
+ }