@dynatrace/react-native-plugin 2.343.1 → 2.347.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.
Files changed (60) hide show
  1. package/README.md +674 -656
  2. package/android/build.gradle +6 -2
  3. package/android/src/main/java/com/dynatrace/android/agent/DynatraceRNBridgeImpl.kt +24 -0
  4. package/files/plugin-runtime.gradle +17 -33
  5. package/files/plugin.gradle +1 -1
  6. package/instrumentation/BabelPluginDynatrace.js +1 -1
  7. package/instrumentation/libs/UserInteraction.js +20 -6
  8. package/instrumentation/libs/react-native/Lists.js +94 -0
  9. package/instrumentation/libs/react-native/index.js +4 -1
  10. package/instrumentation/libs/react-native.js +3 -0
  11. package/instrumentation/libs/react-navigation/ReactNavigation.js +14 -58
  12. package/instrumentation/libs/withOnPressMonitoring.js +3 -54
  13. package/internal.d.ts +2 -0
  14. package/internal.js +5 -1
  15. package/ios/DynatraceRNBridge.mm +37 -1
  16. package/lib/core/configuration/ConfigurationHandler.js +0 -21
  17. package/lib/core/logging/LogMessages.js +50 -0
  18. package/lib/dynatrace-reporter.js +1 -30
  19. package/lib/dynatrace-transformer.js +6 -34
  20. package/lib/next/configuration/INativeRuntimeConfiguration.js +0 -1
  21. package/lib/next/configuration/RuntimeConfigurationObserver.js +1 -6
  22. package/lib/next/events/spec/EventSpecContstants.js +1 -1
  23. package/lib/next/navigation/NavigationTracker.js +101 -0
  24. package/lib/next/navigation/useNavigationTracking.js +54 -0
  25. package/lib/next/triggers/TableReloadTracker.js +23 -0
  26. package/package.json +11 -21
  27. package/public.js +3 -1
  28. package/react-native-dynatrace.podspec +1 -1
  29. package/scripts/Android.js +1 -20
  30. package/scripts/Config.js +0 -4
  31. package/scripts/Deprecations.js +18 -0
  32. package/scripts/Install.js +13 -0
  33. package/scripts/PathsConstants.js +0 -4
  34. package/scripts/Uninstall.js +0 -15
  35. package/scripts/core/InstrumentCall.js +2 -3
  36. package/scripts/util/DeprecationReport.js +24 -0
  37. package/types.d.ts +212 -10
  38. package/instrumentation/DynatraceInstrumentation.js +0 -1
  39. package/instrumentation/libs/community/Picker.InstrInfo.js +0 -20
  40. package/instrumentation/libs/community/gesture-handler/Touchables.InstrInfo.js +0 -25
  41. package/instrumentation/libs/react-native/RefreshControl.InstrInfo.js +0 -12
  42. package/instrumentation/libs/react-native/Switch.InstrInfo.js +0 -12
  43. package/instrumentation/libs/react-native/Touchables.InstrInfo.js +0 -25
  44. package/instrumentation/model/Reference.js +0 -2
  45. package/instrumentation/parser/Babel.js +0 -60
  46. package/instrumentation/parser/ParserUtil.js +0 -11
  47. package/lib/features/ui-interaction/Config.js +0 -42
  48. package/lib/features/ui-interaction/IUserInteractionEvent.js +0 -16
  49. package/lib/features/ui-interaction/Plugin.Fragment.Test.js +0 -170
  50. package/lib/features/ui-interaction/Plugin.js +0 -289
  51. package/lib/features/ui-interaction/RootDetection.js +0 -51
  52. package/lib/features/ui-interaction/RootWrapper.js +0 -236
  53. package/lib/features/ui-interaction/Run.js +0 -38
  54. package/lib/features/ui-interaction/Runtime.js +0 -843
  55. package/lib/features/ui-interaction/TouchMetaResolver.js +0 -493
  56. package/lib/features/ui-interaction/Types.js +0 -14
  57. package/lib/metro/getSourceMapInfo.js +0 -26
  58. package/scripts/LineOffsetAnalyze.js +0 -25
  59. package/scripts/core/LineOffsetAnalyzeCall.js +0 -165
  60. package/scripts/util/SourceMapUtil.js +0 -68
@@ -1,7 +1,7 @@
1
1
  #!/usr/bin/env node
2
2
  'use strict';
3
3
  Object.defineProperty(exports, "__esModule", { value: true });
4
- exports.ensureRuntimeScriptApplied = exports.writeGradleConfig = exports.instrumentAndroidPlatform = exports.GRADLE_APPLY_RUNTIME_SCRIPT_KTS = exports.GRADLE_APPLY_RUNTIME_SCRIPT = exports.GRADLE_APPLY_BUILDSCRIPT_KTS = exports.GRADLE_APPLY_BUILDSCRIPT = exports.GRADLE_DYNATRACE_FILE_KTS = exports.GRADLE_DYNATRACE_FILE = void 0;
4
+ exports.writeGradleConfig = exports.instrumentAndroidPlatform = exports.GRADLE_APPLY_BUILDSCRIPT_KTS = exports.GRADLE_APPLY_BUILDSCRIPT = exports.GRADLE_DYNATRACE_FILE_KTS = 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");
@@ -14,19 +14,15 @@ const GRADLE_BUILDSCRIPT_IDENTIFIER = 'buildscript';
14
14
  exports.GRADLE_APPLY_BUILDSCRIPT = 'apply from: "../node_modules/@dynatrace/react-native-plugin/files/plugin.gradle", to: buildscript';
15
15
  exports.GRADLE_APPLY_BUILDSCRIPT_KTS = 'apply(from = "../node_modules/@dynatrace/react-native-plugin/files/plugin.gradle", to = buildscript)';
16
16
  const GRADLE_REACT_NATIVE_PLUGIN = 'apply plugin: "com.facebook.react.rootproject"';
17
- exports.GRADLE_APPLY_RUNTIME_SCRIPT = 'apply from: "../../node_modules/@dynatrace/react-native-plugin/files/plugin-runtime.gradle"';
18
- exports.GRADLE_APPLY_RUNTIME_SCRIPT_KTS = 'apply(from = "../../node_modules/@dynatrace/react-native-plugin/files/plugin-runtime.gradle")';
19
17
  const isKotlinDslGradleFile = (pathToGradle) => pathToGradle.endsWith('.gradle.kts');
20
18
  const getGradleStatements = (pathToGradle) => isKotlinDslGradleFile(pathToGradle)
21
19
  ? {
22
20
  applyBuildscript: exports.GRADLE_APPLY_BUILDSCRIPT_KTS,
23
21
  dynatraceFile: exports.GRADLE_DYNATRACE_FILE_KTS,
24
- runtimeScript: exports.GRADLE_APPLY_RUNTIME_SCRIPT_KTS,
25
22
  }
26
23
  : {
27
24
  applyBuildscript: exports.GRADLE_APPLY_BUILDSCRIPT,
28
25
  dynatraceFile: exports.GRADLE_DYNATRACE_FILE,
29
- runtimeScript: exports.GRADLE_APPLY_RUNTIME_SCRIPT,
30
26
  };
31
27
  const instrumentAndroidPlatform = (pathToGradle, remove) => {
32
28
  const path = FileOperationHelper_1.default.checkIfFileExistsSync(pathToGradle);
@@ -165,18 +161,3 @@ const removeOldGradleConfig = (gradleFileContent) => {
165
161
  gradleFileContentLines.splice(gradleConfigIndex[0] + 1, gradleConfigIndex[1] - (gradleConfigIndex[0] + 1));
166
162
  return gradleFileContentLines;
167
163
  };
168
- const ensureRuntimeScriptApplied = (pathToGradle) => {
169
- const gradleContent = FileOperationHelper_1.default.readTextFromFileSync(pathToGradle);
170
- const gradleLines = gradleContent.split('\n');
171
- const { runtimeScript } = getGradleStatements(pathToGradle);
172
- const alreadyApplied = gradleLines.some((line) => line.includes('plugin-runtime.gradle'));
173
- if (!alreadyApplied) {
174
- gradleLines.push(runtimeScript);
175
- FileOperationHelper_1.default.writeTextToFileSync(pathToGradle, gradleLines.join('\n'));
176
- Logger_1.default.logMessageSync(`Added runtime script to ${pathToGradle}`, Logger_1.default.INFO);
177
- }
178
- else {
179
- Logger_1.default.logMessageSync(`Runtime script already present in ${pathToGradle}`, Logger_1.default.INFO);
180
- }
181
- };
182
- exports.ensureRuntimeScriptApplied = ensureRuntimeScriptApplied;
package/scripts/Config.js CHANGED
@@ -38,10 +38,6 @@ exports.defaultConfig = {
38
38
  enabled: true,
39
39
  },
40
40
  userInteraction: true,
41
- sourcemap: {
42
- enabled: true,
43
- androidSourcemapLocation: 'app/build/generated/sourcemaps/react/release/index.android.bundle.map',
44
- },
45
41
  },
46
42
  };
47
43
  const readConfigDefault = () => {
@@ -0,0 +1,18 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.DEPRECATIONS = exports.readInstalledPackageVersion = void 0;
4
+ const node_path_1 = require("node:path");
5
+ const FileOperationHelper_1 = require("./FileOperationHelper");
6
+ const PathsConstants_1 = require("./PathsConstants");
7
+ const readInstalledPackageVersion = (packageName) => {
8
+ var _a;
9
+ try {
10
+ const raw = FileOperationHelper_1.default.readTextFromFileSync((0, node_path_1.join)(PathsConstants_1.default.getApplicationPath(), 'node_modules', packageName, 'package.json'));
11
+ return (_a = JSON.parse(raw).version) !== null && _a !== void 0 ? _a : null;
12
+ }
13
+ catch (_b) {
14
+ return null;
15
+ }
16
+ };
17
+ exports.readInstalledPackageVersion = readInstalledPackageVersion;
18
+ exports.DEPRECATIONS = [];
@@ -0,0 +1,13 @@
1
+ #!/usr/bin/env node
2
+ 'use strict';
3
+ Object.defineProperty(exports, "__esModule", { value: true });
4
+ const DeprecationReport_1 = require("./util/DeprecationReport");
5
+ const Logger_1 = require("./Logger");
6
+ module.exports = (() => {
7
+ try {
8
+ (0, DeprecationReport_1.showDeprecationWarnings)();
9
+ Logger_1.default.closeLogFile();
10
+ }
11
+ catch (_a) {
12
+ }
13
+ })();
@@ -30,10 +30,6 @@ exports.default = {
30
30
  getPackageJsonFile() {
31
31
  return (0, node_path_1.join)(this.getApplicationPath(), 'package.json');
32
32
  },
33
- getMetroSouceMapPath() {
34
- return (0, node_path_1.join)(this.getApplicationPath(), 'node_modules', 'metro', 'src', 'DeltaBundler', 'Serializers', 'helpers');
35
- },
36
- getOurSourceMapFile: () => (0, node_path_1.join)(getPluginPath(), 'lib', 'metro', 'getSourceMapInfo.js'),
37
33
  getInternalPackageJsonFile: () => (0, node_path_1.join)(getPluginPath(), 'package.json'),
38
34
  getDefaultConfig: () => (0, node_path_1.join)(getPluginPath(), PATH_FILES, 'default.config.js'),
39
35
  getBuildPath: () => (0, node_path_1.join)(getPluginPath(), 'build'),
@@ -16,20 +16,6 @@ const FileOperationHelper_1 = require("./FileOperationHelper");
16
16
  const PathsConstants_1 = require("./PathsConstants");
17
17
  const android = require("./Android");
18
18
  const Ios_1 = require("./Ios");
19
- const removePatchMetroSourceMap = () => __awaiter(void 0, void 0, void 0, function* () {
20
- Logger_1.default.logMessageSync('Undo Patching SourceMap generation of Metro .. ', Logger_1.default.INFO);
21
- try {
22
- const currentSourceMapPath = nodePath.join(PathsConstants_1.default.getMetroSouceMapPath(), 'getSourceMapInfo.js');
23
- const origSourceMapPath = nodePath.join(PathsConstants_1.default.getMetroSouceMapPath(), 'getSourceMapInfoOrig.js');
24
- yield FileOperationHelper_1.default.checkIfFileExists(origSourceMapPath);
25
- yield FileOperationHelper_1.default.deleteFile(currentSourceMapPath);
26
- yield FileOperationHelper_1.default.renameFile(origSourceMapPath, currentSourceMapPath);
27
- Logger_1.default.logMessageSync('Removed patch for SourceMap generation of Metro!', Logger_1.default.INFO);
28
- }
29
- catch (e) {
30
- Logger_1.default.logMessageSync('Removing of patch for SourceMap generation failed!', Logger_1.default.ERROR);
31
- }
32
- });
33
19
  const removeGradleModification = () => __awaiter(void 0, void 0, void 0, function* () {
34
20
  try {
35
21
  const path = yield FileOperationHelper_1.default.checkIfFileExists(nodePath.join(PathsConstants_1.default.getAndroidFolder(), 'build.gradle'));
@@ -48,7 +34,6 @@ const removePListModification = () => __awaiter(void 0, void 0, void 0, function
48
34
  }
49
35
  });
50
36
  module.exports = (() => __awaiter(void 0, void 0, void 0, function* () {
51
- yield removePatchMetroSourceMap();
52
37
  yield removeGradleModification();
53
38
  yield removePListModification();
54
39
  }))();
@@ -8,9 +8,9 @@ const android = require("../Android");
8
8
  const PathsConstants_1 = require("../PathsConstants");
9
9
  const Ios_1 = require("../Ios");
10
10
  const InstrumentUtil_1 = require("../util/InstrumentUtil");
11
+ const DeprecationReport_1 = require("../util/DeprecationReport");
11
12
  const CustomArgumentUtil_1 = require("../util/CustomArgumentUtil");
12
13
  const Platform_1 = require("../api/model/Platform");
13
- const SourceMapUtil_1 = require("../util/SourceMapUtil");
14
14
  const platformLogPrefix = { info: ' ℹ️ ', warning: ' ⚠️ ', error: ' ❌ ' };
15
15
  const logHelpMessage = () => {
16
16
  const iOSDefaultPath = (0, node_path_1.join)(PathsConstants_1.default.getIOSFolder(), '<appName>', 'Info.plist');
@@ -93,7 +93,6 @@ const instrumentAndroidIfAvailable = (androidAvailable, pathToGradle, pathToAppG
93
93
  Logger_1.default.withPrefix(platformLogPrefix, () => {
94
94
  android.instrumentAndroidPlatform(pathToGradle, false);
95
95
  android.writeGradleConfig(androidConfig, pathToGradle);
96
- android.ensureRuntimeScriptApplied(pathToAppGradle);
97
96
  });
98
97
  Logger_1.default.logMessageSync(' ✅ Finished Android Instrumentation with Dynatrace!', Logger_1.default.INFO);
99
98
  }
@@ -128,7 +127,6 @@ const runPlatformInstrumentation = (paths, availability) => {
128
127
  const configAgent = (0, Config_1.readConfig)(paths.pathToConfig);
129
128
  instrumentAndroidIfAvailable(availability.androidAvailable, paths.pathToGradle, paths.pathToAppGradle, configAgent.android);
130
129
  instrumentIosIfAvailable(availability.iosAvailable, paths.pathToPList, configAgent.ios);
131
- (0, SourceMapUtil_1.patchMetroSourceMap)();
132
130
  Logger_1.default.logMessageSync('🎉 Finished instrumentation of React Native application ..', Logger_1.default.INFO);
133
131
  }
134
132
  catch (e) {
@@ -150,6 +148,7 @@ const instrumentCommand = () => {
150
148
  }
151
149
  Logger_1.default.logMessageSync('⏳ Starting instrumentation of React Native application ..', Logger_1.default.INFO);
152
150
  Logger_1.default.withPrefix({ info: ' ℹ️ ', warning: ' ⚠️ ' }, () => (0, InstrumentUtil_1.showVersionOfPlugin)());
151
+ (0, DeprecationReport_1.showDeprecationWarnings)();
153
152
  const argv = (0, CustomArgumentUtil_1.parseCommandLine)(commandArgs.slice(2));
154
153
  persistCustomArguments(argv);
155
154
  const instrumentationPaths = resolveInstrumentationPaths(argv);
@@ -0,0 +1,24 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.showDeprecationWarnings = void 0;
4
+ const Logger_1 = require("../Logger");
5
+ const Deprecations_1 = require("../Deprecations");
6
+ const formatEntry = (entry) => `⚠️ Deprecation [${entry.id}]: ${entry.description}\n` +
7
+ ` Deprecated since: plugin v${entry.deprecatedSince}\n` +
8
+ ` Removal planned: plugin v${entry.removalVersion}\n` +
9
+ ` Migration: ${entry.migration}`;
10
+ const showDeprecationWarnings = () => {
11
+ for (const entry of Deprecations_1.DEPRECATIONS) {
12
+ let applicable;
13
+ try {
14
+ applicable = entry.isApplicable();
15
+ }
16
+ catch (_a) {
17
+ applicable = false;
18
+ }
19
+ if (applicable) {
20
+ Logger_1.default.logMessageSync(formatEntry(entry), Logger_1.default.WARNING);
21
+ }
22
+ }
23
+ };
24
+ exports.showDeprecationWarnings = showDeprecationWarnings;