@datadog/mobile-react-native 1.7.0 → 1.8.0-rc0
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 +14 -1
- package/android/build.gradle +20 -7
- package/android/src/main/kotlin/com/datadog/reactnative/{DdLogs.kt → DdLogsImplementation.kt} +3 -17
- package/android/src/main/kotlin/com/datadog/reactnative/{DdRum.kt → DdRumImplementation.kt} +2 -18
- package/android/src/main/kotlin/com/datadog/reactnative/{DdSdk.kt → DdSdkImplementation.kt} +3 -14
- package/android/src/main/kotlin/com/datadog/reactnative/DdSdkReactNativePackage.kt +34 -17
- package/android/src/main/kotlin/com/datadog/reactnative/{DdTrace.kt → DdTraceImplementation.kt} +6 -11
- package/android/src/newarch/kotlin/com/datadog/reactnative/DdLogs.kt +148 -0
- package/android/src/newarch/kotlin/com/datadog/reactnative/DdRum.kt +199 -0
- package/android/src/newarch/kotlin/com/datadog/reactnative/DdSdk.kt +90 -0
- package/android/src/newarch/kotlin/com/datadog/reactnative/DdTrace.kt +46 -0
- package/android/src/oldarch/kotlin/com/datadog/reactnative/DdLogs.kt +163 -0
- package/android/src/oldarch/kotlin/com/datadog/reactnative/DdRum.kt +200 -0
- package/android/src/oldarch/kotlin/com/datadog/reactnative/DdSdk.kt +91 -0
- package/android/src/oldarch/kotlin/com/datadog/reactnative/DdTrace.kt +47 -0
- package/android/src/test/kotlin/com/datadog/reactnative/DdLogsTest.kt +3 -13
- package/android/src/test/kotlin/com/datadog/reactnative/DdRumTest.kt +2 -6
- package/android/src/test/kotlin/com/datadog/reactnative/DdSdkTest.kt +33 -33
- package/android/src/test/kotlin/com/datadog/reactnative/DdTraceTest.kt +2 -6
- package/ios/Sources/{DdSdkReactNative-Bridging-Header.h → DatadogSDKReactNative.h} +2 -1
- package/ios/Sources/DdLogs.h +24 -0
- package/ios/Sources/DdLogs.mm +149 -0
- package/ios/Sources/{DdLogs.swift → DdLogsImplementation.swift} +20 -29
- package/ios/Sources/DdRum.h +24 -0
- package/ios/Sources/DdRum.mm +188 -0
- package/ios/Sources/{DdRum.swift → DdRumImplementation.swift} +28 -35
- package/ios/Sources/DdSdk.h +24 -0
- package/ios/Sources/DdSdk.mm +119 -0
- package/ios/Sources/{DdSdk.swift → DdSdkImplementation.swift} +20 -25
- package/ios/Sources/DdTrace.h +24 -0
- package/ios/Sources/DdTrace.mm +66 -0
- package/ios/Sources/{DdTrace.swift → DdTraceImplementation.swift} +10 -17
- package/ios/Sources/QueueHolder.swift +8 -0
- package/jest/mock.js +6 -1
- package/lib/commonjs/DdSdkReactNative.js +32 -49
- package/lib/commonjs/DdSdkReactNative.js.map +1 -1
- package/lib/commonjs/DdSdkReactNativeConfiguration.js +18 -0
- package/lib/commonjs/DdSdkReactNativeConfiguration.js.map +1 -1
- package/lib/commonjs/logs/DdLogs.js +33 -40
- package/lib/commonjs/logs/DdLogs.js.map +1 -1
- package/lib/commonjs/nativeModulesTypes.js +13 -0
- package/lib/commonjs/nativeModulesTypes.js.map +1 -1
- package/lib/commonjs/rum/DdRum.js +104 -106
- package/lib/commonjs/rum/DdRum.js.map +1 -1
- package/lib/commonjs/rum/eventMappers/errorEventMapper.js.map +1 -1
- package/lib/commonjs/rum/instrumentation/interactionTracking/DdEventsInterceptor.js +11 -1
- package/lib/commonjs/rum/instrumentation/interactionTracking/DdEventsInterceptor.js.map +1 -1
- package/lib/commonjs/rum/instrumentation/interactionTracking/DdRumUserInteractionTracking.js +6 -2
- package/lib/commonjs/rum/instrumentation/interactionTracking/DdRumUserInteractionTracking.js.map +1 -1
- package/lib/commonjs/sdk/DdSdk.js +3 -3
- package/lib/commonjs/sdk/DdSdk.js.map +1 -1
- package/lib/commonjs/specs/NativeDdLogs.js +20 -0
- package/lib/commonjs/specs/NativeDdLogs.js.map +1 -0
- package/lib/commonjs/specs/NativeDdRum.js +20 -0
- package/lib/commonjs/specs/NativeDdRum.js.map +1 -0
- package/lib/commonjs/specs/NativeDdSdk.js +20 -0
- package/lib/commonjs/specs/NativeDdSdk.js.map +1 -0
- package/lib/commonjs/specs/NativeDdTrace.js +20 -0
- package/lib/commonjs/specs/NativeDdTrace.js.map +1 -0
- package/lib/commonjs/trace/DdTrace.js +10 -12
- package/lib/commonjs/trace/DdTrace.js.map +1 -1
- package/lib/commonjs/version.js +1 -1
- package/lib/commonjs/version.js.map +1 -1
- package/lib/module/DdSdkReactNative.js +27 -44
- package/lib/module/DdSdkReactNative.js.map +1 -1
- package/lib/module/DdSdkReactNativeConfiguration.js +18 -0
- package/lib/module/DdSdkReactNativeConfiguration.js.map +1 -1
- package/lib/module/logs/DdLogs.js +33 -39
- package/lib/module/logs/DdLogs.js.map +1 -1
- package/lib/module/nativeModulesTypes.js +13 -0
- package/lib/module/nativeModulesTypes.js.map +1 -1
- package/lib/module/rum/DdRum.js +100 -101
- package/lib/module/rum/DdRum.js.map +1 -1
- package/lib/module/rum/eventMappers/errorEventMapper.js.map +1 -1
- package/lib/module/rum/instrumentation/interactionTracking/DdEventsInterceptor.js +11 -1
- package/lib/module/rum/instrumentation/interactionTracking/DdEventsInterceptor.js.map +1 -1
- package/lib/module/rum/instrumentation/interactionTracking/DdRumUserInteractionTracking.js +6 -2
- package/lib/module/rum/instrumentation/interactionTracking/DdRumUserInteractionTracking.js.map +1 -1
- package/lib/module/sdk/DdSdk.js +3 -2
- package/lib/module/sdk/DdSdk.js.map +1 -1
- package/lib/module/specs/NativeDdLogs.js +14 -0
- package/lib/module/specs/NativeDdLogs.js.map +1 -0
- package/lib/module/specs/NativeDdRum.js +14 -0
- package/lib/module/specs/NativeDdRum.js.map +1 -0
- package/lib/module/specs/NativeDdSdk.js +14 -0
- package/lib/module/specs/NativeDdSdk.js.map +1 -0
- package/lib/module/specs/NativeDdTrace.js +14 -0
- package/lib/module/specs/NativeDdTrace.js.map +1 -0
- package/lib/module/trace/DdTrace.js +10 -11
- package/lib/module/trace/DdTrace.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 +4 -4
- package/lib/typescript/DdSdkReactNativeConfiguration.d.ts +14 -0
- package/lib/typescript/logs/DdLogs.d.ts +4 -4
- package/lib/typescript/nativeModulesTypes.d.ts +28 -168
- package/lib/typescript/rum/DdRum.d.ts +12 -12
- package/lib/typescript/rum/eventMappers/errorEventMapper.d.ts +4 -4
- package/lib/typescript/rum/instrumentation/interactionTracking/DdEventsInterceptor.d.ts +4 -0
- package/lib/typescript/rum/instrumentation/interactionTracking/DdRumUserInteractionTracking.d.ts +3 -1
- package/lib/typescript/specs/NativeDdLogs.d.ts +69 -0
- package/lib/typescript/specs/NativeDdRum.d.ts +92 -0
- package/lib/typescript/specs/NativeDdSdk.d.ts +46 -0
- package/lib/typescript/specs/NativeDdTrace.d.ts +23 -0
- package/lib/typescript/version.d.ts +1 -1
- package/package.json +10 -2
- package/src/DdSdkReactNative.tsx +12 -10
- package/src/DdSdkReactNativeConfiguration.tsx +22 -0
- package/src/__tests__/DdSdkReactNativeConfiguration.test.ts +3 -1
- package/src/__tests__/longTasksUtils.test.ts +5 -0
- package/src/__tests__/mock.test.ts +89 -0
- package/src/__tests__/rum/instrumentation/DdEventsInterceptor.test.tsx +54 -0
- package/src/__tests__/rum/instrumentation/DdRumUserInteractionTracking.test.tsx +118 -68
- package/src/logs/DdLogs.ts +11 -11
- package/src/logs/__tests__/DdLogs.test.ts +1 -1
- package/src/nativeModulesTypes.ts +49 -254
- package/src/rum/DdRum.ts +36 -32
- package/src/rum/eventMappers/errorEventMapper.ts +4 -4
- package/src/rum/instrumentation/interactionTracking/DdEventsInterceptor.tsx +15 -0
- package/src/rum/instrumentation/interactionTracking/DdRumUserInteractionTracking.tsx +6 -2
- package/src/sdk/DdSdk.ts +2 -3
- package/src/specs/NativeDdLogs.ts +110 -0
- package/src/specs/NativeDdRum.ts +151 -0
- package/src/specs/NativeDdSdk.ts +62 -0
- package/src/specs/NativeDdTrace.ts +42 -0
- package/src/trace/DdTrace.ts +9 -9
- package/src/version.ts +1 -1
- package/ios/Sources/DdLogs.m +0 -62
- package/ios/Sources/DdRum.m +0 -82
- package/ios/Sources/DdSdk.m +0 -41
- package/ios/Sources/DdTrace.m +0 -23
package/lib/module/rum/DdRum.js
CHANGED
|
@@ -5,7 +5,6 @@ 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 { NativeModules } from 'react-native';
|
|
9
8
|
import { InternalLog } from '../InternalLog';
|
|
10
9
|
import { SdkVerbosity } from '../SdkVerbosity';
|
|
11
10
|
import { TimeProvider } from '../TimeProvider';
|
|
@@ -20,7 +19,7 @@ const generateEmptyPromise = () => new Promise(resolve => resolve());
|
|
|
20
19
|
|
|
21
20
|
class DdRumWrapper {
|
|
22
21
|
constructor() {
|
|
23
|
-
_defineProperty(this, "nativeRum",
|
|
22
|
+
_defineProperty(this, "nativeRum", require('../specs/NativeDdRum').default);
|
|
24
23
|
|
|
25
24
|
_defineProperty(this, "lastActionData", void 0);
|
|
26
25
|
|
|
@@ -30,6 +29,37 @@ class DdRumWrapper {
|
|
|
30
29
|
|
|
31
30
|
_defineProperty(this, "actionEventMapper", generateActionEventMapper(undefined));
|
|
32
31
|
|
|
32
|
+
_defineProperty(this, "startView", (key, name, context = {}, timestampMs = timeProvider.now()) => {
|
|
33
|
+
InternalLog.log(`Starting RUM View “${name}” #${key}`, SdkVerbosity.DEBUG);
|
|
34
|
+
return bufferVoidNativeCall(() => this.nativeRum.startView(key, name, context, timestampMs));
|
|
35
|
+
});
|
|
36
|
+
|
|
37
|
+
_defineProperty(this, "stopView", (key, context = {}, timestampMs = timeProvider.now()) => {
|
|
38
|
+
InternalLog.log(`Stopping RUM View #${key}`, SdkVerbosity.DEBUG);
|
|
39
|
+
return bufferVoidNativeCall(() => this.nativeRum.stopView(key, context, timestampMs));
|
|
40
|
+
});
|
|
41
|
+
|
|
42
|
+
_defineProperty(this, "startAction", (type, name, context = {}, timestampMs = timeProvider.now()) => {
|
|
43
|
+
InternalLog.log(`Starting RUM Action “${name}” (${type})`, SdkVerbosity.DEBUG);
|
|
44
|
+
this.lastActionData = {
|
|
45
|
+
type,
|
|
46
|
+
name
|
|
47
|
+
};
|
|
48
|
+
return bufferVoidNativeCall(() => this.nativeRum.startAction(type, name, context, timestampMs));
|
|
49
|
+
});
|
|
50
|
+
|
|
51
|
+
_defineProperty(this, "stopAction", (...args) => {
|
|
52
|
+
InternalLog.log('Stopping current RUM Action', SdkVerbosity.DEBUG);
|
|
53
|
+
const nativeCallArgs = this.getStopActionNativeCallArgs(args);
|
|
54
|
+
this.lastActionData = undefined;
|
|
55
|
+
|
|
56
|
+
if (!nativeCallArgs) {
|
|
57
|
+
return generateEmptyPromise();
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
return this.callNativeStopAction(...nativeCallArgs);
|
|
61
|
+
});
|
|
62
|
+
|
|
33
63
|
_defineProperty(this, "callNativeStopAction", (type, name, context, timestampMs) => {
|
|
34
64
|
const mappedEvent = this.actionEventMapper.applyEventMapper({
|
|
35
65
|
type,
|
|
@@ -69,121 +99,90 @@ class DdRumWrapper {
|
|
|
69
99
|
|
|
70
100
|
return null;
|
|
71
101
|
});
|
|
72
|
-
}
|
|
73
102
|
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
103
|
+
_defineProperty(this, "addAction", (type, name, context = {}, timestampMs = timeProvider.now(), actionContext) => {
|
|
104
|
+
const mappedEvent = this.actionEventMapper.applyEventMapper({
|
|
105
|
+
type,
|
|
106
|
+
name,
|
|
107
|
+
context,
|
|
108
|
+
timestampMs,
|
|
109
|
+
actionContext
|
|
110
|
+
});
|
|
78
111
|
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
}
|
|
112
|
+
if (!mappedEvent) {
|
|
113
|
+
return generateEmptyPromise();
|
|
114
|
+
}
|
|
83
115
|
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
type,
|
|
88
|
-
name
|
|
89
|
-
};
|
|
90
|
-
return bufferVoidNativeCall(() => this.nativeRum.startAction(type, name, context, timestampMs));
|
|
91
|
-
}
|
|
116
|
+
InternalLog.log(`Adding RUM Action “${name}” (${type})`, SdkVerbosity.DEBUG);
|
|
117
|
+
return bufferVoidNativeCall(() => this.nativeRum.addAction(mappedEvent.type, mappedEvent.name, mappedEvent.context, mappedEvent.timestampMs));
|
|
118
|
+
});
|
|
92
119
|
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
120
|
+
_defineProperty(this, "startResource", (key, method, url, context = {}, timestampMs = timeProvider.now()) => {
|
|
121
|
+
InternalLog.log(`Starting RUM Resource #${key} ${method}: ${url}`, SdkVerbosity.DEBUG);
|
|
122
|
+
return bufferVoidNativeCall(() => this.nativeRum.startResource(key, method, url, context, timestampMs));
|
|
123
|
+
});
|
|
97
124
|
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
125
|
+
_defineProperty(this, "stopResource", (key, statusCode, kind, size = -1, context = {}, timestampMs = timeProvider.now(), resourceContext) => {
|
|
126
|
+
const mappedEvent = this.resourceEventMapper.applyEventMapper({
|
|
127
|
+
key,
|
|
128
|
+
statusCode,
|
|
129
|
+
kind,
|
|
130
|
+
size,
|
|
131
|
+
context,
|
|
132
|
+
timestampMs,
|
|
133
|
+
resourceContext
|
|
134
|
+
});
|
|
101
135
|
|
|
102
|
-
|
|
103
|
-
|
|
136
|
+
if (!mappedEvent) {
|
|
137
|
+
/**
|
|
138
|
+
* To drop the resource we call `stopResource` and pass the `_dd.drop_resource` attribute in the context.
|
|
139
|
+
* It will be picked up by the resource mappers we implement on the native side that will drop the resource.
|
|
140
|
+
* This ensures we don't have any "started" resource left in memory on the native side.
|
|
141
|
+
*/
|
|
142
|
+
return bufferVoidNativeCall(() => this.nativeRum.stopResource(key, statusCode, kind, size, {
|
|
143
|
+
'_dd.resource.drop_resource': true
|
|
144
|
+
}, timestampMs));
|
|
145
|
+
}
|
|
104
146
|
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
type,
|
|
108
|
-
name,
|
|
109
|
-
context,
|
|
110
|
-
timestampMs,
|
|
111
|
-
actionContext
|
|
147
|
+
InternalLog.log(`Stopping RUM Resource #${key} status:${statusCode}`, SdkVerbosity.DEBUG);
|
|
148
|
+
return bufferVoidNativeCall(() => this.nativeRum.stopResource(mappedEvent.key, mappedEvent.statusCode, mappedEvent.kind, mappedEvent.size, mappedEvent.context, mappedEvent.timestampMs));
|
|
112
149
|
});
|
|
113
150
|
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
151
|
+
_defineProperty(this, "addError", (message, source, stacktrace, context = {}, timestampMs = timeProvider.now()) => {
|
|
152
|
+
const mappedEvent = this.errorEventMapper.applyEventMapper({
|
|
153
|
+
message,
|
|
154
|
+
source,
|
|
155
|
+
stacktrace,
|
|
156
|
+
context,
|
|
157
|
+
timestampMs
|
|
158
|
+
});
|
|
121
159
|
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
}
|
|
160
|
+
if (!mappedEvent) {
|
|
161
|
+
return generateEmptyPromise();
|
|
162
|
+
}
|
|
126
163
|
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
kind,
|
|
132
|
-
size,
|
|
133
|
-
context,
|
|
134
|
-
timestampMs,
|
|
135
|
-
resourceContext
|
|
164
|
+
InternalLog.log(`Adding RUM Error “${message}”`, SdkVerbosity.DEBUG);
|
|
165
|
+
const updatedContext = mappedEvent.context;
|
|
166
|
+
updatedContext['_dd.error.source_type'] = 'react-native';
|
|
167
|
+
return bufferVoidNativeCall(() => this.nativeRum.addError(mappedEvent.message, mappedEvent.source, mappedEvent.stacktrace, updatedContext, mappedEvent.timestampMs));
|
|
136
168
|
});
|
|
137
169
|
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
* It will be picked up by the resource mappers we implement on the native side that will drop the resource.
|
|
142
|
-
* This ensures we don't have any "started" resource left in memory on the native side.
|
|
143
|
-
*/
|
|
144
|
-
return bufferVoidNativeCall(() => this.nativeRum.stopResource(key, statusCode, kind, size, {
|
|
145
|
-
'_dd.resource.drop_resource': true
|
|
146
|
-
}, timestampMs));
|
|
147
|
-
}
|
|
148
|
-
|
|
149
|
-
InternalLog.log(`Stopping RUM Resource #${key} status:${statusCode}`, SdkVerbosity.DEBUG);
|
|
150
|
-
return bufferVoidNativeCall(() => this.nativeRum.stopResource(mappedEvent.key, mappedEvent.statusCode, mappedEvent.kind, mappedEvent.size, mappedEvent.context, mappedEvent.timestampMs));
|
|
151
|
-
}
|
|
152
|
-
|
|
153
|
-
addError(message, source, stacktrace, context = {}, timestampMs = timeProvider.now()) {
|
|
154
|
-
const mappedEvent = this.errorEventMapper.applyEventMapper({
|
|
155
|
-
message,
|
|
156
|
-
source,
|
|
157
|
-
stacktrace,
|
|
158
|
-
context,
|
|
159
|
-
timestampMs
|
|
170
|
+
_defineProperty(this, "addTiming", name => {
|
|
171
|
+
InternalLog.log(`Adding timing “${name}” to RUM View`, SdkVerbosity.DEBUG);
|
|
172
|
+
return bufferVoidNativeCall(() => this.nativeRum.addTiming(name));
|
|
160
173
|
});
|
|
161
174
|
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
InternalLog.log(`Adding RUM Error “${message}”`, SdkVerbosity.DEBUG);
|
|
167
|
-
const updatedContext = mappedEvent.context;
|
|
168
|
-
updatedContext['_dd.error.source_type'] = 'react-native';
|
|
169
|
-
return bufferVoidNativeCall(() => this.nativeRum.addError(mappedEvent.message, mappedEvent.source, mappedEvent.stacktrace, updatedContext, mappedEvent.timestampMs));
|
|
170
|
-
}
|
|
171
|
-
|
|
172
|
-
addTiming(name) {
|
|
173
|
-
InternalLog.log(`Adding timing “${name}” to RUM View`, SdkVerbosity.DEBUG);
|
|
174
|
-
return bufferVoidNativeCall(() => this.nativeRum.addTiming(name));
|
|
175
|
-
}
|
|
176
|
-
|
|
177
|
-
stopSession() {
|
|
178
|
-
InternalLog.log('Stopping RUM Session', SdkVerbosity.DEBUG);
|
|
179
|
-
return bufferVoidNativeCall(() => this.nativeRum.stopSession());
|
|
180
|
-
}
|
|
175
|
+
_defineProperty(this, "stopSession", () => {
|
|
176
|
+
InternalLog.log('Stopping RUM Session', SdkVerbosity.DEBUG);
|
|
177
|
+
return bufferVoidNativeCall(() => this.nativeRum.stopSession());
|
|
178
|
+
});
|
|
181
179
|
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
180
|
+
_defineProperty(this, "addFeatureFlagEvaluation", (name, value) => {
|
|
181
|
+
InternalLog.log(`Adding feature flag evaluation for name: ${name} with value: ${JSON.stringify(value)}`, SdkVerbosity.DEBUG);
|
|
182
|
+
return bufferVoidNativeCall(() => this.nativeRum.addFeatureFlagEvaluation(name, {
|
|
183
|
+
value
|
|
184
|
+
}));
|
|
185
|
+
});
|
|
187
186
|
}
|
|
188
187
|
|
|
189
188
|
registerErrorEventMapper(errorEventMapper) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["DdRum.ts"],"names":["NativeModules","InternalLog","SdkVerbosity","TimeProvider","bufferVoidNativeCall","DdSdk","generateActionEventMapper","generateErrorEventMapper","generateResourceEventMapper","timeProvider","generateEmptyPromise","Promise","resolve","DdRumWrapper","DdRum","undefined","type","name","context","timestampMs","mappedEvent","actionEventMapper","applyEventMapper","nativeRum","stopAction","args","isNewStopActionAPI","now","isOldStopActionAPI","lastActionData","telemetryDebug","log","WARN","startView","key","DEBUG","stopView","startAction","nativeCallArgs","getStopActionNativeCallArgs","callNativeStopAction","addAction","actionContext","startResource","method","url","stopResource","statusCode","kind","size","resourceContext","resourceEventMapper","addError","message","source","stacktrace","errorEventMapper","updatedContext","addTiming","stopSession","addFeatureFlagEvaluation","value","JSON","stringify","registerErrorEventMapper","unregisterErrorEventMapper","registerResourceEventMapper","unregisterResourceEventMapper","registerActionEventMapper","unregisterActionEventMapper"],"mappings":";;AAAA;AACA;AACA;AACA;AACA;AAGA,SAASA,aAAT,QAA8B,cAA9B;AAEA,SAASC,WAAT,QAA4B,gBAA5B;AACA,SAASC,YAAT,QAA6B,iBAA7B;AACA,SAASC,YAAT,QAA6B,iBAA7B;AAEA,SAASC,oBAAT,QAAqC,gDAArC;AACA,SAASC,KAAT,QAAsB,cAAtB;AAGA,SAASC,yBAAT,QAA0C,kCAA1C;AAEA,SAASC,wBAAT,QAAyC,iCAAzC;AAEA,SAASC,2BAAT,QAA4C,oCAA5C;AAQA,MAAMC,YAAY,GAAG,IAAIN,YAAJ,EAArB;;AAEA,MAAMO,oBAAoB,GAAG,MAAM,IAAIC,OAAJ,CAAkBC,OAAO,IAAIA,OAAO,EAApC,CAAnC;;AAEA,MAAMC,YAAN,CAAwC;AAAA;AAAA,uCACCb,aAAa,CAACc,KADf;;AAAA;;AAAA,8CAGTP,wBAAwB,CAACQ,SAAD,CAHf;;AAAA,iDAINP,2BAA2B,CAACO,SAAD,CAJrB;;AAAA,+CAKRT,yBAAyB,CAACS,SAAD,CALjB;;AAAA,kDAoEL,CAC3BC,IAD2B,EAE3BC,IAF2B,EAG3BC,OAH2B,EAI3BC,WAJ2B,KAKX;AAChB,YAAMC,WAAW,GAAG,KAAKC,iBAAL,CAAuBC,gBAAvB,CAAwC;AACxDN,QAAAA,IADwD;AAExDC,QAAAA,IAFwD;AAGxDC,QAAAA,OAHwD;AAIxDC,QAAAA;AAJwD,OAAxC,CAApB;;AAMA,UAAI,CAACC,WAAL,EAAkB;AACd,eAAOhB,oBAAoB,CAAC,MACxB,KAAKmB,SAAL,CAAeC,UAAf,CACIR,IADJ,EAEIC,IAFJ,EAGI;AAC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,CAACiC,KAJjB;AAMA,WAAO/B,oBAAoB,CAAC,MACxB,KAAKmB,SAAL,CAAeqC,wBAAf,CAAwC3C,IAAxC,EAA8C;AAAE4C,MAAAA;AAAF,KAA9C,CADuB,CAA3B;AAGH;;AAEDG,EAAAA,wBAAwB,CAACR,gBAAD,EAAqC;AACzD,SAAKA,gBAAL,GAAwBjD,wBAAwB,CAACiD,gBAAD,CAAhD;AACH;;AAEDS,EAAAA,0BAA0B,GAAG;AACzB,SAAKT,gBAAL,GAAwBjD,wBAAwB,CAACQ,SAAD,CAAhD;AACH;;AAEDmD,EAAAA,2BAA2B,CAACf,mBAAD,EAA2C;AAClE,SAAKA,mBAAL,GAA2B3C,2BAA2B,CAClD2C,mBADkD,CAAtD;AAGH;;AAEDgB,EAAAA,6BAA6B,GAAG;AAC5B,SAAKhB,mBAAL,GAA2B3C,2BAA2B,CAACO,SAAD,CAAtD;AACH;;AAEDqD,EAAAA,yBAAyB,CAAC/C,iBAAD,EAAuC;AAC5D,SAAKA,iBAAL,GAAyBf,yBAAyB,CAACe,iBAAD,CAAlD;AACH;;AAEDgD,EAAAA,2BAA2B,GAAG;AAC1B,SAAKhD,iBAAL,GAAyBf,yBAAyB,CAACS,SAAD,CAAlD;AACH;;AAhVmC;;AAmVxC,MAAMW,kBAAkB,GACpBD,IADuB,IActB;AACD,SAAO,OAAOA,IAAI,CAAC,CAAD,CAAX,KAAmB,QAA1B;AACH,CAhBD;;AAkBA,MAAMG,kBAAkB,GACpBH,IADuB,IAS4B;AACnD,SAAO,OAAOA,IAAI,CAAC,CAAD,CAAX,KAAmB,QAAnB,IAA+B,OAAOA,IAAI,CAAC,CAAD,CAAX,KAAmB,WAAzD;AACH,CAXD;;AAaA,OAAO,MAAMX,KAAK,GAAG,IAAID,YAAJ,EAAd","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 { GestureResponderEvent } from 'react-native';\nimport { NativeModules } from 'react-native';\n\nimport { InternalLog } from '../InternalLog';\nimport { SdkVerbosity } from '../SdkVerbosity';\nimport { TimeProvider } from '../TimeProvider';\nimport type { DdNativeRumType } from '../nativeModulesTypes';\nimport { bufferVoidNativeCall } from '../sdk/DatadogProvider/Buffer/bufferNativeCall';\nimport { DdSdk } from '../sdk/DdSdk';\n\nimport type { ActionEventMapper } from './eventMappers/actionEventMapper';\nimport { generateActionEventMapper } from './eventMappers/actionEventMapper';\nimport type { ErrorEventMapper } from './eventMappers/errorEventMapper';\nimport { generateErrorEventMapper } from './eventMappers/errorEventMapper';\nimport type { ResourceEventMapper } from './eventMappers/resourceEventMapper';\nimport { generateResourceEventMapper } from './eventMappers/resourceEventMapper';\nimport type {\n DdRumType,\n RumActionType,\n ResourceKind,\n ErrorSource\n} from './types';\n\nconst timeProvider = new TimeProvider();\n\nconst generateEmptyPromise = () => new Promise<void>(resolve => resolve());\n\nclass DdRumWrapper implements DdRumType {\n private nativeRum: DdNativeRumType = NativeModules.DdRum;\n private lastActionData?: { type: RumActionType; name: string };\n private errorEventMapper = generateErrorEventMapper(undefined);\n private resourceEventMapper = generateResourceEventMapper(undefined);\n private actionEventMapper = generateActionEventMapper(undefined);\n\n startView(\n key: string,\n name: string,\n context: object = {},\n timestampMs: number = timeProvider.now()\n ): Promise<void> {\n InternalLog.log(\n `Starting RUM View “${name}” #${key}`,\n SdkVerbosity.DEBUG\n );\n return bufferVoidNativeCall(() =>\n this.nativeRum.startView(key, name, context, timestampMs)\n );\n }\n\n stopView(\n key: string,\n context: object = {},\n timestampMs: number = timeProvider.now()\n ): Promise<void> {\n InternalLog.log(`Stopping RUM View #${key}`, SdkVerbosity.DEBUG);\n return bufferVoidNativeCall(() =>\n this.nativeRum.stopView(key, context, timestampMs)\n );\n }\n\n startAction(\n type: RumActionType,\n name: string,\n context: object = {},\n timestampMs: number = timeProvider.now()\n ): Promise<void> {\n InternalLog.log(\n `Starting RUM Action “${name}” (${type})`,\n SdkVerbosity.DEBUG\n );\n this.lastActionData = { type, name };\n return bufferVoidNativeCall(() =>\n this.nativeRum.startAction(type, name, context, timestampMs)\n );\n }\n\n stopAction(\n ...args:\n | [\n type: RumActionType,\n name: string,\n context?: object,\n timestampMs?: number\n ]\n | [context?: object, timestampMs?: number]\n ): Promise<void> {\n InternalLog.log('Stopping current RUM Action', SdkVerbosity.DEBUG);\n const nativeCallArgs = this.getStopActionNativeCallArgs(args);\n this.lastActionData = undefined;\n if (!nativeCallArgs) {\n return generateEmptyPromise();\n }\n return this.callNativeStopAction(...nativeCallArgs);\n }\n\n private callNativeStopAction = (\n type: RumActionType,\n name: string,\n context: object,\n timestampMs: number\n ): Promise<void> => {\n const mappedEvent = this.actionEventMapper.applyEventMapper({\n type,\n name,\n context,\n timestampMs\n });\n if (!mappedEvent) {\n return bufferVoidNativeCall(() =>\n this.nativeRum.stopAction(\n type,\n name,\n {\n '_dd.action.drop_action': true\n },\n timestampMs\n )\n );\n }\n\n return bufferVoidNativeCall(() =>\n this.nativeRum.stopAction(\n mappedEvent.type,\n mappedEvent.name,\n mappedEvent.context,\n mappedEvent.timestampMs\n )\n );\n };\n\n private getStopActionNativeCallArgs = (\n args:\n | [\n type: RumActionType,\n name: string,\n context?: object,\n timestampMs?: number\n ]\n | [context?: object, timestampMs?: number]\n ):\n | [\n type: RumActionType,\n name: string,\n context: object,\n timestampMs: number\n ]\n | null => {\n if (isNewStopActionAPI(args)) {\n return [\n args[0],\n args[1],\n args[2] || {},\n args[3] || timeProvider.now()\n ];\n }\n if (isOldStopActionAPI(args)) {\n if (this.lastActionData) {\n DdSdk.telemetryDebug(\n 'DDdRum.stopAction called with the old signature'\n );\n const { type, name } = this.lastActionData;\n return [\n type,\n name,\n args[0] || {},\n args[1] || timeProvider.now()\n ];\n }\n InternalLog.log(\n 'DdRum.startAction needs to be called before DdRum.stopAction',\n SdkVerbosity.WARN\n );\n } else {\n InternalLog.log(\n 'DdRum.stopAction was called with wrong arguments',\n SdkVerbosity.WARN\n );\n }\n\n return null;\n };\n\n addAction(\n type: RumActionType,\n name: string,\n context: object = {},\n timestampMs: number = timeProvider.now(),\n actionContext?: GestureResponderEvent\n ): Promise<void> {\n const mappedEvent = this.actionEventMapper.applyEventMapper({\n type,\n name,\n context,\n timestampMs,\n actionContext\n });\n if (!mappedEvent) {\n return generateEmptyPromise();\n }\n InternalLog.log(\n `Adding RUM Action “${name}” (${type})`,\n SdkVerbosity.DEBUG\n );\n return bufferVoidNativeCall(() =>\n this.nativeRum.addAction(\n mappedEvent.type,\n mappedEvent.name,\n mappedEvent.context,\n mappedEvent.timestampMs\n )\n );\n }\n\n startResource(\n key: string,\n method: string,\n url: string,\n context: object = {},\n timestampMs: number = timeProvider.now()\n ): Promise<void> {\n InternalLog.log(\n `Starting RUM Resource #${key} ${method}: ${url}`,\n SdkVerbosity.DEBUG\n );\n return bufferVoidNativeCall(() =>\n this.nativeRum.startResource(key, method, url, context, timestampMs)\n );\n }\n\n stopResource(\n key: string,\n statusCode: number,\n kind: ResourceKind,\n size: number = -1,\n context: object = {},\n timestampMs: number = timeProvider.now(),\n resourceContext?: XMLHttpRequest\n ): Promise<void> {\n const mappedEvent = this.resourceEventMapper.applyEventMapper({\n key,\n statusCode,\n kind,\n size,\n context,\n timestampMs,\n resourceContext\n });\n if (!mappedEvent) {\n /**\n * To drop the resource we call `stopResource` and pass the `_dd.drop_resource` attribute in the context.\n * It will be picked up by the resource mappers we implement on the native side that will drop the resource.\n * This ensures we don't have any \"started\" resource left in memory on the native side.\n */\n return bufferVoidNativeCall(() =>\n this.nativeRum.stopResource(\n key,\n statusCode,\n kind,\n size,\n {\n '_dd.resource.drop_resource': true\n },\n timestampMs\n )\n );\n }\n\n InternalLog.log(\n `Stopping RUM Resource #${key} status:${statusCode}`,\n SdkVerbosity.DEBUG\n );\n return bufferVoidNativeCall(() =>\n this.nativeRum.stopResource(\n mappedEvent.key,\n mappedEvent.statusCode,\n mappedEvent.kind,\n mappedEvent.size,\n mappedEvent.context,\n mappedEvent.timestampMs\n )\n );\n }\n\n addError(\n message: string,\n source: ErrorSource,\n stacktrace: string,\n context: object = {},\n timestampMs: number = timeProvider.now()\n ): Promise<void> {\n const mappedEvent = this.errorEventMapper.applyEventMapper({\n message,\n source,\n stacktrace,\n context,\n timestampMs\n });\n if (!mappedEvent) {\n return generateEmptyPromise();\n }\n InternalLog.log(`Adding RUM Error “${message}”`, SdkVerbosity.DEBUG);\n const updatedContext: any = mappedEvent.context;\n updatedContext['_dd.error.source_type'] = 'react-native';\n return bufferVoidNativeCall(() =>\n this.nativeRum.addError(\n mappedEvent.message,\n mappedEvent.source,\n mappedEvent.stacktrace,\n updatedContext,\n mappedEvent.timestampMs\n )\n );\n }\n\n addTiming(name: string): Promise<void> {\n InternalLog.log(\n `Adding timing “${name}” to RUM View`,\n SdkVerbosity.DEBUG\n );\n return bufferVoidNativeCall(() => this.nativeRum.addTiming(name));\n }\n\n stopSession(): Promise<void> {\n InternalLog.log('Stopping RUM Session', SdkVerbosity.DEBUG);\n return bufferVoidNativeCall(() => this.nativeRum.stopSession());\n }\n\n addFeatureFlagEvaluation(name: string, value: unknown): Promise<void> {\n InternalLog.log(\n `Adding feature flag evaluation for name: ${name} with value: ${JSON.stringify(\n value\n )}`,\n SdkVerbosity.DEBUG\n );\n return bufferVoidNativeCall(() =>\n this.nativeRum.addFeatureFlagEvaluation(name, { value })\n );\n }\n\n registerErrorEventMapper(errorEventMapper: ErrorEventMapper) {\n this.errorEventMapper = generateErrorEventMapper(errorEventMapper);\n }\n\n unregisterErrorEventMapper() {\n this.errorEventMapper = generateErrorEventMapper(undefined);\n }\n\n registerResourceEventMapper(resourceEventMapper: ResourceEventMapper) {\n this.resourceEventMapper = generateResourceEventMapper(\n resourceEventMapper\n );\n }\n\n unregisterResourceEventMapper() {\n this.resourceEventMapper = generateResourceEventMapper(undefined);\n }\n\n registerActionEventMapper(actionEventMapper: ActionEventMapper) {\n this.actionEventMapper = generateActionEventMapper(actionEventMapper);\n }\n\n unregisterActionEventMapper() {\n this.actionEventMapper = generateActionEventMapper(undefined);\n }\n}\n\nconst isNewStopActionAPI = (\n args:\n | [\n type: RumActionType,\n name: string,\n context?: object,\n timestampMs?: number\n ]\n | [context?: object, timestampMs?: number]\n): args is [\n type: RumActionType,\n name: string,\n context?: object,\n timestampMs?: number\n] => {\n return typeof args[0] === 'string';\n};\n\nconst isOldStopActionAPI = (\n args:\n | [\n type: RumActionType,\n name: string,\n context?: object,\n timestampMs?: number\n ]\n | [context?: object, timestampMs?: number]\n): args is [context?: object, timestampMs?: number] => {\n return typeof args[0] === 'object' || typeof args[0] === 'undefined';\n};\n\nexport const DdRum = new DdRumWrapper();\n"]}
|
|
1
|
+
{"version":3,"sources":["DdRum.ts"],"names":["InternalLog","SdkVerbosity","TimeProvider","bufferVoidNativeCall","DdSdk","generateActionEventMapper","generateErrorEventMapper","generateResourceEventMapper","timeProvider","generateEmptyPromise","Promise","resolve","DdRumWrapper","require","default","undefined","key","name","context","timestampMs","now","log","DEBUG","nativeRum","startView","stopView","type","lastActionData","startAction","args","nativeCallArgs","getStopActionNativeCallArgs","callNativeStopAction","mappedEvent","actionEventMapper","applyEventMapper","stopAction","isNewStopActionAPI","isOldStopActionAPI","telemetryDebug","WARN","actionContext","addAction","method","url","startResource","statusCode","kind","size","resourceContext","resourceEventMapper","stopResource","message","source","stacktrace","errorEventMapper","updatedContext","addError","addTiming","stopSession","value","JSON","stringify","addFeatureFlagEvaluation","registerErrorEventMapper","unregisterErrorEventMapper","registerResourceEventMapper","unregisterResourceEventMapper","registerActionEventMapper","unregisterActionEventMapper","DdRum"],"mappings":";;AAAA;AACA;AACA;AACA;AACA;AAIA,SAASA,WAAT,QAA4B,gBAA5B;AACA,SAASC,YAAT,QAA6B,iBAA7B;AACA,SAASC,YAAT,QAA6B,iBAA7B;AAEA,SAASC,oBAAT,QAAqC,gDAArC;AACA,SAASC,KAAT,QAAsB,cAAtB;A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AChB,mBAAD,EAA2C;AAClE,SAAKA,mBAAL,GAA2B3C,2BAA2B,CAClD2C,mBADkD,CAAtD;AAGH;;AAEDiB,EAAAA,6BAA6B,GAAG;AAC5B,SAAKjB,mBAAL,GAA2B3C,2BAA2B,CAACQ,SAAD,CAAtD;AACH;;AAEDqD,EAAAA,yBAAyB,CAAClC,iBAAD,EAAuC;AAC5D,SAAKA,iBAAL,GAAyB7B,yBAAyB,CAAC6B,iBAAD,CAAlD;AACH;;AAEDmC,EAAAA,2BAA2B,GAAG;AAC1B,SAAKnC,iBAAL,GAAyB7B,yBAAyB,CAACU,SAAD,CAAlD;AACH;;AArVmC;;AAwVxC,MAAMsB,kBAAkB,GACpBR,IADuB,IActB;AACD,SAAO,OAAOA,IAAI,CAAC,CAAD,CAAX,KAAmB,QAA1B;AACH,CAhBD;;AAkBA,MAAMS,kBAAkB,GACpBT,IADuB,IAS4B;AACnD,SAAO,OAAOA,IAAI,CAAC,CAAD,CAAX,KAAmB,QAAnB,IAA+B,OAAOA,IAAI,CAAC,CAAD,CAAX,KAAmB,WAAzD;AACH,CAXD;;AAaA,OAAO,MAAMyC,KAAK,GAAG,IAAI1D,YAAJ,EAAd","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 { GestureResponderEvent } from 'react-native';\n\nimport { InternalLog } from '../InternalLog';\nimport { SdkVerbosity } from '../SdkVerbosity';\nimport { TimeProvider } from '../TimeProvider';\nimport type { DdNativeRumType } from '../nativeModulesTypes';\nimport { bufferVoidNativeCall } from '../sdk/DatadogProvider/Buffer/bufferNativeCall';\nimport { DdSdk } from '../sdk/DdSdk';\n\nimport type { ActionEventMapper } from './eventMappers/actionEventMapper';\nimport { generateActionEventMapper } from './eventMappers/actionEventMapper';\nimport type { ErrorEventMapper } from './eventMappers/errorEventMapper';\nimport { generateErrorEventMapper } from './eventMappers/errorEventMapper';\nimport type { ResourceEventMapper } from './eventMappers/resourceEventMapper';\nimport { generateResourceEventMapper } from './eventMappers/resourceEventMapper';\nimport type {\n DdRumType,\n RumActionType,\n ResourceKind,\n ErrorSource\n} from './types';\n\nconst timeProvider = new TimeProvider();\n\nconst generateEmptyPromise = () => new Promise<void>(resolve => resolve());\n\nclass DdRumWrapper implements DdRumType {\n // eslint-disable-next-line global-require, @typescript-eslint/no-var-requires\n private nativeRum: DdNativeRumType = require('../specs/NativeDdRum')\n .default;\n private lastActionData?: { type: RumActionType; name: string };\n private errorEventMapper = generateErrorEventMapper(undefined);\n private resourceEventMapper = generateResourceEventMapper(undefined);\n private actionEventMapper = generateActionEventMapper(undefined);\n\n startView = (\n key: string,\n name: string,\n context: object = {},\n timestampMs: number = timeProvider.now()\n ): Promise<void> => {\n InternalLog.log(\n `Starting RUM View “${name}” #${key}`,\n SdkVerbosity.DEBUG\n );\n return bufferVoidNativeCall(() =>\n this.nativeRum.startView(key, name, context, timestampMs)\n );\n };\n\n stopView = (\n key: string,\n context: object = {},\n timestampMs: number = timeProvider.now()\n ): Promise<void> => {\n InternalLog.log(`Stopping RUM View #${key}`, SdkVerbosity.DEBUG);\n return bufferVoidNativeCall(() =>\n this.nativeRum.stopView(key, context, timestampMs)\n );\n };\n\n startAction = (\n type: RumActionType,\n name: string,\n context: object = {},\n timestampMs: number = timeProvider.now()\n ): Promise<void> => {\n InternalLog.log(\n `Starting RUM Action “${name}” (${type})`,\n SdkVerbosity.DEBUG\n );\n this.lastActionData = { type, name };\n return bufferVoidNativeCall(() =>\n this.nativeRum.startAction(type, name, context, timestampMs)\n );\n };\n\n stopAction = (\n ...args:\n | [\n type: RumActionType,\n name: string,\n context?: object,\n timestampMs?: number\n ]\n | [context?: object, timestampMs?: number]\n ): Promise<void> => {\n InternalLog.log('Stopping current RUM Action', SdkVerbosity.DEBUG);\n const nativeCallArgs = this.getStopActionNativeCallArgs(args);\n this.lastActionData = undefined;\n if (!nativeCallArgs) {\n return generateEmptyPromise();\n }\n return this.callNativeStopAction(...nativeCallArgs);\n };\n\n private callNativeStopAction = (\n type: RumActionType,\n name: string,\n context: object,\n timestampMs: number\n ): Promise<void> => {\n const mappedEvent = this.actionEventMapper.applyEventMapper({\n type,\n name,\n context,\n timestampMs\n });\n if (!mappedEvent) {\n return bufferVoidNativeCall(() =>\n this.nativeRum.stopAction(\n type,\n name,\n {\n '_dd.action.drop_action': true\n },\n timestampMs\n )\n );\n }\n\n return bufferVoidNativeCall(() =>\n this.nativeRum.stopAction(\n mappedEvent.type,\n mappedEvent.name,\n mappedEvent.context,\n mappedEvent.timestampMs\n )\n );\n };\n\n private getStopActionNativeCallArgs = (\n args:\n | [\n type: RumActionType,\n name: string,\n context?: object,\n timestampMs?: number\n ]\n | [context?: object, timestampMs?: number]\n ):\n | [\n type: RumActionType,\n name: string,\n context: object,\n timestampMs: number\n ]\n | null => {\n if (isNewStopActionAPI(args)) {\n return [\n args[0],\n args[1],\n args[2] || {},\n args[3] || timeProvider.now()\n ];\n }\n if (isOldStopActionAPI(args)) {\n if (this.lastActionData) {\n DdSdk.telemetryDebug(\n 'DDdRum.stopAction called with the old signature'\n );\n const { type, name } = this.lastActionData;\n return [\n type,\n name,\n args[0] || {},\n args[1] || timeProvider.now()\n ];\n }\n InternalLog.log(\n 'DdRum.startAction needs to be called before DdRum.stopAction',\n SdkVerbosity.WARN\n );\n } else {\n InternalLog.log(\n 'DdRum.stopAction was called with wrong arguments',\n SdkVerbosity.WARN\n );\n }\n\n return null;\n };\n\n addAction = (\n type: RumActionType,\n name: string,\n context: object = {},\n timestampMs: number = timeProvider.now(),\n actionContext?: GestureResponderEvent\n ): Promise<void> => {\n const mappedEvent = this.actionEventMapper.applyEventMapper({\n type,\n name,\n context,\n timestampMs,\n actionContext\n });\n if (!mappedEvent) {\n return generateEmptyPromise();\n }\n InternalLog.log(\n `Adding RUM Action “${name}” (${type})`,\n SdkVerbosity.DEBUG\n );\n return bufferVoidNativeCall(() =>\n this.nativeRum.addAction(\n mappedEvent.type,\n mappedEvent.name,\n mappedEvent.context,\n mappedEvent.timestampMs\n )\n );\n };\n\n startResource = (\n key: string,\n method: string,\n url: string,\n context: object = {},\n timestampMs: number = timeProvider.now()\n ): Promise<void> => {\n InternalLog.log(\n `Starting RUM Resource #${key} ${method}: ${url}`,\n SdkVerbosity.DEBUG\n );\n return bufferVoidNativeCall(() =>\n this.nativeRum.startResource(key, method, url, context, timestampMs)\n );\n };\n\n stopResource = (\n key: string,\n statusCode: number,\n kind: ResourceKind,\n size: number = -1,\n context: object = {},\n timestampMs: number = timeProvider.now(),\n resourceContext?: XMLHttpRequest\n ): Promise<void> => {\n const mappedEvent = this.resourceEventMapper.applyEventMapper({\n key,\n statusCode,\n kind,\n size,\n context,\n timestampMs,\n resourceContext\n });\n if (!mappedEvent) {\n /**\n * To drop the resource we call `stopResource` and pass the `_dd.drop_resource` attribute in the context.\n * It will be picked up by the resource mappers we implement on the native side that will drop the resource.\n * This ensures we don't have any \"started\" resource left in memory on the native side.\n */\n return bufferVoidNativeCall(() =>\n this.nativeRum.stopResource(\n key,\n statusCode,\n kind,\n size,\n {\n '_dd.resource.drop_resource': true\n },\n timestampMs\n )\n );\n }\n\n InternalLog.log(\n `Stopping RUM Resource #${key} status:${statusCode}`,\n SdkVerbosity.DEBUG\n );\n return bufferVoidNativeCall(() =>\n this.nativeRum.stopResource(\n mappedEvent.key,\n mappedEvent.statusCode,\n mappedEvent.kind,\n mappedEvent.size,\n mappedEvent.context,\n mappedEvent.timestampMs\n )\n );\n };\n\n addError = (\n message: string,\n source: ErrorSource,\n stacktrace: string,\n context: object = {},\n timestampMs: number = timeProvider.now()\n ): Promise<void> => {\n const mappedEvent = this.errorEventMapper.applyEventMapper({\n message,\n source,\n stacktrace,\n context,\n timestampMs\n });\n if (!mappedEvent) {\n return generateEmptyPromise();\n }\n InternalLog.log(`Adding RUM Error “${message}”`, SdkVerbosity.DEBUG);\n const updatedContext: any = mappedEvent.context;\n updatedContext['_dd.error.source_type'] = 'react-native';\n return bufferVoidNativeCall(() =>\n this.nativeRum.addError(\n mappedEvent.message,\n mappedEvent.source,\n mappedEvent.stacktrace,\n updatedContext,\n mappedEvent.timestampMs\n )\n );\n };\n\n addTiming = (name: string): Promise<void> => {\n InternalLog.log(\n `Adding timing “${name}” to RUM View`,\n SdkVerbosity.DEBUG\n );\n return bufferVoidNativeCall(() => this.nativeRum.addTiming(name));\n };\n\n stopSession = (): Promise<void> => {\n InternalLog.log('Stopping RUM Session', SdkVerbosity.DEBUG);\n return bufferVoidNativeCall(() => this.nativeRum.stopSession());\n };\n\n addFeatureFlagEvaluation = (\n name: string,\n value: unknown\n ): Promise<void> => {\n InternalLog.log(\n `Adding feature flag evaluation for name: ${name} with value: ${JSON.stringify(\n value\n )}`,\n SdkVerbosity.DEBUG\n );\n return bufferVoidNativeCall(() =>\n this.nativeRum.addFeatureFlagEvaluation(name, { value })\n );\n };\n\n registerErrorEventMapper(errorEventMapper: ErrorEventMapper) {\n this.errorEventMapper = generateErrorEventMapper(errorEventMapper);\n }\n\n unregisterErrorEventMapper() {\n this.errorEventMapper = generateErrorEventMapper(undefined);\n }\n\n registerResourceEventMapper(resourceEventMapper: ResourceEventMapper) {\n this.resourceEventMapper = generateResourceEventMapper(\n resourceEventMapper\n );\n }\n\n unregisterResourceEventMapper() {\n this.resourceEventMapper = generateResourceEventMapper(undefined);\n }\n\n registerActionEventMapper(actionEventMapper: ActionEventMapper) {\n this.actionEventMapper = generateActionEventMapper(actionEventMapper);\n }\n\n unregisterActionEventMapper() {\n this.actionEventMapper = generateActionEventMapper(undefined);\n }\n}\n\nconst isNewStopActionAPI = (\n args:\n | [\n type: RumActionType,\n name: string,\n context?: object,\n timestampMs?: number\n ]\n | [context?: object, timestampMs?: number]\n): args is [\n type: RumActionType,\n name: string,\n context?: object,\n timestampMs?: number\n] => {\n return typeof args[0] === 'string';\n};\n\nconst isOldStopActionAPI = (\n args:\n | [\n type: RumActionType,\n name: string,\n context?: object,\n timestampMs?: number\n ]\n | [context?: object, timestampMs?: number]\n): args is [context?: object, timestampMs?: number] => {\n return typeof args[0] === 'object' || typeof args[0] === 'undefined';\n};\n\nexport const DdRum = new DdRumWrapper();\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["errorEventMapper.ts"],"names":["EventMapper","generateErrorEventMapper","eventMapper","formatRawErrorToErrorEvent","formatErrorEventToNativeError","formatRawErrorToNativeError","error","additionalInformation"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AAGA,SAASA,WAAT,QAA4B,oCAA5B;AAuBA,OAAO,MAAMC,wBAAwB,GACjCC,WADoC,IAGpC,IAAIF,WAAJ,CACIE,WADJ,EAEIC,0BAFJ,EAGIC,6BAHJ,EAIIC,2BAJJ,CAHG;;AAUP,MAAMF,0BAA0B,GAAG,CAC/BG,KAD+B,EAE/BC,qBAF+B,KAGlB;AACb,SAAO,EACH,GAAGD,KADA;AAEH,OAAGC;AAFA,GAAP;AAIH,CARD;;AAUA,MAAMF,2BAA2B,GAAIC,KAAD,IAAkC;AAClE,SAAOA,KAAP;AACH,CAFD;;AAIA,MAAMF,6BAA6B,GAAIE,KAAD,IAAoC;AACtE,SAAOA,KAAP;AACH,CAFD","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 { AdditionalEventDataForMapper } from '../../sdk/EventMappers/EventMapper';\nimport { EventMapper } from '../../sdk/EventMappers/EventMapper';\nimport type { ErrorSource } from '../types';\n\ntype RawError = {\n message: string;\n source: ErrorSource;\n stacktrace: string;\n context
|
|
1
|
+
{"version":3,"sources":["errorEventMapper.ts"],"names":["EventMapper","generateErrorEventMapper","eventMapper","formatRawErrorToErrorEvent","formatErrorEventToNativeError","formatRawErrorToNativeError","error","additionalInformation"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AAGA,SAASA,WAAT,QAA4B,oCAA5B;AAuBA,OAAO,MAAMC,wBAAwB,GACjCC,WADoC,IAGpC,IAAIF,WAAJ,CACIE,WADJ,EAEIC,0BAFJ,EAGIC,6BAHJ,EAIIC,2BAJJ,CAHG;;AAUP,MAAMF,0BAA0B,GAAG,CAC/BG,KAD+B,EAE/BC,qBAF+B,KAGlB;AACb,SAAO,EACH,GAAGD,KADA;AAEH,OAAGC;AAFA,GAAP;AAIH,CARD;;AAUA,MAAMF,2BAA2B,GAAIC,KAAD,IAAkC;AAClE,SAAOA,KAAP;AACH,CAFD;;AAIA,MAAMF,6BAA6B,GAAIE,KAAD,IAAoC;AACtE,SAAOA,KAAP;AACH,CAFD","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 { AdditionalEventDataForMapper } from '../../sdk/EventMappers/EventMapper';\nimport { EventMapper } from '../../sdk/EventMappers/EventMapper';\nimport type { ErrorSource } from '../types';\n\ntype RawError = {\n message: string;\n source: ErrorSource;\n stacktrace: string;\n context: object;\n timestampMs: number;\n};\n\ntype ErrorEvent = RawError & AdditionalEventDataForMapper;\n\ntype NativeError = {\n message: string;\n source: ErrorSource;\n stacktrace: string;\n context: object;\n timestampMs: number;\n};\n\nexport type ErrorEventMapper = (event: ErrorEvent) => ErrorEvent | null;\n\nexport const generateErrorEventMapper = (\n eventMapper: ErrorEventMapper | undefined\n) =>\n new EventMapper(\n eventMapper,\n formatRawErrorToErrorEvent,\n formatErrorEventToNativeError,\n formatRawErrorToNativeError\n );\n\nconst formatRawErrorToErrorEvent = (\n error: RawError,\n additionalInformation: AdditionalEventDataForMapper\n): ErrorEvent => {\n return {\n ...error,\n ...additionalInformation\n };\n};\n\nconst formatRawErrorToNativeError = (error: RawError): NativeError => {\n return error;\n};\n\nconst formatErrorEventToNativeError = (error: ErrorEvent): NativeError => {\n return error;\n};\n"]}
|
|
@@ -14,8 +14,14 @@ const DEBOUNCE_EVENT_THRESHOLD_IN_MS = 10;
|
|
|
14
14
|
const HANDLE_EVENT_APP_EXECUTION_TIME_IN_MS = 1;
|
|
15
15
|
const DD_ACTION_NAME_PROP = 'dd-action-name';
|
|
16
16
|
export class DdEventsInterceptor {
|
|
17
|
-
constructor(
|
|
17
|
+
constructor({
|
|
18
|
+
actionNameAttribute
|
|
19
|
+
} = {}) {
|
|
18
20
|
_defineProperty(this, "debouncingStartedTimestamp", Number.MIN_VALUE);
|
|
21
|
+
|
|
22
|
+
_defineProperty(this, "actionNameAttribute", void 0);
|
|
23
|
+
|
|
24
|
+
this.actionNameAttribute = actionNameAttribute;
|
|
19
25
|
}
|
|
20
26
|
|
|
21
27
|
interceptOnPress(...args) {
|
|
@@ -82,6 +88,10 @@ export class DdEventsInterceptor {
|
|
|
82
88
|
return props[DD_ACTION_NAME_PROP];
|
|
83
89
|
}
|
|
84
90
|
|
|
91
|
+
if (this.actionNameAttribute && props && props[this.actionNameAttribute]) {
|
|
92
|
+
return props[this.actionNameAttribute];
|
|
93
|
+
}
|
|
94
|
+
|
|
85
95
|
currentNode = currentNode.return;
|
|
86
96
|
}
|
|
87
97
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["DdEventsInterceptor.tsx"],"names":["InternalLog","SdkVerbosity","DdRum","RumActionType","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_DEBUG_MESSAGE","DEBUG","event","resolvedTargetName","resolveTargetName","addAction","TAP","undefined","closestActionLabel","findClosestActionLabel","accessibilityLabel","memoizedProps","elementTypeName","resolveElementTypeName","elementType","name","currentNode","props","return"],"mappings":";;AAAA;AACA;AACA;AACA;AACA;AAIA,SAASA,WAAT,QAA4B,sBAA5B;AACA,SAASC,YAAT,QAA6B,uBAA7B;AACA,SAASC,KAAT,QAAsB,aAAtB;AACA,SAASC,aAAT,QAA8B,aAA9B;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;
|
|
1
|
+
{"version":3,"sources":["DdEventsInterceptor.tsx"],"names":["InternalLog","SdkVerbosity","DdRum","RumActionType","UNKNOWN_TARGET_NAME","DEBOUNCE_EVENT_THRESHOLD_IN_MS","HANDLE_EVENT_APP_EXECUTION_TIME_IN_MS","DD_ACTION_NAME_PROP","DdEventsInterceptor","constructor","actionNameAttribute","Number","MIN_VALUE","interceptOnPress","args","length","_targetInst","currentTime","Date","now","timestampDifference","Math","abs","debouncingStartedTimestamp","targetNode","handleTargetEvent","log","ACTION_EVENT_DROPPED_DEBUG_MESSAGE","DEBUG","event","resolvedTargetName","resolveTargetName","addAction","TAP","undefined","closestActionLabel","findClosestActionLabel","accessibilityLabel","memoizedProps","elementTypeName","resolveElementTypeName","elementType","name","currentNode","props","return"],"mappings":";;AAAA;AACA;AACA;AACA;AACA;AAIA,SAASA,WAAT,QAA4B,sBAA5B;AACA,SAASC,YAAT,QAA6B,uBAA7B;AACA,SAASC,KAAT,QAAsB,aAAtB;AACA,SAASC,aAAT,QAA8B,aAA9B;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;AAY1DC,EAAAA,WAAW,CAAC;AACRC,IAAAA;AADQ,MAE0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,IAA1B,EAAgC;AAC5B,aAAOA,kBAAP;AACH;;AACD,UAAME,kBAAkB,4BAAGb,UAAU,CAACc,aAAd,0DAAG,sBAA0BD,kBAArD;;AACA,QAAIA,kBAAkB,IAAI,IAA1B,EAAgC;AAC5B,aAAOA,kBAAP;AACH;;AACD,UAAME,eAAe,GAAG,KAAKC,sBAAL,CACpBhB,UAAU,CAACiB,WADS,CAAxB;AAGA,WAAOF,eAAe,IAAInC,mBAA1B;AACH;;AAEOoC,EAAAA,sBAAsB,CAACC,WAAD,EAAkC;AAC5D,QAAIF,eAAe,GAAG,IAAtB;;AACA,QAAI,OAAOE,WAAP,KAAuB,QAA3B,EAAqC;AACjCF,MAAAA,eAAe,GAAGE,WAAlB;AACH,KAFD,MAEO,IAAIA,WAAW,IAAI,OAAOA,WAAW,CAACC,IAAnB,KAA4B,QAA/C,EAAyD;AAC5DH,MAAAA,eAAe,GAAGE,WAAW,CAACC,IAA9B;AACH;;AACD,WAAOH,eAAP;AACH;;AAEOH,EAAAA,sBAAsB,CAACZ,UAAD,EAAiC;AAC3D,QAAImB,WAAW,GAAGnB,UAAlB;;AACA,WAAOmB,WAAP,EAAoB;AAChB,YAAMC,KAAK,GAAGD,WAAW,CAACL,aAA1B;;AACA,UAAIM,KAAK,IAAIA,KAAK,CAACrC,mBAAD,CAAlB,EAAyC;AACrC,eAAOqC,KAAK,CAACrC,mBAAD,CAAZ;AACH;;AACD,UACI,KAAKG,mBAAL,IACAkC,KADA,IAEAA,KAAK,CAAC,KAAKlC,mBAAN,CAHT,EAIE;AACE,eAAOkC,KAAK,CAAC,KAAKlC,mBAAN,CAAZ;AACH;;AACDiC,MAAAA,WAAW,GAAGA,WAAW,CAACE,MAA1B;AACH;;AACD,WAAO,IAAP;AACH;;AA9FyD;;gBAAjDrC,mB,wCAEL,8EACA,8DADA,GAEA,iFAFA,GAGA,4DAHA,GAIA,yC","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 { GestureResponderEvent } from 'react-native';\n\nimport { InternalLog } from '../../../InternalLog';\nimport { SdkVerbosity } from '../../../SdkVerbosity';\nimport { DdRum } from '../../DdRum';\nimport { RumActionType } from '../../types';\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_DEBUG_MESSAGE =\n 'An action event was dropped because either the `onPress` method arguments' +\n ' were undefined or they were missing the target information.' +\n ' This log can happen if you use an abstraction component with an `onPress` prop' +\n ' that does not receive the native event is first argument.' +\n ' In this case, you can ignore this log.';\n\n private debouncingStartedTimestamp = Number.MIN_VALUE;\n\n private actionNameAttribute?: string;\n\n constructor({\n actionNameAttribute\n }: { actionNameAttribute?: string } = {}) {\n this.actionNameAttribute = actionNameAttribute;\n }\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, args[0]);\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_DEBUG_MESSAGE,\n SdkVerbosity.DEBUG\n );\n }\n }\n\n private handleTargetEvent(targetNode: any, event: unknown) {\n if (targetNode) {\n const resolvedTargetName = this.resolveTargetName(targetNode);\n DdRum.addAction(\n RumActionType.TAP,\n resolvedTargetName,\n {},\n undefined,\n event as GestureResponderEvent\n );\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 if (\n this.actionNameAttribute &&\n props &&\n props[this.actionNameAttribute]\n ) {\n return props[this.actionNameAttribute];\n }\n currentNode = currentNode.return;\n }\n return null;\n }\n}\n"]}
|
|
@@ -25,14 +25,18 @@ export class DdRumUserInteractionTracking {
|
|
|
25
25
|
* Please note that we are only considering as valid - for - tracking only the user interactions that have
|
|
26
26
|
* a visible output (either an UI state change or a Resource request)
|
|
27
27
|
*/
|
|
28
|
-
static startTracking(
|
|
28
|
+
static startTracking({
|
|
29
|
+
actionNameAttribute
|
|
30
|
+
} = {}) {
|
|
29
31
|
// extra safety to avoid wrapping more than 1 time this function
|
|
30
32
|
if (DdRumUserInteractionTracking.isTracking) {
|
|
31
33
|
InternalLog.log('Datadog SDK is already tracking interactions', SdkVerbosity.WARN);
|
|
32
34
|
return;
|
|
33
35
|
}
|
|
34
36
|
|
|
35
|
-
DdRumUserInteractionTracking.eventsInterceptor = new DdEventsInterceptor(
|
|
37
|
+
DdRumUserInteractionTracking.eventsInterceptor = new DdEventsInterceptor({
|
|
38
|
+
actionNameAttribute
|
|
39
|
+
});
|
|
36
40
|
const original = React.createElement;
|
|
37
41
|
|
|
38
42
|
React.createElement = (...args) => {
|
package/lib/module/rum/instrumentation/interactionTracking/DdRumUserInteractionTracking.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["DdRumUserInteractionTracking.tsx"],"names":["React","InternalLog","SdkVerbosity","getErrorMessage","DdSdk","DdEventsInterceptor","NoOpEventsInterceptor","areObjectShallowEqual","getJsxRuntime","DdRumUserInteractionTracking","startTracking","isTracking","log","WARN","eventsInterceptor","original","createElement","args","patchCreateElementFunction","jsxRuntime","originaljsx","jsx","originalJsx","e","telemetryDebug","originalMemo","memo","component","propsAreEqual","prev","next","onPress","_prevOnPress","partialPrevProps","prevProps","__DATADOG_INTERNAL_ORIGINAL_ON_PRESS__","_nextOnPress","partialNextProps","nextProps","INFO","stopTracking","originalCreateElement","originalFunction","element","props","rest","originalOnPress","interceptOnPress"],"mappings":";;AAAA;AACA;AACA;AACA;AACA;AAEA,OAAOA,KAAP,MAAkB,OAAlB;AAEA,SAASC,WAAT,QAA4B,sBAA5B;AACA,SAASC,YAAT,QAA6B,uBAA7B;AACA,SAASC,eAAT,QAAgC,qBAAhC;AACA,SAASC,KAAT,QAAsB,oBAAtB;AAEA,SAASC,mBAAT,QAAoC,uBAApC;AAEA,OAAOC,qBAAP,MAAkC,yBAAlC;AACA,SAASC,qBAAT,QAAsC,gCAAtC;AACA,SAASC,aAAT,QAA8B,iBAA9B;AAEA;AACA;AACA;AACA;;AACA,OAAO,MAAMC,4BAAN,CAAmC;AAgCtC;AACJ;AACA;AACA;AACA;AACwB,SAAbC,aAAa,
|
|
1
|
+
{"version":3,"sources":["DdRumUserInteractionTracking.tsx"],"names":["React","InternalLog","SdkVerbosity","getErrorMessage","DdSdk","DdEventsInterceptor","NoOpEventsInterceptor","areObjectShallowEqual","getJsxRuntime","DdRumUserInteractionTracking","startTracking","actionNameAttribute","isTracking","log","WARN","eventsInterceptor","original","createElement","args","patchCreateElementFunction","jsxRuntime","originaljsx","jsx","originalJsx","e","telemetryDebug","originalMemo","memo","component","propsAreEqual","prev","next","onPress","_prevOnPress","partialPrevProps","prevProps","__DATADOG_INTERNAL_ORIGINAL_ON_PRESS__","_nextOnPress","partialNextProps","nextProps","INFO","stopTracking","originalCreateElement","originalFunction","element","props","rest","originalOnPress","interceptOnPress"],"mappings":";;AAAA;AACA;AACA;AACA;AACA;AAEA,OAAOA,KAAP,MAAkB,OAAlB;AAEA,SAASC,WAAT,QAA4B,sBAA5B;AACA,SAASC,YAAT,QAA6B,uBAA7B;AACA,SAASC,eAAT,QAAgC,qBAAhC;AACA,SAASC,KAAT,QAAsB,oBAAtB;AAEA,SAASC,mBAAT,QAAoC,uBAApC;AAEA,OAAOC,qBAAP,MAAkC,yBAAlC;AACA,SAASC,qBAAT,QAAsC,gCAAtC;AACA,SAASC,aAAT,QAA8B,iBAA9B;AAEA;AACA;AACA;AACA;;AACA,OAAO,MAAMC,4BAAN,CAAmC;AAgCtC;AACJ;AACA;AACA;AACA;AACwB,SAAbC,aAAa,CAAC;AACjBC,IAAAA;AADiB,MAEiB,EAFlB,EAE4B;AAC5C;AACA,QAAIF,4BAA4B,CAACG,UAAjC,EAA6C;AACzCX,MAAAA,WAAW,CAACY,GAAZ,CACI,8CADJ,EAEIX,YAAY,CAACY,IAFjB;AAIA;AACH;;AACDL,IAAAA,4BAA4B,CAACM,iBAA7B,GAAiD,IAAIV,mBAAJ,CAC7C;AAAEM,MAAAA;AAAF,KAD6C,CAAjD;AAIA,UAAMK,QAAQ,GAAGhB,KAAK,CAACiB,aAAvB;;AACAjB,IAAAA,KAAK,CAACiB,aAAN,GAAsB,CAClB,GAAGC,IADe,KAEZ;AACN,aAAO,KAAKC,0BAAL,CAAgCH,QAAhC,EAA0CE,IAA1C,CAAP;AACH,KAJD;;AAMA,QAAI;AACA,YAAME,UAAU,GAAGZ,aAAa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B,CAACC,OAAD,EAAUC,KAAV,EAAiB,GAAGC,IAApB,CAAvB;AACH,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 React from 'react';\n\nimport { InternalLog } from '../../../InternalLog';\nimport { SdkVerbosity } from '../../../SdkVerbosity';\nimport { getErrorMessage } from '../../../errorUtils';\nimport { DdSdk } from '../../../sdk/DdSdk';\n\nimport { DdEventsInterceptor } from './DdEventsInterceptor';\nimport type EventsInterceptor from './EventsInterceptor';\nimport NoOpEventsInterceptor from './NoOpEventsInterceptor';\nimport { areObjectShallowEqual } from './ShallowObjectEqualityChecker';\nimport { getJsxRuntime } from './getJsxRuntime';\n\n/**\n * Provides RUM auto-instrumentation feature to track user interaction as RUM events.\n * For now we are only covering the \"onPress\" events.\n */\nexport class DdRumUserInteractionTracking {\n private static isTracking = false;\n private static eventsInterceptor: EventsInterceptor = new NoOpEventsInterceptor();\n private static originalCreateElement = React.createElement;\n private static originalMemo = React.memo;\n private static originalJsx = null;\n\n private static patchCreateElementFunction = (\n originalFunction: typeof React.createElement,\n [element, props, ...rest]: Parameters<typeof React.createElement>\n ): ReturnType<typeof React.createElement> => {\n if (\n props &&\n typeof (props as Record<string, unknown>).onPress === 'function'\n ) {\n const originalOnPress = (props as Record<string, unknown>) // eslint-disable-next-line @typescript-eslint/ban-types\n .onPress as Function;\n (props as Record<string, unknown>).onPress = (...args: any[]) => {\n DdRumUserInteractionTracking.eventsInterceptor.interceptOnPress(\n ...args\n );\n return originalOnPress(...args);\n };\n // we store the original onPress prop so we can keep memoization working\n (props as Record<\n string,\n unknown\n >).__DATADOG_INTERNAL_ORIGINAL_ON_PRESS__ = originalOnPress;\n }\n return originalFunction(element, props, ...rest);\n };\n\n /**\n * Starts tracking user interactions and sends a RUM Action event every time a new interaction was detected.\n * Please note that we are only considering as valid - for - tracking only the user interactions that have\n * a visible output (either an UI state change or a Resource request)\n */\n static startTracking({\n actionNameAttribute\n }: { actionNameAttribute?: string } = {}): void {\n // extra safety to avoid wrapping more than 1 time this function\n if (DdRumUserInteractionTracking.isTracking) {\n InternalLog.log(\n 'Datadog SDK is already tracking interactions',\n SdkVerbosity.WARN\n );\n return;\n }\n DdRumUserInteractionTracking.eventsInterceptor = new DdEventsInterceptor(\n { actionNameAttribute }\n );\n\n const original = React.createElement;\n React.createElement = (\n ...args: Parameters<typeof React.createElement>\n ): any => {\n return this.patchCreateElementFunction(original, args);\n };\n\n try {\n const jsxRuntime = getJsxRuntime();\n const originaljsx = jsxRuntime.jsx;\n this.originalJsx = originaljsx;\n jsxRuntime.jsx = (\n ...args: Parameters<typeof React.createElement>\n ): ReturnType<typeof React.createElement> => {\n return this.patchCreateElementFunction(originaljsx, args);\n };\n } catch (e) {\n DdSdk.telemetryDebug(getErrorMessage(e));\n }\n\n const originalMemo = React.memo;\n\n React.memo = (\n component: any,\n propsAreEqual?: (prevProps: any, newProps: any) => boolean\n ) => {\n return originalMemo(component, (prev, next) => {\n if (!next.onPress || !prev.onPress) {\n return propsAreEqual\n ? propsAreEqual(prev, next)\n : areObjectShallowEqual(prev, next);\n }\n // we replace \"our\" onPress from the props by the original for comparison\n const { onPress: _prevOnPress, ...partialPrevProps } = prev;\n const prevProps = {\n ...partialPrevProps,\n onPress: prev.__DATADOG_INTERNAL_ORIGINAL_ON_PRESS__\n };\n\n const { onPress: _nextOnPress, ...partialNextProps } = next;\n const nextProps = {\n ...partialNextProps,\n onPress: next.__DATADOG_INTERNAL_ORIGINAL_ON_PRESS__\n };\n\n // if no comparison function is provided we do shallow comparison\n return propsAreEqual\n ? propsAreEqual(prevProps, nextProps)\n : areObjectShallowEqual(nextProps, prevProps);\n });\n };\n\n DdRumUserInteractionTracking.isTracking = true;\n InternalLog.log(\n 'Datadog SDK is tracking interactions',\n SdkVerbosity.INFO\n );\n }\n\n static stopTracking() {\n React.createElement = this.originalCreateElement;\n React.memo = this.originalMemo;\n DdRumUserInteractionTracking.isTracking = false;\n if (this.originalJsx) {\n const jsxRuntime = getJsxRuntime();\n jsxRuntime.jsx = this.originalJsx;\n this.originalJsx = null;\n }\n }\n}\n"]}
|
package/lib/module/sdk/DdSdk.js
CHANGED
|
@@ -3,7 +3,8 @@
|
|
|
3
3
|
* This product includes software developed at Datadog (https://www.datadoghq.com/).
|
|
4
4
|
* Copyright 2016-Present Datadog, Inc.
|
|
5
5
|
*/
|
|
6
|
-
|
|
7
|
-
const DdSdk =
|
|
6
|
+
// eslint-disable-next-line global-require, @typescript-eslint/no-var-requires
|
|
7
|
+
const DdSdk = require('../specs/NativeDdSdk').default;
|
|
8
|
+
|
|
8
9
|
export { DdSdk };
|
|
9
10
|
//# sourceMappingURL=DdSdk.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["DdSdk.ts"],"names":["
|
|
1
|
+
{"version":3,"sources":["DdSdk.ts"],"names":["DdSdk","require","default"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AAIA;AACA,MAAMA,KAAsB,GAAGC,OAAO,CAAC,sBAAD,CAAP,CAAgCC,OAA/D;;AAEA,SAASF,KAAT","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 { DdNativeSdkType } from '../nativeModulesTypes';\n\n// eslint-disable-next-line global-require, @typescript-eslint/no-var-requires\nconst DdSdk: DdNativeSdkType = require('../specs/NativeDdSdk').default;\n\nexport { DdSdk };\n"]}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Unless explicitly stated otherwise all files in this repository are licensed under the Apache License Version 2.0.
|
|
3
|
+
* This product includes software developed at Datadog (https://www.datadoghq.com/).
|
|
4
|
+
* Copyright 2016-Present Datadog, Inc.
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
/* eslint-disable @typescript-eslint/ban-types */
|
|
8
|
+
import { TurboModuleRegistry } from 'react-native';
|
|
9
|
+
/**
|
|
10
|
+
* Do not import this Spec directly, use DdNativeLogsType instead.
|
|
11
|
+
*/
|
|
12
|
+
|
|
13
|
+
export default TurboModuleRegistry.get('DdLogs');
|
|
14
|
+
//# sourceMappingURL=NativeDdLogs.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["NativeDdLogs.ts"],"names":["TurboModuleRegistry","get"],"mappings":"AAAA;AACA;AACA;AACA;AACA;;AAEA;AAEA,SAASA,mBAAT,QAAoC,cAApC;AAEA;AACA;AACA;;AAiGA,eAAeA,mBAAmB,CAACC,GAApB,CAA8B,QAA9B,CAAf","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/* eslint-disable @typescript-eslint/ban-types */\nimport type { TurboModule } from 'react-native';\nimport { TurboModuleRegistry } from 'react-native';\n\n/**\n * Do not import this Spec directly, use DdNativeLogsType instead.\n */\nexport interface Spec extends TurboModule {\n readonly getConstants: () => {};\n\n /**\n * Send a log with DEBUG level.\n * @param message: The message to send.\n * @param context: The additional context to send.\n */\n readonly debug: (message: string, context?: Object) => Promise<void>;\n\n /**\n * Send a log with INFO level.\n * @param message: The message to send.\n * @param context: The additional context to send.\n */\n readonly info: (message: string, context?: Object) => Promise<void>;\n\n /**\n * Send a log with WARN level.\n * @param message: The message to send.\n * @param context: The additional context to send.\n */\n readonly warn: (message: string, context?: Object) => Promise<void>;\n\n /**\n * Send a log with ERROR level.\n * @param message: The message to send.\n * @param context: The additional context to send.\n */\n readonly error: (message: string, context?: Object) => Promise<void>;\n\n /**\n * Send a log containing an error with DEBUG level.\n * @param message: The message to send.\n * @param errorKind: The error kind to send.\n * @param errorMessage: The error message to send.\n * @param stacktrace: The stack trace to send.\n * @param context: The additional context to send.\n */\n readonly debugWithError: (\n message: string,\n errorKind?: string,\n errorMessage?: string,\n stacktrace?: string,\n context?: Object\n ) => Promise<void>;\n\n /**\n * Send a log containing an error with INDO level.\n * @param message: The message to send.\n * @param errorKind: The error kind to send.\n * @param errorMessage: The error message to send.\n * @param stacktrace: The stack trace to send.\n * @param context: The additional context to send.\n */\n readonly infoWithError: (\n message: string,\n errorKind?: string,\n errorMessage?: string,\n stacktrace?: string,\n context?: Object\n ) => Promise<void>;\n\n /**\n * Send a log containing an error with WARN level.\n * @param message: The message to send.\n * @param errorKind: The error kind to send.\n * @param errorMessage: The error message to send.\n * @param stacktrace: The stack trace to send.\n * @param context: The additional context to send.\n */\n readonly warnWithError: (\n message: string,\n errorKind?: string,\n errorMessage?: string,\n stacktrace?: string,\n context?: Object\n ) => Promise<void>;\n\n /**\n * Send a log containing an error with ERROR level.\n * @param message: The message to send.\n * @param errorKind: The error kind to send.\n * @param errorMessage: The error message to send.\n * @param stacktrace: The stack trace to send.\n * @param context: The additional context to send.\n */\n readonly errorWithError: (\n message: string,\n errorKind?: string,\n errorMessage?: string,\n stacktrace?: string,\n context?: Object\n ) => Promise<void>;\n}\n\nexport default TurboModuleRegistry.get<Spec>('DdLogs');\n"]}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Unless explicitly stated otherwise all files in this repository are licensed under the Apache License Version 2.0.
|
|
3
|
+
* This product includes software developed at Datadog (https://www.datadoghq.com/).
|
|
4
|
+
* Copyright 2016-Present Datadog, Inc.
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
/* eslint-disable @typescript-eslint/ban-types */
|
|
8
|
+
import { TurboModuleRegistry } from 'react-native';
|
|
9
|
+
/**
|
|
10
|
+
* Do not import this Spec directly, use DdNativeRumType instead.
|
|
11
|
+
*/
|
|
12
|
+
|
|
13
|
+
export default TurboModuleRegistry.get('DdRum');
|
|
14
|
+
//# sourceMappingURL=NativeDdRum.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["NativeDdRum.ts"],"names":["TurboModuleRegistry","get"],"mappings":"AAAA;AACA;AACA;AACA;AACA;;AAEA;AAEA,SAASA,mBAAT,QAAoC,cAApC;AAEA;AACA;AACA;;AA0IA,eAAeA,mBAAmB,CAACC,GAApB,CAA8B,OAA9B,CAAf","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/* eslint-disable @typescript-eslint/ban-types */\nimport type { TurboModule } from 'react-native';\nimport { TurboModuleRegistry } from 'react-native';\n\n/**\n * Do not import this Spec directly, use DdNativeRumType instead.\n */\nexport interface Spec extends TurboModule {\n readonly getConstants: () => {};\n\n /**\n * Start tracking a RUM View.\n * @param key: The view unique key identifier.\n * @param name: The view name.\n * @param context: The additional context to send.\n * @param timestampMs: The timestamp when the view started (in milliseconds). If not provided, current timestamp will be used.\n */\n startView(\n key: string,\n name: string,\n context: Object,\n timestampMs: number\n ): Promise<void>;\n\n /**\n * Stop tracking a RUM View.\n * @param key: The view unique key identifier.\n * @param context: The additional context to send.\n * @param timestampMs: The timestamp when the view stopped (in milliseconds). If not provided, current timestamp will be used.\n */\n stopView(key: string, context: Object, timestampMs: number): Promise<void>;\n\n /**\n * Start tracking a RUM Action.\n * @param type: The action type (tap, scroll, swipe, back, custom).\n * @param name: The action name.\n * @param context: The additional context to send.\n * @param timestampMs: The timestamp when the action started (in milliseconds). If not provided, current timestamp will be used.\n */\n startAction(\n type: string,\n name: string,\n context: Object,\n timestampMs: number\n ): Promise<void>;\n\n /**\n * Stop tracking the ongoing RUM Action.\n * @param type: The action type (tap, scroll, swipe, back, custom).\n * @param name: The action name.\n * @param context: The additional context to send.\n * @param timestampMs: The timestamp when the action stopped (in milliseconds). If not provided, current timestamp will be used.\n */\n stopAction(\n type: string,\n name: string,\n context: Object,\n timestampMs: number\n ): Promise<void>;\n\n /**\n * Add a RUM Action.\n * @param type: The action type (tap, scroll, swipe, back, custom).\n * @param name: The action name.\n * @param context: The additional context to send.\n * @param timestampMs: The timestamp when the action occurred (in milliseconds). If not provided, current timestamp will be used.\n */\n addAction(\n type: string,\n name: string,\n context: Object,\n timestampMs: number\n ): Promise<void>;\n\n /**\n * Start tracking a RUM Resource.\n * @param key: The resource unique key identifier.\n * @param method: The resource method (GET, POST, …).\n * @param url: The resource url.\n * @param context: The additional context to send.\n * @param timestampMs: The timestamp when the resource started (in milliseconds). If not provided, current timestamp will be used.\n */\n startResource(\n key: string,\n method: string,\n url: string,\n context: Object,\n timestampMs: number\n ): Promise<void>;\n\n /**\n * Stop tracking a RUM Resource.\n * @param key: The resource unique key identifier.\n * @param statusCode: The resource status code.\n * @param kind: The resource's kind (xhr, document, image, css, font, …).\n * @param size: The resource size in bytes. If size is unknown, use -1.\n * @param context: The additional context to send.\n * @param timestampMs: The timestamp when the resource stopped (in milliseconds). If not provided, current timestamp will be used.\n */\n stopResource(\n key: string,\n statusCode: number,\n kind: string,\n size: number,\n context: Object,\n timestampMs: number\n ): Promise<void>;\n\n /**\n * Add a RUM Error.\n * @param message: The error message.\n * @param source: The error source (network, source, console, webview, custom).\n * @param stacktrace: The error stacktrace.\n * @param context: The additional context to send.\n * @param timestampMs: The timestamp when the error occurred (in milliseconds). If not provided, current timestamp will be used.\n */\n addError(\n message: string,\n source: string,\n stacktrace: string,\n context: Object,\n timestampMs: number\n ): Promise<void>;\n\n /**\n * Adds a specific timing in the active View. The timing duration will be computed as the difference between the time the View was started and the time this function was called.\n * @param name: The name of the new custom timing attribute. Timings can be nested up to 8 levels deep. Names using more than 8 levels will be sanitized by SDK.\n */\n addTiming(name: string): Promise<void>;\n\n /**\n * Stops the current RUM Session.\n */\n stopSession(): Promise<void>;\n\n /**\n * Adds the result of evaluating a feature flag with a given name and value to the view.\n * Feature flag evaluations are local to the active view and are cleared when the view is stopped.\n * @param name: The name of the feature flag\n * @param value: The value of the feature flag, encapsulated in an Object to accept all types\n */\n addFeatureFlagEvaluation(name: string, value: Object): Promise<void>;\n}\n\nexport default TurboModuleRegistry.get<Spec>('DdRum');\n"]}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Unless explicitly stated otherwise all files in this repository are licensed under the Apache License Version 2.0.
|
|
3
|
+
* This product includes software developed at Datadog (https://www.datadoghq.com/).
|
|
4
|
+
* Copyright 2016-Present Datadog, Inc.
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
/* eslint-disable @typescript-eslint/ban-types */
|
|
8
|
+
import { TurboModuleRegistry } from 'react-native';
|
|
9
|
+
/**
|
|
10
|
+
* Do not import this Spec directly, use DdNativeSdkType instead.
|
|
11
|
+
*/
|
|
12
|
+
|
|
13
|
+
export default TurboModuleRegistry.get('DdSdk');
|
|
14
|
+
//# sourceMappingURL=NativeDdSdk.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["NativeDdSdk.ts"],"names":["TurboModuleRegistry","get"],"mappings":"AAAA;AACA;AACA;AACA;AACA;;AAEA;AAEA,SAASA,mBAAT,QAAoC,cAApC;AAEA;AACA;AACA;;AAiDA,eAAeA,mBAAmB,CAACC,GAApB,CAA8B,OAA9B,CAAf","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/* eslint-disable @typescript-eslint/ban-types */\nimport type { TurboModule } from 'react-native';\nimport { TurboModuleRegistry } from 'react-native';\n\n/**\n * Do not import this Spec directly, use DdNativeSdkType instead.\n */\nexport interface Spec extends TurboModule {\n readonly getConstants: () => {};\n\n /**\n * Initializes Datadog's features.\n * @param configuration: The configuration to use.\n */\n initialize(configuration: Object): Promise<void>;\n\n /**\n * Sets the global context (set of attributes) attached with all future Logs, Spans and RUM events.\n * @param attributes: The global context attributes.\n */\n setAttributes(attributes: Object): Promise<void>;\n\n /**\n * Set the user information.\n * @param user: The user object (use builtin attributes: 'id', 'email', 'name', and/or any custom attribute).\n */\n setUser(user: Object): Promise<Object>;\n\n /**\n * Set the tracking consent regarding the data collection.\n * @param trackingConsent: Consent, which can take one of the following values: 'pending', 'granted', 'not_granted'.\n */\n setTrackingConsent(trackingConsent: string): Promise<void>;\n\n /**\n * Sends internal telemetry debug message\n * @param message debug message\n */\n telemetryDebug(message: string): Promise<void>;\n\n /**\n * Sends internal telemetry error\n * @param message error message\n * @param stack error stack\n * @param kind error kind\n */\n telemetryError(message: string, stack: string, kind: string): Promise<void>;\n\n /**\n * Send webview telemetry logs\n * @param message event description\n */\n consumeWebviewEvent(message: string): Promise<void>;\n}\n\nexport default TurboModuleRegistry.get<Spec>('DdSdk');\n"]}
|