@datadog/mobile-react-native-code-push 1.1.5 → 1.2.0-beta2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/commonjs/index.js +50 -1
- package/lib/commonjs/index.js.map +1 -1
- package/lib/module/index.js +48 -1
- package/lib/module/index.js.map +1 -1
- package/lib/typescript/codepush/src/index.d.ts +2 -0
- package/lib/typescript/core/src/DatadogProvider/Buffer/BoundedBuffer.d.ts +15 -0
- package/lib/typescript/core/src/DatadogProvider/Buffer/BufferSingleton.d.ts +7 -0
- package/lib/typescript/core/src/DatadogProvider/Buffer/DatadogBuffer.d.ts +20 -0
- package/lib/typescript/core/src/DatadogProvider/Buffer/PassThroughBuffer.d.ts +7 -0
- package/lib/typescript/core/src/DatadogProvider/Buffer/bufferNativeCall.d.ts +3 -0
- package/lib/typescript/core/src/DatadogProvider/DatadogProvider.d.ts +26 -0
- package/lib/typescript/core/src/DdSdkReactNative.d.ts +18 -3
- package/lib/typescript/core/src/DdSdkReactNativeConfiguration.d.ts +114 -0
- package/lib/typescript/core/src/errorUtils.d.ts +12 -0
- package/lib/typescript/core/src/index.d.ts +3 -2
- package/lib/typescript/core/src/longTasksUtils.d.ts +6 -0
- package/lib/typescript/core/src/nativeModulesTypes.d.ts +12 -0
- package/lib/typescript/core/src/rum/instrumentation/DdRumErrorTracking.d.ts +0 -2
- package/lib/typescript/core/src/rum/instrumentation/DdRumUserInteractionTracking.d.ts +3 -0
- package/lib/typescript/core/src/rum/instrumentation/resourceTracking/domain/distributedTracing.d.ts +1 -0
- package/lib/typescript/core/src/rum/instrumentation/resourceTracking/domain/interfaces/RumResource.d.ts +1 -1
- package/lib/typescript/core/src/types.d.ts +16 -1
- package/lib/typescript/core/src/version.d.ts +1 -1
- package/package.json +3 -3
- package/src/__tests__/index.test.tsx +213 -0
- package/src/index.ts +48 -1
- package/src/__tests__/index.test.ts +0 -88
package/lib/commonjs/index.js
CHANGED
|
@@ -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;;
|
|
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"]}
|
package/lib/module/index.js
CHANGED
|
@@ -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
|
package/lib/module/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["index.ts"],"names":["DdSdkReactNative","codePush","DatadogCodepush","initialize","configuration","codePushUpdateMetadata","getUpdateMetadata","versionSuffix","label"],"mappings":"AAAA,
|
|
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,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
|
|
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.
|
|
@@ -16,15 +17,28 @@ export declare class DdSdkReactNative {
|
|
|
16
17
|
private static readonly DD_PROXY_PORT_KEY;
|
|
17
18
|
private static readonly DD_PROXY_USERNAME_KEY;
|
|
18
19
|
private static readonly DD_PROXY_PASSWORD_KEY;
|
|
19
|
-
private static readonly DD_NATIVE_LONG_TASK_THRESHOLD_KEY;
|
|
20
|
-
private static readonly NATIVE_LONG_TASK_THRESHOLD_MS;
|
|
21
20
|
private static wasInitialized;
|
|
21
|
+
private static wasAutoInstrumented;
|
|
22
|
+
private static features?;
|
|
22
23
|
/**
|
|
23
24
|
* Initializes the Datadog SDK.
|
|
24
25
|
* @param configuration the configuration for the SDK library
|
|
25
26
|
* @returns a Promise.
|
|
26
27
|
*/
|
|
27
28
|
static initialize(configuration: DdSdkReactNativeConfiguration): Promise<void>;
|
|
29
|
+
private static initializeNativeSDK;
|
|
30
|
+
/**
|
|
31
|
+
* FOR INTERNAL USE ONLY.
|
|
32
|
+
*/
|
|
33
|
+
static _initializeFromDatadogProvider(configuration: DatadogProviderConfiguration): Promise<void>;
|
|
34
|
+
/**
|
|
35
|
+
* FOR INTERNAL USE ONLY.
|
|
36
|
+
*/
|
|
37
|
+
static _enableFeaturesFromDatadogProvider(features: AutoInstrumentationConfiguration): Promise<void>;
|
|
38
|
+
/**
|
|
39
|
+
* FOR INTERNAL USE ONLY.
|
|
40
|
+
*/
|
|
41
|
+
static _initializeFromDatadogProviderWithConfigurationAsync: (configuration: PartialInitializationConfiguration) => Promise<void>;
|
|
28
42
|
/**
|
|
29
43
|
* Sets the global context (set of attributes) attached with all future Logs, Spans and RUM events.
|
|
30
44
|
* @param attributes: The global context attributes.
|
|
@@ -43,5 +57,6 @@ export declare class DdSdkReactNative {
|
|
|
43
57
|
* @returns a Promise.
|
|
44
58
|
*/
|
|
45
59
|
static setTrackingConsent(consent: TrackingConsent): Promise<void>;
|
|
60
|
+
private static buildConfiguration;
|
|
46
61
|
private static enableFeatures;
|
|
47
62
|
}
|
|
@@ -1,6 +1,12 @@
|
|
|
1
1
|
import type { ProxyConfiguration } from './ProxyConfiguration';
|
|
2
2
|
import type { SdkVerbosity } from './SdkVerbosity';
|
|
3
3
|
import { TrackingConsent } from './TrackingConsent';
|
|
4
|
+
export declare enum VitalsUpdateFrequency {
|
|
5
|
+
FREQUENT = "FREQUENT",
|
|
6
|
+
AVERAGE = "AVERAGE",
|
|
7
|
+
RARE = "RARE",
|
|
8
|
+
NEVER = "NEVER"
|
|
9
|
+
}
|
|
4
10
|
/**
|
|
5
11
|
* The SDK configuration class.
|
|
6
12
|
* It will be used to configure the SDK functionality at initialization.
|
|
@@ -13,6 +19,9 @@ export declare class DdSdkReactNativeConfiguration {
|
|
|
13
19
|
readonly trackResources: boolean;
|
|
14
20
|
readonly trackErrors: boolean;
|
|
15
21
|
readonly trackingConsent: TrackingConsent;
|
|
22
|
+
/**
|
|
23
|
+
* Enables crash reporting for native plaforms (iOS, Android). Default `false`.
|
|
24
|
+
*/
|
|
16
25
|
nativeCrashReportEnabled: boolean;
|
|
17
26
|
/**
|
|
18
27
|
* @deprecated `sampleRate` has been replaced by `sessionSamplingRate` to avoid confusion with `resourceTracingSamplingRate` and will be removed in a future release.
|
|
@@ -27,10 +36,24 @@ export declare class DdSdkReactNativeConfiguration {
|
|
|
27
36
|
*/
|
|
28
37
|
resourceTracingSamplingRate: number;
|
|
29
38
|
site: string;
|
|
39
|
+
/**
|
|
40
|
+
* Verbosity for internal SDK logging.
|
|
41
|
+
* Set to `SdkVerbosity.DEBUG` to debug your SDK implementation.
|
|
42
|
+
*/
|
|
30
43
|
verbosity: SdkVerbosity | undefined;
|
|
44
|
+
/**
|
|
45
|
+
* Enables native views tracking.
|
|
46
|
+
* Set to `true` if you use a custom navigation system relying on native views.
|
|
47
|
+
*/
|
|
31
48
|
nativeViewTracking: boolean;
|
|
32
49
|
proxyConfig?: ProxyConfiguration;
|
|
33
50
|
serviceName?: string;
|
|
51
|
+
/**
|
|
52
|
+
* List of your backends hosts to enable tracing with.
|
|
53
|
+
* Regular expressions are NOT supported.
|
|
54
|
+
*
|
|
55
|
+
* Matches domains and subdomains, e.g. `['example.com']` matches `example.com` and `api.example.com`.
|
|
56
|
+
*/
|
|
34
57
|
firstPartyHosts: string[];
|
|
35
58
|
/**
|
|
36
59
|
* Overrides the reported version of the app.
|
|
@@ -52,8 +75,99 @@ export declare class DdSdkReactNativeConfiguration {
|
|
|
52
75
|
* A dash (`-`) will be automatically added between the version and the suffix
|
|
53
76
|
*/
|
|
54
77
|
versionSuffix?: string;
|
|
78
|
+
/**
|
|
79
|
+
* The sampling rate for Internal Telemetry (info related to the work of the
|
|
80
|
+
* SDK internals).
|
|
81
|
+
*
|
|
82
|
+
* The sampling rate must be a value between 0 and 100. A value of 0 means no
|
|
83
|
+
* telemetry will be sent, 100 means all telemetry will be sent. When
|
|
84
|
+
* `telemetrySampleRate` is not set, the default value from the iOS and
|
|
85
|
+
* Android SDK is used, which is 20.
|
|
86
|
+
*/
|
|
87
|
+
telemetrySampleRate: number;
|
|
88
|
+
/**
|
|
89
|
+
* The threshold for native long tasks reporting in milliseconds.
|
|
90
|
+
*
|
|
91
|
+
* - Setting it to `0` or `false` disables native long task reporting.
|
|
92
|
+
* - Values below `100` will be raised to `100`.
|
|
93
|
+
* - Values above `5000` will be lowered to `5000`.
|
|
94
|
+
*
|
|
95
|
+
* Default value is `200`.
|
|
96
|
+
*/
|
|
97
|
+
nativeLongTaskThresholdMs: number | false;
|
|
98
|
+
/**
|
|
99
|
+
* The threshold for javascript long tasks reporting in milliseconds.
|
|
100
|
+
*
|
|
101
|
+
* - Setting it to `0` or `false` disables javascript long task reporting.
|
|
102
|
+
* - Values below `100` will be raised to `100`.
|
|
103
|
+
* - Values above `5000` will be lowered to `5000`.
|
|
104
|
+
*
|
|
105
|
+
* Default value is `0`
|
|
106
|
+
*/
|
|
107
|
+
longTaskThresholdMs: number | false;
|
|
108
|
+
/**
|
|
109
|
+
* Sets the preferred frequency for collecting mobile vitals.
|
|
110
|
+
*/
|
|
111
|
+
vitalsUpdateFrequency: VitalsUpdateFrequency;
|
|
55
112
|
additionalConfig: {
|
|
56
113
|
[k: string]: any;
|
|
57
114
|
};
|
|
58
115
|
constructor(clientToken: string, env: string, applicationId: string, trackInteractions?: boolean, trackResources?: boolean, trackErrors?: boolean, trackingConsent?: TrackingConsent);
|
|
59
116
|
}
|
|
117
|
+
/**
|
|
118
|
+
* Auto Instrumentation configuration passed to DatadogProvider.
|
|
119
|
+
* Does not include default values.
|
|
120
|
+
*/
|
|
121
|
+
export declare type AutoInstrumentationConfiguration = {
|
|
122
|
+
readonly trackInteractions: boolean;
|
|
123
|
+
readonly trackResources: boolean;
|
|
124
|
+
readonly firstPartyHosts?: string[];
|
|
125
|
+
readonly resourceTracingSamplingRate?: number;
|
|
126
|
+
readonly trackErrors: boolean;
|
|
127
|
+
};
|
|
128
|
+
/**
|
|
129
|
+
* Parameters needed to start auto instrumentation. Includes default values.
|
|
130
|
+
*/
|
|
131
|
+
export declare type AutoInstrumentationParameters = {
|
|
132
|
+
readonly trackInteractions: boolean;
|
|
133
|
+
readonly trackResources: boolean;
|
|
134
|
+
readonly firstPartyHosts: string[];
|
|
135
|
+
readonly resourceTracingSamplingRate: number;
|
|
136
|
+
readonly trackErrors: boolean;
|
|
137
|
+
};
|
|
138
|
+
/**
|
|
139
|
+
* We could use `Proxy` instead of this function, but `Proxy` is not available on
|
|
140
|
+
* the older android jsc that can still be used.
|
|
141
|
+
*/
|
|
142
|
+
export declare const addDefaultValuesToAutoInstrumentationConfiguration: (features: AutoInstrumentationConfiguration) => AutoInstrumentationParameters;
|
|
143
|
+
export declare type PartialInitializationConfiguration = {
|
|
144
|
+
readonly clientToken: string;
|
|
145
|
+
readonly env: string;
|
|
146
|
+
readonly applicationId: string;
|
|
147
|
+
readonly sessionSamplingRate?: number;
|
|
148
|
+
readonly site?: string;
|
|
149
|
+
readonly verbosity?: SdkVerbosity | undefined;
|
|
150
|
+
readonly nativeViewTracking?: boolean;
|
|
151
|
+
readonly proxyConfig?: ProxyConfiguration;
|
|
152
|
+
readonly serviceName?: string;
|
|
153
|
+
readonly version?: string;
|
|
154
|
+
versionSuffix?: string;
|
|
155
|
+
readonly additionalConfig?: {
|
|
156
|
+
[k: string]: any;
|
|
157
|
+
};
|
|
158
|
+
readonly trackingConsent?: TrackingConsent;
|
|
159
|
+
readonly longTaskThresholdMs?: number | false;
|
|
160
|
+
readonly nativeLongTaskThresholdMs?: number | false;
|
|
161
|
+
readonly nativeCrashReportEnabled?: boolean;
|
|
162
|
+
readonly telemetrySampleRate?: number;
|
|
163
|
+
readonly vitalsUpdateFrequency?: VitalsUpdateFrequency;
|
|
164
|
+
};
|
|
165
|
+
export declare const buildConfigurationFromPartialConfiguration: (features: AutoInstrumentationConfiguration, configuration: PartialInitializationConfiguration) => DdSdkReactNativeConfiguration;
|
|
166
|
+
export declare class DatadogProviderConfiguration extends DdSdkReactNativeConfiguration {
|
|
167
|
+
initializationMode: InitializationMode;
|
|
168
|
+
}
|
|
169
|
+
export declare enum InitializationMode {
|
|
170
|
+
SYNC = "SYNC",
|
|
171
|
+
ASYNC = "ASYNC"
|
|
172
|
+
}
|
|
173
|
+
export declare type InitializationModeForTelemetry = 'LEGACY' | 'SYNC' | 'ASYNC' | 'PARTIAL';
|
|
@@ -0,0 +1,12 @@
|
|
|
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
|
+
/**
|
|
5
|
+
* Will extract the stack from the error, taking the first key found among:
|
|
6
|
+
* `stacktrace`, `stack`, `componentStack` (component tree for component errors,
|
|
7
|
+
* which contains only native components names in production).
|
|
8
|
+
*
|
|
9
|
+
* In last resort and if `sourceURL`, `line` and `column` are present, it will
|
|
10
|
+
* generate a stack from this information.
|
|
11
|
+
*/
|
|
12
|
+
export declare const getErrorStackTrace: (error: any | undefined) => string;
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import {
|
|
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 };
|
|
@@ -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;
|
|
@@ -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
|
}
|
|
@@ -6,11 +6,26 @@ export declare class DdSdkConfiguration {
|
|
|
6
6
|
readonly env: string;
|
|
7
7
|
readonly applicationId: string;
|
|
8
8
|
readonly nativeCrashReportEnabled: boolean;
|
|
9
|
+
readonly nativeLongTaskThresholdMs: number;
|
|
10
|
+
readonly longTaskThresholdMs: number;
|
|
9
11
|
readonly sampleRate: number;
|
|
10
12
|
readonly site: string;
|
|
11
13
|
readonly trackingConsent: string;
|
|
12
14
|
readonly additionalConfig: object;
|
|
13
|
-
|
|
15
|
+
readonly telemetrySampleRate: number;
|
|
16
|
+
readonly vitalsUpdateFrequency: string;
|
|
17
|
+
readonly configurationForTelemetry: {
|
|
18
|
+
initializationType: string;
|
|
19
|
+
trackErrors: boolean;
|
|
20
|
+
trackInteractions: boolean;
|
|
21
|
+
trackNetworkRequests: boolean;
|
|
22
|
+
};
|
|
23
|
+
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, configurationForTelemetry: {
|
|
24
|
+
initializationType: string;
|
|
25
|
+
trackErrors: boolean;
|
|
26
|
+
trackInteractions: boolean;
|
|
27
|
+
trackNetworkRequests: boolean;
|
|
28
|
+
});
|
|
14
29
|
}
|
|
15
30
|
/**
|
|
16
31
|
* The entry point to initialize Datadog's features.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const version = "1.
|
|
1
|
+
export declare const version = "1.2.0-beta2";
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@datadog/mobile-react-native-code-push",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.2.0-beta2",
|
|
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.
|
|
41
|
+
"@datadog/mobile-react-native": "^1.2.0-beta2",
|
|
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": "
|
|
75
|
+
"gitHead": "ed8c52d7412d19d1b79a748aa600c66c1bfdbdd6"
|
|
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 {
|
|
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
|
-
});
|