@dynatrace/react-native-plugin 2.323.1 → 2.325.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 +33 -9
- package/android/build.gradle +3 -3
- package/files/plugin-runtime.gradle +8 -1
- package/files/plugin.gradle +1 -1
- package/index.js +18 -10
- package/instrumentation/DynatraceInstrumentation.js +1 -1
- package/instrumentation/jsx/CreateElement.js +10 -7
- package/instrumentation/jsx/ElementHelper.js +0 -5
- package/instrumentation/libs/react-native/Switch.js +55 -12
- package/instrumentation/libs/withOnPressMonitoring.js +1 -1
- package/instrumentation/model/Types.js +0 -1
- package/internal.js +7 -0
- package/lib/core/Dynatrace.js +4 -1
- package/lib/core/DynatraceAction.js +3 -2
- package/lib/core/DynatraceWebRequestTiming.js +5 -5
- package/lib/core/ErrorHandler.js +18 -34
- package/lib/core/NullWebRequestTiming.js +1 -0
- package/lib/core/configuration/Configuration.js +2 -2
- package/lib/core/configuration/ConfigurationBuilder.js +3 -2
- package/lib/core/configuration/ManualStartupConfiguration.js +6 -3
- package/lib/core/interface/IWebRequestTiming.js +1 -0
- package/lib/core/logging/LogLevel.js +1 -10
- package/lib/core/logging/LogLevelUtil.js +13 -0
- package/lib/next/Dynatrace.js +29 -19
- package/lib/next/appstart/AppStartObserver.js +1 -1
- package/lib/next/events/EventCreator.js +2 -1
- package/lib/next/events/EventPipeline.js +14 -6
- package/lib/next/events/HttpRequestEventBuilder.js +196 -0
- package/lib/next/events/IHttpRequestEventBuilder.js +2 -0
- package/lib/next/events/ViewInfoCreator.js +1 -1
- package/lib/next/events/modifier/BaseDataEventModifier.js +6 -0
- package/lib/next/events/modifier/EventModifierUtil.js +34 -1
- package/lib/next/events/modifier/ModifyEventValidation.js +18 -5
- package/lib/next/events/modifier/SendEventValidation.js +23 -10
- package/lib/next/events/spec/EventSpecContstants.js +2 -1
- package/package.json +12 -6
- package/public.js +22 -0
- package/react-augmentation.js +3 -0
- package/react-native-dynatrace.podspec +1 -1
- package/scripts/core/LineOffsetAnalyzeCall.js +3 -3
- package/types.d.ts +1969 -0
- package/instrumentation/jsx/components/Switch.js +0 -57
- package/instrumentation/model/TypesUtil.js +0 -21
- package/src/instrumentation/jsx/IDynatraceProperties.ts +0 -15
- package/typings/react-native-dynatrace.d.ts +0 -1729
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
|
|
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.
|
|
36
|
-
* iOS Agent: 8.
|
|
36
|
+
* Android Agent: 8.325.1.1007
|
|
37
|
+
* iOS Agent: 8.325.1.1012
|
|
37
38
|
|
|
38
39
|
## Quick Setup
|
|
39
40
|
|
|
@@ -80,6 +81,7 @@ 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)
|
|
@@ -337,7 +339,7 @@ myAction.leaveAction();
|
|
|
337
339
|
```
|
|
338
340
|

|
|
339
341
|
|
|
340
|
-
* `enterManualAction` - Creates an Action which will NOT be handled by the plugin. This means that you have full control about the
|
|
342
|
+
* `enterManualAction` - Creates an Action which will NOT be handled by the plugin. This means that you have full control about the hierarchy of your actions. This function will create a root action for you, which has the ability to create child actions via `enterAction`. Be aware, because of the full manual approach the plugin will not link webrequest automatically. Webrequest have to be manually tagged by using the tag provided by the action via `getRequestTag`.
|
|
341
343
|
|
|
342
344
|
```ts
|
|
343
345
|
import { Dynatrace } from '@dynatrace/react-native-plugin';
|
|
@@ -738,7 +740,7 @@ npx react-native run-android --port=2000
|
|
|
738
740
|
|
|
739
741
|
## Manually adding iOS OneAgent to a project
|
|
740
742
|
|
|
741
|
-
Adding the iOS agent manually depends on the
|
|
743
|
+
Adding the iOS agent manually depends on the availability of support for CocoaPods.
|
|
742
744
|
|
|
743
745
|
### With CocoaPods support
|
|
744
746
|
Insert the following in your Podfile:
|
|
@@ -961,7 +963,7 @@ The content of the `config` block is directly copied to the `plist` file. Theref
|
|
|
961
963
|
|
|
962
964
|
## Define build stages in dynatrace.config.js
|
|
963
965
|
|
|
964
|
-
If you have several stages such as debug, QA, and production, you probably want to
|
|
966
|
+
If you have several stages such as debug, QA, and production, you probably want to separate them and let them report in different applications. This can be done with two different approaches:
|
|
965
967
|
|
|
966
968
|
1. Create several dynatrace.config.js (e.g. dynatrace.config.prod.js) and pass those configuration files via [arguments](#customizing-paths-for-configuration) in the CLI.
|
|
967
969
|
2. Use the configuration options which are available through Gradle and XCode. (Described below)
|
|
@@ -1378,9 +1380,21 @@ dependencies {
|
|
|
1378
1380
|
|
|
1379
1381
|
```
|
|
1380
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
|
+
|
|
1381
1395
|
## Configuration of standalone React Native project
|
|
1382
1396
|
|
|
1383
|
-
This section explains the configuration of a standalone React Native project. This means you have a React Native project, but don't use the
|
|
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 typical `iOS` and `android` folders. Instead you have a separate native `iOS` or `android` project which is embedding your React Native project.
|
|
1384
1398
|
|
|
1385
1399
|
To get the same experience as somebody who has a combined project, you roughly need to do the following things:
|
|
1386
1400
|
|
|
@@ -1389,7 +1403,7 @@ To get the same experience as somebody who has a combined project, you roughly n
|
|
|
1389
1403
|
|
|
1390
1404
|
### Auto Instrumentation of your Native Project
|
|
1391
1405
|
|
|
1392
|
-
The mobile application in the web UI offers you a configuration wizard (see settings page) for your native project (Android/iOS). Use it and apply it to your
|
|
1406
|
+
The mobile application in the web UI offers you a configuration wizard (see settings page) for your native project (Android/iOS). Use it and apply it to your separated native project according to this documentation:
|
|
1393
1407
|
|
|
1394
1408
|
- Android: https://www.dynatrace.com/support/help/technology-support/operating-systems/android/instrumentation-via-plugin/instrumentation-via-plugin/
|
|
1395
1409
|
- iOS: https://www.dynatrace.com/support/help/technology-support/operating-systems/ios/instrumentation/dynatrace-auto-instrumentation-for-ios/
|
|
@@ -1477,6 +1491,16 @@ If you are struggling with a problem, submit a support ticket to Dynatrace (supp
|
|
|
1477
1491
|
<br/><br/>
|
|
1478
1492
|
## Changelog
|
|
1479
1493
|
|
|
1494
|
+
2.325.1
|
|
1495
|
+
* Updated Android (8.325.1.1007) & iOS Agent (8.325.1.1012)
|
|
1496
|
+
* [New RUM experience preview] ReactNative version now added to RUM on Grail event base data
|
|
1497
|
+
* [New RUM experience preview] Added API documentation for RUM on Grail API
|
|
1498
|
+
|
|
1499
|
+
2.323.2
|
|
1500
|
+
* Fixed error "Execution failed for task ':app:mergeReleaseAssets'. A problem occured starting process 'command 'npx''" when building for release on Windows.
|
|
1501
|
+
* Downgraded required NodeJS version to 16.0.0+
|
|
1502
|
+
* Fixing Switch instrumentation for React Native 0.81+
|
|
1503
|
+
|
|
1480
1504
|
2.323.1
|
|
1481
1505
|
* Updated Android (8.323.1.1002) & iOS Agent (8.323.1.1009)
|
|
1482
1506
|
* Fixing Touchable/Text instrumentation for React Native 0.81+
|
package/android/build.gradle
CHANGED
|
@@ -11,7 +11,7 @@ def isNewArchitectureEnabled() {
|
|
|
11
11
|
buildscript {
|
|
12
12
|
repositories {
|
|
13
13
|
google()
|
|
14
|
-
|
|
14
|
+
mavenCentral()
|
|
15
15
|
}
|
|
16
16
|
|
|
17
17
|
dependencies {
|
|
@@ -68,11 +68,11 @@ android {
|
|
|
68
68
|
|
|
69
69
|
repositories {
|
|
70
70
|
google()
|
|
71
|
-
|
|
71
|
+
mavenCentral()
|
|
72
72
|
}
|
|
73
73
|
|
|
74
74
|
dependencies {
|
|
75
|
-
implementation 'com.dynatrace.agent:agent-android:8.
|
|
75
|
+
implementation 'com.dynatrace.agent:agent-android:8.325.1.1007'
|
|
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
|
-
|
|
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 {
|
package/files/plugin.gradle
CHANGED
package/index.js
CHANGED
|
@@ -1,10 +1,18 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
__exportStar(require("./public"), exports);
|
|
18
|
+
__exportStar(require("./internal"), exports);
|
|
@@ -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))};
|
|
@@ -1,26 +1,29 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.createElement = void 0;
|
|
3
4
|
const Types_1 = require("../model/Types");
|
|
4
5
|
const ElementHelper_1 = require("./ElementHelper");
|
|
5
6
|
const ClassComponent_1 = require("./components/ClassComponent");
|
|
6
7
|
const FunctionalComponent_1 = require("./components/FunctionalComponent");
|
|
7
|
-
const
|
|
8
|
+
const react_1 = require("react");
|
|
8
9
|
const createElement = (type, props, ...children) => {
|
|
9
10
|
if (type != null && type._dtInfo != null && !(0, ElementHelper_1.isDtActionIgnore)(props)) {
|
|
10
11
|
if (type._dtInfo.type === Types_1.Types.FunctionalComponent) {
|
|
11
|
-
return
|
|
12
|
+
return (0, react_1.createElement)(FunctionalComponent_1.DynatraceFunctionalComponent, {
|
|
13
|
+
children: (0, react_1.createElement)(type, props, ...children),
|
|
14
|
+
});
|
|
12
15
|
}
|
|
13
16
|
else if (type._dtInfo.type === Types_1.Types.ClassComponent &&
|
|
14
17
|
type.prototype !== undefined &&
|
|
15
18
|
type.prototype.isReactComponent !== undefined) {
|
|
16
|
-
return
|
|
19
|
+
return (0, react_1.createElement)(ClassComponent_1.DynatraceClassComponent, {
|
|
20
|
+
children: (0, react_1.createElement)(type, props, ...children),
|
|
21
|
+
});
|
|
17
22
|
}
|
|
18
23
|
else {
|
|
19
24
|
(0, ElementHelper_1.modifyElement)(type, props);
|
|
20
25
|
}
|
|
21
26
|
}
|
|
22
|
-
return
|
|
23
|
-
};
|
|
24
|
-
module.exports = {
|
|
25
|
-
createElement,
|
|
27
|
+
return (0, react_1.createElement)(type, props, ...children);
|
|
26
28
|
};
|
|
29
|
+
exports.createElement = createElement;
|
|
@@ -5,7 +5,6 @@ const Types_1 = require("../model/Types");
|
|
|
5
5
|
const Dynatrace_1 = require("../../lib/core/Dynatrace");
|
|
6
6
|
const Picker_1 = require("./components/Picker");
|
|
7
7
|
const RefreshControl_1 = require("./components/RefreshControl");
|
|
8
|
-
const Switch_1 = require("./components/Switch");
|
|
9
8
|
const FunctionalComponent_1 = require("./components/FunctionalComponent");
|
|
10
9
|
const ClassComponent_1 = require("./components/ClassComponent");
|
|
11
10
|
const instrumentCreateElement = (reactModule) => {
|
|
@@ -38,10 +37,6 @@ const modifyElement = (type, props) => {
|
|
|
38
37
|
props.onRefresh != null) {
|
|
39
38
|
(0, RefreshControl_1.RefreshControlHelper)(Dynatrace_1.Dynatrace).attachOnRefresh(props);
|
|
40
39
|
}
|
|
41
|
-
else if (type._dtInfo.type === Types_1.Types.Switch &&
|
|
42
|
-
props.onValueChange != null) {
|
|
43
|
-
(0, Switch_1.SwitchHelper)(Dynatrace_1.Dynatrace).attachOnValueChange(props);
|
|
44
|
-
}
|
|
45
40
|
else if (props.onValueChange != null &&
|
|
46
41
|
type._dtInfo.type === Types_1.Types.Picker) {
|
|
47
42
|
(0, Picker_1.PickerHelper)(Dynatrace_1.Dynatrace).attachOnValueChange(props);
|
|
@@ -1,15 +1,58 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var
|
|
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
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
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
|
+
};
|
|
@@ -71,7 +71,7 @@ const findTouchableName = (props) => {
|
|
|
71
71
|
return props.accessibilityLabel;
|
|
72
72
|
}
|
|
73
73
|
if (typeof props.children === 'function') {
|
|
74
|
-
return
|
|
74
|
+
return null;
|
|
75
75
|
}
|
|
76
76
|
return findTouchableNameRecursive(props.children);
|
|
77
77
|
};
|
package/internal.js
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.createElement = exports.ApplicationHandler = void 0;
|
|
4
|
+
var Application_1 = require("./lib/core/Application");
|
|
5
|
+
Object.defineProperty(exports, "ApplicationHandler", { enumerable: true, get: function () { return Application_1.ApplicationHandler; } });
|
|
6
|
+
var CreateElement_1 = require("./instrumentation/jsx/CreateElement");
|
|
7
|
+
Object.defineProperty(exports, "createElement", { enumerable: true, get: function () { return CreateElement_1.createElement; } });
|
package/lib/core/Dynatrace.js
CHANGED
|
@@ -33,7 +33,7 @@ exports.Dynatrace = {
|
|
|
33
33
|
if (configuration !== undefined) {
|
|
34
34
|
yield DynatraceBridge_1.DynatraceNative.start(configuration);
|
|
35
35
|
if (configuration.errorHandler) {
|
|
36
|
-
(0, ErrorHandler_1.
|
|
36
|
+
(0, ErrorHandler_1.startErrorHandler)(configuration.reportFatalErrorAsCrash);
|
|
37
37
|
}
|
|
38
38
|
else {
|
|
39
39
|
logger.debug('Dynatrace error handler will not be enabled as errorHandler was set to false!');
|
|
@@ -353,4 +353,7 @@ exports.Dynatrace = {
|
|
|
353
353
|
sendExceptionEvent: (error, fields) => {
|
|
354
354
|
Dynatrace_1.Dynatrace.sendExceptionEvent(error, fields);
|
|
355
355
|
},
|
|
356
|
+
sendHttpRequestEvent(httpRequestEventBuilder) {
|
|
357
|
+
Dynatrace_1.Dynatrace.sendHttpRequestEvent(httpRequestEventBuilder);
|
|
358
|
+
},
|
|
356
359
|
};
|
|
@@ -43,12 +43,13 @@ class DynatraceAction {
|
|
|
43
43
|
this.logger.debug(`reportStringValue(${valueName}, ${value}): Action was closed already!`);
|
|
44
44
|
return;
|
|
45
45
|
}
|
|
46
|
-
if (!StringUtils_1.StringUtils.isStringNullEmptyOrUndefined(valueName)
|
|
46
|
+
if (!StringUtils_1.StringUtils.isStringNullEmptyOrUndefined(valueName) &&
|
|
47
|
+
!StringUtils_1.StringUtils.isStringNullEmptyOrUndefined(value)) {
|
|
47
48
|
DynatraceBridge_1.DynatraceNative.reportStringValueInAction(this.key, valueName, value, platform === null || platform === void 0 ? void 0 : platform.toString());
|
|
48
49
|
this.logger.debug(`reportStringValue(${valueName}, ${value}): in Action - ${this.name}`);
|
|
49
50
|
}
|
|
50
51
|
else {
|
|
51
|
-
this.logger.debug(`reportStringValue(valueName, value): String value will not be reported because valueName is invalid! valueName: ${valueName}, value: ${value} in Action - ${this.name}`);
|
|
52
|
+
this.logger.debug(`reportStringValue(valueName, value): String value will not be reported because valueName or value is invalid! valueName: ${valueName}, value: ${value} in Action - ${this.name}`);
|
|
52
53
|
}
|
|
53
54
|
}
|
|
54
55
|
reportIntValue(valueName, value, platform) {
|
|
@@ -4,20 +4,20 @@ exports.DynatraceWebRequestTiming = void 0;
|
|
|
4
4
|
const DynatraceBridge_1 = require("./DynatraceBridge");
|
|
5
5
|
const ConsoleLogger_1 = require("./logging/ConsoleLogger");
|
|
6
6
|
const StringUtils_1 = require("./util/StringUtils");
|
|
7
|
+
const logger = new ConsoleLogger_1.ConsoleLogger('DynatraceWebRequestTiming');
|
|
7
8
|
class DynatraceWebRequestTiming {
|
|
8
9
|
constructor(requestTag, url) {
|
|
9
10
|
this.requestTag = requestTag;
|
|
10
11
|
this.url = url;
|
|
11
|
-
this.logger = new ConsoleLogger_1.ConsoleLogger('DynatraceWebRequestTiming');
|
|
12
12
|
}
|
|
13
13
|
startWebRequestTiming() {
|
|
14
14
|
if (!StringUtils_1.StringUtils.isStringNullEmptyOrUndefined(this.requestTag) &&
|
|
15
15
|
!StringUtils_1.StringUtils.isStringNullEmptyOrUndefined(this.url)) {
|
|
16
|
-
|
|
16
|
+
logger.debug(`startWebRequestTiming() - (${this.url}/${this.requestTag})`);
|
|
17
17
|
DynatraceBridge_1.DynatraceNative.startWebRequestTiming(this.requestTag, this.url);
|
|
18
18
|
}
|
|
19
19
|
else {
|
|
20
|
-
|
|
20
|
+
logger.debug(`startWebRequestTiming(): Web Request Timing could not be created! - (${this.url}/${this.requestTag})`);
|
|
21
21
|
}
|
|
22
22
|
}
|
|
23
23
|
stopWebRequestTiming(responseCode, responseMessage) {
|
|
@@ -28,11 +28,11 @@ class DynatraceWebRequestTiming {
|
|
|
28
28
|
!StringUtils_1.StringUtils.isStringNullEmptyOrUndefined(this.url) &&
|
|
29
29
|
responseCode != null &&
|
|
30
30
|
!StringUtils_1.StringUtils.isStringNullOrUndefined(responseMessage)) {
|
|
31
|
-
|
|
31
|
+
logger.debug(`stopWebRequestTiming(${responseCode}, ${responseMessage}, ${requestSize}, ${responseSize}) - (${this.url}/${this.requestTag})`);
|
|
32
32
|
DynatraceBridge_1.DynatraceNative.stopWebRequestTimingWithSize(this.requestTag, this.url, responseCode, responseMessage, requestSize, responseSize);
|
|
33
33
|
}
|
|
34
34
|
else {
|
|
35
|
-
|
|
35
|
+
logger.debug(`stopWebRequestTiming(${responseCode}, ${responseMessage}, ${requestSize}, ${responseSize}): Web Request Timing could not be stopped! - (${this.url}/${this.requestTag})`);
|
|
36
36
|
}
|
|
37
37
|
}
|
|
38
38
|
getRequestTag() {
|
package/lib/core/ErrorHandler.js
CHANGED
|
@@ -1,56 +1,40 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
4
|
-
const react_native_1 = require("react-native");
|
|
3
|
+
exports.reportErrorToDynatrace = exports.startErrorHandler = void 0;
|
|
5
4
|
const DynatraceInternal_1 = require("./DynatraceInternal");
|
|
6
5
|
const Dynatrace_1 = require("./Dynatrace");
|
|
7
6
|
const StringUtils_1 = require("./util/StringUtils");
|
|
8
7
|
const ConsoleLogger_1 = require("./logging/ConsoleLogger");
|
|
9
|
-
let _isReportFatalErrorAsCrash = true;
|
|
10
|
-
const _isReactNativeGlobal = (globalScope) => globalScope.ErrorUtils !== undefined;
|
|
11
8
|
const logger = new ConsoleLogger_1.ConsoleLogger('ErrorHandler');
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
});
|
|
19
|
-
const setter = global.ErrorUtils.setGlobalHandler;
|
|
20
|
-
global.ErrorUtils.setGlobalHandler = (errorHandler) => {
|
|
21
|
-
setter((error, isFatal) => {
|
|
22
|
-
(0, exports._reportErrorToDynatrace)(error, isFatal, errorHandler);
|
|
23
|
-
});
|
|
24
|
-
};
|
|
25
|
-
}
|
|
9
|
+
let manualStart = { enabled: false };
|
|
10
|
+
const startErrorHandler = (reportFatalErrorAsCrash) => {
|
|
11
|
+
manualStart = {
|
|
12
|
+
enabled: true,
|
|
13
|
+
reportFatalErrorAsCrash: reportFatalErrorAsCrash,
|
|
14
|
+
};
|
|
26
15
|
};
|
|
27
|
-
exports.
|
|
28
|
-
const
|
|
16
|
+
exports.startErrorHandler = startErrorHandler;
|
|
17
|
+
const reportErrorToDynatrace = (exception, isFatal, reportFatalErrorAsCrashFromConfig, autoStart) => {
|
|
18
|
+
if (!autoStart && !manualStart)
|
|
19
|
+
return;
|
|
20
|
+
const reportFatalErrorAsCrash = manualStart.enabled
|
|
21
|
+
? manualStart.reportFatalErrorAsCrash
|
|
22
|
+
: reportFatalErrorAsCrashFromConfig;
|
|
29
23
|
if (exception != null && isExceptionAnError(exception)) {
|
|
30
24
|
if (!StringUtils_1.StringUtils.isStringNullEmptyOrUndefined(exception.name)) {
|
|
31
25
|
if (isFatal === undefined) {
|
|
32
26
|
isFatal = false;
|
|
33
27
|
}
|
|
34
|
-
DynatraceInternal_1.DynatraceInternal.reportErrorFromHandler(isFatal, String(exception.name), adjustedReason(exception.message), exception.stack != null ? exception.stack : '',
|
|
35
|
-
logger.debug(`
|
|
28
|
+
DynatraceInternal_1.DynatraceInternal.reportErrorFromHandler(isFatal, String(exception.name), adjustedReason(exception.message), exception.stack != null ? exception.stack : '', reportFatalErrorAsCrash);
|
|
29
|
+
logger.debug(`reportErrorToDynatrace(${exception}, ${isFatal})`);
|
|
36
30
|
}
|
|
37
31
|
}
|
|
38
32
|
else {
|
|
39
33
|
Dynatrace_1.Dynatrace.reportError(String(exception), -1);
|
|
40
|
-
logger.debug(`
|
|
41
|
-
}
|
|
42
|
-
if (oldHandler !== undefined) {
|
|
43
|
-
if (react_native_1.Platform.OS === 'ios') {
|
|
44
|
-
setTimeout(() => {
|
|
45
|
-
oldHandler(exception, isFatal);
|
|
46
|
-
}, 200);
|
|
47
|
-
}
|
|
48
|
-
else {
|
|
49
|
-
oldHandler(exception, isFatal);
|
|
50
|
-
}
|
|
34
|
+
logger.debug(`reportErrorToDynatrace(${exception}, -1)`);
|
|
51
35
|
}
|
|
52
36
|
};
|
|
53
|
-
exports.
|
|
37
|
+
exports.reportErrorToDynatrace = reportErrorToDynatrace;
|
|
54
38
|
const adjustedReason = (reason) => {
|
|
55
39
|
if (!StringUtils_1.StringUtils.isStringNullEmptyOrUndefined(reason)) {
|
|
56
40
|
const reasonNewLineIndex = reason.indexOf('\n');
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.Configuration = void 0;
|
|
4
|
-
const
|
|
4
|
+
const LogLevelUtil_1 = require("../logging/LogLevelUtil");
|
|
5
5
|
class Configuration {
|
|
6
6
|
constructor(beaconUrl, applicationId, reportCrash, errorHandler, reportFatalErrorAsCrash, logLevel, lifecycleUpdate, userOptIn, actionNamePrivacy, bundleName, bundleVersion) {
|
|
7
7
|
this.beaconUrl = beaconUrl;
|
|
@@ -29,7 +29,7 @@ class Configuration {
|
|
|
29
29
|
`, lifecycleUpdate: ${this.lifecycleUpdate}` +
|
|
30
30
|
(isAutoStart ? '' : `, userOptIn: ${this.userOptIn}`) +
|
|
31
31
|
`, actionNamePrivacy: ${this.actionNamePrivacy}` +
|
|
32
|
-
`, logLevel: ${(0,
|
|
32
|
+
`, logLevel: ${(0, LogLevelUtil_1.LogLevelToString)(this.logLevel)}`;
|
|
33
33
|
if (this.bundleName !== undefined) {
|
|
34
34
|
configurationString += `, bundleName: ${this.bundleName}`;
|
|
35
35
|
}
|
|
@@ -60,10 +60,11 @@ class ConfigurationBuilder {
|
|
|
60
60
|
}
|
|
61
61
|
buildConfiguration() {
|
|
62
62
|
if (!this.autoStartup && this.beaconUrl.length === 0) {
|
|
63
|
-
throw new Error('beaconUrl configuration property is empty. This configuration is not possible! Please use a proper beacon
|
|
63
|
+
throw new Error('beaconUrl configuration property is empty. This configuration is not possible! Please use a proper beacon URL.');
|
|
64
64
|
}
|
|
65
65
|
if (!this.autoStartup && this.applicationId.length === 0) {
|
|
66
|
-
throw new Error('applicationId configuration property is empty.
|
|
66
|
+
throw new Error('applicationId configuration property is empty. ' +
|
|
67
|
+
'This configuration is not possible! Please use a proper application ID.');
|
|
67
68
|
}
|
|
68
69
|
return new Configuration_1.Configuration(this.beaconUrl, this.applicationId, this.reportCrash, this.errorHandler, this.reportFatalErrorAsCrash, this.logLevel, this.lifecycleUpdate, this.userOptIn, this.actionNamePrivacy, this.bundleName, this.bundleVersion);
|
|
69
70
|
}
|