-
Notifications
You must be signed in to change notification settings - Fork 138
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: Load surveys via RemoteConfig #1652
base: main
Are you sure you want to change the base?
Conversation
The latest updates on your projects. Learn more about Vercel for Git ↗︎
|
Size Change: -1.27 kB (-0.04%) Total Size: 3.23 MB
ℹ️ View Unchanged
|
|
||
private onSurveys(surveys: Survey[]) { | ||
this._loadedSurveys = surveys | ||
this._surveysEnabledRemotely = surveys.length > 0 |
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 _surveysEnabledRemotely
should be true
if surveys
isn't undefined, and empty is a valid state (no surveys but the API call has been made), otherwise it'd be semantically wrong, at least the naming.
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 thing is I actually think we should just ditch that property altogether. Server side that property is simply "are there surveys to load" but if we now include them in remtoe config I actually think that property is pointless...
(survey.conditions?.events && | ||
survey.conditions?.events?.values && | ||
survey.conditions?.events?.values?.length > 0) || |
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.
(survey.conditions?.events && | |
survey.conditions?.events?.values && | |
survey.conditions?.events?.values?.length > 0) || | |
(survey.conditions?.events?.values?.length > 0) || |
not needed the 2 checks since the last one is already using the safe operator ?.
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.
True. Just moved code but happy to improve it whilst im here
(survey.conditions?.actions && | ||
survey.conditions?.actions?.values && | ||
survey.conditions?.actions?.values?.length > 0) |
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.
(survey.conditions?.actions && | |
survey.conditions?.actions?.values && | |
survey.conditions?.actions?.values?.length > 0) | |
(survey.conditions?.actions?.values?.length > 0) |
Neil created this ticket which aims to improve the API perf., in case things are slow.
So I'd avoid breaking changes if possible. |
@@ -1285,13 +1285,13 @@ export class PostHog { | |||
} | |||
|
|||
/** Get list of all surveys. */ | |||
getSurveys(callback: SurveyCallback, forceReload = false): void { | |||
this.surveys.getSurveys(callback, forceReload) | |||
getSurveys(callback: SurveyCallback): void { |
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.
Removing forceReload
from public APIs will break customers that are using the methods directly.
Is there a reason to remove the forceReload
?
It'll contradict whats written here:
Surveys are requested on first load and then cached by default by the JavaScript SDK. If you want to force an API call to get an updated list of surveys, pass true to the forceReload parameter. You only need to do this if you want changed surveys to appear mid-session for users.
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.
Ewww - I wish we hadn't allowed people to do that tbh. But I can add it back in. We have a bug currently that causes multiple loads anyways
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 mean it's useful that people do not have to call the API directly, since the "API" mode is one of the supported presentation mode, so yeah I'd add it back, fixing the bug is the extra sauce :D
Changes
We have RemoteConfig loading that includes surveys so time to start using it!
Follow up
Checklist