Skip to content
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

feat(overlay): Allow to directly add sentry envelopes via trigger #498

Closed
wants to merge 5 commits into from
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
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
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',
BYK marked this conversation as resolved.
Show resolved Hide resolved
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);
```
Loading