@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/commonjs/Timer.js
CHANGED
|
@@ -5,18 +5,24 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
5
5
|
});
|
|
6
6
|
exports.default = void 0;
|
|
7
7
|
|
|
8
|
+
var _TimeProvider = require("./TimeProvider");
|
|
9
|
+
|
|
8
10
|
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; }
|
|
9
11
|
|
|
10
|
-
const START_LABEL =
|
|
11
|
-
const STOP_LABEL =
|
|
12
|
+
const START_LABEL = '__start';
|
|
13
|
+
const STOP_LABEL = '__stop';
|
|
12
14
|
/**
|
|
13
15
|
* Simple timer which records time ticks. Shouldn't be re-used once stopped.
|
|
14
16
|
* All timestamps/durations returned are in milliseconds.
|
|
15
17
|
*/
|
|
16
18
|
|
|
17
19
|
class Timer {
|
|
18
|
-
constructor() {
|
|
20
|
+
constructor(timeProvider = new _TimeProvider.TimeProvider()) {
|
|
21
|
+
_defineProperty(this, "timeProvider", void 0);
|
|
22
|
+
|
|
19
23
|
_defineProperty(this, "times", {});
|
|
24
|
+
|
|
25
|
+
this.timeProvider = timeProvider;
|
|
20
26
|
}
|
|
21
27
|
|
|
22
28
|
get startTime() {
|
|
@@ -36,10 +42,7 @@ class Timer {
|
|
|
36
42
|
}
|
|
37
43
|
|
|
38
44
|
recordTick(label) {
|
|
39
|
-
this.times[label] =
|
|
40
|
-
unix: Date.now(),
|
|
41
|
-
react_native: this.performanceNow()
|
|
42
|
-
};
|
|
45
|
+
this.times[label] = this.timeProvider.getTimestamp();
|
|
43
46
|
}
|
|
44
47
|
|
|
45
48
|
hasTickFor(label) {
|
|
@@ -71,22 +74,6 @@ class Timer {
|
|
|
71
74
|
return end.unix - start.unix;
|
|
72
75
|
}
|
|
73
76
|
|
|
74
|
-
performanceNow() {
|
|
75
|
-
if (this.canUsePerformanceNow()) {
|
|
76
|
-
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
77
|
-
// @ts-ignore
|
|
78
|
-
return performance.now();
|
|
79
|
-
}
|
|
80
|
-
|
|
81
|
-
return null;
|
|
82
|
-
}
|
|
83
|
-
|
|
84
|
-
canUsePerformanceNow() {
|
|
85
|
-
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
86
|
-
// @ts-ignore
|
|
87
|
-
return global.performance && typeof performance.now === 'function';
|
|
88
|
-
}
|
|
89
|
-
|
|
90
77
|
checkLabelExists(label) {
|
|
91
78
|
if (!this.hasTickFor(label)) {
|
|
92
79
|
throw new Error(`Label ${label} is not registered`);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["Timer.ts"],"names":["START_LABEL","STOP_LABEL","Timer","startTime","times","unix","stopTime","durationBetween","start","recordTick","stop","label","
|
|
1
|
+
{"version":3,"sources":["Timer.ts"],"names":["START_LABEL","STOP_LABEL","Timer","constructor","timeProvider","TimeProvider","startTime","times","unix","stopTime","durationBetween","start","recordTick","stop","label","getTimestamp","hasTickFor","startLabel","endLabel","checkLabelExists","startTick","endTick","durationBetweenTicks","timeAt","reset","end","react_native","Error"],"mappings":";;;;;;;AAOA;;;;AAEA,MAAMA,WAAW,GAAG,SAApB;AACA,MAAMC,UAAU,GAAG,QAAnB;AAEA;AACA;AACA;AACA;;AACe,MAAMC,KAAN,CAAY;AAIvBC,EAAAA,WAAW,CAACC,YAA0B,GAAG,IAAIC,0BAAJ,EAA9B,EAAkD;AAAA;;AAAA,mCAFlB,EAEkB;;AACzD,SAAKD,YAAL,GAAoBA,YAApB;AACH;;AAEY,MAATE,SAAS,GAAW;AACpB,WAAO,KAAKC,KAAL,CAAWP,WAAX,EAAwBQ,IAA/B;AACH;;AAEW,MAARC,QAAQ,GAAW;AACnB,WAAO,KAAKH,SAAL,GAAiB,KAAKI,eAAL,CAAqBV,WAArB,EAAkCC,UAAlC,CAAxB;AACH;;AAEDU,EAAAA,KAAK,GAAS;AACV,SAAKC,UAAL,CAAgBZ,WAAhB;AACH;;AAEDa,EAAAA,IAAI,GAAS;AACT,SAAKD,UAAL,CAAgBX,UAAhB;AACH;;AAEDW,EAAAA,UAAU,CAACE,KAAD,EAAsB;AAC5B,SAAKP,KAAL,CAAWO,KAAX,IAAoB,KAAKV,YAAL,CAAkBW,YAAlB,EAApB;AACH;;AAEDC,EAAAA,UAAU,CAACF,KAAD,EAAyB;AAC/B,WAAOA,KAAK,IAAI,KAAKP,KAArB;AACH;;AAEDG,EAAAA,eAAe,CAACO,UAAD,EAAqBC,QAArB,EAA+C;AAC1D,SAAKC,gBAAL,CAAsBF,UAAtB;AACA,SAAKE,gBAAL,CAAsBD,QAAtB;AAEA,UAAME,SAAS,GAAG,KAAKb,KAAL,CAAWU,UAAX,CAAlB;AACA,UAAMI,OAAO,GAAG,KAAKd,KAAL,CAAWW,QAAX,CAAhB;AAEA,WAAO,KAAKI,oBAAL,CAA0BF,SAA1B,EAAqCC,OAArC,CAAP;AACH;;AAEDE,EAAAA,MAAM,CAACT,KAAD,EAAwB;AAC1B,SAAKK,gBAAL,CAAsBL,KAAtB;AAEA,WAAO,KAAKR,SAAL,GAAiB,KAAKI,eAAL,CAAqBV,WAArB,EAAkCc,KAAlC,CAAxB;AACH;;AAEDU,EAAAA,KAAK,GAAS;AACV,SAAKjB,KAAL,GAAa,EAAb;AACH;;AAEOe,EAAAA,oBAAoB,CAACX,KAAD,EAAmBc,GAAnB,EAA2C;AACnE,QAAId,KAAK,CAACe,YAAN,IAAsB,IAAtB,IAA8BD,GAAG,CAACC,YAAJ,IAAoB,IAAtD,EAA4D;AACxD,aAAOD,GAAG,CAACC,YAAJ,GAAmBf,KAAK,CAACe,YAAhC;AACH;;AACD,WAAOD,GAAG,CAACjB,IAAJ,GAAWG,KAAK,CAACH,IAAxB;AACH;;AAEOW,EAAAA,gBAAgB,CAACL,KAAD,EAAgB;AACpC,QAAI,CAAC,KAAKE,UAAL,CAAgBF,KAAhB,CAAL,EAA6B;AACzB,YAAM,IAAIa,KAAJ,CAAW,SAAQb,KAAM,oBAAzB,CAAN;AACH;AACJ;;AA/DsB","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 { Timestamp } from './TimeProvider';\nimport { TimeProvider } from './TimeProvider';\n\nconst START_LABEL = '__start';\nconst STOP_LABEL = '__stop';\n\n/**\n * Simple timer which records time ticks. Shouldn't be re-used once stopped.\n * All timestamps/durations returned are in milliseconds.\n */\nexport default class Timer {\n private timeProvider: TimeProvider;\n private times: Record<string, Timestamp> = {};\n\n constructor(timeProvider: TimeProvider = new TimeProvider()) {\n this.timeProvider = timeProvider;\n }\n\n get startTime(): number {\n return this.times[START_LABEL].unix;\n }\n\n get stopTime(): number {\n return this.startTime + this.durationBetween(START_LABEL, STOP_LABEL);\n }\n\n start(): void {\n this.recordTick(START_LABEL);\n }\n\n stop(): void {\n this.recordTick(STOP_LABEL);\n }\n\n recordTick(label: string): void {\n this.times[label] = this.timeProvider.getTimestamp();\n }\n\n hasTickFor(label: string): boolean {\n return label in this.times;\n }\n\n durationBetween(startLabel: string, endLabel: string): number {\n this.checkLabelExists(startLabel);\n this.checkLabelExists(endLabel);\n\n const startTick = this.times[startLabel];\n const endTick = this.times[endLabel];\n\n return this.durationBetweenTicks(startTick, endTick);\n }\n\n timeAt(label: string): number {\n this.checkLabelExists(label);\n\n return this.startTime + this.durationBetween(START_LABEL, label);\n }\n\n reset(): void {\n this.times = {};\n }\n\n private durationBetweenTicks(start: Timestamp, end: Timestamp): number {\n if (start.react_native != null && end.react_native != null) {\n return end.react_native - start.react_native;\n }\n return end.unix - start.unix;\n }\n\n private checkLabelExists(label: string) {\n if (!this.hasTickFor(label)) {\n throw new Error(`Label ${label} is not registered`);\n }\n }\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["TrackingConsent.tsx"],"names":["TrackingConsent"],"mappings":";;;;;;;AAAA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;IACYA,e;;;WAAAA,e;AAAAA,EAAAA,e;AAAAA,EAAAA,e;AAAAA,EAAAA,e;GAAAA,e,+BAAAA,e","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\n/**\n * Enum specifying possible consent options for DD SDK.\n */\nexport enum TrackingConsent {\n PENDING =
|
|
1
|
+
{"version":3,"sources":["TrackingConsent.tsx"],"names":["TrackingConsent"],"mappings":";;;;;;;AAAA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;IACYA,e;;;WAAAA,e;AAAAA,EAAAA,e;AAAAA,EAAAA,e;AAAAA,EAAAA,e;GAAAA,e,+BAAAA,e","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\n/**\n * Enum specifying possible consent options for DD SDK.\n */\nexport enum TrackingConsent {\n PENDING = 'pending',\n GRANTED = 'granted',\n NOT_GRANTED = 'not_granted'\n}\n"]}
|
|
@@ -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,11 +61,17 @@ class DdTraceWrapper {
|
|
|
45
61
|
_defineProperty(this, "nativeTrace", _reactNative.NativeModules.DdTrace);
|
|
46
62
|
}
|
|
47
63
|
|
|
48
|
-
startSpan(operation, context = {}, timestampMs =
|
|
49
|
-
|
|
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;
|
|
50
70
|
}
|
|
51
71
|
|
|
52
|
-
finishSpan(spanId, context = {}, timestampMs =
|
|
72
|
+
finishSpan(spanId, context = {}, timestampMs = timeProvider.now()) {
|
|
73
|
+
_InternalLog.InternalLog.log("Finishing span #" + spanId, _SdkVerbosity.SdkVerbosity.DEBUG);
|
|
74
|
+
|
|
53
75
|
return this.nativeTrace.finishSpan(spanId, context, timestampMs);
|
|
54
76
|
}
|
|
55
77
|
|
|
@@ -60,41 +82,59 @@ class DdRumWrapper {
|
|
|
60
82
|
_defineProperty(this, "nativeRum", _reactNative.NativeModules.DdRum);
|
|
61
83
|
}
|
|
62
84
|
|
|
63
|
-
startView(key, name, context = {}, timestampMs =
|
|
85
|
+
startView(key, name, context = {}, timestampMs = timeProvider.now()) {
|
|
86
|
+
_InternalLog.InternalLog.log("Starting RUM View “" + name + "” #" + key, _SdkVerbosity.SdkVerbosity.DEBUG);
|
|
87
|
+
|
|
64
88
|
return this.nativeRum.startView(key, name, context, timestampMs);
|
|
65
89
|
}
|
|
66
90
|
|
|
67
|
-
stopView(key, context = {}, timestampMs =
|
|
91
|
+
stopView(key, context = {}, timestampMs = timeProvider.now()) {
|
|
92
|
+
_InternalLog.InternalLog.log("Stopping RUM View #" + key, _SdkVerbosity.SdkVerbosity.DEBUG);
|
|
93
|
+
|
|
68
94
|
return this.nativeRum.stopView(key, context, timestampMs);
|
|
69
95
|
}
|
|
70
96
|
|
|
71
|
-
startAction(type, name, context = {}, timestampMs =
|
|
97
|
+
startAction(type, name, context = {}, timestampMs = timeProvider.now()) {
|
|
98
|
+
_InternalLog.InternalLog.log("Starting RUM Action “" + name + "” (" + type + ")", _SdkVerbosity.SdkVerbosity.DEBUG);
|
|
99
|
+
|
|
72
100
|
return this.nativeRum.startAction(type, name, context, timestampMs);
|
|
73
101
|
}
|
|
74
102
|
|
|
75
|
-
stopAction(context = {}, timestampMs =
|
|
103
|
+
stopAction(context = {}, timestampMs = timeProvider.now()) {
|
|
104
|
+
_InternalLog.InternalLog.log("Stopping current RUM Action", _SdkVerbosity.SdkVerbosity.DEBUG);
|
|
105
|
+
|
|
76
106
|
return this.nativeRum.stopAction(context, timestampMs);
|
|
77
107
|
}
|
|
78
108
|
|
|
79
|
-
addAction(type, name, context = {}, timestampMs =
|
|
109
|
+
addAction(type, name, context = {}, timestampMs = timeProvider.now()) {
|
|
110
|
+
_InternalLog.InternalLog.log("Adding RUM Action “" + name + "” (" + type + ")", _SdkVerbosity.SdkVerbosity.DEBUG);
|
|
111
|
+
|
|
80
112
|
return this.nativeRum.addAction(type, name, context, timestampMs);
|
|
81
113
|
}
|
|
82
114
|
|
|
83
|
-
startResource(key, method, url, context = {}, timestampMs =
|
|
115
|
+
startResource(key, method, url, context = {}, timestampMs = timeProvider.now()) {
|
|
116
|
+
_InternalLog.InternalLog.log("Starting RUM Resource #" + key + " " + method + ": " + url, _SdkVerbosity.SdkVerbosity.DEBUG);
|
|
117
|
+
|
|
84
118
|
return this.nativeRum.startResource(key, method, url, context, timestampMs);
|
|
85
119
|
}
|
|
86
120
|
|
|
87
|
-
stopResource(key, statusCode, kind, size = -1, context = {}, timestampMs =
|
|
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
|
+
|
|
88
124
|
return this.nativeRum.stopResource(key, statusCode, kind, size, context, timestampMs);
|
|
89
125
|
}
|
|
90
126
|
|
|
91
|
-
addError(message, source, stacktrace, context = {}, timestampMs =
|
|
127
|
+
addError(message, source, stacktrace, context = {}, timestampMs = timeProvider.now()) {
|
|
128
|
+
_InternalLog.InternalLog.log("Adding RUM Error “" + message + "”", _SdkVerbosity.SdkVerbosity.DEBUG);
|
|
129
|
+
|
|
92
130
|
let updatedContext = context;
|
|
93
131
|
updatedContext["_dd.error.source_type"] = "react-native";
|
|
94
132
|
return this.nativeRum.addError(message, source, stacktrace, updatedContext, timestampMs);
|
|
95
133
|
}
|
|
96
134
|
|
|
97
135
|
addTiming(name) {
|
|
136
|
+
_InternalLog.InternalLog.log("Adding timing “" + name + "” to RUM View", _SdkVerbosity.SdkVerbosity.DEBUG);
|
|
137
|
+
|
|
98
138
|
return this.nativeRum.addTiming(name);
|
|
99
139
|
}
|
|
100
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","size","addError","source","stacktrace","updatedContext","addTiming","DdSdk"],"mappings":";;;;;;;;;;;;;AAMA;;AACA;;;;AAEA,MAAMA,aAAN,CAA0C;AAAA;AAAA,wCAEPC,2BAAcC,MAFP;AAAA;;AAIxCC,EAAAA,KAAK,CAACC,OAAD,EAAkBC,OAAe,GAAG,EAApC,EAAuD;AAC1D,WAAO,KAAKC,UAAL,CAAgBH,KAAhB,CAAsBC,OAAtB,EAA+BC,OAA/B,CAAP;AACD;;AAEDE,EAAAA,IAAI,CAACH,OAAD,EAAkBC,OAAe,GAAG,EAApC,EAAuD;AACzD,WAAO,KAAKC,UAAL,CAAgBC,IAAhB,CAAqBH,OAArB,EAA8BC,OAA9B,CAAP;AACD;;AAEDG,EAAAA,IAAI,CAACJ,OAAD,EAAkBC,OAAe,GAAG,EAApC,EAAuD;AACzD,WAAO,KAAKC,UAAL,CAAgBE,IAAhB,CAAqBJ,OAArB,EAA8BC,OAA9B,CAAP;AACD;;AAEDI,EAAAA,KAAK,CAACL,OAAD,EAAkBC,OAAe,GAAG,EAApC,EAAuD;AAC1D,WAAO,KAAKC,UAAL,CAAgBG,KAAhB,CAAsBL,OAAtB,EAA+BC,OAA/B,CAAP;AACD;;AAlBuC;;AAsB1C,MAAMK,cAAN,CAA4C;AAAA;AAAA,yCAEPT,2BAAcU,OAFP;AAAA;;AAI1CC,EAAAA,SAAS,CAACC,SAAD,EAAoBR,OAAe,GAAG,EAAtC,EAA0CS,WAAmB,GAAGC,IAAI,CAACC,GAAL,EAAhE,EAA6F;AACpG,WAAO,KAAKC,WAAL,CAAiBL,SAAjB,CAA2BC,SAA3B,EAAsCR,OAAtC,EAA+CS,WAA/C,CAAP;AACD;;AAEDI,EAAAA,UAAU,CAACC,MAAD,EAAiBd,OAAe,GAAG,EAAnC,EAAuCS,WAAmB,GAAGC,IAAI,CAACC,GAAL,EAA7D,EAAwF;AAChG,WAAO,KAA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AkB,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\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":["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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AG7C,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,62 +3,78 @@
|
|
|
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, "InternalLog", {
|
|
19
19
|
enumerable: true,
|
|
20
20
|
get: function () {
|
|
21
|
-
return
|
|
21
|
+
return _InternalLog.InternalLog;
|
|
22
22
|
}
|
|
23
23
|
});
|
|
24
|
-
Object.defineProperty(exports, "
|
|
24
|
+
Object.defineProperty(exports, "ProxyConfiguration", {
|
|
25
25
|
enumerable: true,
|
|
26
26
|
get: function () {
|
|
27
|
-
return
|
|
27
|
+
return _ProxyConfiguration.ProxyConfiguration;
|
|
28
28
|
}
|
|
29
29
|
});
|
|
30
|
-
Object.defineProperty(exports, "
|
|
30
|
+
Object.defineProperty(exports, "ProxyType", {
|
|
31
31
|
enumerable: true,
|
|
32
32
|
get: function () {
|
|
33
|
-
return
|
|
33
|
+
return _ProxyConfiguration.ProxyType;
|
|
34
34
|
}
|
|
35
35
|
});
|
|
36
|
-
Object.defineProperty(exports, "
|
|
36
|
+
Object.defineProperty(exports, "SdkVerbosity", {
|
|
37
37
|
enumerable: true,
|
|
38
38
|
get: function () {
|
|
39
|
-
return
|
|
39
|
+
return _SdkVerbosity.SdkVerbosity;
|
|
40
40
|
}
|
|
41
41
|
});
|
|
42
|
-
Object.defineProperty(exports, "
|
|
42
|
+
Object.defineProperty(exports, "TrackingConsent", {
|
|
43
43
|
enumerable: true,
|
|
44
44
|
get: function () {
|
|
45
|
-
return
|
|
45
|
+
return _TrackingConsent.TrackingConsent;
|
|
46
46
|
}
|
|
47
47
|
});
|
|
48
|
-
Object.defineProperty(exports, "
|
|
48
|
+
Object.defineProperty(exports, "DdLogs", {
|
|
49
49
|
enumerable: true,
|
|
50
50
|
get: function () {
|
|
51
|
-
return
|
|
51
|
+
return _foundation.DdLogs;
|
|
52
|
+
}
|
|
53
|
+
});
|
|
54
|
+
Object.defineProperty(exports, "DdTrace", {
|
|
55
|
+
enumerable: true,
|
|
56
|
+
get: function () {
|
|
57
|
+
return _foundation.DdTrace;
|
|
58
|
+
}
|
|
59
|
+
});
|
|
60
|
+
Object.defineProperty(exports, "DdRum", {
|
|
61
|
+
enumerable: true,
|
|
62
|
+
get: function () {
|
|
63
|
+
return _foundation.DdRum;
|
|
52
64
|
}
|
|
53
65
|
});
|
|
54
|
-
|
|
55
|
-
var _foundation = require("./foundation");
|
|
56
66
|
|
|
57
67
|
var _DdSdkReactNativeConfiguration = require("./DdSdkReactNativeConfiguration");
|
|
58
68
|
|
|
59
69
|
var _DdSdkReactNative = require("./DdSdkReactNative");
|
|
60
70
|
|
|
71
|
+
var _InternalLog = require("./InternalLog");
|
|
72
|
+
|
|
61
73
|
var _ProxyConfiguration = require("./ProxyConfiguration");
|
|
62
74
|
|
|
75
|
+
var _SdkVerbosity = require("./SdkVerbosity");
|
|
76
|
+
|
|
63
77
|
var _TrackingConsent = require("./TrackingConsent");
|
|
78
|
+
|
|
79
|
+
var _foundation = require("./foundation");
|
|
64
80
|
//# 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;;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 { 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,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,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,UAAIH,mBAAmB,GAAGb,8BAA1B,EAA0D;AACtD,cAAMiB,UAAU,GAAGV,IAAI,CAAC,CAAD,CAAJ,CAAQE,WAA3B;AACA,aAAKS,iBAAL,CAAuBD,UAAvB,EAFsD,CAGtD;;AACA,aAAKD,0BAAL,GACIN,WAAW,GAAGT,qCADlB;AAEH;AACJ,KAZD,MAYO;AACHkB,+BAAYC,GAAZ,CACIjB,mBAAmB,CAACkB,iCADxB,EAEIC,2BAAaC,IAFjB;AAIH;AACJ;;AAEOL,EAAAA,iBAAiB,CAACD,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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,21 +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 EMPTY_MESSAGE =
|
|
13
|
-
const EMPTY_STACK_TRACE =
|
|
14
|
-
const TYPE_SOURCE =
|
|
15
|
-
const TYPE_CONSOLE =
|
|
16
|
+
const EMPTY_MESSAGE = 'Unknown Error';
|
|
17
|
+
const EMPTY_STACK_TRACE = '';
|
|
18
|
+
const TYPE_SOURCE = 'SOURCE';
|
|
19
|
+
const TYPE_CONSOLE = 'CONSOLE';
|
|
16
20
|
/**
|
|
17
|
-
* Provides RUM auto-instrumentation feature to track errors as RUM events.
|
|
18
|
-
*/
|
|
21
|
+
* Provides RUM auto-instrumentation feature to track errors as RUM events.
|
|
22
|
+
*/
|
|
19
23
|
|
|
20
24
|
class DdRumErrorTracking {
|
|
21
|
-
// eslint-disable-next-line
|
|
22
|
-
// eslint-disable-next-line
|
|
25
|
+
// eslint-disable-next-line
|
|
26
|
+
// eslint-disable-next-line
|
|
23
27
|
|
|
24
28
|
/**
|
|
25
29
|
* Starts tracking errors and sends a RUM Error event every time an error is detected.
|
|
@@ -27,7 +31,8 @@ class DdRumErrorTracking {
|
|
|
27
31
|
static startTracking() {
|
|
28
32
|
// extra safety to avoid wrapping the Error handler twice
|
|
29
33
|
if (DdRumErrorTracking.isTracking) {
|
|
30
|
-
|
|
34
|
+
_InternalLog.InternalLog.log('Datadog SDK is already tracking errors', _SdkVerbosity.SdkVerbosity.WARN);
|
|
35
|
+
|
|
31
36
|
return;
|
|
32
37
|
}
|
|
33
38
|
|
|
@@ -37,6 +42,10 @@ class DdRumErrorTracking {
|
|
|
37
42
|
ErrorUtils.setGlobalHandler(DdRumErrorTracking.onGlobalError);
|
|
38
43
|
console.error = DdRumErrorTracking.onConsoleError;
|
|
39
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);
|
|
40
49
|
}
|
|
41
50
|
} // eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types
|
|
42
51
|
|
|
@@ -46,8 +55,8 @@ class DdRumErrorTracking {
|
|
|
46
55
|
const stacktrace = DdRumErrorTracking.getErrorStackTrace(error);
|
|
47
56
|
|
|
48
57
|
_foundation.DdRum.addError(message, TYPE_SOURCE, stacktrace, {
|
|
49
|
-
|
|
50
|
-
|
|
58
|
+
'_dd.error.is_crash': isFatal,
|
|
59
|
+
'_dd.error.raw': error
|
|
51
60
|
}).then(() => {
|
|
52
61
|
DdRumErrorTracking.isInDefaultErrorHandler = true;
|
|
53
62
|
|
|
@@ -70,7 +79,7 @@ class DdRumErrorTracking {
|
|
|
70
79
|
const param = params[i];
|
|
71
80
|
const paramStack = DdRumErrorTracking.getErrorStackTrace(param);
|
|
72
81
|
|
|
73
|
-
if (paramStack
|
|
82
|
+
if (paramStack !== EMPTY_STACK_TRACE) {
|
|
74
83
|
stack = paramStack;
|
|
75
84
|
break;
|
|
76
85
|
}
|
|
@@ -92,9 +101,9 @@ class DdRumErrorTracking {
|
|
|
92
101
|
static getErrorMessage(error) {
|
|
93
102
|
let message = EMPTY_MESSAGE;
|
|
94
103
|
|
|
95
|
-
if (error
|
|
104
|
+
if (error === undefined || error === null) {
|
|
96
105
|
message = EMPTY_MESSAGE;
|
|
97
|
-
} else if (
|
|
106
|
+
} else if (typeof error === 'object' && 'message' in error) {
|
|
98
107
|
message = String(error.message);
|
|
99
108
|
} else {
|
|
100
109
|
message = String(error);
|
|
@@ -106,18 +115,20 @@ class DdRumErrorTracking {
|
|
|
106
115
|
static getErrorStackTrace(error) {
|
|
107
116
|
let stack = EMPTY_STACK_TRACE;
|
|
108
117
|
|
|
109
|
-
if (error
|
|
118
|
+
if (error === undefined || error === null) {
|
|
110
119
|
stack = EMPTY_STACK_TRACE;
|
|
111
120
|
} else if (typeof error === 'string') {
|
|
112
121
|
stack = EMPTY_STACK_TRACE;
|
|
113
|
-
} else if ('
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
stack
|
|
119
|
-
|
|
120
|
-
|
|
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
|
+
}
|
|
121
132
|
}
|
|
122
133
|
|
|
123
134
|
return stack;
|