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): Insights inside Instantsearch #3598
Merged
Merged
Commits on Apr 12, 2019
-
feat(Insights): integrate Insights (Click Analytics) with InstantSearch
feat(Insights): add withInsightsClient connector wrapper This PR adds a withInsightsClient which is an HOC for connectors. ```js const connectHitsWithInsightsClient = withInsightsClient(connectHits) ``` This connector will be used by default in the widget Hits and InfiniteHits to wrap connectHits and connectInfiniteHits respectively. When this PR is merged and released we can start using withInsightsClient in the flavours. feat(Insights): add template helpers feat(Insights): add withInsightsListener This commit adds withInsightsListener which - wraps Hits and InfiniteHits component, - listens to inner clicks targetting elements with data-insights attributes - calls the insights client exposed by `withInsightsClient` ```js const HitsWithInsightsListener = withInsightsListener(Hits) ``` feat(Insights): allow passing insightsClient to instantsearch instance feat(Insights): add listener to Hits feat(Insights): add listener to InfiniteHits feat(Insights): add storybook example for hits feat(Insights & typescript): type all the things extract *WithInsightsListeners components to upper scope rename withInsightsClient to withInsights feat(Insights): fix positions in infiniteScroll feat(Insights): extract addAbsolutePositions to make it connector responsibility unshorten variable name ev -> event rename isFirstRendering -> isFirstRender type mouse event avoid inline return clean unsused comment avoid inline return inline cast document.querySelector<HTMLElement> prettier things remove document maniputation in tests remove inferrable types in readDataAttributes use post modern typing type return values Apply suggestions from code review Co-Authored-By: tkrugg <tkrugg@users.noreply.github.com> add space before describe change inferPayload signature to use named params remove perf comment add space before Unmounter Apply suggestions from code review Co-Authored-By: tkrugg <tkrugg@users.noreply.github.com> Update src/lib/__tests__/insights-client-test.js Co-Authored-By: tkrugg <tkrugg@users.noreply.github.com> remove param mutation absolute imports before relative convert to typescript client and listener tests factorize Without inside 'types/utils' simplify types typo feedback: expose addAbsolutePosition in utils feedback: improved error message add type on serializedPayload Co-Authored-By: tkrugg <tkrugg@users.noreply.github.com> casting div.firstElementChild with as keyword Co-Authored-By: tkrugg <tkrugg@users.noreply.github.com> feedback: move casting on another line feedback: improve error message on incorrect data-insights-payload json string prettier all the things feedback: add type for Hits React component fix typescript file linting add query id feat(insights): add __queryID to connectHits & connectInfiniteHits simplified tests feat(insights): encode payload to base64 typo Co-Authored-By: tkrugg <tkrugg@users.noreply.github.com> typo Co-Authored-By: tkrugg <tkrugg@users.noreply.github.com> feedback: fix insightsClient defaulting to jest.fn() feedback: remove unused beforeEach feedback: group expect statements for payloads typo Co-Authored-By: tkrugg <tkrugg@users.noreply.github.com> feedback: add quotes around objectID Co-Authored-By: tkrugg <tkrugg@users.noreply.github.com> feedback: rename WidgetParams -> TWidgetParams feedback: move clickAnalytics: true to configure feedback: use toHaveBeenNthCalledWith feedback: remove extra check for insightClient callability feedback: remove proptypes fix: typo inline setup function fix: error message formatting Co-Authored-By: tkrugg <tkrugg@users.noreply.github.com> fix: error message formatting Co-Authored-By: tkrugg <tkrugg@users.noreply.github.com> fix: error message formatting Co-Authored-By: tkrugg <tkrugg@users.noreply.github.com> fix: error message formatting Co-Authored-By: tkrugg <tkrugg@users.noreply.github.com> fix: error message formatting Co-Authored-By: tkrugg <tkrugg@users.noreply.github.com> fix: error message formatting Co-Authored-By: tkrugg <tkrugg@users.noreply.github.com> fix: error message formatting Co-Authored-By: tkrugg <tkrugg@users.noreply.github.com> fix: error message formatting fix: error message formatting Co-Authored-By: tkrugg <tkrugg@users.noreply.github.com> fix: error message formatting Co-Authored-By: tkrugg <tkrugg@users.noreply.github.com> fix: error message formatting Co-Authored-By: tkrugg <tkrugg@users.noreply.github.com> fix: update snapshots after error message reformatting
-
-
-
-
-
feat(Insights): expose
insights
helper on instantsearch instanceThis is mimicking the way we allow usage for `highlight` and `snippet`. ```js Instantsearch.widgets.hits({ // ... templates: { item(hit) { return ` <h2> ${hit.name} </h2> <button ${ Instantsearch.insights('clickedObjectIDsAfterSearch', { eventName: "Add to favorite", objectIDs: [hit.objectID] }) }> Add to favorite </button> `; }, }, }); ```
Commits on Apr 15, 2019
-
feat(Insights): expose connectHitsWithInsights and connectInfiniteHit…
…sWithInsights The intention is to make it easier and more straight forward to create custom InfiniteHits and Hits with the connector. If we exposed `withInsights` directly, this is what we'd need to decide on a definitive name that implies it works only on Hits (like withHitsInsights) ```js const connectHitsWithInsights = Instantsearch.connectors.withHitsInsights(Instantsearch.connectors.connectHits); const connectInfiniteHitsWithInsights = Instantsearch.connectors.withHitsInsights(Instantsearch.connectors.connectInfiniteHits); ``` If we expose `connectHitsWithInsights` and `connectInfiniteHitsWithInsights` directly, we can keep `withInsights` totally private, and all custom components example are more simple.
-
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.