Security News
Fluent Assertions Faces Backlash After Abandoning Open Source Licensing
Fluent Assertions is facing backlash after dropping the Apache license for a commercial model, leaving users blindsided and questioning contributor rights.
@dynatrace/react-native-plugin
Advanced tools
This plugin gives you the ability to use the Dynatrace Mobile agent in your react native application.
The Dynatrace React Native plugin helps to auto-instrument your React Native app with Dynatrace OneAgent for Android and iOS and provides a TypeScript bridge to add manual instrumentation. It is compatible with raw, ejected React Native projects. It does not support Expo.
Currently this plugin is available as an early access version. If you want to test it, please sign up for the EAP.
The following features are currently supported:
react-native eject
. This generates the Android and iOS folders that are required by the plugin.react-native install @dynatrace/react-native-plugin
.
react-native link @dynatrace/react-native-plugin
which will automatically add the iOS agent pod to your iOS project.node ./node_modules/@dynatrace/react-native-plugin/scripts/install.js
react-native link
does not work as expected, you can manually add the iOS agent to your projectinsert the following in your Podfile:
pod 'react-native-dynatrace', :path => '../node_modules/@dynatrace/react-native-plugin'
node_modules/@dynatrace/react-native-plugin/ios
DynatraceRNBridge.xcodeproj
into your Libraries grouplibRNDynatrace.a
under the Workspace groupDepending on your react native version you will need to use a different way to register the transformer. If you don't know it, you can use react-native --version
to get it.
In your projects root, either create or extend metro.config.js
so it contains the transformer.babelTransformerPath
property:
module.exports = {
transformer: {
babelTransformerPath: require.resolve('@dynatrace/react-native-plugin/lib/dynatrace-transformer')
}
};
Add this to your rn-cli.config.js
(make one if you don't have one already):
module.exports = {
transformer: {
babelTransformerPath: require.resolve('@dynatrace/react-native-plugin/lib/dynatrace-transformer')
}
}
Add this to your rn-cli.config.js
(make one if you don't have one already):
module.exports = {
getTransformModulePath() {
return require.resolve('@dynatrace/react-native-plugin/lib/dynatrace-transformer');
},
getSourceExts() {
return ['ts', 'tsx'];
}
}
Define a mobile app in Dynatrace and open the Mobile app instrumentation settings. The React Native plugin uses the same configuration format as the Cordova plugin, so you can select "Cordova". Ignore steps 1 and 2 and move directly to step 3 - "Download dynatrace.config".
Place the file into your project root directory next to app.json. If the file is not available the auto instrumentation will not work.
Example of a dynatrace.config
file:
<NATIVEAGENT>
<DTXApplicationID>Application ID</DTXApplicationID>
<DTXAgentEnvironment>Agent Environment</DTXAgentEnvironment>
<DTXClusterURL>Cluster URL</DTXClusterURL>
<platform name="android">
<DTXLogLevel>debug</DTXLogLevel>
</platform>
<platform name="ios">
<DTXLogLevel>ALL</DTXLogLevel>
</platform>
</NATIVEAGENT>
In this example there are 3 different properties configured for the Mobile Agent. All properties which are available in the Mobile Agent can be used in the <NATIVEAGENT>
tag. You can find all the available properties in the documentation of the mobile agent, see the documentation.
The properties DTXAgentEnvironment
, DTXClusterURL
and DTXApplicationID
are defined as global properties (not within platform tag) and will therefore be applied to both platforms (Android and iOS). The property DTXLogLevel
is set for the Android and iOS platform differently as their value is not the same. In general, all properties which are defined in a platform tag are overriding a duplicate global value. If for example DTXApplicationID
is defined as a global property as well as an Android platform property, always the platform property will have a higher priority.
Execute npm run instrumentDynatrace
in the root of your React Native project. This will configure both Android and iOS project with the settings from dynatrace.config
.
This scripts assumes that the usual react native project structure is given. The following arguments can be specified if the project structure is different.
gradle=C:\MyReactAndroidProject\build.gradle
- the location of the root build.gradle file. We will assume that the other gradle file resides in /app/build.gradle
. This will add the whole agent dependencies automatically for you and will update the configuration.plist=C:\MyReactIOSProject\projectName\info.plist
- Tell the script where your info.plist file is. The plist file is used for updating the configuration for the agent.config=C:\SpecialFolderForDynatrace\dynatrace.config
- If you have not got your config file in the root folder of the React Native project but somewhere else.Use react-native run-android
or react-native run-ios
to rebuild and run your app.
import { Dynatrace } from '@dynatrace/react-native-plugin';
let myAction = Dynatrace.enterAction("MyButton tapped");
//Perform the action and whatever else is needed.
myAction.leaveAction();
platform
of type String
. You can use this to only trigger manual instrumentation for a specific OS. The available values are: ios
, android
and all
.
If you provide any platform value, then the manual instrumentation call is passed to both iOS and Android. Otherwise it is passed only to the relevant OS. For example:let myAction = Dynatrace.enterAction("MyButton tapped", Dynatrace.PLATFORM_IOS);
//Perform the action and whatever else is needed.
myAction.leaveAction("ios");
let myAction = Dynatrace.enterAction("MyButton tapped", Dynatrace.PLATFORM_ANDROID);
//Perform the action and whatever else is needed.
myAction.leaveAction("android");
let myAction = Dynatrace.enterAction("MyButton tapped");
//Perform the action and whatever else is needed.
myAction.leaveAction();
Please refer to the TypeScript bindings to see the full API that is available for manual instrumentation. The file can be found in the plugin directory ./node_modules/@dynatrace/react-native-plugin/typings/react-native-dynatrace.d.ts
.
The documentation for OneAgent for Android and iOS is available at the following location:
Basically if you have problems with the plugin please have a look into the logs. They will tell you what went wrong. The logs can be found in the plugins folder of your React Native project (usually node_modules/@dynatrace/react-native-plugin/logs
).
Missing property DTXApplicationID
means that there is no configuration available. Are you sure you called npm run updateConfiguration
at least once?0.171.0
0.168.0
FAQs
This plugin gives you the ability to use the Dynatrace Mobile agent in your react native application.
The npm package @dynatrace/react-native-plugin receives a total of 9,804 weekly downloads. As such, @dynatrace/react-native-plugin popularity was classified as popular.
We found that @dynatrace/react-native-plugin demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 0 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Fluent Assertions is facing backlash after dropping the Apache license for a commercial model, leaving users blindsided and questioning contributor rights.
Research
Security News
Socket researchers uncover the risks of a malicious Python package targeting Discord developers.
Security News
The UK is proposing a bold ban on ransomware payments by public entities to disrupt cybercrime, protect critical services, and lead global cybersecurity efforts.