@dynatrace/react-native-plugin 2.287.2 → 2.289.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 +68 -16
- package/android/build.gradle +1 -1
- package/android/src/main/java/com/dynatrace/android/agent/DynatraceRNBridgeImpl.java +3 -4
- package/android/src/new/java/com/dynatrace/android/agent/DynatraceRNBridge.java +3 -3
- package/android/src/old/java/com/dynatrace/android/agent/DynatraceRNBridge.java +3 -3
- package/files/default.config.js +14 -0
- package/files/plugin.gradle +1 -1
- package/ios/DynatraceRNBridge.mm +5 -8
- package/lib/instrumentor/DynatraceInstrumentation.js +1 -1
- package/lib/instrumentor/base/Application.js +1 -1
- package/lib/instrumentor/base/Dynatrace.js +10 -3
- package/lib/instrumentor/base/DynatraceInternal.js +21 -5
- package/lib/instrumentor/base/ErrorHandler.js +7 -23
- package/lib/instrumentor/base/Touchable.js +1 -1
- package/lib/instrumentor/base/configuration/Configuration.js +21 -1
- package/lib/instrumentor/base/configuration/ConfigurationBuilder.js +11 -1
- package/lib/instrumentor/base/configuration/ConfigurationDefaults.js +4 -2
- package/lib/instrumentor/base/configuration/ConfigurationHandler.js +2 -0
- package/lib/instrumentor/base/configuration/ConfigurationPreset.js +6 -0
- package/lib/instrumentor/base/configuration/ManualStartupConfiguration.js +13 -0
- package/lib/instrumentor/base/model/LogLevel.js +10 -1
- package/lib/react-native/Touchables.js +15 -58
- package/package.json +3 -2
- package/react-native-dynatrace.podspec +1 -3
- package/scripts/Config.js +4 -0
- package/scripts/Ios.js +2 -2
- package/scripts/util/PlistConstants.js +1 -1
- package/src/lib/instrumentor/base/interface/NativeDynatraceBridge.ts +2 -2
- package/typings/react-native-dynatrace.d.ts +50 -0
package/README.md
CHANGED
|
@@ -15,6 +15,8 @@ If you want to start using this plugin and are not a Dynatrace customer yet, hea
|
|
|
15
15
|
* Reporting React Native errors
|
|
16
16
|
* Manual instrumentation
|
|
17
17
|
* Typescript bindings to add manual instrumentation
|
|
18
|
+
* New React-Native architecture
|
|
19
|
+
>**Note:** With iOS specifically, we noticed that there are some features that are not working the same as when using the current default architecture. You may experience issues with crash reporting being captured and web requests being linked to specific user actions. Per react native, [the new architecture is experimental](https://reactnative.dev/docs/the-new-architecture/landing-page#should-i-use-the-new-architecture-today). We will keep an eye on new updates and will continue to improve our support for the new architecture on both platforms.
|
|
18
20
|
|
|
19
21
|
## Requirements
|
|
20
22
|
* React v16.8 or newer
|
|
@@ -29,8 +31,8 @@ If you want to start using this plugin and are not a Dynatrace customer yet, hea
|
|
|
29
31
|
## Agent Versions
|
|
30
32
|
This agent versions are configured in this plugin:
|
|
31
33
|
|
|
32
|
-
* Android Agent: 8.
|
|
33
|
-
* iOS Agent: 8.
|
|
34
|
+
* Android Agent: 8.289.2.1007
|
|
35
|
+
* iOS Agent: 8.289.1.1015
|
|
34
36
|
|
|
35
37
|
## Quick Setup
|
|
36
38
|
|
|
@@ -73,6 +75,7 @@ This agent versions are configured in this plugin:
|
|
|
73
75
|
* [Agent debug logs](#native-oneagent-debug-logs)
|
|
74
76
|
* [How does Dynatrace determine the user action name?](#how-does-dynatrace-determine-the-user-action-name)
|
|
75
77
|
* [Using dtActionName](#using-dtactionname-to-change-the-name-of-the-action)
|
|
78
|
+
* [How does Dynatrace automatically report crashes?](#how-does-dynatrace-automatically-report-crashes)
|
|
76
79
|
* [React Automatic Runtime](#react-automatic-runtime)
|
|
77
80
|
* [Using a second transformer besides the dynatrace transformer](#using-a-second-transformer-besides-the-dynatrace-transformer)
|
|
78
81
|
* [Upgrading project to Gradle 6](#updating-to-gradle-6)
|
|
@@ -243,6 +246,8 @@ The manual startup of the plugin is triggered via the `start(configuration: ICon
|
|
|
243
246
|
const configurationBuilder = new ConfigurationBuilder("beaconUrl", "applicationId");
|
|
244
247
|
|
|
245
248
|
configurationBuilder.withCrashReporting(true)
|
|
249
|
+
.withErrorHandler(true)
|
|
250
|
+
.withReportFatalErrorAsCrash(true)
|
|
246
251
|
.withLogLevel(LogLevel.Info)
|
|
247
252
|
.withLifecycleUpdate(false)
|
|
248
253
|
.withUserOptIn(false)
|
|
@@ -252,18 +257,20 @@ configurationBuilder.withCrashReporting(true)
|
|
|
252
257
|
Dynatrace.start(configurationBuilder.buildConfiguration());
|
|
253
258
|
```
|
|
254
259
|
|
|
255
|
-
**Info**: The
|
|
260
|
+
**Info**: The value used in the function calls for the parameters is also their default value.
|
|
256
261
|
|
|
257
|
-
| Property name
|
|
258
|
-
|
|
259
|
-
|beaconUrl
|
|
260
|
-
|applicationId
|
|
261
|
-
|reportCrash
|
|
262
|
-
|
|
|
263
|
-
|
|
|
264
|
-
|
|
|
265
|
-
|
|
|
266
|
-
|
|
|
262
|
+
| Property name | Type | Default | Description |
|
|
263
|
+
|-------------------------|--------|-------------|---------------------------------------------------|
|
|
264
|
+
|beaconUrl |string |undefined |Identifies your environment within Dynatrace. This property is mandatory for [manual startup](#manual-oneagent-startup). OneAgent issues an error when the key isn't present.|
|
|
265
|
+
|applicationId |string |undefined |Identifies your mobile app. This property is mandatory for [manual startup](#manual-oneagent-startup). OneAgent issues an error when the key isn't present.|
|
|
266
|
+
|reportCrash |boolean |true |Reports crashes. |
|
|
267
|
+
|errorHandler |boolean |true |Enables the error/crash handler. |
|
|
268
|
+
|reportFatalErrorAsCrash |boolean |true |Reports an unhandled fatal error as a crash or an error. |
|
|
269
|
+
|logLevel |LogLevel|LogLevel.Info|Allows you to choose between `LogLevel.Info` and `LogLevel.Debug`. Debug returns more logs. This is especially important when something is not functioning correctly.|
|
|
270
|
+
|lifecycleUpdate |boolean |false |Decide if you want to see update cycles on lifecycle actions as well. This is per default false as it creates a lot more actions.|
|
|
271
|
+
|userOptIn |boolean |false |Activates the privacy mode when set to `true`. User consent must be queried and set. The privacy settings for [data collection](#data-collection) and [crash reporting](#crash-reporting) can be changed via OneAgent SDK for Mobile as described under Data privacy. The default value is `false`.|
|
|
272
|
+
|actionNamePrivacy |boolean |false |Activates a privacy mode especially for Touchables and Buttons. Setting this option to true means that a name for the control will no longer be shown, e.g. "Touch on Button". When setting a dtActionName onto the component this setting will be ignored.
|
|
273
|
+
|bundleName |string |undefined |Should be used only if you have a multiple bundle setup where you load several .bundle files within your React Native application. Enter the name of your bundle. This should be unique in comparison to your other bundle names. This will ensure that actions coming from different bundles will not interfere with each other.
|
|
267
274
|
|
|
268
275
|
**Attention:**
|
|
269
276
|
* Keep in mind that configuration within the `dynatrace.config.js` file is the basis, even for manual startup. When we look at the lifecycleUpdate property: Per default if not used, it is false. If enabled (set to true) in `dynatrace.config.js` file, this will be also true if manual startup is used. You can still override this behavior by calling `ConfigurationBuilder.withLifecycleUpdate(false)`.
|
|
@@ -755,13 +762,15 @@ module.exports = {
|
|
|
755
762
|
|
|
756
763
|
### Manual Startup Counterparts
|
|
757
764
|
|
|
758
|
-
Here is a list of all the counterparts for the options that can be used with a manual startup. Below the counterparts table you will find an example configuration block for both Android and iOS.
|
|
765
|
+
Here is a list of all the counterparts for the options that can be used with a manual startup. Below in the counterparts table you will find an example configuration block for both Android and iOS.
|
|
759
766
|
|
|
760
767
|
| Property Name | Default | Android | iOS | React |
|
|
761
768
|
|---------------|------|---------|-------------|-------------|
|
|
762
769
|
|beaconUrl|undefined|autoStart.beaconUrl|DTXBeaconURL| - |
|
|
763
770
|
|applicationId|undefined|autoStart.applicationId|DTXApplicationId| - |
|
|
764
771
|
|reportCrash|true|crashReporting|DTXCrashReportingEnabled| - |
|
|
772
|
+
|errorHandler|true| - | - |errorHandler.enabled|
|
|
773
|
+
|reportFatalErrorAsCrash|true| - | - |errorHandler.reportFatalErrorAsCrash|
|
|
765
774
|
|logLevel|LogLevel.Info|debug.agentLogging|DTXLogLevel| debug |
|
|
766
775
|
|lifecycleUpdate|false| - | - | lifecycle.includeUpdate |
|
|
767
776
|
|userOptIn|false|userOptIn|DTXUserOptIn| - |
|
|
@@ -816,6 +825,25 @@ react: {
|
|
|
816
825
|
|
|
817
826
|
This activates the debug mode. You will get more console output during instrumentation and at runtime.
|
|
818
827
|
|
|
828
|
+
#### Error Handler
|
|
829
|
+
|
|
830
|
+
```js
|
|
831
|
+
react: {
|
|
832
|
+
errorHandler: {
|
|
833
|
+
enabled: true,
|
|
834
|
+
reportFatalErrorAsCrash: true,
|
|
835
|
+
},
|
|
836
|
+
}
|
|
837
|
+
```
|
|
838
|
+
|
|
839
|
+
The `enabled` property activates our Error/Crash handler which will insert our handler into your React Native application. This is true per default.
|
|
840
|
+
|
|
841
|
+
The `reportFatalErrorAsCrash` property should be set to false if you are wanting to report a fatal/unhandled error as an error and NOT a crash. Setting this value to false will keep the current session open.
|
|
842
|
+
|
|
843
|
+
**Note:**
|
|
844
|
+
if `enabled` is set to false, the value of `reportFatalErrorAsCrash` is not be considered/used as our error handler will not be started.
|
|
845
|
+
|
|
846
|
+
|
|
819
847
|
#### Autostart
|
|
820
848
|
|
|
821
849
|
```js
|
|
@@ -824,7 +852,7 @@ react: {
|
|
|
824
852
|
}
|
|
825
853
|
```
|
|
826
854
|
|
|
827
|
-
This activates the AutoStart mode
|
|
855
|
+
This activates the AutoStart mode which will insert an auto start call in your React Native application. This is true per default. If you want to use a manual startup call, please have a look into the [manual startup section](#manual-oneagent-startup).
|
|
828
856
|
|
|
829
857
|
#### Bundle Name
|
|
830
858
|
|
|
@@ -1040,6 +1068,19 @@ JavaScript:
|
|
|
1040
1068
|
|
|
1041
1069
|
*Note:* [actionNamePrivacy](#plugin-startup) has no impact on using dtActionName. dtActionName will always be used.
|
|
1042
1070
|
|
|
1071
|
+
## How does Dynatrace automatically report crashes?
|
|
1072
|
+
|
|
1073
|
+
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.
|
|
1074
|
+
|
|
1075
|
+
**Note:** The behavior mentioned below occurs if an error contains a stacktrace or if the stacktrace is empty/missing.
|
|
1076
|
+
|
|
1077
|
+
* Non fatal error: If the internal React Native crash handler shows the error is not fatal, we will report it as error.
|
|
1078
|
+
* Fatal error: If the error is considered as fatal by the React Native crash handler, it will be treated as crash.
|
|
1079
|
+
* Native crashes: If a crash appears solely on the native side and is not noticed by the internal React Native crash handler, it will be reported directly by the Android or iOS agent.
|
|
1080
|
+
* Exception: Some JavaScript crashes will result in Native crashes. Therefore, they are filtered on the native side as normally the crash would be reported twice. On the JavaScript side, these crashes are already reported by us before they hit the native side resulting in no lost information.
|
|
1081
|
+
Additionally, you can use our crash and error reporting APIs which are available with [manual instrumentation](#manual-instrumentation).
|
|
1082
|
+
|
|
1083
|
+
|
|
1043
1084
|
## React Automatic Runtime
|
|
1044
1085
|
|
|
1045
1086
|
React introduced with React v17.x, React v16.14.0, React v15.7.0, and React v14.10 the automatic runtime which changes the JSX transformation (https://reactjs.org/blog/2020/09/22/introducing-the-new-jsx-transform.html).
|
|
@@ -1308,6 +1349,7 @@ To resolve problems with the plugin, first look at creating logs and identify wh
|
|
|
1308
1349
|
** The android configuration was not added to your project. Please refer to the [install the plugin](#install-the-plugin) section.
|
|
1309
1350
|
* For Android, if you see an error like "Gradle sync failed: Could not find com.dynatrace.tools.android:gradle-plugin:8.223.1.1003.", please see the [MavenCentral](#mavenCentral) section for an example and more information.
|
|
1310
1351
|
* When using NodeJS version `15+` and version `2.231.1` of our plugin you could encounter the following error: `npm ERR! Could not resolve dependency: npm ERR! peer react@"^16.0" from @react-native-community/picker@1.8.1`. Using the old deprecrated [Picker dependency](https://www.npmjs.com/package/@react-native-community/picker) was causing peer dependency issues so we updated the auto-instrumentation to use the [new Picker dependency.](https://www.npmjs.com/package/@react-native-picker/picker) If you are still using this `@react-native-community/picker`, you can manually instrument the picker without issue ([create custom actions](#create-custom-actions)).
|
|
1352
|
+
* To disable the error handler when using manual startup, you will need to use/migrate to the `ConfigurationBuilder` instead of the deprecated `ManualStartupConfiguration`. There is no option to disable the crash handler using `ManualStartupConfiguration`.
|
|
1311
1353
|
|
|
1312
1354
|
## Report a bug or open a support case
|
|
1313
1355
|
|
|
@@ -1320,9 +1362,19 @@ If you are struggling with a problem, submit a support ticket to Dynatrace (supp
|
|
|
1320
1362
|
<br/><br/>
|
|
1321
1363
|
## Changelog
|
|
1322
1364
|
|
|
1323
|
-
|
|
1365
|
+
latest
|
|
1366
|
+
* Updated the way we report unhandled errors without a stacktrace
|
|
1367
|
+
|
|
1368
|
+
2.289.1
|
|
1369
|
+
* Update Android (8.289.2.1007) & iOS Agent (8.289.1.1015)
|
|
1370
|
+
* Added option to disable error handler for auto and manual start
|
|
1371
|
+
* Updated touchable instrumentation for React Native v74
|
|
1372
|
+
|
|
1373
|
+
2.287.3
|
|
1324
1374
|
* Update Android (8.287.1.1006) & iOS Agent (8.287.2.1009)
|
|
1325
1375
|
* Added request and response size to [manual web request tagging](#manual-web-request-tagging)
|
|
1376
|
+
* Improved logging of configuration at startup
|
|
1377
|
+
* Fixed dtActionName when using ActionNamePrivacy
|
|
1326
1378
|
|
|
1327
1379
|
2.285.2
|
|
1328
1380
|
* Fixed bridge module issue for older React Native versions (< 0.65.0)
|
package/android/build.gradle
CHANGED
|
@@ -70,7 +70,7 @@ repositories {
|
|
|
70
70
|
}
|
|
71
71
|
|
|
72
72
|
dependencies {
|
|
73
|
-
implementation 'com.dynatrace.agent:agent-android:8.
|
|
73
|
+
implementation 'com.dynatrace.agent:agent-android:8.289.2.1007'
|
|
74
74
|
implementation "com.facebook.react:react-native:${safeExtGet('reactNative', '+')}"
|
|
75
75
|
}
|
|
76
76
|
|
|
@@ -161,12 +161,11 @@ public class DynatraceRNBridgeImpl {
|
|
|
161
161
|
}
|
|
162
162
|
}
|
|
163
163
|
|
|
164
|
-
public void reportCrash(String errorName, String reason, String stacktrace, boolean isRealError,
|
|
164
|
+
public void reportCrash(String errorName, String reason, String stacktrace, boolean isRealError, String platform){
|
|
165
165
|
if (this.shouldWorkOnAndroid(platform)) {
|
|
166
166
|
Dynatrace.reportCrash(isRealError ? PlatformType.JAVA_SCRIPT : PlatformType.CUSTOM, errorName, reason, stacktrace);
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
}
|
|
167
|
+
// Generate new session like iOS to make sure the behavior is the same
|
|
168
|
+
Dynatrace.createNewSession();
|
|
170
169
|
}
|
|
171
170
|
}
|
|
172
171
|
|
|
@@ -71,12 +71,12 @@ public class DynatraceRNBridge extends NativeDynatraceBridgeSpec {
|
|
|
71
71
|
}
|
|
72
72
|
|
|
73
73
|
@Override
|
|
74
|
-
public void reportCrash(String errorName, String reason, String stacktrace, boolean isRealError,
|
|
75
|
-
this.impl.reportCrash(errorName, reason, stacktrace, isRealError,
|
|
74
|
+
public void reportCrash(String errorName, String reason, String stacktrace, boolean isRealError, String platform){
|
|
75
|
+
this.impl.reportCrash(errorName, reason, stacktrace, isRealError, platform);
|
|
76
76
|
}
|
|
77
77
|
|
|
78
78
|
@Override
|
|
79
|
-
public void storeCrash(String errorName, String reason, String stacktrace
|
|
79
|
+
public void storeCrash(String errorName, String reason, String stacktrace){
|
|
80
80
|
// Empty on Purpose
|
|
81
81
|
}
|
|
82
82
|
|
|
@@ -73,12 +73,12 @@ public class DynatraceRNBridge extends ReactContextBaseJavaModule {
|
|
|
73
73
|
}
|
|
74
74
|
|
|
75
75
|
@ReactMethod
|
|
76
|
-
public void reportCrash(String errorName, String reason, String stacktrace, boolean isRealError,
|
|
77
|
-
this.impl.reportCrash(errorName, reason, stacktrace, isRealError,
|
|
76
|
+
public void reportCrash(String errorName, String reason, String stacktrace, boolean isRealError, String platform){
|
|
77
|
+
this.impl.reportCrash(errorName, reason, stacktrace, isRealError, platform);
|
|
78
78
|
}
|
|
79
79
|
|
|
80
80
|
@ReactMethod
|
|
81
|
-
public void storeCrash(String errorName, String reason, String stacktrace
|
|
81
|
+
public void storeCrash(String errorName, String reason, String stacktrace){
|
|
82
82
|
// Empty on Purpose
|
|
83
83
|
}
|
|
84
84
|
|
package/files/default.config.js
CHANGED
|
@@ -10,6 +10,20 @@ module.exports = {
|
|
|
10
10
|
*/
|
|
11
11
|
debug: true,
|
|
12
12
|
|
|
13
|
+
errorHandler: {
|
|
14
|
+
/**
|
|
15
|
+
* Error handler is enabled.
|
|
16
|
+
*/
|
|
17
|
+
enabled: true,
|
|
18
|
+
|
|
19
|
+
/**
|
|
20
|
+
* If we catch an unhandled error (fatal) with our error handler, we will report it as a crash
|
|
21
|
+
* when using the default value of true. If the value is set to false, we will report the fatal
|
|
22
|
+
* error as an error and continue the session.
|
|
23
|
+
*/
|
|
24
|
+
reportFatalErrorAsCrash: true,
|
|
25
|
+
},
|
|
26
|
+
|
|
13
27
|
lifecycle: {
|
|
14
28
|
/**
|
|
15
29
|
* Decide if you want to see Update Cycles as well
|
package/files/plugin.gradle
CHANGED
package/ios/DynatraceRNBridge.mm
CHANGED
|
@@ -172,22 +172,22 @@ RCT_EXPORT_METHOD(reportError:(NSString *)errorName errorValue:(NSString *)error
|
|
|
172
172
|
}
|
|
173
173
|
}
|
|
174
174
|
|
|
175
|
-
RCT_EXPORT_METHOD(reportCrash:(NSString *)errorName errorReason:(NSString *)errorReason stacktrace:(NSString *)stacktrace isRealError:(BOOL)isRealError
|
|
175
|
+
RCT_EXPORT_METHOD(reportCrash:(NSString *)errorName errorReason:(NSString *)errorReason stacktrace:(NSString *)stacktrace isRealError:(BOOL)isRealError platform: (NSString *) platform)
|
|
176
176
|
{
|
|
177
177
|
if ([self shouldWorkOnIosWithPlatform: platform])
|
|
178
178
|
{
|
|
179
179
|
if(isRealError){
|
|
180
|
-
[DTXAction reportExternalCrashForPlatformType:
|
|
180
|
+
[DTXAction reportExternalCrashForPlatformType:DTXActionPlatformCustom crashName:errorName reason:errorReason stacktrace:stacktrace];
|
|
181
181
|
}else{
|
|
182
182
|
[DTXAction reportExternalCrashForPlatformType:DTXActionPlatformCustom crashName:errorName reason:errorReason stacktrace:stacktrace];
|
|
183
183
|
}
|
|
184
184
|
|
|
185
|
-
//
|
|
185
|
+
// Always end the session as the iOS agent has no troubles with this behavior
|
|
186
186
|
[Dynatrace endVisit];
|
|
187
187
|
}
|
|
188
188
|
}
|
|
189
189
|
|
|
190
|
-
RCT_EXPORT_METHOD(storeCrash:(NSString *)crashName reason:(NSString *)reason stacktrace:(NSString *)stacktrace
|
|
190
|
+
RCT_EXPORT_METHOD(storeCrash:(NSString *)crashName reason:(NSString *)reason stacktrace:(NSString *)stacktrace) {
|
|
191
191
|
NSString* dirPath = [[[[NSFileManager defaultManager] URLsForDirectory:NSApplicationSupportDirectory inDomains:NSUserDomainMask] firstObject] path];
|
|
192
192
|
dirPath = [dirPath stringByAppendingPathComponent:@"DTXExternalCrashes"];
|
|
193
193
|
// Create the Application Support/DTXExternalCrashes directory if it does not exist
|
|
@@ -202,10 +202,7 @@ RCT_EXPORT_METHOD(storeCrash:(NSString *)crashName reason:(NSString *)reason sta
|
|
|
202
202
|
// Store react native crash
|
|
203
203
|
[[NSFileManager defaultManager] createFileAtPath:[dirPath stringByAppendingPathComponent:@"RNCrash.txt"] contents:[crashJson dataUsingEncoding:NSUTF8StringEncoding] attributes:nil];
|
|
204
204
|
|
|
205
|
-
|
|
206
|
-
if (newSession) {
|
|
207
|
-
[Dynatrace endVisit];
|
|
208
|
-
}
|
|
205
|
+
[Dynatrace endVisit];
|
|
209
206
|
}
|
|
210
207
|
|
|
211
208
|
RCT_EXPORT_METHOD(reportErrorInAction:(nonnull NSString *)key errorName:(NSString *)errorName errorCode:(nonnull NSNumber *)errorCode platform: (NSString *) platform)
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";var o,n=require("@babel/runtime/helpers/interopRequireDefault"),r=n(require("@babel/runtime/helpers/toConsumableArray")),a=(Object.defineProperty(exports,"t",{value:!0}),exports.instrument=void 0,require("path")),c=require("jscodeshift"),i=require("jscodeshift/src/Collection"),e=require("../../scripts/FileOperationHelper"),t=require("../../scripts/PathsConstants"),u=require("../react-native/Touchables.InstrInfo"),l=require("../react-native/RefreshControl.InstrInfo"),f=require("../react-native/Switch.InstrInfo"),s=require("../community/gesture-handler/Touchables.InstrInfo"),v=require("../community/Picker.InstrInfo"),d=require("./parser/Babel"),p=require("./model/Types"),m=(!function(n){n[n.i=-1]="Filtered",n[n.u=0]="Normal",n[n.o=1]="ReactNative",n[n.l=2]="React"}(o=o||{}),[]),y=(m.push.apply(m,(0,r.default)(u.instrumentationInfo)),m.push.apply(m,(0,r.default)(l.instrumentationInfo)),m.push.apply(m,(0,r.default)(f.instrumentationInfo)),m.push.apply(m,(0,r.default)(s.instrumentationInfo)),m.push.apply(m,(0,r.default)(v.instrumentationInfo)),["AppRegistry","renderApplication","setUpErrorHandling"]),instrument=function(n,r,e){r=P(r);var t=M(r);if(t!==o.i){var i=!1,u=N(r,n);if(t===o.l)T(u),i=!0;else if(t===o.o)r.endsWith("AppRegistry.js")?void 0!==e&&e.autoStart&&(U(u),i=!0):r.endsWith("renderApplication.js")?(q(u),i=!0):r.endsWith("setUpErrorHandling.js")&&(B(u,e.autoStart),i=!0);else{var t=w(r,e);if(e.custom.reactnavigation&&g(r,u))i=!0;else{if(!t.input&&!t.lifecycle)return null!=e&&e.debug&&console.log("Dynatrace - Filtered All: ".concat(r)),I(r),n;t.lifecycle&&q(u)&&(i=!0),t.input&&m.forEach(function(n){n=G(u,n);u=n.root,i=i||n.v})}}i?(n=u.toSource({quote:"single"}),H(n,r)):I(r),null!=e&&e.debug&&i&&console.log("Dynatrace - Modified Filename: "+r)}else r.includes(a.join("@dynatrace","react-native-plugin"))&&r.endsWith(a.join("lib","instrumentor","base","configuration","ConfigurationPreset.js"))&&void 0!==e&&(t=N(r,n),void 0!==e.lifecycle&&h(t,"getLifecycleUpdate",e.lifecycle.includeUpdate),void 0!==e.debug&&h(t,"getLogLevel",e.debug?0:1),void 0!==e.bundleName&&h(t,"getBundleName",e.bundleName),void 0!==e.input&&void 0!==e.input.actionNamePrivacy&&h(t,"getActionNamePrivacy",e.input.actionNamePrivacy),e.autoStart&&h(t,"isAutoStartupEnabled",e.autoStart),n=t.toSource({quote:"single"}),H(n,r));return n},g=(exports.instrument=instrument,function(n,r){return!!b(n,r)&&(r.find(c.ImportDeclaration).at(0).insertBefore("import { registerListener } from '@dynatrace/react-native-plugin/lib/react-navigation/ReactNavigation';"),!0)}),b=function(n,r){var e=!1;return n.includes("react-navigation")&&n.includes("NavigationContainer.tsx")&&r.find(c.VariableDeclarator).forEach(function(n){e||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);"),e=!0)}),e},q=function(n){var r=n.findJSXElements(),t=!1;return 0<r.length&&(n.find(c.FunctionDeclaration).forEach(function(n){var r,e=(0,i.fromPaths)([n]);0<e.findJSXElements().length&&null!=n&&null!=n.value&&null!=n.value.id&&n.value.id.name&&(r=e.find(c.ClassDeclaration),e=e.find(c.ClassExpression),0===r.length)&&0===e.length&&(A(n,p.Types.FunctionalComponent,n.value.id.name),t=!0)}),n.find(c.ClassDeclaration).forEach(function(n){0<(0,i.fromPaths)([n]).findJSXElements().length&&null!=n&&null!=n.value&&n.value.id&&n.value.id.name&&(A(n,p.Types.ClassComponent,n.value.id.name),t=!0)}),n.find(c.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&&(A(n,p.Types.FunctionalComponent,n.parent.value.id.name),t=!0)})),t},A=function(n,r,e){for(r=c.expressionStatement(c.assignmentExpression("=",c.memberExpression(c.identifier(e),c.identifier("_dtInfo")),O(r,e)));void 0!==n.parentPath&&"body"!==n.parentPath.name;)n=n.parentPath;void 0!==n.parentPath&&n.insertAfter(r)},O=function(n,r){return c.objectExpression([c.objectProperty(c.identifier("type"),c.numericLiteral(n)),c.objectProperty(c.identifier("name"),c.stringLiteral(r))])},h=function(n,r,e){var n=n.find(c.Identifier).filter(function(n){return n.node.name===r});1===n.length&&"ReturnStatement"===(n=n.paths()[0].parent.value.body.body[0]).type&&("boolean"==typeof e&&(n.argument=c.booleanLiteral(e)),"string"==typeof e&&(n.argument=c.stringLiteral(e)),"number"==typeof e)&&(n.argument=c.numericLiteral(e))},N=function(n,r){return c.withParser((0,d.babelParser)(a.extname(n)))(r)},P=function(n){return a.isAbsolute(n)?n.replace(t.default.getApplicationPath()+a.sep,""):n},I=function(n){try{var r=a.join(t.default.getBuildPath(),n+".dtx");e.default.checkIfFileExistsSync(r),e.default.deleteFileSync(r)}catch(n){}},H=function(n,r){r=a.join(t.default.getBuildPath(),r);try{e.default.checkIfFileExistsSync(a.dirname(r))}catch(n){e.default.createDirectorySync(a.dirname(r))}e.default.writeTextToFileSync(r+".dtx",n)},w=function(n,r){var e={input:!1,lifecycle:!1};return void 0!==r&&(void 0!==r.lifecycle&&void 0!==r.lifecycle.instrument&&r.lifecycle.instrument(n)&&(e.lifecycle=!0),void 0!==r.input)&&void 0!==r.input.instrument&&r.input.instrument(n)&&(e.input=!0),e},T=function(n){var r,n=n.find(c.Program);1===n.length&&(r=c.expressionStatement(c.callExpression(c.memberExpression(c.callExpression(c.identifier("require"),[c.stringLiteral("@dynatrace/react-native-plugin/lib/instrumentor/base/ElementHelper")]),c.identifier("instrumentCreateElement")),[c.memberExpression(c.identifier("module"),c.identifier("exports"))])),n.paths()[0].node.body.push(r))},U=function(n){var r=J(n,"runApplication",!0);1===r.length&&(rn(n,{p:"_DynatraceApplicationHandler",module:"@dynatrace/react-native-plugin",reference:"ApplicationHandler"}),x(r.paths()[0].parent.value.body.body,0,R("_DynatraceApplicationHandler","startup",[])))},B=function(n,r){n=n.paths()[0].value.program.body;null!=n&&(x(n,n.length,_({p:"_DynatraceErrorHandler",module:"@dynatrace/react-native-plugin/lib/instrumentor/base/ErrorHandler",reference:""})),x(n,n.length,R("_DynatraceErrorHandler","registerErrorHandler",[])))},x=function(n,r){for(var e=arguments.length,t=new Array(2<e?e-2:0),i=2;i<e;i++)t[i-2]=arguments[i];return n.splice.apply(n,[r,0].concat(t))},J=function(n,r,t){for(var e=arguments.length,i=new Array(3<e?e-3:0),u=3;u<e;u++)i[u-3]=arguments[u];return n.find(c.Identifier).filter(function(n){return n.node.name===r}).filter(function(n){return void 0!==n.parent&&void 0!==n.parent.value&&void 0!==n.parent.value.params}).filter(function(n){var r=void 0!==n.parent&&void 0!==n.parent.value;t||(r=r&&n.parent.value.params.length===i.length);for(var e=0;e<0;e++)r=r&&n.parent.value.params[e].name===i[e];return r})},M=function(n){if(n.includes("@dynatrace"))return o.i;var r=a.extname(n);if(".js"!==r&&".ts"!==r&&".tsx"!==r&&".jsx"!==r)return o.i;for(var e=a.parse(n),t=e.dir.split(a.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 y.includes(e.name)?o.o:o.i;if("react"===t[i+1]&&"index"===e.name)return o.l}return o.u},k=function(n,r,e){var t=V(n,r,e);return z(n,r,e)||t},V=function(n,r,e){var t=K(n,r);return 0<t.length&&(void 0!==(t=E(t,r.reference,!1))&&(e.p=t.localName),$(n,e),!0)},z=function(n,r,e){var t=C(n,r.module);if(1===t.length){t=E(t,r.reference,!0);if(void 0!==t)return nn(n,e.defaultImport,t.localName,"ImportNamespaceSpecifier"===t.type),!0}return!1},G=function(n,r){var e=JSON.parse(JSON.stringify(r.new));return{root:n,v:k(n,r.old,e)||Q(n,r.old,r.new.defaultImport)}},K=function(n,r){return n.find(c.ImportDeclaration).filter(function(n){return n.node.source.value===r.module&&null!=n.node.specifiers&&n.node.specifiers.some(function(n){return j(n)&&n.imported.name===r.reference||n.local&&n.local.name===r.reference})})},j=function(n){return void 0!==n.imported},Q=function(n,r,e){var t=!1;return n.find(c.CallExpression).filter(function(n){return W(n.node.callee)&&X(n.node.arguments[0])&&n.node.arguments[0].value===r.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===r.reference)&&(n.node.arguments[0].value=e,t=t||!0)}),t},W=function(n){return"require"===n.name},X=function(n){return"StringLiteral"===n.type||"Literal"===n.type},C=function(n,r){return n.find(c.ImportDeclaration).filter(function(n){return n.node.source.value===r})},E=function(n,e,t){var i;return n.forEach(function(n){void 0!==n.node.specifiers&&(n.node.specifiers=n.node.specifiers.filter(function(n){var r;return j(n)&&!t?((r=n.imported.name!==e)||null==n.local||n.imported.name===n.local.name||(i={localName:n.local.name,type:n.type}),r):!(!j(n)&&t&&(null!=n.local&&(i={localName:n.local.name,type:n.type}),1))}),0===n.node.specifiers.length)&&n.prune()}),i},Y=function(n,r){n.find(c.ImportDeclaration).filter(function(n){return n.node.source.value===r.module}).forEach(function(n){null!=n.node.specifiers&&n.node.specifiers.push(F(r))})},Z=function(n,r,e){n.find(c.ImportDeclaration).filter(function(n){return n.node.source.value===r}).forEach(function(n){null!=n.node.specifiers&&n.node.specifiers.push(e)})},D=function(n,r,e){var t=n.find(c.ImportDeclaration);0<t.length?c(t.paths()[0]).insertAfter(S(r,e)):1===(t=n.find(c.Program)).length&&t.paths()[0].node.body.unshift(S(r,e))},$=function(n,r){0<C(n,r.module).length?Y(n,r):D(n,r.module,[F(r)])},nn=function(n,r,e,t){var i=C(n,r),t=(t?cn:an)(e);0<i.length?Z(n,r,t):D(n,r,[t])},rn=function(n,r){n=n.find(c.VariableDeclaration);0<n.length&&c(n.paths()[0]).insertAfter(_(r))},R=function(n,r,e){return c.expressionStatement(en(n,r,e))},en=function(n,r,e){return c.callExpression(on(n,r),e)},_=function(n){return c.variableDeclaration("var",[tn(n)])},tn=function(n){return c.variableDeclarator(void 0!==n.p?c.identifier(n.p):c.identifier(n.reference),(0<n.reference.length?un:L)(n))},un=function(n){return c.memberExpression(L(n),c.identifier(n.reference))},on=function(n,r){return c.memberExpression(c.identifier(n),c.identifier(r))},L=function(n){return c.callExpression(c.identifier("require"),[c.literal(n.module)])},S=function(n,r){return c.importDeclaration(r,c.literal(n))},F=function(n){return void 0!==n.p?c.importSpecifier(c.identifier(n.reference),c.identifier(n.p)):c.importSpecifier(c.identifier(n.reference))},an=function(n){return c.importDefaultSpecifier(c.identifier(n))},cn=function(n){return c.importNamespaceSpecifier(c.identifier(n))};
|
|
1
|
+
"use strict";var o,n=require("@babel/runtime/helpers/interopRequireDefault"),r=n(require("@babel/runtime/helpers/toConsumableArray")),a=(Object.defineProperty(exports,"t",{value:!0}),exports.instrument=void 0,require("path")),c=require("jscodeshift"),i=require("jscodeshift/src/Collection"),e=require("../../scripts/FileOperationHelper"),t=require("../../scripts/PathsConstants"),u=require("../react-native/Touchables.InstrInfo"),l=require("../react-native/RefreshControl.InstrInfo"),f=require("../react-native/Switch.InstrInfo"),s=require("../community/gesture-handler/Touchables.InstrInfo"),v=require("../community/Picker.InstrInfo"),d=require("./parser/Babel"),p=require("./model/Types"),m=(!function(n){n[n.i=-1]="Filtered",n[n.u=0]="Normal",n[n.o=1]="ReactNative",n[n.l=2]="React"}(o=o||{}),[]),y=(m.push.apply(m,(0,r.default)(u.instrumentationInfo)),m.push.apply(m,(0,r.default)(l.instrumentationInfo)),m.push.apply(m,(0,r.default)(f.instrumentationInfo)),m.push.apply(m,(0,r.default)(s.instrumentationInfo)),m.push.apply(m,(0,r.default)(v.instrumentationInfo)),["AppRegistry","renderApplication","setUpErrorHandling"]),instrument=function(n,r,e){r=P(r);var t=M(r);if(t!==o.i){var i=!1,u=N(r,n);if(t===o.l)T(u),i=!0;else if(t===o.o)r.endsWith("AppRegistry.js")?void 0!==e&&e.autoStart&&(U(u),i=!0):r.endsWith("renderApplication.js")?(q(u),i=!0):r.endsWith("setUpErrorHandling.js")&&void 0!==e&&e.autoStart&&e.errorHandler.enabled&&(B(u,e.autoStart,e.errorHandler.reportFatalErrorAsCrash),i=!0);else{var t=w(r,e);if(e.custom.reactnavigation&&g(r,u))i=!0;else{if(!t.input&&!t.lifecycle)return null!=e&&e.debug&&console.log("Dynatrace - Filtered All: ".concat(r)),E(r),n;t.lifecycle&&q(u)&&(i=!0),t.input&&m.forEach(function(n){n=G(u,n);u=n.root,i=i||n.v})}}i?(n=u.toSource({quote:"single"}),H(n,r)):E(r),null!=e&&e.debug&&i&&console.log("Dynatrace - Modified Filename: "+r)}else r.includes(a.join("@dynatrace","react-native-plugin"))&&r.endsWith(a.join("lib","instrumentor","base","configuration","ConfigurationPreset.js"))&&void 0!==e&&(t=N(r,n),void 0!==e.lifecycle&&h(t,"getLifecycleUpdate",e.lifecycle.includeUpdate),void 0!==e.debug&&h(t,"getLogLevel",e.debug?0:1),void 0!==e.bundleName&&h(t,"getBundleName",e.bundleName),void 0!==e.input&&void 0!==e.input.actionNamePrivacy&&h(t,"getActionNamePrivacy",e.input.actionNamePrivacy),void 0!==e.errorHandler&&(h(t,"isErrorHandlerEnabled",e.errorHandler.enabled),h(t,"isReportFatalErrorAsCrash",e.errorHandler.reportFatalErrorAsCrash)),e.autoStart&&h(t,"isAutoStartupEnabled",e.autoStart),n=t.toSource({quote:"single"}),H(n,r));return n},g=(exports.instrument=instrument,function(n,r){return!!b(n,r)&&(r.find(c.ImportDeclaration).at(0).insertBefore("import { registerListener } from '@dynatrace/react-native-plugin/lib/react-navigation/ReactNavigation';"),!0)}),b=function(n,r){var e=!1;return n.includes("react-navigation")&&n.includes("NavigationContainer.tsx")&&r.find(c.VariableDeclarator).forEach(function(n){e||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);"),e=!0)}),e},q=function(n){var r=n.findJSXElements(),t=!1;return 0<r.length&&(n.find(c.FunctionDeclaration).forEach(function(n){var r,e=(0,i.fromPaths)([n]);0<e.findJSXElements().length&&null!=n&&null!=n.value&&null!=n.value.id&&n.value.id.name&&(r=e.find(c.ClassDeclaration),e=e.find(c.ClassExpression),0===r.length)&&0===e.length&&(A(n,p.Types.FunctionalComponent,n.value.id.name),t=!0)}),n.find(c.ClassDeclaration).forEach(function(n){0<(0,i.fromPaths)([n]).findJSXElements().length&&null!=n&&null!=n.value&&n.value.id&&n.value.id.name&&(A(n,p.Types.ClassComponent,n.value.id.name),t=!0)}),n.find(c.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&&(A(n,p.Types.FunctionalComponent,n.parent.value.id.name),t=!0)})),t},A=function(n,r,e){for(r=c.expressionStatement(c.assignmentExpression("=",c.memberExpression(c.identifier(e),c.identifier("_dtInfo")),O(r,e)));void 0!==n.parentPath&&"body"!==n.parentPath.name;)n=n.parentPath;void 0!==n.parentPath&&n.insertAfter(r)},O=function(n,r){return c.objectExpression([c.objectProperty(c.identifier("type"),c.numericLiteral(n)),c.objectProperty(c.identifier("name"),c.stringLiteral(r))])},h=function(n,r,e){var n=n.find(c.Identifier).filter(function(n){return n.node.name===r});1===n.length&&"ReturnStatement"===(n=n.paths()[0].parent.value.body.body[0]).type&&("boolean"==typeof e&&(n.argument=c.booleanLiteral(e)),"string"==typeof e&&(n.argument=c.stringLiteral(e)),"number"==typeof e)&&(n.argument=c.numericLiteral(e))},N=function(n,r){return c.withParser((0,d.babelParser)(a.extname(n)))(r)},P=function(n){return a.isAbsolute(n)?n.replace(t.default.getApplicationPath()+a.sep,""):n},E=function(n){try{var r=a.join(t.default.getBuildPath(),n+".dtx");e.default.checkIfFileExistsSync(r),e.default.deleteFileSync(r)}catch(n){}},H=function(n,r){r=a.join(t.default.getBuildPath(),r);try{e.default.checkIfFileExistsSync(a.dirname(r))}catch(n){e.default.createDirectorySync(a.dirname(r))}e.default.writeTextToFileSync(r+".dtx",n)},w=function(n,r){var e={input:!1,lifecycle:!1};return void 0!==r&&(void 0!==r.lifecycle&&void 0!==r.lifecycle.instrument&&r.lifecycle.instrument(n)&&(e.lifecycle=!0),void 0!==r.input)&&void 0!==r.input.instrument&&r.input.instrument(n)&&(e.input=!0),e},T=function(n){var r,n=n.find(c.Program);1===n.length&&(r=c.expressionStatement(c.callExpression(c.memberExpression(c.callExpression(c.identifier("require"),[c.stringLiteral("@dynatrace/react-native-plugin/lib/instrumentor/base/ElementHelper")]),c.identifier("instrumentCreateElement")),[c.memberExpression(c.identifier("module"),c.identifier("exports"))])),n.paths()[0].node.body.push(r))},U=function(n){var r=J(n,"runApplication",!0);1===r.length&&(rn(n,{p:"_DynatraceApplicationHandler",module:"@dynatrace/react-native-plugin",reference:"ApplicationHandler"}),I(r.paths()[0].parent.value.body.body,0,D("_DynatraceApplicationHandler","startup",[])))},B=function(n,r,e){n=n.paths()[0].value.program.body;null!=n&&(I(n,n.length,_({p:"_DynatraceErrorHandler",module:"@dynatrace/react-native-plugin/lib/instrumentor/base/ErrorHandler",reference:""})),I(n,n.length,D("_DynatraceErrorHandler","registerErrorHandler",[c.literal(e)])))},I=function(n,r){for(var e=arguments.length,t=new Array(2<e?e-2:0),i=2;i<e;i++)t[i-2]=arguments[i];return n.splice.apply(n,[r,0].concat(t))},J=function(n,r,t){for(var e=arguments.length,i=new Array(3<e?e-3:0),u=3;u<e;u++)i[u-3]=arguments[u];return n.find(c.Identifier).filter(function(n){return n.node.name===r}).filter(function(n){return void 0!==n.parent&&void 0!==n.parent.value&&void 0!==n.parent.value.params}).filter(function(n){var r=void 0!==n.parent&&void 0!==n.parent.value;t||(r=r&&n.parent.value.params.length===i.length);for(var e=0;e<0;e++)r=r&&n.parent.value.params[e].name===i[e];return r})},M=function(n){if(n.includes("@dynatrace"))return o.i;var r=a.extname(n);if(".js"!==r&&".ts"!==r&&".tsx"!==r&&".jsx"!==r)return o.i;for(var e=a.parse(n),t=e.dir.split(a.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 y.includes(e.name)?o.o:o.i;if("react"===t[i+1]&&"index"===e.name)return o.l}return o.u},k=function(n,r,e){var t=V(n,r,e);return z(n,r,e)||t},V=function(n,r,e){var t=K(n,r);return 0<t.length&&(void 0!==(t=j(t,r.reference,!1))&&(e.p=t.localName),$(n,e),!0)},z=function(n,r,e){var t=C(n,r.module);if(1===t.length){t=j(t,r.reference,!0);if(void 0!==t)return nn(n,e.defaultImport,t.localName,"ImportNamespaceSpecifier"===t.type),!0}return!1},G=function(n,r){var e=JSON.parse(JSON.stringify(r.new));return{root:n,v:k(n,r.old,e)||Q(n,r.old,r.new.defaultImport)}},K=function(n,r){return n.find(c.ImportDeclaration).filter(function(n){return n.node.source.value===r.module&&null!=n.node.specifiers&&n.node.specifiers.some(function(n){return x(n)&&n.imported.name===r.reference||n.local&&n.local.name===r.reference})})},x=function(n){return void 0!==n.imported},Q=function(n,r,e){var t=!1;return n.find(c.CallExpression).filter(function(n){return W(n.node.callee)&&X(n.node.arguments[0])&&n.node.arguments[0].value===r.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===r.reference)&&(n.node.arguments[0].value=e,t=t||!0)}),t},W=function(n){return"require"===n.name},X=function(n){return"StringLiteral"===n.type||"Literal"===n.type},C=function(n,r){return n.find(c.ImportDeclaration).filter(function(n){return n.node.source.value===r})},j=function(n,e,t){var i;return n.forEach(function(n){void 0!==n.node.specifiers&&(n.node.specifiers=n.node.specifiers.filter(function(n){var r;return x(n)&&!t?((r=n.imported.name!==e)||null==n.local||n.imported.name===n.local.name||(i={localName:n.local.name,type:n.type}),r):!(!x(n)&&t&&(null!=n.local&&(i={localName:n.local.name,type:n.type}),1))}),0===n.node.specifiers.length)&&n.prune()}),i},Y=function(n,r){n.find(c.ImportDeclaration).filter(function(n){return n.node.source.value===r.module}).forEach(function(n){null!=n.node.specifiers&&n.node.specifiers.push(F(r))})},Z=function(n,r,e){n.find(c.ImportDeclaration).filter(function(n){return n.node.source.value===r}).forEach(function(n){null!=n.node.specifiers&&n.node.specifiers.push(e)})},R=function(n,r,e){var t=n.find(c.ImportDeclaration);0<t.length?c(t.paths()[0]).insertAfter(S(r,e)):1===(t=n.find(c.Program)).length&&t.paths()[0].node.body.unshift(S(r,e))},$=function(n,r){0<C(n,r.module).length?Y(n,r):R(n,r.module,[F(r)])},nn=function(n,r,e,t){var i=C(n,r),t=(t?cn:an)(e);0<i.length?Z(n,r,t):R(n,r,[t])},rn=function(n,r){n=n.find(c.VariableDeclaration);0<n.length&&c(n.paths()[0]).insertAfter(_(r))},D=function(n,r,e){return c.expressionStatement(en(n,r,e))},en=function(n,r,e){return c.callExpression(on(n,r),e)},_=function(n){return c.variableDeclaration("var",[tn(n)])},tn=function(n){return c.variableDeclarator(void 0!==n.p?c.identifier(n.p):c.identifier(n.reference),(0<n.reference.length?un:L)(n))},un=function(n){return c.memberExpression(L(n),c.identifier(n.reference))},on=function(n,r){return c.memberExpression(c.identifier(n),c.identifier(r))},L=function(n){return c.callExpression(c.identifier("require"),[c.literal(n.module)])},S=function(n,r){return c.importDeclaration(r,c.literal(n))},F=function(n){return void 0!==n.p?c.importSpecifier(c.identifier(n.reference),c.identifier(n.p)):c.importSpecifier(c.identifier(n.reference))},an=function(n){return c.importDefaultSpecifier(c.identifier(n))},cn=function(n){return c.importNamespaceSpecifier(c.identifier(n))};
|
|
@@ -9,7 +9,7 @@ exports.ApplicationHandler = {
|
|
|
9
9
|
if (!ConfigurationHandler_1.ConfigurationHandler.isConfigurationAvailable()) {
|
|
10
10
|
const config = new ConfigurationBuilder_1.ConfigurationBuilder('', '').buildConfiguration();
|
|
11
11
|
ConfigurationHandler_1.ConfigurationHandler.setConfiguration(config);
|
|
12
|
-
Logger_1.Logger.logDebug('Configuration set: ' +
|
|
12
|
+
Logger_1.Logger.logDebug('Configuration set: ' + config.toString());
|
|
13
13
|
Logger_1.Logger.logInfo('Dynatrace React Native Plugin started!');
|
|
14
14
|
}
|
|
15
15
|
},
|
|
@@ -22,13 +22,20 @@ const NullRootAction_1 = require("./NullRootAction");
|
|
|
22
22
|
const DynatraceInternal_1 = require("./DynatraceInternal");
|
|
23
23
|
const DynatraceAction_1 = require("./DynatraceAction");
|
|
24
24
|
const NullAction_1 = require("./NullAction");
|
|
25
|
+
const ErrorHandler_1 = require("./ErrorHandler");
|
|
25
26
|
exports.Dynatrace = {
|
|
26
27
|
start: (configuration) => __awaiter(void 0, void 0, void 0, function* () {
|
|
27
28
|
if (!ConfigurationHandler_1.ConfigurationHandler.isConfigurationAvailable()) {
|
|
28
29
|
if (configuration !== undefined) {
|
|
29
30
|
DynatraceBridge_1.DynatraceNative.start(configuration);
|
|
31
|
+
if (configuration.errorHandler) {
|
|
32
|
+
(0, ErrorHandler_1.registerErrorHandler)(configuration.reportFatalErrorAsCrash);
|
|
33
|
+
}
|
|
34
|
+
else {
|
|
35
|
+
Logger_1.Logger.logDebug('Dynatrace error handler will not be enabled as errorHandler was set to false!');
|
|
36
|
+
}
|
|
30
37
|
ConfigurationHandler_1.ConfigurationHandler.setConfiguration(configuration);
|
|
31
|
-
Logger_1.Logger.logDebug('
|
|
38
|
+
Logger_1.Logger.logDebug('Configuration set: ' + configuration.toString());
|
|
32
39
|
}
|
|
33
40
|
else {
|
|
34
41
|
throw new Error('Configuration is empty! Not allowed for Manual Startup!');
|
|
@@ -151,7 +158,7 @@ exports.Dynatrace = {
|
|
|
151
158
|
}
|
|
152
159
|
}
|
|
153
160
|
Logger_1.Logger.logDebug(`Dynatrace reportCrash(${crashName}, ${reason}, ${stacktrace})`);
|
|
154
|
-
DynatraceBridge_1.DynatraceNative.reportCrash(crashName, reason, stacktrace, false,
|
|
161
|
+
DynatraceBridge_1.DynatraceNative.reportCrash(crashName, reason, stacktrace, false, platform === null || platform === void 0 ? void 0 : platform.toString());
|
|
155
162
|
}
|
|
156
163
|
}
|
|
157
164
|
else {
|
|
@@ -170,7 +177,7 @@ exports.Dynatrace = {
|
|
|
170
177
|
}
|
|
171
178
|
}
|
|
172
179
|
Logger_1.Logger.logDebug(`Dynatrace reportCrashWithException(${crashName}, ${crash.stack})`);
|
|
173
|
-
DynatraceBridge_1.DynatraceNative.reportCrash(crashName, crashReason, crash.stack, true,
|
|
180
|
+
DynatraceBridge_1.DynatraceNative.reportCrash(crashName, crashReason, crash.stack, true, platform === null || platform === void 0 ? void 0 : platform.toString());
|
|
174
181
|
}
|
|
175
182
|
}
|
|
176
183
|
else {
|
|
@@ -1,17 +1,33 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.DynatraceInternal = void 0;
|
|
4
|
+
const ReactNative = require("react-native");
|
|
4
5
|
const DynatraceBridge_1 = require("./DynatraceBridge");
|
|
6
|
+
const Dynatrace_1 = require("./Dynatrace");
|
|
5
7
|
const Logger_1 = require("./Logger");
|
|
8
|
+
const StringUtils_1 = require("./util/StringUtils");
|
|
6
9
|
let counter = 0;
|
|
7
10
|
exports.DynatraceInternal = {
|
|
8
|
-
reportErrorFromHandler: (isFatal, errorName, reason, stacktrace,
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
11
|
+
reportErrorFromHandler: (isFatal, errorName, reason, stacktrace, isReportFatalErrorAsCrash, platform) => {
|
|
12
|
+
if (isFatal && isReportFatalErrorAsCrash) {
|
|
13
|
+
if (ReactNative.Platform.OS === 'ios') {
|
|
14
|
+
DynatraceBridge_1.DynatraceNative.storeCrash(errorName, reason, stacktrace);
|
|
15
|
+
Logger_1.Logger.logDebug(`ErrorHandler storeCrash(${errorName}, ${reason}, ${stacktrace})`);
|
|
16
|
+
}
|
|
17
|
+
else {
|
|
18
|
+
DynatraceBridge_1.DynatraceNative.reportCrash(errorName, reason, stacktrace, true, platform === null || platform === void 0 ? void 0 : platform.toString());
|
|
19
|
+
Logger_1.Logger.logDebug(`Dynatrace reportCrash(${errorName}, ${reason}, ${stacktrace})`);
|
|
20
|
+
}
|
|
12
21
|
}
|
|
13
22
|
else {
|
|
14
|
-
|
|
23
|
+
if (!StringUtils_1.StringUtils.isStringNullEmptyOrUndefined(stacktrace)) {
|
|
24
|
+
DynatraceBridge_1.DynatraceNative.reportError(errorName, '-', reason, stacktrace, platform === null || platform === void 0 ? void 0 : platform.toString());
|
|
25
|
+
Logger_1.Logger.logDebug(`Dynatrace reportError(${errorName}, ${reason}, ${stacktrace})`);
|
|
26
|
+
}
|
|
27
|
+
else {
|
|
28
|
+
Dynatrace_1.Dynatrace.reportError(errorName, -1);
|
|
29
|
+
Logger_1.Logger.logDebug(`Dynatrace reportErrorWithoutStacktrace(${errorName})`);
|
|
30
|
+
}
|
|
15
31
|
}
|
|
16
32
|
},
|
|
17
33
|
getCounter: () => counter++,
|
|
@@ -1,24 +1,22 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports._reportErrorToDynatrace = exports.
|
|
3
|
+
exports._reportErrorToDynatrace = exports.registerErrorHandler = void 0;
|
|
4
4
|
const ReactNative = require("react-native");
|
|
5
5
|
const DynatraceInternal_1 = require("./DynatraceInternal");
|
|
6
|
-
const DynatraceBridge_1 = require("./DynatraceBridge");
|
|
7
6
|
const Dynatrace_1 = require("./Dynatrace");
|
|
8
7
|
const StringUtils_1 = require("./util/StringUtils");
|
|
9
8
|
const Logger_1 = require("./Logger");
|
|
10
|
-
|
|
11
|
-
let _isCustomErrorHandlerSet = false;
|
|
9
|
+
let _isReportFatalErrorAsCrash = true;
|
|
12
10
|
const _isReactNativeGlobal = (globalScope) => globalScope.ErrorUtils !== undefined;
|
|
13
|
-
const registerErrorHandler = () => {
|
|
11
|
+
const registerErrorHandler = (reportFatalErrorAsCrash) => {
|
|
14
12
|
if (global !== undefined && _isReactNativeGlobal(global)) {
|
|
13
|
+
_isReportFatalErrorAsCrash = reportFatalErrorAsCrash;
|
|
15
14
|
const oldHandler = global.ErrorUtils.getGlobalHandler();
|
|
16
15
|
global.ErrorUtils.setGlobalHandler((error, isFatal) => {
|
|
17
16
|
(0, exports._reportErrorToDynatrace)(error, isFatal, oldHandler);
|
|
18
17
|
});
|
|
19
18
|
const setter = global.ErrorUtils.setGlobalHandler;
|
|
20
19
|
global.ErrorUtils.setGlobalHandler = (errorHandler) => {
|
|
21
|
-
_isCustomErrorHandlerSet = true;
|
|
22
20
|
setter((error, isFatal) => {
|
|
23
21
|
(0, exports._reportErrorToDynatrace)(error, isFatal, errorHandler);
|
|
24
22
|
});
|
|
@@ -26,33 +24,19 @@ const registerErrorHandler = () => {
|
|
|
26
24
|
}
|
|
27
25
|
};
|
|
28
26
|
exports.registerErrorHandler = registerErrorHandler;
|
|
29
|
-
const isCustomErrorHandlerSet = () => _isCustomErrorHandlerSet;
|
|
30
|
-
exports.isCustomErrorHandlerSet = isCustomErrorHandlerSet;
|
|
31
27
|
const _reportErrorToDynatrace = (exception, isFatal, oldHandler) => {
|
|
32
28
|
if (exception != null && isExceptionAnError(exception)) {
|
|
33
29
|
if (!StringUtils_1.StringUtils.isStringNullEmptyOrUndefined(exception.name)) {
|
|
34
30
|
if (isFatal === undefined) {
|
|
35
31
|
isFatal = false;
|
|
36
32
|
}
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
DynatraceBridge_1.DynatraceNative.storeCrash(String(exception.name), adjustedReason(exception.message), exception.stack, Platform_1.Platform.Ios.toString());
|
|
40
|
-
Logger_1.Logger.logDebug(`ErrorHandler storeCrash(${exception}, ${isFatal})`);
|
|
41
|
-
}
|
|
42
|
-
else {
|
|
43
|
-
DynatraceInternal_1.DynatraceInternal.reportErrorFromHandler(isFatal, String(exception.name), adjustedReason(exception.message), exception.stack, _isCustomErrorHandlerSet);
|
|
44
|
-
Logger_1.Logger.logDebug(`ErrorHandler _reportErrorToDynatrace(${exception}, ${isFatal})`);
|
|
45
|
-
}
|
|
46
|
-
}
|
|
47
|
-
else {
|
|
48
|
-
Dynatrace_1.Dynatrace.reportError(String(exception.name) + ': ' + exception.message, -1);
|
|
49
|
-
Logger_1.Logger.logDebug(`ErrorHandler _reportErrorToDynatrace(${exception})`);
|
|
50
|
-
}
|
|
33
|
+
DynatraceInternal_1.DynatraceInternal.reportErrorFromHandler(isFatal, String(exception.name), adjustedReason(exception.message), exception.stack != null ? exception.stack : "", _isReportFatalErrorAsCrash);
|
|
34
|
+
Logger_1.Logger.logDebug(`ErrorHandler _reportErrorToDynatrace(${exception}, ${isFatal})`);
|
|
51
35
|
}
|
|
52
36
|
}
|
|
53
37
|
else {
|
|
54
38
|
Dynatrace_1.Dynatrace.reportError(String(exception), -1);
|
|
55
|
-
Logger_1.Logger.logDebug(`ErrorHandler _reportErrorToDynatrace(${exception})`);
|
|
39
|
+
Logger_1.Logger.logDebug(`ErrorHandler _reportErrorToDynatrace(${exception}, -1)`);
|
|
56
40
|
}
|
|
57
41
|
if (oldHandler !== undefined) {
|
|
58
42
|
if (ReactNative.Platform.OS === 'ios') {
|
|
@@ -25,7 +25,7 @@ const TouchableHelper = (Dynatrace, Logger) => ({
|
|
|
25
25
|
}
|
|
26
26
|
else {
|
|
27
27
|
let finalNameOfAction = nameOfAction;
|
|
28
|
-
if (ConfigurationHandler_1.ConfigurationHandler.isActionNamePrivacyEnabled()) {
|
|
28
|
+
if (!(0, IDynatraceProperties_1.isDynatraceNaming)(props) && ConfigurationHandler_1.ConfigurationHandler.isActionNamePrivacyEnabled()) {
|
|
29
29
|
finalNameOfAction = isButton ? 'Button' : 'Touchable';
|
|
30
30
|
}
|
|
31
31
|
const action = Dynatrace.enterAutoAction(`Touch on ${finalNameOfAction}`);
|
|
@@ -1,16 +1,36 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.Configuration = void 0;
|
|
4
|
+
const LogLevel_1 = require("../model/LogLevel");
|
|
4
5
|
class Configuration {
|
|
5
|
-
constructor(beaconUrl, applicationId, reportCrash, logLevel, lifecycleUpdate, userOptIn, actionNamePrivacy, bundleName) {
|
|
6
|
+
constructor(beaconUrl, applicationId, reportCrash, errorHandler, reportFatalErrorAsCrash, logLevel, lifecycleUpdate, userOptIn, actionNamePrivacy, bundleName) {
|
|
6
7
|
this.beaconUrl = beaconUrl;
|
|
7
8
|
this.applicationId = applicationId;
|
|
8
9
|
this.reportCrash = reportCrash;
|
|
10
|
+
this.errorHandler = errorHandler;
|
|
11
|
+
this.reportFatalErrorAsCrash = reportFatalErrorAsCrash;
|
|
9
12
|
this.logLevel = logLevel;
|
|
10
13
|
this.lifecycleUpdate = lifecycleUpdate;
|
|
11
14
|
this.userOptIn = userOptIn;
|
|
12
15
|
this.actionNamePrivacy = actionNamePrivacy;
|
|
13
16
|
this.bundleName = bundleName;
|
|
14
17
|
}
|
|
18
|
+
toString() {
|
|
19
|
+
let configurationString;
|
|
20
|
+
if (this.beaconUrl === '' && this.applicationId === '') {
|
|
21
|
+
configurationString = '{Startup: Auto Start,';
|
|
22
|
+
}
|
|
23
|
+
else {
|
|
24
|
+
configurationString = `{Startup: Manual Start, applicationId: ${this.applicationId}, beaconUrl: ${this.beaconUrl},`;
|
|
25
|
+
}
|
|
26
|
+
configurationString += ` reportCrash: ${this.reportCrash}, errorHandler: ${this.errorHandler}, reportFatalErrorAsCrash: ${this.reportFatalErrorAsCrash},`
|
|
27
|
+
+ ` lifecycleUpdate: ${this.lifecycleUpdate}, userOptIn: ${this.userOptIn},`
|
|
28
|
+
+ ` actionNamePrivacy: ${this.actionNamePrivacy}, logLevel: ${(0, LogLevel_1.LogLevelToString)(this.logLevel)}`;
|
|
29
|
+
if (this.bundleName !== undefined) {
|
|
30
|
+
configurationString += `, bundleName: ${this.bundleName}`;
|
|
31
|
+
}
|
|
32
|
+
configurationString += '}';
|
|
33
|
+
return configurationString;
|
|
34
|
+
}
|
|
15
35
|
}
|
|
16
36
|
exports.Configuration = Configuration;
|
|
@@ -12,6 +12,8 @@ class ConfigurationBuilder {
|
|
|
12
12
|
this.applicationId = applicationId;
|
|
13
13
|
const preset = new ConfigurationPreset_1.ConfigurationPreset();
|
|
14
14
|
this.reportCrash = ConfigurationDefaults_1.DEFAULT_REPORT_CRASH;
|
|
15
|
+
this.errorHandler = preset.isErrorHandlerEnabled();
|
|
16
|
+
this.reportFatalErrorAsCrash = preset.isReportFatalErrorAsCrash();
|
|
15
17
|
this.logLevel = preset.getLogLevel();
|
|
16
18
|
this.lifecycleUpdate = preset.getLifecycleUpdate();
|
|
17
19
|
this.userOptIn = ConfigurationDefaults_1.DEFAULT_USER_OPT_IN;
|
|
@@ -23,6 +25,14 @@ class ConfigurationBuilder {
|
|
|
23
25
|
this.reportCrash = reportCrash;
|
|
24
26
|
return this;
|
|
25
27
|
}
|
|
28
|
+
withErrorHandler(errorHandler) {
|
|
29
|
+
this.errorHandler = errorHandler;
|
|
30
|
+
return this;
|
|
31
|
+
}
|
|
32
|
+
withReportFatalErrorAsCrash(reportFatalErrorAsCrash) {
|
|
33
|
+
this.reportFatalErrorAsCrash = reportFatalErrorAsCrash;
|
|
34
|
+
return this;
|
|
35
|
+
}
|
|
26
36
|
withLogLevel(logLevel) {
|
|
27
37
|
this.logLevel = logLevel;
|
|
28
38
|
return this;
|
|
@@ -50,7 +60,7 @@ class ConfigurationBuilder {
|
|
|
50
60
|
if (!this.autoStartup && this.applicationId.length === 0) {
|
|
51
61
|
throw new Error('applicationId configuration property is empty. This configuration is not possible! Please use a proper application id.');
|
|
52
62
|
}
|
|
53
|
-
return new Configuration_1.Configuration(this.beaconUrl, this.applicationId, this.reportCrash, this.logLevel, this.lifecycleUpdate, this.userOptIn, this.actionNamePrivacy, this.bundleName);
|
|
63
|
+
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);
|
|
54
64
|
}
|
|
55
65
|
}
|
|
56
66
|
exports.ConfigurationBuilder = ConfigurationBuilder;
|
|
@@ -1,9 +1,11 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.DEFAULT_ACTION_NAME_PRIVACY = exports.DEFAULT_USER_OPT_IN = exports.
|
|
3
|
+
exports.DEFAULT_ACTION_NAME_PRIVACY = exports.DEFAULT_USER_OPT_IN = exports.DEFAULT_LOGLEVEL = exports.DEFAULT_FATAL_AS_CRASH = exports.DEFAULT_ERROR_HANDLER = exports.DEFAULT_REPORT_CRASH = exports.DEFAULT_LIFECYCLE_UPDATE = void 0;
|
|
4
4
|
const LogLevel_1 = require("../model/LogLevel");
|
|
5
5
|
exports.DEFAULT_LIFECYCLE_UPDATE = false;
|
|
6
|
-
exports.DEFAULT_LOGLEVEL = LogLevel_1.LogLevel.Info;
|
|
7
6
|
exports.DEFAULT_REPORT_CRASH = true;
|
|
7
|
+
exports.DEFAULT_ERROR_HANDLER = true;
|
|
8
|
+
exports.DEFAULT_FATAL_AS_CRASH = true;
|
|
9
|
+
exports.DEFAULT_LOGLEVEL = LogLevel_1.LogLevel.Info;
|
|
8
10
|
exports.DEFAULT_USER_OPT_IN = false;
|
|
9
11
|
exports.DEFAULT_ACTION_NAME_PRIVACY = false;
|
|
@@ -8,6 +8,8 @@ exports.ConfigurationHandler = {
|
|
|
8
8
|
_configuration = configuration;
|
|
9
9
|
},
|
|
10
10
|
isConfigurationAvailable: () => _configuration !== undefined,
|
|
11
|
+
isErrorHandlerEnabled: () => _configuration.errorHandler,
|
|
12
|
+
isReportFatalErrorAsCrash: () => _configuration.reportFatalErrorAsCrash,
|
|
11
13
|
isDebugEnabled: () => _configuration.logLevel === LogLevel_1.LogLevel.Debug,
|
|
12
14
|
isLifecycleUpdateEnabled: () => _configuration.lifecycleUpdate,
|
|
13
15
|
isActionNamePrivacyEnabled: () => _configuration.actionNamePrivacy,
|
|
@@ -12,6 +12,12 @@ class ConfigurationPreset {
|
|
|
12
12
|
getLogLevel() {
|
|
13
13
|
return ConfigurationDefaults_1.DEFAULT_LOGLEVEL;
|
|
14
14
|
}
|
|
15
|
+
isErrorHandlerEnabled() {
|
|
16
|
+
return ConfigurationDefaults_1.DEFAULT_ERROR_HANDLER;
|
|
17
|
+
}
|
|
18
|
+
isReportFatalErrorAsCrash() {
|
|
19
|
+
return ConfigurationDefaults_1.DEFAULT_FATAL_AS_CRASH;
|
|
20
|
+
}
|
|
15
21
|
getActionNamePrivacy() {
|
|
16
22
|
return ConfigurationDefaults_1.DEFAULT_ACTION_NAME_PRIVACY;
|
|
17
23
|
}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.ManualStartupConfiguration = void 0;
|
|
4
|
+
const LogLevel_1 = require("../model/LogLevel");
|
|
4
5
|
const ConfigurationDefaults_1 = require("./ConfigurationDefaults");
|
|
5
6
|
const ConfigurationPreset_1 = require("./ConfigurationPreset");
|
|
6
7
|
class ManualStartupConfiguration {
|
|
@@ -14,6 +15,8 @@ class ManualStartupConfiguration {
|
|
|
14
15
|
this.beaconUrl = beaconUrl;
|
|
15
16
|
const preset = new ConfigurationPreset_1.ConfigurationPreset();
|
|
16
17
|
this.logLevel = preset.getLogLevel();
|
|
18
|
+
this.errorHandler = preset.isErrorHandlerEnabled();
|
|
19
|
+
this.reportFatalErrorAsCrash = preset.isReportFatalErrorAsCrash();
|
|
17
20
|
this.lifecycleUpdate = preset.getLifecycleUpdate();
|
|
18
21
|
this.actionNamePrivacy = preset.getActionNamePrivacy();
|
|
19
22
|
this.bundleName = preset.getBundleName();
|
|
@@ -36,5 +39,15 @@ class ManualStartupConfiguration {
|
|
|
36
39
|
this.bundleName = bundleName;
|
|
37
40
|
}
|
|
38
41
|
}
|
|
42
|
+
toString() {
|
|
43
|
+
let configurationString = `{Startup: Manual Start, applicationId: ${this.applicationId}, beaconUrl: ${this.beaconUrl},`
|
|
44
|
+
+ ` reportCrash: ${this.reportCrash}, errorHandler: ${this.errorHandler}, reportFatalErrorAsCrash: ${this.reportFatalErrorAsCrash},`
|
|
45
|
+
+ ` lifecycleUpdate: ${this.lifecycleUpdate}, userOptIn: ${this.userOptIn}, actionNamePrivacy: ${this.actionNamePrivacy}, logLevel: ${(0, LogLevel_1.LogLevelToString)(this.logLevel)}`;
|
|
46
|
+
if (this.bundleName !== undefined) {
|
|
47
|
+
configurationString += `, bundleName: ${this.bundleName}`;
|
|
48
|
+
}
|
|
49
|
+
configurationString += '}';
|
|
50
|
+
return configurationString;
|
|
51
|
+
}
|
|
39
52
|
}
|
|
40
53
|
exports.ManualStartupConfiguration = ManualStartupConfiguration;
|
|
@@ -1,8 +1,17 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.LogLevel = void 0;
|
|
3
|
+
exports.LogLevelToString = exports.LogLevel = void 0;
|
|
4
4
|
var LogLevel;
|
|
5
5
|
(function (LogLevel) {
|
|
6
6
|
LogLevel[LogLevel["Debug"] = 0] = "Debug";
|
|
7
7
|
LogLevel[LogLevel["Info"] = 1] = "Info";
|
|
8
8
|
})(LogLevel = exports.LogLevel || (exports.LogLevel = {}));
|
|
9
|
+
const LogLevelToString = (level) => {
|
|
10
|
+
if (level === LogLevel.Debug) {
|
|
11
|
+
return 'Debug';
|
|
12
|
+
}
|
|
13
|
+
else {
|
|
14
|
+
return 'Info';
|
|
15
|
+
}
|
|
16
|
+
};
|
|
17
|
+
exports.LogLevelToString = LogLevelToString;
|
|
@@ -1,63 +1,20 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var _a, _b, _c, _d, _e, _f;
|
|
3
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
3
|
exports.Pressable = exports.Text = exports.TouchableWithoutFeedback = exports.TouchableNativeFeedback = exports.TouchableHighlight = exports.TouchableOpacity = exports.Button = void 0;
|
|
5
4
|
const ReactNative = require("react-native");
|
|
5
|
+
const React = require("react");
|
|
6
6
|
const Types_1 = require("../instrumentor/model/Types");
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
}
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
},
|
|
22
|
-
_b._dtInfo = { type: Types_1.Types.TouchableOpacity },
|
|
23
|
-
_b);
|
|
24
|
-
}
|
|
25
|
-
if (typeof ReactNative.TouchableHighlight === 'object') {
|
|
26
|
-
exports.TouchableHighlight = Object.assign({ _dtInfo: { type: Types_1.Types.TouchableHighlight } }, ReactNative.TouchableHighlight);
|
|
27
|
-
}
|
|
28
|
-
else {
|
|
29
|
-
exports.TouchableHighlight = (_c = class TouchableHighlight extends (ReactNative.TouchableHighlight) {
|
|
30
|
-
},
|
|
31
|
-
_c._dtInfo = { type: Types_1.Types.TouchableHighlight },
|
|
32
|
-
_c);
|
|
33
|
-
}
|
|
34
|
-
if (typeof ReactNative.TouchableNativeFeedback === 'object') {
|
|
35
|
-
exports.TouchableNativeFeedback = Object.assign({ _dtInfo: { type: Types_1.Types.TouchableNativeFeedback } }, ReactNative.TouchableNativeFeedback);
|
|
36
|
-
}
|
|
37
|
-
else {
|
|
38
|
-
exports.TouchableNativeFeedback = (_d = class TouchableNativeFeedback extends (ReactNative.TouchableNativeFeedback) {
|
|
39
|
-
},
|
|
40
|
-
_d._dtInfo = { type: Types_1.Types.TouchableNativeFeedback },
|
|
41
|
-
_d);
|
|
42
|
-
}
|
|
43
|
-
if (typeof ReactNative.TouchableWithoutFeedback === 'object') {
|
|
44
|
-
exports.TouchableWithoutFeedback = Object.assign({ _dtInfo: { type: Types_1.Types.TouchableWithoutFeedback } }, ReactNative.TouchableWithoutFeedback);
|
|
45
|
-
}
|
|
46
|
-
else {
|
|
47
|
-
exports.TouchableWithoutFeedback = (_e = class TouchableWithoutFeedback extends (ReactNative.TouchableWithoutFeedback) {
|
|
48
|
-
},
|
|
49
|
-
_e._dtInfo = { type: Types_1.Types.TouchableWithoutFeedback },
|
|
50
|
-
_e);
|
|
51
|
-
}
|
|
52
|
-
if (typeof ReactNative.Text === 'object') {
|
|
53
|
-
exports.Text = Object.assign({ _dtInfo: { type: Types_1.Types.Text } }, ReactNative.Text);
|
|
54
|
-
}
|
|
55
|
-
else {
|
|
56
|
-
exports.Text = (_f = class Text extends ReactNative.Text {
|
|
57
|
-
},
|
|
58
|
-
_f._dtInfo = { type: Types_1.Types.Text },
|
|
59
|
-
_f);
|
|
60
|
-
}
|
|
61
|
-
if (typeof ReactNative.Pressable === 'object') {
|
|
62
|
-
exports.Pressable = Object.assign({ _dtInfo: { type: Types_1.Types.Pressable } }, ReactNative.Pressable);
|
|
63
|
-
}
|
|
7
|
+
exports.Button = React.forwardRef((props, ref) => React.createElement(ReactNative.Button, Object.assign({}, props, { ref: ref })));
|
|
8
|
+
exports.Button._dtInfo = { type: Types_1.Types.Button };
|
|
9
|
+
exports.TouchableOpacity = React.forwardRef((props, ref) => React.createElement(ReactNative.TouchableOpacity, Object.assign({}, props, { ref: ref })));
|
|
10
|
+
exports.TouchableOpacity._dtInfo = { type: Types_1.Types.TouchableOpacity };
|
|
11
|
+
exports.TouchableHighlight = React.forwardRef((props, ref) => React.createElement(ReactNative.TouchableHighlight, Object.assign({}, props, { ref: ref })));
|
|
12
|
+
exports.TouchableHighlight._dtInfo = { type: Types_1.Types.TouchableHighlight };
|
|
13
|
+
exports.TouchableNativeFeedback = React.forwardRef((props, ref) => React.createElement(ReactNative.TouchableNativeFeedback, Object.assign({}, props, { ref: ref })));
|
|
14
|
+
exports.TouchableNativeFeedback._dtInfo = { type: Types_1.Types.TouchableNativeFeedback };
|
|
15
|
+
exports.TouchableWithoutFeedback = React.forwardRef((props, ref) => React.createElement(ReactNative.TouchableWithoutFeedback, Object.assign({}, props, { ref: ref })));
|
|
16
|
+
exports.TouchableWithoutFeedback._dtInfo = { type: Types_1.Types.TouchableWithoutFeedback };
|
|
17
|
+
exports.Text = React.forwardRef((props, ref) => React.createElement(ReactNative.Text, Object.assign({}, props, { ref: ref })));
|
|
18
|
+
exports.Text._dtInfo = { type: Types_1.Types.Text };
|
|
19
|
+
exports.Pressable = React.forwardRef((props, ref) => React.createElement(ReactNative.Pressable, Object.assign({}, props, { ref: ref })));
|
|
20
|
+
exports.Pressable._dtInfo = { type: Types_1.Types.Pressable };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dynatrace/react-native-plugin",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.289.1",
|
|
4
4
|
"description": "This plugin gives you the ability to use the Dynatrace Mobile agent in your react native application.",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"types": "typings/react-native-dynatrace.d.ts",
|
|
@@ -71,7 +71,7 @@
|
|
|
71
71
|
"author": "Dynatrace",
|
|
72
72
|
"license": "SEE LICENSE IN LICENSE.md",
|
|
73
73
|
"dependencies": {
|
|
74
|
-
"@babel/runtime": "^7.24.
|
|
74
|
+
"@babel/runtime": "^7.24.4",
|
|
75
75
|
"jscodeshift": "^0.15.2",
|
|
76
76
|
"plist": "^3.1.0",
|
|
77
77
|
"proxy-polyfill": "^0.3.2",
|
|
@@ -146,6 +146,7 @@
|
|
|
146
146
|
"lib/community/gesture-handler/*.js",
|
|
147
147
|
"lib/react-navigation/*.js",
|
|
148
148
|
"lib/react-native/*.js",
|
|
149
|
+
"lib/react-native/Touchables.jsx",
|
|
149
150
|
"lib/react/*.js",
|
|
150
151
|
"lib/metro/*.js",
|
|
151
152
|
"lib/util/*.js",
|
|
@@ -111,7 +111,7 @@ Pod::Spec.new do |s|
|
|
|
111
111
|
#
|
|
112
112
|
|
|
113
113
|
s.dependency "React"
|
|
114
|
-
s.dependency 'Dynatrace', '~> 8.
|
|
114
|
+
s.dependency 'Dynatrace', '~> 8.289.1.1015'
|
|
115
115
|
|
|
116
116
|
# Allows for better compatibility for older and newer versions
|
|
117
117
|
if defined?(install_modules_dependencies)
|
|
@@ -136,5 +136,3 @@ Pod::Spec.new do |s|
|
|
|
136
136
|
end
|
|
137
137
|
|
|
138
138
|
end
|
|
139
|
-
|
|
140
|
-
|
package/scripts/Config.js
CHANGED
package/scripts/Ios.js
CHANGED
|
@@ -128,9 +128,9 @@ const checkForExcludedControls = (config) => config != null && config.indexOf('D
|
|
|
128
128
|
const updatedExcludedStr = (config) => {
|
|
129
129
|
if (checkForExcludedControls(config)) {
|
|
130
130
|
const controlsArr = Object.keys(PlistConstants_1.CONTROLS_PROP_OPTIONS);
|
|
131
|
-
let updatedStr = `${PlistConstants_1.START_CONTROLS_PROP}${PlistConstants_1.CONTROLS_PROP_OPTIONS.PickerView}`;
|
|
131
|
+
let updatedStr = `${PlistConstants_1.START_CONTROLS_PROP}${PlistConstants_1.CONTROLS_PROP_OPTIONS.PickerView}${PlistConstants_1.CONTROLS_PROP_OPTIONS.Switch}`;
|
|
132
132
|
for (let index = 0; index < controlsArr.length; index++) {
|
|
133
|
-
if (controlsArr[index] !== 'PickerView' && config.indexOf(PlistConstants_1.CONTROLS_PROP_OPTIONS[controlsArr[index]].trim()) >= 0) {
|
|
133
|
+
if (controlsArr[index] !== 'PickerView' && controlsArr[index] !== 'Switch' && config.indexOf(PlistConstants_1.CONTROLS_PROP_OPTIONS[controlsArr[index]].trim()) >= 0) {
|
|
134
134
|
updatedStr = updatedStr + PlistConstants_1.CONTROLS_PROP_OPTIONS[controlsArr[index]];
|
|
135
135
|
}
|
|
136
136
|
}
|
|
@@ -5,7 +5,7 @@ exports.START_PLIST = '<plist><dict>';
|
|
|
5
5
|
exports.END_PLIST = '</dict></plist>';
|
|
6
6
|
exports.AUTO_START_PROP = '<key>DTXAutoStart</key>';
|
|
7
7
|
exports.FLAVOR_PROP = '<key>DTXFlavor</key>\n<string>react_native</string>';
|
|
8
|
-
exports.DEFAULT_CONTROLS_PROP = '<key>DTXExcludedControls</key>\n<array>\n\t<string>PickerView</string>\n</array>';
|
|
8
|
+
exports.DEFAULT_CONTROLS_PROP = '<key>DTXExcludedControls</key>\n<array>\n\t<string>PickerView</string>\n\t<string>Switch</string>\n</array>';
|
|
9
9
|
exports.START_CONTROLS_PROP = '<key>DTXExcludedControls</key>\n<array>';
|
|
10
10
|
exports.END_CONTROLS_PROP = '\n</array>';
|
|
11
11
|
exports.CONTROLS_PROP_OPTIONS = {
|
|
@@ -33,9 +33,9 @@ export interface Spec extends TurboModule {
|
|
|
33
33
|
reportError(errorName: string, errorValue: string, reason: string, stacktrace: string, platform?: string): void;
|
|
34
34
|
|
|
35
35
|
// eslint-disable-next-line max-len
|
|
36
|
-
reportCrash(errorName: string, reason: string, stacktrace: string, isRealError: boolean,
|
|
36
|
+
reportCrash(errorName: string, reason: string, stacktrace: string, isRealError: boolean, platform?: string): void;
|
|
37
37
|
|
|
38
|
-
storeCrash(errorName: string, reason: string, stacktrace: string
|
|
38
|
+
storeCrash(errorName: string, reason: string, stacktrace: string): void;
|
|
39
39
|
|
|
40
40
|
reportErrorInAction(key: string, errorName: string, errorCode: number, platform?: string): void;
|
|
41
41
|
|
|
@@ -574,6 +574,24 @@ export declare interface IConfiguration {
|
|
|
574
574
|
*/
|
|
575
575
|
readonly reportCrash: boolean;
|
|
576
576
|
|
|
577
|
+
/**
|
|
578
|
+
* Enables the react native error/crash handler. By default this value is true if nothing is passed.
|
|
579
|
+
*
|
|
580
|
+
* Be aware this value is only important for manual startup. In case of auto startup this needs to be handled via
|
|
581
|
+
* react configuration.
|
|
582
|
+
*/
|
|
583
|
+
readonly errorHandler: boolean;
|
|
584
|
+
|
|
585
|
+
/**
|
|
586
|
+
* Reports a fatal error as a crash or as an error.
|
|
587
|
+
* The default value of true results in an unhandled fatal error being reported as a crash which will also end the current session.
|
|
588
|
+
* If the value is false, the unhandled fatal error will be reported as an error and the current session will continue.
|
|
589
|
+
*
|
|
590
|
+
* Be aware this value is only important for manual startup. In case of auto startup this needs to be handled via
|
|
591
|
+
* react configuration.
|
|
592
|
+
*/
|
|
593
|
+
readonly reportFatalErrorAsCrash: boolean;
|
|
594
|
+
|
|
577
595
|
/**
|
|
578
596
|
* Log level of our plugin during application runtime. By default this values is LogLevel.Info, if nothing is passed.
|
|
579
597
|
*/
|
|
@@ -656,6 +674,24 @@ export declare class ManualStartupConfiguration implements IConfiguration {
|
|
|
656
674
|
*/
|
|
657
675
|
readonly reportCrash: boolean;
|
|
658
676
|
|
|
677
|
+
/**
|
|
678
|
+
* Enables the react native error/crash handler. By default this value is true if nothing is passed.
|
|
679
|
+
*
|
|
680
|
+
* Be aware this value is only important for manual startup. In case of auto startup this needs to be handled via
|
|
681
|
+
* react configuration.
|
|
682
|
+
*/
|
|
683
|
+
readonly errorHandler: boolean;
|
|
684
|
+
|
|
685
|
+
/**
|
|
686
|
+
* Reports a fatal error as a crash or as an error.
|
|
687
|
+
* The default value of true results in an unhandled fatal error being reported as a crash which will also end the current session.
|
|
688
|
+
* If the value is false, the unhandled fatal error will be reported as an error and the current session will continue.
|
|
689
|
+
*
|
|
690
|
+
* Be aware this value is only important for manual startup. In case of auto startup this needs to be handled via
|
|
691
|
+
* react configuration.
|
|
692
|
+
*/
|
|
693
|
+
readonly reportFatalErrorAsCrash: boolean;
|
|
694
|
+
|
|
659
695
|
/**
|
|
660
696
|
* Log level of our plugin during application runtime. By default this values is LogLevel.Info, if nothing is passed.
|
|
661
697
|
*/
|
|
@@ -711,6 +747,20 @@ export declare class ConfigurationBuilder {
|
|
|
711
747
|
*/
|
|
712
748
|
public withCrashReporting(reportCrash: boolean): ConfigurationBuilder;
|
|
713
749
|
|
|
750
|
+
/**
|
|
751
|
+
* Builder function to handle error handler property
|
|
752
|
+
*
|
|
753
|
+
* @param {boolean} errorHandler Allows you to enable or disable the Dynatrace React Native error handler.
|
|
754
|
+
*/
|
|
755
|
+
public withErrorHandler(errorHandler: boolean): ConfigurationBuilder;
|
|
756
|
+
|
|
757
|
+
/**
|
|
758
|
+
* Builder function to handle preventing crash property
|
|
759
|
+
*
|
|
760
|
+
* @param {boolean} reportFatalErrorAsCrash If you want to report a fatal error as an error and not as a crash, set this to false.
|
|
761
|
+
*/
|
|
762
|
+
public withReportFatalErrorAsCrash(reportFatalErrorAsCrash: boolean): ConfigurationBuilder;
|
|
763
|
+
|
|
714
764
|
/**
|
|
715
765
|
* Builder function to handle loglevel property
|
|
716
766
|
*
|