-
Notifications
You must be signed in to change notification settings - Fork 4.2k
feat(js,react): context-aware inbox session fixes NV-6789 #9344
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
Conversation
✅ Deploy Preview for dashboard-v2-novu-staging canceled.
|
f3f91ec
to
ee42b15
Compare
@coderabbitai summary |
✅ Actions performedSummary regeneration triggered. |
WalkthroughAdds context propagation to session initialization and exposes contextKeys in responses. Server DTO and use case now include contextKeys. JS SDK accepts optional context, forwards it to /inbox/session, and exposes context and contextKeys. React and UI layers accept and pass context, and UI context provides contextKeys from the initialized session. Changes
Sequence Diagram(s)sequenceDiagram
participant App as React App
participant React as @novu/react
participant JSSDK as @novu/js
participant API as /inbox/session API
participant Usecase as Session.usecase
participant DTO as SubscriberSessionResponseDto
App->>React: <Inbox context={...} />
React->>JSSDK: new Novu({ ..., context })
React->>JSSDK: session.initialize()
JSSDK->>API: POST /inbox/session { subscriberId, ..., context }
API->>Usecase: execute(request)
Usecase->>DTO: build response with contextKeys
DTO-->>API: { ..., contextKeys }
API-->>JSSDK: 200 OK { ..., contextKeys }
JSSDK-->>React: resolve initialize(data)
React-->>App: InboxContext provides contextKeys
note over App,React: UI can consume contextKeys from context
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~25 minutes Possibly related PRs
Suggested labels
Suggested reviewers
Poem
✨ Finishing touches
🧪 Generate unit tests (beta)
📜 Recent review detailsConfiguration used: CodeRabbit UI Review profile: CHILL Plan: Pro 📒 Files selected for processing (12)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
@novu/js
@novu/nextjs
novu
@novu/react
@novu/react-native
commit: |
}) => { | ||
const novu = useNovu(); | ||
const channelName = `nv_ws_connection:a=${novu.applicationIdentifier}:s=${novu.subscriberId}:e=${webSocketEvent}`; | ||
const channelName = `nv_ws_connection:a=${novu.applicationIdentifier}:s=${novu.subscriberId}:c=${novu.contextKey}:e=${webSocketEvent}`; |
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.
Context = session boundary - we open a new WS connection with separate JWT token for each context.
public get context() { | ||
return this.#session.context; | ||
} | ||
|
||
public get contextKey() { | ||
return buildContextKey(this.#session.context); | ||
} |
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.
The context
is passed to the Novu
constructor, so it is defined in the client code. I am not sure if it would be helpful to expose that.
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.
Yes thats true I just did it for the consistency with the other attributes.
What changed? Why was the change needed?
Screenshots
Expand for optional sections
Related enterprise PR
Special notes for your reviewer
Summary by CodeRabbit