@datadog/mobile-react-native 1.0.0-rc4 → 1.0.0-rc7
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 +1 -1
- package/android/gradle.properties +4 -4
- package/lib/commonjs/DdSdkReactNative.js +38 -23
- 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 +56 -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 +51 -11
- package/lib/commonjs/foundation.js.map +1 -1
- package/lib/commonjs/index.js +34 -18
- package/lib/commonjs/index.js.map +1 -1
- 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 +34 -23
- package/lib/commonjs/rum/instrumentation/DdRumErrorTracking.js.map +1 -1
- package/lib/commonjs/rum/instrumentation/DdRumResourceTracking.js +62 -36
- 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 +1 -1
- package/lib/commonjs/version.js.map +1 -1
- package/lib/module/DdSdkReactNative.js +31 -23
- 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 +52 -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 +31 -11
- package/lib/module/foundation.js.map +1 -1
- package/lib/module/index.js +4 -2
- package/lib/module/index.js.map +1 -1
- 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 +30 -23
- package/lib/module/rum/instrumentation/DdRumErrorTracking.js.map +1 -1
- package/lib/module/rum/instrumentation/DdRumResourceTracking.js +57 -34
- 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 +1 -1
- package/lib/module/version.js.map +1 -1
- package/lib/typescript/DdSdkReactNative.d.ts +6 -6
- package/lib/typescript/DdSdkReactNativeConfiguration.d.ts +15 -4
- package/lib/typescript/InternalLog.d.ts +11 -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 +4 -2
- package/lib/typescript/rum/instrumentation/DdEventsInterceptor.d.ts +1 -0
- package/lib/typescript/rum/instrumentation/DdRumErrorTracking.d.ts +2 -2
- package/lib/typescript/rum/instrumentation/DdRumResourceTracking.d.ts +10 -9
- 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/version.d.ts +1 -1
- package/package.json +6 -3
- package/src/DdSdkReactNative.tsx +112 -62
- package/src/DdSdkReactNativeConfiguration.tsx +22 -14
- package/src/InternalLog.tsx +50 -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 +40 -33
- package/src/__tests__/DdSdkReactNative.test.tsx +697 -513
- 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 +179 -106
- package/src/__tests__/rum/instrumentation/DdRumResourceTracking.test.tsx +714 -644
- 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 +80 -61
- package/src/index.tsx +15 -3
- package/src/rum/instrumentation/DdEventsInterceptor.tsx +51 -35
- package/src/rum/instrumentation/DdRumErrorTracking.tsx +61 -49
- package/src/rum/instrumentation/DdRumResourceTracking.tsx +307 -233
- 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 -158
- package/src/version.ts +1 -1
- 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
package/lib/module/foundation.js
CHANGED
|
@@ -7,6 +7,10 @@ function _defineProperty(obj, key, value) { if (key in obj) { Object.definePrope
|
|
|
7
7
|
*/
|
|
8
8
|
import { NativeModules } from 'react-native';
|
|
9
9
|
import { DdSdkConfiguration } from './types';
|
|
10
|
+
import { InternalLog } from "./InternalLog";
|
|
11
|
+
import { SdkVerbosity } from "./SdkVerbosity";
|
|
12
|
+
import { TimeProvider } from "./TimeProvider";
|
|
13
|
+
const timeProvider = new TimeProvider();
|
|
10
14
|
|
|
11
15
|
class DdLogsWrapper {
|
|
12
16
|
constructor() {
|
|
@@ -14,18 +18,22 @@ class DdLogsWrapper {
|
|
|
14
18
|
}
|
|
15
19
|
|
|
16
20
|
debug(message, context = {}) {
|
|
21
|
+
InternalLog.log("Tracking debug log “" + message + "”", SdkVerbosity.DEBUG);
|
|
17
22
|
return this.nativeLogs.debug(message, context);
|
|
18
23
|
}
|
|
19
24
|
|
|
20
25
|
info(message, context = {}) {
|
|
26
|
+
InternalLog.log("Tracking info log “" + message + "”", SdkVerbosity.DEBUG);
|
|
21
27
|
return this.nativeLogs.info(message, context);
|
|
22
28
|
}
|
|
23
29
|
|
|
24
30
|
warn(message, context = {}) {
|
|
31
|
+
InternalLog.log("Tracking warn log “" + message + "”", SdkVerbosity.DEBUG);
|
|
25
32
|
return this.nativeLogs.warn(message, context);
|
|
26
33
|
}
|
|
27
34
|
|
|
28
35
|
error(message, context = {}) {
|
|
36
|
+
InternalLog.log("Tracking error log “" + message + "”", SdkVerbosity.DEBUG);
|
|
29
37
|
return this.nativeLogs.error(message, context);
|
|
30
38
|
}
|
|
31
39
|
|
|
@@ -36,11 +44,14 @@ class DdTraceWrapper {
|
|
|
36
44
|
_defineProperty(this, "nativeTrace", NativeModules.DdTrace);
|
|
37
45
|
}
|
|
38
46
|
|
|
39
|
-
startSpan(operation, context = {}, timestampMs =
|
|
40
|
-
|
|
47
|
+
startSpan(operation, context = {}, timestampMs = timeProvider.now()) {
|
|
48
|
+
let spanId = this.nativeTrace.startSpan(operation, context, timestampMs);
|
|
49
|
+
InternalLog.log("Starting span “" + operation + "” #" + spanId, SdkVerbosity.DEBUG);
|
|
50
|
+
return spanId;
|
|
41
51
|
}
|
|
42
52
|
|
|
43
|
-
finishSpan(spanId, context = {}, timestampMs =
|
|
53
|
+
finishSpan(spanId, context = {}, timestampMs = timeProvider.now()) {
|
|
54
|
+
InternalLog.log("Finishing span #" + spanId, SdkVerbosity.DEBUG);
|
|
44
55
|
return this.nativeTrace.finishSpan(spanId, context, timestampMs);
|
|
45
56
|
}
|
|
46
57
|
|
|
@@ -51,41 +62,50 @@ class DdRumWrapper {
|
|
|
51
62
|
_defineProperty(this, "nativeRum", NativeModules.DdRum);
|
|
52
63
|
}
|
|
53
64
|
|
|
54
|
-
startView(key, name, context = {}, timestampMs =
|
|
65
|
+
startView(key, name, context = {}, timestampMs = timeProvider.now()) {
|
|
66
|
+
InternalLog.log("Starting RUM View “" + name + "” #" + key, SdkVerbosity.DEBUG);
|
|
55
67
|
return this.nativeRum.startView(key, name, context, timestampMs);
|
|
56
68
|
}
|
|
57
69
|
|
|
58
|
-
stopView(key, context = {}, timestampMs =
|
|
70
|
+
stopView(key, context = {}, timestampMs = timeProvider.now()) {
|
|
71
|
+
InternalLog.log("Stopping RUM View #" + key, SdkVerbosity.DEBUG);
|
|
59
72
|
return this.nativeRum.stopView(key, context, timestampMs);
|
|
60
73
|
}
|
|
61
74
|
|
|
62
|
-
startAction(type, name, context = {}, timestampMs =
|
|
75
|
+
startAction(type, name, context = {}, timestampMs = timeProvider.now()) {
|
|
76
|
+
InternalLog.log("Starting RUM Action “" + name + "” (" + type + ")", SdkVerbosity.DEBUG);
|
|
63
77
|
return this.nativeRum.startAction(type, name, context, timestampMs);
|
|
64
78
|
}
|
|
65
79
|
|
|
66
|
-
stopAction(context = {}, timestampMs =
|
|
80
|
+
stopAction(context = {}, timestampMs = timeProvider.now()) {
|
|
81
|
+
InternalLog.log("Stopping current RUM Action", SdkVerbosity.DEBUG);
|
|
67
82
|
return this.nativeRum.stopAction(context, timestampMs);
|
|
68
83
|
}
|
|
69
84
|
|
|
70
|
-
addAction(type, name, context = {}, timestampMs =
|
|
85
|
+
addAction(type, name, context = {}, timestampMs = timeProvider.now()) {
|
|
86
|
+
InternalLog.log("Adding RUM Action “" + name + "” (" + type + ")", SdkVerbosity.DEBUG);
|
|
71
87
|
return this.nativeRum.addAction(type, name, context, timestampMs);
|
|
72
88
|
}
|
|
73
89
|
|
|
74
|
-
startResource(key, method, url, context = {}, timestampMs =
|
|
90
|
+
startResource(key, method, url, context = {}, timestampMs = timeProvider.now()) {
|
|
91
|
+
InternalLog.log("Starting RUM Resource #" + key + " " + method + ": " + url, SdkVerbosity.DEBUG);
|
|
75
92
|
return this.nativeRum.startResource(key, method, url, context, timestampMs);
|
|
76
93
|
}
|
|
77
94
|
|
|
78
|
-
stopResource(key, statusCode, kind, size = -1, context = {}, timestampMs =
|
|
95
|
+
stopResource(key, statusCode, kind, size = -1, context = {}, timestampMs = timeProvider.now()) {
|
|
96
|
+
InternalLog.log("Stopping RUM Resource #" + key + " status:" + statusCode, SdkVerbosity.DEBUG);
|
|
79
97
|
return this.nativeRum.stopResource(key, statusCode, kind, size, context, timestampMs);
|
|
80
98
|
}
|
|
81
99
|
|
|
82
|
-
addError(message, source, stacktrace, context = {}, timestampMs =
|
|
100
|
+
addError(message, source, stacktrace, context = {}, timestampMs = timeProvider.now()) {
|
|
101
|
+
InternalLog.log("Adding RUM Error “" + message + "”", SdkVerbosity.DEBUG);
|
|
83
102
|
let updatedContext = context;
|
|
84
103
|
updatedContext["_dd.error.source_type"] = "react-native";
|
|
85
104
|
return this.nativeRum.addError(message, source, stacktrace, updatedContext, timestampMs);
|
|
86
105
|
}
|
|
87
106
|
|
|
88
107
|
addTiming(name) {
|
|
108
|
+
InternalLog.log("Adding timing “" + name + "” to RUM View", SdkVerbosity.DEBUG);
|
|
89
109
|
return this.nativeRum.addTiming(name);
|
|
90
110
|
}
|
|
91
111
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["foundation.tsx"],"names":["NativeModules","DdSdkConfiguration","DdLogsWrapper","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","size","addError","source","stacktrace","updatedContext","addTiming","DdSdk"],"mappings":";;AAAA;AACA;AACA;AACA;AACA;AAEA,SAASA,aAAT,QAA8B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7B;AACA,MAAMW,KAAgB,GAAG,IAAID,YAAJ,EAAzB;AAEA,SAASpB,kBAAT,EAA6B2C,KAA7B,EAAoCzC,MAApC,EAA4CS,OAA5C,EAAqDU,KAArD","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\n info(message: string, context: object = {}): Promise<void> {\n return this.nativeLogs.info(message, context);\n }\n\n warn(message: string, context: object = {}): Promise<void> {\n return this.nativeLogs.warn(message, context);\n }\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 return this.nativeTrace.startSpan(operation, context, timestampMs);\n }\n\n finishSpan(spanId: string, context: object = {}, timestampMs: number = Date.now()): Promise<void> {\n return this.nativeTrace.finishSpan(spanId, context, timestampMs);\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 return this.nativeRum.startView(key, name, context, timestampMs);\n }\n\n stopView(key: string, context: object = {}, timestampMs: number = Date.now()): Promise<void> {\n return this.nativeRum.stopView(key, context, timestampMs);\n }\n\n startAction(type: string, name: string, context: object = {}, timestampMs: number = Date.now()): Promise<void> {\n return this.nativeRum.startAction(type, name, context, timestampMs);\n }\n\n stopAction(context: object = {}, timestampMs: number = Date.now()): Promise<void> {\n return this.nativeRum.stopAction(context, timestampMs);\n }\n\n addAction(type: string, name: string, context: object = {}, timestampMs: number = Date.now()): Promise<void> {\n return this.nativeRum.addAction(type, name, context, timestampMs);\n }\n\n startResource(key: string, method: string, url: string, context: object = {}, timestampMs: number = Date.now()): Promise<void> {\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 = Date.now()): Promise<void> {\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 = Date.now()): Promise<void> {\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 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":["NativeModules","DdSdkConfiguration","InternalLog","SdkVerbosity","TimeProvider","timeProvider","DdLogsWrapper","DdLogs","debug","message","context","log","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":";;AAAA;AACA;AACA;AACA;AACA;AAEA,SAASA,aAAT,QAA8B,cAA9B;AACA,SAASC,kBAAT,QAAkF,SAAlF;AACA,SAAQC,WAAR,QAA0B,eAA1B;AACA,SAAQC,YAAR,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AO,KAAKhB,SAAL,CAAea,QAAf,CAAwBnC,OAAxB,EAAiCoC,MAAjC,EAAyCC,UAAzC,EAAqDC,cAArD,EAAqE1B,WAArE,CAAP;AACH;;AAED2B,EAAAA,SAAS,CAAClB,IAAD,EAA8B;AACnC5B,IAAAA,WAAW,CAACS,GAAZ,CAAgB,oBAAoBmB,IAApB,GAA2B,eAA3C,EAA4D3B,YAAY,CAACS,KAAzE;AACA,WAAO,KAAKmB,SAAL,CAAeiB,SAAf,CAAyBlB,IAAzB,CAAP;AACH;;AAjDmC;;AAoDxC,MAAMmB,KAAgB,GAAGjD,aAAa,CAACiD,KAAvC;AACA,MAAM1C,MAAkB,GAAG,IAAID,aAAJ,EAA3B;AACA,MAAMY,OAAoB,GAAG,IAAID,cAAJ,EAA7B;AACA,MAAMU,KAAgB,GAAG,IAAID,YAAJ,EAAzB;AAEA,SAASzB,kBAAT,EAA6BgD,KAA7B,EAAoC1C,MAApC,EAA4CW,OAA5C,EAAqDS,KAArD","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/module/index.js
CHANGED
|
@@ -3,10 +3,12 @@
|
|
|
3
3
|
* This product includes software developed at Datadog (https://www.datadoghq.com/).
|
|
4
4
|
* Copyright 2016-Present Datadog, Inc.
|
|
5
5
|
*/
|
|
6
|
-
import { DdLogs, DdTrace, DdRum } from './foundation';
|
|
7
6
|
import { DdSdkReactNativeConfiguration } from './DdSdkReactNativeConfiguration';
|
|
8
7
|
import { DdSdkReactNative } from './DdSdkReactNative';
|
|
8
|
+
import { InternalLog } from './InternalLog';
|
|
9
9
|
import { ProxyConfiguration, ProxyType } from './ProxyConfiguration';
|
|
10
|
+
import { SdkVerbosity } from './SdkVerbosity';
|
|
10
11
|
import { TrackingConsent } from './TrackingConsent';
|
|
11
|
-
|
|
12
|
+
import { DdLogs, DdTrace, DdRum } from './foundation';
|
|
13
|
+
export { DdLogs, DdTrace, DdRum, DdSdkReactNativeConfiguration, DdSdkReactNative, InternalLog, ProxyConfiguration, ProxyType, TrackingConsent, SdkVerbosity };
|
|
12
14
|
//# sourceMappingURL=index.js.map
|
package/lib/module/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["index.tsx"],"names":["
|
|
1
|
+
{"version":3,"sources":["index.tsx"],"names":["DdSdkReactNativeConfiguration","DdSdkReactNative","InternalLog","ProxyConfiguration","ProxyType","SdkVerbosity","TrackingConsent","DdLogs","DdTrace","DdRum"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AAEA,SAASA,6BAAT,QAA8C,iCAA9C;AACA,SAASC,gBAAT,QAAiC,oBAAjC;AACA,SAASC,WAAT,QAA4B,eAA5B;AACA,SAASC,kBAAT,EAA6BC,SAA7B,QAA8C,sBAA9C;AACA,SAASC,YAAT,QAA6B,gBAA7B;AACA,SAASC,eAAT,QAAgC,mBAAhC;AACA,SAASC,MAAT,EAAiBC,OAAjB,EAA0BC,KAA1B,QAAuC,cAAvC;AAEA,SACIF,MADJ,EAEIC,OAFJ,EAGIC,KAHJ,EAIIT,6BAJJ,EAKIC,gBALJ,EAMIC,WANJ,EAOIC,kBAPJ,EAQIC,SARJ,EASIE,eATJ,EAUID,YAVJ","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 { InternalLog } from './InternalLog';\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 InternalLog,\n ProxyConfiguration,\n ProxyType,\n TrackingConsent,\n SdkVerbosity\n};\n"]}
|
|
@@ -5,11 +5,13 @@ function _defineProperty(obj, key, value) { if (key in obj) { Object.definePrope
|
|
|
5
5
|
* This product includes software developed at Datadog (https://www.datadoghq.com/).
|
|
6
6
|
* Copyright 2016-Present Datadog, Inc.
|
|
7
7
|
*/
|
|
8
|
+
import { InternalLog } from '../../InternalLog';
|
|
9
|
+
import { SdkVerbosity } from '../../SdkVerbosity';
|
|
8
10
|
import { DdRum } from '../../foundation';
|
|
9
|
-
export const UNKNOWN_TARGET_NAME =
|
|
11
|
+
export const UNKNOWN_TARGET_NAME = 'unknown_target';
|
|
10
12
|
const DEBOUNCE_EVENT_THRESHOLD_IN_MS = 10;
|
|
11
13
|
const HANDLE_EVENT_APP_EXECUTION_TIME_IN_MS = 1;
|
|
12
|
-
const DD_ACTION_NAME_PROP =
|
|
14
|
+
const DD_ACTION_NAME_PROP = 'dd-action-name';
|
|
13
15
|
export class DdEventsInterceptor {
|
|
14
16
|
constructor() {
|
|
15
17
|
_defineProperty(this, "debouncingStartedTimestamp", Number.MIN_VALUE);
|
|
@@ -26,6 +28,8 @@ export class DdEventsInterceptor {
|
|
|
26
28
|
|
|
27
29
|
this.debouncingStartedTimestamp = currentTime + HANDLE_EVENT_APP_EXECUTION_TIME_IN_MS;
|
|
28
30
|
}
|
|
31
|
+
} else {
|
|
32
|
+
InternalLog.log(DdEventsInterceptor.ACTION_EVENT_DROPPED_WARN_MESSAGE, SdkVerbosity.WARN);
|
|
29
33
|
}
|
|
30
34
|
}
|
|
31
35
|
|
|
@@ -52,15 +56,15 @@ export class DdEventsInterceptor {
|
|
|
52
56
|
}
|
|
53
57
|
|
|
54
58
|
const elementTypeName = this.resolveElementTypeName(targetNode.elementType);
|
|
55
|
-
return elementTypeName
|
|
59
|
+
return elementTypeName || UNKNOWN_TARGET_NAME;
|
|
56
60
|
}
|
|
57
61
|
|
|
58
62
|
resolveElementTypeName(elementType) {
|
|
59
63
|
let elementTypeName = null;
|
|
60
64
|
|
|
61
|
-
if (typeof elementType ===
|
|
65
|
+
if (typeof elementType === 'string') {
|
|
62
66
|
elementTypeName = elementType;
|
|
63
|
-
} else if (elementType && typeof elementType.name ===
|
|
67
|
+
} else if (elementType && typeof elementType.name === 'string') {
|
|
64
68
|
elementTypeName = elementType.name;
|
|
65
69
|
}
|
|
66
70
|
|
|
@@ -88,6 +92,8 @@ export class DdEventsInterceptor {
|
|
|
88
92
|
* Describe the type of a RUM Action.
|
|
89
93
|
*/
|
|
90
94
|
|
|
95
|
+
_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.');
|
|
96
|
+
|
|
91
97
|
export let RumActionType;
|
|
92
98
|
|
|
93
99
|
(function (RumActionType) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["DdEventsInterceptor.tsx"],"names":["DdRum","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","addAction","RumActionType","TAP","valueOf","closestActionLabel","findClosestActionLabel","accessibilityLabel","memoizedProps","elementTypeName","resolveElementTypeName","elementType","name","currentNode","props","return"],"mappings":";;AAAA;AACA;AACA;AACA;AACA;
|
|
1
|
+
{"version":3,"sources":["DdEventsInterceptor.tsx"],"names":["InternalLog","SdkVerbosity","DdRum","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","log","ACTION_EVENT_DROPPED_WARN_MESSAGE","WARN","resolvedTargetName","resolveTargetName","addAction","RumActionType","TAP","valueOf","closestActionLabel","findClosestActionLabel","accessibilityLabel","memoizedProps","elementTypeName","resolveElementTypeName","elementType","name","currentNode","props","return"],"mappings":";;AAAA;AACA;AACA;AACA;AACA;AAEA,SAASA,WAAT,QAA4B,mBAA5B;AACA,SAASC,YAAT,QAA6B,oBAA7B;AACA,SAASC,KAAT,QAAsB,kBAAtB;AAIA,OAAO,MAAMC,mBAAmB,GAAG,gBAA5B;AACP,MAAMC,8BAA8B,GAAG,EAAvC;AACA,MAAMC,qCAAqC,GAAG,CAA9C;AACA,MAAMC,mBAAmB,GAAG,gBAA5B;AAEA,OAAO,MAAMC,mBAAN,CAAuD;AAAA;AAAA,wDAKrBC,MAAM,CAACC,SALc;AAAA;;AAO1DC,EAAAA,gBAAgB,CAAC,GAAGC,IAAJ,EAAuB;AACnC,QAAIA,IAAI,CAACC,MAAL,GAAc,CAAd,IAAmBD,IAAI,CAAC,CAAD,CAAvB,IAA8BA,IAAI,CAAC,CAAD,CAAJ,CAAQE,WAA1C,EAAuD;AACnD,YAAMC,WAAW,GAAGC,IAAI,CAACC,GAAL,EAApB;AACA,YAAMC,mBAAmB,GAAGC,IAAI,CAACC,GAAL,CACxBJ,IAAI,CAACC,GAAL,KAAa,KAAKI,0BADM,CAA5B;;AAGA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ACC,IAAnB,KAA4B,QAA/C,EAAyD;AAC5DH,MAAAA,eAAe,GAAGE,WAAW,CAACC,IAA9B;AACH;;AACD,WAAOH,eAAP;AACH;;AAEOH,EAAAA,sBAAsB,CAACZ,UAAD,EAAiC;AAC3D,QAAImB,WAAW,GAAGnB,UAAlB;;AACA,WAAOmB,WAAP,EAAoB;AAChB,YAAMC,KAAK,GAAGD,WAAW,CAACL,aAA1B;;AACA,UAAIM,KAAK,IAAIA,KAAK,CAACnC,mBAAD,CAAlB,EAAyC;AACrC,eAAOmC,KAAK,CAACnC,mBAAD,CAAZ;AACH;;AACDkC,MAAAA,WAAW,GAAGA,WAAW,CAACE,MAA1B;AACH;;AACD,WAAO,IAAP;AACH;;AAtEyD;AAyE9D;AACA;AACA;;gBA3EanC,mB,uCAEL,8EACA,8D;;AAyER,WAAYsB,aAAZ;;WAAYA,a;AAAAA,EAAAA,a;AAAAA,EAAAA,a;AAAAA,EAAAA,a;AAAAA,EAAAA,a;AAAAA,EAAAA,a;GAAAA,a,KAAAA,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,18 +5,20 @@ function _defineProperty(obj, key, value) { if (key in obj) { Object.definePrope
|
|
|
5
5
|
* This product includes software developed at Datadog (https://www.datadoghq.com/).
|
|
6
6
|
* Copyright 2016-Present Datadog, Inc.
|
|
7
7
|
*/
|
|
8
|
+
import { InternalLog } from '../../InternalLog';
|
|
9
|
+
import { SdkVerbosity } from '../../SdkVerbosity';
|
|
8
10
|
import { DdRum } from '../../foundation';
|
|
9
|
-
const EMPTY_MESSAGE =
|
|
10
|
-
const EMPTY_STACK_TRACE =
|
|
11
|
-
const TYPE_SOURCE =
|
|
12
|
-
const TYPE_CONSOLE =
|
|
11
|
+
const EMPTY_MESSAGE = 'Unknown Error';
|
|
12
|
+
const EMPTY_STACK_TRACE = '';
|
|
13
|
+
const TYPE_SOURCE = 'SOURCE';
|
|
14
|
+
const TYPE_CONSOLE = 'CONSOLE';
|
|
13
15
|
/**
|
|
14
|
-
* Provides RUM auto-instrumentation feature to track errors as RUM events.
|
|
15
|
-
*/
|
|
16
|
+
* Provides RUM auto-instrumentation feature to track errors as RUM events.
|
|
17
|
+
*/
|
|
16
18
|
|
|
17
19
|
export class DdRumErrorTracking {
|
|
18
|
-
// eslint-disable-next-line
|
|
19
|
-
// eslint-disable-next-line
|
|
20
|
+
// eslint-disable-next-line
|
|
21
|
+
// eslint-disable-next-line
|
|
20
22
|
|
|
21
23
|
/**
|
|
22
24
|
* Starts tracking errors and sends a RUM Error event every time an error is detected.
|
|
@@ -24,7 +26,7 @@ export class DdRumErrorTracking {
|
|
|
24
26
|
static startTracking() {
|
|
25
27
|
// extra safety to avoid wrapping the Error handler twice
|
|
26
28
|
if (DdRumErrorTracking.isTracking) {
|
|
27
|
-
|
|
29
|
+
InternalLog.log('Datadog SDK is already tracking errors', SdkVerbosity.WARN);
|
|
28
30
|
return;
|
|
29
31
|
}
|
|
30
32
|
|
|
@@ -34,6 +36,9 @@ export class DdRumErrorTracking {
|
|
|
34
36
|
ErrorUtils.setGlobalHandler(DdRumErrorTracking.onGlobalError);
|
|
35
37
|
console.error = DdRumErrorTracking.onConsoleError;
|
|
36
38
|
DdRumErrorTracking.isTracking = true;
|
|
39
|
+
InternalLog.log('Datadog SDK is tracking errors', SdkVerbosity.INFO);
|
|
40
|
+
} else {
|
|
41
|
+
InternalLog.log('Datadog SDK cannot track errors, ErrorUtils is not defined', SdkVerbosity.ERROR);
|
|
37
42
|
}
|
|
38
43
|
} // eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types
|
|
39
44
|
|
|
@@ -42,8 +47,8 @@ export class DdRumErrorTracking {
|
|
|
42
47
|
const message = DdRumErrorTracking.getErrorMessage(error);
|
|
43
48
|
const stacktrace = DdRumErrorTracking.getErrorStackTrace(error);
|
|
44
49
|
DdRum.addError(message, TYPE_SOURCE, stacktrace, {
|
|
45
|
-
|
|
46
|
-
|
|
50
|
+
'_dd.error.is_crash': isFatal,
|
|
51
|
+
'_dd.error.raw': error
|
|
47
52
|
}).then(() => {
|
|
48
53
|
DdRumErrorTracking.isInDefaultErrorHandler = true;
|
|
49
54
|
|
|
@@ -66,7 +71,7 @@ export class DdRumErrorTracking {
|
|
|
66
71
|
const param = params[i];
|
|
67
72
|
const paramStack = DdRumErrorTracking.getErrorStackTrace(param);
|
|
68
73
|
|
|
69
|
-
if (paramStack
|
|
74
|
+
if (paramStack !== EMPTY_STACK_TRACE) {
|
|
70
75
|
stack = paramStack;
|
|
71
76
|
break;
|
|
72
77
|
}
|
|
@@ -87,9 +92,9 @@ export class DdRumErrorTracking {
|
|
|
87
92
|
static getErrorMessage(error) {
|
|
88
93
|
let message = EMPTY_MESSAGE;
|
|
89
94
|
|
|
90
|
-
if (error
|
|
95
|
+
if (error === undefined || error === null) {
|
|
91
96
|
message = EMPTY_MESSAGE;
|
|
92
|
-
} else if (
|
|
97
|
+
} else if (typeof error === 'object' && 'message' in error) {
|
|
93
98
|
message = String(error.message);
|
|
94
99
|
} else {
|
|
95
100
|
message = String(error);
|
|
@@ -101,18 +106,20 @@ export class DdRumErrorTracking {
|
|
|
101
106
|
static getErrorStackTrace(error) {
|
|
102
107
|
let stack = EMPTY_STACK_TRACE;
|
|
103
108
|
|
|
104
|
-
if (error
|
|
109
|
+
if (error === undefined || error === null) {
|
|
105
110
|
stack = EMPTY_STACK_TRACE;
|
|
106
111
|
} else if (typeof error === 'string') {
|
|
107
112
|
stack = EMPTY_STACK_TRACE;
|
|
108
|
-
} else if ('
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
stack
|
|
114
|
-
|
|
115
|
-
|
|
113
|
+
} else if (typeof error === 'object') {
|
|
114
|
+
if ('componentStack' in error) {
|
|
115
|
+
stack = String(error.componentStack);
|
|
116
|
+
} else if ('stacktrace' in error) {
|
|
117
|
+
stack = String(error.stacktrace);
|
|
118
|
+
} else if ('stack' in error) {
|
|
119
|
+
stack = String(error.stack);
|
|
120
|
+
} else if ('sourceURL' in error && 'line' in error && 'column' in error) {
|
|
121
|
+
stack = `at ${error.sourceURL}:${error.line}:${error.column}`;
|
|
122
|
+
}
|
|
116
123
|
}
|
|
117
124
|
|
|
118
125
|
return stack;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["DdRumErrorTracking.tsx"],"names":["DdRum","EMPTY_MESSAGE","EMPTY_STACK_TRACE","TYPE_SOURCE","TYPE_CONSOLE","DdRumErrorTracking","startTracking","isTracking","
|
|
1
|
+
{"version":3,"sources":["DdRumErrorTracking.tsx"],"names":["InternalLog","SdkVerbosity","DdRum","EMPTY_MESSAGE","EMPTY_STACK_TRACE","TYPE_SOURCE","TYPE_CONSOLE","DdRumErrorTracking","startTracking","isTracking","log","WARN","ErrorUtils","defaultErrorHandler","getGlobalHandler","defaultConsoleError","console","error","setGlobalHandler","onGlobalError","onConsoleError","INFO","ERROR","isFatal","message","getErrorMessage","stacktrace","getErrorStackTrace","addError","then","isInDefaultErrorHandler","params","stack","i","length","param","paramStack","map","join","apply","undefined","String","componentStack","sourceURL","line","column","_error","_isFatal","_params"],"mappings":";;AAAA;AACA;AACA;AACA;AACA;AAIA,SAASA,WAAT,QAA4B,mBAA5B;AACA,SAASC,YAAT,QAA6B,oBAA7B;AACA,SAASC,KAAT,QAAsB,kBAAtB;AAEA,MAAMC,aAAa,GAAG,eAAtB;AACA,MAAMC,iBAAiB,GAAG,EAA1B;AACA,MAAMC,WAAW,GAAG,QAApB;AACA,MAAMC,YAAY,GAAG,SAArB;AAEA;AACA;AACA;;AACA,OAAO,MAAMC,kBAAN,CAAyB;AAK5B;AAGA;;AAGA;AACJ;AACA;AACwB,SAAbC,aAAa,GAAS;AACzB;AACA,QAAID,kBAAkB,CAACE,UAAvB,EAAmC;AAC/BT,MAAAA,WAAW,CAACU,GAAZ,CACI,wCADJ,EAEIT,YAAY,CAACU,IAFjB;AAIA;AACH;;AAED,QAAIC,UAAJ,EAAgB;AACZL,MAAAA,kBAAkB,CAACM,mBAAnB,GAAyCD,UAAU,CAACE,gBAAX,EAAzC;AACAP,MAAAA,kBAAkB,CAACQ,mBAAnB,GAAyCC,OAAO,CAACC,KAAjD;AAEAL,MAAAA,UAAU,CAACM,gBAAX,CAA4BX,kBAAkB,CAACY,aAA/C;AACAH,MAAAA,OAAO,CAACC,KAAR,GAAgBV,kBAAkB,CAACa,cAAnC;AAEAb,MAAAA,kBAAkB,CAACE,UAAnB,GAAgC,IAAhC;AACAT,MAAAA,WAAW,CAACU,GAAZ,CACI,gCADJ,EAEIT,YAAY,CAACoB,IAFjB;AAIH,KAZD,MAYO;AACHrB,MAAAA,WAAW,CAACU,GAAZ,CACI,4DADJ,EAEIT,YAAY,CAACqB,KAFjB;AAIH;AACJ,GA1C2B,CA4C5B;;;AACoB,SAAbH,aAAa,CAACF,KAAD,EAAaM,OAAb,EAAsC;AACtD,UAAMC,OAAO,GAAGjB,kBAAkB,CAACkB,eAAnB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e,QAAAA,KAAK,GAAGS,MAAM,CAACxB,KAAK,CAACe,KAAP,CAAd;AACH,OAFM,MAEA,IACH,eAAef,KAAf,IACA,UAAUA,KADV,IAEA,YAAYA,KAHT,EAIL;AACEe,QAAAA,KAAK,GAAI,MAAKf,KAAK,CAAC0B,SAAU,IAAG1B,KAAK,CAAC2B,IAAK,IAAG3B,KAAK,CAAC4B,MAAO,EAA5D;AACH;AACJ;;AAED,WAAOb,KAAP;AACH;;AAhI2B;;gBAAnBzB,kB,gBACmB,K;;gBADnBA,kB,6BAGgC,K;;gBAHhCA,kB,yBAMkD,CAACuC,MAAD,EAAcC,QAAd,KAAqC,CAAG,C;;gBAN1FxC,kB,yBAS4B,CAAC,GAAGyC,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"]}
|
|
@@ -6,16 +6,18 @@ function _defineProperty(obj, key, value) { if (key in obj) { Object.definePrope
|
|
|
6
6
|
* Copyright 2016-Present Datadog, Inc.
|
|
7
7
|
*/
|
|
8
8
|
import { Platform } from 'react-native';
|
|
9
|
-
import {
|
|
9
|
+
import { InternalLog } from '../../InternalLog';
|
|
10
|
+
import { SdkVerbosity } from '../../SdkVerbosity';
|
|
10
11
|
import Timer from '../../Timer';
|
|
12
|
+
import { DdRum } from '../../foundation';
|
|
11
13
|
import { generateTraceId } from './TraceIdentifier';
|
|
12
|
-
export const TRACE_ID_HEADER_KEY =
|
|
13
|
-
export const PARENT_ID_HEADER_KEY =
|
|
14
|
-
export const ORIGIN_HEADER_KEY =
|
|
15
|
-
export const SAMPLING_PRIORITY_HEADER_KEY =
|
|
16
|
-
export const
|
|
17
|
-
export const
|
|
18
|
-
const RESPONSE_START_LABEL =
|
|
14
|
+
export const TRACE_ID_HEADER_KEY = 'x-datadog-trace-id';
|
|
15
|
+
export const PARENT_ID_HEADER_KEY = 'x-datadog-parent-id';
|
|
16
|
+
export const ORIGIN_HEADER_KEY = 'x-datadog-origin';
|
|
17
|
+
export const SAMPLING_PRIORITY_HEADER_KEY = 'x-datadog-sampling-priority';
|
|
18
|
+
export const ORIGIN_RUM = 'rum';
|
|
19
|
+
export const RESOURCE_SIZE_ERROR_MESSAGE = "Couldn't get resource size, because an error occured: ";
|
|
20
|
+
const RESPONSE_START_LABEL = 'response_start';
|
|
19
21
|
const MISSING_RESOURCE_SIZE = -1;
|
|
20
22
|
|
|
21
23
|
function createTimings(startTime, responseStartTime, responseEndTime) {
|
|
@@ -115,7 +117,7 @@ export function calculateResponseSize(xhr) {
|
|
|
115
117
|
break;
|
|
116
118
|
}
|
|
117
119
|
} catch (e) {
|
|
118
|
-
|
|
120
|
+
InternalLog.log(`${RESOURCE_SIZE_ERROR_MESSAGE}${e}`, SdkVerbosity.ERROR);
|
|
119
121
|
}
|
|
120
122
|
|
|
121
123
|
if (typeof size !== 'number') {
|
|
@@ -124,32 +126,51 @@ export function calculateResponseSize(xhr) {
|
|
|
124
126
|
|
|
125
127
|
return size;
|
|
126
128
|
}
|
|
129
|
+
|
|
130
|
+
const generateTracingAttributes = tracingSamplingRate => {
|
|
131
|
+
if (Math.random() * 100 <= tracingSamplingRate) {
|
|
132
|
+
return {
|
|
133
|
+
traceId: generateTraceId(),
|
|
134
|
+
spanId: generateTraceId(),
|
|
135
|
+
samplingPriorityHeader: '1',
|
|
136
|
+
tracingStrategy: 'KEEP'
|
|
137
|
+
};
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
return {
|
|
141
|
+
samplingPriorityHeader: '0',
|
|
142
|
+
tracingStrategy: 'DISCARD'
|
|
143
|
+
};
|
|
144
|
+
};
|
|
127
145
|
/**
|
|
128
|
-
* Provides RUM auto-instrumentation feature to track resources (fetch, XHR, axios) as RUM events.
|
|
129
|
-
*/
|
|
146
|
+
* Provides RUM auto-instrumentation feature to track resources (fetch, XHR, axios) as RUM events.
|
|
147
|
+
*/
|
|
148
|
+
|
|
130
149
|
|
|
131
150
|
export class DdRumResourceTracking {
|
|
132
151
|
/**
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
static startTracking() {
|
|
136
|
-
DdRumResourceTracking.startTrackingInternal(XMLHttpRequest);
|
|
152
|
+
* Starts tracking resources and sends a RUM Resource event every time a network request is detected.
|
|
153
|
+
*/
|
|
154
|
+
static startTracking(tracingSamplingRate) {
|
|
155
|
+
DdRumResourceTracking.startTrackingInternal(XMLHttpRequest, tracingSamplingRate);
|
|
137
156
|
}
|
|
138
157
|
/**
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
// eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types
|
|
158
|
+
* Starts tracking resources and sends a RUM Resource event every time a fetch or XHR call is detected.
|
|
159
|
+
*/
|
|
142
160
|
|
|
143
161
|
|
|
144
|
-
static startTrackingInternal(xhrType) {
|
|
162
|
+
static startTrackingInternal(xhrType, tracingSamplingRate) {
|
|
145
163
|
// extra safety to avoid proxying the XHR class twice
|
|
146
164
|
if (DdRumResourceTracking.isTracking) {
|
|
165
|
+
InternalLog.log('Datadog SDK is already tracking XHR resources', SdkVerbosity.WARN);
|
|
147
166
|
return;
|
|
148
167
|
}
|
|
149
168
|
|
|
169
|
+
DdRumResourceTracking.tracingSamplingRate = tracingSamplingRate;
|
|
150
170
|
DdRumResourceTracking.originalXhrOpen = xhrType.prototype.open;
|
|
151
171
|
DdRumResourceTracking.originalXhrSend = xhrType.prototype.send;
|
|
152
172
|
DdRumResourceTracking.proxyXhr(xhrType);
|
|
173
|
+
InternalLog.log('Datadog SDK is tracking XHR resources', SdkVerbosity.INFO);
|
|
153
174
|
}
|
|
154
175
|
|
|
155
176
|
static stopTracking() {
|
|
@@ -172,15 +193,12 @@ export class DdRumResourceTracking {
|
|
|
172
193
|
xhrType.prototype.open = function (method, url) {
|
|
173
194
|
// Keep track of the method and url
|
|
174
195
|
// start time is tracked by the `send` method
|
|
175
|
-
const spanId = generateTraceId();
|
|
176
|
-
const traceId = generateTraceId();
|
|
177
196
|
this._datadog_xhr = {
|
|
178
197
|
method,
|
|
179
|
-
url
|
|
198
|
+
url,
|
|
180
199
|
reported: false,
|
|
181
200
|
timer: new Timer(),
|
|
182
|
-
|
|
183
|
-
traceId: traceId
|
|
201
|
+
tracingAttributes: generateTracingAttributes(DdRumResourceTracking.tracingSamplingRate)
|
|
184
202
|
}; // eslint-disable-next-line prefer-rest-params
|
|
185
203
|
|
|
186
204
|
return originalXhrOpen.apply(this, arguments);
|
|
@@ -195,11 +213,14 @@ export class DdRumResourceTracking {
|
|
|
195
213
|
// keep track of start time
|
|
196
214
|
this._datadog_xhr.timer.start();
|
|
197
215
|
|
|
198
|
-
this.setRequestHeader(TRACE_ID_HEADER_KEY, this._datadog_xhr.traceId);
|
|
199
|
-
this.setRequestHeader(PARENT_ID_HEADER_KEY, this._datadog_xhr.spanId);
|
|
200
216
|
this.setRequestHeader(ORIGIN_HEADER_KEY, ORIGIN_RUM);
|
|
201
|
-
this.
|
|
202
|
-
this.setRequestHeader(
|
|
217
|
+
const tracingAttributes = this._datadog_xhr.tracingAttributes;
|
|
218
|
+
this.setRequestHeader(SAMPLING_PRIORITY_HEADER_KEY, tracingAttributes.samplingPriorityHeader);
|
|
219
|
+
|
|
220
|
+
if (tracingAttributes.tracingStrategy !== 'DISCARD') {
|
|
221
|
+
this.setRequestHeader(TRACE_ID_HEADER_KEY, tracingAttributes.traceId);
|
|
222
|
+
this.setRequestHeader(PARENT_ID_HEADER_KEY, tracingAttributes.spanId);
|
|
223
|
+
}
|
|
203
224
|
}
|
|
204
225
|
|
|
205
226
|
DdRumResourceTracking.proxyOnReadyStateChange(this, xhrType); // eslint-disable-next-line prefer-rest-params
|
|
@@ -231,14 +252,14 @@ export class DdRumResourceTracking {
|
|
|
231
252
|
static reportXhr(xhrProxy) {
|
|
232
253
|
const responseSize = calculateResponseSize(xhrProxy);
|
|
233
254
|
const context = xhrProxy._datadog_xhr;
|
|
234
|
-
const key = context.timer.startTime
|
|
255
|
+
const key = `${context.timer.startTime}/${context.method}`;
|
|
235
256
|
context.timer.stop();
|
|
236
|
-
DdRum.startResource(key, context.method, context.url, {
|
|
237
|
-
|
|
238
|
-
|
|
257
|
+
DdRum.startResource(key, context.method, context.url, context.tracingAttributes.tracingStrategy === 'DISCARD' ? undefined : {
|
|
258
|
+
'_dd.span_id': context.tracingAttributes.spanId,
|
|
259
|
+
'_dd.trace_id': context.tracingAttributes.traceId
|
|
239
260
|
}, context.timer.startTime).then(() => {
|
|
240
|
-
DdRum.stopResource(key, xhrProxy.status,
|
|
241
|
-
|
|
261
|
+
DdRum.stopResource(key, xhrProxy.status, 'xhr', responseSize, {
|
|
262
|
+
'_dd.resource_timings': context.timer.hasTickFor(RESPONSE_START_LABEL) ? createTimings(context.timer.startTime, context.timer.timeAt(RESPONSE_START_LABEL), context.timer.stopTime) : null
|
|
242
263
|
}, context.timer.stopTime);
|
|
243
264
|
});
|
|
244
265
|
}
|
|
@@ -247,6 +268,8 @@ export class DdRumResourceTracking {
|
|
|
247
268
|
|
|
248
269
|
_defineProperty(DdRumResourceTracking, "isTracking", false);
|
|
249
270
|
|
|
271
|
+
_defineProperty(DdRumResourceTracking, "tracingSamplingRate", void 0);
|
|
272
|
+
|
|
250
273
|
_defineProperty(DdRumResourceTracking, "originalXhrOpen", void 0);
|
|
251
274
|
|
|
252
275
|
_defineProperty(DdRumResourceTracking, "originalXhrSend", void 0);
|