-
Notifications
You must be signed in to change notification settings - Fork 3.9k
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(js): js sdk preferences #5701
Conversation
async getPreferences({ | ||
level = PreferenceLevelEnum.TEMPLATE, | ||
}: { | ||
level?: `${PreferenceLevelEnum}`; | ||
}): Promise<Array<IUserPreferenceSettings | IUserGlobalPreferenceSettings>> { | ||
return this.httpClient.get(`/widgets/preferences/${level}`); | ||
} | ||
|
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.
We provide newer APIs but it wasn't exposed with this ApiService class.
export const mapPreference = (apiPreference: { | ||
template?: TODO; | ||
preference: { | ||
enabled: boolean; | ||
channels: { | ||
email?: boolean; | ||
sms?: boolean; | ||
in_app?: boolean; | ||
chat?: boolean; | ||
push?: boolean; | ||
}; | ||
overrides?: ChannelPreferenceOverride[]; | ||
}; | ||
}): Preference => { | ||
const { template: workflow, preference } = apiPreference; | ||
const hasWorkflow = workflow !== undefined; | ||
const level = hasWorkflow ? PreferenceLevel.TEMPLATE : PreferenceLevel.GLOBAL; | ||
|
||
return new Preference({ | ||
level, | ||
enabled: preference.enabled, | ||
channels: preference.channels, | ||
workflow, | ||
overrides: preference.overrides, | ||
}); | ||
}; |
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.
Map server preference to the one that we use in the module with a better interface.
❌ Deploy Preview for novu-design failed. Why did it fail? →
|
payload: Record<string, unknown>; | ||
overrides: Record<string, unknown>; | ||
readonly _id: string; | ||
readonly _feedId?: string | null; |
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.
We can remove this, notifications will always belong to a feed array.
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.
but you might want to know to which feed it belongs when using individually
name: string; | ||
critical: boolean; | ||
tags?: string[]; | ||
identifier: string; |
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.
What's the difference between an identifier
and the _id
?
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.
identifier
is used for the trigger, _id
is internal Mongo id
export type ChannelPreference = { | ||
email?: boolean; | ||
sms?: boolean; | ||
in_app?: boolean; |
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.
in_app?: boolean; | |
inApp?: boolean; |
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.
this is due to internal implementation and will require changes across the stack :(
packages/js/src/types.ts
Outdated
push?: boolean; | ||
}; | ||
|
||
export type ChannelPreferenceOverride = { |
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.
This seems overly complicated for the current frontend needs and is driven by the current state of the API. Let's build the DX on an ideal scenario and hide the API tech-debt with internal helper methods. Then we will update the API.
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.
I think that we can remove it from the new Preference class for now, not even sure if that is used often by clients.
9448d67
to
e62dd85
Compare
713d403
to
708b237
Compare
b57c777
to
9b0473d
Compare
69aa508
to
4fd00de
Compare
4fd00de
to
ab164a5
Compare
4ede520
to
68987c2
Compare
✅ Deploy Preview for dev-web-novu ready!
To edit notification comments on pull requests, go to your Netlify site configuration. |
* feat(js): js sdk feeds module (#5688) * feat(js): improve the package json exports and tsup config * feat(js): lazy session initialization and interface fixes * feat(js): js sdk feeds module * feat(js): js sdk preferences (#5701) * feat(js): js sdk preferences * feat(js): handling the web socket connection and events (#5704) * feat(js): handling the web socket connection and events * feat: ui solid --------- Co-authored-by: Biswajeet Das <[email protected]> * fix: caching for session initialize * fix: worker --------- Co-authored-by: Paweł Tymczuk <[email protected]> Co-authored-by: Biswajeet Das <[email protected]> Co-authored-by: Dima Grossman <[email protected]>
What changed? Why was the change needed?
The Preferences module for JS SDK.
Screenshots
Expand for optional sections
Related enterprise PR
Special notes for your reviewer