-
Notifications
You must be signed in to change notification settings - Fork 529
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(insights): automatically add insights middleware #5488
feat(insights): automatically add insights middleware #5488
Conversation
This pull request is automatically built and testable in CodeSandbox. To see build info of the built libraries, click here or the icon next to each commit SHA. Latest deployment of this branch, based on commit 3d7aa28:
|
Nice ! 🙌 |
4685922
to
de9bf32
Compare
5fc27cb
to
5b35140
Compare
the insights middleware is added now for downstream
5b35140
to
3d7aa28
Compare
// This is the default middleware, | ||
// any user-provided middleware will be added later and override this one. | ||
this.use(createInsightsMiddleware({ $$internal: true })); |
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.
something still needs to be fixed here, the script is always loaded from the internal middleware, even if users add a different middleware later (even right after). Not too sure how to fix that yet
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.
solved through #5493
function normalizeState(state: PlainSearchParameters) { | ||
const { clickAnalytics, userToken, ...rest } = state || {}; | ||
return rest; | ||
} |
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.
if infiniteHits is added before start, it's reading from the cache before the insights middleware is started, and thus it doesn't have clickAnalytics + userToken yet
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.
to solve this, we could change some things about the insights middleware to make sure we have the search parameters right away, even before init, but that's currently not possible yet (helper is null)
if (isMetadataEnabled()) { | ||
this.use(createMetadataMiddleware()); | ||
this.use(createMetadataMiddleware({ $$internal: true })); |
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.
Nitpick: this is technically always internal, it could be set statically in createMetadataMiddleware()
.
Summary
Automatically add the insights middleware
Result
FX-2248
clickAnalytics: true