Skip to content
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

Merged

Conversation

Haroenv
Copy link
Contributor

@Haroenv Haroenv commented Mar 21, 2023

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

  • automatic search insights client is 2.4.0
  • only 2.4.0+, 1.10+ of search insights will send events with headers in

@codesandbox-ci
Copy link

codesandbox-ci bot commented Mar 21, 2023

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:

Sandbox Source
InstantSearch.js Configuration
react-instantsearch-app Configuration
example-react-instantsearch-hooks-default-theme Configuration
example-vue-instantsearch-default-theme Configuration

@Haroenv Haroenv requested review from dhayab, a team and aymeric-giraudet and removed request for a team March 22, 2023 11:13
@Haroenv Haroenv marked this pull request as ready for review March 22, 2023 11:13
@@ -138,7 +138,7 @@ export function _buildEventPayloadsForHits({
widgetType,
eventType,
payload: {
eventName,
eventName: eventName || 'Hit Converted',
Copy link
Contributor Author

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

Copy link
Member

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.

Copy link
Contributor Author

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',
Copy link
Member

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.

@Haroenv Haroenv requested a review from dhayab March 23, 2023 09:56
@Haroenv Haroenv merged commit 235313a into feat/automatic-insights Mar 23, 2023
@Haroenv Haroenv deleted the fix/automatic-insights-newest-version branch March 23, 2023 15:17
Haroenv added a commit that referenced this pull request Apr 18, 2023
)

* fix(insights): send extra parameters only for applicable versions

still to do: update tests

* test: impact of requiring version on tests

* move type
Haroenv added a commit that referenced this pull request Apr 24, 2023
)

* fix(insights): send extra parameters only for applicable versions

still to do: update tests

* test: impact of requiring version on tests

* move type
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants