Skip to content

feat(expo): Add Expo Support #3399

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 47 commits into from
Jan 15, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
47 commits
Select commit Hold shift + click to select a range
0b80597
feat(expo): Add Expo config plugin (#3391)
kbrandwijk Nov 15, 2023
d1cec7b
Merge branch 'main' into expo
krystofwoldrich Nov 27, 2023
21d165e
feat(expo): Add @sentry/react-native/expo export for expo-plugin (#3429)
krystofwoldrich Nov 29, 2023
3120e1d
feat(samples): Add Expo sample application (#3427)
krystofwoldrich Nov 29, 2023
5b207d9
fix(web): Fix JSX build errors when using Webpack (#3428)
krystofwoldrich Nov 30, 2023
62320b4
feat(xcode): Dynamically resolve SDK and CLI package paths (#3431)
krystofwoldrich Dec 4, 2023
d93ea93
Merge remote-tracking branch 'origin/main' into expo
krystofwoldrich Dec 4, 2023
1bcb0b5
fix(xcode): Collect modules js path from shell
krystofwoldrich Dec 5, 2023
f990c2e
Merge remote-tracking branch 'origin/release/5.15.0' into expo
krystofwoldrich Dec 5, 2023
81563a3
Merge remote-tracking branch 'origin/main' into expo
krystofwoldrich Dec 5, 2023
de57355
chore(changelog): Add experimental note to Expo support
krystofwoldrich Dec 5, 2023
e912ae5
release: 5.16.0-alpha.1
getsentry-bot Dec 5, 2023
b85b73a
Merge branch 'release/5.16.0-alpha.1' into expo
Dec 5, 2023
6f95f45
chore(expo): Bump Expo min version to SDK 49 (#3453)
krystofwoldrich Dec 7, 2023
817bb8d
feat(expo): Add `withSentryExpoSerializers` for easy metro configurat…
krystofwoldrich Dec 7, 2023
a788595
fix(sample): All Expo native scripts paths are relative to the repo r…
krystofwoldrich Dec 13, 2023
cae7f34
fix(web): Remove all RN internals imports for web builds (#3462)
krystofwoldrich Dec 13, 2023
f6575dd
fix(sdk): Remove circular dependencies from SDK code (#3464)
krystofwoldrich Dec 13, 2023
d228d68
fix(promises): Fix missing RN Promise import waring
krystofwoldrich Dec 13, 2023
544a858
Merge branch 'main' into expo
krystofwoldrich Dec 13, 2023
1bc6744
release: 5.16.0-alpha.2
getsentry-bot Dec 13, 2023
1007a35
Merge branch 'release/5.16.0-alpha.2' into expo
Dec 13, 2023
e9bff4c
Merge branch 'main' into expo
krystofwoldrich Jan 5, 2024
4fd5328
chore(internal): Use new DSN after leaked token
krystofwoldrich Jan 5, 2024
0179309
Merge branch 'origin/main' into expo
krystofwoldrich Jan 8, 2024
2593f66
Add 5.15.2 fixes info to the changelog
krystofwoldrich Jan 8, 2024
337cd67
chore(sample): Update Expo sample to SDK 50 beta 0 (#3463)
krystofwoldrich Jan 8, 2024
1e7038e
chore(sample): Update DSN
krystofwoldrich Jan 8, 2024
e5538c1
feat(expo): Add support to inject debug module before serialization (…
quinlanj Jan 8, 2024
1fa5bbc
chore(sdk): Bump Expo to 50.0.0-preview.8 (#3500)
krystofwoldrich Jan 8, 2024
2e40f57
feat(expo): More universal `getSentryExpoConfig` (#3501)
krystofwoldrich Jan 8, 2024
6bd18dc
feat(expo): Add source maps upload script (#3491)
quinlanj Jan 8, 2024
55fe14c
fix(expo): Fix expo upload source maps script lint (#3508)
krystofwoldrich Jan 9, 2024
dc8966b
feat(expo): Dynamically resolve default integrations based on platfor…
krystofwoldrich Jan 9, 2024
8d8a8a4
feat(expo): Dynamically resolve sentry-cli path in expo source maps u…
krystofwoldrich Jan 9, 2024
a48c9b5
Merge remote-tracking branch 'origin/main' into expo
krystofwoldrich Jan 9, 2024
4fb79c3
feat(expo): Add Expo Modules Integration (#3466)
krystofwoldrich Jan 9, 2024
0d87adb
feat(expo): Add `npx sentry-expo-upload-sourcemaps` command (#3510)
krystofwoldrich Jan 9, 2024
3a2721b
release: 5.16.0-alpha.3
getsentry-bot Jan 10, 2024
70f6d72
Merge branch 'release/5.16.0-alpha.3' into expo
Jan 10, 2024
2684f2c
fix(expo): Make `getSentryExpoConfig` options param optional (#3514)
krystofwoldrich Jan 10, 2024
e9e2c8c
fix(expo): Use `@sentry/react-native/expo` as plugin name in expo upl…
krystofwoldrich Jan 10, 2024
4e64cdd
Merge branch 'main' into expo
krystofwoldrich Jan 10, 2024
1423f05
release: 5.16.0-alpha.4
getsentry-bot Jan 10, 2024
b51f045
Merge branch 'release/5.16.0-alpha.4' into expo
Jan 10, 2024
e0f5713
Merge branch 'main' into expo
krystofwoldrich Jan 15, 2024
7499eaa
chore(sdk): Add Expo release summary to the changelog (#3522)
krystofwoldrich Jan 15, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 10 additions & 2 deletions .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,15 @@ module.exports = {
settings: {
version: 'detect', // React version. "detect" automatically picks the version you have installed.
},
ignorePatterns: ['test/react-native/versions/**/*', 'coverage/**/*', 'test/typescript/**/*', 'metro.d.ts'],
ignorePatterns: [
'test/react-native/versions/**/*',
'coverage/**/*',
'test/typescript/**/*',
'metro.d.ts',
'samples/**/*',
'plugin/build/**/*',
'expo.d.ts',
],
overrides: [
{
// Typescript Files
Expand All @@ -37,7 +45,7 @@ module.exports = {
// Scripts
files: ['scripts/*'],
parserOptions: {
ecmaVersion: 2015,
ecmaVersion: 2018,
},
rules: {
'no-console': 'off',
Expand Down
36 changes: 36 additions & 0 deletions .github/workflows/buildandtest.yml
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,11 @@ jobs:
with:
name: ts3.8
path: ts3.8
- name: Archive Expo Plugin
uses: actions/upload-artifact@v3
with:
name: expo-plugin
path: plugin/build
- name: Pack
run: yarn pack
- name: Archive Artifacts
Expand Down Expand Up @@ -155,6 +160,37 @@ jobs:
working-directory: test/typescript/ts3.8
run: yarn type-check

job_circular_dep_check:
name: Circular Dependency Check
runs-on: ubuntu-latest
needs: [job_build]
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: 18
- name: Cache Dependencies
uses: actions/cache@v3
id: cache
with:
path: node_modules
key: ${{ runner.os }}-${{ github.sha }}
- name: Install Dependencies
if: ${{ steps.cache.outputs['cache-hit'] != 'true' }}
run: yarn install
- name: Download dist
uses: actions/download-artifact@v3
with:
name: dist
path: dist
- name: Download Expo Plugin
uses: actions/download-artifact@v3
with:
name: expo-plugin
path: plugin/build
- name: Run madge
run: yarn circularDepCheck

job_bundle:
name: Bundle
runs-on: ubuntu-latest
Expand Down
7 changes: 7 additions & 0 deletions .npmignore
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,14 @@
!scripts/sentry-xcode.sh
!scripts/sentry-xcode-debug-files.sh
!scripts/sentry_utils.rb
!scripts/expo-upload-sourcemaps.js

# Metro
!/metro.js
!/metro.d.ts

# Expo
!/expo.js
!/expo.d.ts
!/app.plugin.js
!/plugin/build/**/*
4 changes: 1 addition & 3 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,7 @@
"editor.formatOnType": true,
"editor.formatOnPaste": false,
"editor.formatOnSave": true,
"editor.rulers": [
120
],
"editor.rulers": [120],
"editor.tabSize": 2,
"files.autoSave": "onWindowChange",
"files.trimTrailingWhitespace": true,
Expand Down
172 changes: 171 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,145 @@

## Unreleased

### Fixes
This release ships with a beta version of our new built-in Expo SDK 50 support,
which replaces the deprecated `sentry-expo` package. To learn more,
see [the Expo guide](https://docs.sentry.io/platforms/react-native/manual-setup/expo/).

### Features

- New `@sentry/react-native/expo` Expo config plugin ([#3429](https://github.com/getsentry/sentry-react-native/pull/3429))

```js
const { withSentry } = require('@sentry/react-native/expo');

const config = {...};

module.exports = withSentry(config, {
url: 'https://www.sentry.io/',
authToken: 'example-token', // Or use SENTRY_AUTH_TOKEN env
project: 'project-slug', // Or use SENTRY_PROJECT env
organization: 'org-slug', // Or use SENTRY_ORG env
});
```

- And `Sentry.init` in `App.js`

```js
import * as Sentry from '@sentry/react-native';

Sentry.init({
dsn: '__DSN__',
});
```

- New `getSentryExpoConfig` for simple Metro configuration ([#3454](https://github.com/getsentry/sentry-react-native/pull/3454), [#3501](https://github.com/getsentry/sentry-react-native/pull/3501), [#3514](https://github.com/getsentry/sentry-react-native/pull/3514))
- This function is a drop in replacement for `getDefaultConfig` from `expo/metro-config`

```js
// const { getDefaultConfig } = require("expo/metro-config");
const { getSentryExpoConfig } = require("@sentry/react-native/metro");

// const config = getDefaultConfig(__dirname);
const config = getSentryExpoConfig(config, {});
```

- New `npx sentry-expo-upload-sourcemaps` for simple EAS Update (`npx expo export`) source maps upload ([#3491](https://github.com/getsentry/sentry-react-native/pull/3491), [#3510](https://github.com/getsentry/sentry-react-native/pull/3510), [#3515](https://github.com/getsentry/sentry-react-native/pull/3515), [#3507](https://github.com/getsentry/sentry-react-native/pull/3507))

```bash
SENTRY_PROJECT=project-slug \
SENTRY_ORG=org-slug \
SENTRY_AUTH_TOKEN=super-secret-token \
npx sentry-expo-upload-sourcemaps dist
```

### Others

- Update `sentry-xcode.sh` scripts with Node modules resolution ([#3450](https://github.com/getsentry/sentry-react-native/pull/3450))
- RN SDK and Sentry CLI are dynamically resolved if override is not supplied
- Resolve Default Integrations based on current platform ([#3465](https://github.com/getsentry/sentry-react-native/pull/3465))
- Native Integrations are only added if Native Module is available
- Web Integrations only for React Native Web builds
- Remove Native Modules warning from platform where the absence is expected ([#3466](https://github.com/getsentry/sentry-react-native/pull/3466))
- Add Expo Context information using Expo Native Modules ([#3466](https://github.com/getsentry/sentry-react-native/pull/3466))
- Errors from InternalBytecode.js are no longer marked as in_app ([#3518](https://github.com/getsentry/sentry-react-native/pull/3518))

## 5.16.0-alpha.4

### Fixes

- Make `getSentryExpoConfig` options parameter optional ([#3514](https://github.com/getsentry/sentry-react-native/pull/3514))
- Use `@sentry/react-native/expo` as plugin name in `expo-upload-sourcemaps.js` ([#3515](https://github.com/getsentry/sentry-react-native/pull/3515))

## 5.16.0-alpha.3

This release is compatible with `[email protected]` and newer.

### Features

- `withSentryExpoSerializers` changes to `getSentryExpoConfig` ([#3501](https://github.com/getsentry/sentry-react-native/pull/3501))
- `getSentryExpoConfig` accepts the same parameters as `getDefaultConfig` from `expo/metro-config` and returns Metro configuration
- This also works for EAS Updates (and expo export). Debug ID is generated by `expo/metro-config` and used by Sentry.

```js
const { getSentryExpoConfig } = require("@sentry/react-native/metro");
const config = getSentryExpoConfig(config, {});
```

- Add `npx sentry-expo-upload-sourcemaps` for simple EAS Update (expo export) source maps upload to Sentry ([#3491](https://github.com/getsentry/sentry-react-native/pull/3491), [#3510](https://github.com/getsentry/sentry-react-native/pull/3510))

```bash
SENTRY_PROJECT=project-slug \
SENTRY_ORG=org-slug \
SENTRY_AUTH_TOKEN=super-secret-token \
npx sentry-expo-upload-sourcemaps dist
```

- Sentry CLI binary path in `scripts/expo-upload-sourcemaps.js` is resolved dynamically ([#3507](https://github.com/getsentry/sentry-react-native/pull/3507))
- Or can be overwritten by `SENTRY_CLI_EXECUTABLE` env

- Resolve Default Integrations based on current platform ([#3465](https://github.com/getsentry/sentry-react-native/pull/3465))
- Native Integrations are only added if Native Module is available
- Web Integrations only for React Native Web builds
- Remove Native Modules warning from platform where the absence is expected ([#3466](https://github.com/getsentry/sentry-react-native/pull/3466))
- Add Expo Context information using Expo Native Modules ([#3466](https://github.com/getsentry/sentry-react-native/pull/3466))

### Fixes

- Includes fixes from version 5.15.2

## 5.15.2

### Fixes

- Stop sending navigation route params for auto-generated transactions, as they may contain PII or other sensitive data ([#3487](https://github.com/getsentry/sentry-react-native/pull/3487))
- Further details and other strategies to mitigate this issue can be found on our [trouble shooting guide page](https://docs.sentry.io/platforms/react-native/troubleshooting/#routing-transaction-data-contains-sensitive-information)

## 5.16.0-alpha.2

### Features

- Add `withSentryExpoSerializers` for easy configurable `metro.config.js` ([#3454](https://github.com/getsentry/sentry-react-native/pull/3454))

This Serializer doesn't support EAS Updates (and expo export) commands yet. Debug IDs needed for source maps resolution in Sentry
are generated only during native builds.

```js
const { getDefaultConfig } = require('expo/metro-config');
const { withSentryExpoSerializers } = require("@sentry/react-native/metro");

const config = getDefaultConfig(__dirname);
module.exports = withSentryExpoSerializers(config);
```

Note that this will remove any existing `customSerializer`. Guide for advanced setups [can be found here](https://docs.sentry.io/platforms/react-native/manual-setup/metro).

### Fixes

- Expo SDK minimum version is 49 ([#3453](https://github.com/getsentry/sentry-react-native/pull/3453))
- Remove RN Internal imports for RN Web builds ([#3462](https://github.com/getsentry/sentry-react-native/pull/3462))
- Remove circular dependencies inside of the SDK ([#3464](https://github.com/getsentry/sentry-react-native/pull/3464))
- Includes fixes from version 5.15.1

## 5.15.1

### Fixes
Expand All @@ -25,6 +153,48 @@
- [changelog](https://github.com/getsentry/sentry-cli/blob/master/CHANGELOG.md#2230)
- [diff](https://github.com/getsentry/sentry-cli/compare/2.21.3...2.23.0)

## 5.16.0-alpha.1

### Features

- Add `@sentry/react-native/expo` Expo config plugin ([#3429](https://github.com/getsentry/sentry-react-native/pull/3429))

This Release introduces the first alpha version of our new SDK for Expo.
At this time, the SDK is considered experimental and things might break and change in future versions.

The core of the SDK is Expo plugin which you can easily add to your App config:

```js
const { withSentry } = require('@sentry/react-native/expo');

const config = {...};

module.exports = withSentry(config, {
url: 'https://www.sentry.io/',
authToken: 'example-token', // Or use SENTRY_AUTH_TOKEN env
project: 'project-slug', // Or use SENTRY_PROJECT env
organization: 'org-slug', // Or use SENTRY_ORG env
});
```

- And `Sentry.init` in `App.js`

```js
import * as Sentry from '@sentry/react-native';

Sentry.init({
dsn: '__DSN__',
});
```

- Update `sentry-xcode.sh` scripts with Node modules resolution ([#3450](https://github.com/getsentry/sentry-react-native/pull/3450))
- RN SDK and Sentry CLI are dynamically resolved if override is not supplied

### Fixes

- Transform shipped JSX for both react-native and web ([#3428](https://github.com/getsentry/sentry-react-native/pull/3428))
- Removes builds errors when using react-native-web with Webpack

## 5.15.0

### Features
Expand Down
1 change: 1 addition & 0 deletions app.plugin.js
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
module.exports = require('./expo');
1 change: 1 addition & 0 deletions expo.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export * from './plugin/build';
1 change: 1 addition & 0 deletions expo.js
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
module.exports = require('./plugin/build');
28 changes: 23 additions & 5 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "@sentry/react-native",
"homepage": "https://github.com/getsentry/sentry-react-native",
"repository": "https://github.com/getsentry/sentry-react-native",
"version": "5.15.2",
"version": "5.16.0-alpha.4",
"description": "Official Sentry SDK for react-native",
"typings": "dist/js/index.d.ts",
"types": "dist/js/index.d.ts",
Expand All @@ -18,26 +18,33 @@
},
"main": "dist/js/index.js",
"scripts": {
"build": "yarn build:sdk && yarn downlevel && yarn build:tools",
"build": "yarn build:sdk && yarn downlevel && yarn build:tools && yarn build:plugin",
"build:sdk": "tsc -p tsconfig.build.json",
"build:sdk:watch": "tsc -p tsconfig.build.json -w --preserveWatchOutput",
"build:tools": "tsc -p tsconfig.build.tools.json",
"build:tools:watch": "tsc -p tsconfig.build.tools.json -w --preserveWatchOutput",
"build:plugin": "EXPO_NONINTERACTIVE=true expo-module build plugin",
"downlevel": "downlevel-dts dist ts3.8/dist --to=3.8",
"clean": "rimraf dist coverage",
"clean": "rimraf dist coverage && yarn clean:plugin",
"clean:plugin": "expo-module clean plugin",
"circularDepCheck": "madge --circular dist/js/index.js && madge --circular metro.js && madge --circular expo.js",
"test": "yarn test:sdk && yarn test:tools",
"test:sdk": "jest",
"test:tools": "jest --config jest.config.tools.js",
"fix": "yarn fix:eslint && yarn fix:prettier",
"fix:eslint": "eslint --config .eslintrc.js --fix .",
"fix:prettier": "prettier --write \"{src,test,scripts}/**/**.ts\"",
"fix:prettier": "prettier --write \"{src,test,scripts,plugin/src}/**/**.ts\"",
"lint": "yarn lint:eslint && yarn lint:prettier",
"lint:eslint": "eslint --config .eslintrc.js .",
"lint:prettier": "prettier --check \"{src,test,scripts}/**/**.ts\"",
"lint:prettier": "prettier --check \"{src,test,scripts,plugin/src}/**/**.ts\"",
"test:watch": "jest --watch",
"run-ios": "cd samples/react-native && yarn react-native run-ios",
"run-android": "cd samples/react-native && yarn react-native run-android",
"yalc:add:sentry-javascript": "yalc add @sentry/browser @sentry/core @sentry/hub @sentry/integrations @sentry/react @sentry/types @sentry/utils"
},
"bin": {
"sentry-expo-upload-sourcemaps": "scripts/expo-upload-sourcemaps.js"
},
"keywords": [
"react-native",
"sentry",
Expand All @@ -54,6 +61,7 @@
"When bumping make sure to update the version of react, i.e: https://github.com/facebook/react-native/blob/v0.56.0/package.json"
],
"peerDependencies": {
"expo": ">=49.0.0",
"react": ">=17.0.0",
"react-native": ">=0.65.0"
},
Expand All @@ -68,6 +76,8 @@
"@sentry/utils": "7.81.1"
},
"devDependencies": {
"@babel/core": "^7.23.5",
"@expo/metro-config": "0.16.0",
"@sentry-internal/eslint-config-sdk": "7.81.1",
"@sentry-internal/eslint-plugin-sdk": "7.81.1",
"@sentry-internal/typescript": "7.80.0",
Expand All @@ -82,8 +92,11 @@
"eslint": "^7.6.0",
"eslint-plugin-react": "^7.20.6",
"eslint-plugin-react-native": "^3.8.1",
"expo": "50.0.0-preview.8",
"expo-module-scripts": "^3.1.0",
"jest": "^29.6.2",
"jest-environment-jsdom": "^29.6.2",
"madge": "^6.1.0",
"metro": "0.76",
"prettier": "^2.0.5",
"react": "18.2.0",
Expand All @@ -110,5 +123,10 @@
"android": {
"javaPackageName": "io.sentry.react"
}
},
"peerDependenciesMeta": {
"expo": {
"optional": true
}
}
}
5 changes: 5 additions & 0 deletions plugin/src/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
import { withSentry } from './withSentry';

export { withSentry };

export default withSentry;
Loading