Expo config plugin for @dynatrace/react-native-plugin
npm install dynatrace-expo-pluginThis plugin automatically configures the required native changes for the @dynatrace/react-native-plugin package, so you no longer need to manually edit:
- iOS Info.plist
- Android build.gradle
- Android app/build.gradle
- Android dynatrace.gradle (auto-generated)
It ensures Dynatrace instrumentation works correctly in Expo-managed (prebuild) projects.
---
- π§ Automatically inserts Dynatrace native configuration during expo prebuild
- π± Supports both iOS and Android
- βοΈ Generates & updates all required Dynatrace Gradle files
- π No more manual native edits
- π Works with EAS Build
---
``bash`
npm install @dynatrace/react-native-plugin
`bash`
npm install dynatrace-expo-plugin
---
Add the plugin to your app.json or app.config.js/ts.
`ts
export default {
name: "my-app",
slug: "my-app",
plugins: [
[
"dynatrace-expo-plugin",
{
applicationId: "YOUR-APPLICATION-ID",
beaconUrl: "https://example.live.dynatrace.com/mbeacon",
// Optional overrides:
logLevel: "ALL",
userOptIn: false,
startupLoadBalancing: true,
disableWebRequestsInstrumentationV2: true,
excludedControls: ["PickerView", "Switch"]
}
]
]
};
`
---
| Prop | Type | Description |
|-----------------|----------|-------------|
| applicationId | string | Dynatrace application ID from your Dynatrace environment |beaconUrl
| | string | Dynatrace beacon URL (usually ends with /mbeacon) |
| Prop | Type | Default | Description |
|--------------------------------------|-----------|---------|-------------|
| logLevel | string | "ALL" | iOS log level |userOptIn
| | boolean | false | Enables Dynatrace user consent mode |startupLoadBalancing
| | boolean | true | Enables startup load balancing |disableWebRequestsInstrumentationV2
| | boolean | true | Disables advanced web request instrumentation (iOS) |excludedControls
| | string[] | ["PickerView", "Switch"] | UI controls to exclude from instrumentation |
---
Automatically writes the following keys to Info.plist:
- DTXApplicationIDDTXBeaconURL
- DTXLogLevel
- DTXUserOptIn
- DTXStartupLoadBalancing
- DTXFlavor = "react_native"
- DTXDisableWebRequestsInstrumentationV2
- DTXExcludedControls
- array
#### Modifies android/build.gradle:
- Applies Dynatrace plugin.gradleapply from: "./dynatrace.gradle"
- Adds
#### Modifies android/app/build.gradle:
- Adds Dynatrace runtime plugin (plugin-runtime.gradle)
#### Generates android/dynatrace.gradle:
Automatically creates:
`gradle
ext['dynatrace.instrumentationFlavor'] = 'react_native'
apply plugin: 'com.dynatrace.instrumentation'
dynatrace {
configurations {
defaultConfig {
autoStart {
applicationId 'YOUR-ID'
beaconUrl 'YOUR-URL'
}
userOptIn false
agentBehavior.startupLoadBalancing true
}
}
}
`
---
Run:
`bash`
npx expo prebuild --clean
Then verify:
- ios/*/Info.plist contains Dynatrace keysandroid/build.gradle
- is patchedandroid/app/build.gradle
- includes plugin-runtimeandroid/dynatrace.gradle
- is generated
---
- This plugin only runs when using expo prebuild or EAS Build.
- Not needed for bare React Native apps (use Dynatrace setup instructions instead).
- Ensure the Dynatrace SDK is installed:
`bash`
npm install @dynatrace/react-native-plugin
---
βDynatrace configuration not foundβ
β Ensure applicationId and beaconUrl are passed to the plugin.
Android build errors after upgrading Expo SDK
β Re-run:
`bash`
npx expo prebuild --clean
Plugin not applying
β Ensure plugin appears in:
`bash``
expo config --json
---
MIT
---
PRs and issues are welcome!
If you have improvements for Android/iOS instrumentation or want test coverage added, feel free to open a pull request.