@@ -198,26 +198,26 @@ end
198
198
``` javascript
199
199
const SENTRY_HOST = " oXXXXXX.ingest.sentry.io"
200
200
const SENTRY_PROJECT_IDS = [" 123456" ]
201
-
201
+
202
202
export const postAction = async ({ request }) => {
203
203
try {
204
204
const envelope = await request .text ();
205
205
const piece = envelope .split (" \n " )[0 ];
206
206
const header = JSON .parse (piece);
207
207
const dsn = new URL (header[" dsn" ]);
208
208
const project_id = dsn .pathname ? .replace (" /" , " " );
209
-
209
+
210
210
if (dsn .hostname !== SENTRY_HOST ) {
211
211
throw new Error (` Invalid sentry hostname: ${ dsn .hostname } ` );
212
212
}
213
-
213
+
214
214
if (! project_id || ! SENTRY_PROJECT_IDS .includes (project_id)) {
215
215
throw new Error (` Invalid sentry project id: ${ project_id} ` );
216
216
}
217
-
217
+
218
218
const upstream_sentry_url = ` https://${ SENTRY_HOST } /api/${ project_id} /envelope/` ;
219
219
await fetch (upstream_sentry_url, { method: " POST" , body: envelope });
220
-
220
+
221
221
return json ({}, { status: 200 });
222
222
} catch (e) {
223
223
console .error (" error tunneling to sentry" , e);
@@ -298,7 +298,7 @@ import {
298
298
defaultStackParser ,
299
299
defaultIntegrations ,
300
300
makeFetchTransport ,
301
- Hub ,
301
+ Scope ,
302
302
} from " @sentry/browser" ;
303
303
304
304
const client = new BrowserClient ({
@@ -308,12 +308,13 @@ const client = new BrowserClient({
308
308
integrations: defaultIntegrations,
309
309
});
310
310
311
- // You have to bind the client to a hub, otherwise integrations will not run!
312
- const hub = new Hub (client);
313
- // Or, if you already have a hub you want to re-use, you can also do:
314
- // hub.bindClient( client);
311
+ const scope = new Scope ();
312
+ scope . setClient (client);
313
+
314
+ client . init () // initializing has to be done after setting the client on the scope
315
315
316
- hub .captureException (new Error (" example" ));
316
+ // You can capture exceptions manually for this client like this:
317
+ scope .captureException (new Error (" example" ));
317
318
` ` `
318
319
319
320
You can now customize the hub to your liking, without affecting other hubs/clients.
0 commit comments