@allstak/react 0.1.2 → 0.2.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +150 -47
- package/dist/index.d.mts +552 -1
- package/dist/index.d.ts +552 -1
- package/dist/index.js +1264 -5
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +1250 -6
- package/dist/index.mjs.map +1 -1
- package/package.json +11 -10
package/README.md
CHANGED
|
@@ -1,80 +1,183 @@
|
|
|
1
|
-
# @allstak
|
|
1
|
+
# @allstak/react
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
**Drop-in error tracking for React. One `<AllStakErrorBoundary>`, zero config beyond your API key.**
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
[](https://www.npmjs.com/package/@allstak/react)
|
|
6
|
+
[](https://github.com/AllStak/allstak-react/actions)
|
|
7
|
+
[](https://opensource.org/licenses/MIT)
|
|
6
8
|
|
|
7
|
-
|
|
9
|
+
Official AllStak SDK for React — error boundary component, hooks, and a profiler HOC on top of the browser SDK.
|
|
8
10
|
|
|
9
|
-
|
|
11
|
+
## Dashboard
|
|
10
12
|
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
13
|
+
View captured events live at [app.allstak.sa](https://app.allstak.sa).
|
|
14
|
+
|
|
15
|
+

|
|
16
|
+
|
|
17
|
+
## Features
|
|
18
|
+
|
|
19
|
+
- `<AllStakErrorBoundary>` component for render-tree error capture
|
|
20
|
+
- `useAllStak()` hook for in-component capture and context
|
|
21
|
+
- `withAllStakProfiler` HOC for mount/update timing
|
|
22
|
+
- Inherits automatic fetch, console, and window error capture from the core SDK
|
|
23
|
+
- Works with React 17, 18, and 19
|
|
24
|
+
- Full TypeScript types
|
|
25
|
+
|
|
26
|
+
## What You Get
|
|
27
|
+
|
|
28
|
+
Once integrated, every event flows to your AllStak dashboard:
|
|
15
29
|
|
|
16
|
-
|
|
30
|
+
- **Errors** — render-tree crashes, caught hook errors, stack traces with component names
|
|
31
|
+
- **Logs** — console warnings and errors as structured breadcrumbs
|
|
32
|
+
- **HTTP** — outbound `fetch` timing, status codes, failed calls
|
|
33
|
+
- **Performance** — mount and update timing from the profiler HOC
|
|
34
|
+
- **Alerts** — email and webhook notifications on regressions
|
|
35
|
+
|
|
36
|
+
## Installation
|
|
17
37
|
|
|
18
38
|
```bash
|
|
19
|
-
npm install @allstak
|
|
20
|
-
# react >=16.8 is a peer dep — install separately if needed
|
|
39
|
+
npm install @allstak/react
|
|
21
40
|
```
|
|
22
41
|
|
|
23
|
-
##
|
|
42
|
+
## Quick Start
|
|
43
|
+
|
|
44
|
+
> Create a project at [app.allstak.sa](https://app.allstak.sa) to get your API key.
|
|
24
45
|
|
|
25
46
|
```tsx
|
|
26
|
-
import { AllStak } from '@allstak
|
|
27
|
-
import { AllStakErrorBoundary, useAllStak } from '@allstak-io/react';
|
|
47
|
+
import { AllStak, AllStakErrorBoundary } from '@allstak/react';
|
|
28
48
|
|
|
29
|
-
// 1. Initialize once at app root
|
|
30
49
|
AllStak.init({
|
|
31
|
-
apiKey:
|
|
50
|
+
apiKey: import.meta.env.VITE_ALLSTAK_API_KEY,
|
|
32
51
|
environment: 'production',
|
|
33
|
-
release: 'v1.0.0',
|
|
34
52
|
});
|
|
35
53
|
|
|
36
|
-
|
|
37
|
-
|
|
54
|
+
AllStak.captureException(new Error('test: hello from allstak-react'));
|
|
55
|
+
|
|
56
|
+
export function App() {
|
|
38
57
|
return (
|
|
39
58
|
<AllStakErrorBoundary fallback={<p>Something went wrong.</p>}>
|
|
40
|
-
<
|
|
59
|
+
<Routes />
|
|
41
60
|
</AllStakErrorBoundary>
|
|
42
61
|
);
|
|
43
62
|
}
|
|
63
|
+
```
|
|
44
64
|
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
65
|
+
Load the app — the test error appears in your dashboard within seconds.
|
|
66
|
+
|
|
67
|
+
## Get Your API Key
|
|
48
68
|
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
allstak.captureException(err as Error);
|
|
54
|
-
}
|
|
55
|
-
};
|
|
69
|
+
1. Sign up at [app.allstak.sa](https://app.allstak.sa)
|
|
70
|
+
2. Create a project
|
|
71
|
+
3. Copy your API key from **Project Settings → API Keys**
|
|
72
|
+
4. Export it as `ALLSTAK_API_KEY` or pass it to `AllStak.init(...)`
|
|
56
73
|
|
|
57
|
-
|
|
74
|
+
## Configuration
|
|
75
|
+
|
|
76
|
+
| Option | Type | Required | Default | Description |
|
|
77
|
+
|---|---|---|---|---|
|
|
78
|
+
| `apiKey` | `string` | yes | — | Project API key (`ask_live_…`) |
|
|
79
|
+
| `environment` | `string` | no | — | Deployment env |
|
|
80
|
+
| `release` | `string` | no | — | Version or git SHA |
|
|
81
|
+
| `host` | `string` | no | `https://api.allstak.sa` | Ingest host override |
|
|
82
|
+
| `user` | `{ id?, email? }` | no | — | Default user context |
|
|
83
|
+
| `tags` | `Record<string,string>` | no | — | Default tags |
|
|
84
|
+
|
|
85
|
+
## Example Usage
|
|
86
|
+
|
|
87
|
+
Capture an error inside a component:
|
|
88
|
+
|
|
89
|
+
```tsx
|
|
90
|
+
import { useAllStak } from '@allstak/react';
|
|
91
|
+
|
|
92
|
+
function CheckoutButton() {
|
|
93
|
+
const allstak = useAllStak();
|
|
94
|
+
return (
|
|
95
|
+
<button onClick={() => {
|
|
96
|
+
try { checkout(); }
|
|
97
|
+
catch (e) { allstak.captureException(e as Error); }
|
|
98
|
+
}}>Pay</button>
|
|
99
|
+
);
|
|
58
100
|
}
|
|
59
101
|
```
|
|
60
102
|
|
|
61
|
-
|
|
103
|
+
Wrap a component with the profiler:
|
|
104
|
+
|
|
105
|
+
```tsx
|
|
106
|
+
import { withAllStakProfiler } from '@allstak/react';
|
|
107
|
+
export default withAllStakProfiler(Dashboard, { name: 'Dashboard' });
|
|
108
|
+
```
|
|
109
|
+
|
|
110
|
+
Set user context on login:
|
|
111
|
+
|
|
112
|
+
```tsx
|
|
113
|
+
import { AllStak } from '@allstak/react';
|
|
114
|
+
AllStak.setUser({ id: user.id, email: user.email });
|
|
115
|
+
```
|
|
116
|
+
|
|
117
|
+
## Production Endpoint
|
|
118
|
+
|
|
119
|
+
Production endpoint: `https://api.allstak.sa`. Override via `host` for self-hosted installs:
|
|
120
|
+
|
|
121
|
+
```tsx
|
|
122
|
+
AllStak.init({ apiKey: '...', host: 'https://allstak.mycorp.com' });
|
|
123
|
+
```
|
|
124
|
+
|
|
125
|
+
## Source maps
|
|
126
|
+
|
|
127
|
+
Production stack traces are minified — to see real function names and
|
|
128
|
+
line numbers in the AllStak dashboard you need to upload the source maps
|
|
129
|
+
that your bundler emits. The CLI lives in `@allstak/js/sourcemaps`; you
|
|
130
|
+
do **not** need to install `@allstak/js` as a runtime dependency, only
|
|
131
|
+
as a `devDependency` for the build step.
|
|
132
|
+
|
|
133
|
+
### Vite
|
|
134
|
+
|
|
135
|
+
```bash
|
|
136
|
+
npm install -D @allstak/js
|
|
137
|
+
```
|
|
138
|
+
|
|
139
|
+
```ts
|
|
140
|
+
// vite.config.ts
|
|
141
|
+
import { defineConfig } from 'vite';
|
|
142
|
+
import { allstakSourcemaps } from '@allstak/js/vite';
|
|
143
|
+
|
|
144
|
+
export default defineConfig({
|
|
145
|
+
build: { sourcemap: 'hidden' },
|
|
146
|
+
plugins: [
|
|
147
|
+
allstakSourcemaps({
|
|
148
|
+
release: process.env.RELEASE!,
|
|
149
|
+
token: process.env.ALLSTAK_UPLOAD_TOKEN!,
|
|
150
|
+
}),
|
|
151
|
+
],
|
|
152
|
+
});
|
|
153
|
+
```
|
|
154
|
+
|
|
155
|
+
### Webpack / Next / generic
|
|
156
|
+
|
|
157
|
+
The plugin exists for `@allstak/js/webpack` and `@allstak/js/next`; for
|
|
158
|
+
any other bundler call the underlying API after your build:
|
|
159
|
+
|
|
160
|
+
```ts
|
|
161
|
+
import { processBuildOutput } from '@allstak/js/sourcemaps';
|
|
162
|
+
|
|
163
|
+
await processBuildOutput({
|
|
164
|
+
dir: 'dist',
|
|
165
|
+
release: process.env.RELEASE!,
|
|
166
|
+
token: process.env.ALLSTAK_UPLOAD_TOKEN!,
|
|
167
|
+
});
|
|
168
|
+
```
|
|
62
169
|
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
| `AllStakErrorBoundaryProps` | Props type for the boundary |
|
|
68
|
-
| `useAllStak()` | Hook returning `{ captureException, captureMessage, setUser, setTag }` |
|
|
69
|
-
| `withAllStakProfiler(Component)` | HOC that wraps a component in the profiler |
|
|
170
|
+
This injects a stable `debugId` into every chunk and uploads the matching
|
|
171
|
+
`.map`. The runtime resolver in `@allstak/react` reads `globalThis._allstakDebugIds`
|
|
172
|
+
to attach the right debug-id to each captured frame, so the symbolicator
|
|
173
|
+
picks the correct map even after long-tail caching of bundles.
|
|
70
174
|
|
|
71
|
-
##
|
|
175
|
+
## Links
|
|
72
176
|
|
|
73
|
-
-
|
|
74
|
-
-
|
|
75
|
-
-
|
|
76
|
-
- **Releases:** [github.com/allstak-io/allstak-react/releases](https://github.com/allstak-io/allstak-react/releases)
|
|
177
|
+
- Documentation: https://docs.allstak.sa
|
|
178
|
+
- Dashboard: https://app.allstak.sa
|
|
179
|
+
- Source: https://github.com/AllStak/allstak-react
|
|
77
180
|
|
|
78
|
-
##
|
|
181
|
+
## License
|
|
79
182
|
|
|
80
|
-
|
|
183
|
+
MIT © AllStak
|