@datadog/mobile-react-native-code-push 1.1.4 → 1.2.0-beta1

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.
@@ -3,7 +3,7 @@
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
- exports.DatadogCodepush = void 0;
6
+ exports.DatadogCodepushProvider = exports.DatadogCodepush = void 0;
7
7
 
8
8
  var _mobileReactNative = require("@datadog/mobile-react-native");
9
9
 
@@ -27,4 +27,53 @@ const DatadogCodepush = {
27
27
 
28
28
  };
29
29
  exports.DatadogCodepush = DatadogCodepush;
30
+
31
+ const initializeWithCodepushVersion = async configuration => {
32
+ const codePushUpdateMetadata = await _reactNativeCodePush.default.getUpdateMetadata();
33
+
34
+ if (codePushUpdateMetadata) {
35
+ configuration.versionSuffix = `codepush.${codePushUpdateMetadata.label}`;
36
+ }
37
+
38
+ _mobileReactNative.DatadogProvider.initialize(configuration);
39
+ };
40
+
41
+ const DatadogCodepushProvider = ({
42
+ configuration,
43
+ ...rest
44
+ }) => {
45
+ // We cannot use SYNC or ASYNC initialization modes as we need to asynchronously get the CodePush version.
46
+ // We turn it to partial initialization, while in parallel we get the CodePush version and initialize the SDK.
47
+ if (configuration instanceof _mobileReactNative.DatadogProviderConfiguration) {
48
+ initializeWithCodepushVersion(configuration);
49
+ const partialConfiguration = {
50
+ trackErrors: configuration.trackErrors,
51
+ trackResources: configuration.trackResources,
52
+ trackInteractions: configuration.trackInteractions,
53
+ firstPartyHosts: configuration.firstPartyHosts,
54
+ resourceTracingSamplingRate: configuration.resourceTracingSamplingRate
55
+ };
56
+ return (0, _mobileReactNative.DatadogProvider)({
57
+ configuration: partialConfiguration,
58
+ ...rest
59
+ });
60
+ } else {
61
+ return (0, _mobileReactNative.DatadogProvider)({
62
+ configuration,
63
+ ...rest
64
+ });
65
+ }
66
+ };
67
+
68
+ exports.DatadogCodepushProvider = DatadogCodepushProvider;
69
+
70
+ DatadogCodepushProvider.initialize = async configuration => {
71
+ const codePushUpdateMetadata = await _reactNativeCodePush.default.getUpdateMetadata();
72
+
73
+ if (codePushUpdateMetadata) {
74
+ configuration.versionSuffix = `codepush.${codePushUpdateMetadata.label}`;
75
+ }
76
+
77
+ _mobileReactNative.DatadogProvider.initialize(configuration);
78
+ };
30
79
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["index.ts"],"names":["DatadogCodepush","initialize","configuration","codePushUpdateMetadata","codePush","getUpdateMetadata","versionSuffix","label","DdSdkReactNative"],"mappings":";;;;;;;AAAA;;AAEA;;;;AAEA;AACA;AACA;AACO,MAAMA,eAAe,GAAG;AAC3B,QAAMC,UAAN,CACIC,aADJ,EAEiB;AACb,UAAMC,sBAAsB,GAAG,MAAMC,6BAASC,iBAAT,EAArC;;AACA,QAAIF,sBAAJ,EAA4B;AACxBD,MAAAA,aAAa,CAACI,aAAd,GAA+B,YAAWH,sBAAsB,CAACI,KAAM,EAAvE;AACH;;AACD,WAAOC,oCAAiBP,UAAjB,CAA4BC,aAA5B,CAAP;AACH;;AAT0B,CAAxB","sourcesContent":["import { DdSdkReactNative } from '@datadog/mobile-react-native';\nimport type { DdSdkReactNativeConfiguration } from '@datadog/mobile-react-native';\nimport codePush from 'react-native-code-push';\n\n/**\n * Use this class instead of DdSdkReactNative to initialize the Datadog SDK when using AppCenter CodePush.\n */\nexport const DatadogCodepush = {\n async initialize(\n configuration: DdSdkReactNativeConfiguration\n ): Promise<void> {\n const codePushUpdateMetadata = await codePush.getUpdateMetadata();\n if (codePushUpdateMetadata) {\n configuration.versionSuffix = `codepush.${codePushUpdateMetadata.label}`;\n }\n return DdSdkReactNative.initialize(configuration);\n }\n};\n"]}
1
+ {"version":3,"sources":["index.ts"],"names":["DatadogCodepush","initialize","configuration","codePushUpdateMetadata","codePush","getUpdateMetadata","versionSuffix","label","DdSdkReactNative","initializeWithCodepushVersion","DatadogProvider","DatadogCodepushProvider","rest","DatadogProviderConfiguration","partialConfiguration","trackErrors","trackResources","trackInteractions","firstPartyHosts","resourceTracingSamplingRate"],"mappings":";;;;;;;AAAA;;AAMA;;;;AAEA;AACA;AACA;AACO,MAAMA,eAAe,GAAG;AAC3B,QAAMC,UAAN,CACIC,aADJ,EAEiB;AACb,UAAMC,sBAAsB,GAAG,MAAMC,6BAASC,iBAAT,EAArC;;AACA,QAAIF,sBAAJ,EAA4B;AACxBD,MAAAA,aAAa,CAACI,aAAd,GAA+B,YAAWH,sBAAsB,CAACI,KAAM,EAAvE;AACH;;AACD,WAAOC,oCAAiBP,UAAjB,CAA4BC,aAA5B,CAAP;AACH;;AAT0B,CAAxB;;;AAYP,MAAMO,6BAA6B,GAAG,MAClCP,aADkC,IAEjC;AACD,QAAMC,sBAAsB,GAAG,MAAMC,6BAASC,iBAAT,EAArC;;AACA,MAAIF,sBAAJ,EAA4B;AACxBD,IAAAA,aAAa,CAACI,aAAd,GAA+B,YAAWH,sBAAsB,CAACI,KAAM,EAAvE;AACH;;AACDG,qCAAgBT,UAAhB,CAA2BC,aAA3B;AACH,CARD;;AAUO,MAAMS,uBAA+C,GAAG,CAAC;AAC5DT,EAAAA,aAD4D;AAE5D,KAAGU;AAFyD,CAAD,KAGzD;AACF;AACA;AACA,MAAIV,aAAa,YAAYW,+CAA7B,EAA2D;AACvDJ,IAAAA,6BAA6B,CAACP,aAAD,CAA7B;AACA,UAAMY,oBAAoB,GAAG;AACzBC,MAAAA,WAAW,EAAEb,aAAa,CAACa,WADF;AAEzBC,MAAAA,cAAc,EAAEd,aAAa,CAACc,cAFL;AAGzBC,MAAAA,iBAAiB,EAAEf,aAAa,CAACe,iBAHR;AAIzBC,MAAAA,eAAe,EAAEhB,aAAa,CAACgB,eAJN;AAKzBC,MAAAA,2BAA2B,EACvBjB,aAAa,CAACiB;AANO,KAA7B;AAQA,WAAO,wCAAgB;AACnBjB,MAAAA,aAAa,EAAEY,oBADI;AAEnB,SAAGF;AAFgB,KAAhB,CAAP;AAIH,GAdD,MAcO;AACH,WAAO,wCAAgB;AAAEV,MAAAA,aAAF;AAAiB,SAAGU;AAApB,KAAhB,CAAP;AACH;AACJ,CAvBM;;;;AAyBPD,uBAAuB,CAACV,UAAxB,GAAqC,MAAMC,aAAN,IAAuB;AACxD,QAAMC,sBAAsB,GAAG,MAAMC,6BAASC,iBAAT,EAArC;;AACA,MAAIF,sBAAJ,EAA4B;AACxBD,IAAAA,aAAa,CAACI,aAAd,GAA+B,YAAWH,sBAAsB,CAACI,KAAM,EAAvE;AACH;;AACDG,qCAAgBT,UAAhB,CAA2BC,aAA3B;AACH,CAND","sourcesContent":["import {\n DatadogProvider,\n DatadogProviderConfiguration,\n DdSdkReactNative\n} from '@datadog/mobile-react-native';\nimport type { DdSdkReactNativeConfiguration } from '@datadog/mobile-react-native';\nimport codePush from 'react-native-code-push';\n\n/**\n * Use this class instead of DdSdkReactNative to initialize the Datadog SDK when using AppCenter CodePush.\n */\nexport const DatadogCodepush = {\n async initialize(\n configuration: DdSdkReactNativeConfiguration\n ): Promise<void> {\n const codePushUpdateMetadata = await codePush.getUpdateMetadata();\n if (codePushUpdateMetadata) {\n configuration.versionSuffix = `codepush.${codePushUpdateMetadata.label}`;\n }\n return DdSdkReactNative.initialize(configuration);\n }\n};\n\nconst initializeWithCodepushVersion = async (\n configuration: DatadogProviderConfiguration\n) => {\n const codePushUpdateMetadata = await codePush.getUpdateMetadata();\n if (codePushUpdateMetadata) {\n configuration.versionSuffix = `codepush.${codePushUpdateMetadata.label}`;\n }\n DatadogProvider.initialize(configuration);\n};\n\nexport const DatadogCodepushProvider: typeof DatadogProvider = ({\n configuration,\n ...rest\n}) => {\n // We cannot use SYNC or ASYNC initialization modes as we need to asynchronously get the CodePush version.\n // We turn it to partial initialization, while in parallel we get the CodePush version and initialize the SDK.\n if (configuration instanceof DatadogProviderConfiguration) {\n initializeWithCodepushVersion(configuration);\n const partialConfiguration = {\n trackErrors: configuration.trackErrors,\n trackResources: configuration.trackResources,\n trackInteractions: configuration.trackInteractions,\n firstPartyHosts: configuration.firstPartyHosts,\n resourceTracingSamplingRate:\n configuration.resourceTracingSamplingRate\n };\n return DatadogProvider({\n configuration: partialConfiguration,\n ...rest\n });\n } else {\n return DatadogProvider({ configuration, ...rest });\n }\n};\n\nDatadogCodepushProvider.initialize = async configuration => {\n const codePushUpdateMetadata = await codePush.getUpdateMetadata();\n if (codePushUpdateMetadata) {\n configuration.versionSuffix = `codepush.${codePushUpdateMetadata.label}`;\n }\n DatadogProvider.initialize(configuration);\n};\n"]}
@@ -1,4 +1,4 @@
1
- import { DdSdkReactNative } from '@datadog/mobile-react-native';
1
+ import { DatadogProvider, DatadogProviderConfiguration, DdSdkReactNative } from '@datadog/mobile-react-native';
2
2
  import codePush from 'react-native-code-push';
3
3
  /**
4
4
  * Use this class instead of DdSdkReactNative to initialize the Datadog SDK when using AppCenter CodePush.
@@ -16,4 +16,51 @@ export const DatadogCodepush = {
16
16
  }
17
17
 
18
18
  };
19
+
20
+ const initializeWithCodepushVersion = async configuration => {
21
+ const codePushUpdateMetadata = await codePush.getUpdateMetadata();
22
+
23
+ if (codePushUpdateMetadata) {
24
+ configuration.versionSuffix = `codepush.${codePushUpdateMetadata.label}`;
25
+ }
26
+
27
+ DatadogProvider.initialize(configuration);
28
+ };
29
+
30
+ export const DatadogCodepushProvider = ({
31
+ configuration,
32
+ ...rest
33
+ }) => {
34
+ // We cannot use SYNC or ASYNC initialization modes as we need to asynchronously get the CodePush version.
35
+ // We turn it to partial initialization, while in parallel we get the CodePush version and initialize the SDK.
36
+ if (configuration instanceof DatadogProviderConfiguration) {
37
+ initializeWithCodepushVersion(configuration);
38
+ const partialConfiguration = {
39
+ trackErrors: configuration.trackErrors,
40
+ trackResources: configuration.trackResources,
41
+ trackInteractions: configuration.trackInteractions,
42
+ firstPartyHosts: configuration.firstPartyHosts,
43
+ resourceTracingSamplingRate: configuration.resourceTracingSamplingRate
44
+ };
45
+ return DatadogProvider({
46
+ configuration: partialConfiguration,
47
+ ...rest
48
+ });
49
+ } else {
50
+ return DatadogProvider({
51
+ configuration,
52
+ ...rest
53
+ });
54
+ }
55
+ };
56
+
57
+ DatadogCodepushProvider.initialize = async configuration => {
58
+ const codePushUpdateMetadata = await codePush.getUpdateMetadata();
59
+
60
+ if (codePushUpdateMetadata) {
61
+ configuration.versionSuffix = `codepush.${codePushUpdateMetadata.label}`;
62
+ }
63
+
64
+ DatadogProvider.initialize(configuration);
65
+ };
19
66
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["index.ts"],"names":["DdSdkReactNative","codePush","DatadogCodepush","initialize","configuration","codePushUpdateMetadata","getUpdateMetadata","versionSuffix","label"],"mappings":"AAAA,SAASA,gBAAT,QAAiC,8BAAjC;AAEA,OAAOC,QAAP,MAAqB,wBAArB;AAEA;AACA;AACA;;AACA,OAAO,MAAMC,eAAe,GAAG;AAC3B,QAAMC,UAAN,CACIC,aADJ,EAEiB;AACb,UAAMC,sBAAsB,GAAG,MAAMJ,QAAQ,CAACK,iBAAT,EAArC;;AACA,QAAID,sBAAJ,EAA4B;AACxBD,MAAAA,aAAa,CAACG,aAAd,GAA+B,YAAWF,sBAAsB,CAACG,KAAM,EAAvE;AACH;;AACD,WAAOR,gBAAgB,CAACG,UAAjB,CAA4BC,aAA5B,CAAP;AACH;;AAT0B,CAAxB","sourcesContent":["import { DdSdkReactNative } from '@datadog/mobile-react-native';\nimport type { DdSdkReactNativeConfiguration } from '@datadog/mobile-react-native';\nimport codePush from 'react-native-code-push';\n\n/**\n * Use this class instead of DdSdkReactNative to initialize the Datadog SDK when using AppCenter CodePush.\n */\nexport const DatadogCodepush = {\n async initialize(\n configuration: DdSdkReactNativeConfiguration\n ): Promise<void> {\n const codePushUpdateMetadata = await codePush.getUpdateMetadata();\n if (codePushUpdateMetadata) {\n configuration.versionSuffix = `codepush.${codePushUpdateMetadata.label}`;\n }\n return DdSdkReactNative.initialize(configuration);\n }\n};\n"]}
1
+ {"version":3,"sources":["index.ts"],"names":["DatadogProvider","DatadogProviderConfiguration","DdSdkReactNative","codePush","DatadogCodepush","initialize","configuration","codePushUpdateMetadata","getUpdateMetadata","versionSuffix","label","initializeWithCodepushVersion","DatadogCodepushProvider","rest","partialConfiguration","trackErrors","trackResources","trackInteractions","firstPartyHosts","resourceTracingSamplingRate"],"mappings":"AAAA,SACIA,eADJ,EAEIC,4BAFJ,EAGIC,gBAHJ,QAIO,8BAJP;AAMA,OAAOC,QAAP,MAAqB,wBAArB;AAEA;AACA;AACA;;AACA,OAAO,MAAMC,eAAe,GAAG;AAC3B,QAAMC,UAAN,CACIC,aADJ,EAEiB;AACb,UAAMC,sBAAsB,GAAG,MAAMJ,QAAQ,CAACK,iBAAT,EAArC;;AACA,QAAID,sBAAJ,EAA4B;AACxBD,MAAAA,aAAa,CAACG,aAAd,GAA+B,YAAWF,sBAAsB,CAACG,KAAM,EAAvE;AACH;;AACD,WAAOR,gBAAgB,CAACG,UAAjB,CAA4BC,aAA5B,CAAP;AACH;;AAT0B,CAAxB;;AAYP,MAAMK,6BAA6B,GAAG,MAClCL,aADkC,IAEjC;AACD,QAAMC,sBAAsB,GAAG,MAAMJ,QAAQ,CAACK,iBAAT,EAArC;;AACA,MAAID,sBAAJ,EAA4B;AACxBD,IAAAA,aAAa,CAACG,aAAd,GAA+B,YAAWF,sBAAsB,CAACG,KAAM,EAAvE;AACH;;AACDV,EAAAA,eAAe,CAACK,UAAhB,CAA2BC,aAA3B;AACH,CARD;;AAUA,OAAO,MAAMM,uBAA+C,GAAG,CAAC;AAC5DN,EAAAA,aAD4D;AAE5D,KAAGO;AAFyD,CAAD,KAGzD;AACF;AACA;AACA,MAAIP,aAAa,YAAYL,4BAA7B,EAA2D;AACvDU,IAAAA,6BAA6B,CAACL,aAAD,CAA7B;AACA,UAAMQ,oBAAoB,GAAG;AACzBC,MAAAA,WAAW,EAAET,aAAa,CAACS,WADF;AAEzBC,MAAAA,cAAc,EAAEV,aAAa,CAACU,cAFL;AAGzBC,MAAAA,iBAAiB,EAAEX,aAAa,CAACW,iBAHR;AAIzBC,MAAAA,eAAe,EAAEZ,aAAa,CAACY,eAJN;AAKzBC,MAAAA,2BAA2B,EACvBb,aAAa,CAACa;AANO,KAA7B;AAQA,WAAOnB,eAAe,CAAC;AACnBM,MAAAA,aAAa,EAAEQ,oBADI;AAEnB,SAAGD;AAFgB,KAAD,CAAtB;AAIH,GAdD,MAcO;AACH,WAAOb,eAAe,CAAC;AAAEM,MAAAA,aAAF;AAAiB,SAAGO;AAApB,KAAD,CAAtB;AACH;AACJ,CAvBM;;AAyBPD,uBAAuB,CAACP,UAAxB,GAAqC,MAAMC,aAAN,IAAuB;AACxD,QAAMC,sBAAsB,GAAG,MAAMJ,QAAQ,CAACK,iBAAT,EAArC;;AACA,MAAID,sBAAJ,EAA4B;AACxBD,IAAAA,aAAa,CAACG,aAAd,GAA+B,YAAWF,sBAAsB,CAACG,KAAM,EAAvE;AACH;;AACDV,EAAAA,eAAe,CAACK,UAAhB,CAA2BC,aAA3B;AACH,CAND","sourcesContent":["import {\n DatadogProvider,\n DatadogProviderConfiguration,\n DdSdkReactNative\n} from '@datadog/mobile-react-native';\nimport type { DdSdkReactNativeConfiguration } from '@datadog/mobile-react-native';\nimport codePush from 'react-native-code-push';\n\n/**\n * Use this class instead of DdSdkReactNative to initialize the Datadog SDK when using AppCenter CodePush.\n */\nexport const DatadogCodepush = {\n async initialize(\n configuration: DdSdkReactNativeConfiguration\n ): Promise<void> {\n const codePushUpdateMetadata = await codePush.getUpdateMetadata();\n if (codePushUpdateMetadata) {\n configuration.versionSuffix = `codepush.${codePushUpdateMetadata.label}`;\n }\n return DdSdkReactNative.initialize(configuration);\n }\n};\n\nconst initializeWithCodepushVersion = async (\n configuration: DatadogProviderConfiguration\n) => {\n const codePushUpdateMetadata = await codePush.getUpdateMetadata();\n if (codePushUpdateMetadata) {\n configuration.versionSuffix = `codepush.${codePushUpdateMetadata.label}`;\n }\n DatadogProvider.initialize(configuration);\n};\n\nexport const DatadogCodepushProvider: typeof DatadogProvider = ({\n configuration,\n ...rest\n}) => {\n // We cannot use SYNC or ASYNC initialization modes as we need to asynchronously get the CodePush version.\n // We turn it to partial initialization, while in parallel we get the CodePush version and initialize the SDK.\n if (configuration instanceof DatadogProviderConfiguration) {\n initializeWithCodepushVersion(configuration);\n const partialConfiguration = {\n trackErrors: configuration.trackErrors,\n trackResources: configuration.trackResources,\n trackInteractions: configuration.trackInteractions,\n firstPartyHosts: configuration.firstPartyHosts,\n resourceTracingSamplingRate:\n configuration.resourceTracingSamplingRate\n };\n return DatadogProvider({\n configuration: partialConfiguration,\n ...rest\n });\n } else {\n return DatadogProvider({ configuration, ...rest });\n }\n};\n\nDatadogCodepushProvider.initialize = async configuration => {\n const codePushUpdateMetadata = await codePush.getUpdateMetadata();\n if (codePushUpdateMetadata) {\n configuration.versionSuffix = `codepush.${codePushUpdateMetadata.label}`;\n }\n DatadogProvider.initialize(configuration);\n};\n"]}
@@ -1,3 +1,4 @@
1
+ import { DatadogProvider } from '@datadog/mobile-react-native';
1
2
  import type { DdSdkReactNativeConfiguration } from '@datadog/mobile-react-native';
2
3
  /**
3
4
  * Use this class instead of DdSdkReactNative to initialize the Datadog SDK when using AppCenter CodePush.
@@ -5,3 +6,4 @@ import type { DdSdkReactNativeConfiguration } from '@datadog/mobile-react-native
5
6
  export declare const DatadogCodepush: {
6
7
  initialize(configuration: DdSdkReactNativeConfiguration): Promise<void>;
7
8
  };
9
+ export declare const DatadogCodepushProvider: typeof DatadogProvider;
@@ -0,0 +1,15 @@
1
+ import { DatadogBuffer } from './DatadogBuffer';
2
+ export declare class BoundedBuffer extends DatadogBuffer {
3
+ private bufferSize;
4
+ private buffer;
5
+ private idTable;
6
+ private telemetryBuffer;
7
+ constructor(bufferSize?: number);
8
+ addCallback: (callback: () => Promise<void>) => Promise<void>;
9
+ addCallbackReturningId: (callback: () => Promise<string>) => Promise<string>;
10
+ addCallbackWithId: (callback: (id: string) => Promise<void>, bufferId: string) => Promise<void>;
11
+ drain: () => Promise<void>;
12
+ private generateRandomBufferId;
13
+ private addTelemetryEvent;
14
+ private drainTelemetry;
15
+ }
@@ -0,0 +1,7 @@
1
+ import type { DatadogBuffer } from './DatadogBuffer';
2
+ export declare class BufferSingleton {
3
+ private static bufferInstance;
4
+ static getInstance: () => DatadogBuffer;
5
+ static onInitialization: () => void;
6
+ static reset: () => void;
7
+ }
@@ -0,0 +1,20 @@
1
+ export declare abstract class DatadogBuffer {
2
+ /**
3
+ * Add a callback that takes no input and yields no output to the buffer.
4
+ */
5
+ abstract addCallback: (callback: () => Promise<void>) => Promise<void>;
6
+ /**
7
+ * Add a callback that returns an id to the buffer.
8
+ * This method also returns an id (possibly different), to be passed to addCallbackWithId.
9
+ */
10
+ abstract addCallbackReturningId: (callback: () => Promise<string>) => Promise<string>;
11
+ /**
12
+ * Add a callback that takes an id as input to the buffer.
13
+ * This id must be obtained by calling addCallbackReturningId.
14
+ */
15
+ abstract addCallbackWithId: (callback: (id: string) => Promise<void>, id: string) => Promise<void>;
16
+ /**
17
+ * Execute all callbacks in the buffer.
18
+ */
19
+ abstract drain: () => void;
20
+ }
@@ -0,0 +1,7 @@
1
+ import { DatadogBuffer } from './DatadogBuffer';
2
+ export declare class PassThroughBuffer extends DatadogBuffer {
3
+ addCallback: (callback: () => any) => any;
4
+ addCallbackReturningId: (callback: () => any) => any;
5
+ addCallbackWithId: (callback: (id: string) => any, id: string) => any;
6
+ drain: () => undefined;
7
+ }
@@ -0,0 +1,3 @@
1
+ export declare const bufferVoidNativeCall: (callback: () => Promise<void>) => Promise<void>;
2
+ export declare const bufferNativeCallReturningId: (callback: () => Promise<string>) => Promise<string>;
3
+ export declare const bufferNativeCallWithId: (callback: (id: string) => Promise<void>, id: string) => Promise<void>;
@@ -0,0 +1,26 @@
1
+ import React from 'react';
2
+ import type { PropsWithChildren } from 'react';
3
+ import { DatadogProviderConfiguration } from '../DdSdkReactNativeConfiguration';
4
+ import type { PartialInitializationConfiguration, AutoInstrumentationConfiguration } from '../DdSdkReactNativeConfiguration';
5
+ declare type Props = PropsWithChildren<{
6
+ /**
7
+ * If a `DatadogProviderConfiguration` instance is passed, the SDK will start tracking errors, resources and actions and sending events.
8
+ *
9
+ * If a `AutoInstrumentationConfiguration` object is passed, the SDK will start tracking errors, resources and actions. To start sending events, call `DatadogProvider.initialize`.
10
+ */
11
+ configuration: DatadogProviderConfiguration | AutoInstrumentationConfiguration;
12
+ /**
13
+ * Callback to be run once the SDK starts sending events.
14
+ */
15
+ onInitialization?: () => void;
16
+ }>;
17
+ declare type StaticProperties = {
18
+ initialize: (configuration: PartialInitializationConfiguration) => Promise<void>;
19
+ onInitialization?: () => void;
20
+ };
21
+ /**
22
+ * Set up the Datadog React Native SDK.
23
+ */
24
+ export declare const DatadogProvider: React.FC<Props> & StaticProperties;
25
+ export declare const __internalResetIsInitializedForTesting: () => void;
26
+ export {};
@@ -1,4 +1,5 @@
1
- import type { DdSdkReactNativeConfiguration } from './DdSdkReactNativeConfiguration';
1
+ import { DdSdkReactNativeConfiguration } from './DdSdkReactNativeConfiguration';
2
+ import type { DatadogProviderConfiguration, PartialInitializationConfiguration, AutoInstrumentationConfiguration } from './DdSdkReactNativeConfiguration';
2
3
  import type { TrackingConsent } from './TrackingConsent';
3
4
  /**
4
5
  * This class initializes the Datadog SDK, and sets up communication with the server.
@@ -19,12 +20,32 @@ export declare class DdSdkReactNative {
19
20
  private static readonly DD_NATIVE_LONG_TASK_THRESHOLD_KEY;
20
21
  private static readonly NATIVE_LONG_TASK_THRESHOLD_MS;
21
22
  private static wasInitialized;
23
+ private static wasAutoInstrumented;
24
+ private static configuration?;
25
+ private static features?;
22
26
  /**
23
27
  * Initializes the Datadog SDK.
24
28
  * @param configuration the configuration for the SDK library
25
29
  * @returns a Promise.
26
30
  */
27
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 _initializeFromDatadogProviderAsync: () => Promise<void>;
45
+ /**
46
+ * FOR INTERNAL USE ONLY.
47
+ */
48
+ static _initializeFromDatadogProviderWithConfigurationAsync: (configuration: PartialInitializationConfiguration) => Promise<void>;
28
49
  /**
29
50
  * Sets the global context (set of attributes) attached with all future Logs, Spans and RUM events.
30
51
  * @param attributes: The global context attributes.
@@ -43,5 +64,6 @@ export declare class DdSdkReactNative {
43
64
  * @returns a Promise.
44
65
  */
45
66
  static setTrackingConsent(consent: TrackingConsent): Promise<void>;
67
+ private static buildConfiguration;
46
68
  private static enableFeatures;
47
69
  }
@@ -52,8 +52,71 @@ export declare class DdSdkReactNativeConfiguration {
52
52
  * A dash (`-`) will be automatically added between the version and the suffix
53
53
  */
54
54
  versionSuffix?: string;
55
+ /**
56
+ * The sampling rate for Internal Telemetry (info related to the work of the
57
+ * SDK internals).
58
+ *
59
+ * The sampling rate must be a value between 0 and 100. A value of 0 means no
60
+ * telemetry will be sent, 100 means all telemetry will be sent. When
61
+ * `telemetrySampleRate` is not set, the default value from the iOS and
62
+ * Android SDK is used, which is 20.
63
+ */
64
+ telemetrySampleRate: number;
55
65
  additionalConfig: {
56
66
  [k: string]: any;
57
67
  };
58
68
  constructor(clientToken: string, env: string, applicationId: string, trackInteractions?: boolean, trackResources?: boolean, trackErrors?: boolean, trackingConsent?: TrackingConsent);
59
69
  }
70
+ /**
71
+ * Auto Instrumentation configuration passed to DatadogProvider.
72
+ * Does not include default values.
73
+ */
74
+ export declare type AutoInstrumentationConfiguration = {
75
+ readonly trackInteractions: boolean;
76
+ readonly trackResources: boolean;
77
+ readonly firstPartyHosts?: string[];
78
+ readonly resourceTracingSamplingRate?: number;
79
+ readonly trackErrors: boolean;
80
+ };
81
+ /**
82
+ * Parameters needed to start auto instrumentation. Includes default values.
83
+ */
84
+ export declare type AutoInstrumentationParameters = {
85
+ readonly trackInteractions: boolean;
86
+ readonly trackResources: boolean;
87
+ readonly firstPartyHosts: string[];
88
+ readonly resourceTracingSamplingRate: number;
89
+ readonly trackErrors: boolean;
90
+ };
91
+ /**
92
+ * We could use `Proxy` instead of this function, but `Proxy` is not available on
93
+ * the older android jsc that can still be used.
94
+ */
95
+ export declare const addDefaultValuesToAutoInstrumentationConfiguration: (features: AutoInstrumentationConfiguration) => AutoInstrumentationParameters;
96
+ export declare type PartialInitializationConfiguration = {
97
+ readonly clientToken: string;
98
+ readonly env: string;
99
+ readonly applicationId: string;
100
+ readonly sessionSamplingRate?: number;
101
+ readonly site?: string;
102
+ readonly verbosity?: SdkVerbosity | undefined;
103
+ readonly nativeViewTracking?: boolean;
104
+ readonly proxyConfig?: ProxyConfiguration;
105
+ readonly serviceName?: string;
106
+ readonly version?: string;
107
+ versionSuffix?: string;
108
+ readonly additionalConfig?: {
109
+ [k: string]: any;
110
+ };
111
+ readonly trackingConsent?: TrackingConsent;
112
+ readonly nativeCrashReportEnabled?: boolean;
113
+ readonly telemetrySampleRate?: number;
114
+ };
115
+ export declare const buildConfigurationFromPartialConfiguration: (features: AutoInstrumentationConfiguration, configuration: PartialInitializationConfiguration) => DdSdkReactNativeConfiguration;
116
+ export declare class DatadogProviderConfiguration extends DdSdkReactNativeConfiguration {
117
+ initializationMode: InitializationMode;
118
+ }
119
+ export declare enum InitializationMode {
120
+ SYNC = "SYNC",
121
+ ASYNC = "ASYNC"
122
+ }
@@ -0,0 +1,4 @@
1
+ export declare const EMPTY_MESSAGE = "Unknown Error";
2
+ export declare const EMPTY_STACK_TRACE = "";
3
+ export declare const getErrorMessage: (error: any | undefined) => string;
4
+ export declare const getErrorStackTrace: (error: any | undefined) => string;
@@ -1,4 +1,5 @@
1
- import { DdSdkReactNativeConfiguration } from './DdSdkReactNativeConfiguration';
1
+ import { DatadogProvider } from './DatadogProvider/DatadogProvider';
2
+ import { DatadogProviderConfiguration, DdSdkReactNativeConfiguration, InitializationMode } from './DdSdkReactNativeConfiguration';
2
3
  import { DdSdkReactNative } from './DdSdkReactNative';
3
4
  import { InternalLog } from './InternalLog';
4
5
  import { ProxyConfiguration, ProxyType } from './ProxyConfiguration';
@@ -6,4 +7,4 @@ import { SdkVerbosity } from './SdkVerbosity';
6
7
  import { TrackingConsent } from './TrackingConsent';
7
8
  import { DdLogs, DdTrace, DdRum } from './foundation';
8
9
  import { RumActionType, ErrorSource } from './types';
9
- export { DdLogs, DdTrace, DdRum, RumActionType, ErrorSource, DdSdkReactNativeConfiguration, DdSdkReactNative, InternalLog, ProxyConfiguration, ProxyType, TrackingConsent, SdkVerbosity };
10
+ export { DatadogProvider, DatadogProviderConfiguration, InitializationMode, DdLogs, DdTrace, DdRum, RumActionType, ErrorSource, DdSdkReactNativeConfiguration, DdSdkReactNative, InternalLog, ProxyConfiguration, ProxyType, TrackingConsent, SdkVerbosity };
@@ -36,6 +36,18 @@ export declare type DdNativeSdkType = {
36
36
  * @param trackingConsent: Consent, which can take one of the following values: 'pending', 'granted', 'not_granted'.
37
37
  */
38
38
  setTrackingConsent(trackingConsent: string): Promise<void>;
39
+ /**
40
+ * Sends internal telemetry debug message
41
+ * @param message debug message
42
+ */
43
+ telemetryDebug(message: string): Promise<void>;
44
+ /**
45
+ * Sends internal telemetry error
46
+ * @param message error message
47
+ * @param stack error stack
48
+ * @param kind error kind
49
+ */
50
+ telemetryError(message: string, stack: string, kind: string): Promise<void>;
39
51
  };
40
52
  /**
41
53
  * The entry point to use Datadog's Logs feature.
@@ -12,6 +12,4 @@ export declare class DdRumErrorTracking {
12
12
  static startTracking(): void;
13
13
  static onGlobalError(error: any, isFatal?: boolean): void;
14
14
  static onConsoleError(...params: unknown[]): void;
15
- private static getErrorMessage;
16
- private static getErrorStackTrace;
17
15
  }
@@ -5,6 +5,8 @@
5
5
  export declare class DdRumUserInteractionTracking {
6
6
  private static isTracking;
7
7
  private static eventsInterceptor;
8
+ private static originalCreateElement;
9
+ private static originalMemo;
8
10
  private static patchCreateElementFunction;
9
11
  /**
10
12
  * Starts tracking user interactions and sends a RUM Action event every time a new interaction was detected.
@@ -12,4 +14,5 @@ export declare class DdRumUserInteractionTracking {
12
14
  * a visible output (either an UI state change or a Resource request)
13
15
  */
14
16
  static startTracking(): void;
17
+ static stopTracking(): void;
15
18
  }
@@ -10,7 +10,8 @@ export declare class DdSdkConfiguration {
10
10
  readonly site: string;
11
11
  readonly trackingConsent: string;
12
12
  readonly additionalConfig: object;
13
- constructor(clientToken: string, env: string, applicationId: string, nativeCrashReportEnabled: boolean, sampleRate: number, site: string, trackingConsent: string, additionalConfig: object);
13
+ readonly telemetrySampleRate: number;
14
+ constructor(clientToken: string, env: string, applicationId: string, nativeCrashReportEnabled: boolean, sampleRate: number, site: string, trackingConsent: string, additionalConfig: object, telemetrySampleRate: number);
14
15
  }
15
16
  /**
16
17
  * The entry point to initialize Datadog's features.
@@ -1 +1 @@
1
- export declare const version = "1.1.4";
1
+ export declare const version = "1.2.0-beta1";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@datadog/mobile-react-native-code-push",
3
- "version": "1.1.4",
3
+ "version": "1.2.0-beta1",
4
4
  "description": "A client-side React Native module to interact with Appcenter Codepush and Datadog",
5
5
  "keywords": [
6
6
  "datadog",
@@ -38,7 +38,7 @@
38
38
  "prepare": "rm -rf lib && yarn bob build"
39
39
  },
40
40
  "devDependencies": {
41
- "@datadog/mobile-react-native": "^1.1.4",
41
+ "@datadog/mobile-react-native": "^1.2.0-beta1",
42
42
  "@testing-library/react-native": "7.0.2",
43
43
  "react-native-code-push": "7.0.5"
44
44
  },
@@ -72,5 +72,5 @@
72
72
  ]
73
73
  ]
74
74
  },
75
- "gitHead": "7baf5db95c89544dde5488437b43f13cccb3a18e"
75
+ "gitHead": "c367071a477296075f9140771e4c01f19dd40377"
76
76
  }
@@ -0,0 +1,213 @@
1
+ import {
2
+ DdSdkReactNative,
3
+ DdSdkReactNativeConfiguration,
4
+ DatadogProviderConfiguration
5
+ } from '@datadog/mobile-react-native';
6
+ import { render } from '@testing-library/react-native';
7
+ import codePush from 'react-native-code-push';
8
+ import React from 'react';
9
+
10
+ import { DatadogCodepush, DatadogCodepushProvider } from '..';
11
+
12
+ jest.mock('react-native-code-push', () => ({
13
+ getUpdateMetadata: jest.fn()
14
+ }));
15
+
16
+ jest.mock('@datadog/mobile-react-native', () => {
17
+ const actualPackage = jest.requireActual('@datadog/mobile-react-native');
18
+ actualPackage.DdSdkReactNative.initialize = jest.fn();
19
+ actualPackage.DdSdkReactNative._initializeFromDatadogProviderWithConfigurationAsync = jest.fn();
20
+ return actualPackage;
21
+ });
22
+
23
+ const flushPromises = () => new Promise(setImmediate);
24
+
25
+ const createCodepushPackageMock = label => ({
26
+ label,
27
+ isMandatory: false,
28
+ install: jest.fn(),
29
+ appVersion: '1.0.0',
30
+ deploymentKey: '1',
31
+ description: '1',
32
+ failedInstall: false,
33
+ isFirstRun: false,
34
+ isPending: false,
35
+ packageHash: '1',
36
+ packageSize: 42
37
+ });
38
+
39
+ describe('AppCenter Codepush integration', () => {
40
+ beforeEach(() => {
41
+ jest.clearAllMocks();
42
+ });
43
+ describe('initialize', () => {
44
+ it('initializes the SDK with the correct version when using a CodePush bundle', async () => {
45
+ (codePush.getUpdateMetadata as jest.MockedFunction<
46
+ typeof codePush.getUpdateMetadata
47
+ >).mockResolvedValueOnce(createCodepushPackageMock('v3'));
48
+
49
+ const configuration = new DdSdkReactNativeConfiguration(
50
+ 'token',
51
+ 'env',
52
+ 'appId',
53
+ true,
54
+ true,
55
+ true
56
+ );
57
+
58
+ await DatadogCodepush.initialize(configuration);
59
+
60
+ expect(DdSdkReactNative.initialize).toHaveBeenCalledTimes(1);
61
+ expect(DdSdkReactNative.initialize).toHaveBeenCalledWith(
62
+ expect.objectContaining({ versionSuffix: 'codepush.v3' })
63
+ );
64
+ });
65
+
66
+ it('initializes the SDK with the correct version when not using a CodePush bundle', async () => {
67
+ (codePush.getUpdateMetadata as jest.MockedFunction<
68
+ typeof codePush.getUpdateMetadata
69
+ >).mockResolvedValueOnce(null);
70
+
71
+ const configuration = new DdSdkReactNativeConfiguration(
72
+ 'token',
73
+ 'env',
74
+ 'appId',
75
+ true,
76
+ true,
77
+ true
78
+ );
79
+
80
+ await DatadogCodepush.initialize(configuration);
81
+
82
+ expect(DdSdkReactNative.initialize).toHaveBeenCalledTimes(1);
83
+ expect(
84
+ Object.keys(
85
+ (DdSdkReactNative.initialize as jest.MockedFunction<
86
+ typeof DdSdkReactNative.initialize
87
+ >).mock.calls[0]
88
+ )
89
+ ).not.toContain('versionSuffix');
90
+ });
91
+ });
92
+
93
+ describe('DatadogCodepushProvider', () => {
94
+ it('initializes the sdk with the right codepush version when using DatadogProviderConfiguration', async () => {
95
+ (codePush.getUpdateMetadata as jest.MockedFunction<
96
+ typeof codePush.getUpdateMetadata
97
+ >).mockResolvedValueOnce(createCodepushPackageMock('v4'));
98
+
99
+ const configuration = new DatadogProviderConfiguration(
100
+ 'token',
101
+ 'env',
102
+ 'appId',
103
+ true,
104
+ true,
105
+ true
106
+ );
107
+ render(<DatadogCodepushProvider configuration={configuration} />);
108
+ await flushPromises();
109
+
110
+ expect(
111
+ DdSdkReactNative._initializeFromDatadogProviderWithConfigurationAsync
112
+ ).toHaveBeenCalledTimes(1);
113
+ expect(
114
+ DdSdkReactNative._initializeFromDatadogProviderWithConfigurationAsync
115
+ ).toHaveBeenCalledWith(
116
+ expect.objectContaining({ versionSuffix: 'codepush.v4' })
117
+ );
118
+ });
119
+ it('initializes the sdk with the right codepush version when using partial configuration', async () => {
120
+ (codePush.getUpdateMetadata as jest.MockedFunction<
121
+ typeof codePush.getUpdateMetadata
122
+ >).mockResolvedValueOnce(createCodepushPackageMock('v5'));
123
+
124
+ const configuration = {
125
+ trackErrors: true,
126
+ trackInteractions: true,
127
+ trackResources: true
128
+ };
129
+ render(<DatadogCodepushProvider configuration={configuration} />);
130
+ await flushPromises();
131
+ expect(
132
+ DdSdkReactNative._initializeFromDatadogProviderWithConfigurationAsync
133
+ ).not.toHaveBeenCalled();
134
+
135
+ DatadogCodepushProvider.initialize({
136
+ applicationId: 'fake-application-id',
137
+ clientToken: 'fake-client-token',
138
+ env: 'fake-env'
139
+ });
140
+ await flushPromises();
141
+
142
+ expect(
143
+ DdSdkReactNative._initializeFromDatadogProviderWithConfigurationAsync
144
+ ).toHaveBeenCalledTimes(1);
145
+ expect(
146
+ DdSdkReactNative._initializeFromDatadogProviderWithConfigurationAsync
147
+ ).toHaveBeenCalledWith(
148
+ expect.objectContaining({ versionSuffix: 'codepush.v5' })
149
+ );
150
+ });
151
+ it('initializes the sdk with commercial version when using DatadogProviderConfiguration', async () => {
152
+ (codePush.getUpdateMetadata as jest.MockedFunction<
153
+ typeof codePush.getUpdateMetadata
154
+ >).mockResolvedValueOnce(createCodepushPackageMock(null));
155
+
156
+ const configuration = new DatadogProviderConfiguration(
157
+ 'token',
158
+ 'env',
159
+ 'appId',
160
+ true,
161
+ true,
162
+ true
163
+ );
164
+ render(<DatadogCodepushProvider configuration={configuration} />);
165
+ await flushPromises();
166
+
167
+ expect(
168
+ DdSdkReactNative._initializeFromDatadogProviderWithConfigurationAsync
169
+ ).toHaveBeenCalledTimes(1);
170
+ expect(
171
+ Object.keys(
172
+ (DdSdkReactNative._initializeFromDatadogProviderWithConfigurationAsync as jest.MockedFunction<
173
+ typeof DdSdkReactNative._initializeFromDatadogProviderWithConfigurationAsync
174
+ >).mock.calls[0]
175
+ )
176
+ ).not.toContain('versionSuffix');
177
+ });
178
+ it('initializes the sdk with commercial version when using partial configuration', async () => {
179
+ (codePush.getUpdateMetadata as jest.MockedFunction<
180
+ typeof codePush.getUpdateMetadata
181
+ >).mockResolvedValueOnce(createCodepushPackageMock(null));
182
+
183
+ const configuration = {
184
+ trackErrors: true,
185
+ trackInteractions: true,
186
+ trackResources: true
187
+ };
188
+ render(<DatadogCodepushProvider configuration={configuration} />);
189
+ await flushPromises();
190
+ expect(
191
+ DdSdkReactNative._initializeFromDatadogProviderWithConfigurationAsync
192
+ ).not.toHaveBeenCalled();
193
+
194
+ DatadogCodepushProvider.initialize({
195
+ applicationId: 'fake-application-id',
196
+ clientToken: 'fake-client-token',
197
+ env: 'fake-env'
198
+ });
199
+ await flushPromises();
200
+
201
+ expect(
202
+ DdSdkReactNative._initializeFromDatadogProviderWithConfigurationAsync
203
+ ).toHaveBeenCalledTimes(1);
204
+ expect(
205
+ Object.keys(
206
+ (DdSdkReactNative._initializeFromDatadogProviderWithConfigurationAsync as jest.MockedFunction<
207
+ typeof DdSdkReactNative._initializeFromDatadogProviderWithConfigurationAsync
208
+ >).mock.calls[0]
209
+ )
210
+ ).not.toContain('versionSuffix');
211
+ });
212
+ });
213
+ });
package/src/index.ts CHANGED
@@ -1,4 +1,8 @@
1
- import { DdSdkReactNative } from '@datadog/mobile-react-native';
1
+ import {
2
+ DatadogProvider,
3
+ DatadogProviderConfiguration,
4
+ DdSdkReactNative
5
+ } from '@datadog/mobile-react-native';
2
6
  import type { DdSdkReactNativeConfiguration } from '@datadog/mobile-react-native';
3
7
  import codePush from 'react-native-code-push';
4
8
 
@@ -16,3 +20,46 @@ export const DatadogCodepush = {
16
20
  return DdSdkReactNative.initialize(configuration);
17
21
  }
18
22
  };
23
+
24
+ const initializeWithCodepushVersion = async (
25
+ configuration: DatadogProviderConfiguration
26
+ ) => {
27
+ const codePushUpdateMetadata = await codePush.getUpdateMetadata();
28
+ if (codePushUpdateMetadata) {
29
+ configuration.versionSuffix = `codepush.${codePushUpdateMetadata.label}`;
30
+ }
31
+ DatadogProvider.initialize(configuration);
32
+ };
33
+
34
+ export const DatadogCodepushProvider: typeof DatadogProvider = ({
35
+ configuration,
36
+ ...rest
37
+ }) => {
38
+ // We cannot use SYNC or ASYNC initialization modes as we need to asynchronously get the CodePush version.
39
+ // We turn it to partial initialization, while in parallel we get the CodePush version and initialize the SDK.
40
+ if (configuration instanceof DatadogProviderConfiguration) {
41
+ initializeWithCodepushVersion(configuration);
42
+ const partialConfiguration = {
43
+ trackErrors: configuration.trackErrors,
44
+ trackResources: configuration.trackResources,
45
+ trackInteractions: configuration.trackInteractions,
46
+ firstPartyHosts: configuration.firstPartyHosts,
47
+ resourceTracingSamplingRate:
48
+ configuration.resourceTracingSamplingRate
49
+ };
50
+ return DatadogProvider({
51
+ configuration: partialConfiguration,
52
+ ...rest
53
+ });
54
+ } else {
55
+ return DatadogProvider({ configuration, ...rest });
56
+ }
57
+ };
58
+
59
+ DatadogCodepushProvider.initialize = async configuration => {
60
+ const codePushUpdateMetadata = await codePush.getUpdateMetadata();
61
+ if (codePushUpdateMetadata) {
62
+ configuration.versionSuffix = `codepush.${codePushUpdateMetadata.label}`;
63
+ }
64
+ DatadogProvider.initialize(configuration);
65
+ };
@@ -1,88 +0,0 @@
1
- import {
2
- DdSdkReactNative,
3
- DdSdkReactNativeConfiguration
4
- } from '@datadog/mobile-react-native';
5
- import codePush from 'react-native-code-push';
6
-
7
- import { DatadogCodepush } from '..';
8
-
9
- jest.mock('react-native-code-push', () => ({
10
- getUpdateMetadata: jest.fn()
11
- }));
12
-
13
- jest.mock('@datadog/mobile-react-native', () => {
14
- const actualPackage = jest.requireActual('@datadog/mobile-react-native');
15
- return {
16
- ...actualPackage,
17
- DdSdkReactNative: {
18
- initialize: jest.fn()
19
- }
20
- };
21
- });
22
-
23
- describe('AppCenter Codepush integration', () => {
24
- beforeEach(() => {
25
- jest.clearAllMocks();
26
- });
27
- describe('initialize', () => {
28
- it('initializes the SDK with the correct version when using a CodePush bundle', async () => {
29
- (codePush.getUpdateMetadata as jest.MockedFunction<
30
- typeof codePush.getUpdateMetadata
31
- >).mockResolvedValueOnce({
32
- label: 'v3',
33
- isMandatory: false,
34
- install: jest.fn(),
35
- appVersion: '1.0.0',
36
- deploymentKey: '1',
37
- description: '1',
38
- failedInstall: false,
39
- isFirstRun: false,
40
- isPending: false,
41
- packageHash: '1',
42
- packageSize: 42
43
- });
44
-
45
- const configuration = new DdSdkReactNativeConfiguration(
46
- 'token',
47
- 'env',
48
- 'appId',
49
- true,
50
- true,
51
- true
52
- );
53
-
54
- await DatadogCodepush.initialize(configuration);
55
-
56
- expect(DdSdkReactNative.initialize).toHaveBeenCalledTimes(1);
57
- expect(DdSdkReactNative.initialize).toHaveBeenCalledWith(
58
- expect.objectContaining({ versionSuffix: 'codepush.v3' })
59
- );
60
- });
61
-
62
- it('initializes the SDK with the correct version when not using a CodePush bundle', async () => {
63
- (codePush.getUpdateMetadata as jest.MockedFunction<
64
- typeof codePush.getUpdateMetadata
65
- >).mockResolvedValueOnce(null);
66
-
67
- const configuration = new DdSdkReactNativeConfiguration(
68
- 'token',
69
- 'env',
70
- 'appId',
71
- true,
72
- true,
73
- true
74
- );
75
-
76
- await DatadogCodepush.initialize(configuration);
77
-
78
- expect(DdSdkReactNative.initialize).toHaveBeenCalledTimes(1);
79
- expect(
80
- Object.keys(
81
- (DdSdkReactNative.initialize as jest.MockedFunction<
82
- typeof DdSdkReactNative.initialize
83
- >).mock.calls[0]
84
- )
85
- ).not.toContain('versionSuffix');
86
- });
87
- });
88
- });