@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
@@ -0,0 +1,69 @@
1
+ import type { TurboModule } from 'react-native';
2
+ /**
3
+ * Do not import this Spec directly, use DdNativeLogsType instead.
4
+ */
5
+ export interface Spec extends TurboModule {
6
+ readonly getConstants: () => {};
7
+ /**
8
+ * Send a log with DEBUG level.
9
+ * @param message: The message to send.
10
+ * @param context: The additional context to send.
11
+ */
12
+ readonly debug: (message: string, context?: Object) => Promise<void>;
13
+ /**
14
+ * Send a log with INFO level.
15
+ * @param message: The message to send.
16
+ * @param context: The additional context to send.
17
+ */
18
+ readonly info: (message: string, context?: Object) => Promise<void>;
19
+ /**
20
+ * Send a log with WARN level.
21
+ * @param message: The message to send.
22
+ * @param context: The additional context to send.
23
+ */
24
+ readonly warn: (message: string, context?: Object) => Promise<void>;
25
+ /**
26
+ * Send a log with ERROR level.
27
+ * @param message: The message to send.
28
+ * @param context: The additional context to send.
29
+ */
30
+ readonly error: (message: string, context?: Object) => Promise<void>;
31
+ /**
32
+ * Send a log containing an error with DEBUG level.
33
+ * @param message: The message to send.
34
+ * @param errorKind: The error kind to send.
35
+ * @param errorMessage: The error message to send.
36
+ * @param stacktrace: The stack trace to send.
37
+ * @param context: The additional context to send.
38
+ */
39
+ readonly debugWithError: (message: string, errorKind?: string, errorMessage?: string, stacktrace?: string, context?: Object) => Promise<void>;
40
+ /**
41
+ * Send a log containing an error with INDO level.
42
+ * @param message: The message to send.
43
+ * @param errorKind: The error kind to send.
44
+ * @param errorMessage: The error message to send.
45
+ * @param stacktrace: The stack trace to send.
46
+ * @param context: The additional context to send.
47
+ */
48
+ readonly infoWithError: (message: string, errorKind?: string, errorMessage?: string, stacktrace?: string, context?: Object) => Promise<void>;
49
+ /**
50
+ * Send a log containing an error with WARN level.
51
+ * @param message: The message to send.
52
+ * @param errorKind: The error kind to send.
53
+ * @param errorMessage: The error message to send.
54
+ * @param stacktrace: The stack trace to send.
55
+ * @param context: The additional context to send.
56
+ */
57
+ readonly warnWithError: (message: string, errorKind?: string, errorMessage?: string, stacktrace?: string, context?: Object) => Promise<void>;
58
+ /**
59
+ * Send a log containing an error with ERROR level.
60
+ * @param message: The message to send.
61
+ * @param errorKind: The error kind to send.
62
+ * @param errorMessage: The error message to send.
63
+ * @param stacktrace: The stack trace to send.
64
+ * @param context: The additional context to send.
65
+ */
66
+ readonly errorWithError: (message: string, errorKind?: string, errorMessage?: string, stacktrace?: string, context?: Object) => Promise<void>;
67
+ }
68
+ declare const _default: Spec | null;
69
+ export default _default;
@@ -0,0 +1,92 @@
1
+ import type { TurboModule } from 'react-native';
2
+ /**
3
+ * Do not import this Spec directly, use DdNativeRumType instead.
4
+ */
5
+ export interface Spec extends TurboModule {
6
+ readonly getConstants: () => {};
7
+ /**
8
+ * Start tracking a RUM View.
9
+ * @param key: The view unique key identifier.
10
+ * @param name: The view name.
11
+ * @param context: The additional context to send.
12
+ * @param timestampMs: The timestamp when the view started (in milliseconds). If not provided, current timestamp will be used.
13
+ */
14
+ startView(key: string, name: string, context: Object, timestampMs: number): Promise<void>;
15
+ /**
16
+ * Stop tracking a RUM View.
17
+ * @param key: The view unique key identifier.
18
+ * @param context: The additional context to send.
19
+ * @param timestampMs: The timestamp when the view stopped (in milliseconds). If not provided, current timestamp will be used.
20
+ */
21
+ stopView(key: string, context: Object, timestampMs: number): Promise<void>;
22
+ /**
23
+ * Start tracking a RUM Action.
24
+ * @param type: The action type (tap, scroll, swipe, back, custom).
25
+ * @param name: The action name.
26
+ * @param context: The additional context to send.
27
+ * @param timestampMs: The timestamp when the action started (in milliseconds). If not provided, current timestamp will be used.
28
+ */
29
+ startAction(type: string, name: string, context: Object, timestampMs: number): Promise<void>;
30
+ /**
31
+ * Stop tracking the ongoing RUM Action.
32
+ * @param type: The action type (tap, scroll, swipe, back, custom).
33
+ * @param name: The action name.
34
+ * @param context: The additional context to send.
35
+ * @param timestampMs: The timestamp when the action stopped (in milliseconds). If not provided, current timestamp will be used.
36
+ */
37
+ stopAction(type: string, name: string, context: Object, timestampMs: number): Promise<void>;
38
+ /**
39
+ * Add a RUM Action.
40
+ * @param type: The action type (tap, scroll, swipe, back, custom).
41
+ * @param name: The action name.
42
+ * @param context: The additional context to send.
43
+ * @param timestampMs: The timestamp when the action occurred (in milliseconds). If not provided, current timestamp will be used.
44
+ */
45
+ addAction(type: string, name: string, context: Object, timestampMs: number): Promise<void>;
46
+ /**
47
+ * Start tracking a RUM Resource.
48
+ * @param key: The resource unique key identifier.
49
+ * @param method: The resource method (GET, POST, …).
50
+ * @param url: The resource url.
51
+ * @param context: The additional context to send.
52
+ * @param timestampMs: The timestamp when the resource started (in milliseconds). If not provided, current timestamp will be used.
53
+ */
54
+ startResource(key: string, method: string, url: string, context: Object, timestampMs: number): Promise<void>;
55
+ /**
56
+ * Stop tracking a RUM Resource.
57
+ * @param key: The resource unique key identifier.
58
+ * @param statusCode: The resource status code.
59
+ * @param kind: The resource's kind (xhr, document, image, css, font, …).
60
+ * @param size: The resource size in bytes. If size is unknown, use -1.
61
+ * @param context: The additional context to send.
62
+ * @param timestampMs: The timestamp when the resource stopped (in milliseconds). If not provided, current timestamp will be used.
63
+ */
64
+ stopResource(key: string, statusCode: number, kind: string, size: number, context: Object, timestampMs: number): Promise<void>;
65
+ /**
66
+ * Add a RUM Error.
67
+ * @param message: The error message.
68
+ * @param source: The error source (network, source, console, webview, custom).
69
+ * @param stacktrace: The error stacktrace.
70
+ * @param context: The additional context to send.
71
+ * @param timestampMs: The timestamp when the error occurred (in milliseconds). If not provided, current timestamp will be used.
72
+ */
73
+ addError(message: string, source: string, stacktrace: string, context: Object, timestampMs: number): Promise<void>;
74
+ /**
75
+ * Adds a specific timing in the active View. The timing duration will be computed as the difference between the time the View was started and the time this function was called.
76
+ * @param name: The name of the new custom timing attribute. Timings can be nested up to 8 levels deep. Names using more than 8 levels will be sanitized by SDK.
77
+ */
78
+ addTiming(name: string): Promise<void>;
79
+ /**
80
+ * Stops the current RUM Session.
81
+ */
82
+ stopSession(): Promise<void>;
83
+ /**
84
+ * Adds the result of evaluating a feature flag with a given name and value to the view.
85
+ * Feature flag evaluations are local to the active view and are cleared when the view is stopped.
86
+ * @param name: The name of the feature flag
87
+ * @param value: The value of the feature flag, encapsulated in an Object to accept all types
88
+ */
89
+ addFeatureFlagEvaluation(name: string, value: Object): Promise<void>;
90
+ }
91
+ declare const _default: Spec | null;
92
+ export default _default;
@@ -0,0 +1,46 @@
1
+ import type { TurboModule } from 'react-native';
2
+ /**
3
+ * Do not import this Spec directly, use DdNativeSdkType instead.
4
+ */
5
+ export interface Spec extends TurboModule {
6
+ readonly getConstants: () => {};
7
+ /**
8
+ * Initializes Datadog's features.
9
+ * @param configuration: The configuration to use.
10
+ */
11
+ initialize(configuration: Object): Promise<void>;
12
+ /**
13
+ * Sets the global context (set of attributes) attached with all future Logs, Spans and RUM events.
14
+ * @param attributes: The global context attributes.
15
+ */
16
+ setAttributes(attributes: Object): Promise<void>;
17
+ /**
18
+ * Set the user information.
19
+ * @param user: The user object (use builtin attributes: 'id', 'email', 'name', and/or any custom attribute).
20
+ */
21
+ setUser(user: Object): Promise<Object>;
22
+ /**
23
+ * Set the tracking consent regarding the data collection.
24
+ * @param trackingConsent: Consent, which can take one of the following values: 'pending', 'granted', 'not_granted'.
25
+ */
26
+ setTrackingConsent(trackingConsent: string): Promise<void>;
27
+ /**
28
+ * Sends internal telemetry debug message
29
+ * @param message debug message
30
+ */
31
+ telemetryDebug(message: string): Promise<void>;
32
+ /**
33
+ * Sends internal telemetry error
34
+ * @param message error message
35
+ * @param stack error stack
36
+ * @param kind error kind
37
+ */
38
+ telemetryError(message: string, stack: string, kind: string): Promise<void>;
39
+ /**
40
+ * Send webview telemetry logs
41
+ * @param message event description
42
+ */
43
+ consumeWebviewEvent(message: string): Promise<void>;
44
+ }
45
+ declare const _default: Spec | null;
46
+ export default _default;
@@ -0,0 +1,23 @@
1
+ import type { TurboModule } from 'react-native';
2
+ /**
3
+ * Do not import this Spec directly, use DdNativeTraceType instead.
4
+ */
5
+ export interface Spec extends TurboModule {
6
+ readonly getConstants: () => {};
7
+ /**
8
+ * Start a span, and returns a unique identifier for the span.
9
+ * @param operation: The operation name of the span.
10
+ * @param context: The additional context to send.
11
+ * @param timestampMs: The timestamp when the operation started (in milliseconds). If not provided, current timestamp will be used.
12
+ */
13
+ startSpan(operation: string, context: Object, timestampMs: number): Promise<string>;
14
+ /**
15
+ * Finish a started span.
16
+ * @param spanId: The unique identifier of the span.
17
+ * @param context: The additional context to send.
18
+ * @param timestampMs: The timestamp when the operation stopped (in milliseconds). If not provided, current timestamp will be used.
19
+ */
20
+ finishSpan(spanId: string, context: Object, timestampMs: number): Promise<void>;
21
+ }
22
+ declare const _default: Spec | null;
23
+ export default _default;
@@ -0,0 +1,3 @@
1
+ import type { DdTraceType } from '../types';
2
+ declare const DdTrace: DdTraceType;
3
+ export { DdTrace };
@@ -0,0 +1,81 @@
1
+ /**
2
+ * A configuration object to initialize Datadog's features.
3
+ */
4
+ export declare class DdSdkConfiguration {
5
+ readonly clientToken: string;
6
+ readonly env: string;
7
+ readonly applicationId: string;
8
+ readonly nativeCrashReportEnabled: boolean;
9
+ readonly nativeLongTaskThresholdMs: number;
10
+ readonly longTaskThresholdMs: number;
11
+ readonly sampleRate: number;
12
+ readonly site: string;
13
+ readonly trackingConsent: string;
14
+ readonly additionalConfig: object;
15
+ readonly telemetrySampleRate: number;
16
+ readonly vitalsUpdateFrequency: string;
17
+ readonly uploadFrequency: string;
18
+ readonly batchSize: string;
19
+ readonly trackFrustrations: boolean;
20
+ readonly trackBackgroundEvents: boolean;
21
+ readonly configurationForTelemetry: {
22
+ initializationType: string;
23
+ trackErrors: boolean;
24
+ trackInteractions: boolean;
25
+ trackNetworkRequests: boolean;
26
+ reactVersion: string;
27
+ reactNativeVersion: string;
28
+ };
29
+ constructor(clientToken: string, env: string, applicationId: string, nativeCrashReportEnabled: boolean, nativeLongTaskThresholdMs: number, longTaskThresholdMs: number, sampleRate: number, site: string, trackingConsent: string, additionalConfig: object, telemetrySampleRate: number, vitalsUpdateFrequency: string, uploadFrequency: string, batchSize: string, trackFrustrations: boolean, trackBackgroundEvents: boolean, configurationForTelemetry: {
30
+ initializationType: string;
31
+ trackErrors: boolean;
32
+ trackInteractions: boolean;
33
+ trackNetworkRequests: boolean;
34
+ reactVersion: string;
35
+ reactNativeVersion: string;
36
+ });
37
+ }
38
+ /**
39
+ * The entry point to initialize Datadog's features.
40
+ */
41
+ export declare type DdSdkType = {
42
+ /**
43
+ * Initializes Datadog's features.
44
+ * @param configuration: The configuration to use.
45
+ */
46
+ initialize(configuration: DdSdkConfiguration): Promise<void>;
47
+ /**
48
+ * Sets the global context (set of attributes) attached with all future Logs, Spans and RUM events.
49
+ * @param attributes: The global context attributes.
50
+ */
51
+ setAttributes(attributes: object): 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
+ */
56
+ setUser(user: object): Promise<void>;
57
+ /**
58
+ * Set the tracking consent regarding the data collection.
59
+ * @param trackingConsent: Consent, which can take one of the following values: 'pending', 'granted', 'not_granted'.
60
+ */
61
+ setTrackingConsent(trackingConsent: string): Promise<void>;
62
+ };
63
+ /**
64
+ * The entry point to use Datadog's Trace feature.
65
+ */
66
+ export declare type DdTraceType = {
67
+ /**
68
+ * Start a span, and returns a unique identifier for the span.
69
+ * @param operation: The operation name of the span.
70
+ * @param context: The additional context to send.
71
+ * @param timestampMs: The timestamp when the operation started (in milliseconds). If not provided, current timestamp will be used.
72
+ */
73
+ startSpan(operation: string, context?: object, timestampMs?: number): Promise<string>;
74
+ /**
75
+ * Finish a started span.
76
+ * @param spanId: The unique identifier of the span.
77
+ * @param context: The additional context to send.
78
+ * @param timestampMs: The timestamp when the operation stopped (in milliseconds). If not provided, current timestamp will be used.
79
+ */
80
+ finishSpan(spanId: string, context?: object, timestampMs?: number): Promise<void>;
81
+ };
@@ -0,0 +1,20 @@
1
+ /**
2
+ * A Timestamp structure holding the
3
+ */
4
+ export declare type Timestamp = {
5
+ unix: number;
6
+ react_native: number | null;
7
+ };
8
+ /**
9
+ * Simple class providing timestamps in milliseconds.
10
+ * If available, it will use the `performance.now()` method, and will fallback on `Date.now()` otherwise.
11
+ */
12
+ export declare class TimeProvider {
13
+ private canUsePerformanceNow;
14
+ /** Keeps an average offset between the unix time and the provided timestamp. */
15
+ private baseOffset;
16
+ constructor();
17
+ getTimestamp(): Timestamp;
18
+ now(): number;
19
+ private performanceNow;
20
+ }
@@ -0,0 +1,21 @@
1
+ import { TimeProvider } from './TimeProvider';
2
+ /**
3
+ * Simple timer which records time ticks. Shouldn't be re-used once stopped.
4
+ * All timestamps/durations returned are in milliseconds.
5
+ */
6
+ export default class Timer {
7
+ private timeProvider;
8
+ private times;
9
+ constructor(timeProvider?: TimeProvider);
10
+ get startTime(): number;
11
+ get stopTime(): number;
12
+ start(): void;
13
+ stop(): void;
14
+ recordTick(label: string): void;
15
+ hasTickFor(label: string): boolean;
16
+ durationBetween(startLabel: string, endLabel: string): number;
17
+ timeAt(label: string): number;
18
+ reset(): void;
19
+ private durationBetweenTicks;
20
+ private checkLabelExists;
21
+ }
@@ -0,0 +1,14 @@
1
+ export declare const EMPTY_MESSAGE = "Unknown Error";
2
+ export declare const EMPTY_STACK_TRACE = "";
3
+ export declare const DEFAULT_ERROR_NAME = "Error";
4
+ export declare const getErrorMessage: (error: any | undefined) => string;
5
+ /**
6
+ * Will extract the stack from the error, taking the first key found among:
7
+ * `stacktrace`, `stack`, `componentStack` (component tree for component errors,
8
+ * which contains only native components names in production).
9
+ *
10
+ * In last resort and if `sourceURL`, `line` and `column` are present, it will
11
+ * generate a stack from this information.
12
+ */
13
+ export declare const getErrorStackTrace: (error: any | undefined) => string;
14
+ export declare const getErrorName: (error: unknown) => string;
@@ -0,0 +1 @@
1
+ export declare const executeWithDelay: <T>(callback: () => T, delay: number) => Promise<T>;
@@ -0,0 +1,6 @@
1
+ /**
2
+ * Makes sure the long task threshold value is above 100 and below 5000.
3
+ * Also makes sure it is a number, passing `0` if it is `false`, as the React Native
4
+ * bridge cannot handle values with dual types.
5
+ */
6
+ export declare const adaptLongTaskThreshold: (longTaskThreshold: number | false) => number;
@@ -0,0 +1 @@
1
+ export declare const version = "2.0.0-rc.0";
@@ -0,0 +1,4 @@
1
+ import { ApolloLink } from '@apollo/client';
2
+ export declare class DatadogLink extends ApolloLink {
3
+ constructor();
4
+ }
@@ -0,0 +1,7 @@
1
+ /**
2
+ * NOTE: Do not import from '@apollo/client/utilities' as the package does not exist in Apollo Client < v3.
3
+ */
4
+ import type { Operation } from '@apollo/client';
5
+ export declare const getVariables: (operation: Operation) => string | null;
6
+ export declare const getOperationName: (operation: Operation) => string | null;
7
+ export declare const getOperationType: (operation: Operation) => 'query' | 'mutation' | 'subscription' | null;
@@ -0,0 +1 @@
1
+ export { DatadogLink } from './DatadogLink';
package/package.json ADDED
@@ -0,0 +1,82 @@
1
+ {
2
+ "name": "@datadog/mobile-react-native-apollo-client",
3
+ "version": "2.0.0-rc.0",
4
+ "description": "A client-side React Native module to interact with Apollo Client and Datadog",
5
+ "keywords": [
6
+ "datadog",
7
+ "react-native",
8
+ "ios",
9
+ "android",
10
+ "apollo",
11
+ "graphql"
12
+ ],
13
+ "author": "Datadog (https://github.com/DataDog)",
14
+ "homepage": "https://github.com/DataDog/dd-sdk-reactnative/packages/react-native-apollo-client#readme",
15
+ "repository": {
16
+ "url": "https://github.com/DataDog/dd-sdk-reactnative",
17
+ "directory": "packages/react-native-apollo-client"
18
+ },
19
+ "bugs": {
20
+ "url": "https://github.com/DataDog/dd-sdk-reactnative/issues"
21
+ },
22
+ "license": "Apache-2.0",
23
+ "main": "lib/commonjs/index",
24
+ "files": [
25
+ "src/**",
26
+ "lib/**"
27
+ ],
28
+ "types": "lib/typescript/index.d.ts",
29
+ "react-native": "src/index",
30
+ "source": "src/index",
31
+ "module": "lib/module/index",
32
+ "publishConfig": {
33
+ "access": "public"
34
+ },
35
+ "scripts": {
36
+ "test": "jest",
37
+ "lint": "eslint .",
38
+ "prepare": "rm -rf lib && yarn bob build"
39
+ },
40
+ "devDependencies": {
41
+ "@apollo/client": "^3.8.3",
42
+ "@testing-library/react-native": "7.0.2",
43
+ "graphql": "^16.8.0",
44
+ "react-native-builder-bob": "0.17.1"
45
+ },
46
+ "peerDependencies": {
47
+ "@apollo/client": ">=3.0",
48
+ "@datadog/mobile-react-native": ">=1.5.0",
49
+ "react": ">=16.13.1",
50
+ "react-native": ">=0.63.4 <1.0"
51
+ },
52
+ "jest": {
53
+ "preset": "react-native",
54
+ "moduleNameMapper": {
55
+ "@datadog/mobile-react-native": "<rootDir>../core/src"
56
+ },
57
+ "modulePathIgnorePatterns": [
58
+ "<rootDir>/lib/"
59
+ ],
60
+ "testPathIgnorePatterns": [
61
+ "/__utils__/"
62
+ ],
63
+ "transformIgnorePatterns": [
64
+ "jest-runner"
65
+ ]
66
+ },
67
+ "react-native-builder-bob": {
68
+ "source": "src",
69
+ "output": "lib",
70
+ "targets": [
71
+ "commonjs",
72
+ "module",
73
+ [
74
+ "typescript",
75
+ {
76
+ "tsc": "./../../node_modules/.bin/tsc"
77
+ }
78
+ ]
79
+ ]
80
+ },
81
+ "gitHead": "b669a61b193a49c512116947c8ca46e27cc2eb67"
82
+ }
@@ -0,0 +1,46 @@
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 { ApolloLink } from '@apollo/client';
8
+ import {
9
+ DATADOG_GRAPH_QL_OPERATION_TYPE_HEADER,
10
+ DATADOG_GRAPH_QL_OPERATION_NAME_HEADER,
11
+ DATADOG_GRAPH_QL_VARIABLES_HEADER
12
+ } from '@datadog/mobile-react-native';
13
+
14
+ import { getOperationName, getVariables, getOperationType } from './helpers';
15
+
16
+ export class DatadogLink extends ApolloLink {
17
+ constructor() {
18
+ super((operation, forward) => {
19
+ const operationName = getOperationName(operation);
20
+ const formattedVariables = getVariables(operation);
21
+ const operationType = getOperationType(operation);
22
+
23
+ operation.setContext(({ headers = {} }) => {
24
+ const newHeaders: Record<string, string | null> = {
25
+ ...headers
26
+ };
27
+
28
+ newHeaders[
29
+ DATADOG_GRAPH_QL_OPERATION_TYPE_HEADER
30
+ ] = operationType;
31
+ newHeaders[
32
+ DATADOG_GRAPH_QL_OPERATION_NAME_HEADER
33
+ ] = operationName;
34
+ newHeaders[
35
+ DATADOG_GRAPH_QL_VARIABLES_HEADER
36
+ ] = formattedVariables;
37
+
38
+ return {
39
+ headers: newHeaders
40
+ };
41
+ });
42
+
43
+ return forward(operation);
44
+ });
45
+ }
46
+ }
@@ -0,0 +1,125 @@
1
+ {
2
+ "variables": { "name": "Croute", "age": 22 },
3
+ "extensions": {},
4
+ "operationName": "CreateCat",
5
+ "query": {
6
+ "kind": "Document",
7
+ "definitions": [
8
+ {
9
+ "kind": "OperationDefinition",
10
+ "operation": "mutation",
11
+ "name": { "kind": "Name", "value": "CreateCat" },
12
+ "variableDefinitions": [
13
+ {
14
+ "kind": "VariableDefinition",
15
+ "variable": {
16
+ "kind": "Variable",
17
+ "name": { "kind": "Name", "value": "name" }
18
+ },
19
+ "type": {
20
+ "kind": "NamedType",
21
+ "name": { "kind": "Name", "value": "String" }
22
+ },
23
+ "directives": []
24
+ },
25
+ {
26
+ "kind": "VariableDefinition",
27
+ "variable": {
28
+ "kind": "Variable",
29
+ "name": { "kind": "Name", "value": "age" }
30
+ },
31
+ "type": {
32
+ "kind": "NamedType",
33
+ "name": { "kind": "Name", "value": "Int" }
34
+ },
35
+ "directives": []
36
+ }
37
+ ],
38
+ "directives": [],
39
+ "selectionSet": {
40
+ "kind": "SelectionSet",
41
+ "selections": [
42
+ {
43
+ "kind": "Field",
44
+ "name": { "kind": "Name", "value": "createCat" },
45
+ "arguments": [
46
+ {
47
+ "kind": "Argument",
48
+ "name": {
49
+ "kind": "Name",
50
+ "value": "createCatInput"
51
+ },
52
+ "value": {
53
+ "kind": "ObjectValue",
54
+ "fields": [
55
+ {
56
+ "kind": "ObjectField",
57
+ "name": {
58
+ "kind": "Name",
59
+ "value": "name"
60
+ },
61
+ "value": {
62
+ "kind": "Variable",
63
+ "name": {
64
+ "kind": "Name",
65
+ "value": "name"
66
+ }
67
+ }
68
+ },
69
+ {
70
+ "kind": "ObjectField",
71
+ "name": {
72
+ "kind": "Name",
73
+ "value": "age"
74
+ },
75
+ "value": {
76
+ "kind": "Variable",
77
+ "name": {
78
+ "kind": "Name",
79
+ "value": "age"
80
+ }
81
+ }
82
+ }
83
+ ]
84
+ }
85
+ }
86
+ ],
87
+ "directives": [],
88
+ "selectionSet": {
89
+ "kind": "SelectionSet",
90
+ "selections": [
91
+ {
92
+ "kind": "Field",
93
+ "name": {
94
+ "kind": "Name",
95
+ "value": "name"
96
+ },
97
+ "arguments": [],
98
+ "directives": []
99
+ },
100
+ {
101
+ "kind": "Field",
102
+ "name": {
103
+ "kind": "Name",
104
+ "value": "age"
105
+ },
106
+ "arguments": [],
107
+ "directives": []
108
+ },
109
+ {
110
+ "kind": "Field",
111
+ "name": {
112
+ "kind": "Name",
113
+ "value": "__typename"
114
+ }
115
+ }
116
+ ]
117
+ }
118
+ }
119
+ ]
120
+ }
121
+ }
122
+ ],
123
+ "loc": { "start": 0, "end": 139 }
124
+ }
125
+ }