Skip to content

Commit 832fd0f

Browse files
committed
Add React Native Expo support
chore: remove inline require-import eslint suppressions Fix React Native Expo integration Attach React component stacks to error data Fix React Native PR review findings Add React Native client agent skill docs Force localhost for Expo iOS dogfooding Add native crash plugin review coverage Fix React Native README startup wording
1 parent daf40ff commit 832fd0f

71 files changed

Lines changed: 10488 additions & 735 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.agents/skills/exceptionless-javascript/SKILL.md

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
---
22
name: exceptionless-javascript
3-
description: Use this skill when a developer wants to install, configure, troubleshoot, or integrate Exceptionless JavaScript clients for browser, Node.js, React, Vue, AngularJS, Express, Next.js, SvelteKit, or custom runtimes. Use it for API keys, startup, self-hosting, sending errors/logs/feature usage/404/custom events, indexed event properties, sessions, heartbeats, user identity, PII/data exclusions, plugins, runtime client configuration values, queues, and production setup even if they only ask "how do I wire up Exceptionless?"
3+
description: Use this skill when a developer wants to install, configure, troubleshoot, or integrate Exceptionless JavaScript clients for browser, Node.js, React, React Native, Expo, Vue, AngularJS, Express, Next.js, SvelteKit, or custom runtimes. Use it for API keys, startup, self-hosting, sending errors/logs/feature usage/404/custom events, indexed event properties, sessions, heartbeats, user identity, PII/data exclusions, plugins, runtime client configuration values, queues, native crash reporting, and production setup even if they only ask "how do I wire up Exceptionless?"
44
---
55

66
# Exceptionless JavaScript SDK
@@ -38,6 +38,7 @@ Read only the reference that matches the user's runtime, then add shared referen
3838
- `@exceptionless/browser`: [references/client-browser.md](references/client-browser.md)
3939
- `@exceptionless/node`: [references/client-node.md](references/client-node.md)
4040
- `@exceptionless/react`: [references/client-react.md](references/client-react.md)
41+
- `@exceptionless/react-native`: [references/client-react-native.md](references/client-react-native.md)
4142
- `@exceptionless/vue`: [references/client-vue.md](references/client-vue.md)
4243
- `@exceptionless/angularjs`: [references/client-angularjs.md](references/client-angularjs.md)
4344
- Sending events: [references/sending-events.md](references/sending-events.md)
@@ -52,6 +53,8 @@ Read only the reference that matches the user's runtime, then add shared referen
5253

5354
- Use `Exceptionless.startup(...)` once during app startup. `startup()` with no args is used later by lifecycle plugins to resume timers/queue processing.
5455
- Use the singleton from the platform package when automatic capture matters. Create `ExceptionlessClient` manually only for custom pipelines or tests.
56+
- For React Native or Expo apps, use `@exceptionless/react-native`; do not substitute `@exceptionless/browser` or `@exceptionless/react`.
57+
- In Expo, add `@exceptionless/react-native/expo-plugin` when native iOS crash reporting is expected. Expo Go can report JavaScript errors but cannot load the native crash reporter.
5558
- `submitException` and `createException` take an `Error`. For unknown caught values, use exported `toError(value)` when available.
5659
- `markAsCritical()` marks the event critical; `markAsCritical(false)` leaves tags unchanged.
5760
- `config.serverUrl` also sets `configServerUrl` and `heartbeatServerUrl`; assign custom endpoint overrides after setting `serverUrl`.
@@ -80,4 +83,7 @@ Verify behavior in:
8083
- `packages/core/src/submission/DefaultSubmissionClient.ts`
8184
- `packages/browser/src/BrowserExceptionlessClient.ts`
8285
- `packages/node/src/NodeExceptionlessClient.ts`
86+
- `packages/react-native/src/ReactNativeExceptionlessClient.ts`
87+
- `packages/react-native/src/plugins/ReactNativeErrorPlugin.ts`
88+
- `packages/react-native/src/plugins/NativeCrashPlugin.ts`
8389
- Package READMEs and `example/` apps.
Lines changed: 124 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,124 @@
1+
# @exceptionless/react-native
2+
3+
Use for React Native and Expo apps. This package adds a React Native client, AsyncStorage-backed persistence, React Native/Hermes stack parsing, lifecycle handling, global JavaScript error capture, an error boundary, and iOS native crash reporting.
4+
5+
## Install
6+
7+
Expo:
8+
9+
```bash
10+
npx expo install @exceptionless/react-native @react-native-async-storage/async-storage
11+
```
12+
13+
React Native CLI:
14+
15+
```bash
16+
npm install @exceptionless/react-native @react-native-async-storage/async-storage
17+
cd ios && pod install
18+
```
19+
20+
For Expo development or standalone builds, add the config plugin:
21+
22+
```json
23+
{
24+
"expo": {
25+
"plugins": ["@exceptionless/react-native/expo-plugin"]
26+
}
27+
}
28+
```
29+
30+
Native iOS crash reporting requires an Expo development build, a standalone build, or a bare React Native app. Expo Go can capture JavaScript errors but cannot load the native crash reporter.
31+
32+
## Configure
33+
34+
Call `startup` once during app initialization:
35+
36+
```tsx
37+
import { Exceptionless } from "@exceptionless/react-native";
38+
39+
await Exceptionless.startup((config) => {
40+
config.apiKey = "API_KEY_HERE";
41+
config.setUserIdentity("12345678", "Blake");
42+
config.defaultTags.push("React Native");
43+
});
44+
```
45+
46+
For self-hosted Exceptionless:
47+
48+
```tsx
49+
await Exceptionless.startup((config) => {
50+
config.apiKey = "API_KEY_HERE";
51+
config.serverUrl = "https://exceptionless.example.com";
52+
});
53+
```
54+
55+
For local simulator development, prefer `http://localhost:<port>` when the app is running in the iOS simulator. Start Expo with `--localhost` or set `REACT_NATIVE_PACKAGER_HOSTNAME=localhost` so Metro bundle URLs in stack traces also use localhost. Use a LAN IP only when a physical device must reach a server on the development machine.
56+
57+
## Error Boundary
58+
59+
Wrap rendering surfaces to capture React render errors and attach the React component stack to `@error.data["@component_stack"]`:
60+
61+
```tsx
62+
import { Text } from "react-native";
63+
import { ExceptionlessErrorBoundary } from "@exceptionless/react-native";
64+
65+
export function App() {
66+
return (
67+
<ExceptionlessErrorBoundary fallback={<Text>Something went wrong.</Text>}>
68+
<YourApp />
69+
</ExceptionlessErrorBoundary>
70+
);
71+
}
72+
```
73+
74+
React error boundaries do not catch event handlers, async failures, or manually swallowed errors. Submit those explicitly.
75+
76+
## Send
77+
78+
```tsx
79+
import { Exceptionless, toError } from "@exceptionless/react-native";
80+
81+
try {
82+
await saveProfile();
83+
} catch (error) {
84+
await Exceptionless.submitException(toError(error));
85+
}
86+
87+
await Exceptionless.submitLog("mobile", "Profile opened", "info");
88+
await Exceptionless.submitFeatureUsage("Profile Editor");
89+
90+
await Exceptionless.createException(new Error("Checkout failed"))
91+
.addTags("checkout", "mobile")
92+
.setProperty("orderId", "12345")
93+
.markAsCritical(true)
94+
.submit();
95+
```
96+
97+
## Captured Behavior
98+
99+
- Unhandled JavaScript errors and unhandled promise rejections are captured automatically after startup.
100+
- React Native/Hermes stack frames are parsed into structured Exceptionless stack frames.
101+
- iOS native crashes are persisted by PLCrashReporter and submitted on the next launch.
102+
- Device, OS, locale, React Native version, sessions, and lifecycle state are captured when available.
103+
- Event queue storage uses `@react-native-async-storage/async-storage`.
104+
105+
## Troubleshooting
106+
107+
- If native crashes do not appear in Expo, verify the app is not running in Expo Go and that the config plugin is present before rebuilding the native app.
108+
- If simulator submissions cannot reach a local Exceptionless server, use `http://localhost:<port>` for iOS Simulator and make sure Metro is not running in Expo's default LAN mode. Physical devices need a reachable LAN host.
109+
- For malformed or unexpected stacks, verify behavior in `ReactNativeErrorPlugin` tests before changing parser logic.
110+
- For native crash report loss concerns, verify `NativeCrashPlugin` only clears pending reports after at least one report is retrieved and submitted.
111+
112+
## Source Anchors
113+
114+
- `packages/react-native/README.md`
115+
- `packages/react-native/src/ReactNativeExceptionlessClient.ts`
116+
- `packages/react-native/src/ExceptionlessErrorBoundary.tsx`
117+
- `packages/react-native/src/plugins/ReactNativeErrorPlugin.ts`
118+
- `packages/react-native/src/plugins/ReactNativeGlobalHandlerPlugin.ts`
119+
- `packages/react-native/src/plugins/ReactNativeLifeCyclePlugin.ts`
120+
- `packages/react-native/src/plugins/NativeCrashPlugin.ts`
121+
- `packages/react-native/src/storage/AsyncStorageProvider.ts`
122+
- `packages/react-native/exceptionless-react-native.podspec`
123+
- `packages/react-native/expo-plugin/withExceptionless.cjs`
124+
- `example/expo/`

.prettierignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,9 @@
33
node_modules
44
minver
55
example/svelte-kit/.svelte-kit
6+
example/expo/.expo
7+
example/expo/android
8+
example/expo/ios
69

710
# Ignore files for PNPM, NPM and YARN
811
package-lock.json

.vscode/launch.json

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,17 @@
11
{
22
"version": "0.2.0",
33
"configurations": [
4+
{
5+
"name": "Expo iOS Example",
6+
"request": "launch",
7+
"type": "node",
8+
"runtimeExecutable": "npm",
9+
"runtimeArgs": ["run", "ios", "--workspace=example/expo"],
10+
"console": "integratedTerminal",
11+
"internalConsoleOptions": "neverOpen",
12+
"cwd": "${workspaceRoot}",
13+
"skipFiles": ["<node_internals>/**"]
14+
},
415
{
516
"name": "Express",
617
"program": "${workspaceRoot}/example/express/app.js",

README.md

Lines changed: 25 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ The definition of the word exceptionless is: to be without exception. Exceptionl
1010

1111
You can install the npm package via `npm install @exceptionless/browser --save`
1212
or via cdn [`https://unpkg.com/@exceptionless/browser`](https://unpkg.com/@exceptionless/browser).
13-
Next, you just need to call startup during your apps startup to automatically
13+
Next, you just need to call startup during your app's startup to automatically
1414
capture unhandled errors.
1515

1616
```js
@@ -38,7 +38,7 @@ try {
3838
## Node
3939

4040
You can install the npm package via `npm install @exceptionless/node --save`.
41-
Next, you just need to call startup during your apps startup to automatically
41+
Next, you just need to call startup during your app's startup to automatically
4242
capture unhandled errors.
4343

4444
```js
@@ -63,6 +63,29 @@ try {
6363
}
6464
```
6565

66+
## React Native / Expo
67+
68+
You can install the npm package via
69+
`npm install @exceptionless/react-native @react-native-async-storage/async-storage`.
70+
Next, you just need to call startup during your apps startup to automatically
71+
capture unhandled errors, promise rejections, and native iOS crashes.
72+
73+
```tsx
74+
import { Exceptionless, toError } from "@exceptionless/react-native";
75+
76+
await Exceptionless.startup((c) => {
77+
c.apiKey = "API_KEY_HERE";
78+
c.setUserIdentity("12345678", "Blake");
79+
c.defaultTags.push("Example", "React Native");
80+
});
81+
82+
try {
83+
throw new Error("test");
84+
} catch (error) {
85+
await Exceptionless.submitException(toError(error));
86+
}
87+
```
88+
6689
## Using Exceptionless
6790

6891
### Installation

eslint.config.mjs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import vitest from "@vitest/eslint-plugin";
55
import tseslint from "typescript-eslint";
66

77
export default defineConfig(
8-
{ ignores: ["**/dist/", "**/node_modules/", ".agents/", "example/"] },
8+
{ ignores: ["**/dist/", "**/node_modules/", ".agents/", "example/", "**/expo-plugin/", "**/react-native.config.*"] },
99
eslint.configs.recommended,
1010
{
1111
extends: tseslint.configs.recommendedTypeChecked,

example/expo/.gitignore

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
node_modules/
2+
.expo/
3+
dist/
4+
ios/
5+
android/
6+
*.xcworkspace
7+
Pods/
8+
9+
# @generated expo-cli sync-2b81b286409207a5da26e14c78851eb30d8ccbdb
10+
# The following patterns were generated by expo-cli
11+
12+
expo-env.d.ts
13+
# @end expo-cli

0 commit comments

Comments
 (0)