-
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
fix(insights): send extra parameters only for applicable versions #5558
fix(insights): send extra parameters only for applicable versions #5558
Conversation
still to do: update tests
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 f2cac54:
|
packages/instantsearch.js/src/middlewares/createInsightsMiddleware.ts
Outdated
Show resolved
Hide resolved
@@ -138,7 +138,7 @@ export function _buildEventPayloadsForHits({ | |||
widgetType, | |||
eventType, | |||
payload: { | |||
eventName, | |||
eventName: eventName || 'Hit Converted', |
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.
alternatively eventName could be required in the type when it's click or convert, but not sure if that can easily be done
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 could maybe have sendEventForHits
satisfy both a custom payload signature and type, hit, eventName
? For now though, having those defaults works for me.
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, I prefer defaults too, as typescript types aren't enforced at runtime, meaning there will be more valid events.
@@ -138,7 +138,7 @@ export function _buildEventPayloadsForHits({ | |||
widgetType, | |||
eventType, | |||
payload: { | |||
eventName, | |||
eventName: eventName || 'Hit Converted', |
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 could maybe have sendEventForHits
satisfy both a custom payload signature and type, hit, eventName
? For now though, having those defaults works for me.
Summary
In v2, pre 2.4.0 sendEvent is variadic, meaning that the "extra parameters" were sent as an extra network request.
This wasn't clear in the tests, as we were asserting we were sending two arguments to search-insights, but possibly we could have asserted what actual network request was sent. That would have required a whole set of search-insights versions as dependency, which seems overly complex to me.
Result