-
Notifications
You must be signed in to change notification settings - Fork 2
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 VisynEvents to send global events, incl. better Sentry integration #757
base: develop
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
PR Overview
This PR introduces a typed event mechanism ("VisynEvents") to replace and augment the legacy global event handling for key application events such as Sentry initialization and user session changes. Key changes include:
- Adding new hooks (useVisynEventCallback and useVisynEventValue) to listen to typed events.
- Defining the VisynEventMap and supporting functions (dispatchVisynEvent, addVisynEventListener, removeVisynEventListener) for global event dispatching.
- Migrating existing event usage (in UserSession, SessionWatcher, VisynAppProvider, etc.) from the legacy globalEventHandler mechanism to the new VisynEvents system.
Reviewed Changes
File | Description |
---|---|
src/hooks/useVisynEventValue.tsx | New hook to subscribe to event values via the new mechanism. |
src/hooks/useVisynEventCallback.tsx | New hook to listen for event triggers using a stable callback. |
src/app/VisynEvents.ts | Defines the typed event interface and helper functions. |
src/demo/index.initialize.tsx | Demonstrates usage of sending and listening to a sentryInitialized event. |
src/security/UserSession.ts | Migrates user login/logout events to use dispatchVisynEvent. |
src/hooks/useVisynUser.ts | Simplifies user retrieval by leveraging the updated VisynAppContext. |
src/base/event.ts | Marks legacy event handling APIs as deprecated. |
src/app/VisynAppProvider.ts | Updates Sentry initialization and user session propagation to use new events. |
src/security/watcher.ts | Adjusts session watcher to listen to new user events. |
src/demo/MainApp.tsx | Switches from the old context hook to the new useVisynUser hook. |
Copilot reviewed 12 out of 12 changed files in this pull request and generated no comments.
51417d9
to
baf812a
Compare
29d932e
to
8982982
Compare
Developer Checklist (Definition of Done)
Issue
UI/UX/Vis
Code
PR
release: minor
) to this PR following semverCloses #...
)Summary of changes
Sentry.init
event (both in React but also globally). We previously had theglobalEventHandler
mechanism, but that is completely untyped and uses a custom event system (inspired by jQuery). The modern way to do this is viawindow.dispatchEvent
, and theVisynEvent
is just a typed wrapper around it.useVisynUser
,watcher
, ... to the new mechanism, while keeping the oldfire
in place to ensure backwards compatibility. Removes usage of session storage to store user, as that is not recommended and has been replaced in favor of a "memory" store, i.e. a variableuseVisynEventCallback
anduseVisynEventValue
to listen to the changes/values of the events.main_app
entrypoint to the server to finally give us a way of what the primary plugin is. With that, we can send proper Sentry release information.Screenshots
Additional notes for the reviewer(s)
Thanks for creating this pull request 🤗