Analytics: Fix recordTracksEvent import in analytics library docs #53526
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.
Changes proposed in this Pull Request
There are two ways to call
recordTracksEvent()
; one is by using the function directly from the@automattic/calypso-analytics
package, and the other is to use the calypso data-layer middleware by dispatching an action to redux. This is a little confusing because both the raw function and the redux action creator are calledrecordTracksEvents
, but they are defined in two different places.In #41125, an example was added to the README of the
@automattic/calypso-analytics
package to explain how to use the redux action creator rather than the raw function, but #47453 (accidentally, I think) broke that example. Using the code in the example will in fact throw an error since the exportedrecordTracksEvents
function has no return value and cannot be used as an action creator. This PR restores the correct example, which is not ideal because it references an import path in a separate npm package, but it is better than providing an example that is totally wrong.Testing instructions
None needed. Just verify that places that use
recordTracksEvents
inside a redux dispatch call are importing from the location in the corrected example.Eg:
wp-calypso/client/my-sites/checkout/composite-checkout/hooks/use-create-payment-complete-callback.tsx
Line 40 in 76f435d