Skip to content

Commit 8ba1fc6

Browse files
Add sentry-expo to RN Sentry migration guide (#8875)
Co-authored-by: Shana Matthews <[email protected]>
1 parent 3a54448 commit 8ba1fc6

File tree

5 files changed

+125
-1
lines changed

5 files changed

+125
-1
lines changed

src/platforms/react-native/manual-setup/expo.mdx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ To set up the Sentry React Native SDK in your Expo project, follow the steps on
1717

1818
- [Expo SDK 50](https://docs.expo.dev/workflow/upgrading-expo-sdk-walkthrough/) or newer.
1919
- [Expo SDK 49](https://docs.expo.dev/guides/using-sentry/) and older are supported by the `sentry-expo` package.
20+
- [Migrate from `sentry-expo` to `@sentry/react-native`](/platforms/react-native/migration/sentry-expo/).
2021
- [Sign up for an account](https://sentry.io/signup/).
2122

2223
## Install the Sentry SDK

src/platforms/react-native/migration/index.mdx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@ sidebar_order: 8000
44
description: "Learn about migrating from 1.x to 2.x to enable release health tracking and native stack traces by default."
55
---
66

7+
<PageGrid />
8+
79
## From 4.x to 5.x
810

911
The React Native SDK version 5 supports both Legacy (from RN 0.65 and above) and New Architecture (from RN 0.69 and above) as well as the new React Native Gradle Plugin (introduced in RN 0.71).
Lines changed: 119 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,119 @@
1+
---
2+
title: Migrate from sentry-expo
3+
sidebar_order: 3
4+
description: "Learn about migrating from sentry-expo to @sentry/react-native"
5+
---
6+
7+
<Alert level="info" title="Experimental Support">
8+
9+
Expo support is currently experimental and available since version `5.16.0-alpha.4`.
10+
11+
Experimental support means it may have bugs. We recognize the irony.
12+
13+
</Alert>
14+
15+
This guide scribes how to migrate from `sentry-expo` to `@sentry/react-native` in your Expo application.
16+
17+
## Remove `sentry-expo`
18+
19+
First, remove `sentry-expo` from your dependencies:
20+
21+
```bash {tabTitle:npm}
22+
npm uninstall sentry-expo
23+
```
24+
25+
```bash {tabTitle:Yarn}
26+
yarn remove sentry-expo
27+
```
28+
29+
### Install `@sentry/react-native`
30+
31+
Install the `@sentry/react-native` package:
32+
33+
```bash {tabTitle:Expo}
34+
npx expo install @sentry/react-native
35+
```
36+
37+
```bash {tabTitle:npm}
38+
npm install --save @sentry/react-native
39+
```
40+
41+
```bash {tabTitle:Yarn}
42+
yarn add @sentry/react-native
43+
```
44+
45+
### Fix Imports
46+
47+
Replace all imports of `sentry-expo` with `@sentry/react-native`:
48+
49+
```diff {tabTitle:JavaScript}
50+
- import * as Sentry from 'sentry-expo';
51+
+ import * as Sentry from '@sentry/react-native';
52+
```
53+
54+
Replace `sentry-expo` exports `Browser` and `React` with `@sentry/react`:
55+
56+
```diff {tabTitle:JavaScript}
57+
- import { Browser, React } from 'sentry-expo';
58+
+ import * as Browser from '@sentry/react';
59+
+ import * as React from '@sentry/react';
60+
```
61+
62+
Replace `sentry-expo` export `Native` with `@sentry/react-native`:
63+
64+
```diff {tabTitle:JavaScript}
65+
- import { Native } from 'sentry-expo';
66+
+ import * as Sentry from '@sentry/react-native';
67+
```
68+
69+
### Review `Sentry.init` Options
70+
71+
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.
72+
73+
```diff {tabTitle:JavaScript}
74+
Sentry.init({
75+
- enableInExpoDevelopment: true,
76+
+ enabled: __DEV__,
77+
});
78+
```
79+
80+
### Changes to Default Tags
81+
82+
Expo-specific tags are no longer added by default. If you were using them, you can add them manually:
83+
84+
```js
85+
import Constants from "expo-constants";
86+
import * as Device from "expo-device";
87+
import * as Updates from "expo-updates";
88+
89+
import * as Sentry from "@sentry/react-native";
90+
91+
Sentry.setExtras({
92+
manifest,
93+
deviceYearClass: Device.deviceYearClass,
94+
linkingUri: Constants.linkingUri,
95+
});
96+
97+
Sentry.setTag("expoReleaseChannel", Updates.manifest.releaseChannel);
98+
Sentry.setTag("appVersion", Updates.manifest.version);
99+
Sentry.setTag("appPublishedTime", Updates.manifest.publishedTime);
100+
Sentry.setTag("expoSdkVersion", Updates.manifest.sdkVersion);
101+
Sentry.setTag("deviceId", Constants.sessionId);
102+
Sentry.setTag("appOwnership", Constants.appOwnership || "N/A");
103+
if (Constants.appOwnership === "expo" && Constants.expoVersion) {
104+
setTag("expoAppVersion", Constants.expoVersion);
105+
}
106+
Sentry.setTag("expoChannel", Updates.channel);
107+
```
108+
109+
## Review `react-native-web` Compatibility
110+
111+
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.
112+
113+
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.
114+
115+
To continue using `@sentry/react` for `react-native-web` builds, see [@sentry/react](/platforms/javascript/guides/react/) for more details about the web React package.
116+
117+
## Set Up the `@sentry/react-native` Expo and Metro Plugins
118+
119+
Next, [set up the Expo and Metro plugins](/platforms/react-native/manual-setup/expo/) for `@sentry/react-native`.

src/platforms/react-native/sourcemaps/uploading/expo-advanced.mdx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ For a guide on how to automatically upload source maps for Expo application rele
1010
## Prerequisities
1111

1212
- [Sign up for an account](https://sentry.io/signup/)
13+
- [Migrate from `sentry-expo` to `@sentry/react-native`](/platforms/react-native/migration/sentry-expo/)
1314
- [Set up Sentry React Native SDK](/platforms/react-native/manual-setup/expo/) version 5.16.0-alpha.4 or newer
1415

1516
<OrgAuthTokenNote />

src/platforms/react-native/sourcemaps/uploading/expo.mdx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ Sentry's React Native SDK works out of the box with Expo applications. To see re
88
## Prerequisities
99

1010
- [Sign up for an account](https://sentry.io/signup/)
11+
- [Migrate from `sentry-expo` to `@sentry/react-native`](/platforms/react-native/migration/sentry-expo/)
1112
- [Set up Sentry React Native SDK](/platforms/react-native/manual-setup/expo/) version 5.16.0-alpha.4 or newer
1213

1314
<OrgAuthTokenNote />
@@ -16,7 +17,7 @@ Sentry's React Native SDK works out of the box with Expo applications. To see re
1617

1718
## Automatic Upload for Release
1819

19-
When the Sentry Expo Plugin `@sentry/react-native/expo` and the Sentry Metro Pugin are added to your application configuration, source maps for the native builds are uploaded automatically during EAS Builds and when building the native application release locally using `expo prebuild`.
20+
When the Sentry Expo Plugin `@sentry/react-native/expo` and the Sentry Metro Pugin are added to your application configuration, source maps for the native builds are uploaded automatically during EAS Builds and when building the native application release locally using `npx expo prebuild`.
2021

2122
## Manual Upload for EAS Updates
2223

0 commit comments

Comments
 (0)