/dynatrace:dt-setup-react-nativefrom dynatrace
Integrates Dynatrace React Native Plugin and Session Replay into React Native or Expo projects — handles dependency setup, config, Babel registration, instrumentation, navigation tracking, and privacy options.
Ships in dynatrace. Installing the plugin adds it to Claude Code.
What the skill costs in Claude's context, stage by stage
Name and description: Claude knows it exists.
SKILL.md joins the conversation and stays.
Read when SKILL.md points to them.
PATHpackage.json at the project rootandroid/ and ios/ platform folders present (Expo managed workflow requires npx expo prebuild first)applicationId and beaconUrl, or to download dynatrace.config.js)Work through the steps below in order, interacting with the user at each decision point. Read actual project files before suggesting changes — do not assume the current state.
dynatrace.config.jsBefore asking the user anything, check whether dynatrace.config.js exists at the project root.
applicationId and beaconUrl, and confirm they match the target environment (with manual startup, autoStart: false, they are intentionally absent — see Step 7a). If correct, run the userOptIn check below and skip to Step 3 (config is already present — Step 2 is not needed). A config downloaded from the console ships with react.debug: true and DTXLogLevel ALL — mention that debug logging should be removed before a production build.userOptIn check:
Inspect the file for userOptIn (Android block) and DTXUserOptIn (iOS block).
true, flag Step 10. If false, skip Step 10 unless the user later chooses Session Replay in Step 9, which requires switching opt-in on.true.dynatrace.config.js (only if Step 1 found no file)Ask the user which approach they prefer:
Option A — Download from console (recommended):
dynatrace.config.js and place it at the project root (same level as package.json)Once the file is in place, apply the userOptIn check from Step 1 and flag Step 10 if needed.
Option B — Provide credentials manually:
Read references/config-js.md for the full template and conditional blocks. Collect all required values from the user before creating any files, then apply the userOptIn check and flag Step 10 if needed.
Read package.json first.
npm install @dynatrace/react-native-plugin
dependencies: No change needed.devDependencies: Remove it and run npm install @dynatrace/react-native-plugin. The plugin is required at runtime including in release builds.Note: npm install alphabetically sorts the dependencies object in package.json. Existing entries may appear reordered after this step — this is expected npm behavior, not an error.
If on macOS and targeting iOS, run:
cd ios && pod install && cd ..
Confirm success before continuing. CocoaPods must be installed (gem install cocoapods if missing). If the Session Replay package is added later (Step 9), run pod install again.
babel.config.jsRead babel.config.js. Append BabelPluginDynatrace to the plugins array, just before react-native-reanimated/plugin if that plugin is present (reanimated must always be last):
module.exports = {
presets: ['module:@react-native/babel-preset'],
plugins: [
// ... existing plugins ...
'@dynatrace/react-native-plugin/instrumentation/BabelPluginDynatrace',
// react-native-reanimated/plugin goes here if present — must stay last
],
};
'@dynatrace/react-native-plugin/instrumentation/BabelPluginDynatrace': skip this step.metro.config.js with babelTransformerPath: '@dynatrace/react-native-plugin/lib/dynatrace-transformer': that is the legacy Metro transformer approach — auto-instrumentation is already handled; skip this step and Step 6.Common mistakes to flag and correct:
presets instead of pluginsBabelPluginDynatrace after react-native-reanimated/plugin — reanimated must always be the absolute last pluginbabel.config.jsRead babel.config.js and determine which preset the project uses — this controls how the JSX runtime is registered.
babel-preset-expo)If babel-preset-expo appears in presets, set jsxImportSource on the preset itself. Do not add a separate @babel/plugin-transform-react-jsx plugin — Expo's preset already owns the JSX transform, and stacking a second JSX plugin over it breaks the instrumentation.
module.exports = function (api) {
api.cache(true);
return {
presets: [
['babel-preset-expo', {
jsxRuntime: 'automatic',
jsxImportSource: '@dynatrace/react-native-plugin',
}],
],
plugins: [
'@dynatrace/react-native-plugin/instrumentation/BabelPluginDynatrace',
'react-native-reanimated/plugin', // stays last
],
};
};
babel-preset-expo already has jsxImportSource: '@dynatrace/react-native-plugin': no change needed.jsxImportSource is already set: replace it with '@dynatrace/react-native-plugin'.@babel/plugin-transform-react-jsx plugin entry — it must not coexist with the preset-level jsxImportSource on babel-preset-expo.@react-native/babel-preset or metro-react-native-babel-preset)For metro 0.72.0+ (React Native 0.71+), add @babel/plugin-transform-react-jsx with the Dynatrace importSource before BabelPluginDynatrace in the plugins array:
module.exports = {
presets: [
['module:@react-native/babel-preset', { unstable_transformProfile: 'hermes-stable' }],
],
plugins: [
['@babel/plugin-transform-react-jsx', {
runtime: 'automatic',
importSource: '@dynatrace/react-native-plugin',
}],
'@dynatrace/react-native-plugin/instrumentation/BabelPluginDynatrace',
'react-native-reanimated/plugin', // stays last
],
};
The required plugin order is:
@babel/plugin-transform-react-jsx (JSX runtime — first)BabelPluginDynatrace (auto-instrumentation — before reanimated)react-native-reanimated/plugin (must be absolutely last)@babel/plugin-transform-react-jsx with importSource: '@dynatrace/react-native-plugin': no change needed.importSource is set: replace it with '@dynatrace/react-native-plugin'.After any Babel change, reset Metro cache on next build:
npx react-native start --reset-cache
npx instrumentDynatracenpx instrumentDynatrace
This reads dynatrace.config.js and automatically configures Android build.gradle and iOS Info.plist. Must be re-run whenever dynatrace.config.js changes.
Common mistakes to flag and correct:
dynatrace.config.jsreact-native instrument-dynatrace — same effect but deprecated for RN 0.70+build.gradle or Info.plist — not needed, the script handles itIf android/ and ios/ folders exist but automatic plist discovery fails, pass explicit paths:
npx instrumentDynatrace plist=ios/YourApp/Info.plist
Expo only: If android/ and ios/ folders do not yet exist, run npx expo prebuild first, then re-run npx instrumentDynatrace.
autoStart: false)Skip this step if autoStart is true or absent in dynatrace.config.js — the SDK starts automatically.
Check dynatrace.config.js for autoStart: false in the react block. If present, the SDK will not start on its own and no data will be collected until Dynatrace.start() is called explicitly.
Native auto start must be disabled in the same file, and the native blocks must not carry applicationId / beaconUrl (on iOS, npx instrumentDynatrace fails if DTXApplicationID or DTXBeaconURL are present while DTXAutoStart is false):
autoStart { ... } block with autoStart.enabled false and keep every other setting the app needs (userOptIn, sessionReplay.enabled true, agentBehavior.*) — the Gradle plugin still applies them at build time.DTXAutoStart = false is the only property for a manual startup; other iOS keys are not guaranteed to be used. Pass anything else (for example opt-in mode) at runtime through ConfigurationBuilder.module.exports = {
react: {
autoStart: false,
// ...
},
android: {
config: `
dynatrace {
configurations {
defaultConfig {
autoStart.enabled false
agentBehavior.startupLoadBalancing true
agentBehavior.startupWithGrailEnabled true
// keep userOptIn / sessionReplay.enabled here if they were set
}
}
}
`,
},
ios: {
config: `
<key>DTXAutoStart</key>
<false/>
`,
},
};
Re-run npx instrumentDynatrace after changing these blocks.
Add the startup call at the top level of the app entry file (for example App.tsx or index.js). Any logic that depends on the SDK being ready goes after the await:
import { Dynatrace, ConfigurationBuilder } from '@dynatrace/react-native-plugin';
await Dynatrace.start(
new ConfigurationBuilder('<BEACON_URL>', '<APPLICATION_ID>').buildConfiguration()
);
// SDK is initialized — place any SDK-dependent logic here
Replace <BEACON_URL> and <APPLICATION_ID> with the values for the target app (from the console's dynatrace.config.js download or the user's credentials).
Important: With manual startup, beaconUrl and applicationId come only from the ConfigurationBuilder call. If native auto start is not disabled as shown above, the runtime values are discarded and the config-file values are used. Other react options in dynatrace.config.js (for example lifecycle) remain the baseline for manual startup.
Opt-in mode with manual startup: ConfigurationBuilder has its own userOptIn setting that is passed to the native agent on start and defaults to false. If User Opt-In mode is on (Step 1, or switched on for Session Replay in Step 9), add .withUserOptIn(true) before .buildConfiguration() so the runtime value matches the config, and still make the applyUserPrivacyOptions(...) call in Step 10.
Tradeoff: Manual startup causes the SDK to miss the native application start event and any interactions that happen before start() is called. Use autoStart: true (the default) unless runtime credential injection is a hard requirement.
Check dynatrace.config.js for the react.navigation block and check package.json for @react-navigation/native.
If @react-navigation/native is present and navigation.enabled is not set to true, add it:
module.exports = {
react: {
navigation: {
enabled: true, // requires @react-navigation/native v5–v7
},
// ...
},
// ...
};
Then re-run npx instrumentDynatrace.
What this does: When enabled, the plugin hooks into React Navigation's NavigationContainer and detects route changes automatically. Each navigation event is reported to Dynatrace as a view change, with the current route represented as a URL-style path (e.g., /Home, /Home/Details). This populates the screen timeline in Dynatrace user sessions and associates all events with the currently active screen. This setting is enabled by default in the plugin's own config template.
If @react-navigation/native is not present: inform the user that automatic view tracking requires @react-navigation/native. They can use Dynatrace.startView("ScreenName") for manual view tracking instead.
Ask the user: "Do you want to enable Session Replay?" If they already said so, or @dynatrace/react-native-session-replay is already in package.json, treat it as yes. On no, continue to Step 10.
Read references/session-replay.md for the Grail flags, plugin version check, package install, Android config flag, SessionReplay.configure(...) call, masking, and console capability. Remember the answer — Step 10 needs it.
Session Replay requires userOptIn: true: the Android Gradle plugin fails the build if sessionReplay.enabled true is set without it. If the user chose Session Replay while userOptIn is false, references/session-replay.md (section 4) covers switching it on with the user's consent — Step 10 then becomes required.
userOptIn: true)Skip this step if userOptIn was not true after Steps 1, 2 and 9.
Read references/user-opt-in.md for the full guidance on DataCollectionLevel, crashReportingOptedIn, Session Replay consent, and placement options. Ask the user the questions defined there, then apply the call to the relevant file.
Confirm to the user what is active:
Enabled by default (when userOptIn is false or absent):
When
userOptIn: true, all data collection — including crash reporting — is gated on theapplyUserPrivacyOptions(...)call.
Configured during this setup:
SessionReplay.configure(...) added, Android sessionReplay.enabled true set, console capability confirmed, masking level chosen, screenRecordOptedIn set if opt-in / not enabled]Read references/verification.md and show the user the verification checklist. If no data appears after 5 minutes, work through the troubleshooting steps in that file.
references/config-js.md — Full dynatrace.config.js template with userOptIn, Session Replay and manual-startup conditional blocksreferences/user-opt-in.md — applyUserPrivacyOptions guidance, DataCollectionLevel options, Session Replay consent, placement optionsreferences/session-replay.md — Session Replay setup: Grail flags, plugin version, package, Android flag, configure, masking, console capabilityreferences/verification.md — Post-setup verification checklist and troubleshootingWhat SKILL.md sets; muted values are Claude Code's defaults
Three short reads, in order
38 skills in this plugin
/dt-alertingEnd-to-end Dynatrace alerting lifecycle — anomaly detector setup and model selection (static threshold, adaptive baseline, seasonal baseline), alert event storage in Grail, problem grouping and denoising by root cause analysis, and workflow-based notification routing (email, Slack, ServiceNow, webhook). Use when configuring alerting, choosing between detector types, querying alert event history, understanding why alerts merged into a problem, or setting up problem-triggered notifications./dt-app-dashboardsWork with Dynatrace dashboards - create, modify, query, and analyze dashboard JSON including tiles, layouts, DQL queries, variables, and visualizations./dt-app-notebooksWork with Dynatrace notebooks - create, modify, query, and analyze notebook JSON including sections, DQL queries, and visualizations./dt-dql-essentialsCore DQL syntax, pitfalls, query patterns, and query optimization. Load to write, build, fix, or OPTIMIZE a DQL query — prevents syntax errors and makes queries faster, more efficient, and cheaper (less data scanned = lower query consumption/cost per run). Covers fetch commands, data models, field namespaces, time alignment, entity/smartscape patterns, metric discovery, and performance/cost optimization (filter early, bucket filters, short time ranges, field selection, sampling, cardinality). Trigger: "write/build/fix a DQL query", "DQL syntax", "query logs/spans/metrics", "create a timeseries", "optimize my DQL", "make my query faster/cheaper", "reduce DQL cost/consumption/scanned data", "keep DQL cost under control". Do NOT use to explain an existing query or answer product questions. For MONITORING a tenant's ACTUAL query consumption/billing (how much queries cost, who scanned most, cost trends) use dt-platform-costs — this tunes the query text, not billing data./dt-js-runtimeDynatrace server-side JS runtime — function contract, runtime limits, Web APIs, Node.js modules, fetch with credential vault, and the @dynatrace-sdk/* catalog./dt-migrationMigrate Dynatrace classic and Gen2 entity-based DQL to Smartscape equivalents. Covers three scenarios. (1) mass data queries filtered by classic entity conditions — migrate to direct dimension filters first, Smartscape only as fallback; (2) mass data queries using entity subqueries for filtering — same dimension-first strategy; (3) pure entity list queries — migrate fetch dt.entity.* to smartscapeNodes. Also handles entityName, entityAttr, classicEntitySelector, and classic relationship patterns.npx claudepluginhub dynatrace/dynatrace-for-ai --plugin dynatraceOther plugins' skills for the same job