@datadog/mobile-react-native 1.0.0-rc3 → 1.0.0-rc6
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/DatadogSDKReactNative.podspec +1 -1
- package/README.md +47 -16
- package/android/build.gradle +2 -3
- package/android/gradle.properties +4 -4
- package/android/src/main/java/com/datadog/reactnative/DdRum.kt +25 -24
- package/android/src/main/java/com/datadog/reactnative/DdTrace.kt +6 -6
- package/ios/Sources/DdRum.m +10 -9
- package/ios/Sources/DdRum.swift +24 -24
- package/ios/Sources/DdTrace.m +2 -2
- package/ios/Sources/DdTrace.swift +6 -6
- package/lib/commonjs/DdSdkReactNative.js +42 -22
- package/lib/commonjs/DdSdkReactNative.js.map +1 -1
- package/lib/commonjs/DdSdkReactNativeConfiguration.js +17 -2
- package/lib/commonjs/DdSdkReactNativeConfiguration.js.map +1 -1
- package/lib/commonjs/InternalLog.js +51 -0
- package/lib/commonjs/InternalLog.js.map +1 -0
- package/lib/commonjs/ProxyConfiguration.js.map +1 -1
- package/lib/commonjs/SdkVerbosity.js +26 -0
- package/lib/commonjs/SdkVerbosity.js.map +1 -0
- package/lib/commonjs/TimeProvider.js +72 -0
- package/lib/commonjs/TimeProvider.js.map +1 -0
- package/lib/commonjs/Timer.js +10 -23
- package/lib/commonjs/Timer.js.map +1 -1
- package/lib/commonjs/TrackingConsent.js.map +1 -1
- package/lib/commonjs/foundation.js +62 -40
- package/lib/commonjs/foundation.js.map +1 -1
- package/lib/commonjs/index.js +26 -18
- package/lib/commonjs/index.js.map +1 -1
- package/lib/commonjs/internal.js +14 -0
- package/lib/commonjs/internal.js.map +1 -0
- package/lib/commonjs/rum/instrumentation/DdEventsInterceptor.js +14 -5
- package/lib/commonjs/rum/instrumentation/DdEventsInterceptor.js.map +1 -1
- package/lib/commonjs/rum/instrumentation/DdRumErrorTracking.js +51 -20
- package/lib/commonjs/rum/instrumentation/DdRumErrorTracking.js.map +1 -1
- package/lib/commonjs/rum/instrumentation/DdRumResourceTracking.js +141 -30
- package/lib/commonjs/rum/instrumentation/DdRumResourceTracking.js.map +1 -1
- package/lib/commonjs/rum/instrumentation/DdRumUserInteractionTracking.js +46 -7
- package/lib/commonjs/rum/instrumentation/DdRumUserInteractionTracking.js.map +1 -1
- package/lib/commonjs/rum/instrumentation/NoOpEventsInterceptor.js.map +1 -1
- package/lib/commonjs/rum/instrumentation/ShallowObjectEqualityChecker.js +34 -0
- package/lib/commonjs/rum/instrumentation/ShallowObjectEqualityChecker.js.map +1 -0
- package/lib/commonjs/rum/instrumentation/TraceIdentifier.js.map +1 -1
- package/lib/commonjs/types.js.map +1 -1
- package/lib/commonjs/version.js +10 -0
- package/lib/commonjs/version.js.map +1 -0
- package/lib/module/DdSdkReactNative.js +34 -22
- package/lib/module/DdSdkReactNative.js.map +1 -1
- package/lib/module/DdSdkReactNativeConfiguration.js +18 -3
- package/lib/module/DdSdkReactNativeConfiguration.js.map +1 -1
- package/lib/module/InternalLog.js +46 -0
- package/lib/module/InternalLog.js.map +1 -0
- package/lib/module/ProxyConfiguration.js.map +1 -1
- package/lib/module/SdkVerbosity.js +18 -0
- package/lib/module/SdkVerbosity.js.map +1 -0
- package/lib/module/TimeProvider.js +63 -0
- package/lib/module/TimeProvider.js.map +1 -0
- package/lib/module/Timer.js +14 -23
- package/lib/module/Timer.js.map +1 -1
- package/lib/module/TrackingConsent.js.map +1 -1
- package/lib/module/foundation.js +42 -40
- package/lib/module/foundation.js.map +1 -1
- package/lib/module/index.js +3 -2
- package/lib/module/index.js.map +1 -1
- package/lib/module/internal.js +2 -0
- package/lib/module/internal.js.map +1 -0
- package/lib/module/rum/instrumentation/DdEventsInterceptor.js +11 -5
- package/lib/module/rum/instrumentation/DdEventsInterceptor.js.map +1 -1
- package/lib/module/rum/instrumentation/DdRumErrorTracking.js +46 -20
- package/lib/module/rum/instrumentation/DdRumErrorTracking.js.map +1 -1
- package/lib/module/rum/instrumentation/DdRumResourceTracking.js +133 -29
- package/lib/module/rum/instrumentation/DdRumResourceTracking.js.map +1 -1
- package/lib/module/rum/instrumentation/DdRumUserInteractionTracking.js +41 -6
- package/lib/module/rum/instrumentation/DdRumUserInteractionTracking.js.map +1 -1
- package/lib/module/rum/instrumentation/NoOpEventsInterceptor.js.map +1 -1
- package/lib/module/rum/instrumentation/ShallowObjectEqualityChecker.js +25 -0
- package/lib/module/rum/instrumentation/ShallowObjectEqualityChecker.js.map +1 -0
- package/lib/module/rum/instrumentation/TraceIdentifier.js.map +1 -1
- package/lib/module/types.js.map +1 -1
- package/lib/module/version.js +3 -0
- package/lib/module/version.js.map +1 -0
- package/lib/typescript/DdSdkReactNative.d.ts +7 -6
- package/lib/typescript/DdSdkReactNativeConfiguration.d.ts +15 -4
- package/lib/typescript/InternalLog.d.ts +6 -0
- package/lib/typescript/SdkVerbosity.d.ts +9 -0
- package/lib/typescript/TimeProvider.d.ts +20 -0
- package/lib/typescript/Timer.d.ts +3 -2
- package/lib/typescript/index.d.ts +3 -2
- package/lib/typescript/internal.d.ts +1 -0
- package/lib/typescript/rum/instrumentation/DdEventsInterceptor.d.ts +1 -0
- package/lib/typescript/rum/instrumentation/DdRumErrorTracking.d.ts +3 -2
- package/lib/typescript/rum/instrumentation/DdRumResourceTracking.d.ts +13 -8
- package/lib/typescript/rum/instrumentation/DdRumUserInteractionTracking.d.ts +3 -3
- package/lib/typescript/rum/instrumentation/DdRumXhr.d.ts +13 -3
- package/lib/typescript/rum/instrumentation/ShallowObjectEqualityChecker.d.ts +4 -0
- package/lib/typescript/types.d.ts +12 -11
- package/lib/typescript/version.d.ts +1 -0
- package/package.json +7 -4
- package/src/DdSdkReactNative.tsx +112 -58
- package/src/DdSdkReactNativeConfiguration.tsx +22 -14
- package/src/InternalLog.tsx +45 -0
- package/src/ProxyConfiguration.tsx +5 -5
- package/src/{NativeSdkVerbosity.tsx → SdkVerbosity.tsx} +6 -6
- package/src/TimeProvider.tsx +64 -0
- package/src/Timer.ts +20 -35
- package/src/TrackingConsent.tsx +3 -3
- package/src/__mocks__/InternalLog.tsx +9 -0
- package/src/__tests__/DdRumWrapper.test.tsx +98 -0
- package/src/__tests__/DdSdkReactNative.test.tsx +699 -500
- package/src/__tests__/InternalLog.test.tsx +379 -0
- package/src/__tests__/TimeProvider.test.tsx +75 -0
- package/src/__tests__/Timer.test.ts +148 -57
- package/src/__tests__/rum/instrumentation/DdEventsInterceptor.test.tsx +151 -92
- package/src/__tests__/rum/instrumentation/DdRumErrorTracking.test.tsx +243 -76
- package/src/__tests__/rum/instrumentation/DdRumResourceTracking.test.tsx +723 -403
- package/src/__tests__/rum/instrumentation/DdRumUserInteractionTracking.test.tsx +239 -85
- package/src/__tests__/rum/instrumentation/ShallowObjectEqualityChecker.test.ts +31 -0
- package/src/__tests__/rum/instrumentation/TraceIdentifier.test.tsx +13 -15
- package/src/__tests__/rum/instrumentation/__utils__/XMLHttpRequestMock.ts +97 -0
- package/src/foundation.tsx +55 -42
- package/src/index.tsx +13 -3
- package/src/internal.tsx +1 -0
- package/src/rum/instrumentation/DdEventsInterceptor.tsx +51 -35
- package/src/rum/instrumentation/DdRumErrorTracking.tsx +75 -42
- package/src/rum/instrumentation/DdRumResourceTracking.tsx +312 -166
- package/src/rum/instrumentation/DdRumUserInteractionTracking.tsx +72 -25
- package/src/rum/instrumentation/DdRumXhr.tsx +21 -11
- package/src/rum/instrumentation/EventsInterceptor.tsx +3 -3
- package/src/rum/instrumentation/NoOpEventsInterceptor.tsx +2 -2
- package/src/rum/instrumentation/ShallowObjectEqualityChecker.ts +24 -0
- package/src/rum/instrumentation/TraceIdentifier.tsx +19 -19
- package/src/types.tsx +199 -157
- package/src/version.ts +2 -0
- package/lib/commonjs/NativeSdkVerbosity.js +0 -26
- package/lib/commonjs/NativeSdkVerbosity.js.map +0 -1
- package/lib/module/NativeSdkVerbosity.js +0 -18
- package/lib/module/NativeSdkVerbosity.js.map +0 -1
- package/lib/typescript/NativeSdkVerbosity.d.ts +0 -9
|
@@ -15,26 +15,42 @@ var _reactNative = require("react-native");
|
|
|
15
15
|
|
|
16
16
|
var _types = require("./types");
|
|
17
17
|
|
|
18
|
+
var _InternalLog = require("./InternalLog");
|
|
19
|
+
|
|
20
|
+
var _SdkVerbosity = require("./SdkVerbosity");
|
|
21
|
+
|
|
22
|
+
var _TimeProvider = require("./TimeProvider");
|
|
23
|
+
|
|
18
24
|
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
19
25
|
|
|
26
|
+
const timeProvider = new _TimeProvider.TimeProvider();
|
|
27
|
+
|
|
20
28
|
class DdLogsWrapper {
|
|
21
29
|
constructor() {
|
|
22
30
|
_defineProperty(this, "nativeLogs", _reactNative.NativeModules.DdLogs);
|
|
23
31
|
}
|
|
24
32
|
|
|
25
33
|
debug(message, context = {}) {
|
|
34
|
+
_InternalLog.InternalLog.log("Tracking debug log “" + message + "”", _SdkVerbosity.SdkVerbosity.DEBUG);
|
|
35
|
+
|
|
26
36
|
return this.nativeLogs.debug(message, context);
|
|
27
37
|
}
|
|
28
38
|
|
|
29
39
|
info(message, context = {}) {
|
|
40
|
+
_InternalLog.InternalLog.log("Tracking info log “" + message + "”", _SdkVerbosity.SdkVerbosity.DEBUG);
|
|
41
|
+
|
|
30
42
|
return this.nativeLogs.info(message, context);
|
|
31
43
|
}
|
|
32
44
|
|
|
33
45
|
warn(message, context = {}) {
|
|
46
|
+
_InternalLog.InternalLog.log("Tracking warn log “" + message + "”", _SdkVerbosity.SdkVerbosity.DEBUG);
|
|
47
|
+
|
|
34
48
|
return this.nativeLogs.warn(message, context);
|
|
35
49
|
}
|
|
36
50
|
|
|
37
51
|
error(message, context = {}) {
|
|
52
|
+
_InternalLog.InternalLog.log("Tracking error log “" + message + "”", _SdkVerbosity.SdkVerbosity.DEBUG);
|
|
53
|
+
|
|
38
54
|
return this.nativeLogs.error(message, context);
|
|
39
55
|
}
|
|
40
56
|
|
|
@@ -45,16 +61,18 @@ class DdTraceWrapper {
|
|
|
45
61
|
_defineProperty(this, "nativeTrace", _reactNative.NativeModules.DdTrace);
|
|
46
62
|
}
|
|
47
63
|
|
|
48
|
-
startSpan(operation, context = {}, timestampMs =
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
64
|
+
startSpan(operation, context = {}, timestampMs = timeProvider.now()) {
|
|
65
|
+
let spanId = this.nativeTrace.startSpan(operation, context, timestampMs);
|
|
66
|
+
|
|
67
|
+
_InternalLog.InternalLog.log("Starting span “" + operation + "” #" + spanId, _SdkVerbosity.SdkVerbosity.DEBUG);
|
|
68
|
+
|
|
69
|
+
return spanId;
|
|
52
70
|
}
|
|
53
71
|
|
|
54
|
-
finishSpan(spanId, context = {}, timestampMs =
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
return this.nativeTrace.finishSpan(spanId,
|
|
72
|
+
finishSpan(spanId, context = {}, timestampMs = timeProvider.now()) {
|
|
73
|
+
_InternalLog.InternalLog.log("Finishing span #" + spanId, _SdkVerbosity.SdkVerbosity.DEBUG);
|
|
74
|
+
|
|
75
|
+
return this.nativeTrace.finishSpan(spanId, context, timestampMs);
|
|
58
76
|
}
|
|
59
77
|
|
|
60
78
|
}
|
|
@@ -64,55 +82,59 @@ class DdRumWrapper {
|
|
|
64
82
|
_defineProperty(this, "nativeRum", _reactNative.NativeModules.DdRum);
|
|
65
83
|
}
|
|
66
84
|
|
|
67
|
-
startView(key, name, context = {}, timestampMs =
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
return this.nativeRum.startView(key, name,
|
|
85
|
+
startView(key, name, context = {}, timestampMs = timeProvider.now()) {
|
|
86
|
+
_InternalLog.InternalLog.log("Starting RUM View “" + name + "” #" + key, _SdkVerbosity.SdkVerbosity.DEBUG);
|
|
87
|
+
|
|
88
|
+
return this.nativeRum.startView(key, name, context, timestampMs);
|
|
71
89
|
}
|
|
72
90
|
|
|
73
|
-
stopView(key, context = {}, timestampMs =
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
return this.nativeRum.stopView(key,
|
|
91
|
+
stopView(key, context = {}, timestampMs = timeProvider.now()) {
|
|
92
|
+
_InternalLog.InternalLog.log("Stopping RUM View #" + key, _SdkVerbosity.SdkVerbosity.DEBUG);
|
|
93
|
+
|
|
94
|
+
return this.nativeRum.stopView(key, context, timestampMs);
|
|
77
95
|
}
|
|
78
96
|
|
|
79
|
-
startAction(type, name, context = {}, timestampMs =
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
return this.nativeRum.startAction(type, name,
|
|
97
|
+
startAction(type, name, context = {}, timestampMs = timeProvider.now()) {
|
|
98
|
+
_InternalLog.InternalLog.log("Starting RUM Action “" + name + "” (" + type + ")", _SdkVerbosity.SdkVerbosity.DEBUG);
|
|
99
|
+
|
|
100
|
+
return this.nativeRum.startAction(type, name, context, timestampMs);
|
|
83
101
|
}
|
|
84
102
|
|
|
85
|
-
stopAction(context = {}, timestampMs =
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
return this.nativeRum.stopAction(
|
|
103
|
+
stopAction(context = {}, timestampMs = timeProvider.now()) {
|
|
104
|
+
_InternalLog.InternalLog.log("Stopping current RUM Action", _SdkVerbosity.SdkVerbosity.DEBUG);
|
|
105
|
+
|
|
106
|
+
return this.nativeRum.stopAction(context, timestampMs);
|
|
89
107
|
}
|
|
90
108
|
|
|
91
|
-
addAction(type, name, context = {}, timestampMs =
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
return this.nativeRum.addAction(type, name,
|
|
109
|
+
addAction(type, name, context = {}, timestampMs = timeProvider.now()) {
|
|
110
|
+
_InternalLog.InternalLog.log("Adding RUM Action “" + name + "” (" + type + ")", _SdkVerbosity.SdkVerbosity.DEBUG);
|
|
111
|
+
|
|
112
|
+
return this.nativeRum.addAction(type, name, context, timestampMs);
|
|
95
113
|
}
|
|
96
114
|
|
|
97
|
-
startResource(key, method, url, context = {}, timestampMs =
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
return this.nativeRum.startResource(key, method, url,
|
|
115
|
+
startResource(key, method, url, context = {}, timestampMs = timeProvider.now()) {
|
|
116
|
+
_InternalLog.InternalLog.log("Starting RUM Resource #" + key + " " + method + ": " + url, _SdkVerbosity.SdkVerbosity.DEBUG);
|
|
117
|
+
|
|
118
|
+
return this.nativeRum.startResource(key, method, url, context, timestampMs);
|
|
101
119
|
}
|
|
102
120
|
|
|
103
|
-
stopResource(key, statusCode, kind, context = {}, timestampMs =
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
return this.nativeRum.stopResource(key, statusCode, kind,
|
|
121
|
+
stopResource(key, statusCode, kind, size = -1, context = {}, timestampMs = timeProvider.now()) {
|
|
122
|
+
_InternalLog.InternalLog.log("Stopping RUM Resource #" + key + " status:" + statusCode, _SdkVerbosity.SdkVerbosity.DEBUG);
|
|
123
|
+
|
|
124
|
+
return this.nativeRum.stopResource(key, statusCode, kind, size, context, timestampMs);
|
|
107
125
|
}
|
|
108
126
|
|
|
109
|
-
addError(message, source, stacktrace, context = {}, timestampMs =
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
127
|
+
addError(message, source, stacktrace, context = {}, timestampMs = timeProvider.now()) {
|
|
128
|
+
_InternalLog.InternalLog.log("Adding RUM Error “" + message + "”", _SdkVerbosity.SdkVerbosity.DEBUG);
|
|
129
|
+
|
|
130
|
+
let updatedContext = context;
|
|
131
|
+
updatedContext["_dd.error.source_type"] = "react-native";
|
|
132
|
+
return this.nativeRum.addError(message, source, stacktrace, updatedContext, timestampMs);
|
|
113
133
|
}
|
|
114
134
|
|
|
115
135
|
addTiming(name) {
|
|
136
|
+
_InternalLog.InternalLog.log("Adding timing “" + name + "” to RUM View", _SdkVerbosity.SdkVerbosity.DEBUG);
|
|
137
|
+
|
|
116
138
|
return this.nativeRum.addTiming(name);
|
|
117
139
|
}
|
|
118
140
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["foundation.tsx"],"names":["DdLogsWrapper","NativeModules","DdLogs","debug","message","context","nativeLogs","info","warn","error","DdTraceWrapper","DdTrace","startSpan","operation","timestampMs","Date","now","nativeTrace","finishSpan","spanId","DdRumWrapper","DdRum","startView","key","name","nativeRum","stopView","startAction","type","stopAction","addAction","startResource","method","url","stopResource","statusCode","kind","addError","source","stacktrace","addTiming","DdSdk"],"mappings":";;;;;;;;;;;;;AAMA;;AACA;;;;AAEA,MAAMA,aAAN,CAA0C;AAAA;AAAA,wCAELC,2BAAcC,MAFT;AAAA;;AAItCC,EAAAA,KAAK,CAACC,OAAD,EAAkBC,OAAe,GAAG,EAApC,EAAuD;AACxD,WAAO,KAAKC,UAAL,CAAgBH,KAAhB,CAAsBC,OAAtB,EAA+BC,OAA/B,CAAP;AACH;;AACDE,EAAAA,IAAI,CAACH,OAAD,EAAkBC,OAAe,GAAG,EAApC,EAAuD;AACvD,WAAO,KAAKC,UAAL,CAAgBC,IAAhB,CAAqBH,OAArB,EAA8BC,OAA9B,CAAP;AACH;;AACDG,EAAAA,IAAI,CAACJ,OAAD,EAAkBC,OAAe,GAAG,EAApC,EAAuD;AACvD,WAAO,KAAKC,UAAL,CAAgBE,IAAhB,CAAqBJ,OAArB,EAA8BC,OAA9B,CAAP;AACH;;AACDI,EAAAA,KAAK,CAACL,OAAD,EAAkBC,OAAe,GAAG,EAApC,EAAuD;AACxD,WAAO,KAAKC,UAAL,CAAgBG,KAAhB,CAAsBL,OAAtB,EAA+BC,OAA/B,CAAP;AACH;;AAfqC;;AAmB1C,MAAMK,cAAN,CAA4C;AAAA;AAAA,yCAELT,2BAAcU,OAFT;AAAA;;AAIxCC,EAAAA,SAAS,CAACC,SAAD,EAAoBR,OAAe,GAAG,EAAtC,EAA0CS,WAAmB,GAAGC,IAAI,CAACC,GAAL,EAAhE,EAA6F;AAClG;AACA;AACA,WAAO,KAAKC,WAAL,CAAiBL,SAAjB,CAA2BC,SAA3B,EAAsCC,WAAtC,EAAmDT,OAAnD,CAAP;AACH;;AACDa,EAAAA,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,KAAgB,GAAGxC,2BAAcwC,KAAvC;;AACA,MAAMvC,MAAkB,GAAG,IAAIF,aAAJ,EAA3B;;AACA,MAAMW,OAAoB,GAAG,IAAID,cAAJ,EAA7B;;AACA,MAAMW,KAAgB,GAAG,IAAID,YAAJ,EAAzB","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\nimport { NativeModules } from 'react-native';\nimport { DdSdkConfiguration, DdSdkType, DdLogsType, DdTraceType, DdRumType } from './types';\n\nclass DdLogsWrapper implements DdLogsType {\n\n private nativeLogs: DdLogsType = NativeModules.DdLogs;\n\n debug(message: string, context: object = {}): Promise<void> {\n return this.nativeLogs.debug(message, context);\n }\n info(message: string, context: object = {}): Promise<void> {\n return this.nativeLogs.info(message, context);\n }\n warn(message: string, context: object = {}): Promise<void> {\n return this.nativeLogs.warn(message, context);\n }\n error(message: string, context: object = {}): Promise<void> {\n return this.nativeLogs.error(message, context);\n }\n\n}\n\nclass DdTraceWrapper implements DdTraceType {\n\n private nativeTrace: DdTraceType = NativeModules.DdTrace;\n\n startSpan(operation: string, context: object = {}, timestampMs: number = Date.now()): Promise<string> {\n // TODO swap context and stacktrace in the native call, requires native bridges update\n // @ts-ignore\n return this.nativeTrace.startSpan(operation, timestampMs, context);\n }\n finishSpan(spanId: string, context: object = {}, timestampMs: number = Date.now()): Promise<void> {\n // TODO swap context and stacktrace in the native call, requires native bridges update\n // @ts-ignore\n return this.nativeTrace.finishSpan(spanId, timestampMs, context);\n }\n\n}\n\nclass DdRumWrapper implements DdRumType {\n\n private nativeRum: DdRumType = NativeModules.DdRum;\n\n startView(key: string, name: string, context: object = {}, timestampMs: number = Date.now()): Promise<void> {\n // TODO swap context and stacktrace in the native call, requires native bridges update\n // @ts-ignore\n return this.nativeRum.startView(key, name, timestampMs, context);\n }\n stopView(key: string, context: object = {}, timestampMs: number = Date.now()): Promise<void> {\n // TODO swap context and stacktrace in the native call, requires native bridges update\n // @ts-ignore\n return this.nativeRum.stopView(key, timestampMs, context);\n }\n startAction(type: string, name: string, context: object = {}, timestampMs: number = Date.now()): Promise<void> {\n // TODO swap context and stacktrace in the native call, requires native bridges update\n // @ts-ignore\n return this.nativeRum.startAction(type, name, timestampMs, context);\n }\n stopAction(context: object = {}, timestampMs: number = Date.now()): Promise<void> {\n // TODO swap context and stacktrace in the native call, requires native bridges update\n // @ts-ignore\n return this.nativeRum.stopAction(timestampMs, context);\n }\n addAction(type: string, name: string, context: object = {}, timestampMs: number = Date.now()): Promise<void> {\n // TODO swap context and stacktrace in the native call, requires native bridges update\n // @ts-ignore\n return this.nativeRum.addAction(type, name, timestampMs, context);\n }\n startResource(key: string, method: string, url: string, context: object = {}, timestampMs: number = Date.now()): Promise<void> {\n // TODO swap context and stacktrace in the native call, requires native bridges update\n // @ts-ignore\n return this.nativeRum.startResource(key, method, url, timestampMs, context);\n }\n stopResource(key: string, statusCode: number, kind: string, context: object = {}, timestampMs: number = Date.now()): Promise<void> {\n // TODO swap context and stacktrace in the native call, requires native bridges update\n // @ts-ignore\n return this.nativeRum.stopResource(key, statusCode, kind, timestampMs, context);\n }\n addError(message: string, source: string, stacktrace: string, context: object = {}, timestampMs: number = Date.now()): Promise<void> {\n // TODO swap context and stacktrace in the native call, requires native bridges update\n // @ts-ignore\n return this.nativeRum.addError(message, source, stacktrace, timestampMs, context);\n }\n addTiming(name: string): Promise<void> {\n return this.nativeRum.addTiming(name);\n }\n\n}\n\nconst DdSdk: DdSdkType = NativeModules.DdSdk;\nconst DdLogs: DdLogsType = new DdLogsWrapper();\nconst DdTrace: DdTraceType = new DdTraceWrapper();\nconst DdRum: DdRumType = new DdRumWrapper();\n\nexport { DdSdkConfiguration, DdSdk, DdLogs, DdTrace, DdRum };\n"]}
|
|
1
|
+
{"version":3,"sources":["foundation.tsx"],"names":["timeProvider","TimeProvider","DdLogsWrapper","NativeModules","DdLogs","debug","message","context","InternalLog","log","SdkVerbosity","DEBUG","nativeLogs","info","warn","error","DdTraceWrapper","DdTrace","startSpan","operation","timestampMs","now","spanId","nativeTrace","finishSpan","DdRumWrapper","DdRum","startView","key","name","nativeRum","stopView","startAction","type","stopAction","addAction","startResource","method","url","stopResource","statusCode","kind","size","addError","source","stacktrace","updatedContext","addTiming","DdSdk"],"mappings":";;;;;;;;;;;;;AAMA;;AACA;;AACA;;AACA;;AACA;;;;AAEA,MAAMA,YAAY,GAAG,IAAIC,0BAAJ,EAArB;;AAEA,MAAMC,aAAN,CAA0C;AAAA;AAAA,wCAELC,2BAAcC,MAFT;AAAA;;AAItCC,EAAAA,KAAK,CAACC,OAAD,EAAkBC,OAAe,GAAG,EAApC,EAAuD;AACxDC,6BAAYC,GAAZ,CAAgB,yBAA0BH,OAA1B,GAAoC,GAApD,EAAyDI,2BAAaC,KAAtE;;AACA,WAAO,KAAKC,UAAL,CAAgBP,KAAhB,CAAsBC,OAAtB,EAA+BC,OAA/B,CAAP;AACH;;AAEDM,EAAAA,IAAI,CAACP,OAAD,EAAkBC,OAAe,GAAG,EAApC,EAAuD;AACvDC,6BAAYC,GAAZ,CAAgB,wBAAyBH,OAAzB,GAAmC,GAAnD,EAAwDI,2BAAaC,KAArE;;AACA,WAAO,KAAKC,UAAL,CAAgBC,IAAhB,CAAqBP,OAArB,EAA8BC,OAA9B,CAAP;AACH;;AAEDO,EAAAA,IAAI,CAACR,OAAD,EAAkBC,OAAe,GAAG,EAApC,EAAuD;AACvDC,6BAAYC,GAAZ,CAAgB,wBAAyBH,OAAzB,GAAmC,GAAnD,EAAwDI,2BAAaC,KAArE;;AACA,WAAO,KAAKC,UAAL,CAAgBE,IAAhB,CAAqBR,OAArB,EAA8BC,OAA9B,CAAP;AACH;;AAEDQ,EAAAA,KAAK,CAACT,OAAD,EAAkBC,OAAe,GAAG,EAApC,EAAuD;AACxDC,6BAAYC,GAAZ,CAAgB,yBAA0BH,OAA1B,GAAoC,GAApD,E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c,CAAC,uBAAD,CAAd,GAA0C,cAA1C;AACA,WAAO,KAAKhB,SAAL,CAAea,QAAf,CAAwBrC,OAAxB,EAAiCsC,MAAjC,EAAyCC,UAAzC,EAAqDC,cAArD,EAAqE1B,WAArE,CAAP;AACH;;AAED2B,EAAAA,SAAS,CAAClB,IAAD,EAA8B;AACnCrB,6BAAYC,GAAZ,CAAgB,oBAAoBoB,IAApB,GAA2B,eAA3C,EAA4DnB,2BAAaC,KAAzE;;AACA,WAAO,KAAKmB,SAAL,CAAeiB,SAAf,CAAyBlB,IAAzB,CAAP;AACH;;AAjDmC;;AAoDxC,MAAMmB,KAAgB,GAAG7C,2BAAc6C,KAAvC;;AACA,MAAM5C,MAAkB,GAAG,IAAIF,aAAJ,EAA3B;;AACA,MAAMe,OAAoB,GAAG,IAAID,cAAJ,EAA7B;;AACA,MAAMU,KAAgB,GAAG,IAAID,YAAJ,EAAzB","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\nimport { NativeModules } from 'react-native';\nimport { DdSdkConfiguration, DdSdkType, DdLogsType, DdTraceType, DdRumType } from './types';\nimport {InternalLog} from \"./InternalLog\"\nimport {SdkVerbosity} from \"./SdkVerbosity\";\nimport {TimeProvider} from \"./TimeProvider\";\n\nconst timeProvider = new TimeProvider();\n\nclass DdLogsWrapper implements DdLogsType {\n\n private nativeLogs: DdLogsType = NativeModules.DdLogs;\n\n debug(message: string, context: object = {}): Promise<void> {\n InternalLog.log(\"Tracking debug log “\" + message + \"”\", SdkVerbosity.DEBUG);\n return this.nativeLogs.debug(message, context);\n }\n\n info(message: string, context: object = {}): Promise<void> {\n InternalLog.log(\"Tracking info log “\" + message + \"”\", SdkVerbosity.DEBUG);\n return this.nativeLogs.info(message, context);\n }\n\n warn(message: string, context: object = {}): Promise<void> {\n InternalLog.log(\"Tracking warn log “\" + message + \"”\", SdkVerbosity.DEBUG);\n return this.nativeLogs.warn(message, context);\n }\n\n error(message: string, context: object = {}): Promise<void> {\n InternalLog.log(\"Tracking error log “\" + message + \"”\", SdkVerbosity.DEBUG);\n return this.nativeLogs.error(message, context);\n }\n\n}\n\nclass DdTraceWrapper implements DdTraceType {\n\n private nativeTrace: DdTraceType = NativeModules.DdTrace;\n\n startSpan(operation: string, context: object = {}, timestampMs: number = timeProvider.now()): Promise<string> {\n let spanId = this.nativeTrace.startSpan(operation, context, timestampMs);\n InternalLog.log(\"Starting span “\" + operation + \"” #\" + spanId, SdkVerbosity.DEBUG);\n return spanId\n }\n\n finishSpan(spanId: string, context: object = {}, timestampMs: number = timeProvider.now()): Promise<void> {\n InternalLog.log(\"Finishing span #\" + spanId, SdkVerbosity.DEBUG);\n return this.nativeTrace.finishSpan(spanId, context, timestampMs);\n }\n}\n\nclass DdRumWrapper implements DdRumType {\n\n private nativeRum: DdRumType = NativeModules.DdRum;\n\n startView(key: string, name: string, context: object = {}, timestampMs: number = timeProvider.now()): Promise<void> {\n InternalLog.log(\"Starting RUM View “\" + name + \"” #\" + key, SdkVerbosity.DEBUG);\n return this.nativeRum.startView(key, name, context, timestampMs);\n }\n\n stopView(key: string, context: object = {}, timestampMs: number = timeProvider.now()): Promise<void> {\n InternalLog.log(\"Stopping RUM View #\" + key, SdkVerbosity.DEBUG);\n return this.nativeRum.stopView(key, context, timestampMs);\n }\n\n startAction(type: string, name: string, context: object = {}, timestampMs: number = timeProvider.now()): Promise<void> {\n InternalLog.log(\"Starting RUM Action “\" + name + \"” (\" + type + \")\", SdkVerbosity.DEBUG);\n return this.nativeRum.startAction(type, name, context, timestampMs);\n }\n\n stopAction(context: object = {}, timestampMs: number = timeProvider.now()): Promise<void> {\n InternalLog.log(\"Stopping current RUM Action\", SdkVerbosity.DEBUG);\n return this.nativeRum.stopAction(context, timestampMs);\n }\n\n addAction(type: string, name: string, context: object = {}, timestampMs: number = timeProvider.now()): Promise<void> {\n InternalLog.log(\"Adding RUM Action “\" + name + \"” (\" + type + \")\", SdkVerbosity.DEBUG);\n return this.nativeRum.addAction(type, name, context, timestampMs);\n }\n\n startResource(key: string, method: string, url: string, context: object = {}, timestampMs: number = timeProvider.now()): Promise<void> {\n InternalLog.log(\"Starting RUM Resource #\" + key + \" \" + method + \": \" + url, SdkVerbosity.DEBUG);\n return this.nativeRum.startResource(key, method, url, context, timestampMs);\n }\n\n stopResource(key: string, statusCode: number, kind: string, size: number = -1, context: object = {}, timestampMs: number = timeProvider.now()): Promise<void> {\n InternalLog.log(\"Stopping RUM Resource #\" + key + \" status:\" + statusCode, SdkVerbosity.DEBUG);\n return this.nativeRum.stopResource(key, statusCode, kind, size, context, timestampMs);\n }\n\n addError(message: string, source: string, stacktrace: string, context: object = {}, timestampMs: number = timeProvider.now()): Promise<void> {\n InternalLog.log(\"Adding RUM Error “\" + message + \"”\", SdkVerbosity.DEBUG);\n let updatedContext: any = context;\n updatedContext[\"_dd.error.source_type\"] = \"react-native\";\n return this.nativeRum.addError(message, source, stacktrace, updatedContext, timestampMs);\n }\n\n addTiming(name: string): Promise<void> {\n InternalLog.log(\"Adding timing “\" + name + \"” to RUM View\", SdkVerbosity.DEBUG);\n return this.nativeRum.addTiming(name);\n }\n}\n\nconst DdSdk: DdSdkType = NativeModules.DdSdk;\nconst DdLogs: DdLogsType = new DdLogsWrapper();\nconst DdTrace: DdTraceType = new DdTraceWrapper();\nconst DdRum: DdRumType = new DdRumWrapper();\n\nexport { DdSdkConfiguration, DdSdk, DdLogs, DdTrace, DdRum };\n"]}
|
package/lib/commonjs/index.js
CHANGED
|
@@ -3,56 +3,60 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
-
Object.defineProperty(exports, "
|
|
6
|
+
Object.defineProperty(exports, "DdSdkReactNativeConfiguration", {
|
|
7
7
|
enumerable: true,
|
|
8
8
|
get: function () {
|
|
9
|
-
return
|
|
9
|
+
return _DdSdkReactNativeConfiguration.DdSdkReactNativeConfiguration;
|
|
10
10
|
}
|
|
11
11
|
});
|
|
12
|
-
Object.defineProperty(exports, "
|
|
12
|
+
Object.defineProperty(exports, "DdSdkReactNative", {
|
|
13
13
|
enumerable: true,
|
|
14
14
|
get: function () {
|
|
15
|
-
return
|
|
15
|
+
return _DdSdkReactNative.DdSdkReactNative;
|
|
16
16
|
}
|
|
17
17
|
});
|
|
18
|
-
Object.defineProperty(exports, "
|
|
18
|
+
Object.defineProperty(exports, "ProxyConfiguration", {
|
|
19
19
|
enumerable: true,
|
|
20
20
|
get: function () {
|
|
21
|
-
return
|
|
21
|
+
return _ProxyConfiguration.ProxyConfiguration;
|
|
22
22
|
}
|
|
23
23
|
});
|
|
24
|
-
Object.defineProperty(exports, "
|
|
24
|
+
Object.defineProperty(exports, "ProxyType", {
|
|
25
25
|
enumerable: true,
|
|
26
26
|
get: function () {
|
|
27
|
-
return
|
|
27
|
+
return _ProxyConfiguration.ProxyType;
|
|
28
28
|
}
|
|
29
29
|
});
|
|
30
|
-
Object.defineProperty(exports, "
|
|
30
|
+
Object.defineProperty(exports, "SdkVerbosity", {
|
|
31
31
|
enumerable: true,
|
|
32
32
|
get: function () {
|
|
33
|
-
return
|
|
33
|
+
return _SdkVerbosity.SdkVerbosity;
|
|
34
34
|
}
|
|
35
35
|
});
|
|
36
|
-
Object.defineProperty(exports, "
|
|
36
|
+
Object.defineProperty(exports, "TrackingConsent", {
|
|
37
37
|
enumerable: true,
|
|
38
38
|
get: function () {
|
|
39
|
-
return
|
|
39
|
+
return _TrackingConsent.TrackingConsent;
|
|
40
40
|
}
|
|
41
41
|
});
|
|
42
|
-
Object.defineProperty(exports, "
|
|
42
|
+
Object.defineProperty(exports, "DdLogs", {
|
|
43
43
|
enumerable: true,
|
|
44
44
|
get: function () {
|
|
45
|
-
return
|
|
45
|
+
return _foundation.DdLogs;
|
|
46
46
|
}
|
|
47
47
|
});
|
|
48
|
-
Object.defineProperty(exports, "
|
|
48
|
+
Object.defineProperty(exports, "DdTrace", {
|
|
49
49
|
enumerable: true,
|
|
50
50
|
get: function () {
|
|
51
|
-
return
|
|
51
|
+
return _foundation.DdTrace;
|
|
52
|
+
}
|
|
53
|
+
});
|
|
54
|
+
Object.defineProperty(exports, "DdRum", {
|
|
55
|
+
enumerable: true,
|
|
56
|
+
get: function () {
|
|
57
|
+
return _foundation.DdRum;
|
|
52
58
|
}
|
|
53
59
|
});
|
|
54
|
-
|
|
55
|
-
var _foundation = require("./foundation");
|
|
56
60
|
|
|
57
61
|
var _DdSdkReactNativeConfiguration = require("./DdSdkReactNativeConfiguration");
|
|
58
62
|
|
|
@@ -60,5 +64,9 @@ var _DdSdkReactNative = require("./DdSdkReactNative");
|
|
|
60
64
|
|
|
61
65
|
var _ProxyConfiguration = require("./ProxyConfiguration");
|
|
62
66
|
|
|
67
|
+
var _SdkVerbosity = require("./SdkVerbosity");
|
|
68
|
+
|
|
63
69
|
var _TrackingConsent = require("./TrackingConsent");
|
|
70
|
+
|
|
71
|
+
var _foundation = require("./foundation");
|
|
64
72
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["index.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"sources":["index.tsx"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAMA;;AACA;;AACA;;AACA;;AACA;;AACA","sourcesContent":["/*\n * Unless explicitly stated otherwise all files in this repository are licensed under the Apache License Version 2.0.\n * This product includes software developed at Datadog (https://www.datadoghq.com/).\n * Copyright 2016-Present Datadog, Inc.\n */\n\nimport { DdSdkReactNativeConfiguration } from './DdSdkReactNativeConfiguration';\nimport { DdSdkReactNative } from './DdSdkReactNative';\nimport { ProxyConfiguration, ProxyType } from './ProxyConfiguration';\nimport { SdkVerbosity } from './SdkVerbosity';\nimport { TrackingConsent } from './TrackingConsent';\nimport { DdLogs, DdTrace, DdRum } from './foundation';\n\nexport {\n DdLogs,\n DdTrace,\n DdRum,\n DdSdkReactNativeConfiguration,\n DdSdkReactNative,\n ProxyConfiguration,\n ProxyType,\n TrackingConsent,\n SdkVerbosity\n};\n"]}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
Object.defineProperty(exports, "InternalLog", {
|
|
7
|
+
enumerable: true,
|
|
8
|
+
get: function () {
|
|
9
|
+
return _InternalLog.InternalLog;
|
|
10
|
+
}
|
|
11
|
+
});
|
|
12
|
+
|
|
13
|
+
var _InternalLog = require("./InternalLog");
|
|
14
|
+
//# sourceMappingURL=internal.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["internal.tsx"],"names":[],"mappings":";;;;;;;;;;;;AAAA","sourcesContent":["export { InternalLog } from './InternalLog';\n"]}
|
|
@@ -5,15 +5,19 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
5
5
|
});
|
|
6
6
|
exports.RumActionType = exports.DdEventsInterceptor = exports.UNKNOWN_TARGET_NAME = void 0;
|
|
7
7
|
|
|
8
|
+
var _InternalLog = require("../../InternalLog");
|
|
9
|
+
|
|
10
|
+
var _SdkVerbosity = require("../../SdkVerbosity");
|
|
11
|
+
|
|
8
12
|
var _foundation = require("../../foundation");
|
|
9
13
|
|
|
10
14
|
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
11
15
|
|
|
12
|
-
const UNKNOWN_TARGET_NAME =
|
|
16
|
+
const UNKNOWN_TARGET_NAME = 'unknown_target';
|
|
13
17
|
exports.UNKNOWN_TARGET_NAME = UNKNOWN_TARGET_NAME;
|
|
14
18
|
const DEBOUNCE_EVENT_THRESHOLD_IN_MS = 10;
|
|
15
19
|
const HANDLE_EVENT_APP_EXECUTION_TIME_IN_MS = 1;
|
|
16
|
-
const DD_ACTION_NAME_PROP =
|
|
20
|
+
const DD_ACTION_NAME_PROP = 'dd-action-name';
|
|
17
21
|
|
|
18
22
|
class DdEventsInterceptor {
|
|
19
23
|
constructor() {
|
|
@@ -31,6 +35,8 @@ class DdEventsInterceptor {
|
|
|
31
35
|
|
|
32
36
|
this.debouncingStartedTimestamp = currentTime + HANDLE_EVENT_APP_EXECUTION_TIME_IN_MS;
|
|
33
37
|
}
|
|
38
|
+
} else {
|
|
39
|
+
_InternalLog.InternalLog.log(DdEventsInterceptor.ACTION_EVENT_DROPPED_WARN_MESSAGE, _SdkVerbosity.SdkVerbosity.WARN);
|
|
34
40
|
}
|
|
35
41
|
}
|
|
36
42
|
|
|
@@ -58,15 +64,15 @@ class DdEventsInterceptor {
|
|
|
58
64
|
}
|
|
59
65
|
|
|
60
66
|
const elementTypeName = this.resolveElementTypeName(targetNode.elementType);
|
|
61
|
-
return elementTypeName
|
|
67
|
+
return elementTypeName || UNKNOWN_TARGET_NAME;
|
|
62
68
|
}
|
|
63
69
|
|
|
64
70
|
resolveElementTypeName(elementType) {
|
|
65
71
|
let elementTypeName = null;
|
|
66
72
|
|
|
67
|
-
if (typeof elementType ===
|
|
73
|
+
if (typeof elementType === 'string') {
|
|
68
74
|
elementTypeName = elementType;
|
|
69
|
-
} else if (elementType && typeof elementType.name ===
|
|
75
|
+
} else if (elementType && typeof elementType.name === 'string') {
|
|
70
76
|
elementTypeName = elementType.name;
|
|
71
77
|
}
|
|
72
78
|
|
|
@@ -96,6 +102,9 @@ class DdEventsInterceptor {
|
|
|
96
102
|
|
|
97
103
|
|
|
98
104
|
exports.DdEventsInterceptor = DdEventsInterceptor;
|
|
105
|
+
|
|
106
|
+
_defineProperty(DdEventsInterceptor, "ACTION_EVENT_DROPPED_WARN_MESSAGE", 'An action event was dropped because either the `onPress` method arguments' + ' were undefined or they were missing the target information.');
|
|
107
|
+
|
|
99
108
|
let RumActionType;
|
|
100
109
|
exports.RumActionType = RumActionType;
|
|
101
110
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["DdEventsInterceptor.tsx"],"names":["UNKNOWN_TARGET_NAME","DEBOUNCE_EVENT_THRESHOLD_IN_MS","HANDLE_EVENT_APP_EXECUTION_TIME_IN_MS","DD_ACTION_NAME_PROP","DdEventsInterceptor","Number","MIN_VALUE","interceptOnPress","args","length","_targetInst","currentTime","Date","now","timestampDifference","Math","abs","debouncingStartedTimestamp","targetNode","handleTargetEvent","resolvedTargetName","resolveTargetName","DdRum","addAction","RumActionType","TAP","valueOf","closestActionLabel","findClosestActionLabel","accessibilityLabel","memoizedProps","elementTypeName","resolveElementTypeName","elementType","name","currentNode","props","return"],"mappings":";;;;;;;
|
|
1
|
+
{"version":3,"sources":["DdEventsInterceptor.tsx"],"names":["UNKNOWN_TARGET_NAME","DEBOUNCE_EVENT_THRESHOLD_IN_MS","HANDLE_EVENT_APP_EXECUTION_TIME_IN_MS","DD_ACTION_NAME_PROP","DdEventsInterceptor","Number","MIN_VALUE","interceptOnPress","args","length","_targetInst","currentTime","Date","now","timestampDifference","Math","abs","debouncingStartedTimestamp","targetNode","handleTargetEvent","InternalLog","log","ACTION_EVENT_DROPPED_WARN_MESSAGE","SdkVerbosity","WARN","resolvedTargetName","resolveTargetName","DdRum","addAction","RumActionType","TAP","valueOf","closestActionLabel","findClosestActionLabel","accessibilityLabel","memoizedProps","elementTypeName","resolveElementTypeName","elementType","name","currentNode","props","return"],"mappings":";;;;;;;AAMA;;AACA;;AACA;;;;AAIO,MAAMA,mBAAmB,GAAG,gBAA5B;;AACP,MAAMC,8BAA8B,GAAG,EAAvC;AACA,MAAMC,qCAAqC,GAAG,CAA9C;AACA,MAAMC,mBAAmB,GAAG,gBAA5B;;AAEO,MAAMC,mBAAN,CAAuD;AAAA;AAAA,wDAKrBC,MAAM,CAACC,SALc;AAAA;;AAO1DC,EAAAA,gBAAgB,CAAC,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nB,UAAU,CAACoB,WADS,CAAxB;AAGA,WAAOF,eAAe,IAAIpC,mBAA1B;AACH;;AAEOqC,EAAAA,sBAAsB,CAACC,WAAD,EAAkC;AAC5D,QAAIF,eAAe,GAAG,IAAtB;;AACA,QAAI,OAAOE,WAAP,KAAuB,QAA3B,EAAqC;AACjCF,MAAAA,eAAe,GAAGE,WAAlB;AACH,KAFD,MAEO,IAAIA,WAAW,IAAI,OAAOA,WAAW,CAACC,IAAnB,KAA4B,QAA/C,EAAyD;AAC5DH,MAAAA,eAAe,GAAGE,WAAW,CAACC,IAA9B;AACH;;AACD,WAAOH,eAAP;AACH;;AAEOH,EAAAA,sBAAsB,CAACf,UAAD,EAAiC;AAC3D,QAAIsB,WAAW,GAAGtB,UAAlB;;AACA,WAAOsB,WAAP,EAAoB;AAChB,YAAMC,KAAK,GAAGD,WAAW,CAACL,aAA1B;;AACA,UAAIM,KAAK,IAAIA,KAAK,CAACtC,mBAAD,CAAlB,EAAyC;AACrC,eAAOsC,KAAK,CAACtC,mBAAD,CAAZ;AACH;;AACDqC,MAAAA,WAAW,GAAGA,WAAW,CAACE,MAA1B;AACH;;AACD,WAAO,IAAP;AACH;;AAtEyD;AAyE9D;AACA;AACA;;;;;gBA3EatC,mB,uCAEL,8EACA,8D;;IAyEIyB,a;;;WAAAA,a;AAAAA,EAAAA,a;AAAAA,EAAAA,a;AAAAA,EAAAA,a;AAAAA,EAAAA,a;AAAAA,EAAAA,a;GAAAA,a,6BAAAA,a","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\nimport { InternalLog } from '../../InternalLog';\nimport { SdkVerbosity } from '../../SdkVerbosity';\nimport { DdRum } from '../../foundation';\n\nimport type EventsInterceptor from './EventsInterceptor';\n\nexport const UNKNOWN_TARGET_NAME = 'unknown_target';\nconst DEBOUNCE_EVENT_THRESHOLD_IN_MS = 10;\nconst HANDLE_EVENT_APP_EXECUTION_TIME_IN_MS = 1;\nconst DD_ACTION_NAME_PROP = 'dd-action-name';\n\nexport class DdEventsInterceptor implements EventsInterceptor {\n static ACTION_EVENT_DROPPED_WARN_MESSAGE =\n 'An action event was dropped because either the `onPress` method arguments' +\n ' were undefined or they were missing the target information.';\n\n private debouncingStartedTimestamp = Number.MIN_VALUE;\n\n interceptOnPress(...args: any[]): void {\n if (args.length > 0 && args[0] && args[0]._targetInst) {\n const currentTime = Date.now();\n const timestampDifference = Math.abs(\n Date.now() - this.debouncingStartedTimestamp\n );\n if (timestampDifference > DEBOUNCE_EVENT_THRESHOLD_IN_MS) {\n const targetNode = args[0]._targetInst;\n this.handleTargetEvent(targetNode);\n // we add an approximated 1 millisecond for the execution time of the `handleTargetEvent` function\n this.debouncingStartedTimestamp =\n currentTime + HANDLE_EVENT_APP_EXECUTION_TIME_IN_MS;\n }\n } else {\n InternalLog.log(\n DdEventsInterceptor.ACTION_EVENT_DROPPED_WARN_MESSAGE,\n SdkVerbosity.WARN\n );\n }\n }\n\n private handleTargetEvent(targetNode: any | null) {\n if (targetNode) {\n const resolvedTargetName = this.resolveTargetName(targetNode);\n DdRum.addAction(RumActionType.TAP.valueOf(), resolvedTargetName);\n }\n }\n\n private resolveTargetName(targetNode: any): string {\n const closestActionLabel = this.findClosestActionLabel(targetNode);\n if (closestActionLabel != null) {\n return closestActionLabel;\n }\n const accessibilityLabel = targetNode.memoizedProps?.accessibilityLabel;\n if (accessibilityLabel != null) {\n return accessibilityLabel;\n }\n const elementTypeName = this.resolveElementTypeName(\n targetNode.elementType\n );\n return elementTypeName || UNKNOWN_TARGET_NAME;\n }\n\n private resolveElementTypeName(elementType: any): string | null {\n let elementTypeName = null;\n if (typeof elementType === 'string') {\n elementTypeName = elementType;\n } else if (elementType && typeof elementType.name === 'string') {\n elementTypeName = elementType.name;\n }\n return elementTypeName;\n }\n\n private findClosestActionLabel(targetNode: any): string | null {\n let currentNode = targetNode;\n while (currentNode) {\n const props = currentNode.memoizedProps;\n if (props && props[DD_ACTION_NAME_PROP]) {\n return props[DD_ACTION_NAME_PROP];\n }\n currentNode = currentNode.return;\n }\n return null;\n }\n}\n\n/**\n * Describe the type of a RUM Action.\n */\nexport enum RumActionType {\n /** User tapped on a widget. */\n TAP = 'TAP',\n /** User scrolled a view. */\n SCROLL = 'SCROLL',\n /** User swiped on a view. */\n SWIPE = 'SWIPE',\n /** User clicked on a widget (not used on Mobile). */\n CLICK = 'CLICK',\n /** A custom action. */\n CUSTOM = 'CUSTOM'\n}\n"]}
|
|
@@ -5,20 +5,25 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
5
5
|
});
|
|
6
6
|
exports.DdRumErrorTracking = void 0;
|
|
7
7
|
|
|
8
|
+
var _InternalLog = require("../../InternalLog");
|
|
9
|
+
|
|
10
|
+
var _SdkVerbosity = require("../../SdkVerbosity");
|
|
11
|
+
|
|
8
12
|
var _foundation = require("../../foundation");
|
|
9
13
|
|
|
10
14
|
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
11
15
|
|
|
12
|
-
const
|
|
13
|
-
const
|
|
14
|
-
const
|
|
16
|
+
const EMPTY_MESSAGE = 'Unknown Error';
|
|
17
|
+
const EMPTY_STACK_TRACE = '';
|
|
18
|
+
const TYPE_SOURCE = 'SOURCE';
|
|
19
|
+
const TYPE_CONSOLE = 'CONSOLE';
|
|
15
20
|
/**
|
|
16
|
-
* Provides RUM auto-instrumentation feature to track errors as RUM events.
|
|
17
|
-
*/
|
|
21
|
+
* Provides RUM auto-instrumentation feature to track errors as RUM events.
|
|
22
|
+
*/
|
|
18
23
|
|
|
19
24
|
class DdRumErrorTracking {
|
|
20
|
-
// eslint-disable-next-line
|
|
21
|
-
// eslint-disable-next-line
|
|
25
|
+
// eslint-disable-next-line
|
|
26
|
+
// eslint-disable-next-line
|
|
22
27
|
|
|
23
28
|
/**
|
|
24
29
|
* Starts tracking errors and sends a RUM Error event every time an error is detected.
|
|
@@ -26,7 +31,8 @@ class DdRumErrorTracking {
|
|
|
26
31
|
static startTracking() {
|
|
27
32
|
// extra safety to avoid wrapping the Error handler twice
|
|
28
33
|
if (DdRumErrorTracking.isTracking) {
|
|
29
|
-
|
|
34
|
+
_InternalLog.InternalLog.log('Datadog SDK is already tracking errors', _SdkVerbosity.SdkVerbosity.WARN);
|
|
35
|
+
|
|
30
36
|
return;
|
|
31
37
|
}
|
|
32
38
|
|
|
@@ -36,14 +42,21 @@ class DdRumErrorTracking {
|
|
|
36
42
|
ErrorUtils.setGlobalHandler(DdRumErrorTracking.onGlobalError);
|
|
37
43
|
console.error = DdRumErrorTracking.onConsoleError;
|
|
38
44
|
DdRumErrorTracking.isTracking = true;
|
|
45
|
+
|
|
46
|
+
_InternalLog.InternalLog.log('Datadog SDK is tracking errors', _SdkVerbosity.SdkVerbosity.INFO);
|
|
47
|
+
} else {
|
|
48
|
+
_InternalLog.InternalLog.log('Datadog SDK cannot track errors, ErrorUtils is not defined', _SdkVerbosity.SdkVerbosity.ERROR);
|
|
39
49
|
}
|
|
40
50
|
} // eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types
|
|
41
51
|
|
|
42
52
|
|
|
43
53
|
static onGlobalError(error, isFatal) {
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
54
|
+
const message = DdRumErrorTracking.getErrorMessage(error);
|
|
55
|
+
const stacktrace = DdRumErrorTracking.getErrorStackTrace(error);
|
|
56
|
+
|
|
57
|
+
_foundation.DdRum.addError(message, TYPE_SOURCE, stacktrace, {
|
|
58
|
+
'_dd.error.is_crash': isFatal,
|
|
59
|
+
'_dd.error.raw': error
|
|
47
60
|
}).then(() => {
|
|
48
61
|
DdRumErrorTracking.isInDefaultErrorHandler = true;
|
|
49
62
|
|
|
@@ -66,7 +79,7 @@ class DdRumErrorTracking {
|
|
|
66
79
|
const param = params[i];
|
|
67
80
|
const paramStack = DdRumErrorTracking.getErrorStackTrace(param);
|
|
68
81
|
|
|
69
|
-
if (paramStack
|
|
82
|
+
if (paramStack !== EMPTY_STACK_TRACE) {
|
|
70
83
|
stack = paramStack;
|
|
71
84
|
break;
|
|
72
85
|
}
|
|
@@ -75,10 +88,8 @@ class DdRumErrorTracking {
|
|
|
75
88
|
const message = params.map(param => {
|
|
76
89
|
if (typeof param === 'string') {
|
|
77
90
|
return param;
|
|
78
|
-
} else if (param instanceof Error) {
|
|
79
|
-
return String(param);
|
|
80
91
|
} else {
|
|
81
|
-
return
|
|
92
|
+
return DdRumErrorTracking.getErrorMessage(param);
|
|
82
93
|
}
|
|
83
94
|
}).join(' ');
|
|
84
95
|
|
|
@@ -87,17 +98,37 @@ class DdRumErrorTracking {
|
|
|
87
98
|
});
|
|
88
99
|
}
|
|
89
100
|
|
|
101
|
+
static getErrorMessage(error) {
|
|
102
|
+
let message = EMPTY_MESSAGE;
|
|
103
|
+
|
|
104
|
+
if (error === undefined || error === null) {
|
|
105
|
+
message = EMPTY_MESSAGE;
|
|
106
|
+
} else if (typeof error === 'object' && 'message' in error) {
|
|
107
|
+
message = String(error.message);
|
|
108
|
+
} else {
|
|
109
|
+
message = String(error);
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
return message;
|
|
113
|
+
}
|
|
114
|
+
|
|
90
115
|
static getErrorStackTrace(error) {
|
|
91
116
|
let stack = EMPTY_STACK_TRACE;
|
|
92
117
|
|
|
93
|
-
if (error
|
|
118
|
+
if (error === undefined || error === null) {
|
|
94
119
|
stack = EMPTY_STACK_TRACE;
|
|
95
120
|
} else if (typeof error === 'string') {
|
|
96
121
|
stack = EMPTY_STACK_TRACE;
|
|
97
|
-
} else if ('
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
122
|
+
} else if (typeof error === 'object') {
|
|
123
|
+
if ('componentStack' in error) {
|
|
124
|
+
stack = String(error.componentStack);
|
|
125
|
+
} else if ('stacktrace' in error) {
|
|
126
|
+
stack = String(error.stacktrace);
|
|
127
|
+
} else if ('stack' in error) {
|
|
128
|
+
stack = String(error.stack);
|
|
129
|
+
} else if ('sourceURL' in error && 'line' in error && 'column' in error) {
|
|
130
|
+
stack = `at ${error.sourceURL}:${error.line}:${error.column}`;
|
|
131
|
+
}
|
|
101
132
|
}
|
|
102
133
|
|
|
103
134
|
return stack;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["DdRumErrorTracking.tsx"],"names":["EMPTY_STACK_TRACE","TYPE_SOURCE","TYPE_CONSOLE","DdRumErrorTracking","startTracking","isTracking","
|
|
1
|
+
{"version":3,"sources":["DdRumErrorTracking.tsx"],"names":["EMPTY_MESSAGE","EMPTY_STACK_TRACE","TYPE_SOURCE","TYPE_CONSOLE","DdRumErrorTracking","startTracking","isTracking","InternalLog","log","SdkVerbosity","WARN","ErrorUtils","defaultErrorHandler","getGlobalHandler","defaultConsoleError","console","error","setGlobalHandler","onGlobalError","onConsoleError","INFO","ERROR","isFatal","message","getErrorMessage","stacktrace","getErrorStackTrace","DdRum","addError","then","isInDefaultErrorHandler","params","stack","i","length","param","paramStack","map","join","apply","undefined","String","componentStack","sourceURL","line","column","_error","_isFatal","_params"],"mappings":";;;;;;;AAQA;;AACA;;AACA;;;;AAEA,MAAMA,aAAa,GAAG,eAAtB;AACA,MAAMC,iBAAiB,GAAG,EAA1B;AACA,MAAMC,WAAW,GAAG,QAApB;AACA,MAAMC,YAAY,GAAG,SAArB;AAEA;AACA;AACA;;AACO,MAAMC,kBAAN,CAAyB;AAK5B;AAGA;;AAGA;AACJ;AACA;AACwB,SAAbC,aAAa,GAAS;AACzB;AACA,QAAID,kBAAkB,CAACE,UAAvB,EAAmC;AAC/BC,+BAAYC,GAAZ,CACI,wCADJ,EAEIC,2BAAaC,IAFjB;;AAIA;AACH;;AAED,QAAIC,UAAJ,EAAgB;AACZP,MAAAA,kBAAkB,CAACQ,mBAAnB,GAAyCD,UAAU,CAACE,gBAAX,EAA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SAAV,IAAuBxB,KAAK,KAAK,IAArC,EAA2C;AACvCgB,MAAAA,KAAK,GAAG/B,iBAAR;AACH,KAFD,MAEO,IAAI,OAAOe,KAAP,KAAiB,QAArB,EAA+B;AAClCgB,MAAAA,KAAK,GAAG/B,iBAAR;AACH,KAFM,MAEA,IAAI,OAAOe,KAAP,KAAiB,QAArB,EAA+B;AAClC,UAAI,oBAAoBA,KAAxB,EAA+B;AAC3BgB,QAAAA,KAAK,GAAGS,MAAM,CAACzB,KAAK,CAAC0B,cAAP,CAAd;AACH,OAFD,MAEO,IAAI,gBAAgB1B,KAApB,EAA2B;AAC9BgB,QAAAA,KAAK,GAAGS,MAAM,CAACzB,KAAK,CAACS,UAAP,CAAd;AACH,OAFM,MAEA,IAAI,WAAWT,KAAf,EAAsB;AACzBgB,QAAAA,KAAK,GAAGS,MAAM,CAACzB,KAAK,CAACgB,KAAP,CAAd;AACH,OAFM,MAEA,IACH,eAAehB,KAAf,IACA,UAAUA,KADV,IAEA,YAAYA,KAHT,EAIL;AACEgB,QAAAA,KAAK,GAAI,MAAKhB,KAAK,CAAC2B,SAAU,IAAG3B,KAAK,CAAC4B,IAAK,IAAG5B,KAAK,CAAC6B,MAAO,EAA5D;AACH;AACJ;;AAED,WAAOb,KAAP;AACH;;AAhI2B;;;;gBAAnB5B,kB,gBACmB,K;;gBADnBA,kB,6BAGgC,K;;gBAHhCA,kB,yBAMkD,CAAC0C,MAAD,EAAcC,QAAd,KAAqC,CAAG,C;;gBAN1F3C,kB,yBAS4B,CAAC,GAAG4C,OAAJ,KAA2B,CAAG,C","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\nimport type { ErrorHandlerCallback } from 'react-native';\n\nimport { InternalLog } from '../../InternalLog';\nimport { SdkVerbosity } from '../../SdkVerbosity';\nimport { DdRum } from '../../foundation';\n\nconst EMPTY_MESSAGE = 'Unknown Error';\nconst EMPTY_STACK_TRACE = '';\nconst TYPE_SOURCE = 'SOURCE';\nconst TYPE_CONSOLE = 'CONSOLE';\n\n/**\n * Provides RUM auto-instrumentation feature to track errors as RUM events.\n */\nexport class DdRumErrorTracking {\n private static isTracking = false;\n\n private static isInDefaultErrorHandler = false;\n\n // eslint-disable-next-line\n private static defaultErrorHandler: ErrorHandlerCallback = (_error: any, _isFatal?: boolean) => { }\n\n // eslint-disable-next-line\n private static defaultConsoleError = (..._params: unknown[]) => { }\n\n /**\n * Starts tracking errors and sends a RUM Error event every time an error is detected.\n */\n static startTracking(): void {\n // extra safety to avoid wrapping the Error handler twice\n if (DdRumErrorTracking.isTracking) {\n InternalLog.log(\n 'Datadog SDK is already tracking errors',\n SdkVerbosity.WARN\n );\n return;\n }\n\n if (ErrorUtils) {\n DdRumErrorTracking.defaultErrorHandler = ErrorUtils.getGlobalHandler();\n DdRumErrorTracking.defaultConsoleError = console.error;\n\n ErrorUtils.setGlobalHandler(DdRumErrorTracking.onGlobalError);\n console.error = DdRumErrorTracking.onConsoleError;\n\n DdRumErrorTracking.isTracking = true;\n InternalLog.log(\n 'Datadog SDK is tracking errors',\n SdkVerbosity.INFO\n );\n } else {\n InternalLog.log(\n 'Datadog SDK cannot track errors, ErrorUtils is not defined',\n SdkVerbosity.ERROR\n );\n }\n }\n\n // eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types\n static onGlobalError(error: any, isFatal?: boolean): void {\n const message = DdRumErrorTracking.getErrorMessage(error);\n const stacktrace = DdRumErrorTracking.getErrorStackTrace(error);\n DdRum.addError(message, TYPE_SOURCE, stacktrace, {\n '_dd.error.is_crash': isFatal,\n '_dd.error.raw': error\n }).then(() => {\n DdRumErrorTracking.isInDefaultErrorHandler = true;\n try {\n DdRumErrorTracking.defaultErrorHandler(error, isFatal);\n } finally {\n DdRumErrorTracking.isInDefaultErrorHandler = false;\n }\n });\n }\n\n static onConsoleError(...params: unknown[]): void {\n if (DdRumErrorTracking.isInDefaultErrorHandler) {\n return;\n }\n\n let stack: string = EMPTY_STACK_TRACE;\n for (let i = 0; i < params.length; i += 1) {\n const param = params[i];\n const paramStack = DdRumErrorTracking.getErrorStackTrace(param);\n if (paramStack !== EMPTY_STACK_TRACE) {\n stack = paramStack;\n break;\n }\n }\n\n const message = params\n .map(param => {\n if (typeof param === 'string') {\n return param;\n } else {\n return DdRumErrorTracking.getErrorMessage(param);\n }\n })\n .join(' ');\n\n DdRum.addError(message, TYPE_CONSOLE, stack).then(() => {\n DdRumErrorTracking.defaultConsoleError.apply(console, params);\n });\n }\n\n private static getErrorMessage(error: any | undefined): string {\n let message = EMPTY_MESSAGE;\n if (error === undefined || error === null) {\n message = EMPTY_MESSAGE;\n } else if (typeof error === 'object' && 'message' in error) {\n message = String(error.message);\n } else {\n message = String(error);\n }\n\n return message;\n }\n\n private static getErrorStackTrace(error: any | undefined): string {\n let stack = EMPTY_STACK_TRACE;\n\n if (error === undefined || error === null) {\n stack = EMPTY_STACK_TRACE;\n } else if (typeof error === 'string') {\n stack = EMPTY_STACK_TRACE;\n } else if (typeof error === 'object') {\n if ('componentStack' in error) {\n stack = String(error.componentStack);\n } else if ('stacktrace' in error) {\n stack = String(error.stacktrace);\n } else if ('stack' in error) {\n stack = String(error.stack);\n } else if (\n 'sourceURL' in error &&\n 'line' in error &&\n 'column' in error\n ) {\n stack = `at ${error.sourceURL}:${error.line}:${error.column}`;\n }\n }\n\n return stack;\n }\n}\n"]}
|