@datadog/mobile-react-native 2.12.0 → 2.12.2
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/android/src/main/kotlin/com/datadog/reactnative/SdkVersion.kt +1 -1
- package/ios/Sources/SdkVersion.swift +1 -1
- package/lib/commonjs/DdSdkReactNative.js +1 -0
- package/lib/commonjs/DdSdkReactNative.js.map +1 -1
- package/lib/commonjs/metro/plugin/debugIdHelper.js +4 -5
- package/lib/commonjs/metro/plugin/debugIdHelper.js.map +1 -1
- package/lib/commonjs/metro/plugin/metroSerializer.js +7 -11
- package/lib/commonjs/metro/plugin/metroSerializer.js.map +1 -1
- package/lib/commonjs/metro/plugin/utils.js +145 -66
- package/lib/commonjs/metro/plugin/utils.js.map +1 -1
- package/lib/commonjs/rum/instrumentation/interactionTracking/DdBabelInteractionTracking.js +22 -11
- package/lib/commonjs/rum/instrumentation/interactionTracking/DdBabelInteractionTracking.js.map +1 -1
- package/lib/commonjs/rum/instrumentation/interactionTracking/DdRumUserInteractionTracking.js +2 -2
- package/lib/commonjs/rum/instrumentation/interactionTracking/DdRumUserInteractionTracking.js.map +1 -1
- package/lib/commonjs/version.js +1 -1
- package/lib/module/DdSdkReactNative.js +1 -0
- package/lib/module/DdSdkReactNative.js.map +1 -1
- package/lib/module/metro/plugin/debugIdHelper.js +3 -3
- package/lib/module/metro/plugin/debugIdHelper.js.map +1 -1
- package/lib/module/metro/plugin/metroSerializer.js +6 -8
- package/lib/module/metro/plugin/metroSerializer.js.map +1 -1
- package/lib/module/metro/plugin/utils.js +134 -60
- package/lib/module/metro/plugin/utils.js.map +1 -1
- package/lib/module/rum/instrumentation/interactionTracking/DdBabelInteractionTracking.js +22 -11
- package/lib/module/rum/instrumentation/interactionTracking/DdBabelInteractionTracking.js.map +1 -1
- package/lib/module/rum/instrumentation/interactionTracking/DdRumUserInteractionTracking.js +2 -2
- package/lib/module/rum/instrumentation/interactionTracking/DdRumUserInteractionTracking.js.map +1 -1
- package/lib/module/version.js +1 -1
- package/lib/typescript/DdSdkReactNative.d.ts.map +1 -1
- package/lib/typescript/metro/plugin/debugIdHelper.d.ts.map +1 -1
- package/lib/typescript/metro/plugin/metroSerializer.d.ts.map +1 -1
- package/lib/typescript/metro/plugin/utils.d.ts +62 -11
- package/lib/typescript/metro/plugin/utils.d.ts.map +1 -1
- package/lib/typescript/rum/instrumentation/interactionTracking/DdBabelInteractionTracking.d.ts +9 -1
- package/lib/typescript/rum/instrumentation/interactionTracking/DdBabelInteractionTracking.d.ts.map +1 -1
- package/lib/typescript/version.d.ts +1 -1
- package/package.json +2 -2
- package/src/DdSdkReactNative.tsx +2 -0
- package/src/metro/__tests__/__utils__/serializerUtils.ts +6 -4
- package/src/metro/__tests__/metro.test.ts +254 -0
- package/src/metro/metro.d.ts +4 -4
- package/src/metro/plugin/debugIdHelper.ts +3 -3
- package/src/metro/plugin/metroSerializer.ts +8 -9
- package/src/metro/plugin/utils.ts +189 -86
- package/src/rum/instrumentation/interactionTracking/DdBabelInteractionTracking.ts +39 -19
- package/src/rum/instrumentation/interactionTracking/DdRumUserInteractionTracking.tsx +2 -2
- package/src/version.ts +1 -1
- package/lib/commonjs/utils/telemetry.js +0 -23
- package/lib/commonjs/utils/telemetry.js.map +0 -1
- package/lib/module/utils/telemetry.js +0 -16
- package/lib/module/utils/telemetry.js.map +0 -1
- package/lib/typescript/utils/telemetry.d.ts +0 -7
- package/lib/typescript/utils/telemetry.d.ts.map +0 -1
- package/src/utils/telemetry.ts +0 -17
|
@@ -6,12 +6,6 @@
|
|
|
6
6
|
* Portions of this code are adapted from Sentry's Metro configuration:
|
|
7
7
|
* https://github.com/getsentry/sentry-react-native/blob/17c0c2e8913030e4826d055284a735efad637312/packages/core/src/js/tools/sentryMetroSerializer.ts
|
|
8
8
|
*/
|
|
9
|
-
|
|
10
|
-
// eslint-disable-next-line import/no-extraneous-dependencies
|
|
11
|
-
import baseJSBundle from 'metro/src/DeltaBundler/Serializers/baseJSBundle';
|
|
12
|
-
// eslint-disable-next-line import/no-extraneous-dependencies
|
|
13
|
-
import bundleToString from 'metro/src/lib/bundleToString';
|
|
14
|
-
|
|
15
9
|
import {
|
|
16
10
|
DEBUG_ID_PLACEHOLDER,
|
|
17
11
|
addDebugIdModule,
|
|
@@ -32,9 +26,11 @@ import type {
|
|
|
32
26
|
ReadOnlyGraph
|
|
33
27
|
} from './types/metroTypes';
|
|
34
28
|
import {
|
|
29
|
+
getBaseJSBundleFunction,
|
|
30
|
+
getBundleToStringFunction,
|
|
35
31
|
convertSerializerOutput as getMetroBundleWithMap,
|
|
36
32
|
getSortedModules,
|
|
37
|
-
|
|
33
|
+
getSourceMapStringFunction
|
|
38
34
|
} from './utils';
|
|
39
35
|
|
|
40
36
|
/**
|
|
@@ -105,8 +101,9 @@ export const createDatadogMetroSerializer = (
|
|
|
105
101
|
*/
|
|
106
102
|
export const createDefaultMetroSerializer = (): MetroSerializer => {
|
|
107
103
|
return (entryPoint, preModules, graph, options) => {
|
|
108
|
-
//
|
|
104
|
+
// Creates the default metro bundle
|
|
109
105
|
// https://github.com/facebook/metro/blob/a3d021a0d021b5706372059f472715c63019e044/packages/metro/src/DeltaBundler/Serializers/baseJSBundle.js#L25
|
|
106
|
+
const baseJSBundle = getBaseJSBundleFunction();
|
|
110
107
|
let bundle = baseJSBundle(entryPoint, preModules, graph, options);
|
|
111
108
|
|
|
112
109
|
// Modify the bundle through the datadogBundleCallback, if we are not in hot-reload mode
|
|
@@ -118,6 +115,7 @@ export const createDefaultMetroSerializer = (): MetroSerializer => {
|
|
|
118
115
|
}
|
|
119
116
|
|
|
120
117
|
// Retrieves the processed code from the bundle
|
|
118
|
+
const bundleToString = getBundleToStringFunction();
|
|
121
119
|
const { code } = bundleToString(bundle);
|
|
122
120
|
|
|
123
121
|
// If we are in hot-reload mode, we skip sourcemaps generation, and only return the code.
|
|
@@ -126,7 +124,8 @@ export const createDefaultMetroSerializer = (): MetroSerializer => {
|
|
|
126
124
|
}
|
|
127
125
|
|
|
128
126
|
// Force generation of sourcemaps
|
|
129
|
-
const
|
|
127
|
+
const sourceMapString = getSourceMapStringFunction();
|
|
128
|
+
const map = sourceMapString(
|
|
130
129
|
[...preModules, ...getSortedModules(graph, options)],
|
|
131
130
|
{
|
|
132
131
|
processModuleFilter: options.processModuleFilter,
|
|
@@ -3,29 +3,75 @@
|
|
|
3
3
|
* This product includes software developed at Datadog (https://www.datadoghq.com/).
|
|
4
4
|
* Copyright 2016-Present Datadog, Inc.
|
|
5
5
|
*/
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
import
|
|
9
|
-
|
|
6
|
+
import type baseJSBundle from 'metro/private/DeltaBundler/Serializers/baseJSBundle';
|
|
7
|
+
import type sourceMapString from 'metro/private/DeltaBundler/Serializers/sourceMapString';
|
|
8
|
+
import type bundleToString from 'metro/private/lib/bundleToString';
|
|
9
|
+
import type countLines from 'metro/private/lib/countLines';
|
|
10
10
|
import type CountingSet from 'metro/src/lib/CountingSet';
|
|
11
11
|
import type { ReadOnlyGraph, Module, MixedOutput } from 'metro';
|
|
12
12
|
|
|
13
13
|
import type { DefaultConfigOptions } from './types/expoTypes';
|
|
14
14
|
import type {
|
|
15
15
|
MetroSerializerOutput,
|
|
16
|
-
MetroBundleWithMap
|
|
17
|
-
SourceMapString
|
|
16
|
+
MetroBundleWithMap
|
|
18
17
|
} from './types/metroTypes';
|
|
19
18
|
|
|
20
19
|
/**
|
|
21
|
-
* Lazy-init
|
|
20
|
+
* Lazy-init cache for modules loaded through `safeRequireDefaultExport`.
|
|
21
|
+
*/
|
|
22
|
+
const lazyLoadedModules: { [key: string]: any } = {};
|
|
23
|
+
|
|
24
|
+
/**
|
|
25
|
+
* Lazy-init reference for {@link getSourceMapStringFunction} resolved function.
|
|
26
|
+
*/
|
|
27
|
+
let sourceMapStringFunction: typeof sourceMapString | undefined;
|
|
28
|
+
|
|
29
|
+
/**
|
|
30
|
+
* Safely loads and returns the `baseJSBundle` function from Metro's internal modules.
|
|
31
|
+
* Supports multiple Metro versions with different internal paths.
|
|
32
|
+
*/
|
|
33
|
+
export const getBaseJSBundleFunction = (): typeof baseJSBundle =>
|
|
34
|
+
lazyRequireDefaultExport([
|
|
35
|
+
'metro/private/DeltaBundler/Serializers/baseJSBundle',
|
|
36
|
+
'metro/src/DeltaBundler/Serializers/baseJSBundle'
|
|
37
|
+
]);
|
|
38
|
+
|
|
39
|
+
/**
|
|
40
|
+
* Safely loads and returns the `countLines` function from Metro's internal modules.
|
|
41
|
+
* Supports multiple Metro versions with different internal paths.
|
|
42
|
+
*/
|
|
43
|
+
export const getCountLinesFunction = (): typeof countLines =>
|
|
44
|
+
lazyRequireDefaultExport([
|
|
45
|
+
'metro/private/lib/countLines',
|
|
46
|
+
'metro/src/lib/countLines'
|
|
47
|
+
]);
|
|
48
|
+
|
|
49
|
+
/**
|
|
50
|
+
* Safely loads and returns the `bundleToString` function from Metro's internal modules.
|
|
51
|
+
* Supports multiple Metro versions with different internal paths.
|
|
22
52
|
*/
|
|
23
|
-
|
|
53
|
+
export const getBundleToStringFunction = (): typeof bundleToString =>
|
|
54
|
+
lazyRequireDefaultExport([
|
|
55
|
+
'metro/private/lib/bundleToString',
|
|
56
|
+
'metro/src/lib/bundleToString'
|
|
57
|
+
]);
|
|
24
58
|
|
|
25
59
|
/**
|
|
26
|
-
*
|
|
60
|
+
* CountingSet was added in Metro 0.71.2 - a modified `Set` that only deletes items when the
|
|
61
|
+
* number of `delete(item)` calls matches the number of `add(item)` calls.
|
|
62
|
+
*
|
|
63
|
+
* https://github.com/facebook/metro/commit/fc29a1177f883144674cf85a813b58567f69d545
|
|
27
64
|
*/
|
|
28
|
-
|
|
65
|
+
export const getCreateCountingSetFunction: () => () => CountingSet<string> = () => {
|
|
66
|
+
const CountingSetClass = safeLazyRequireDefaultExport<typeof CountingSet>([
|
|
67
|
+
'metro/private/lib/CountingSet',
|
|
68
|
+
'metro/src/lib/CountingSet'
|
|
69
|
+
]);
|
|
70
|
+
|
|
71
|
+
return CountingSetClass
|
|
72
|
+
? () => new CountingSetClass<string>()
|
|
73
|
+
: () => (new Set() as unknown) as CountingSet<string>;
|
|
74
|
+
};
|
|
29
75
|
|
|
30
76
|
/**
|
|
31
77
|
* Lazy-init reference for {@link getDefaultExpoConfig} resolved function.
|
|
@@ -37,6 +83,45 @@ let getDefaultExpoConfigFunc:
|
|
|
37
83
|
) => DefaultConfigOptions)
|
|
38
84
|
| undefined;
|
|
39
85
|
|
|
86
|
+
/**
|
|
87
|
+
* In Metro versions prior to v0.80.10, `sourceMapString` was exported as a default export.
|
|
88
|
+
* Starting with v0.80.10, it became a named export.
|
|
89
|
+
*
|
|
90
|
+
* @returns The resolved `sourceMapString` function, of type {@link sourceMapString}
|
|
91
|
+
*/
|
|
92
|
+
export const getSourceMapStringFunction = (): typeof sourceMapString => {
|
|
93
|
+
if (sourceMapStringFunction) {
|
|
94
|
+
return sourceMapStringFunction;
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
const sourceMapStringModule = safeRequireDefaultExport([
|
|
98
|
+
'metro/private/DeltaBundler/Serializers/sourceMapString',
|
|
99
|
+
'metro/src/DeltaBundler/Serializers/sourceMapString'
|
|
100
|
+
]);
|
|
101
|
+
|
|
102
|
+
if (typeof sourceMapStringModule === 'function') {
|
|
103
|
+
sourceMapStringFunction = sourceMapStringModule as typeof sourceMapString;
|
|
104
|
+
} else if (
|
|
105
|
+
sourceMapStringModule &&
|
|
106
|
+
typeof sourceMapStringModule === 'object' &&
|
|
107
|
+
typeof (sourceMapStringModule as { sourceMapString: any })[
|
|
108
|
+
'sourceMapString'
|
|
109
|
+
] === 'function'
|
|
110
|
+
) {
|
|
111
|
+
sourceMapStringFunction = (sourceMapStringModule as {
|
|
112
|
+
sourceMapString: typeof sourceMapString;
|
|
113
|
+
}).sourceMapString;
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
if (!sourceMapStringFunction) {
|
|
117
|
+
throw new Error(
|
|
118
|
+
"[DATADOG METRO PLUGIN] Unexpected error: Cannot resolve sourceMapString function from Metro's internal modules."
|
|
119
|
+
);
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
return sourceMapStringFunction;
|
|
123
|
+
};
|
|
124
|
+
|
|
40
125
|
/**
|
|
41
126
|
* This function ensures that modules in source maps are sorted in the same
|
|
42
127
|
* order as in a plain JS bundle.
|
|
@@ -60,71 +145,6 @@ export function getSortedModules(
|
|
|
60
145
|
);
|
|
61
146
|
}
|
|
62
147
|
|
|
63
|
-
/**
|
|
64
|
-
* CountingSet was added in Metro 0.71.2 - a modified `Set` that only deletes items when the
|
|
65
|
-
* number of `delete(item)` calls matches the number of `add(item)` calls.
|
|
66
|
-
*
|
|
67
|
-
* https://github.com/facebook/metro/commit/fc29a1177f883144674cf85a813b58567f69d545
|
|
68
|
-
*/
|
|
69
|
-
export const createCountingSet = () => {
|
|
70
|
-
if (createCountingSetFunc) {
|
|
71
|
-
return createCountingSetFunc();
|
|
72
|
-
}
|
|
73
|
-
|
|
74
|
-
try {
|
|
75
|
-
createCountingSetFunc = () => {
|
|
76
|
-
const {
|
|
77
|
-
default: MetroCountingSet
|
|
78
|
-
// eslint-disable-next-line global-require, import/no-extraneous-dependencies, @typescript-eslint/no-var-requires
|
|
79
|
-
} = require('metro/src/lib/CountingSet');
|
|
80
|
-
return new MetroCountingSet();
|
|
81
|
-
};
|
|
82
|
-
} catch (_) {
|
|
83
|
-
createCountingSetFunc = () =>
|
|
84
|
-
(new Set() as unknown) as CountingSet<string>;
|
|
85
|
-
}
|
|
86
|
-
|
|
87
|
-
return createCountingSetFunc();
|
|
88
|
-
};
|
|
89
|
-
/**
|
|
90
|
-
* In Metro versions prior to v0.80.10, `sourceMapString` was exported as a default export.
|
|
91
|
-
* Starting with v0.80.10, it became a named export.
|
|
92
|
-
*
|
|
93
|
-
* @returns The resolved `sourceMapString` function, of type {@link SourceMapString}
|
|
94
|
-
*/
|
|
95
|
-
export const metroSourceMapString: SourceMapString = (
|
|
96
|
-
modules: Module<MixedOutput>[],
|
|
97
|
-
options: {
|
|
98
|
-
excludeSource?: boolean;
|
|
99
|
-
processModuleFilter?: (module: Module<MixedOutput>) => boolean;
|
|
100
|
-
shouldAddToIgnoreList?: (module: Module<MixedOutput>) => boolean;
|
|
101
|
-
}
|
|
102
|
-
): string => {
|
|
103
|
-
if (sourceMapStringFunc) {
|
|
104
|
-
return sourceMapStringFunc(modules, options);
|
|
105
|
-
}
|
|
106
|
-
|
|
107
|
-
if (typeof sourceMapString === 'function') {
|
|
108
|
-
sourceMapStringFunc = sourceMapString;
|
|
109
|
-
} else if (
|
|
110
|
-
sourceMapString &&
|
|
111
|
-
typeof sourceMapString === 'object' &&
|
|
112
|
-
typeof sourceMapString['sourceMapString'] === 'function'
|
|
113
|
-
) {
|
|
114
|
-
sourceMapStringFunc = (sourceMapString as {
|
|
115
|
-
sourceMapString: SourceMapString;
|
|
116
|
-
}).sourceMapString;
|
|
117
|
-
}
|
|
118
|
-
|
|
119
|
-
if (!sourceMapStringFunc) {
|
|
120
|
-
throw new Error(
|
|
121
|
-
"[DATADOG METRO PLUGIN] Cannot find sourceMapString function in 'metro/src/DeltaBundler/Serializers/sourceMapString'"
|
|
122
|
-
);
|
|
123
|
-
}
|
|
124
|
-
|
|
125
|
-
return sourceMapStringFunc(modules, options);
|
|
126
|
-
};
|
|
127
|
-
|
|
128
148
|
/**
|
|
129
149
|
* Converts the serializer result of type {@link MetroSerializerOutput} to {@link MetroBundleWithMap}.
|
|
130
150
|
*/
|
|
@@ -160,18 +180,101 @@ export const getDefaultExpoConfig = (
|
|
|
160
180
|
projectRoot: string,
|
|
161
181
|
options: DefaultConfigOptions
|
|
162
182
|
): DefaultConfigOptions => {
|
|
163
|
-
if (
|
|
183
|
+
if (getDefaultExpoConfigFunc) {
|
|
184
|
+
return getDefaultExpoConfigFunc(projectRoot, options);
|
|
185
|
+
}
|
|
186
|
+
try {
|
|
187
|
+
// eslint-disable-next-line global-require, @typescript-eslint/no-var-requires
|
|
188
|
+
const metroConfig = require('expo/metro-config');
|
|
189
|
+
getDefaultExpoConfigFunc = metroConfig.getDefaultConfig;
|
|
190
|
+
return metroConfig.getDefaultConfig(projectRoot, options);
|
|
191
|
+
} catch (e) {
|
|
192
|
+
throw new Error(
|
|
193
|
+
'Cannot load `expo/metro-config`. Make sure Expo is properly set up in your project.'
|
|
194
|
+
);
|
|
195
|
+
}
|
|
196
|
+
};
|
|
197
|
+
|
|
198
|
+
/**
|
|
199
|
+
* Safely requires a module from multiple possible paths, returning its default export if found.
|
|
200
|
+
* Caches the result to avoid redundant requires.
|
|
201
|
+
* Useful for supporting multiple Metro versions with different internal paths.
|
|
202
|
+
* @param modulePaths The list of possible module paths to try.
|
|
203
|
+
* @returns the default export of the first successfully required module.
|
|
204
|
+
* @throws if none of the module paths could be resolved.
|
|
205
|
+
*/
|
|
206
|
+
export const lazyRequireDefaultExport = <T>(modulePaths: string[]): T => {
|
|
207
|
+
const resolvedModule = safeLazyRequireDefaultExport<T>(modulePaths);
|
|
208
|
+
if (!resolvedModule) {
|
|
209
|
+
throw new Error(
|
|
210
|
+
`[DATADOG METRO PLUGIN] Unexpected error: cannot find module in any of the following paths: ${modulePaths.join(
|
|
211
|
+
', '
|
|
212
|
+
)}`
|
|
213
|
+
);
|
|
214
|
+
}
|
|
215
|
+
return resolvedModule;
|
|
216
|
+
};
|
|
217
|
+
|
|
218
|
+
/**
|
|
219
|
+
* Safely requires a module from multiple possible paths, returning its default export if found.
|
|
220
|
+
* Caches the result to avoid redundant requires.
|
|
221
|
+
* Useful for supporting multiple Metro versions with different internal paths.
|
|
222
|
+
* @param modulePaths The list of possible module paths to try.
|
|
223
|
+
* @returns the default export of the first successfully required module, or `undefined` if none could be resolved.
|
|
224
|
+
*/
|
|
225
|
+
export const safeLazyRequireDefaultExport = <T>(
|
|
226
|
+
modulePaths: string[]
|
|
227
|
+
): T | undefined => {
|
|
228
|
+
const cacheKey = modulePaths.join('|');
|
|
229
|
+
if (lazyLoadedModules[cacheKey]) {
|
|
230
|
+
return lazyLoadedModules[cacheKey] as T;
|
|
231
|
+
}
|
|
232
|
+
|
|
233
|
+
const resolvedModule = safeRequireDefaultExport<T>(modulePaths);
|
|
234
|
+
|
|
235
|
+
lazyLoadedModules[cacheKey] = resolvedModule;
|
|
236
|
+
return resolvedModule;
|
|
237
|
+
};
|
|
238
|
+
|
|
239
|
+
/**
|
|
240
|
+
* Safely requires a module from multiple possible paths, returning its default export if found.
|
|
241
|
+
* Useful for supporting multiple Metro versions with different internal paths.
|
|
242
|
+
* @param modulePaths The list of possible module paths to try.
|
|
243
|
+
* @returns the default export of the first successfully required module, or `undefined` if none could be resolved.
|
|
244
|
+
*/
|
|
245
|
+
export function safeRequireDefaultExport<T>(
|
|
246
|
+
modulePaths: string[]
|
|
247
|
+
): T | undefined {
|
|
248
|
+
let resolvedModule: T | undefined;
|
|
249
|
+
for (const modulePath of modulePaths) {
|
|
164
250
|
try {
|
|
165
|
-
// eslint-disable-next-line global-require, @typescript-eslint/no-var-requires
|
|
166
|
-
const
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
251
|
+
// eslint-disable-next-line global-require, import/no-extraneous-dependencies, @typescript-eslint/no-var-requires, import/no-dynamic-require
|
|
252
|
+
const mod = require(modulePath);
|
|
253
|
+
const defaultExport = getDefaultExport<T>(mod);
|
|
254
|
+
if (defaultExport) {
|
|
255
|
+
return defaultExport;
|
|
256
|
+
}
|
|
257
|
+
} catch (_) {
|
|
258
|
+
// Try next path
|
|
173
259
|
}
|
|
260
|
+
}
|
|
261
|
+
|
|
262
|
+
return resolvedModule;
|
|
263
|
+
}
|
|
264
|
+
|
|
265
|
+
/**
|
|
266
|
+
* Safely extracts the default export from a module, if it exists.
|
|
267
|
+
* Useful for supporting both CommonJS and ESM-syntax exports.
|
|
268
|
+
* Supports upcoming Metro v0.83.2 https://github.com/facebook/metro/commit/5d301d7177af455fc6a94a0ba464639677cdf4b4.
|
|
269
|
+
*/
|
|
270
|
+
export function getDefaultExport<T>(module: { default: T } | T): T | undefined {
|
|
271
|
+
if (!module) {
|
|
272
|
+
return undefined;
|
|
273
|
+
}
|
|
274
|
+
|
|
275
|
+
if (typeof module === 'object' && 'default' in module) {
|
|
276
|
+
return module.default as T;
|
|
174
277
|
} else {
|
|
175
|
-
return
|
|
278
|
+
return module as T;
|
|
176
279
|
}
|
|
177
|
-
}
|
|
280
|
+
}
|
|
@@ -4,13 +4,10 @@
|
|
|
4
4
|
* Copyright 2016-Present Datadog, Inc.
|
|
5
5
|
*/
|
|
6
6
|
|
|
7
|
-
import { InternalLog } from '../../../InternalLog';
|
|
8
|
-
import { SdkVerbosity } from '../../../SdkVerbosity';
|
|
9
|
-
import DdNativeRum from '../../../specs/NativeDdRum';
|
|
10
7
|
import DdSdk from '../../../specs/NativeDdSdk';
|
|
11
|
-
import { getBabelTelemetryConfig } from '../../../utils/telemetry';
|
|
12
8
|
import { DefaultTimeProvider } from '../../../utils/time-provider/DefaultTimeProvider';
|
|
13
9
|
import type { TimeProvider } from '../../../utils/time-provider/TimeProvider';
|
|
10
|
+
import type { DdRum } from '../../DdRum';
|
|
14
11
|
import { BABEL_PLUGIN_TELEMETRY } from '../../constants';
|
|
15
12
|
import type { RumActionType } from '../../types';
|
|
16
13
|
import { ActionSource } from '../../types';
|
|
@@ -47,24 +44,42 @@ export class DdBabelInteractionTracking {
|
|
|
47
44
|
|
|
48
45
|
private telemetrySent: boolean = false;
|
|
49
46
|
|
|
47
|
+
private ddRum: typeof DdRum | null = null;
|
|
48
|
+
|
|
50
49
|
isInitialized: boolean = false;
|
|
51
50
|
|
|
52
|
-
private constructor() {
|
|
51
|
+
private constructor(ddRum?: typeof DdRum) {
|
|
53
52
|
if (DdBabelInteractionTracking.instance) {
|
|
54
53
|
throw new Error(StateErrors.ALREADY_INITIALIZED);
|
|
55
54
|
}
|
|
56
55
|
|
|
56
|
+
if (ddRum) {
|
|
57
|
+
this.ddRum = ddRum;
|
|
58
|
+
}
|
|
59
|
+
|
|
57
60
|
DdBabelInteractionTracking.instance = this;
|
|
58
61
|
}
|
|
59
62
|
|
|
60
|
-
static getInstance() {
|
|
63
|
+
static getInstance(ddRum?: typeof DdRum) {
|
|
61
64
|
if (!DdBabelInteractionTracking.instance) {
|
|
62
|
-
DdBabelInteractionTracking.instance = new DdBabelInteractionTracking(
|
|
65
|
+
DdBabelInteractionTracking.instance = new DdBabelInteractionTracking(
|
|
66
|
+
ddRum
|
|
67
|
+
);
|
|
63
68
|
}
|
|
64
69
|
|
|
65
70
|
return DdBabelInteractionTracking.instance;
|
|
66
71
|
}
|
|
67
72
|
|
|
73
|
+
static getTelemetryConfig() {
|
|
74
|
+
return {
|
|
75
|
+
babel_plugin: {
|
|
76
|
+
enabled: !!globalThis.__DD_RN_BABEL_PLUGIN_ENABLED__,
|
|
77
|
+
track_interactions: !!DdBabelInteractionTracking.config
|
|
78
|
+
.trackInteractions
|
|
79
|
+
}
|
|
80
|
+
};
|
|
81
|
+
}
|
|
82
|
+
|
|
68
83
|
private getTargetName(targetObject: TargetObject) {
|
|
69
84
|
const {
|
|
70
85
|
getContent,
|
|
@@ -129,7 +144,7 @@ export class DdBabelInteractionTracking {
|
|
|
129
144
|
if (!this.telemetrySent) {
|
|
130
145
|
DdSdk?.sendTelemetryLog(
|
|
131
146
|
BABEL_PLUGIN_TELEMETRY,
|
|
132
|
-
|
|
147
|
+
DdBabelInteractionTracking.getTelemetryConfig(),
|
|
133
148
|
{ onlyOnce: true }
|
|
134
149
|
);
|
|
135
150
|
|
|
@@ -141,17 +156,22 @@ export class DdBabelInteractionTracking {
|
|
|
141
156
|
const { trackInteractions } = DdBabelInteractionTracking.config;
|
|
142
157
|
|
|
143
158
|
if (trackInteractions) {
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
159
|
+
this.ddRum
|
|
160
|
+
?.addAction(
|
|
161
|
+
action,
|
|
162
|
+
targetName,
|
|
163
|
+
{ '__dd.action_source': ActionSource.BABEL },
|
|
164
|
+
this.timeProvider.now()
|
|
165
|
+
)
|
|
166
|
+
.catch(e => {
|
|
167
|
+
if (e instanceof Error) {
|
|
168
|
+
DdSdk?.telemetryError(
|
|
169
|
+
e.message,
|
|
170
|
+
e.stack || '',
|
|
171
|
+
'BabelActionTrack'
|
|
172
|
+
);
|
|
173
|
+
}
|
|
174
|
+
});
|
|
155
175
|
}
|
|
156
176
|
|
|
157
177
|
return result;
|
|
@@ -10,9 +10,9 @@ import { InternalLog } from '../../../InternalLog';
|
|
|
10
10
|
import { SdkVerbosity } from '../../../SdkVerbosity';
|
|
11
11
|
import { DdSdk } from '../../../sdk/DdSdk';
|
|
12
12
|
import { getErrorMessage } from '../../../utils/errorUtils';
|
|
13
|
-
import { getBabelTelemetryConfig } from '../../../utils/telemetry';
|
|
14
13
|
import { BABEL_PLUGIN_TELEMETRY } from '../../constants';
|
|
15
14
|
|
|
15
|
+
import { DdBabelInteractionTracking } from './DdBabelInteractionTracking';
|
|
16
16
|
import type { DdEventsInterceptorOptions } from './DdEventsInterceptor';
|
|
17
17
|
import { DdEventsInterceptor } from './DdEventsInterceptor';
|
|
18
18
|
import type { EventsInterceptor } from './EventsInterceptor';
|
|
@@ -74,7 +74,7 @@ export class DdRumUserInteractionTracking {
|
|
|
74
74
|
|
|
75
75
|
DdSdk?.sendTelemetryLog(
|
|
76
76
|
BABEL_PLUGIN_TELEMETRY,
|
|
77
|
-
|
|
77
|
+
DdBabelInteractionTracking.getTelemetryConfig(),
|
|
78
78
|
{ onlyOnce: true }
|
|
79
79
|
);
|
|
80
80
|
|
package/src/version.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
// generated by genversion
|
|
2
|
-
export const version = '2.12.
|
|
2
|
+
export const version = '2.12.2';
|
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.getBabelTelemetryConfig = void 0;
|
|
7
|
-
var _DdBabelInteractionTracking = require("../rum/instrumentation/interactionTracking/DdBabelInteractionTracking");
|
|
8
|
-
/*
|
|
9
|
-
* Unless explicitly stated otherwise all files in this repository are licensed under the Apache License Version 2.0.
|
|
10
|
-
* This product includes software developed at Datadog (https://www.datadoghq.com/).
|
|
11
|
-
* Copyright 2016-Present Datadog, Inc.
|
|
12
|
-
*/
|
|
13
|
-
|
|
14
|
-
const getBabelTelemetryConfig = () => {
|
|
15
|
-
return {
|
|
16
|
-
babel_plugin: {
|
|
17
|
-
enabled: !!globalThis.__DD_RN_BABEL_PLUGIN_ENABLED__,
|
|
18
|
-
track_interactions: !!_DdBabelInteractionTracking.DdBabelInteractionTracking.config.trackInteractions
|
|
19
|
-
}
|
|
20
|
-
};
|
|
21
|
-
};
|
|
22
|
-
exports.getBabelTelemetryConfig = getBabelTelemetryConfig;
|
|
23
|
-
//# sourceMappingURL=telemetry.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"names":["_DdBabelInteractionTracking","require","getBabelTelemetryConfig","babel_plugin","enabled","globalThis","__DD_RN_BABEL_PLUGIN_ENABLED__","track_interactions","DdBabelInteractionTracking","config","trackInteractions","exports"],"sourceRoot":"../../../src","sources":["utils/telemetry.ts"],"mappings":";;;;;;AAMA,IAAAA,2BAAA,GAAAC,OAAA;AANA;AACA;AACA;AACA;AACA;;AAIO,MAAMC,uBAAuB,GAAGA,CAAA,KAAM;EACzC,OAAO;IACHC,YAAY,EAAE;MACVC,OAAO,EAAE,CAAC,CAACC,UAAU,CAACC,8BAA8B;MACpDC,kBAAkB,EAAE,CAAC,CAACC,sDAA0B,CAACC,MAAM,CAClDC;IACT;EACJ,CAAC;AACL,CAAC;AAACC,OAAA,CAAAT,uBAAA,GAAAA,uBAAA","ignoreList":[]}
|
|
@@ -1,16 +0,0 @@
|
|
|
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
|
-
import { DdBabelInteractionTracking } from '../rum/instrumentation/interactionTracking/DdBabelInteractionTracking';
|
|
8
|
-
export const getBabelTelemetryConfig = () => {
|
|
9
|
-
return {
|
|
10
|
-
babel_plugin: {
|
|
11
|
-
enabled: !!globalThis.__DD_RN_BABEL_PLUGIN_ENABLED__,
|
|
12
|
-
track_interactions: !!DdBabelInteractionTracking.config.trackInteractions
|
|
13
|
-
}
|
|
14
|
-
};
|
|
15
|
-
};
|
|
16
|
-
//# sourceMappingURL=telemetry.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"names":["DdBabelInteractionTracking","getBabelTelemetryConfig","babel_plugin","enabled","globalThis","__DD_RN_BABEL_PLUGIN_ENABLED__","track_interactions","config","trackInteractions"],"sourceRoot":"../../../src","sources":["utils/telemetry.ts"],"mappings":"AAAA;AACA;AACA;AACA;AACA;;AAEA,SAASA,0BAA0B,QAAQ,uEAAuE;AAElH,OAAO,MAAMC,uBAAuB,GAAGA,CAAA,KAAM;EACzC,OAAO;IACHC,YAAY,EAAE;MACVC,OAAO,EAAE,CAAC,CAACC,UAAU,CAACC,8BAA8B;MACpDC,kBAAkB,EAAE,CAAC,CAACN,0BAA0B,CAACO,MAAM,CAClDC;IACT;EACJ,CAAC;AACL,CAAC","ignoreList":[]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"telemetry.d.ts","sourceRoot":"","sources":["../../../src/utils/telemetry.ts"],"names":[],"mappings":"AAQA,eAAO,MAAM,uBAAuB;;;;;CAQnC,CAAC"}
|
package/src/utils/telemetry.ts
DELETED
|
@@ -1,17 +0,0 @@
|
|
|
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
|
-
import { DdBabelInteractionTracking } from '../rum/instrumentation/interactionTracking/DdBabelInteractionTracking';
|
|
8
|
-
|
|
9
|
-
export const getBabelTelemetryConfig = () => {
|
|
10
|
-
return {
|
|
11
|
-
babel_plugin: {
|
|
12
|
-
enabled: !!globalThis.__DD_RN_BABEL_PLUGIN_ENABLED__,
|
|
13
|
-
track_interactions: !!DdBabelInteractionTracking.config
|
|
14
|
-
.trackInteractions
|
|
15
|
-
}
|
|
16
|
-
};
|
|
17
|
-
};
|