Migrate from sentry-expo
Learn about migrating from sentry-expo to @sentry/react-native
This guide scribes how to migrate from sentry-expo to @sentry/react-native in your Expo application.
First, remove sentry-expo from your dependencies:
npm uninstall sentry-expo
Remove the Sentry Source Maps Upload hook from your Expo Application configuration, expo.hooks.postPublish. The new methods of uploading source maps are described in the new Expo guide, as part of the final step of the migration at the bottom of the page.
Install the @sentry/react-native package:
npx expo install @sentry/react-native
Replace all imports of sentry-expo with @sentry/react-native:
- import * as Sentry from 'sentry-expo';
+ import * as Sentry from '@sentry/react-native';
Replace sentry-expo exports Browser and React with @sentry/react:
- import { Browser, React } from 'sentry-expo';
+ import * as Browser from '@sentry/react';
+ import * as React from '@sentry/react';
Replace sentry-expo export Native with @sentry/react-native:
- import { Native } from 'sentry-expo';
+ import * as Sentry from '@sentry/react-native';
The enableInExpoDevelopment option is no longer supported. If you were using it, remove it and replace it with a __DEV__ check, or leave the SDK enabled in development.
Sentry.init({
- enableInExpoDevelopment: false,
+ enabled: !__DEV__,
});
Expo-specific tags are no longer added by default. If you were using them, you can add them manually:
import Constants from "expo-constants";
import * as Application from "expo-application";
import * as Device from "expo-device";
import * as Updates from "expo-updates";
import * as Sentry from "@sentry/react-native";
Sentry.setExtras({
manifest: Updates.manifest,
deviceYearClass: Device.deviceYearClass,
linkingUri: Constants.linkingUri,
});
Sentry.setTag("expoChannel", Updates.channel);
Sentry.setTag("appVersion", Application.nativeApplicationVersion);
Sentry.setTag("deviceId", Constants.sessionId);
Sentry.setTag("executionEnvironment", Constants.executionEnvironment);
Sentry.setTag("expoGoVersion", Constants.expoVersion);
Sentry.setTag("expoRuntimeVersion", Constants.expoRuntimeVersion);
The sentry-expo package automatically switched to @sentry/react for react-native-web builds. This is no longer the case with @sentry/react-native which supports react-native-web out of the box.
Note that some features might not be supported or work differently in @sentry/react-native on react-native-web compared to direct usage of @sentry/react. Verify in your application that the features you use work as expected.
To continue using @sentry/react for react-native-web builds, see @sentry/react for more details about the web React package.
Next, set up the Expo and Metro plugins for @sentry/react-native.
Our documentation is open source and available on GitHub. Your contributions are welcome, whether fixing a typo (drat!) or suggesting an update ("yeah, this would be better").