@dynatrace/react-native-plugin 2.331.1 → 2.335.1
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/README.md +136 -177
- package/android/build.gradle +1 -1
- package/android/src/main/java/com/dynatrace/android/agent/DynatraceRNBridgeImpl.kt +7 -1
- package/android/src/main/java/com/dynatrace/android/agent/DynatraceUtils.kt +1 -0
- package/android/src/new/java/com/dynatrace/android/agent/DynatraceRNBridge.kt +1 -0
- package/android/src/old/java/com/dynatrace/android/agent/DynatraceRNBridge.kt +2 -1
- package/files/plugin-runtime.gradle +27 -13
- package/files/plugin.gradle +1 -1
- package/instrumentation/BabelPluginDynatrace.js +1 -0
- package/instrumentation/DynatraceInstrumentation.js +1 -1
- package/instrumentation/jsx/CreateElement.js +106 -6
- package/instrumentation/jsx/JsxDevRuntime.js +2 -6
- package/instrumentation/jsx/JsxRuntime.js +6 -10
- package/instrumentation/libs/UserInteraction.js +114 -0
- package/instrumentation/libs/community/gesture-handler/Touchables.InstrInfo.js +2 -0
- package/instrumentation/libs/community/gesture-handler/Touchables.js +3 -1
- package/instrumentation/libs/community/gesture-handler/index.js +3 -1
- package/instrumentation/libs/withOnPressMonitoring.js +55 -3
- package/ios/DynatraceRNBridge.mm +8 -1
- package/lib/core/Application.js +2 -0
- package/lib/core/Dynatrace.js +2 -1
- package/lib/core/UserPrivacyOptions.js +8 -1
- package/lib/core/configuration/ConfigurationHandler.js +21 -0
- package/lib/dynatrace-reporter.js +0 -14
- package/lib/dynatrace-transformer.js +10 -13
- package/lib/features/ui-interaction/Config.js +42 -0
- package/lib/features/ui-interaction/IUserInteractionEvent.js +16 -0
- package/lib/features/ui-interaction/Plugin.Fragment.Test.js +170 -0
- package/lib/features/ui-interaction/Plugin.js +289 -0
- package/lib/features/ui-interaction/RootDetection.js +51 -0
- package/lib/features/ui-interaction/RootWrapper.js +236 -0
- package/lib/features/ui-interaction/Run.js +38 -0
- package/lib/features/ui-interaction/Runtime.js +827 -0
- package/lib/features/ui-interaction/TouchMetaResolver.js +492 -0
- package/lib/features/ui-interaction/Types.js +14 -0
- package/lib/next/Dynatrace.js +1 -1
- package/lib/next/configuration/INativeRuntimeConfiguration.js +1 -0
- package/lib/next/configuration/RuntimeConfigurationObserver.js +47 -12
- package/lib/next/events/EventPipeline.js +9 -0
- package/package.json +19 -13
- package/react-native-dynatrace.podspec +1 -1
- package/scripts/Android.js +75 -62
- package/scripts/Config.js +12 -1
- package/scripts/core/InstrumentCall.js +1 -2
- package/scripts/core/LineOffsetAnalyzeCall.js +9 -15
- package/src/lib/core/interface/NativeDynatraceBridge.ts +1 -0
- package/types.d.ts +22 -9
- package/scripts/util/ReactOptions.js +0 -21
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dynatrace/react-native-plugin",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.335.1",
|
|
4
4
|
"description": "This plugin gives you the ability to use the Dynatrace Mobile agent in your react native application.",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"types": "types.d.ts",
|
|
@@ -24,6 +24,7 @@
|
|
|
24
24
|
"scripts": {
|
|
25
25
|
"uninstall": "node ./scripts/Uninstall.js",
|
|
26
26
|
"test": "jest --runInBand",
|
|
27
|
+
"test:coverage": "jest --runInBand --coverage",
|
|
27
28
|
"test:debug": "node --inspect-brk ./node_modules/jest/bin/jest.js --runInBand",
|
|
28
29
|
"test:local": "npm run lint && node runner.js test",
|
|
29
30
|
"test:examples": "node tests/jsdoc_examples/RunJestTest.js",
|
|
@@ -48,7 +49,7 @@
|
|
|
48
49
|
"author": "Dynatrace",
|
|
49
50
|
"license": "SEE LICENSE IN LICENSE.md",
|
|
50
51
|
"dependencies": {
|
|
51
|
-
"@babel/runtime": "^7.
|
|
52
|
+
"@babel/runtime": "^7.29.2",
|
|
52
53
|
"jscodeshift": "^17.3.0",
|
|
53
54
|
"plist": "^3.1.0",
|
|
54
55
|
"proxy-polyfill": "^0.3.2",
|
|
@@ -56,7 +57,7 @@
|
|
|
56
57
|
},
|
|
57
58
|
"homepage": "https://www.dynatrace.com/",
|
|
58
59
|
"peerDependencies": {
|
|
59
|
-
"@babel/
|
|
60
|
+
"@babel/core": ">=7.4.4",
|
|
60
61
|
"@react-native-picker/picker": ">=1.0.0",
|
|
61
62
|
"diff": "^8.0.2",
|
|
62
63
|
"react": ">=16.11.0",
|
|
@@ -67,8 +68,7 @@
|
|
|
67
68
|
"ast-types": "npm:ast-types-x"
|
|
68
69
|
},
|
|
69
70
|
"ast-types": "npm:ast-types-x",
|
|
70
|
-
"flow-parser": "0.160"
|
|
71
|
-
"fast-xml-parser@>=4.3.6 <=5.3.3": "5.3.4"
|
|
71
|
+
"flow-parser": "0.160"
|
|
72
72
|
},
|
|
73
73
|
"devDependencies": {
|
|
74
74
|
"@babel/plugin-transform-class-properties": "^7.27.1",
|
|
@@ -80,33 +80,37 @@
|
|
|
80
80
|
"@react-native/babel-preset": "^0.80.1",
|
|
81
81
|
"@react-navigation/core": "^7.13.0",
|
|
82
82
|
"@react-navigation/drawer": "^7.7.2",
|
|
83
|
-
"@testing-library/react-native": "^13.
|
|
83
|
+
"@testing-library/react-native": "^13.3.3",
|
|
84
84
|
"@types/jest": "^30.0.0",
|
|
85
85
|
"@types/jscodeshift": "^17.3.0",
|
|
86
|
+
"@types/micromatch": "^4.0.10",
|
|
86
87
|
"@types/node": "^18.19.123",
|
|
87
88
|
"@types/plist": "^3.0.5",
|
|
88
89
|
"@types/react": "^19.1.8",
|
|
89
90
|
"@types/semver": "^7.7.0",
|
|
90
91
|
"@types/shelljs": "^0.8.17",
|
|
91
92
|
"@types/uglify-js": "^3.17.5",
|
|
92
|
-
"@typescript-eslint/eslint-plugin": "^8.
|
|
93
|
-
"@typescript-eslint/parser": "^8.
|
|
93
|
+
"@typescript-eslint/eslint-plugin": "^8.56.0",
|
|
94
|
+
"@typescript-eslint/parser": "^8.56.0",
|
|
94
95
|
"compressing": "^1.10.3",
|
|
95
96
|
"diff": "^8.0.2",
|
|
96
97
|
"eslint": "^9.29.0",
|
|
97
98
|
"eslint-config-prettier": "^8.5.0",
|
|
98
|
-
"eslint-plugin-import": "^2.
|
|
99
|
+
"eslint-plugin-import": "^2.32.0",
|
|
99
100
|
"eslint-plugin-jsdoc": "^50.6.3",
|
|
100
101
|
"eslint-plugin-prefer-arrow": "^1.2.3",
|
|
101
|
-
"eslint-plugin-unicorn": "^
|
|
102
|
+
"eslint-plugin-unicorn": "^63.0.0",
|
|
102
103
|
"husky": "^9.1.6",
|
|
103
|
-
"jest": "^30.0
|
|
104
|
-
"jest-each": "^30.0
|
|
104
|
+
"jest": "^30.2.0",
|
|
105
|
+
"jest-each": "^30.2.0",
|
|
105
106
|
"jest-junit": "^16.0.0",
|
|
106
|
-
"jest-mock": "^30.0
|
|
107
|
+
"jest-mock": "^30.2.0",
|
|
107
108
|
"npm-check-updates": "^18.0.1",
|
|
108
109
|
"prettier": "^2.6.1",
|
|
110
|
+
"react": "19.2.3",
|
|
111
|
+
"react-native": "^0.84.0",
|
|
109
112
|
"react-native-gesture-handler": "^2.28.0",
|
|
113
|
+
"react-test-renderer": "19.2.3",
|
|
110
114
|
"rollup": "^4.52.4",
|
|
111
115
|
"rollup-plugin-dts": "^6.2.3",
|
|
112
116
|
"shelljs": "^0.10.0",
|
|
@@ -150,6 +154,7 @@
|
|
|
150
154
|
"instrumentation/model/*.js",
|
|
151
155
|
"instrumentation/parser/*.js",
|
|
152
156
|
"instrumentation/DynatraceInstrumentation.js",
|
|
157
|
+
"instrumentation/BabelPluginDynatrace.js",
|
|
153
158
|
"lib/*.js",
|
|
154
159
|
"lib/core/*.js",
|
|
155
160
|
"lib/core/configuration/*.js",
|
|
@@ -167,6 +172,7 @@
|
|
|
167
172
|
"lib/next/events/modifier/*.js",
|
|
168
173
|
"lib/next/events/spec/*.js",
|
|
169
174
|
"lib/next/provider/*.js",
|
|
175
|
+
"lib/features/ui-interaction/*.js",
|
|
170
176
|
"src/lib/core/interface/NativeDynatraceBridge.ts",
|
|
171
177
|
"types.d.ts"
|
|
172
178
|
],
|
|
@@ -111,7 +111,7 @@ Pod::Spec.new do |s|
|
|
|
111
111
|
#
|
|
112
112
|
|
|
113
113
|
s.dependency "React"
|
|
114
|
-
s.dependency 'Dynatrace', '~> 8.
|
|
114
|
+
s.dependency 'Dynatrace', '~> 8.335.1.1009'
|
|
115
115
|
|
|
116
116
|
# Allows for better compatibility for older and newer versions
|
|
117
117
|
if defined?(install_modules_dependencies)
|
package/scripts/Android.js
CHANGED
|
@@ -1,13 +1,14 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
'use strict';
|
|
3
3
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
|
-
exports.ensureRuntimeScriptApplied = exports.
|
|
4
|
+
exports.ensureRuntimeScriptApplied = exports.writeGradleConfig = exports.instrumentAndroidPlatform = exports.GRADLE_APPLY_RUNTIME_SCRIPT = exports.GRADLE_APPLY_BUILDSCRIPT = exports.GRADLE_DYNATRACE_FILE = void 0;
|
|
5
5
|
const path_1 = require("path");
|
|
6
6
|
const Logger_1 = require("./Logger");
|
|
7
7
|
const FileOperationHelper_1 = require("./FileOperationHelper");
|
|
8
8
|
const PathsConstants_1 = require("./PathsConstants");
|
|
9
9
|
const GRADLE_CONFIG_IDENTIFIER = '// AUTO - INSERTED';
|
|
10
10
|
exports.GRADLE_DYNATRACE_FILE = `apply from: "./${PathsConstants_1.DYNATRACE_CONFIG_GRADLE_FILE}"`;
|
|
11
|
+
const LEGACY_GRADLE_DYNATRACE_NODE_MODULES = 'node_modules/@dynatrace/react-native-plugin/files/dynatrace.gradle';
|
|
11
12
|
const GRADLE_BUILDSCRIPT_IDENTIFIER = 'buildscript';
|
|
12
13
|
exports.GRADLE_APPLY_BUILDSCRIPT = 'apply from: "../node_modules/@dynatrace/react-native-plugin/files/plugin.gradle", to: buildscript';
|
|
13
14
|
const GRADLE_REACT_NATIVE_PLUGIN = 'apply plugin: "com.facebook.react.rootproject"';
|
|
@@ -31,78 +32,91 @@ const removeOldDynatraceClasspath = (gradleFileContent) => {
|
|
|
31
32
|
}
|
|
32
33
|
return gradleFileContentLines.join('\n');
|
|
33
34
|
};
|
|
34
|
-
const
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
for (let i = 0; i < gradleFileContentLines.length && (gradleDynatraceFileIndex === -1 || gradlePluginFileIndex === -1); i++) {
|
|
41
|
-
if (gradleFileContentLines[i].indexOf('plugin.gradle') > -1) {
|
|
42
|
-
gradlePluginFileIndex = i;
|
|
35
|
+
const findGradleLineIndices = (lines) => {
|
|
36
|
+
let pluginFileIndex = -1;
|
|
37
|
+
let dynatraceFileIndex = -1;
|
|
38
|
+
for (let i = 0; i < lines.length && (dynatraceFileIndex === -1 || pluginFileIndex === -1); i++) {
|
|
39
|
+
if (lines[i].indexOf('plugin.gradle') > -1) {
|
|
40
|
+
pluginFileIndex = i;
|
|
43
41
|
}
|
|
44
|
-
else if (
|
|
45
|
-
|
|
42
|
+
else if (lines[i].indexOf(PathsConstants_1.DYNATRACE_CONFIG_GRADLE_FILE) > -1) {
|
|
43
|
+
dynatraceFileIndex = i;
|
|
46
44
|
}
|
|
47
45
|
}
|
|
46
|
+
return { pluginFileIndex, dynatraceFileIndex };
|
|
47
|
+
};
|
|
48
|
+
const removeDynatraceFromGradle = (lines, indices, pathToGradle) => {
|
|
48
49
|
let modified = false;
|
|
49
|
-
if (
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
50
|
+
if (indices.pluginFileIndex !== -1) {
|
|
51
|
+
lines.splice(indices.pluginFileIndex, 1);
|
|
52
|
+
modified = true;
|
|
53
|
+
}
|
|
54
|
+
if (indices.dynatraceFileIndex !== -1) {
|
|
55
|
+
lines.splice(indices.dynatraceFileIndex - (modified ? 1 : 0), 1);
|
|
56
|
+
modified = true;
|
|
57
|
+
}
|
|
58
|
+
if (modified) {
|
|
59
|
+
Logger_1.default.logMessageSync('Removed Dynatrace modifications from build.gradle: ' + pathToGradle, Logger_1.default.INFO);
|
|
60
|
+
}
|
|
61
|
+
return modified;
|
|
62
|
+
};
|
|
63
|
+
const addDynatraceToGradle = (lines, indices, pathToGradle) => {
|
|
64
|
+
let modified = false;
|
|
65
|
+
if (indices.dynatraceFileIndex !== -1 &&
|
|
66
|
+
lines[indices.dynatraceFileIndex].includes(LEGACY_GRADLE_DYNATRACE_NODE_MODULES)) {
|
|
67
|
+
lines[indices.dynatraceFileIndex] = exports.GRADLE_DYNATRACE_FILE;
|
|
68
|
+
Logger_1.default.logMessageSync('Migrated old node_modules dynatrace.gradle path to local path in build.gradle', Logger_1.default.INFO);
|
|
69
|
+
modified = true;
|
|
70
|
+
}
|
|
71
|
+
if (indices.pluginFileIndex === -1) {
|
|
72
|
+
const buildscriptIndex = lines.findIndex((line) => line.startsWith(GRADLE_BUILDSCRIPT_IDENTIFIER));
|
|
73
|
+
if (buildscriptIndex === -1) {
|
|
74
|
+
throw new Error('Could not find Buildscript block in build.gradle.');
|
|
60
75
|
}
|
|
76
|
+
lines.splice(buildscriptIndex + 1, 0, exports.GRADLE_APPLY_BUILDSCRIPT);
|
|
77
|
+
modified = true;
|
|
78
|
+
}
|
|
79
|
+
if (indices.dynatraceFileIndex === -1) {
|
|
80
|
+
const pluginLineIndex = lines.findIndex((line) => line.includes(GRADLE_REACT_NATIVE_PLUGIN));
|
|
81
|
+
lines.splice(pluginLineIndex !== -1 ? pluginLineIndex : lines.length, 0, exports.GRADLE_DYNATRACE_FILE);
|
|
82
|
+
modified = true;
|
|
83
|
+
}
|
|
84
|
+
if (modified) {
|
|
85
|
+
Logger_1.default.logMessageSync('Added Dynatrace plugin.gradle to the build.gradle: ' + pathToGradle, Logger_1.default.INFO);
|
|
61
86
|
}
|
|
62
87
|
else {
|
|
63
|
-
|
|
64
|
-
let gradleFileReactIndex = -1;
|
|
65
|
-
for (let i = 0; i < gradleFileContentLines.length; i++) {
|
|
66
|
-
if (gradleFileContentLines[i].startsWith(GRADLE_BUILDSCRIPT_IDENTIFIER)) {
|
|
67
|
-
gradleFileReactIndex = i;
|
|
68
|
-
break;
|
|
69
|
-
}
|
|
70
|
-
}
|
|
71
|
-
if (gradleFileReactIndex === -1) {
|
|
72
|
-
throw new Error('Could not find Buildscript block in build.gradle.');
|
|
73
|
-
}
|
|
74
|
-
gradleFileContentLines.splice(gradleFileReactIndex + 1, 0, exports.GRADLE_APPLY_BUILDSCRIPT);
|
|
75
|
-
modified = true;
|
|
76
|
-
}
|
|
77
|
-
if (gradleDynatraceFileIndex === -1) {
|
|
78
|
-
let pluginLineIndex = -1;
|
|
79
|
-
for (let i = 0; i < gradleFileContentLines.length; i++) {
|
|
80
|
-
if (gradleFileContentLines[i].includes(GRADLE_REACT_NATIVE_PLUGIN)) {
|
|
81
|
-
pluginLineIndex = i;
|
|
82
|
-
break;
|
|
83
|
-
}
|
|
84
|
-
}
|
|
85
|
-
gradleFileContentLines.splice(pluginLineIndex !== -1 ? pluginLineIndex : gradleFileContentLines.length, 0, exports.GRADLE_DYNATRACE_FILE);
|
|
86
|
-
modified = true;
|
|
87
|
-
}
|
|
88
|
-
if (modified) {
|
|
89
|
-
Logger_1.default.logMessageSync('Added Dynatrace plugin.gradle to the build.gradle: ' + pathToGradle, Logger_1.default.INFO);
|
|
90
|
-
}
|
|
91
|
-
else {
|
|
92
|
-
Logger_1.default.logMessageSync('Dynatrace plugin & agent already added to build.gradle', Logger_1.default.INFO);
|
|
93
|
-
}
|
|
88
|
+
Logger_1.default.logMessageSync('Dynatrace plugin & agent already added to build.gradle', Logger_1.default.INFO);
|
|
94
89
|
}
|
|
90
|
+
return modified;
|
|
91
|
+
};
|
|
92
|
+
const changeReactNativeBuildGradleFile = (pathToGradle, remove) => {
|
|
93
|
+
const gradleFileContent = FileOperationHelper_1.default.readTextFromFileSync(pathToGradle);
|
|
94
|
+
const modifiedFileContent = removeOldDynatraceClasspath(gradleFileContent);
|
|
95
|
+
const gradleFileContentLines = modifiedFileContent.split('\n');
|
|
96
|
+
const indices = findGradleLineIndices(gradleFileContentLines);
|
|
97
|
+
const modified = remove
|
|
98
|
+
? removeDynatraceFromGradle(gradleFileContentLines, indices, pathToGradle)
|
|
99
|
+
: addDynatraceToGradle(gradleFileContentLines, indices, pathToGradle);
|
|
95
100
|
if (modified) {
|
|
96
101
|
const fullGradleFile = gradleFileContentLines.join('\n');
|
|
97
102
|
FileOperationHelper_1.default.writeTextToFileSync(pathToGradle, fullGradleFile);
|
|
98
103
|
}
|
|
99
104
|
};
|
|
100
|
-
const writeGradleConfig = (androidConfig) => {
|
|
105
|
+
const writeGradleConfig = (androidConfig, pathToGradle) => {
|
|
101
106
|
if (androidConfig === undefined || androidConfig.config === undefined) {
|
|
102
107
|
Logger_1.default.logMessageSync("Can't write configuration of Android agent because it is missing!", Logger_1.default.WARNING);
|
|
103
108
|
return;
|
|
104
109
|
}
|
|
105
|
-
const
|
|
110
|
+
const gradleDirectory = (0, path_1.dirname)(pathToGradle);
|
|
111
|
+
const targetPath = (0, path_1.join)(gradleDirectory, PathsConstants_1.DYNATRACE_CONFIG_GRADLE_FILE);
|
|
112
|
+
let gradleFileContent;
|
|
113
|
+
try {
|
|
114
|
+
FileOperationHelper_1.default.checkIfFileExistsSync(targetPath);
|
|
115
|
+
gradleFileContent = FileOperationHelper_1.default.readTextFromFileSync(targetPath);
|
|
116
|
+
}
|
|
117
|
+
catch (_a) {
|
|
118
|
+
gradleFileContent = FileOperationHelper_1.default.readTextFromFileSync(PathsConstants_1.default.getDynatraceGradleFile());
|
|
119
|
+
}
|
|
106
120
|
const gradleFileContentLines = removeOldGradleConfig(gradleFileContent);
|
|
107
121
|
let gradleFileIndex = -1;
|
|
108
122
|
for (let i = 0; i < gradleFileContentLines.length; i++) {
|
|
@@ -113,15 +127,14 @@ const writeGradleConfig = (androidConfig) => {
|
|
|
113
127
|
}
|
|
114
128
|
gradleFileContentLines.splice(gradleFileIndex + 1, 0, androidConfig.config);
|
|
115
129
|
const fullGradleFile = gradleFileContentLines.join('\n');
|
|
116
|
-
|
|
130
|
+
if (fullGradleFile === gradleFileContent) {
|
|
131
|
+
Logger_1.default.logMessageSync(`Configuration in ${PathsConstants_1.DYNATRACE_CONFIG_GRADLE_FILE} is already up to date`, Logger_1.default.INFO);
|
|
132
|
+
return;
|
|
133
|
+
}
|
|
134
|
+
FileOperationHelper_1.default.writeTextToFileSync(targetPath, fullGradleFile);
|
|
117
135
|
Logger_1.default.logMessageSync(`Replaced old configuration with current configuration in ${PathsConstants_1.DYNATRACE_CONFIG_GRADLE_FILE}`, Logger_1.default.INFO);
|
|
118
136
|
};
|
|
119
137
|
exports.writeGradleConfig = writeGradleConfig;
|
|
120
|
-
const copyGradleConfigFile = (pathToGradle) => {
|
|
121
|
-
const gradleDirectory = (0, path_1.dirname)(pathToGradle);
|
|
122
|
-
FileOperationHelper_1.default.copyFileSync(PathsConstants_1.default.getDynatraceGradleFile(), (0, path_1.join)(gradleDirectory, PathsConstants_1.DYNATRACE_CONFIG_GRADLE_FILE));
|
|
123
|
-
};
|
|
124
|
-
exports.copyGradleConfigFile = copyGradleConfigFile;
|
|
125
138
|
const removeOldGradleConfig = (gradleFileContent) => {
|
|
126
139
|
const gradleFileContentLines = gradleFileContent.split('\n');
|
|
127
140
|
const gradleConfigIndex = [];
|
package/scripts/Config.js
CHANGED
|
@@ -10,10 +10,12 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
10
10
|
});
|
|
11
11
|
};
|
|
12
12
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
13
|
-
exports.checkConfiguration = exports.addDefaultConfigs = exports.readConfig = exports.defaultConfig = exports.ERROR_CONFIG_NOT_AVAILABLE = void 0;
|
|
13
|
+
exports.checkConfiguration = exports.addDefaultConfigs = exports.readConfig = exports.readConfigDefault = exports.defaultConfig = exports.ERROR_CONFIG_NOT_AVAILABLE = void 0;
|
|
14
14
|
const FileOperationHelper_1 = require("./FileOperationHelper");
|
|
15
15
|
const Logger_1 = require("./Logger");
|
|
16
16
|
const PathsConstants_1 = require("./PathsConstants");
|
|
17
|
+
const CustomArgumentUtil_1 = require("./util/CustomArgumentUtil");
|
|
18
|
+
const path = require("path");
|
|
17
19
|
exports.ERROR_CONFIG_NOT_AVAILABLE = '-1';
|
|
18
20
|
exports.defaultConfig = {
|
|
19
21
|
react: {
|
|
@@ -34,12 +36,21 @@ exports.defaultConfig = {
|
|
|
34
36
|
navigation: {
|
|
35
37
|
enabled: true,
|
|
36
38
|
},
|
|
39
|
+
userInteraction: false,
|
|
37
40
|
sourcemap: {
|
|
38
41
|
enabled: true,
|
|
39
42
|
androidSourcemapLocation: 'app/build/generated/sourcemaps/react/release/index.android.bundle.map',
|
|
40
43
|
},
|
|
41
44
|
},
|
|
42
45
|
};
|
|
46
|
+
const readConfigDefault = () => {
|
|
47
|
+
const customArguments = (0, CustomArgumentUtil_1.readCustomArguments)();
|
|
48
|
+
const configPath = customArguments.isCustomConfigurationPathSet()
|
|
49
|
+
? path.join(PathsConstants_1.default.getApplicationPath(), customArguments.getCustomConfigurationPath())
|
|
50
|
+
: PathsConstants_1.default.getConfigFilePath();
|
|
51
|
+
return (0, exports.readConfig)(configPath);
|
|
52
|
+
};
|
|
53
|
+
exports.readConfigDefault = readConfigDefault;
|
|
43
54
|
const readConfig = (pathToConfig) => {
|
|
44
55
|
patchMalformedConfiguration(pathToConfig);
|
|
45
56
|
const readConfig = require(pathToConfig);
|
|
@@ -85,10 +85,9 @@ const instrumentCommand = () => {
|
|
|
85
85
|
Logger_1.default.logMessageSync('⏳ Starting Android Instrumentation with Dynatrace!', Logger_1.default.INFO);
|
|
86
86
|
Logger_1.default.withPrefix({ info: ' ℹ️ ', warning: ' ⚠️ ', error: ' ❌ ' }, () => {
|
|
87
87
|
android.instrumentAndroidPlatform(pathToGradle, false);
|
|
88
|
-
android.writeGradleConfig(configAgent.android);
|
|
88
|
+
android.writeGradleConfig(configAgent.android, pathToGradle);
|
|
89
89
|
android.ensureRuntimeScriptApplied(pathToAppGradle);
|
|
90
90
|
});
|
|
91
|
-
android.copyGradleConfigFile(pathToGradle);
|
|
92
91
|
Logger_1.default.logMessageSync(' ✅ Finished Android Instrumentation with Dynatrace!', Logger_1.default.INFO);
|
|
93
92
|
}
|
|
94
93
|
catch (e) {
|
|
@@ -16,11 +16,7 @@ const diff_1 = require("diff");
|
|
|
16
16
|
const Logger_1 = require("../Logger");
|
|
17
17
|
const InstrumentUtil_1 = require("../util/InstrumentUtil");
|
|
18
18
|
const FileOperationHelper_1 = require("../../scripts/FileOperationHelper");
|
|
19
|
-
const
|
|
20
|
-
const config = require("../../scripts/Config");
|
|
21
|
-
const CustomArgumentUtil_1 = require("../../scripts/util/CustomArgumentUtil");
|
|
22
|
-
const PathsConstants_1 = require("../../scripts/PathsConstants");
|
|
23
|
-
const customArguments = (0, CustomArgumentUtil_1.readCustomArguments)();
|
|
19
|
+
const Config_1 = require("../../scripts/Config");
|
|
24
20
|
class LineOffsetAnalyzer {
|
|
25
21
|
constructor(options) {
|
|
26
22
|
this.rootDir = (0, path_1.resolve)(options.projectRoot);
|
|
@@ -29,10 +25,15 @@ class LineOffsetAnalyzer {
|
|
|
29
25
|
this.logFile = (0, path_1.resolve)(this.instrumentedDir, 'debug.log');
|
|
30
26
|
this.appBundleInfo = options.appBundleInfo;
|
|
31
27
|
this.sourcemapPath = options.sourcemapPath;
|
|
28
|
+
this.reactOptions = (0, Config_1.readConfigDefault)();
|
|
32
29
|
}
|
|
33
30
|
run() {
|
|
34
31
|
var _a;
|
|
35
32
|
return __awaiter(this, void 0, void 0, function* () {
|
|
33
|
+
if (!this.reactOptions.react.useLegacyJscodeshift) {
|
|
34
|
+
console.info('ℹ️ Skipping line offset analysis since this it not needed anymore for the new babel architecture.');
|
|
35
|
+
return;
|
|
36
|
+
}
|
|
36
37
|
try {
|
|
37
38
|
const buildExists = yield FileOperationHelper_1.default.checkIfFileExists(this.instrumentedDir);
|
|
38
39
|
if (!buildExists) {
|
|
@@ -79,20 +80,13 @@ class LineOffsetAnalyzer {
|
|
|
79
80
|
};
|
|
80
81
|
yield fs.writeFile(this.outputFile, JSON.stringify(finalOutput, null, 2));
|
|
81
82
|
yield this.log(`✅ Line offsets written to ${this.outputFile}`, true);
|
|
82
|
-
|
|
83
|
-
if (customArguments.isCustomConfigurationPathSet()) {
|
|
84
|
-
reactOptions = config.readConfig((0, path_1.join)(PathsConstants_1.default.getApplicationPath(), customArguments.getCustomConfigurationPath()));
|
|
85
|
-
}
|
|
86
|
-
else {
|
|
87
|
-
reactOptions = config.readConfig((0, path_1.join)(PathsConstants_1.default.getConfigFilePath()));
|
|
88
|
-
}
|
|
89
|
-
if (!this.sourcemapPath && !reactOptions.react.sourcemap.enabled) {
|
|
83
|
+
if (!this.sourcemapPath && !this.reactOptions.react.sourcemap.enabled) {
|
|
90
84
|
const message = 'ℹ️ Automatic sourcemap patching disabled. Skipping sourcemap patching.';
|
|
91
85
|
yield this.log(message);
|
|
92
86
|
console.info(message);
|
|
93
87
|
return;
|
|
94
88
|
}
|
|
95
|
-
const loadedMap = yield this.loadSourceMap((_a = this.sourcemapPath) !== null && _a !== void 0 ? _a : reactOptions.react.sourcemap.androidSourcemapLocation);
|
|
89
|
+
const loadedMap = yield this.loadSourceMap((_a = this.sourcemapPath) !== null && _a !== void 0 ? _a : this.reactOptions.react.sourcemap.androidSourcemapLocation);
|
|
96
90
|
if (loadedMap) {
|
|
97
91
|
const { map, path: originalMapPath } = loadedMap;
|
|
98
92
|
map.x_dynatrace_offset = mappings;
|
|
@@ -126,7 +120,7 @@ class LineOffsetAnalyzer {
|
|
|
126
120
|
}
|
|
127
121
|
log(msg, logOnScreen = false) {
|
|
128
122
|
return __awaiter(this, void 0, void 0, function* () {
|
|
129
|
-
if (
|
|
123
|
+
if (this.reactOptions && this.reactOptions.react.debug && logOnScreen) {
|
|
130
124
|
Logger_1.default.logMessageSync(msg, Logger_1.default.INFO);
|
|
131
125
|
}
|
|
132
126
|
yield fs.appendFile(this.logFile, msg + '\n');
|
|
@@ -177,6 +177,7 @@ export interface Spec extends TurboModule {
|
|
|
177
177
|
export type NativeUserPrivacyOptions = {
|
|
178
178
|
dataCollectionLevel: string;
|
|
179
179
|
crashReportingOptedIn: boolean;
|
|
180
|
+
screenRecordOptedIn?: boolean;
|
|
180
181
|
};
|
|
181
182
|
|
|
182
183
|
export default TurboModuleRegistry.getEnforcing<Spec>('DynatraceBridge');
|
package/types.d.ts
CHANGED
|
@@ -126,11 +126,13 @@ declare enum DataCollectionLevel {
|
|
|
126
126
|
declare class UserPrivacyOptions {
|
|
127
127
|
private _dataCollectionLevel;
|
|
128
128
|
private _crashReportingOptedIn;
|
|
129
|
+
private _screenRecordOptedIn;
|
|
129
130
|
/**
|
|
130
131
|
* Creates a new UserPrivacyOptions instance with the specified privacy settings.
|
|
131
132
|
*
|
|
132
133
|
* @param {DataCollectionLevel} dataCollectionLevel The level of data collection to allow
|
|
133
134
|
* @param {boolean} crashReportingOptedIn Whether crash reporting should be enabled
|
|
135
|
+
* @param {boolean} screenRecordOptedIn Whether screen recording (Session Replay) should be enabled
|
|
134
136
|
*
|
|
135
137
|
* @example
|
|
136
138
|
* ```ts
|
|
@@ -147,7 +149,7 @@ declare class UserPrivacyOptions {
|
|
|
147
149
|
*
|
|
148
150
|
* @see https://www.npmjs.com/package/@dynatrace/react-native-plugin#user-privacy-options
|
|
149
151
|
*/
|
|
150
|
-
constructor(dataCollectionLevel: DataCollectionLevel, crashReportingOptedIn: boolean);
|
|
152
|
+
constructor(dataCollectionLevel: DataCollectionLevel, crashReportingOptedIn: boolean, screenRecordOptedIn?: boolean);
|
|
151
153
|
/**
|
|
152
154
|
* Gets the current data collection level.
|
|
153
155
|
*
|
|
@@ -216,6 +218,8 @@ declare class UserPrivacyOptions {
|
|
|
216
218
|
* @see https://www.npmjs.com/package/@dynatrace/react-native-plugin#user-privacy-options
|
|
217
219
|
*/
|
|
218
220
|
set dataCollectionLevel(dataCollectionLevel: DataCollectionLevel);
|
|
221
|
+
get screenRecordOptedIn(): boolean;
|
|
222
|
+
set screenRecordOptedIn(screenRecordOptedIn: boolean);
|
|
219
223
|
}
|
|
220
224
|
|
|
221
225
|
/**
|
|
@@ -394,15 +398,16 @@ interface IDynatraceAction {
|
|
|
394
398
|
*/
|
|
395
399
|
cancel(platform?: Platform): void;
|
|
396
400
|
/**
|
|
397
|
-
* Generates a
|
|
398
|
-
*
|
|
399
|
-
* using `getRequestTagHeader()`.
|
|
401
|
+
* Generates a unique x-dynatrace header for the web request with a specified url,
|
|
402
|
+
* which has to be manually added as http header.
|
|
400
403
|
*
|
|
401
|
-
*
|
|
402
|
-
*
|
|
404
|
+
* This is the same tag that was provided when constructing the DynatraceWebRequestTiming instance.
|
|
405
|
+
* The header key can be obtained with the method getRequestTagHeader.
|
|
403
406
|
*
|
|
404
|
-
*
|
|
405
|
-
*
|
|
407
|
+
* The string value can be empty in cases when the agent is not able to send data, the agent is turned off completly,
|
|
408
|
+
* has not started yet or is not allowed to track web requests because of privacy reasons.
|
|
409
|
+
* The tag value is evaluated by the corresponding web server agent.
|
|
410
|
+
* The Dynatrace server will link the server-side PurePath data with this mobile user action.
|
|
406
411
|
*
|
|
407
412
|
* @param {string} url The URL of the request you want to track
|
|
408
413
|
* @returns {Promise<string>} The request tag value to be used as the HTTP header value
|
|
@@ -2081,8 +2086,16 @@ interface IDynatraceWebRequestTiming {
|
|
|
2081
2086
|
*/
|
|
2082
2087
|
stopWebRequestTimingWithSize(responseCode: number, responseMessage: string, requestSize: number, responseSize: number): void;
|
|
2083
2088
|
/**
|
|
2084
|
-
*
|
|
2089
|
+
* Generates a unique x-dynatrace header for the web request with a specified url,
|
|
2090
|
+
* which has to be manually added as http header.
|
|
2091
|
+
*
|
|
2085
2092
|
* This is the same tag that was provided when constructing the DynatraceWebRequestTiming instance.
|
|
2093
|
+
* The header key can be obtained with the method getRequestTagHeader.
|
|
2094
|
+
*
|
|
2095
|
+
* The string value can be empty in cases when the agent is not able to send data, the agent is turned off completly,
|
|
2096
|
+
* has not started yet or is not allowed to track web requests because of privacy reasons.
|
|
2097
|
+
* The tag value is evaluated by the corresponding web server agent.
|
|
2098
|
+
* The Dynatrace server will link the server-side PurePath data with this mobile user action.
|
|
2086
2099
|
*
|
|
2087
2100
|
* @returns {string} The request tag value to be used as the HTTP header value
|
|
2088
2101
|
*
|
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.reactOptions = void 0;
|
|
4
|
-
const nodePath = require("path");
|
|
5
|
-
const PathsConstants_1 = require("../../scripts/PathsConstants");
|
|
6
|
-
const CustomArgumentUtil_1 = require("../util/CustomArgumentUtil");
|
|
7
|
-
const config = require("../../scripts/Config");
|
|
8
|
-
const customArguments = (0, CustomArgumentUtil_1.readCustomArguments)();
|
|
9
|
-
let reactOptions;
|
|
10
|
-
exports.reactOptions = reactOptions;
|
|
11
|
-
try {
|
|
12
|
-
if (customArguments.isCustomConfigurationPathSet()) {
|
|
13
|
-
exports.reactOptions = reactOptions = config.readConfig(nodePath.join(PathsConstants_1.default.getApplicationPath(), customArguments.getCustomConfigurationPath()));
|
|
14
|
-
}
|
|
15
|
-
else {
|
|
16
|
-
exports.reactOptions = reactOptions = config.readConfig(nodePath.join(PathsConstants_1.default.getConfigFilePath()));
|
|
17
|
-
}
|
|
18
|
-
}
|
|
19
|
-
catch (_a) {
|
|
20
|
-
exports.reactOptions = reactOptions = undefined;
|
|
21
|
-
}
|