Skip to content

Commit

Permalink
feat(overlay): Allow to directly add sentry envelopes via trigger
Browse files Browse the repository at this point in the history
  • Loading branch information
mydea committed Aug 20, 2024
1 parent 86055cc commit 87ba9ff
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 1 deletion.
5 changes: 5 additions & 0 deletions .changeset/blue-trees-repeat.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@spotlightjs/overlay': minor
---

feat: Allow to directly add sentry envelopes via trigger
11 changes: 11 additions & 0 deletions packages/overlay/src/integrations/sentry/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,19 @@ export default function sentryIntegration(options: SentryIntegrationOptions = {}

on('sentry:showError', onRenderError as EventListener);

const onAddEnvelope = (e: CustomEvent) => {
if (!e.detail.envelope) return;
processEnvelope({
contentType: 'application/x-sentry-envelope',
data: e.detail.envelope,
});
};

on('sentry:addEnvelope', onAddEnvelope as EventListener);

return () => {
off('sentry:showError', onRenderError as EventListener);
off('sentry:addEnvelope', onAddEnvelope as EventListener);
};
},

Expand Down
10 changes: 9 additions & 1 deletion packages/website/src/content/docs/reference/sentry.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,18 @@ init({
Additionally it includes an event to trigger synchronously rendering an error:

```js
import { trigger } as Spotlight from '@spotlightjs/spotlight';
import { trigger } from '@spotlightjs/spotlight';

trigger("sentry:showError", {
eventId: string,
event?: Event,
});
```

You can also directly add envelopes to the Sentry integration:

```js
import { trigger } from '@spotlightjs/spotlight';

trigger("sentry:addEnvelope", sentryEnvelope);
```

0 comments on commit 87ba9ff

Please sign in to comment.