@datadog/mobile-react-native 1.8.2 → 1.8.4
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/ios/Sources/DdSdk.mm +3 -1
- package/ios/Sources/DdSdkImplementation.swift +6 -6
- package/lib/commonjs/sdk/EventMappers/utils/deepClone.js +25 -18
- package/lib/commonjs/sdk/EventMappers/utils/deepClone.js.map +1 -1
- package/lib/commonjs/version.js +1 -1
- package/lib/commonjs/version.js.map +1 -1
- package/lib/module/sdk/EventMappers/utils/deepClone.js +25 -18
- package/lib/module/sdk/EventMappers/utils/deepClone.js.map +1 -1
- package/lib/module/version.js +1 -1
- package/lib/module/version.js.map +1 -1
- package/lib/typescript/version.d.ts +1 -1
- package/package.json +2 -2
- package/src/sdk/EventMappers/utils/deepClone.ts +23 -17
- package/src/version.ts +1 -1
package/ios/Sources/DdSdk.mm
CHANGED
|
@@ -10,9 +10,11 @@
|
|
|
10
10
|
#import <DatadogSDKReactNative/DatadogSDKReactNative-Swift.h>
|
|
11
11
|
#endif
|
|
12
12
|
#import "DdSdk.h"
|
|
13
|
+
#import <React/RCTBridge+Private.h>
|
|
13
14
|
|
|
14
15
|
@implementation DdSdk
|
|
15
16
|
|
|
17
|
+
@synthesize bridge = _bridge;
|
|
16
18
|
RCT_EXPORT_MODULE()
|
|
17
19
|
|
|
18
20
|
RCT_REMAP_METHOD(initialize, withConfiguration:(NSDictionary*)configuration
|
|
@@ -79,7 +81,7 @@ RCT_REMAP_METHOD(consumeWebviewEvent, withWebviewMessage:(NSString*)message
|
|
|
79
81
|
- (DdSdkImplementation*)ddSdkImplementation
|
|
80
82
|
{
|
|
81
83
|
if (_ddSdkImplementation == nil) {
|
|
82
|
-
_ddSdkImplementation = [[DdSdkImplementation alloc]
|
|
84
|
+
_ddSdkImplementation = [[DdSdkImplementation alloc] initWithBridge:_bridge];
|
|
83
85
|
}
|
|
84
86
|
return _ddSdkImplementation;
|
|
85
87
|
}
|
|
@@ -17,20 +17,20 @@ func getDefaultAppVersion() -> String {
|
|
|
17
17
|
|
|
18
18
|
@objc
|
|
19
19
|
public class DdSdkImplementation: NSObject {
|
|
20
|
-
|
|
21
|
-
|
|
20
|
+
let jsDispatchQueue: DispatchQueueType
|
|
22
21
|
let jsRefreshRateMonitor: RefreshRateMonitor
|
|
23
22
|
let mainDispatchQueue: DispatchQueueType
|
|
24
23
|
|
|
25
24
|
private let jsLongTaskThresholdInSeconds: TimeInterval = 0.1;
|
|
26
25
|
|
|
27
26
|
@objc
|
|
28
|
-
public convenience
|
|
29
|
-
self.init(mainDispatchQueue: DispatchQueue.main, jsRefreshRateMonitor: JSRefreshRateMonitor.init())
|
|
27
|
+
public convenience init(bridge: RCTBridge) {
|
|
28
|
+
self.init(mainDispatchQueue: DispatchQueue.main, jsDispatchQueue: bridge, jsRefreshRateMonitor: JSRefreshRateMonitor.init())
|
|
30
29
|
}
|
|
31
30
|
|
|
32
|
-
init(mainDispatchQueue: DispatchQueueType, jsRefreshRateMonitor: RefreshRateMonitor) {
|
|
31
|
+
init(mainDispatchQueue: DispatchQueueType, jsDispatchQueue: DispatchQueueType, jsRefreshRateMonitor: RefreshRateMonitor) {
|
|
33
32
|
self.mainDispatchQueue = mainDispatchQueue
|
|
33
|
+
self.jsDispatchQueue = jsDispatchQueue
|
|
34
34
|
self.jsRefreshRateMonitor = jsRefreshRateMonitor
|
|
35
35
|
super.init()
|
|
36
36
|
}
|
|
@@ -377,7 +377,7 @@ public class DdSdkImplementation: NSObject {
|
|
|
377
377
|
func startJSRefreshRateMonitoring(sdkConfiguration: DdSdkConfiguration) {
|
|
378
378
|
if let frameTimeCallback = buildFrameTimeCallback(sdkConfiguration: sdkConfiguration) {
|
|
379
379
|
// Falling back to mainDispatchQueue if bridge is nil is only useful for tests
|
|
380
|
-
self.jsRefreshRateMonitor.startMonitoring(jsQueue:
|
|
380
|
+
self.jsRefreshRateMonitor.startMonitoring(jsQueue: jsDispatchQueue, frameTimeCallback: frameTimeCallback)
|
|
381
381
|
}
|
|
382
382
|
}
|
|
383
383
|
|
|
@@ -10,30 +10,36 @@ exports.deepClone = void 0;
|
|
|
10
10
|
* This product includes software developed at Datadog (https://www.datadoghq.com/).
|
|
11
11
|
* Copyright 2016-Present Datadog, Inc.
|
|
12
12
|
*/
|
|
13
|
-
const isDate =
|
|
14
|
-
const type = {}.toString.call(object).slice(8, -1);
|
|
13
|
+
const isDate = (type, _) => {
|
|
15
14
|
return type === 'Date';
|
|
16
15
|
};
|
|
17
16
|
|
|
18
|
-
const isArray =
|
|
19
|
-
const type = {}.toString.call(object).slice(8, -1);
|
|
17
|
+
const isArray = (type, _) => {
|
|
20
18
|
return type === 'Array';
|
|
21
19
|
};
|
|
22
20
|
|
|
23
|
-
const isObject =
|
|
24
|
-
const type = {}.toString.call(object).slice(8, -1);
|
|
21
|
+
const isObject = (type, _) => {
|
|
25
22
|
return type === 'Object';
|
|
26
23
|
};
|
|
27
24
|
|
|
28
|
-
const isSet =
|
|
29
|
-
const type = {}.toString.call(object).slice(8, -1);
|
|
25
|
+
const isSet = (type, _) => {
|
|
30
26
|
return type === 'Set';
|
|
31
27
|
};
|
|
32
28
|
|
|
33
|
-
const isMap =
|
|
34
|
-
const type = {}.toString.call(object).slice(8, -1);
|
|
29
|
+
const isMap = (type, _) => {
|
|
35
30
|
return type === 'Map';
|
|
36
31
|
};
|
|
32
|
+
/**
|
|
33
|
+
* Be careful when changing this value, it can lead to performance issues: https://github.com/DataDog/dd-sdk-reactnative/issues/514.
|
|
34
|
+
* Benchmark of average execution time for an action event mapper with different max depth on iOS simulator:
|
|
35
|
+
* 7: 40ms
|
|
36
|
+
* 6: 15ms
|
|
37
|
+
* 5: 4ms
|
|
38
|
+
* 4: <1ms
|
|
39
|
+
*/
|
|
40
|
+
|
|
41
|
+
|
|
42
|
+
const MAX_DEPTH = 4;
|
|
37
43
|
/**
|
|
38
44
|
* Simple deep clone inspired from https://github.com/angus-c/just/blob/master/packages/collection-clone/index.cjs
|
|
39
45
|
* Functions and RegExp will be returned as they are.
|
|
@@ -44,22 +50,23 @@ const isMap = object => {
|
|
|
44
50
|
* @returns
|
|
45
51
|
*/
|
|
46
52
|
|
|
47
|
-
|
|
48
53
|
const deepClone = (originalObject, depth = 0) => {
|
|
49
|
-
|
|
54
|
+
const type = {}.toString.call(originalObject).slice(8, -1);
|
|
55
|
+
|
|
56
|
+
if (isDate(type, originalObject)) {
|
|
50
57
|
return new Date(originalObject.getTime());
|
|
51
58
|
}
|
|
52
59
|
|
|
53
|
-
if (isSet(originalObject)) {
|
|
60
|
+
if (isSet(type, originalObject)) {
|
|
54
61
|
return new Set([...originalObject].map(value => deepClone(value)));
|
|
55
62
|
}
|
|
56
63
|
|
|
57
|
-
if (isMap(originalObject)) {
|
|
64
|
+
if (isMap(type, originalObject)) {
|
|
58
65
|
return new Map([...originalObject].map(kv => [deepClone(kv[0]), deepClone(kv[1])]));
|
|
59
66
|
}
|
|
60
67
|
|
|
61
|
-
if (isArray(originalObject)) {
|
|
62
|
-
if (depth >=
|
|
68
|
+
if (isArray(type, originalObject)) {
|
|
69
|
+
if (depth >= MAX_DEPTH) {
|
|
63
70
|
// Break the circular reference here
|
|
64
71
|
return originalObject;
|
|
65
72
|
}
|
|
@@ -74,8 +81,8 @@ const deepClone = (originalObject, depth = 0) => {
|
|
|
74
81
|
return result;
|
|
75
82
|
}
|
|
76
83
|
|
|
77
|
-
if (isObject(originalObject)) {
|
|
78
|
-
if (depth >=
|
|
84
|
+
if (isObject(type, originalObject)) {
|
|
85
|
+
if (depth >= MAX_DEPTH) {
|
|
79
86
|
// Break the circular reference here
|
|
80
87
|
return originalObject;
|
|
81
88
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["deepClone.ts"],"names":["isDate","
|
|
1
|
+
{"version":3,"sources":["deepClone.ts"],"names":["isDate","type","_","isArray","isObject","isSet","isMap","MAX_DEPTH","deepClone","originalObject","depth","toString","call","slice","Date","getTime","Set","map","value","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L,IAAD,EAAOQ,cAAP,CAAT,EAAiC;AAC7B,WAAQ,IAAIU,GAAJ,CACJ,CAAC,GAAGV,cAAJ,EAAoBQ,GAApB,CAAwBG,EAAE,IAAI,CAACZ,SAAS,CAACY,EAAE,CAAC,CAAD,CAAH,CAAV,EAAmBZ,SAAS,CAACY,EAAE,CAAC,CAAD,CAAH,CAA5B,CAA9B,CADI,CAAR;AAGH;;AACD,MAAIjB,OAAO,CAACF,IAAD,EAAOQ,cAAP,CAAX,EAAmC;AAC/B,QAAIC,KAAK,IAAIH,SAAb,EAAwB;AACpB;AACA,aAAOE,cAAP;AACH;;AACD,UAAMY,MAAiB,GAAG,EAA1B,CAL+B,CAM/B;;AACA,SAAK,MAAMC,GAAX,IAAkBb,cAAlB,EAAkC;AAC9B;AACAY,MAAAA,MAAM,CAACC,GAAD,CAAN,GAAcd,SAAS,CAACC,cAAc,CAACa,GAAD,CAAf,EAAsBZ,KAAK,GAAG,CAA9B,CAAvB;AACH;;AAED,WAAQW,MAAR;AACH;;AACD,MAAIjB,QAAQ,CAACH,IAAD,EAAOQ,cAAP,CAAZ,EAAoC;AAChC,QAAIC,KAAK,IAAIH,SAAb,EAAwB;AACpB;AACA,aAAOE,cAAP;AACH;;AACD,UAAMY,MAA+B,GAAG,EAAxC,CALgC,CAMhC;;AACA,SAAK,MAAMC,GAAX,IAAkBb,cAAlB,EAAkC;AAC9B;AACAY,MAAAA,MAAM,CAACC,GAAD,CAAN,GAAcd,SAAS,CAACC,cAAc,CAACa,GAAD,CAAf,EAAsBZ,KAAK,GAAG,CAA9B,CAAvB;AACH;;AAED,WAAQW,MAAR;AACH,GA1CoE,CA4CrE;;;AACA,SAAOZ,cAAP;AACH,CA9CM","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\nconst isDate = (type: string, _: unknown): _ is Date => {\n return type === 'Date';\n};\n\nconst isArray = (type: string, _: unknown): _ is unknown[] => {\n return type === 'Array';\n};\n\nconst isObject = (type: string, _: unknown): _ is Record<string, unknown> => {\n return type === 'Object';\n};\n\nconst isSet = (type: string, _: unknown): _ is Set<unknown> => {\n return type === 'Set';\n};\n\nconst isMap = (type: string, _: unknown): _ is Map<string, unknown> => {\n return type === 'Map';\n};\n\n/**\n * Be careful when changing this value, it can lead to performance issues: https://github.com/DataDog/dd-sdk-reactnative/issues/514.\n * Benchmark of average execution time for an action event mapper with different max depth on iOS simulator:\n * 7: 40ms\n * 6: 15ms\n * 5: 4ms\n * 4: <1ms\n */\nconst MAX_DEPTH = 4;\n\n/**\n * Simple deep clone inspired from https://github.com/angus-c/just/blob/master/packages/collection-clone/index.cjs\n * Functions and RegExp will be returned as they are.\n * Maps and Sets are cloned even though they won't be accepted by React Native, just in case they are mutated by the user to avoid side effects.\n *\n * We added support for circular references by limiting the number of depth levels to 8.\n * @param originalObject\n * @returns\n */\nexport const deepClone = <T>(originalObject: T, depth: number = 0): T => {\n const type = {}.toString.call(originalObject).slice(8, -1);\n if (isDate(type, originalObject)) {\n return (new Date(originalObject.getTime()) as unknown) as T;\n }\n if (isSet(type, originalObject)) {\n return (new Set(\n [...originalObject].map(value => deepClone(value))\n ) as unknown) as T;\n }\n if (isMap(type, originalObject)) {\n return (new Map(\n [...originalObject].map(kv => [deepClone(kv[0]), deepClone(kv[1])])\n ) as unknown) as T;\n }\n if (isArray(type, originalObject)) {\n if (depth >= MAX_DEPTH) {\n // Break the circular reference here\n return originalObject;\n }\n const result: unknown[] = [];\n // eslint-disable-next-line guard-for-in\n for (const key in originalObject) {\n // include prototype properties\n result[key] = deepClone(originalObject[key], depth + 1);\n }\n\n return (result as unknown) as T;\n }\n if (isObject(type, originalObject)) {\n if (depth >= MAX_DEPTH) {\n // Break the circular reference here\n return originalObject;\n }\n const result: Record<string, unknown> = {};\n // eslint-disable-next-line guard-for-in\n for (const key in originalObject) {\n // include prototype properties\n result[key] = deepClone(originalObject[key], depth + 1);\n }\n\n return (result as unknown) as T;\n }\n\n // primitives and non-supported objects (e.g. functions) land here\n return originalObject;\n};\n"]}
|
package/lib/commonjs/version.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["version.ts"],"names":["version"],"mappings":";;;;;;AAAA;AACO,MAAMA,OAAO,GAAG,OAAhB","sourcesContent":["// generated by genversion\nexport const version = '1.8.
|
|
1
|
+
{"version":3,"sources":["version.ts"],"names":["version"],"mappings":";;;;;;AAAA;AACO,MAAMA,OAAO,GAAG,OAAhB","sourcesContent":["// generated by genversion\nexport const version = '1.8.4';\n"]}
|
|
@@ -3,30 +3,36 @@
|
|
|
3
3
|
* This product includes software developed at Datadog (https://www.datadoghq.com/).
|
|
4
4
|
* Copyright 2016-Present Datadog, Inc.
|
|
5
5
|
*/
|
|
6
|
-
const isDate =
|
|
7
|
-
const type = {}.toString.call(object).slice(8, -1);
|
|
6
|
+
const isDate = (type, _) => {
|
|
8
7
|
return type === 'Date';
|
|
9
8
|
};
|
|
10
9
|
|
|
11
|
-
const isArray =
|
|
12
|
-
const type = {}.toString.call(object).slice(8, -1);
|
|
10
|
+
const isArray = (type, _) => {
|
|
13
11
|
return type === 'Array';
|
|
14
12
|
};
|
|
15
13
|
|
|
16
|
-
const isObject =
|
|
17
|
-
const type = {}.toString.call(object).slice(8, -1);
|
|
14
|
+
const isObject = (type, _) => {
|
|
18
15
|
return type === 'Object';
|
|
19
16
|
};
|
|
20
17
|
|
|
21
|
-
const isSet =
|
|
22
|
-
const type = {}.toString.call(object).slice(8, -1);
|
|
18
|
+
const isSet = (type, _) => {
|
|
23
19
|
return type === 'Set';
|
|
24
20
|
};
|
|
25
21
|
|
|
26
|
-
const isMap =
|
|
27
|
-
const type = {}.toString.call(object).slice(8, -1);
|
|
22
|
+
const isMap = (type, _) => {
|
|
28
23
|
return type === 'Map';
|
|
29
24
|
};
|
|
25
|
+
/**
|
|
26
|
+
* Be careful when changing this value, it can lead to performance issues: https://github.com/DataDog/dd-sdk-reactnative/issues/514.
|
|
27
|
+
* Benchmark of average execution time for an action event mapper with different max depth on iOS simulator:
|
|
28
|
+
* 7: 40ms
|
|
29
|
+
* 6: 15ms
|
|
30
|
+
* 5: 4ms
|
|
31
|
+
* 4: <1ms
|
|
32
|
+
*/
|
|
33
|
+
|
|
34
|
+
|
|
35
|
+
const MAX_DEPTH = 4;
|
|
30
36
|
/**
|
|
31
37
|
* Simple deep clone inspired from https://github.com/angus-c/just/blob/master/packages/collection-clone/index.cjs
|
|
32
38
|
* Functions and RegExp will be returned as they are.
|
|
@@ -37,22 +43,23 @@ const isMap = object => {
|
|
|
37
43
|
* @returns
|
|
38
44
|
*/
|
|
39
45
|
|
|
40
|
-
|
|
41
46
|
export const deepClone = (originalObject, depth = 0) => {
|
|
42
|
-
|
|
47
|
+
const type = {}.toString.call(originalObject).slice(8, -1);
|
|
48
|
+
|
|
49
|
+
if (isDate(type, originalObject)) {
|
|
43
50
|
return new Date(originalObject.getTime());
|
|
44
51
|
}
|
|
45
52
|
|
|
46
|
-
if (isSet(originalObject)) {
|
|
53
|
+
if (isSet(type, originalObject)) {
|
|
47
54
|
return new Set([...originalObject].map(value => deepClone(value)));
|
|
48
55
|
}
|
|
49
56
|
|
|
50
|
-
if (isMap(originalObject)) {
|
|
57
|
+
if (isMap(type, originalObject)) {
|
|
51
58
|
return new Map([...originalObject].map(kv => [deepClone(kv[0]), deepClone(kv[1])]));
|
|
52
59
|
}
|
|
53
60
|
|
|
54
|
-
if (isArray(originalObject)) {
|
|
55
|
-
if (depth >=
|
|
61
|
+
if (isArray(type, originalObject)) {
|
|
62
|
+
if (depth >= MAX_DEPTH) {
|
|
56
63
|
// Break the circular reference here
|
|
57
64
|
return originalObject;
|
|
58
65
|
}
|
|
@@ -67,8 +74,8 @@ export const deepClone = (originalObject, depth = 0) => {
|
|
|
67
74
|
return result;
|
|
68
75
|
}
|
|
69
76
|
|
|
70
|
-
if (isObject(originalObject)) {
|
|
71
|
-
if (depth >=
|
|
77
|
+
if (isObject(type, originalObject)) {
|
|
78
|
+
if (depth >= MAX_DEPTH) {
|
|
72
79
|
// Break the circular reference here
|
|
73
80
|
return originalObject;
|
|
74
81
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["deepClone.ts"],"names":["isDate","
|
|
1
|
+
{"version":3,"sources":["deepClone.ts"],"names":["isDate","type","_","isArray","isObject","isSet","isMap","MAX_DEPTH","deepClone","originalObject","depth","toString","call","slice","Date","getTime","Set","map","value","Map","kv","result","key"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AAEA,MAAMA,MAAM,GAAG,CAACC,IAAD,EAAeC,CAAf,KAAyC;AACpD,SAAOD,IAAI,KAAK,MAAhB;AACH,CAFD;;AAIA,MAAME,OAAO,GAAG,CAACF,IAAD,EAAeC,CAAf,KAA8C;AAC1D,SAAOD,IAAI,KAAK,OAAhB;AACH,CAFD;;AAIA,MAAMG,QAAQ,GAAG,CAACH,IAAD,EAAeC,CAAf,KAA4D;AACzE,SAAOD,IAAI,KAAK,QAAhB;AACH,CAFD;;AAIA,MAAMI,KAAK,GAAG,CAACJ,IAAD,EAAeC,CAAf,KAAiD;AAC3D,SAAOD,IAAI,KAAK,KAAhB;AACH,CAFD;;AAIA,MAAMK,KAAK,GAAG,CAACL,IAAD,EAAeC,CAAf,KAAyD;AACnE,SAAOD,IAAI,KAAK,KAAhB;AACH,CAFD;AAIA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;AACA,MAAMM,SAAS,GAAG,CAAlB;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AACA,OAAO,MAAMC,SAAS,GAAG,CAAIC,cAAJ,EAAuBC,KAAa,GAAG,CAAvC,KAAgD;AACrE,QAAMT,IAAI,GAAG,GAAGU,QAAH,CAAYC,IAAZ,CAAiBH,cAAjB,EAAiCI,KAAjC,CAAuC,CAAvC,EAA0C,CAAC,CAA3C,CAAb;;AACA,MAA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AD,CAAN,GAAcd,SAAS,CAACC,cAAc,CAACa,GAAD,CAAf,EAAsBZ,KAAK,GAAG,CAA9B,CAAvB;AACH;;AAED,WAAQW,MAAR;AACH,GA1CoE,CA4CrE;;;AACA,SAAOZ,cAAP;AACH,CA9CM","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\nconst isDate = (type: string, _: unknown): _ is Date => {\n return type === 'Date';\n};\n\nconst isArray = (type: string, _: unknown): _ is unknown[] => {\n return type === 'Array';\n};\n\nconst isObject = (type: string, _: unknown): _ is Record<string, unknown> => {\n return type === 'Object';\n};\n\nconst isSet = (type: string, _: unknown): _ is Set<unknown> => {\n return type === 'Set';\n};\n\nconst isMap = (type: string, _: unknown): _ is Map<string, unknown> => {\n return type === 'Map';\n};\n\n/**\n * Be careful when changing this value, it can lead to performance issues: https://github.com/DataDog/dd-sdk-reactnative/issues/514.\n * Benchmark of average execution time for an action event mapper with different max depth on iOS simulator:\n * 7: 40ms\n * 6: 15ms\n * 5: 4ms\n * 4: <1ms\n */\nconst MAX_DEPTH = 4;\n\n/**\n * Simple deep clone inspired from https://github.com/angus-c/just/blob/master/packages/collection-clone/index.cjs\n * Functions and RegExp will be returned as they are.\n * Maps and Sets are cloned even though they won't be accepted by React Native, just in case they are mutated by the user to avoid side effects.\n *\n * We added support for circular references by limiting the number of depth levels to 8.\n * @param originalObject\n * @returns\n */\nexport const deepClone = <T>(originalObject: T, depth: number = 0): T => {\n const type = {}.toString.call(originalObject).slice(8, -1);\n if (isDate(type, originalObject)) {\n return (new Date(originalObject.getTime()) as unknown) as T;\n }\n if (isSet(type, originalObject)) {\n return (new Set(\n [...originalObject].map(value => deepClone(value))\n ) as unknown) as T;\n }\n if (isMap(type, originalObject)) {\n return (new Map(\n [...originalObject].map(kv => [deepClone(kv[0]), deepClone(kv[1])])\n ) as unknown) as T;\n }\n if (isArray(type, originalObject)) {\n if (depth >= MAX_DEPTH) {\n // Break the circular reference here\n return originalObject;\n }\n const result: unknown[] = [];\n // eslint-disable-next-line guard-for-in\n for (const key in originalObject) {\n // include prototype properties\n result[key] = deepClone(originalObject[key], depth + 1);\n }\n\n return (result as unknown) as T;\n }\n if (isObject(type, originalObject)) {\n if (depth >= MAX_DEPTH) {\n // Break the circular reference here\n return originalObject;\n }\n const result: Record<string, unknown> = {};\n // eslint-disable-next-line guard-for-in\n for (const key in originalObject) {\n // include prototype properties\n result[key] = deepClone(originalObject[key], depth + 1);\n }\n\n return (result as unknown) as T;\n }\n\n // primitives and non-supported objects (e.g. functions) land here\n return originalObject;\n};\n"]}
|
package/lib/module/version.js
CHANGED
|
@@ -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 = '1.8.
|
|
1
|
+
{"version":3,"sources":["version.ts"],"names":["version"],"mappings":"AAAA;AACA,OAAO,MAAMA,OAAO,GAAG,OAAhB","sourcesContent":["// generated by genversion\nexport const version = '1.8.4';\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const version = "1.8.
|
|
1
|
+
export declare const version = "1.8.4";
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@datadog/mobile-react-native",
|
|
3
|
-
"version": "1.8.
|
|
3
|
+
"version": "1.8.4",
|
|
4
4
|
"description": "A client-side React Native module to interact with Datadog",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"datadog",
|
|
@@ -86,5 +86,5 @@
|
|
|
86
86
|
"javaPackageName": "com.datadog.reactnative"
|
|
87
87
|
}
|
|
88
88
|
},
|
|
89
|
-
"gitHead": "
|
|
89
|
+
"gitHead": "f1a99e7f43ace289d107f38d94e265d413d07bac"
|
|
90
90
|
}
|
|
@@ -4,31 +4,36 @@
|
|
|
4
4
|
* Copyright 2016-Present Datadog, Inc.
|
|
5
5
|
*/
|
|
6
6
|
|
|
7
|
-
const isDate = (
|
|
8
|
-
const type = {}.toString.call(object).slice(8, -1);
|
|
7
|
+
const isDate = (type: string, _: unknown): _ is Date => {
|
|
9
8
|
return type === 'Date';
|
|
10
9
|
};
|
|
11
10
|
|
|
12
|
-
const isArray = (
|
|
13
|
-
const type = {}.toString.call(object).slice(8, -1);
|
|
11
|
+
const isArray = (type: string, _: unknown): _ is unknown[] => {
|
|
14
12
|
return type === 'Array';
|
|
15
13
|
};
|
|
16
14
|
|
|
17
|
-
const isObject = (
|
|
18
|
-
const type = {}.toString.call(object).slice(8, -1);
|
|
15
|
+
const isObject = (type: string, _: unknown): _ is Record<string, unknown> => {
|
|
19
16
|
return type === 'Object';
|
|
20
17
|
};
|
|
21
18
|
|
|
22
|
-
const isSet = (
|
|
23
|
-
const type = {}.toString.call(object).slice(8, -1);
|
|
19
|
+
const isSet = (type: string, _: unknown): _ is Set<unknown> => {
|
|
24
20
|
return type === 'Set';
|
|
25
21
|
};
|
|
26
22
|
|
|
27
|
-
const isMap = (
|
|
28
|
-
const type = {}.toString.call(object).slice(8, -1);
|
|
23
|
+
const isMap = (type: string, _: unknown): _ is Map<string, unknown> => {
|
|
29
24
|
return type === 'Map';
|
|
30
25
|
};
|
|
31
26
|
|
|
27
|
+
/**
|
|
28
|
+
* Be careful when changing this value, it can lead to performance issues: https://github.com/DataDog/dd-sdk-reactnative/issues/514.
|
|
29
|
+
* Benchmark of average execution time for an action event mapper with different max depth on iOS simulator:
|
|
30
|
+
* 7: 40ms
|
|
31
|
+
* 6: 15ms
|
|
32
|
+
* 5: 4ms
|
|
33
|
+
* 4: <1ms
|
|
34
|
+
*/
|
|
35
|
+
const MAX_DEPTH = 4;
|
|
36
|
+
|
|
32
37
|
/**
|
|
33
38
|
* Simple deep clone inspired from https://github.com/angus-c/just/blob/master/packages/collection-clone/index.cjs
|
|
34
39
|
* Functions and RegExp will be returned as they are.
|
|
@@ -39,21 +44,22 @@ const isMap = (object: unknown): object is Map<string, unknown> => {
|
|
|
39
44
|
* @returns
|
|
40
45
|
*/
|
|
41
46
|
export const deepClone = <T>(originalObject: T, depth: number = 0): T => {
|
|
42
|
-
|
|
47
|
+
const type = {}.toString.call(originalObject).slice(8, -1);
|
|
48
|
+
if (isDate(type, originalObject)) {
|
|
43
49
|
return (new Date(originalObject.getTime()) as unknown) as T;
|
|
44
50
|
}
|
|
45
|
-
if (isSet(originalObject)) {
|
|
51
|
+
if (isSet(type, originalObject)) {
|
|
46
52
|
return (new Set(
|
|
47
53
|
[...originalObject].map(value => deepClone(value))
|
|
48
54
|
) as unknown) as T;
|
|
49
55
|
}
|
|
50
|
-
if (isMap(originalObject)) {
|
|
56
|
+
if (isMap(type, originalObject)) {
|
|
51
57
|
return (new Map(
|
|
52
58
|
[...originalObject].map(kv => [deepClone(kv[0]), deepClone(kv[1])])
|
|
53
59
|
) as unknown) as T;
|
|
54
60
|
}
|
|
55
|
-
if (isArray(originalObject)) {
|
|
56
|
-
if (depth >=
|
|
61
|
+
if (isArray(type, originalObject)) {
|
|
62
|
+
if (depth >= MAX_DEPTH) {
|
|
57
63
|
// Break the circular reference here
|
|
58
64
|
return originalObject;
|
|
59
65
|
}
|
|
@@ -66,8 +72,8 @@ export const deepClone = <T>(originalObject: T, depth: number = 0): T => {
|
|
|
66
72
|
|
|
67
73
|
return (result as unknown) as T;
|
|
68
74
|
}
|
|
69
|
-
if (isObject(originalObject)) {
|
|
70
|
-
if (depth >=
|
|
75
|
+
if (isObject(type, originalObject)) {
|
|
76
|
+
if (depth >= MAX_DEPTH) {
|
|
71
77
|
// Break the circular reference here
|
|
72
78
|
return originalObject;
|
|
73
79
|
}
|
package/src/version.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
// generated by genversion
|
|
2
|
-
export const version = '1.8.
|
|
2
|
+
export const version = '1.8.4';
|