@dynatrace/react-native-plugin 2.321.2 → 2.323.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.
Files changed (39) hide show
  1. package/README.md +54 -17
  2. package/android/build.gradle +3 -3
  3. package/files/plugin-runtime.gradle +8 -1
  4. package/files/plugin.gradle +1 -1
  5. package/index.js +1 -0
  6. package/instrumentation/DynatraceInstrumentation.js +1 -1
  7. package/instrumentation/jsx/CreateElement.js +1 -1
  8. package/instrumentation/jsx/ElementHelper.js +2 -21
  9. package/instrumentation/jsx/IDynatraceProperties.js +0 -7
  10. package/instrumentation/jsx/JsxDevRuntime.js +2 -7
  11. package/instrumentation/jsx/JsxRuntime.js +2 -7
  12. package/instrumentation/jsx/components/ComponentUtil.js +12 -1
  13. package/instrumentation/jsx/components/Picker.js +3 -3
  14. package/instrumentation/jsx/components/RefreshControl.js +3 -3
  15. package/instrumentation/libs/community/gesture-handler/Touchables.js +7 -37
  16. package/instrumentation/libs/react-native/Switch.js +55 -12
  17. package/instrumentation/libs/react-native/Touchables.js +8 -47
  18. package/instrumentation/libs/withOnPressMonitoring.js +121 -0
  19. package/instrumentation/model/Types.js +3 -15
  20. package/instrumentation/model/TypesUtil.js +5 -34
  21. package/lib/core/Dynatrace.js +4 -1
  22. package/lib/core/ErrorHandler.js +18 -34
  23. package/lib/next/Dynatrace.js +16 -10
  24. package/lib/next/events/EventCreator.js +2 -1
  25. package/lib/next/events/HttpRequestEventBuilder.js +196 -0
  26. package/lib/next/events/ViewInfoCreator.js +1 -1
  27. package/lib/next/events/modifier/EventModifierUtil.js +14 -1
  28. package/lib/next/events/modifier/SendEventValidation.js +23 -10
  29. package/lib/next/events/spec/EventSpecContstants.js +1 -1
  30. package/package.json +6 -4
  31. package/react-native-dynatrace.podspec +1 -1
  32. package/scripts/Ios.js +1 -1
  33. package/scripts/Logger.js +20 -1
  34. package/scripts/core/InstrumentCall.js +62 -34
  35. package/scripts/util/SourceMapUtil.js +4 -4
  36. package/src/instrumentation/jsx/IDynatraceProperties.ts +15 -0
  37. package/typings/react-native-dynatrace.d.ts +130 -1
  38. package/instrumentation/jsx/components/Switch.js +0 -57
  39. package/instrumentation/jsx/components/Touchable.js +0 -151
package/README.md CHANGED
@@ -21,19 +21,20 @@ If you want to start using this plugin and are not a Dynatrace customer yet, hea
21
21
  ## Requirements
22
22
  * React v16.8 or newer
23
23
  * React Native v0.60 or newer
24
- * For Android users:
24
+ * For Android users:
25
25
  * SDK version 21+
26
26
  * Gradle version 7.0+ ([How to update?](#updating-to-gradle-7))
27
27
  * Android Gradle plugin version 7.0+
28
28
  * Java 11
29
+ * Kotlin 2.0.21 — see [Kotlin Compatibility Note](#⚠️-kotlin-compatibility-note)
29
30
  * For iOS users: Minimum iOS 12
30
- * NodeJS 18.18+
31
+ * NodeJS 16.0.0+ since our dependencies require NodeJS 16.0.0
31
32
 
32
33
  ## Agent Versions
33
34
  This agent versions are configured in this plugin:
34
35
 
35
- * Android Agent: 8.321.1.1009
36
- * iOS Agent: 8.321.1.1007
36
+ * Android Agent: 8.323.1.1002
37
+ * iOS Agent: 8.323.1.1009
37
38
 
38
39
  ## Quick Setup
39
40
 
@@ -80,9 +81,11 @@ This agent versions are configured in this plugin:
80
81
  * [React Automatic Runtime](#react-automatic-runtime)
81
82
  * [Using a second transformer besides the dynatrace transformer](#using-a-second-transformer-besides-the-dynatrace-transformer)
82
83
  * [Upgrading project to Gradle 7](#updating-to-gradle-7)
84
+ * [Kotlin Compatibility Note](#⚠️-kotlin-compatibility-note)
83
85
  * [Maven Central in top-level gradle file](#maven-central-in-top-level-gradle-file)
84
86
  * [Configuration of standalone React Native project](#configuration-of-standalone-react-native-project)
85
87
  * [Instrumentation Overhead](#instrumentation-overhead)
88
+ * [Typescript Setup for dtActionName and dtActionIgnore](#typescript-setup-for-dtactionignore-and-dtactionname)
86
89
 
87
90
  ## Troubleshooting
88
91
  * [Documentation](#dynatrace-documentation)
@@ -681,11 +684,7 @@ export default TouchableHighlightScreen;
681
684
 
682
685
  This example shows two *TouchableHighlight*, which will fire the *onPress()* function when pressed. The property `dtActionIgnore="true"` will prevent the monitoring of one of them. This means that the onPress will still be executed but we will no longer create a user action which is wrapping the button click.
683
686
 
684
- If you want to set this property and use typescript you can use the following workaround:
685
-
686
- ```ts
687
- <TouchableHighlight {...{ "dtActionIgnore": "true" }}><Text>TouchableHighlight that will be ignored</Text></TouchableHighlight>
688
- ```
687
+ >*Attention:* If you are using Typescript and want to set this property with type-safety, look [here](#typescript-setup-for-dtactionignore-and-dtactionname).
689
688
  ## NPX Commands
690
689
 
691
690
  The following npx commands are available for the plugin:
@@ -1128,20 +1127,18 @@ ios: {
1128
1127
 
1129
1128
  ## Using dtActionName to change the name of the action
1130
1129
 
1131
- We check for a property named `dtActionName` when creating an action. If `dtActionName` exists, this will be used for the action name above every other option listed in the previous section. Examples:
1132
-
1133
- Typescript:
1134
- ```ts
1135
- <TouchableHighlight {...{ "dtActionName": "CustomActionName" }}><Text>Custom Action Name</Text></TouchableHighlight>
1136
- ```
1130
+ We check for a property named `dtActionName` when creating an action. If `dtActionName` exists, this will be used for the action name above every other option listed in the previous section. Example:
1137
1131
 
1138
- JavaScript:
1139
1132
  ```js
1140
- <TouchableHighlight dtActionName="CustomActionName"><Text>Custom Action Name</Text></TouchableHighlight>
1133
+ <TouchableHighlight dtActionName="CustomActionName">
1134
+ <Text>Custom Action Name</Text>
1135
+ </TouchableHighlight>
1141
1136
  ```
1142
1137
 
1143
1138
  *Note:* [actionNamePrivacy](#plugin-startup) has no impact on using dtActionName. dtActionName will always be used.
1144
1139
 
1140
+ >*Attention:* If you are using Typescript and want to set this property with type-safety, look [here](#typescript-setup-for-dtactionignore-and-dtactionname).
1141
+
1145
1142
  ## How does Dynatrace automatically report crashes?
1146
1143
 
1147
1144
  In general, Dynatrace always closes the session when a crash occurs. Usually a crash is when the application gets fully terminated. In React Native, we also see fatal errors in the JavaScript part as a full crash even though the native application is still alive. When this happens we will end the session. This is due to visibility reasons and may change in the future. The automated crash reporting will be (automatically) put in place by the transformer at the very beginning of the application. Using a custom error handler afterwards will not interfere with our crash handler.
@@ -1383,6 +1380,18 @@ dependencies {
1383
1380
 
1384
1381
  ```
1385
1382
 
1383
+ ## ⚠️ Kotlin Compatibility Note
1384
+
1385
+ Our Android Agent currently (2025-09-15) requires **Kotlin 2.0.21**. However, it should be noted that using this version may cause compatibility issues with older versions of React Native and the corresponding `react-native-gradle-plugin` due to, for instance, differences in Kotlin metadata:
1386
+
1387
+ Kotlin embeds language-specific features that Java doesn't natively support (like nullability and extension functions) into bytecode using `@Metadata` annotations. These annotations include a `metadataVersion`.
1388
+
1389
+ - **React Native 0.66**, for instance, works with Kotlin 2.0.21 because its `react-native-gradle-plugin` does **not use Kotlin**, avoiding metadata conflicts.
1390
+ - **React Native 0.71**, for instance, uses a `react-native-gradle-plugin` compiled with Kotlin **1.7.22**, which expects `metadataVersion 1.6.0`. Using Kotlin 2.0.21 (which produces `metadataVersion 1.9.0`) can lead to build failures.
1391
+ - **React Native 0.72**, for instance, again is compatible with Kotlin 2.0.21, as its `react-native-gradle-plugin` expects a metadata version that is compatible with `1.9.0`.
1392
+
1393
+ In summary, ensure your build fulfills our Kotlin 2.0.21 requirement while simultaneously fulfilling the requirements of your React Native version and its `react-native-gradle-plugin`.
1394
+
1386
1395
  ## Configuration of standalone React Native project
1387
1396
 
1388
1397
  This section explains the configuration of a standalone React Native project. This means you have a React Native project, but don't use the typicial `iOS` and `android` folders. Instead you have a seperate native `iOS` or `android` project which is embedding your React Native project.
@@ -1424,6 +1433,24 @@ When using auto-instrumenation through our plugin, here are some examples of the
1424
1433
  | Android | Default new app | 0.74.3 | 50.7 MB | 50.9 MB | 0.2 MB |
1425
1434
  | iOS | Default new app | 0.74.3 | 28.1 MB | 36.5 MB | 8.4 MB |
1426
1435
 
1436
+ ## Typescript Setup for dtActionIgnore and dtActionName
1437
+
1438
+ We are using module augmentation to augment the IntrinsicAttributes Interface in the JSX namespace in the React module with dtActionName and dtActionIgnore. The IntrinsicAttributes Interface in the JSX namespace contains properties that you can pass to every JSX element, thus, in short, you can use dtActionName and dtActionIgnore with full type-safety on every JSX element if you follow the setup below.
1439
+
1440
+ In general, ambient/global type declarations in packages like @dynatrace/react-native-plugin in your node_modules are visible and thus available to you for type checking in at least these cases:
1441
+
1442
+ 1. You import any type from a .ts or .d.ts file located in our package anywhere in your project. For instance, if you do `import { Dynatrace } from '@dynatrace/react-native-plugin'` anywhere in your project, Typescript will consider our Types and the module augmentation will work.
1443
+
1444
+ 2. You update your `tsconfig.json` to include our types, which will also make the module augmentation work:
1445
+ ```json
1446
+ "compilerOptions": {
1447
+ "types": [
1448
+ "@dynatrace/react-native-plugin"
1449
+ ]
1450
+ }
1451
+ ```
1452
+ We recommend the second option, since it works independent of whether you import anything from `@dynatrace/react-native-plugin`. We simply show the first option in case you wonder why `dtActionName` and `dtActionIgnore` are available on JSX elements despite not having added any configuration.
1453
+
1427
1454
  ## Troubleshooting and applicable restrictions
1428
1455
 
1429
1456
  >**Attention:** If you think something is not working the way it should, ALWAYS try to reset the cache of metro first before starting a support case. You can do this via the CLI *react-native start --reset-cache*. If it still does not work feel free to open a support case.
@@ -1464,6 +1491,16 @@ If you are struggling with a problem, submit a support ticket to Dynatrace (supp
1464
1491
  <br/><br/>
1465
1492
  ## Changelog
1466
1493
 
1494
+ 2.323.2
1495
+ * Fixed error "Execution failed for task ':app:mergeReleaseAssets'. A problem occured starting process 'command 'npx''" when building for release on Windows.
1496
+ * Downgraded required NodeJS version to 16.0.0+
1497
+ * Fixing Switch instrumentation for React Native 0.81+
1498
+
1499
+ 2.323.1
1500
+ * Updated Android (8.323.1.1002) & iOS Agent (8.323.1.1009)
1501
+ * Fixing Touchable/Text instrumentation for React Native 0.81+
1502
+ * Added [module augmentation of React](#typescript-setup-for-dtactionignore-and-dtactionname) to allow using dtActionName and dtActionIgnore type-safely on every JSX Element
1503
+
1467
1504
  2.321.1
1468
1505
  * Updated Android (8.321.1.1009) & iOS Agent (8.321.1.1007)
1469
1506
  * Auto startup fixed for React Native v0.80 and higher
@@ -11,7 +11,7 @@ def isNewArchitectureEnabled() {
11
11
  buildscript {
12
12
  repositories {
13
13
  google()
14
- jcenter()
14
+ mavenCentral()
15
15
  }
16
16
 
17
17
  dependencies {
@@ -68,11 +68,11 @@ android {
68
68
 
69
69
  repositories {
70
70
  google()
71
- jcenter()
71
+ mavenCentral()
72
72
  }
73
73
 
74
74
  dependencies {
75
- implementation 'com.dynatrace.agent:agent-android:8.321.1.1009'
75
+ implementation 'com.dynatrace.agent:agent-android:8.323.1.1002'
76
76
  implementation "com.facebook.react:react-native:${safeExtGet('reactNative', '+')}"
77
77
  }
78
78
 
@@ -1,3 +1,5 @@
1
+ import org.gradle.nativeplatform.platform.internal.DefaultNativePlatform
2
+
1
3
  android.applicationVariants.all { variant ->
2
4
  if (variant.buildType.name == "release") {
3
5
  variant.mergeAssetsProvider.configure { task ->
@@ -10,7 +12,12 @@ android.applicationVariants.all { variant ->
10
12
 
11
13
  exec {
12
14
  workingDir rootDir
13
- commandLine 'npx', 'lineOffsetDynatrace', 'env=prod'
15
+ if (DefaultNativePlatform.currentOperatingSystem.isWindows()) {
16
+ // On windows, npx.cmd may not be a true binary executable and may need to be interpreted by a shell instead of executed direclty
17
+ commandLine 'cmd', '/c', 'npx', 'lineOffsetDynatrace', 'env=prod'
18
+ } else {
19
+ commandLine 'npx', 'lineOffsetDynatrace', 'env=prod'
20
+ }
14
21
  }
15
22
 
16
23
  } else {
@@ -1,4 +1,4 @@
1
1
  // TEMPLATE: plugin-gradle.template
2
2
  dependencies {
3
- classpath 'com.dynatrace.tools.android:gradle-plugin:8.321.1.1009'
3
+ classpath 'com.dynatrace.tools.android:gradle-plugin:8.323.1.1002'
4
4
  }
package/index.js CHANGED
@@ -8,3 +8,4 @@ export { ApplicationHandler } from './lib/core/Application';
8
8
  export { UserPrivacyOptions } from './lib/core/UserPrivacyOptions';
9
9
  export { DynatraceWebRequestTiming } from './lib/core/DynatraceWebRequestTiming';
10
10
  export { createElement } from './instrumentation/jsx/CreateElement';
11
+ export { default as HttpRequestEventBuilder } from './lib/next/events/HttpRequestEventBuilder'
@@ -1 +1 @@
1
- var o,n=require("@babel/runtime/helpers/interopRequireDefault"),e=n(require("@babel/runtime/helpers/toConsumableArray")),l=(Object.defineProperty(exports,"t",{value:!0}),exports.instrument=void 0,require("path")),i=require("jscodeshift"),u=require("jscodeshift/src/Collection"),r=require("../scripts/FileOperationHelper"),c=require("../scripts/PathsConstants"),f=require("../lib/core/util/GetValuesFromPackage"),t=require("../scripts/util/InstrumentUtil"),a=require("./libs/react-native/Touchables.InstrInfo"),s=require("./libs/react-native/RefreshControl.InstrInfo"),d=require("./libs/react-native/Switch.InstrInfo"),v=require("./libs/community/gesture-handler/Touchables.InstrInfo"),p=require("./libs/community/Picker.InstrInfo"),m=require("./model/Types"),y=require("./parser/ParserUtil"),g=((n=>{n[n.i=-1]="Filtered",n[n.u=0]="Normal",n[n.o=1]="ReactNative",n[n.l=2]="React",n[n.v=3]="ReactNativeCssInterop"})(o=o||{}),[]),b=(g.push.apply(g,(0,e.default)(a.instrumentationInfo)),g.push.apply(g,(0,e.default)(s.instrumentationInfo)),g.push.apply(g,(0,e.default)(d.instrumentationInfo)),g.push.apply(g,(0,e.default)(v.instrumentationInfo)),g.push.apply(g,(0,e.default)(p.instrumentationInfo)),["AppRegistry","AppRegistryImpl","renderApplication","setUpErrorHandling"]),U="@dynatrace/react-native-plugin/instrumentation/libs",instrument=function(n,e,r){e=k(e);var t,i=K(e);if(i!==o.i){var u=!1,a=I(e,n);if(i===o.l)w(a),u=!0;else if(i===o.o)e.endsWith("AppRegistryImpl.js")?null!=r&&r.autoStart&&J(a)&&(u=!0):e.endsWith("AppRegistry.js")?null!=r&&r.autoStart&&M(a)&&(u=!0):e.endsWith("renderApplication.js")?(q(a),u=!0):e.endsWith("setUpErrorHandling.js")&&void 0!==r&&r.autoStart&&r.errorHandler.enabled&&(G(a,r.autoStart,r.errorHandler.reportFatalErrorAsCrash),u=!0);else if(i===o.v)u=z(a)||u;else{var i=T(e,r);if(r.custom.reactnavigation&&B(e,a))u=!0;else{if(!i.input&&!i.lifecycle)return null!=r&&r.debug&&console.log("Dynatrace - Filtered All: ".concat(e)),N(e),n;i.lifecycle&&q(a)&&(u=!0),i.input&&g.forEach(function(n){n=Y(a,n);a=n.root,u=u||n.p})}}u?(n=a.toSource({quote:"single"}),x(n,e)):N(e),null!=r&&r.debug&&u&&console.log("Dynatrace - Modified Filename: "+e)}else e.includes(l.join("@dynatrace","react-native-plugin"))&&e.endsWith(l.join("lib","core","configuration","ConfigurationPreset.js"))&&void 0!==r&&(i=(0,f.getHostAppBundleInfo)(c.default.getPackageJsonFile()),t=I(e,n),void 0!==r.lifecycle&&j(t,"getLifecycleUpdate",r.lifecycle.includeUpdate),void 0!==r.debug&&j(t,"getLogLevel",r.debug?0:1),void 0!==r.bundleName?j(t,"getBundleName",r.bundleName):null!==i&&j(t,"getBundleName",null==i?void 0:i.name),void 0!==r.bundleVersion?j(t,"getBundleVersion",r.bundleVersion):null!==i&&j(t,"getBundleVersion",null==i?void 0:i.version),void 0!==r.input&&void 0!==r.input.actionNamePrivacy&&j(t,"getActionNamePrivacy",r.input.actionNamePrivacy),void 0!==r.errorHandler&&(j(t,"isErrorHandlerEnabled",r.errorHandler.enabled),j(t,"isReportFatalErrorAsCrash",r.errorHandler.reportFatalErrorAsCrash)),r.autoStart&&j(t,"isAutoStartupEnabled",r.autoStart),n=t.toSource({quote:"single"}),x(n,e));return n},B=(exports.instrument=instrument,function(n,e){return!!O(n,e)&&(n="import { registerListener } from '".concat(U,"/react-navigation/ReactNavigation';"),e.find(i.ImportDeclaration).at(0).insertBefore(n),!0)}),O=function(n,e){var r=!1;return n.includes("react-navigation")&&n.includes("NavigationContainer.tsx")&&e.find(i.VariableDeclarator).forEach(function(n){r||null==n.value||null==n.value.id||"refContainer"!==n.value.id.name||null!=n.parent&&null!=n.parent.value&&null!=n.parent.value.type&&"VariableDeclaration"===n.parent.value.type&&(n.parent.insertAfter("registerListener(refContainer);"),r=!0)}),r},q=function(n){var e=n.findJSXElements(),t=!1;return 0<e.length&&(n.find(i.FunctionDeclaration).forEach(function(n){var e,r=(0,u.fromPaths)([n]);0<r.findJSXElements().length&&null!=n&&null!=n.value&&null!=n.value.id&&n.value.id.name.toString()&&(e=r.find(i.ClassDeclaration),r=r.find(i.ClassExpression),0===e.length)&&0===r.length&&(A(n,m.Types.FunctionalComponent,n.value.id.name.toString()),t=!0)}),n.find(i.ClassDeclaration).forEach(function(n){0<(0,u.fromPaths)([n]).findJSXElements().length&&null!=n&&null!=n.value&&n.value.id&&n.value.id.name.toString()&&(A(n,m.Types.ClassComponent,n.value.id.name.toString()),t=!0)}),n.find(i.ArrowFunctionExpression).forEach(function(n){0<(0,u.fromPaths)([n]).findJSXElements().length&&null!=n.parent&&null!=n.parent.value&&null!=n.parent.value.id&&null!=n.parent.value.id.name&&(A(n,m.Types.FunctionalComponent,n.parent.value.id.name),t=!0)})),t},A=function(n,e,r){for(e=i.expressionStatement(i.assignmentExpression("=",i.memberExpression(i.identifier(r),i.identifier("_dtInfo")),V(e,r)));"body"!==(null==n?void 0:n.parentPath.name);)n=n.parentPath;void 0!==n.parentPath&&n.insertAfter(e)},V=function(n,e){return i.objectExpression([i.objectProperty(i.identifier("type"),i.numericLiteral(n)),i.objectProperty(i.identifier("name"),i.stringLiteral(e))])},j=function(n,e,r){var n=n.find(i.Identifier).filter(function(n){return n.node.name===e});1===n.length&&"ReturnStatement"===(n=n.paths()[0].parent.value.body.body[0]).type&&("boolean"==typeof r&&(n.argument=i.booleanLiteral(r)),"string"==typeof r&&(n.argument=i.stringLiteral(r)),"number"==typeof r)&&(n.argument=i.numericLiteral(r))},I=function(n,e){return i.withParser((0,y.chooseParser)(n,e))(e)},k=function(n){return l.isAbsolute(n)?n.replace(c.default.getApplicationPath()+l.sep,""):n},N=function(n){try{var e=l.join(c.default.getBuildPath(),n+t.INSTRUMENTED_FILE_EXTENSION);r.default.checkIfFileExistsSync(e),r.default.deleteFileSync(e)}catch(n){}},x=function(n,e){e=l.join(c.default.getBuildPath(),e);try{r.default.checkIfFileExistsSync(l.dirname(e))}catch(n){r.default.createDirectorySync(l.dirname(e))}r.default.writeTextToFileSync(e+t.INSTRUMENTED_FILE_EXTENSION,n)},T=function(n,e){var r={input:!1,lifecycle:!1};return void 0!==e&&(void 0!==e.lifecycle&&void 0!==e.lifecycle.instrument&&e.lifecycle.instrument(n)&&(r.lifecycle=!0),void 0!==e.input)&&void 0!==e.input.instrument&&e.input.instrument(n)&&(r.input=!0),r},w=function(n){var e,n=n.find(i.Program);1===n.length&&(e=i.expressionStatement(i.callExpression(i.memberExpression(i.callExpression(i.identifier("require"),[i.stringLiteral("@dynatrace/react-native-plugin/instrumentation/jsx/ElementHelper")]),i.identifier("instrumentCreateElement")),[i.memberExpression(i.identifier("module"),i.identifier("exports"))])),n.paths()[0].node.body.push(e))},J=function(n){var e=n.find(i.FunctionDeclaration,{id:{name:"runApplication"}});return 1===e.length&&(D(n,{m:"_DynatraceApplicationHandler",module:"@dynatrace/react-native-plugin",reference:"ApplicationHandler"}),H(e.get().value.body.body,0,_("_DynatraceApplicationHandler","startup",[])),!0)},M=function(n){var e=n.find(i.ObjectMethod,{key:{name:"runApplication"}});return 1===e.length&&(D(n,{m:"_DynatraceApplicationHandler",module:"@dynatrace/react-native-plugin",reference:"ApplicationHandler"}),H(e.get().value.body.body,0,_("_DynatraceApplicationHandler","startup",[])),!0)},G=function(n,e,r){n=n.paths()[0].value.program.body;null!=n&&(H(n,n.length,L({m:"_DynatraceErrorHandler",module:"@dynatrace/react-native-plugin/lib/core/ErrorHandler",reference:""})),H(n,n.length,_("_DynatraceErrorHandler","registerErrorHandler",[i.literal(r)])))},z=function(n){var e=!1,n=n.find(i.CallExpression,{callee:{name:"require"}});return n.find(i.Literal,{value:"react/jsx-runtime"}).replaceWith(function(n){n=n.node;return n.value="@dynatrace/react-native-plugin/jsx-runtime",e=!0,n}),n.find(i.Literal,{value:"react/jsx-dev-runtime"}).replaceWith(function(n){n=n.node;return n.value="@dynatrace/react-native-plugin/jsx-dev-runtime",e=!0,n}),e},H=function(n,e){for(var r=arguments.length,t=new Array(2<r?r-2:0),i=2;i<r;i++)t[i-2]=arguments[i];return n.splice.apply(n,[e,0].concat(t))},K=function(n){if(n.includes("@dynatrace"))return o.i;var e=l.extname(n);if(".js"!==e&&".ts"!==e&&".tsx"!==e&&".jsx"!==e)return o.i;for(var r=l.parse(n),t=r.dir.split(l.sep),i=0;i<t.length;i++)if("node_modules"===t[i]){if("react-native"===t[i+1]||"create-react-class"===t[i+1]||"react-clone-referenced-element"===t[i+1])return b.includes(r.name)?o.o:o.i;if("react"===t[i+1]&&"index"===r.name)return o.l;if("react-native-css-interop"===t[i+1]&&("jsx-runtime"===r.name||"jsx-dev-runtime"===r.name))return o.v}return o.u},Q=function(n,e,r){var t=W(n,e,r);return X(n,e,r)||t},W=function(n,e,r){var t=Z(n,e);return 0<t.length&&(void 0!==(t=R(t,e.reference,!1))&&(r.m=t.localName),un(n,r),!0)},X=function(n,e,r){var t=E(n,e.module);if(1===t.length){t=R(t,e.reference,!0);if(void 0!==t)return an(n,r.defaultImport,t.localName,"ImportNamespaceSpecifier"===t.type),!0}return!1},Y=function(n,e){var r=JSON.parse(JSON.stringify(e.new));return{root:n,p:Q(n,e.old,r)||$(n,e.old,e.new.defaultImport)}},Z=function(n,e){return n.find(i.ImportDeclaration).filter(function(n){return n.node.source.value===e.module&&null!=n.node.specifiers&&n.node.specifiers.some(function(n){return h(n)&&n.imported.name===e.reference||n.local&&n.local.name===e.reference})})},h=function(n){return void 0!==n.imported},$=function(n,e,r){var t=!1;return n.find(i.CallExpression).filter(function(n){return nn(n.node.callee)&&en(n.node.arguments[0])&&n.node.arguments[0].value===e.module&&void 0!==n.parent}).forEach(function(n){(void 0===n.parent.value.property||void 0!==n.parent.value.property&&void 0!==n.parent.value.property.name&&n.parent.value.property.name===e.reference)&&(n.node.arguments[0].value=r,t=t||!0)}),t},nn=function(n){return"require"===n.name},en=function(n){return"StringLiteral"===n.type||"Literal"===n.type},E=function(n,e){return n.find(i.ImportDeclaration).filter(function(n){return n.node.source.value===e})},R=function(n,r,t){var i;return n.forEach(function(n){void 0!==n.node.specifiers&&(n.node.specifiers=n.node.specifiers.filter(function(n){var e;return h(n)&&!t?((e=n.imported.name!==r)||null==n.local||n.imported.name===n.local.name||(i={localName:n.local.name.toString(),type:n.type}),e):!(!h(n)&&t&&(null!=n.local&&(i={localName:n.local.name.toString(),type:n.type}),1))}),0===n.node.specifiers.length)&&n.prune()}),i},rn=function(n,e){n.find(i.ImportDeclaration).filter(function(n){return n.node.source.value===e.module}).forEach(function(n){null!=n.node.specifiers&&n.node.specifiers.push(P(e))})},tn=function(n,e,r){n.find(i.ImportDeclaration).filter(function(n){return n.node.source.value===e}).forEach(function(n){null!=n.node.specifiers&&n.node.specifiers.push(r)})},C=function(n,e,r){var t=n.find(i.ImportDeclaration);0<t.length?i(t.paths()[0]).insertAfter(F(e,r)):1===(t=n.find(i.Program)).length&&t.paths()[0].node.body.unshift(F(e,r))},un=function(n,e){0<E(n,e.module).length?rn(n,e):C(n,e.module,[P(e)])},an=function(n,e,r,t){var i=E(n,e),t=(t?dn:sn)(r);0<i.length?tn(n,e,t):C(n,e,[t])},D=function(n,e){n=n.find(i.VariableDeclaration);0<n.length&&i(n.paths()[0]).insertAfter(L(e))},_=function(n,e,r){return i.expressionStatement(on(n,e,r))},on=function(n,e,r){return i.callExpression(fn(n,e),r)},L=function(n){return i.variableDeclaration("var",[ln(n)])},ln=function(n){return i.variableDeclarator(void 0!==n.m?i.identifier(n.m):i.identifier(n.reference),(0<n.reference.length?cn:S)(n))},cn=function(n){return i.memberExpression(S(n),i.identifier(n.reference))},fn=function(n,e){return i.memberExpression(i.identifier(n),i.identifier(e))},S=function(n){return i.callExpression(i.identifier("require"),[i.literal(n.module)])},F=function(n,e){return i.importDeclaration(e,i.literal(n))},P=function(n){return void 0!==n.m?i.importSpecifier(i.identifier(n.reference),i.identifier(n.m)):i.importSpecifier(i.identifier(n.reference))},sn=function(n){return i.importDefaultSpecifier(i.identifier(n))},dn=function(n){return i.importNamespaceSpecifier(i.identifier(n))};
1
+ var o,n=require("@babel/runtime/helpers/interopRequireDefault"),e=n(require("@babel/runtime/helpers/toConsumableArray")),c=(Object.defineProperty(exports,"t",{value:!0}),exports.instrument=void 0,require("path")),u=require("jscodeshift"),i=require("jscodeshift/src/Collection"),r=require("../scripts/FileOperationHelper"),l=require("../scripts/PathsConstants"),f=require("../lib/core/util/GetValuesFromPackage"),t=require("../scripts/util/InstrumentUtil"),a=require("./libs/react-native/Touchables.InstrInfo"),s=require("./libs/react-native/RefreshControl.InstrInfo"),v=require("./libs/react-native/Switch.InstrInfo"),d=require("./libs/community/gesture-handler/Touchables.InstrInfo"),p=require("./libs/community/Picker.InstrInfo"),m=require("./model/Types"),y=require("./parser/ParserUtil"),g=((n=>{n[n.i=-1]="Filtered",n[n.u=0]="Normal",n[n.o=1]="ReactNative",n[n.l=2]="React",n[n.v=3]="ReactNativeCssInterop"})(o=o||{}),[]),q=(g.push.apply(g,(0,e.default)(a.instrumentationInfo)),g.push.apply(g,(0,e.default)(s.instrumentationInfo)),g.push.apply(g,(0,e.default)(v.instrumentationInfo)),g.push.apply(g,(0,e.default)(d.instrumentationInfo)),g.push.apply(g,(0,e.default)(p.instrumentationInfo)),["AppRegistry","AppRegistryImpl","renderApplication","ExceptionsManager"]),b="@dynatrace/react-native-plugin/instrumentation/libs",instrument=function(n,e,r){e=T(e);var t=z(e);if(t!==o.i){var i=!1,u=I(e,n);if(t===o.l)k(u),i=!0;else if(t===o.o)e.endsWith("AppRegistryImpl.js")?null!=r&&r.autoStart&&U(u)&&(i=!0):e.endsWith("AppRegistry.js")?null!=r&&r.autoStart&&w(u)&&(i=!0):e.endsWith("renderApplication.js")?(A(u),i=!0):e.endsWith("ExceptionsManager.js")&&(a=void 0!==r&&r.autoStart&&r.errorHandler.enabled,J(u,r.errorHandler.reportFatalErrorAsCrash,a),i=!0);else if(t===o.v)i=G(u)||i;else{var a=V(e,r);if(r.custom.reactnavigation&&B(e,u))i=!0;else{if(!a.input&&!a.lifecycle)return null!=r&&r.debug&&console.log("Dynatrace - Filtered All: ".concat(e)),h(e),n;a.lifecycle&&A(u)&&(i=!0),a.input&&g.forEach(function(n){n=X(u,n);u=n.root,i=i||n.p})}}i?(n=u.toSource({quote:"single"}),N(n,e)):h(e),null!=r&&r.debug&&i&&console.log("Dynatrace - Modified Filename: "+e)}else e.includes(c.join("@dynatrace","react-native-plugin"))&&e.endsWith(c.join("lib","core","configuration","ConfigurationPreset.js"))&&void 0!==r&&(t=(0,f.getHostAppBundleInfo)(l.default.getPackageJsonFile()),a=I(e,n),void 0!==r.lifecycle&&j(a,"getLifecycleUpdate",r.lifecycle.includeUpdate),void 0!==r.debug&&j(a,"getLogLevel",r.debug?0:1),void 0!==r.bundleName?j(a,"getBundleName",r.bundleName):null!==t&&j(a,"getBundleName",null==t?void 0:t.name),void 0!==r.bundleVersion?j(a,"getBundleVersion",r.bundleVersion):null!==t&&j(a,"getBundleVersion",null==t?void 0:t.version),void 0!==r.input&&void 0!==r.input.actionNamePrivacy&&j(a,"getActionNamePrivacy",r.input.actionNamePrivacy),void 0!==r.errorHandler&&(j(a,"isErrorHandlerEnabled",r.errorHandler.enabled),j(a,"isReportFatalErrorAsCrash",r.errorHandler.reportFatalErrorAsCrash)),r.autoStart&&j(a,"isAutoStartupEnabled",r.autoStart),n=a.toSource({quote:"single"}),N(n,e));return n},B=(exports.instrument=instrument,function(n,e){return!!M(n,e)&&(n="import { registerListener } from '".concat(b,"/react-navigation/ReactNavigation';"),e.find(u.ImportDeclaration).at(0).insertBefore(n),!0)}),M=function(n,e){var r=!1;return n.includes("react-navigation")&&n.includes("NavigationContainer.tsx")&&e.find(u.VariableDeclarator).forEach(function(n){r||null==n.value||null==n.value.id||"refContainer"!==n.value.id.name||null!=n.parent&&null!=n.parent.value&&null!=n.parent.value.type&&"VariableDeclaration"===n.parent.value.type&&(n.parent.insertAfter("registerListener(refContainer);"),r=!0)}),r},A=function(n){var e=n.findJSXElements(),t=!1;return 0<e.length&&(n.find(u.FunctionDeclaration).forEach(function(n){var e,r=(0,i.fromPaths)([n]);0<r.findJSXElements().length&&null!=n&&null!=n.value&&null!=n.value.id&&n.value.id.name.toString()&&(e=r.find(u.ClassDeclaration),r=r.find(u.ClassExpression),0===e.length)&&0===r.length&&(x(n,m.Types.FunctionalComponent,n.value.id.name.toString()),t=!0)}),n.find(u.ClassDeclaration).forEach(function(n){0<(0,i.fromPaths)([n]).findJSXElements().length&&null!=n&&null!=n.value&&n.value.id&&n.value.id.name.toString()&&(x(n,m.Types.ClassComponent,n.value.id.name.toString()),t=!0)}),n.find(u.ArrowFunctionExpression).forEach(function(n){0<(0,i.fromPaths)([n]).findJSXElements().length&&null!=n.parent&&null!=n.parent.value&&null!=n.parent.value.id&&null!=n.parent.value.id.name&&(x(n,m.Types.FunctionalComponent,n.parent.value.id.name),t=!0)})),t},x=function(n,e,r){for(e=u.expressionStatement(u.assignmentExpression("=",u.memberExpression(u.identifier(r),u.identifier("_dtInfo")),O(e,r)));"body"!==(null==n?void 0:n.parentPath.name);)n=n.parentPath;void 0!==n.parentPath&&n.insertAfter(e)},O=function(n,e){return u.objectExpression([u.objectProperty(u.identifier("type"),u.numericLiteral(n)),u.objectProperty(u.identifier("name"),u.stringLiteral(e))])},j=function(n,e,r){var n=n.find(u.Identifier).filter(function(n){return n.node.name===e});1===n.length&&"ReturnStatement"===(n=n.paths()[0].parent.value.body.body[0]).type&&("boolean"==typeof r&&(n.argument=u.booleanLiteral(r)),"string"==typeof r&&(n.argument=u.stringLiteral(r)),"number"==typeof r)&&(n.argument=u.numericLiteral(r))},I=function(n,e){return u.withParser((0,y.chooseParser)(n,e))(e)},T=function(n){return c.isAbsolute(n)?n.replace(l.default.getApplicationPath()+c.sep,""):n},h=function(n){try{var e=c.join(l.default.getBuildPath(),n+t.INSTRUMENTED_FILE_EXTENSION);r.default.checkIfFileExistsSync(e),r.default.deleteFileSync(e)}catch(n){}},N=function(n,e){e=c.join(l.default.getBuildPath(),e);try{r.default.checkIfFileExistsSync(c.dirname(e))}catch(n){r.default.createDirectorySync(c.dirname(e))}r.default.writeTextToFileSync(e+t.INSTRUMENTED_FILE_EXTENSION,n)},V=function(n,e){var r={input:!1,lifecycle:!1};return void 0!==e&&(void 0!==e.lifecycle&&void 0!==e.lifecycle.instrument&&e.lifecycle.instrument(n)&&(r.lifecycle=!0),void 0!==e.input)&&void 0!==e.input.instrument&&e.input.instrument(n)&&(r.input=!0),r},k=function(n){var e,n=n.find(u.Program);1===n.length&&(e=u.expressionStatement(u.callExpression(u.memberExpression(u.callExpression(u.identifier("require"),[u.stringLiteral("@dynatrace/react-native-plugin/instrumentation/jsx/ElementHelper")]),u.identifier("instrumentCreateElement")),[u.memberExpression(u.identifier("module"),u.identifier("exports"))])),n.paths()[0].node.body.push(e))},U=function(n){var e=n.find(u.FunctionDeclaration,{id:{name:"runApplication"}});return 1===e.length&&(_(n,{m:"_DynatraceApplicationHandler",module:"@dynatrace/react-native-plugin",reference:"ApplicationHandler"}),R(e.get().value.body.body,0,F("_DynatraceApplicationHandler","startup",[])),!0)},w=function(n){var e=n.find(u.ObjectMethod,{key:{name:"runApplication"}});return 1===e.length&&(_(n,{m:"_DynatraceApplicationHandler",module:"@dynatrace/react-native-plugin",reference:"ApplicationHandler"}),R(e.get().value.body.body,0,F("_DynatraceApplicationHandler","startup",[])),!0)},J=function(n,r,t){var i=u;n.find(i.FunctionDeclaration,{id:{name:"handleException"}}).forEach(function(n){var e=i.expressionStatement(i.callExpression(i.memberExpression(i.callExpression(i.identifier("require"),[i.literal("@dynatrace/react-native-plugin/lib/core/ErrorHandler")]),i.identifier("reportErrorToDynatrace")),[i.identifier("e"),i.identifier("isFatal"),i.literal(r),i.literal(t)]));n.node.body.body.unshift(e)})},G=function(n){var e=!1,n=n.find(u.CallExpression,{callee:{name:"require"}});return n.find(u.Literal,{value:"react/jsx-runtime"}).replaceWith(function(n){n=n.node;return n.value="@dynatrace/react-native-plugin/jsx-runtime",e=!0,n}),n.find(u.Literal,{value:"react/jsx-dev-runtime"}).replaceWith(function(n){n=n.node;return n.value="@dynatrace/react-native-plugin/jsx-dev-runtime",e=!0,n}),e},R=function(n,e){for(var r=arguments.length,t=new Array(2<r?r-2:0),i=2;i<r;i++)t[i-2]=arguments[i];return n.splice.apply(n,[e,0].concat(t))},z=function(n){if(n.includes("@dynatrace"))return o.i;var e=c.extname(n);if(".js"!==e&&".ts"!==e&&".tsx"!==e&&".jsx"!==e)return o.i;for(var r=c.parse(n),t=r.dir.split(c.sep),i=0;i<t.length;i++)if("node_modules"===t[i]){if("react-native"===t[i+1]||"create-react-class"===t[i+1]||"react-clone-referenced-element"===t[i+1])return q.includes(r.name)?o.o:o.i;if("react"===t[i+1]&&"index"===r.name)return o.l;if("react-native-css-interop"===t[i+1]&&("jsx-runtime"===r.name||"jsx-dev-runtime"===r.name))return o.v}return o.u},K=function(n,e,r){var t=Q(n,e,r);return W(n,e,r)||t},Q=function(n,e,r){var t=Y(n,e);return 0<t.length&&(void 0!==(t=H(t,e.reference,!1))&&(r.m=t.localName),tn(n,r),!0)},W=function(n,e,r){var t=E(n,e.module);if(1===t.length){t=H(t,e.reference,!0);if(void 0!==t)return un(n,r.defaultImport,t.localName,"ImportNamespaceSpecifier"===t.type),!0}return!1},X=function(n,e){var r=JSON.parse(JSON.stringify(e.new));return{root:n,p:K(n,e.old,r)||Z(n,e.old,e.new.defaultImport)}},Y=function(n,e){return n.find(u.ImportDeclaration).filter(function(n){return n.node.source.value===e.module&&null!=n.node.specifiers&&n.node.specifiers.some(function(n){return C(n)&&n.imported.name===e.reference||n.local&&n.local.name===e.reference})})},C=function(n){return void 0!==n.imported},Z=function(n,e,r){var t=!1;return n.find(u.CallExpression).filter(function(n){return $(n.node.callee)&&nn(n.node.arguments[0])&&n.node.arguments[0].value===e.module&&void 0!==n.parent}).forEach(function(n){(void 0===n.parent.value.property||void 0!==n.parent.value.property&&void 0!==n.parent.value.property.name&&n.parent.value.property.name===e.reference)&&(n.node.arguments[0].value=r,t=t||!0)}),t},$=function(n){return"require"===n.name},nn=function(n){return"StringLiteral"===n.type||"Literal"===n.type},E=function(n,e){return n.find(u.ImportDeclaration).filter(function(n){return n.node.source.value===e})},H=function(n,r,t){var i;return n.forEach(function(n){void 0!==n.node.specifiers&&(n.node.specifiers=n.node.specifiers.filter(function(n){var e;return C(n)&&!t?((e=n.imported.name!==r)||null==n.local||n.imported.name===n.local.name||(i={localName:n.local.name.toString(),type:n.type}),e):!(!C(n)&&t&&(null!=n.local&&(i={localName:n.local.name.toString(),type:n.type}),1))}),0===n.node.specifiers.length)&&n.prune()}),i},en=function(n,e){n.find(u.ImportDeclaration).filter(function(n){return n.node.source.value===e.module}).forEach(function(n){null!=n.node.specifiers&&n.node.specifiers.push(P(e))})},rn=function(n,e,r){n.find(u.ImportDeclaration).filter(function(n){return n.node.source.value===e}).forEach(function(n){null!=n.node.specifiers&&n.node.specifiers.push(r)})},D=function(n,e,r){var t=n.find(u.ImportDeclaration);0<t.length?u(t.paths()[0]).insertAfter(S(e,r)):1===(t=n.find(u.Program)).length&&t.paths()[0].node.body.unshift(S(e,r))},tn=function(n,e){0<E(n,e.module).length?en(n,e):D(n,e.module,[P(e)])},un=function(n,e,r,t){var i=E(n,e),t=(t?vn:sn)(r);0<i.length?rn(n,e,t):D(n,e,[t])},_=function(n,e){n=n.find(u.VariableDeclaration);0<n.length&&u(n.paths()[0]).insertAfter(on(e))},F=function(n,e,r){return u.expressionStatement(an(n,e,r))},an=function(n,e,r){return u.callExpression(fn(n,e),r)},on=function(n){return u.variableDeclaration("var",[cn(n)])},cn=function(n){return u.variableDeclarator(void 0!==n.m?u.identifier(n.m):u.identifier(n.reference),(0<n.reference.length?ln:L)(n))},ln=function(n){return u.memberExpression(L(n),u.identifier(n.reference))},fn=function(n,e){return u.memberExpression(u.identifier(n),u.identifier(e))},L=function(n){return u.callExpression(u.identifier("require"),[u.literal(n.module)])},S=function(n,e){return u.importDeclaration(e,u.literal(n))},P=function(n){return void 0!==n.m?u.importSpecifier(u.identifier(n.reference),u.identifier(n.m)):u.importSpecifier(u.identifier(n.reference))},sn=function(n){return u.importDefaultSpecifier(u.identifier(n))},vn=function(n){return u.importNamespaceSpecifier(u.identifier(n))};
@@ -16,7 +16,7 @@ const createElement = (type, props, ...children) => {
16
16
  return _createElement(ClassComponent_1.DynatraceClassComponent, {}, _createElement(type, props, ...children));
17
17
  }
18
18
  else {
19
- (0, ElementHelper_1.modifyElement)(type, props, ...children);
19
+ (0, ElementHelper_1.modifyElement)(type, props);
20
20
  }
21
21
  }
22
22
  return _createElement(type, props, ...children);
@@ -2,13 +2,9 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.isDtActionIgnore = exports.modifyElement = exports.instrumentCreateElement = void 0;
4
4
  const Types_1 = require("../model/Types");
5
- const TypesUtil_1 = require("../model/TypesUtil");
6
5
  const Dynatrace_1 = require("../../lib/core/Dynatrace");
7
- const ConsoleLogger_1 = require("../../lib/core/logging/ConsoleLogger");
8
6
  const Picker_1 = require("./components/Picker");
9
- const Touchable_1 = require("./components/Touchable");
10
7
  const RefreshControl_1 = require("./components/RefreshControl");
11
- const Switch_1 = require("./components/Switch");
12
8
  const FunctionalComponent_1 = require("./components/FunctionalComponent");
13
9
  const ClassComponent_1 = require("./components/ClassComponent");
14
10
  const instrumentCreateElement = (reactModule) => {
@@ -27,7 +23,7 @@ const instrumentCreateElement = (reactModule) => {
27
23
  return reactCreateElement(ClassComponent_1.DynatraceClassComponent, {}, reactCreateElement(type, props, ...children));
28
24
  }
29
25
  else {
30
- (0, exports.modifyElement)(type, props, ...children);
26
+ (0, exports.modifyElement)(type, props);
31
27
  }
32
28
  }
33
29
  return reactCreateElement(type, props, ...children);
@@ -35,27 +31,12 @@ const instrumentCreateElement = (reactModule) => {
35
31
  }
36
32
  };
37
33
  exports.instrumentCreateElement = instrumentCreateElement;
38
- const modifyElement = (type, props, ...children) => {
34
+ const modifyElement = (type, props) => {
39
35
  if (props != null) {
40
36
  if (type._dtInfo.type === Types_1.Types.RefreshControl &&
41
37
  props.onRefresh != null) {
42
38
  (0, RefreshControl_1.RefreshControlHelper)(Dynatrace_1.Dynatrace).attachOnRefresh(props);
43
39
  }
44
- else if (type._dtInfo.type === Types_1.Types.Switch &&
45
- props.onValueChange != null) {
46
- (0, Switch_1.SwitchHelper)(Dynatrace_1.Dynatrace).attachOnValueChange(props);
47
- }
48
- else if (type._dtInfo.type === Types_1.Types.Button ||
49
- type._dtInfo.type === Types_1.Types.Text ||
50
- type._dtInfo.type === Types_1.Types.Pressable ||
51
- (0, TypesUtil_1.isTypeTouchable)(type._dtInfo.type)) {
52
- if (props.onPress != null) {
53
- props.onPress = (0, Touchable_1.TouchableHelper)(Dynatrace_1.Dynatrace, new ConsoleLogger_1.ConsoleLogger('TouchableHelper')).attachOnPress(false, props, children, type._dtInfo.type);
54
- }
55
- if (props.onLongPress != null) {
56
- props.onLongPress = (0, Touchable_1.TouchableHelper)(Dynatrace_1.Dynatrace, new ConsoleLogger_1.ConsoleLogger('TouchableHelper')).attachOnPress(true, props, children, type._dtInfo.type);
57
- }
58
- }
59
40
  else if (props.onValueChange != null &&
60
41
  type._dtInfo.type === Types_1.Types.Picker) {
61
42
  (0, Picker_1.PickerHelper)(Dynatrace_1.Dynatrace).attachOnValueChange(props);
@@ -1,9 +1,2 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.isDynatraceIgnored = exports.isDynatraceNaming = void 0;
4
- const isDynatraceNaming = (properties) => properties.dtActionName !== undefined;
5
- exports.isDynatraceNaming = isDynatraceNaming;
6
- const isDynatraceIgnored = (properties) => (properties.dtActionIgnore !== undefined &&
7
- properties.dtActionIgnore === true) ||
8
- properties.dtActionIgnore === 'true';
9
- exports.isDynatraceIgnored = isDynatraceIgnored;
@@ -1,10 +1,10 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
+ const ReactDevRuntime = require("react/jsx-dev-runtime");
3
4
  const Types_1 = require("../model/Types");
4
5
  const FunctionalComponent_1 = require("./components/FunctionalComponent");
5
6
  const ClassComponent_1 = require("./components/ClassComponent");
6
7
  const ElementHelper_1 = require("./ElementHelper");
7
- const ReactDevRuntime = require("react/jsx-dev-runtime");
8
8
  try {
9
9
  const jsxDEV = (...args) => {
10
10
  if (args[0] !== undefined &&
@@ -38,12 +38,7 @@ try {
38
38
  return ReactDevRuntime.jsxDEV(ClassComponent_1.DynatraceClassComponent, wrapperProps);
39
39
  }
40
40
  }
41
- if (Array.isArray(args[1].children)) {
42
- (0, ElementHelper_1.modifyElement)(args[0], args[1], ...args[1].children);
43
- }
44
- else {
45
- (0, ElementHelper_1.modifyElement)(args[0], args[1], args[1].children);
46
- }
41
+ (0, ElementHelper_1.modifyElement)(args[0], args[1]);
47
42
  }
48
43
  return ReactDevRuntime.jsxDEV(...args);
49
44
  };
@@ -1,10 +1,10 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
+ const ReactRuntime = require("react/jsx-runtime");
3
4
  const Types_1 = require("../model/Types");
4
5
  const FunctionalComponent_1 = require("./components/FunctionalComponent");
5
6
  const ClassComponent_1 = require("./components/ClassComponent");
6
7
  const ElementHelper_1 = require("./ElementHelper");
7
- const ReactRuntime = require("react/jsx-runtime");
8
8
  const instrumentJsxCall = (jsxFunction) => (...args) => {
9
9
  if (args[0] !== undefined &&
10
10
  args[0]._dtInfo !== undefined &&
@@ -37,12 +37,7 @@ const instrumentJsxCall = (jsxFunction) => (...args) => {
37
37
  return jsxFunction(ClassComponent_1.DynatraceClassComponent, wrapperProps);
38
38
  }
39
39
  }
40
- if (Array.isArray(args[1].children)) {
41
- (0, ElementHelper_1.modifyElement)(args[0], args[1], ...args[1].children);
42
- }
43
- else {
44
- (0, ElementHelper_1.modifyElement)(args[0], args[1], args[1].children);
45
- }
40
+ (0, ElementHelper_1.modifyElement)(args[0], args[1]);
46
41
  }
47
42
  return jsxFunction(...args);
48
43
  };
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.getNameFromComponent = void 0;
3
+ exports.isDynatraceIgnored = exports.isDynatraceNaming = exports.getNameFromComponent = void 0;
4
4
  const getNameFromComponent = (props) => {
5
5
  if (props !== undefined && props.children !== undefined) {
6
6
  let child;
@@ -31,3 +31,14 @@ const getNameFromComponent = (props) => {
31
31
  }
32
32
  };
33
33
  exports.getNameFromComponent = getNameFromComponent;
34
+ const isDynatraceNaming = (properties) => typeof properties === 'object' &&
35
+ properties !== null &&
36
+ 'dtActionName' in properties &&
37
+ typeof properties.dtActionName === 'string';
38
+ exports.isDynatraceNaming = isDynatraceNaming;
39
+ const isDynatraceIgnored = (properties) => typeof properties === 'object' &&
40
+ properties !== null &&
41
+ 'dtActionIgnore' in properties &&
42
+ (properties.dtActionIgnore === true ||
43
+ properties.dtActionIgnore === 'true');
44
+ exports.isDynatraceIgnored = isDynatraceIgnored;
@@ -1,10 +1,10 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.PickerHelper = void 0;
4
- const IDynatraceProperties_1 = require("../IDynatraceProperties");
4
+ const ComponentUtil_1 = require("./ComponentUtil");
5
5
  const PickerHelper = (Dynatrace) => ({
6
6
  attachOnValueChange: (pickerProps) => {
7
- if ((0, IDynatraceProperties_1.isDynatraceIgnored)(pickerProps)) {
7
+ if ((0, ComponentUtil_1.isDynatraceIgnored)(pickerProps)) {
8
8
  return;
9
9
  }
10
10
  const origOnValueChange = pickerProps.onValueChange;
@@ -31,7 +31,7 @@ const PickerHelper = (Dynatrace) => ({
31
31
  exports.PickerHelper = PickerHelper;
32
32
  const isPickerItemProps = (props) => props.label !== undefined;
33
33
  const _findActionName = (pickerProps) => {
34
- if ((0, IDynatraceProperties_1.isDynatraceNaming)(pickerProps)) {
34
+ if ((0, ComponentUtil_1.isDynatraceNaming)(pickerProps)) {
35
35
  return pickerProps.dtActionName;
36
36
  }
37
37
  else if (pickerProps.accessibilityLabel != null) {
@@ -1,10 +1,10 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.RefreshControlHelper = void 0;
4
- const IDynatraceProperties_1 = require("../IDynatraceProperties");
4
+ const ComponentUtil_1 = require("./ComponentUtil");
5
5
  const RefreshControlHelper = (Dynatrace) => ({
6
6
  attachOnRefresh: (refreshControlProps) => {
7
- if ((0, IDynatraceProperties_1.isDynatraceIgnored)(refreshControlProps)) {
7
+ if ((0, ComponentUtil_1.isDynatraceIgnored)(refreshControlProps)) {
8
8
  return;
9
9
  }
10
10
  const origOnRefresh = refreshControlProps.onRefresh;
@@ -29,7 +29,7 @@ const RefreshControlHelper = (Dynatrace) => ({
29
29
  });
30
30
  exports.RefreshControlHelper = RefreshControlHelper;
31
31
  const _findActionName = (refreshControlProps) => {
32
- if ((0, IDynatraceProperties_1.isDynatraceNaming)(refreshControlProps)) {
32
+ if ((0, ComponentUtil_1.isDynatraceNaming)(refreshControlProps)) {
33
33
  return refreshControlProps.dtActionName;
34
34
  }
35
35
  else if (refreshControlProps.accessibilityLabel != null) {
@@ -1,40 +1,10 @@
1
1
  "use strict";
2
- var _a, _b, _c, _d;
3
2
  Object.defineProperty(exports, "__esModule", { value: true });
4
3
  exports.RectButton = exports.TouchableWithoutFeedback = exports.TouchableNativeFeedback = exports.TouchableHighlight = exports.TouchableOpacity = void 0;
5
- const Types_1 = require("../../../model/Types");
6
- const gestureHandler = require('react-native-gesture-handler');
7
- if (gestureHandler !== undefined) {
8
- if (typeof gestureHandler.TouchableOpacity !== 'object') {
9
- exports.TouchableOpacity = (_a = class TouchableOpacity extends (gestureHandler.TouchableOpacity) {
10
- },
11
- _a._dtInfo = { type: Types_1.Types.TouchableOpacityGestureHandler },
12
- _a);
13
- }
14
- if (typeof gestureHandler.TouchableHighlight !== 'object') {
15
- exports.TouchableHighlight = (_b = class TouchableHighlight extends (gestureHandler.TouchableHighlight) {
16
- },
17
- _b._dtInfo = { type: Types_1.Types.TouchableHighlightGestureHandler },
18
- _b);
19
- }
20
- if (typeof gestureHandler.TouchableNativeFeedback !== 'object') {
21
- exports.TouchableNativeFeedback = (_c = class TouchableNativeFeedback extends (gestureHandler.TouchableNativeFeedback) {
22
- },
23
- _c._dtInfo = {
24
- type: Types_1.Types.TouchableNativeFeedbackGestureHandler,
25
- },
26
- _c);
27
- }
28
- if (typeof gestureHandler.TouchableWithoutFeedback === 'object') {
29
- exports.TouchableWithoutFeedback = Object.assign({ _dtInfo: { type: Types_1.Types.TouchableWithoutFeedbackGestureHandler } }, gestureHandler.TouchableWithoutFeedback);
30
- }
31
- if (typeof gestureHandler.RectButton !== 'object') {
32
- exports.RectButton = (_d = class RectButton extends gestureHandler.RectButton {
33
- },
34
- _d._dtInfo = { type: Types_1.Types.RectButtonGestureHandler },
35
- _d);
36
- }
37
- else {
38
- exports.RectButton = Object.assign({ _dtInfo: { type: Types_1.Types.RectButtonGestureHandler } }, gestureHandler.RectButton);
39
- }
40
- }
4
+ const GestureHandler = require("react-native-gesture-handler");
5
+ const withOnPressMonitoring_1 = require("../../withOnPressMonitoring");
6
+ exports.TouchableOpacity = (0, withOnPressMonitoring_1.withOnPressMonitoring)(GestureHandler.TouchableOpacity, 'Touchable');
7
+ exports.TouchableHighlight = (0, withOnPressMonitoring_1.withOnPressMonitoring)(GestureHandler.TouchableHighlight, 'Touchable');
8
+ exports.TouchableNativeFeedback = (0, withOnPressMonitoring_1.withOnPressMonitoring)(GestureHandler.TouchableNativeFeedback, 'Touchable');
9
+ exports.TouchableWithoutFeedback = (0, withOnPressMonitoring_1.withOnPressMonitoring)(GestureHandler.TouchableWithoutFeedback, 'Touchable');
10
+ exports.RectButton = (0, withOnPressMonitoring_1.withOnPressMonitoring)(GestureHandler.RectButton, 'Button');
@@ -1,15 +1,58 @@
1
1
  "use strict";
2
- var _a;
2
+ var __rest = (this && this.__rest) || function (s, e) {
3
+ var t = {};
4
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
5
+ t[p] = s[p];
6
+ if (s != null && typeof Object.getOwnPropertySymbols === "function")
7
+ for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
8
+ if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
9
+ t[p[i]] = s[p[i]];
10
+ }
11
+ return t;
12
+ };
3
13
  Object.defineProperty(exports, "__esModule", { value: true });
4
- exports.Switch = void 0;
14
+ exports.wrapOnValueChange = exports.Switch = void 0;
5
15
  const react_native_1 = require("react-native");
6
- const Types_1 = require("../../model/Types");
7
- if (typeof react_native_1.Switch === 'object') {
8
- exports.Switch = Object.assign({ _dtInfo: { type: Types_1.Types.Switch } }, react_native_1.Switch);
9
- }
10
- else {
11
- exports.Switch = (_a = class Switch extends react_native_1.Switch {
12
- },
13
- _a._dtInfo = { type: Types_1.Types.Switch },
14
- _a);
15
- }
16
+ const React = require("react");
17
+ const ConfigurationHandler_1 = require("../../../lib/core/configuration/ConfigurationHandler");
18
+ const Dynatrace_1 = require("../../../lib/core/Dynatrace");
19
+ const ComponentUtil_1 = require("../../jsx/components/ComponentUtil");
20
+ exports.Switch = React.forwardRef((_a, ref) => {
21
+ var { onValueChange } = _a, rest = __rest(_a, ["onValueChange"]);
22
+ const shouldWrap = (0, ComponentUtil_1.isDynatraceIgnored)(rest) || !onValueChange;
23
+ const wrappedOnValueChange = shouldWrap
24
+ ? onValueChange
25
+ : (0, exports.wrapOnValueChange)(onValueChange, rest);
26
+ return (React.createElement(react_native_1.Switch, Object.assign({ ref: ref, onValueChange: wrappedOnValueChange }, rest)));
27
+ });
28
+ const wrapOnValueChange = (onValueChange, switchProps) => (value) => {
29
+ const switchName = findSwitchName(switchProps);
30
+ const action = Dynatrace_1.Dynatrace.enterAutoAction(`Touch on ${switchName} to ${value}`);
31
+ let isSync = true;
32
+ try {
33
+ const returnValue = onValueChange(value);
34
+ if (returnValue instanceof Promise) {
35
+ isSync = false;
36
+ return Promise.resolve(returnValue).finally(() => {
37
+ action.leaveAction();
38
+ });
39
+ }
40
+ }
41
+ finally {
42
+ if (isSync) {
43
+ action.leaveAction();
44
+ }
45
+ }
46
+ };
47
+ exports.wrapOnValueChange = wrapOnValueChange;
48
+ const findSwitchName = (switchProps) => {
49
+ var _a;
50
+ if (switchProps.dtActionName) {
51
+ return switchProps.dtActionName;
52
+ }
53
+ if (ConfigurationHandler_1.ConfigurationHandler.isConfigurationAvailable() &&
54
+ ConfigurationHandler_1.ConfigurationHandler.isActionNamePrivacyEnabled()) {
55
+ return 'Switch';
56
+ }
57
+ return (_a = switchProps.accessibilityLabel) !== null && _a !== void 0 ? _a : 'Switch';
58
+ };