This repository has been archived by the owner on Dec 30, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 386
feat(insights): add connectInsights connector [PART-2] #2217
Merged
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This was referenced Mar 22, 2019
tkrugg
force-pushed
the
feat-insights-2-connectInsights
branch
from
March 22, 2019 09:59
7f35e04
to
4bdde10
Compare
Deploy preview for react-instantsearch ready! Built with commit 7f35e04 https://deploy-preview-2217--react-instantsearch.netlify.com |
tkrugg
changed the title
feat(insights): add connectInsights connector
feat(insights): add connectInsights connector [PART-2]
Mar 22, 2019
Deploy preview for react-instantsearch ready! Built with commit 4dc11ef https://deploy-preview-2217--react-instantsearch.netlify.com |
tkrugg
force-pushed
the
feat-insights-2-connectInsights
branch
2 times, most recently
from
March 22, 2019 14:23
6e74bac
to
5d66c8f
Compare
packages/react-instantsearch-core/src/connectors/connectInsights.ts
Outdated
Show resolved
Hide resolved
packages/react-instantsearch-core/src/connectors/connectInsights.ts
Outdated
Show resolved
Hide resolved
tkrugg
force-pushed
the
feat-insights-1-hits
branch
from
March 24, 2019 11:17
a1e1a66
to
24327e7
Compare
tkrugg
force-pushed
the
feat-insights-2-connectInsights
branch
2 times, most recently
from
March 24, 2019 12:23
8ab8132
to
e9029ea
Compare
samouss
suggested changes
Mar 25, 2019
packages/react-instantsearch-core/src/connectors/__tests__/connectInsights.ts
Outdated
Show resolved
Hide resolved
packages/react-instantsearch-core/src/connectors/connectInsights.ts
Outdated
Show resolved
Hide resolved
packages/react-instantsearch-core/src/connectors/connectInsights.ts
Outdated
Show resolved
Hide resolved
packages/react-instantsearch-core/src/connectors/connectInsights.ts
Outdated
Show resolved
Hide resolved
tkrugg
force-pushed
the
feat-insights-1-hits
branch
2 times, most recently
from
March 25, 2019 14:39
58e837b
to
6929935
Compare
This connector is to be used on the hitComponent provided to <Hits /> and <InfiniteHits /> **Usage**: ```tsx // window.aa is the insightsClient const Product = ({ hit, insights }) => <span /> const ProductWithInsights = connectInsights(aa)(Product) <Hits hitComponent={ProductWithInsights} /> ``` ```tsx const Product = ({ hit, insights }) => ( <> <a href={`/product/${hit.objectID}/?queryID=${hit.__queryID}`}> {hit.name} </a> <button onClick={() => insights("clickedObjectIDsAfterSearch", {"eventName": "Add to cart"})}> Add to Cart </button> <button onClick={() => insights("convertedObjectIDsAfterSearch", {"eventName": "Add to cart"})}> Add to Cart </button> </> ) ``` This sends to the API ```js aa('clickedObjectIDsAfterSearch', { eventName: "Add to cart", index: "...", // infered queryID: [hit.__queryID], objectIDs: [hit.objectID], positions: [hit.__position], }) aa('convertedObjectIDsAfterSearch', { eventName: "Add to cart", index: "...", // infered queryID: [hit.__queryID], objectIDs: [hit.objectID], }) ```
tkrugg
force-pushed
the
feat-insights-2-connectInsights
branch
from
March 25, 2019 14:40
e9029ea
to
3f79bc6
Compare
remove Without<InsightsClientPayload, 'eventName' | 'positions'>
tkrugg
force-pushed
the
feat-insights-2-connectInsights
branch
from
March 27, 2019 12:05
b53006c
to
2eb25d4
Compare
tkrugg
force-pushed
the
feat-insights-2-connectInsights
branch
from
March 27, 2019 13:42
9158a4d
to
449066a
Compare
samouss
suggested changes
Mar 28, 2019
packages/react-instantsearch-core/src/connectors/__tests__/connectHitsInsights.ts
Outdated
Show resolved
Hide resolved
packages/react-instantsearch-core/src/connectors/connectHitsInsights.ts
Outdated
Show resolved
Hide resolved
samouss
approved these changes
Mar 29, 2019
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.
You have to increase the size for two bundle. I usually take the .25
above.
tkrugg
added a commit
that referenced
this pull request
Apr 1, 2019
* feat(insights): compute insights data in connectHits adds __positions and __queryID to every hit * feedback: move helper methods to utils.js * feedback: rename hits to hitsWithPositions and hitsWithPositionsAndQueryID * feat(insights): add connectInsights connector [PART-2] (#2217) * feat(insights): add connectInsights connector This connector is to be used on the hitComponent provided to <Hits /> and <InfiniteHits /> **Usage**: ```tsx // window.aa is the insightsClient const Product = ({ hit, insights }) => <span /> const ProductWithInsights = connectInsights(aa)(Product) <Hits hitComponent={ProductWithInsights} /> ``` ```tsx const Product = ({ hit, insights }) => ( <> <a href={`/product/${hit.objectID}/?queryID=${hit.__queryID}`}> {hit.name} </a> <button onClick={() => insights("clickedObjectIDsAfterSearch", {"eventName": "Add to cart"})}> Add to Cart </button> <button onClick={() => insights("convertedObjectIDsAfterSearch", {"eventName": "Add to cart"})}> Add to Cart </button> </> ) ``` This sends to the API ```js aa('clickedObjectIDsAfterSearch', { eventName: "Add to cart", index: "...", // infered queryID: [hit.__queryID], objectIDs: [hit.objectID], positions: [hit.__position], }) aa('convertedObjectIDsAfterSearch', { eventName: "Add to cart", index: "...", // infered queryID: [hit.__queryID], objectIDs: [hit.objectID], }) ``` * feat(insights): add insights example to Hits and InfiniteHits stories * feedback: simplify types remove Without<InsightsClientPayload, 'eventName' | 'positions'> * feedback: fix error message thrown on unsupported method * feedback: simplified tests * feedback: clarify skipping of elements in infiniteHits tests on hitPerPage change * renamed connectInsights to connectHitsInsights * feedback: decontruct all props used from results for consistency * feedback: using toEqual * feedback: rename connectHitsInsights to connectHitInsights * feedback: expose connectHitInsights from dom and native * feedback: sort imports * feedback: add .25 to react-instantsearc & react-instantsearch-dom bundle sizes
tkrugg
added a commit
that referenced
this pull request
Apr 2, 2019
* feat(insights): add utility functions addAbsolutePositions & addQueryID * feat(insights): compute insights data in connectInfiniteHits adds __positions and __queryID to every hit * feedback: move helper methods to utils.js * feedback: rename hits to hitsWithPositions and hitsWithPositionsAndQueryID$ * feedback: revert sorting of lodash imports * feedback: curly styles * feat(insights): compute insights data in connectHits [PART-1] (#2216) * feat(insights): compute insights data in connectHits adds __positions and __queryID to every hit * feedback: move helper methods to utils.js * feedback: rename hits to hitsWithPositions and hitsWithPositionsAndQueryID * feat(insights): add connectInsights connector [PART-2] (#2217) * feat(insights): add connectInsights connector This connector is to be used on the hitComponent provided to <Hits /> and <InfiniteHits /> **Usage**: ```tsx // window.aa is the insightsClient const Product = ({ hit, insights }) => <span /> const ProductWithInsights = connectInsights(aa)(Product) <Hits hitComponent={ProductWithInsights} /> ``` ```tsx const Product = ({ hit, insights }) => ( <> <a href={`/product/${hit.objectID}/?queryID=${hit.__queryID}`}> {hit.name} </a> <button onClick={() => insights("clickedObjectIDsAfterSearch", {"eventName": "Add to cart"})}> Add to Cart </button> <button onClick={() => insights("convertedObjectIDsAfterSearch", {"eventName": "Add to cart"})}> Add to Cart </button> </> ) ``` This sends to the API ```js aa('clickedObjectIDsAfterSearch', { eventName: "Add to cart", index: "...", // infered queryID: [hit.__queryID], objectIDs: [hit.objectID], positions: [hit.__position], }) aa('convertedObjectIDsAfterSearch', { eventName: "Add to cart", index: "...", // infered queryID: [hit.__queryID], objectIDs: [hit.objectID], }) ``` * feat(insights): add insights example to Hits and InfiniteHits stories * feedback: simplify types remove Without<InsightsClientPayload, 'eventName' | 'positions'> * feedback: fix error message thrown on unsupported method * feedback: simplified tests * feedback: clarify skipping of elements in infiniteHits tests on hitPerPage change * renamed connectInsights to connectHitsInsights * feedback: decontruct all props used from results for consistency * feedback: using toEqual * feedback: rename connectHitsInsights to connectHitInsights * feedback: expose connectHitInsights from dom and native * feedback: sort imports * feedback: add .25 to react-instantsearc & react-instantsearch-dom bundle sizes
francoischalifour
pushed a commit
that referenced
this pull request
Apr 8, 2019
* feat(insights): add utility functions addAbsolutePositions & addQueryID * feat(insights): compute insights data in connectInfiniteHits adds __positions and __queryID to every hit * feedback: move helper methods to utils.js * feedback: rename hits to hitsWithPositions and hitsWithPositionsAndQueryID$ * feedback: revert sorting of lodash imports * feedback: curly styles * feat(insights): compute insights data in connectHits [PART-1] (#2216) * feat(insights): compute insights data in connectHits adds __positions and __queryID to every hit * feedback: move helper methods to utils.js * feedback: rename hits to hitsWithPositions and hitsWithPositionsAndQueryID * feat(insights): add connectInsights connector [PART-2] (#2217) * feat(insights): add connectInsights connector This connector is to be used on the hitComponent provided to <Hits /> and <InfiniteHits /> **Usage**: ```tsx // window.aa is the insightsClient const Product = ({ hit, insights }) => <span /> const ProductWithInsights = connectInsights(aa)(Product) <Hits hitComponent={ProductWithInsights} /> ``` ```tsx const Product = ({ hit, insights }) => ( <> <a href={`/product/${hit.objectID}/?queryID=${hit.__queryID}`}> {hit.name} </a> <button onClick={() => insights("clickedObjectIDsAfterSearch", {"eventName": "Add to cart"})}> Add to Cart </button> <button onClick={() => insights("convertedObjectIDsAfterSearch", {"eventName": "Add to cart"})}> Add to Cart </button> </> ) ``` This sends to the API ```js aa('clickedObjectIDsAfterSearch', { eventName: "Add to cart", index: "...", // infered queryID: [hit.__queryID], objectIDs: [hit.objectID], positions: [hit.__position], }) aa('convertedObjectIDsAfterSearch', { eventName: "Add to cart", index: "...", // infered queryID: [hit.__queryID], objectIDs: [hit.objectID], }) ``` * feat(insights): add insights example to Hits and InfiniteHits stories * feedback: simplify types remove Without<InsightsClientPayload, 'eventName' | 'positions'> * feedback: fix error message thrown on unsupported method * feedback: simplified tests * feedback: clarify skipping of elements in infiniteHits tests on hitPerPage change * renamed connectInsights to connectHitsInsights * feedback: decontruct all props used from results for consistency * feedback: using toEqual * feedback: rename connectHitsInsights to connectHitInsights * feedback: expose connectHitInsights from dom and native * feedback: sort imports * feedback: add .25 to react-instantsearc & react-instantsearch-dom bundle sizes
Haroenv
pushed a commit
that referenced
this pull request
Apr 9, 2019
* feat(insights): add utility functions addAbsolutePositions & addQueryID * feat(insights): compute insights data in connectInfiniteHits adds __positions and __queryID to every hit * feedback: move helper methods to utils.js * feedback: rename hits to hitsWithPositions and hitsWithPositionsAndQueryID$ * feedback: revert sorting of lodash imports * feedback: curly styles * feat(insights): compute insights data in connectHits [PART-1] (#2216) * feat(insights): compute insights data in connectHits adds __positions and __queryID to every hit * feedback: move helper methods to utils.js * feedback: rename hits to hitsWithPositions and hitsWithPositionsAndQueryID * feat(insights): add connectInsights connector [PART-2] (#2217) * feat(insights): add connectInsights connector This connector is to be used on the hitComponent provided to <Hits /> and <InfiniteHits /> **Usage**: ```tsx // window.aa is the insightsClient const Product = ({ hit, insights }) => <span /> const ProductWithInsights = connectInsights(aa)(Product) <Hits hitComponent={ProductWithInsights} /> ``` ```tsx const Product = ({ hit, insights }) => ( <> <a href={`/product/${hit.objectID}/?queryID=${hit.__queryID}`}> {hit.name} </a> <button onClick={() => insights("clickedObjectIDsAfterSearch", {"eventName": "Add to cart"})}> Add to Cart </button> <button onClick={() => insights("convertedObjectIDsAfterSearch", {"eventName": "Add to cart"})}> Add to Cart </button> </> ) ``` This sends to the API ```js aa('clickedObjectIDsAfterSearch', { eventName: "Add to cart", index: "...", // infered queryID: [hit.__queryID], objectIDs: [hit.objectID], positions: [hit.__position], }) aa('convertedObjectIDsAfterSearch', { eventName: "Add to cart", index: "...", // infered queryID: [hit.__queryID], objectIDs: [hit.objectID], }) ``` * feat(insights): add insights example to Hits and InfiniteHits stories * feedback: simplify types remove Without<InsightsClientPayload, 'eventName' | 'positions'> * feedback: fix error message thrown on unsupported method * feedback: simplified tests * feedback: clarify skipping of elements in infiniteHits tests on hitPerPage change * renamed connectInsights to connectHitsInsights * feedback: decontruct all props used from results for consistency * feedback: using toEqual * feedback: rename connectHitsInsights to connectHitInsights * feedback: expose connectHitInsights from dom and native * feedback: sort imports * feedback: add .25 to react-instantsearc & react-instantsearch-dom bundle sizes
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
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.
Summary
This connector is to be used on the hitComponent provided to and
Usage:
This sends to the API
Result
Test here:
Global Outline