@datadog/mobile-react-native 2.0.4 → 2.1.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 (59) hide show
  1. package/android/build.gradle +4 -0
  2. package/android/src/main/kotlin/com/datadog/reactnative/DatadogSDKWrapper.kt +63 -8
  3. package/android/src/main/kotlin/com/datadog/reactnative/DatadogWrapper.kt +5 -0
  4. package/android/src/main/kotlin/com/datadog/reactnative/DdLogsImplementation.kt +1 -1
  5. package/android/src/main/kotlin/com/datadog/reactnative/DdSdkBridgeExt.kt +4 -2
  6. package/android/src/main/kotlin/com/datadog/reactnative/DdSdkConfiguration.kt +14 -0
  7. package/android/src/main/kotlin/com/datadog/reactnative/DdSdkConfigurationExt.kt +17 -0
  8. package/android/src/main/kotlin/com/datadog/reactnative/DdSdkImplementation.kt +38 -4
  9. package/android/src/main/kotlin/com/datadog/reactnative/DdTraceImplementation.kt +1 -1
  10. package/android/src/newarch/kotlin/com/datadog/reactnative/DdSdk.kt +8 -0
  11. package/android/src/oldarch/kotlin/com/datadog/reactnative/DdSdk.kt +8 -0
  12. package/android/src/test/kotlin/com/datadog/reactnative/DdSdkTest.kt +53 -0
  13. package/android/src/test/kotlin/com/datadog/tools/unit/DdSdkConfigurationExt.kt +13 -0
  14. package/android/src/test/kotlin/com/datadog/tools/unit/ReflectUtils.kt +24 -5
  15. package/android/src/test/kotlin/com/datadog/tools/unit/RemoveFinalModifierJava.java +32 -0
  16. package/android/src/test/kotlin/com/datadog/tools/unit/forge/DdSdkConfigurationForgeryFactory.kt +7 -1
  17. package/ios/Sources/DatadogSDKWrapper.swift +163 -0
  18. package/ios/Sources/DdLogsImplementation.swift +1 -2
  19. package/ios/Sources/DdSdk.mm +10 -0
  20. package/ios/Sources/DdSdkConfiguration.swift +21 -1
  21. package/ios/Sources/DdSdkImplementation.swift +56 -17
  22. package/ios/Sources/RNDdSdkConfiguration.swift +14 -0
  23. package/jest/mock.js +3 -0
  24. package/lib/commonjs/DdSdkReactNative.js +7 -1
  25. package/lib/commonjs/DdSdkReactNative.js.map +1 -1
  26. package/lib/commonjs/DdSdkReactNativeConfiguration.js +5 -3
  27. package/lib/commonjs/DdSdkReactNativeConfiguration.js.map +1 -1
  28. package/lib/commonjs/specs/NativeDdLogs.js.map +1 -1
  29. package/lib/commonjs/specs/NativeDdSdk.js.map +1 -1
  30. package/lib/commonjs/types.js +2 -1
  31. package/lib/commonjs/types.js.map +1 -1
  32. package/lib/commonjs/version.js +1 -1
  33. package/lib/commonjs/version.js.map +1 -1
  34. package/lib/module/DdSdkReactNative.js +6 -1
  35. package/lib/module/DdSdkReactNative.js.map +1 -1
  36. package/lib/module/DdSdkReactNativeConfiguration.js +5 -3
  37. package/lib/module/DdSdkReactNativeConfiguration.js.map +1 -1
  38. package/lib/module/specs/NativeDdLogs.js.map +1 -1
  39. package/lib/module/specs/NativeDdSdk.js.map +1 -1
  40. package/lib/module/types.js +2 -1
  41. package/lib/module/types.js.map +1 -1
  42. package/lib/module/version.js +1 -1
  43. package/lib/module/version.js.map +1 -1
  44. package/lib/typescript/DdSdkReactNative.d.ts +5 -0
  45. package/lib/typescript/DdSdkReactNativeConfiguration.d.ts +7 -0
  46. package/lib/typescript/specs/NativeDdLogs.d.ts +8 -8
  47. package/lib/typescript/specs/NativeDdSdk.d.ts +4 -0
  48. package/lib/typescript/types.d.ts +10 -1
  49. package/lib/typescript/version.d.ts +1 -1
  50. package/package.json +2 -2
  51. package/src/DdSdkReactNative.tsx +10 -0
  52. package/src/DdSdkReactNativeConfiguration.tsx +11 -1
  53. package/src/__tests__/DdSdkReactNative.test.tsx +44 -0
  54. package/src/__tests__/DdSdkReactNativeConfiguration.test.ts +15 -2
  55. package/src/sdk/DatadogProvider/__tests__/initialization.test.tsx +1 -0
  56. package/src/specs/NativeDdLogs.ts +20 -20
  57. package/src/specs/NativeDdSdk.ts +5 -0
  58. package/src/types.tsx +5 -0
  59. package/src/version.ts +1 -1
@@ -1 +1 @@
1
- {"version":3,"sources":["types.tsx"],"names":["DdSdkConfiguration","constructor","clientToken","env","applicationId","nativeCrashReportEnabled","nativeLongTaskThresholdMs","longTaskThresholdMs","sampleRate","site","trackingConsent","additionalConfig","telemetrySampleRate","vitalsUpdateFrequency","uploadFrequency","batchSize","trackFrustrations","trackBackgroundEvents","configurationForTelemetry"],"mappings":"AAAA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA,OAAO,MAAMA,kBAAN,CAAyB;AAC5BC,EAAAA,WAAW,CACEC,WADF,EAEEC,GAFF,EAGEC,aAHF,EAIEC,wBAJF,EAKEC,yBALF,EAMEC,mBANF,EAOEC,UAPF,EAQEC,IARF,EASEC,eATF,EAUEC,gBAVF,EAWEC,mBAXF,EAYEC,qBAZF,EAaEC,eAbF,EAcEC,SAdF,EAeEC,iBAfF,EAgBEC,qBAhBF,EAiBEC,yBAjBF,EAyBT;AAAA,SAxBWhB,WAwBX,GAxBWA,WAwBX;AAAA,SAvBWC,GAuBX,GAvBWA,GAuBX;AAAA,SAtBWC,aAsBX,GAtBWA,aAsBX;AAAA,SArBWC,wBAqBX,GArBWA,wBAqBX;AAAA,SApBWC,yBAoBX,GApBWA,yBAoBX;AAAA,SAnBWC,mBAmBX,GAnBWA,mBAmBX;AAAA,SAlBWC,UAkBX,GAlBWA,UAkBX;AAAA,SAjBWC,IAiBX,GAjBWA,IAiBX;AAAA,SAhBWC,eAgBX,GAhBWA,eAgBX;AAAA,SAfWC,gBAeX,GAfWA,gBAeX;AAAA,SAdWC,mBAcX,GAdWA,mBAcX;AAAA,SAbWC,qBAaX,GAbWA,qBAaX;AAAA,SAZWC,eAYX,GAZWA,eAYX;AAAA,SAXWC,SAWX,GAXWA,SAWX;AAAA,SAVWC,iBAUX,GAVWA,iBAUX;AAAA,SATWC,qBASX,GATWA,qBASX;AAAA,SARWC,yBAQX,GARWA,yBAQX;AAAE;;AA1BwB;AA6BhC;AACA;AACA","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 * A configuration object to initialize Datadog's features.\n */\nexport class DdSdkConfiguration {\n constructor(\n readonly clientToken: string,\n readonly env: string,\n readonly applicationId: string,\n readonly nativeCrashReportEnabled: boolean,\n readonly nativeLongTaskThresholdMs: number,\n readonly longTaskThresholdMs: number,\n readonly sampleRate: number,\n readonly site: string,\n readonly trackingConsent: string,\n readonly additionalConfig: object,\n readonly telemetrySampleRate: number,\n readonly vitalsUpdateFrequency: string,\n readonly uploadFrequency: string,\n readonly batchSize: string,\n readonly trackFrustrations: boolean,\n readonly trackBackgroundEvents: boolean,\n readonly configurationForTelemetry: {\n initializationType: string;\n trackErrors: boolean;\n trackInteractions: boolean;\n trackNetworkRequests: boolean;\n reactVersion: string;\n reactNativeVersion: string;\n }\n ) {}\n}\n\n/**\n * The entry point to initialize Datadog's features.\n */\nexport type DdSdkType = {\n /**\n * Initializes Datadog's features.\n * @param configuration: The configuration to use.\n */\n initialize(configuration: DdSdkConfiguration): Promise<void>;\n\n /**\n * Sets the global context (set of attributes) attached with all future Logs, Spans and RUM events.\n * @param attributes: The global context attributes.\n */\n setAttributes(attributes: object): Promise<void>;\n\n /**\n * Set the user information.\n * @param user: The user object (use builtin attributes: 'id', 'email', 'name', and/or any custom attribute).\n */\n setUser(user: object): Promise<void>;\n\n /**\n * Set the tracking consent regarding the data collection.\n * @param trackingConsent: Consent, which can take one of the following values: 'pending', 'granted', 'not_granted'.\n */\n setTrackingConsent(trackingConsent: string): Promise<void>;\n};\n\n/**\n * The entry point to use Datadog's Trace feature.\n */\nexport type DdTraceType = {\n /**\n * Start a span, and returns a unique identifier for the span.\n * @param operation: The operation name of the span.\n * @param context: The additional context to send.\n * @param timestampMs: The timestamp when the operation started (in milliseconds). If not provided, current timestamp will be used.\n */\n startSpan(\n operation: string,\n context?: object,\n timestampMs?: number\n ): Promise<string>;\n\n /**\n * Finish a started span.\n * @param spanId: The unique identifier of the span.\n * @param context: The additional context to send.\n * @param timestampMs: The timestamp when the operation stopped (in milliseconds). If not provided, current timestamp will be used.\n */\n finishSpan(\n spanId: string,\n context?: object,\n timestampMs?: number\n ): Promise<void>;\n};\n"]}
1
+ {"version":3,"sources":["types.tsx"],"names":["DdSdkConfiguration","constructor","clientToken","env","applicationId","nativeCrashReportEnabled","nativeLongTaskThresholdMs","longTaskThresholdMs","sampleRate","site","trackingConsent","additionalConfig","telemetrySampleRate","vitalsUpdateFrequency","uploadFrequency","batchSize","trackFrustrations","trackBackgroundEvents","customEndpoints","configurationForTelemetry"],"mappings":"AAAA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA,OAAO,MAAMA,kBAAN,CAAyB;AAC5BC,EAAAA,WAAW,CACEC,WADF,EAEEC,GAFF,EAGEC,aAHF,EAIEC,wBAJF,EAKEC,yBALF,EAMEC,mBANF,EAOEC,UAPF,EAQEC,IARF,EASEC,eATF,EAUEC,gBAVF,EAWEC,mBAXF,EAYEC,qBAZF,EAaEC,eAbF,EAcEC,SAdF,EAeEC,iBAfF,EAgBEC,qBAhBF,EAiBEC,eAjBF,EAsBEC,yBAtBF,EA8BT;AAAA,SA7BWjB,WA6BX,GA7BWA,WA6BX;AAAA,SA5BWC,GA4BX,GA5BWA,GA4BX;AAAA,SA3BWC,aA2BX,GA3BWA,aA2BX;AAAA,SA1BWC,wBA0BX,GA1BWA,wBA0BX;AAAA,SAzBWC,yBAyBX,GAzBWA,yBAyBX;AAAA,SAxBWC,mBAwBX,GAxBWA,mBAwBX;AAAA,SAvBWC,UAuBX,GAvBWA,UAuBX;AAAA,SAtBWC,IAsBX,GAtBWA,IAsBX;AAAA,SArBWC,eAqBX,GArBWA,eAqBX;AAAA,SApBWC,gBAoBX,GApBWA,gBAoBX;AAAA,SAnBWC,mBAmBX,GAnBWA,mBAmBX;AAAA,SAlBWC,qBAkBX,GAlBWA,qBAkBX;AAAA,SAjBWC,eAiBX,GAjBWA,eAiBX;AAAA,SAhBWC,SAgBX,GAhBWA,SAgBX;AAAA,SAfWC,iBAeX,GAfWA,iBAeX;AAAA,SAdWC,qBAcX,GAdWA,qBAcX;AAAA,SAbWC,eAaX,GAbWA,eAaX;AAAA,SARWC,yBAQX,GARWA,yBAQX;AAAE;;AA/BwB;AAkChC;AACA;AACA","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 * A configuration object to initialize Datadog's features.\n */\nexport class DdSdkConfiguration {\n constructor(\n readonly clientToken: string,\n readonly env: string,\n readonly applicationId: string,\n readonly nativeCrashReportEnabled: boolean,\n readonly nativeLongTaskThresholdMs: number,\n readonly longTaskThresholdMs: number,\n readonly sampleRate: number,\n readonly site: string,\n readonly trackingConsent: string,\n readonly additionalConfig: object,\n readonly telemetrySampleRate: number,\n readonly vitalsUpdateFrequency: string,\n readonly uploadFrequency: string,\n readonly batchSize: string,\n readonly trackFrustrations: boolean,\n readonly trackBackgroundEvents: boolean,\n readonly customEndpoints: {\n rum?: string;\n trace?: string;\n logs?: string;\n },\n readonly configurationForTelemetry: {\n initializationType: string;\n trackErrors: boolean;\n trackInteractions: boolean;\n trackNetworkRequests: boolean;\n reactVersion: string;\n reactNativeVersion: string;\n }\n ) {}\n}\n\n/**\n * The entry point to initialize Datadog's features.\n */\nexport type DdSdkType = {\n /**\n * Initializes Datadog's features.\n * @param configuration: The configuration to use.\n */\n initialize(configuration: DdSdkConfiguration): Promise<void>;\n\n /**\n * Sets the global context (set of attributes) attached with all future Logs, Spans and RUM events.\n * @param attributes: The global context attributes.\n */\n setAttributes(attributes: object): Promise<void>;\n\n /**\n * Set the user information.\n * @param user: The user object (use builtin attributes: 'id', 'email', 'name', and/or any custom attribute).\n */\n setUser(user: object): Promise<void>;\n\n /**\n * Set the tracking consent regarding the data collection.\n * @param trackingConsent: Consent, which can take one of the following values: 'pending', 'granted', 'not_granted'.\n */\n setTrackingConsent(trackingConsent: string): Promise<void>;\n};\n\n/**\n * The entry point to use Datadog's Trace feature.\n */\nexport type DdTraceType = {\n /**\n * Start a span, and returns a unique identifier for the span.\n * @param operation: The operation name of the span.\n * @param context: The additional context to send.\n * @param timestampMs: The timestamp when the operation started (in milliseconds). If not provided, current timestamp will be used.\n */\n startSpan(\n operation: string,\n context?: object,\n timestampMs?: number\n ): Promise<string>;\n\n /**\n * Finish a started span.\n * @param spanId: The unique identifier of the span.\n * @param context: The additional context to send.\n * @param timestampMs: The timestamp when the operation stopped (in milliseconds). If not provided, current timestamp will be used.\n */\n finishSpan(\n spanId: string,\n context?: object,\n timestampMs?: number\n ): Promise<void>;\n};\n"]}
@@ -1,3 +1,3 @@
1
1
  // generated by genversion
2
- export const version = '2.0.4';
2
+ export const version = '2.1.0';
3
3
  //# sourceMappingURL=version.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["version.ts"],"names":["version"],"mappings":"AAAA;AACA,OAAO,MAAMA,OAAO,GAAG,OAAhB","sourcesContent":["// generated by genversion\nexport const version = '2.0.4';\n"]}
1
+ {"version":3,"sources":["version.ts"],"names":["version"],"mappings":"AAAA;AACA,OAAO,MAAMA,OAAO,GAAG,OAAhB","sourcesContent":["// generated by genversion\nexport const version = '2.1.0';\n"]}
@@ -61,6 +61,11 @@ export declare class DdSdkReactNative {
61
61
  * @returns a Promise.
62
62
  */
63
63
  static setTrackingConsent: (consent: TrackingConsent) => Promise<void>;
64
+ /**
65
+ * Clears all data that has not already been sent to Datadog servers
66
+ * @returns a Promise
67
+ */
68
+ static clearAllData: () => Promise<void>;
64
69
  private static buildConfiguration;
65
70
  private static enableFeatures;
66
71
  }
@@ -42,6 +42,11 @@ export declare enum BatchSize {
42
42
  }
43
43
  export declare type FirstPartyHostsConfiguration = (FirstPartyHost | LegacyFirstPartyHost)[];
44
44
  export declare type LegacyFirstPartyHost = string;
45
+ export declare type CustomEndpoints = {
46
+ rum?: string;
47
+ logs?: string;
48
+ trace?: string;
49
+ };
45
50
  /**
46
51
  * Defaults legacy first party hosts format to Datadog first party hosts to keep
47
52
  * retro-compatibility before OTel support was introduced.
@@ -193,6 +198,7 @@ export declare class DdSdkReactNativeConfiguration {
193
198
  additionalConfig: {
194
199
  [k: string]: any;
195
200
  };
201
+ customEndpoints: CustomEndpoints;
196
202
  constructor(clientToken: string, env: string, applicationId: string, trackInteractions?: boolean, trackResources?: boolean, trackErrors?: boolean, trackingConsent?: TrackingConsent);
197
203
  }
198
204
  /**
@@ -257,6 +263,7 @@ export declare type PartialInitializationConfiguration = {
257
263
  readonly uploadFrequency?: UploadFrequency;
258
264
  readonly batchSize?: BatchSize;
259
265
  readonly trackBackgroundEvents?: boolean;
266
+ readonly customEndpoints?: CustomEndpoints;
260
267
  };
261
268
  export declare const buildConfigurationFromPartialConfiguration: (features: AutoInstrumentationConfiguration, configuration: PartialInitializationConfiguration) => DdSdkReactNativeConfiguration;
262
269
  export declare class DatadogProviderConfiguration extends DdSdkReactNativeConfiguration {
@@ -9,25 +9,25 @@ export interface Spec extends TurboModule {
9
9
  * @param message: The message to send.
10
10
  * @param context: The additional context to send.
11
11
  */
12
- readonly debug: (message: string, context?: Object) => Promise<void>;
12
+ readonly debug: (message: string, context: Object) => Promise<void>;
13
13
  /**
14
14
  * Send a log with INFO level.
15
15
  * @param message: The message to send.
16
16
  * @param context: The additional context to send.
17
17
  */
18
- readonly info: (message: string, context?: Object) => Promise<void>;
18
+ readonly info: (message: string, context: Object) => Promise<void>;
19
19
  /**
20
20
  * Send a log with WARN level.
21
21
  * @param message: The message to send.
22
22
  * @param context: The additional context to send.
23
23
  */
24
- readonly warn: (message: string, context?: Object) => Promise<void>;
24
+ readonly warn: (message: string, context: Object) => Promise<void>;
25
25
  /**
26
26
  * Send a log with ERROR level.
27
27
  * @param message: The message to send.
28
28
  * @param context: The additional context to send.
29
29
  */
30
- readonly error: (message: string, context?: Object) => Promise<void>;
30
+ readonly error: (message: string, context: Object) => Promise<void>;
31
31
  /**
32
32
  * Send a log containing an error with DEBUG level.
33
33
  * @param message: The message to send.
@@ -36,7 +36,7 @@ export interface Spec extends TurboModule {
36
36
  * @param stacktrace: The stack trace to send.
37
37
  * @param context: The additional context to send.
38
38
  */
39
- readonly debugWithError: (message: string, errorKind?: string, errorMessage?: string, stacktrace?: string, context?: Object) => Promise<void>;
39
+ readonly debugWithError: (message: string, errorKind: string, errorMessage: string, stacktrace: string, context: Object) => Promise<void>;
40
40
  /**
41
41
  * Send a log containing an error with INFO level.
42
42
  * @param message: The message to send.
@@ -45,7 +45,7 @@ export interface Spec extends TurboModule {
45
45
  * @param stacktrace: The stack trace to send.
46
46
  * @param context: The additional context to send.
47
47
  */
48
- readonly infoWithError: (message: string, errorKind?: string, errorMessage?: string, stacktrace?: string, context?: Object) => Promise<void>;
48
+ readonly infoWithError: (message: string, errorKind: string, errorMessage: string, stacktrace: string, context: Object) => Promise<void>;
49
49
  /**
50
50
  * Send a log containing an error with WARN level.
51
51
  * @param message: The message to send.
@@ -54,7 +54,7 @@ export interface Spec extends TurboModule {
54
54
  * @param stacktrace: The stack trace to send.
55
55
  * @param context: The additional context to send.
56
56
  */
57
- readonly warnWithError: (message: string, errorKind?: string, errorMessage?: string, stacktrace?: string, context?: Object) => Promise<void>;
57
+ readonly warnWithError: (message: string, errorKind: string, errorMessage: string, stacktrace: string, context: Object) => Promise<void>;
58
58
  /**
59
59
  * Send a log containing an error with ERROR level.
60
60
  * @param message: The message to send.
@@ -63,7 +63,7 @@ export interface Spec extends TurboModule {
63
63
  * @param stacktrace: The stack trace to send.
64
64
  * @param context: The additional context to send.
65
65
  */
66
- readonly errorWithError: (message: string, errorKind?: string, errorMessage?: string, stacktrace?: string, context?: Object) => Promise<void>;
66
+ readonly errorWithError: (message: string, errorKind: string, errorMessage: string, stacktrace: string, context: Object) => Promise<void>;
67
67
  }
68
68
  declare const _default: Spec | null;
69
69
  export default _default;
@@ -41,6 +41,10 @@ export interface Spec extends TurboModule {
41
41
  * @param message event description
42
42
  */
43
43
  consumeWebviewEvent(message: string): Promise<void>;
44
+ /**
45
+ * Clears all data that has not already been sent to Datadog servers
46
+ */
47
+ clearAllData(): Promise<void>;
44
48
  }
45
49
  declare const _default: Spec | null;
46
50
  export default _default;
@@ -18,6 +18,11 @@ export declare class DdSdkConfiguration {
18
18
  readonly batchSize: string;
19
19
  readonly trackFrustrations: boolean;
20
20
  readonly trackBackgroundEvents: boolean;
21
+ readonly customEndpoints: {
22
+ rum?: string;
23
+ trace?: string;
24
+ logs?: string;
25
+ };
21
26
  readonly configurationForTelemetry: {
22
27
  initializationType: string;
23
28
  trackErrors: boolean;
@@ -26,7 +31,11 @@ export declare class DdSdkConfiguration {
26
31
  reactVersion: string;
27
32
  reactNativeVersion: string;
28
33
  };
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: {
34
+ 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, customEndpoints: {
35
+ rum?: string;
36
+ trace?: string;
37
+ logs?: string;
38
+ }, configurationForTelemetry: {
30
39
  initializationType: string;
31
40
  trackErrors: boolean;
32
41
  trackInteractions: boolean;
@@ -1 +1 @@
1
- export declare const version = "2.0.4";
1
+ export declare const version = "2.1.0";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@datadog/mobile-react-native",
3
- "version": "2.0.4",
3
+ "version": "2.1.0",
4
4
  "description": "A client-side React Native module to interact with Datadog",
5
5
  "keywords": [
6
6
  "datadog",
@@ -94,5 +94,5 @@
94
94
  "javaPackageName": "com.datadog.reactnative"
95
95
  }
96
96
  },
97
- "gitHead": "0bbd1776a464f4eab6e250d4aa234144543d5c82"
97
+ "gitHead": "d1503f22cfed97eaa8ace75d569fda7bd25c9766"
98
98
  }
@@ -122,6 +122,7 @@ export class DdSdkReactNative {
122
122
  configuration.batchSize,
123
123
  configuration.trackFrustrations,
124
124
  configuration.trackBackgroundEvents,
125
+ configuration.customEndpoints,
125
126
  {
126
127
  initializationType: params.initializationModeForTelemetry,
127
128
  trackErrors: configuration.trackErrors,
@@ -243,6 +244,15 @@ export class DdSdkReactNative {
243
244
  return DdSdk.setTrackingConsent(consent);
244
245
  };
245
246
 
247
+ /**
248
+ * Clears all data that has not already been sent to Datadog servers
249
+ * @returns a Promise
250
+ */
251
+ static clearAllData = (): Promise<void> => {
252
+ InternalLog.log('Clearing all data', SdkVerbosity.DEBUG);
253
+ return DdSdk.clearAllData();
254
+ };
255
+
246
256
  private static buildConfiguration = (
247
257
  configuration: DdSdkReactNativeConfiguration
248
258
  ) => {
@@ -64,6 +64,12 @@ const isLegacyFirstPartyHost = (
64
64
  return typeof firstPartyHost === 'string';
65
65
  };
66
66
 
67
+ export type CustomEndpoints = {
68
+ rum?: string;
69
+ logs?: string;
70
+ trace?: string;
71
+ };
72
+
67
73
  /**
68
74
  * Defaults legacy first party hosts format to Datadog first party hosts to keep
69
75
  * retro-compatibility before OTel support was introduced.
@@ -106,7 +112,8 @@ const DEFAULTS = {
106
112
  trackFrustrations: true,
107
113
  uploadFrequency: UploadFrequency.AVERAGE,
108
114
  batchSize: BatchSize.MEDIUM,
109
- trackBackgroundEvents: false
115
+ trackBackgroundEvents: false,
116
+ getCustomEndpoints: () => ({})
110
117
  };
111
118
 
112
119
  /**
@@ -271,6 +278,8 @@ export class DdSdkReactNativeConfiguration {
271
278
  [k: string]: any;
272
279
  } = DEFAULTS.getAdditionalConfig();
273
280
 
281
+ public customEndpoints: CustomEndpoints = DEFAULTS.getCustomEndpoints();
282
+
274
283
  constructor(
275
284
  readonly clientToken: string,
276
285
  readonly env: string,
@@ -373,6 +382,7 @@ export type PartialInitializationConfiguration = {
373
382
  readonly uploadFrequency?: UploadFrequency;
374
383
  readonly batchSize?: BatchSize;
375
384
  readonly trackBackgroundEvents?: boolean;
385
+ readonly customEndpoints?: CustomEndpoints;
376
386
  };
377
387
 
378
388
  const setConfigurationAttribute = <
@@ -948,6 +948,40 @@ describe('DdSdkReactNative', () => {
948
948
  expect(ddSdkConfiguration.nativeLongTaskThresholdMs).toBe(0);
949
949
  expect(ddSdkConfiguration.longTaskThresholdMs).toBe(0);
950
950
  });
951
+
952
+ it('enables custom endpoints when initialize { custom endpoints specified }', async () => {
953
+ // GIVEN
954
+ const fakeAppId = '1';
955
+ const fakeClientToken = '2';
956
+ const fakeEnvName = 'env';
957
+ const configuration = new DdSdkReactNativeConfiguration(
958
+ fakeClientToken,
959
+ fakeEnvName,
960
+ fakeAppId,
961
+ false,
962
+ false,
963
+ true
964
+ );
965
+ configuration.customEndpoints = {
966
+ rum: 'https://rum.example.com/',
967
+ trace: 'https://trace.example.com/',
968
+ logs: 'https://logs.example.com/'
969
+ };
970
+
971
+ NativeModules.DdSdk.initialize.mockResolvedValue(null);
972
+
973
+ // WHEN
974
+ await DdSdkReactNative.initialize(configuration);
975
+
976
+ // THEN
977
+ const ddSdkConfiguration = NativeModules.DdSdk.initialize.mock
978
+ .calls[0][0] as DdSdkConfiguration;
979
+ expect(ddSdkConfiguration.customEndpoints).toEqual({
980
+ rum: 'https://rum.example.com/',
981
+ trace: 'https://trace.example.com/',
982
+ logs: 'https://logs.example.com/'
983
+ });
984
+ });
951
985
  });
952
986
 
953
987
  describe('setAttributes', () => {
@@ -1001,6 +1035,16 @@ describe('DdSdkReactNative', () => {
1001
1035
  });
1002
1036
  });
1003
1037
 
1038
+ describe('clearAllData', () => {
1039
+ it('calls SDK method when clearAllData', async () => {
1040
+ // WHEN
1041
+ DdSdkReactNative.clearAllData();
1042
+
1043
+ // THEN
1044
+ expect(DdSdk.clearAllData).toHaveBeenCalledTimes(1);
1045
+ });
1046
+ });
1047
+
1004
1048
  describe.each([[ProxyType.HTTP], [ProxyType.HTTPS], [ProxyType.SOCKS]])(
1005
1049
  'proxy configs test, no auth',
1006
1050
  proxyType => {
@@ -36,6 +36,7 @@ describe('DdSdkReactNativeConfiguration', () => {
36
36
  "applicationId": "fake-app-id",
37
37
  "batchSize": "MEDIUM",
38
38
  "clientToken": "fake-client-token",
39
+ "customEndpoints": {},
39
40
  "env": "fake-env",
40
41
  "errorEventMapper": null,
41
42
  "firstPartyHosts": [],
@@ -106,7 +107,12 @@ describe('DdSdkReactNativeConfiguration', () => {
106
107
  trackFrustrations: true,
107
108
  uploadFrequency: UploadFrequency.FREQUENT,
108
109
  batchSize: BatchSize.LARGE,
109
- trackBackgroundEvents: true
110
+ trackBackgroundEvents: true,
111
+ customEndpoints: {
112
+ rum: 'https://rum.example.com/',
113
+ logs: 'https://logs.example.com/',
114
+ trace: 'https://trace.example.com/'
115
+ }
110
116
  }
111
117
  )
112
118
  ).toMatchInlineSnapshot(`
@@ -119,6 +125,11 @@ describe('DdSdkReactNativeConfiguration', () => {
119
125
  "applicationId": "fake-app-id",
120
126
  "batchSize": "LARGE",
121
127
  "clientToken": "fake-client-token",
128
+ "customEndpoints": {
129
+ "logs": "https://logs.example.com/",
130
+ "rum": "https://rum.example.com/",
131
+ "trace": "https://trace.example.com/",
132
+ },
122
133
  "env": "fake-env",
123
134
  "errorEventMapper": [Function],
124
135
  "firstPartyHosts": [
@@ -183,7 +194,8 @@ describe('DdSdkReactNativeConfiguration', () => {
183
194
  nativeLongTaskThresholdMs: false,
184
195
  longTaskThresholdMs: false,
185
196
  trackFrustrations: false,
186
- trackBackgroundEvents: false
197
+ trackBackgroundEvents: false,
198
+ customEndpoints: {}
187
199
  }
188
200
  )
189
201
  ).toMatchInlineSnapshot(`
@@ -193,6 +205,7 @@ describe('DdSdkReactNativeConfiguration', () => {
193
205
  "applicationId": "",
194
206
  "batchSize": "MEDIUM",
195
207
  "clientToken": "",
208
+ "customEndpoints": {},
196
209
  "env": "",
197
210
  "errorEventMapper": null,
198
211
  "firstPartyHosts": [],
@@ -77,6 +77,7 @@ describe('DatadogProvider', () => {
77
77
  "trackInteractions": true,
78
78
  "trackNetworkRequests": false,
79
79
  },
80
+ "customEndpoints": {},
80
81
  "env": "fakeEnv",
81
82
  "longTaskThresholdMs": 0,
82
83
  "nativeCrashReportEnabled": false,
@@ -19,28 +19,28 @@ export interface Spec extends TurboModule {
19
19
  * @param message: The message to send.
20
20
  * @param context: The additional context to send.
21
21
  */
22
- readonly debug: (message: string, context?: Object) => Promise<void>;
22
+ readonly debug: (message: string, context: Object) => Promise<void>;
23
23
 
24
24
  /**
25
25
  * Send a log with INFO level.
26
26
  * @param message: The message to send.
27
27
  * @param context: The additional context to send.
28
28
  */
29
- readonly info: (message: string, context?: Object) => Promise<void>;
29
+ readonly info: (message: string, context: Object) => Promise<void>;
30
30
 
31
31
  /**
32
32
  * Send a log with WARN level.
33
33
  * @param message: The message to send.
34
34
  * @param context: The additional context to send.
35
35
  */
36
- readonly warn: (message: string, context?: Object) => Promise<void>;
36
+ readonly warn: (message: string, context: Object) => Promise<void>;
37
37
 
38
38
  /**
39
39
  * Send a log with ERROR level.
40
40
  * @param message: The message to send.
41
41
  * @param context: The additional context to send.
42
42
  */
43
- readonly error: (message: string, context?: Object) => Promise<void>;
43
+ readonly error: (message: string, context: Object) => Promise<void>;
44
44
 
45
45
  /**
46
46
  * Send a log containing an error with DEBUG level.
@@ -52,10 +52,10 @@ export interface Spec extends TurboModule {
52
52
  */
53
53
  readonly debugWithError: (
54
54
  message: string,
55
- errorKind?: string,
56
- errorMessage?: string,
57
- stacktrace?: string,
58
- context?: Object
55
+ errorKind: string,
56
+ errorMessage: string,
57
+ stacktrace: string,
58
+ context: Object
59
59
  ) => Promise<void>;
60
60
 
61
61
  /**
@@ -68,10 +68,10 @@ export interface Spec extends TurboModule {
68
68
  */
69
69
  readonly infoWithError: (
70
70
  message: string,
71
- errorKind?: string,
72
- errorMessage?: string,
73
- stacktrace?: string,
74
- context?: Object
71
+ errorKind: string,
72
+ errorMessage: string,
73
+ stacktrace: string,
74
+ context: Object
75
75
  ) => Promise<void>;
76
76
 
77
77
  /**
@@ -84,10 +84,10 @@ export interface Spec extends TurboModule {
84
84
  */
85
85
  readonly warnWithError: (
86
86
  message: string,
87
- errorKind?: string,
88
- errorMessage?: string,
89
- stacktrace?: string,
90
- context?: Object
87
+ errorKind: string,
88
+ errorMessage: string,
89
+ stacktrace: string,
90
+ context: Object
91
91
  ) => Promise<void>;
92
92
 
93
93
  /**
@@ -100,10 +100,10 @@ export interface Spec extends TurboModule {
100
100
  */
101
101
  readonly errorWithError: (
102
102
  message: string,
103
- errorKind?: string,
104
- errorMessage?: string,
105
- stacktrace?: string,
106
- context?: Object
103
+ errorKind: string,
104
+ errorMessage: string,
105
+ stacktrace: string,
106
+ context: Object
107
107
  ) => Promise<void>;
108
108
  }
109
109
 
@@ -57,6 +57,11 @@ export interface Spec extends TurboModule {
57
57
  * @param message event description
58
58
  */
59
59
  consumeWebviewEvent(message: string): Promise<void>;
60
+
61
+ /**
62
+ * Clears all data that has not already been sent to Datadog servers
63
+ */
64
+ clearAllData(): Promise<void>;
60
65
  }
61
66
 
62
67
  export default TurboModuleRegistry.get<Spec>('DdSdk');
package/src/types.tsx CHANGED
@@ -25,6 +25,11 @@ export class DdSdkConfiguration {
25
25
  readonly batchSize: string,
26
26
  readonly trackFrustrations: boolean,
27
27
  readonly trackBackgroundEvents: boolean,
28
+ readonly customEndpoints: {
29
+ rum?: string;
30
+ trace?: string;
31
+ logs?: string;
32
+ },
28
33
  readonly configurationForTelemetry: {
29
34
  initializationType: string;
30
35
  trackErrors: boolean;
package/src/version.ts CHANGED
@@ -1,2 +1,2 @@
1
1
  // generated by genversion
2
- export const version = '2.0.4';
2
+ export const version = '2.1.0';