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: Add no-sidecar Sentry SDK integration for overlay #509

Merged
merged 5 commits into from
Aug 28, 2024

Conversation

BYK
Copy link
Member

@BYK BYK commented Aug 27, 2024

Ref #133.

Copy link

vercel bot commented Aug 27, 2024

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
spotlightjs ✅ Ready (Inspect) Visit Preview 💬 Add feedback Aug 28, 2024 2:36pm

@BYK
Copy link
Member Author

BYK commented Aug 27, 2024

Okay this works but we need some persistent storage as the events don't survive across page loads or even a simple reload.

@BYK
Copy link
Member Author

BYK commented Aug 27, 2024

@Lms24 any thoughts here? This is to close #133

@BYK
Copy link
Member Author

BYK commented Aug 27, 2024

Seemingly best way forward:

  • Use IndexedDB with expiry as shown in https://stackoverflow.com/a/35518068/90297
  • On initialization (afterAllSetup), expire all stored and expired events, send rest to Spotlight
  • Store each envelope in beforeSend hook before forwarding to Spotlight

@Lms24
Copy link
Member

Lms24 commented Aug 28, 2024

Why do we need to care about previously expired events? I'm not yet sure I understand why we'd need to store anything in IndexdDB. Here's what I'm currently thinking:

  1. Spotlight Overlay and Sentry SDK (with spotlight integration) intialize on page load
  2. Sentry SDK sends event
  3. Spotlight Sentry integration's beforeEnvelope listener is invoked and forwards the event via trigger('event',...)
  4. Event appears in spotlight
  5. When page is reloaded/hard navigation to next step -> back to step 1

I guess the only advantage we'd get with storing events is that we can show events from past page loads. Which is probably not always what we/users want but I can see it being helpful. If that's the goal then let's do it but IMO, this is something we should handle within spotlight and independent of if the event came in from the sidecar or from the event target.

@Lms24 Lms24 closed this Aug 28, 2024
@Lms24 Lms24 reopened this Aug 28, 2024
@Lms24
Copy link
Member

Lms24 commented Aug 28, 2024

whoops, sorry for the accidental close!

@BYK
Copy link
Member Author

BYK commented Aug 28, 2024

I guess the only advantage we'd get with storing events is that we can show events from past page loads. Which is probably not always what we/users want but I can see it being helpful. If that's the goal then let's do it but IMO, this is something we should handle within spotlight and independent of if the event came in from the sidecar or from the event target.

This is the current state anyway. Sidecar stores all past events (and without expiry which we may wanna address in the future due to memory concerns), and replays them as the first thing when a connection is made. When a user goes through pages or reloads, the events persist. In my own testing, I was also surprised when they were missing.

Regarding at which level this should be done, I agree it makes sense to move it to Spotlight core so I'll tie this in to the new manual event trigger system.

@BYK BYK marked this pull request as ready for review August 28, 2024 12:19
Copy link
Member

@Lms24 Lms24 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sounds good to me! Though I'm a bit concerned with the TS bump (see comments). Given 5.4 isn't that old yet, I suggest we think twice if we need to bump it. I think in this case, rewriting Promise.withResolvers should be doable. If you still want to bump, we can of course also cut a major.

packages/overlay/package.json Outdated Show resolved Hide resolved
packages/overlay/src/lib/db.ts Outdated Show resolved Hide resolved
@BYK BYK requested a review from Lms24 August 28, 2024 14:36
@BYK BYK enabled auto-merge (squash) August 28, 2024 14:38
@BYK BYK disabled auto-merge August 28, 2024 14:46
@BYK BYK enabled auto-merge (squash) August 28, 2024 14:46
Copy link
Member

@Lms24 Lms24 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM! Thanks for making the changes!

@BYK BYK merged commit 4acbad0 into main Aug 28, 2024
13 checks passed
@BYK BYK deleted the byk/feat/fe-only-sentry-integration branch August 28, 2024 15:04
BYK pushed a commit that referenced this pull request Sep 2, 2024
This PR was opened by the [Changesets
release](https://github.com/changesets/action) GitHub action. When
you're ready to do a release, you can merge this and publish to npm
yourself or [setup this action to publish
automatically](https://github.com/changesets/action#with-publishing). If
you're not ready to do a release yet, that's fine, whenever you add more
changesets to main, this PR will be updated.


# Releases
## @spotlightjs/overlay@2.4.0

### Minor Changes

- Add no-sidecar Sentry SDK integration for Spotlight overlay
([#509](#509))

- Add direct event ingestion through
`Spotlight.sendEvent('<content-type>', <event>)` to allow sending events
without
the ([#508](#508)) sidecar

### Patch Changes

- Fix stacktraces are not reversed sometimes (appearing in wrong order)
    ([#513](#513))

## @spotlightjs/astro@2.1.7

### Patch Changes

-   Updated dependencies \[]:
    -   @spotlightjs/spotlight@2.3.2

## @spotlightjs/electron@1.1.7

### Patch Changes

-   Updated dependencies

\[[`4acbad0ac4e5dc5a466af13ab2de50169bf8867b`](4acbad0),

[`50135855e46c67c44d960c0ce0c22e001abcf982`](5013585),

[`365ab8a1c085cf52a6620c0b8438eac44967f70f`](365ab8a)]:
    -   @spotlightjs/overlay@2.4.0

## @spotlightjs/spotlight@2.3.2

### Patch Changes

-   Updated dependencies

\[[`4acbad0ac4e5dc5a466af13ab2de50169bf8867b`](4acbad0),

[`50135855e46c67c44d960c0ce0c22e001abcf982`](5013585),

[`365ab8a1c085cf52a6620c0b8438eac44967f70f`](365ab8a)]:
    -   @spotlightjs/overlay@2.4.0

Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants