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

Setup Redux middleware for analytics tracking #4066

Merged
merged 20 commits into from
Oct 27, 2021
Merged

Conversation

jhnstn
Copy link
Member

@jhnstn jhnstn commented Oct 1, 2021

Related PRs

Description

Fixes #4009. This adds the ability to send Redux actions over the RN bridge for processing on the host apps.

To test: See WPiOS and WPAndroid PRs.

PR submission checklist:

  • I have considered adding unit tests where possible.
  • I have considered if this change warrants user-facing release notes more info and have added them to RELEASE-NOTES.txt if necessary.

Includes tracking for block insertion
src/analytics/events.js Outdated Show resolved Hide resolved
src/analytics/trackers.js Outdated Show resolved Hide resolved
src/analytics/from-redux.js Outdated Show resolved Hide resolved
@peril-wordpress-mobile
Copy link

peril-wordpress-mobile bot commented Oct 1, 2021

Wanna run full suite of Android and iOS UI tests? Click here and 'Approve' CI job!

src/analytics/trackers.js Outdated Show resolved Hide resolved
Copy link
Member

@dcalhoun dcalhoun left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great work! Thank you for putting this together. 🙌🏻

I left a few comments, but most of them are personal preference and not blockers. The only blockers would be innerBlocks and that we need to make sure all the sibling branches ultimately align on things like the pattern of the string values sent to the host app. I would imagine we will wait to merge all of the PRs together after they are tested together.

I also tested this work (with a minor event name change from insertBlock to editor_block_inserted) against my current wordpress-mobile/WordPress-iOS#17243 and WordPress/gutenberg#35272 work — the event arrived in Tracks with the expected block_name property. 🎉

src/analytics/from-redux.js Outdated Show resolved Hide resolved
src/analytics/index.js Outdated Show resolved Hide resolved
src/analytics/trackers.js Outdated Show resolved Hide resolved
src/analytics/trackers.js Outdated Show resolved Hide resolved
src/analytics/trackers.js Outdated Show resolved Hide resolved
@jhnstn jhnstn marked this pull request as ready for review October 20, 2021 20:17
( { name } ) => ( { block_name: name } )
);
},
insertBlocks( blocks ) {
Copy link
Contributor

@mchowning mchowning Oct 25, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I can easily trigger insertBlock, but I'm not sure how to trigger insertBlocks from mobile. Any suggestions?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

From researching the usage of the insertBlocks action creator, it would appear splitting at the end of some rich text blocks causes a insertBlocks Redux action to trigger. E.g. placing a the cursor in a PullQuote block's citation input and pressing Return will trigger the action.

That said, neither WPAndroid or WPiOS implementations currently have sibling events defined for insertBlocks, so the resulting analytics event will not be sent. I plan to add the required sibling events.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Following up to share that my plan is to rename the editor_blocks_inserted event to editor_block_inserted rather than add sibling events to WPAndroid and WPiOS. This approach mimics what Calypso does, as both insertBlock and insertBlocks leverage the same event name.

To me, this approach makes more sense, as we our goal is tracking the insertion of a block. Whether the insertBlock or insertBlocks action creator is leveraged is implementation details. In fact, the insertBlock action calls insertBlocks itself.

Because we recursively track individual blocks inserted, there is no
value in tracking the implementation details of which action creator
triggers the resulting block inserted analytic event.

This mimics Calypso's approach and avoid leaking implementation details
into the analytic events.
@dcalhoun dcalhoun added this to the 1.65.0 (18.6) milestone Oct 26, 2021
@dcalhoun dcalhoun self-assigned this Oct 26, 2021
Copy link
Member

@dcalhoun dcalhoun left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🚀 LGTM. I verified functionality via wordpress-mobile/WordPress-Android#15406 (review).

@illusaen illusaen merged commit 26c44f9 into develop Oct 27, 2021
@illusaen illusaen deleted the add/analytics-tracking branch October 27, 2021 19:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Set up Redux Middleware in Gutenberg Mobile
4 participants