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

Editor Stats - track core global styles updates & saves #53801

Merged
merged 34 commits into from
Jun 29, 2021

Conversation

Addison-Stavlo
Copy link
Contributor

@Addison-Stavlo Addison-Stavlo commented Jun 17, 2021

Changes proposed in this Pull Request

Adds tracking for global styles update and save events (wpcom_block_editor_global_styles_update and wpcom_block_editor_global_styles_save). Unfortunately, core Global Styles seems to update through useEntityProp (which in turn uses updateEntityRecord), which requires passing the entire content object of Global Styles and not only the items that have changed. This means if we want to track individual changes we need to compare the updated content object to the original content object.

Here we attempt to dissect the changes made to wp_global_styles and map them into events with the following properties:

  • block_type - the block name if the change is to an individual block style or setting.
  • section - the type of style being updated (color, typography, etc.)
  • field - the property being changed (text, background, fontSize, fontFamily, etc.)
  • field_value - the value of the property being changed. This is currently populated as reset if the field is removed. (is this better than just not having a field value in this case?)
  • element_type - The element type the setting corresponds to. Currently I only see this as link, but given the structure of the content object I think its important we leave this property as case other items are added in this way (span, etc?).
  • palette_slug - Slug of the color palette value that was updated.

Some examples of how these event properties populate in GS update events (note any global properties such as blog_id, editor_type, etc. are also included):

  • Changing text color: { section: "color", field: "text", field_value: "var:preset|color|green" }
  • Changing background color: { section: "color", field: "background", field_value: "var:preset|color|green" }
  • Changing a typography setting: { section: "typography", field: "fontSize", field_value: "20px" }
  • Returning to 'default' on a setting: { section: "typography", field: "fontSize", field_value: "reset" }
  • Changing link text color: { element_type: "link", section: "color", field: "text", field_value: "var:preset|color|green" }
  • Changing a color palette setting: { section: "color", field: "palette", field_value: "#3ec71a", palette_slug: "green"}

Performing any of these actions at the individual block level will also add the block_type property (ex block_type: "core/buttons")

Testing instructions

  • Follow steps to enable tracking debugging at PCYsg-nrf-p2
  • Open the site editor, change various global styles options and verify the wpcom_block_editor_global_styles_update tracks events follow the format noted above.
  • Save the global styles changes and verify the wpcom_block_editor_global_styles_save tracks events follow the format above.

Related to #53410

@Addison-Stavlo Addison-Stavlo added [Feature] Stats Everything related to our analytics product at /stats/ [Goal] Full Site Editing labels Jun 17, 2021
@Addison-Stavlo Addison-Stavlo self-assigned this Jun 17, 2021
@matticbot
Copy link
Contributor

This PR modifies the release build for editing-toolkit

To test your changes on WordPress.com, run install-plugin.sh editing-toolkit add/track-site-editor-global-styles-updates on your sandbox.

To deploy your changes after merging, see the documentation: PCYsg-mMA-p2

@matticbot matticbot added the [Status] Needs Review The PR is ready for review. This also triggers e2e canary tests and wp-desktop tests automatically. label Jun 17, 2021
@matticbot
Copy link
Contributor

matticbot commented Jun 17, 2021

@Addison-Stavlo Addison-Stavlo requested review from Copons and a team June 17, 2021 19:33
@matticbot
Copy link
Contributor

This PR does not affect the size of JS and CSS bundles shipped to the user's browser.

Generated by performance advisor bot at iscalypsofastyet.com.

@Addison-Stavlo Addison-Stavlo changed the title track color, typography, and basic block settings Editor Stats - track core global styles updates Jun 18, 2021
@matticbot
Copy link
Contributor

This PR modifies the release build for wpcom-block-editor

To test your changes on WordPress.com, run install-plugin.sh wpcom-block-editor add/track-site-editor-global-styles-updates on your sandbox.

To deploy your changes after merging, see the documentation: PCYsg-l4k-p2

@Addison-Stavlo Addison-Stavlo marked this pull request as ready for review June 18, 2021 19:17
@david-szabo97 david-szabo97 force-pushed the add/track-site-editor-global-styles-header-click branch from e5923db to 1539fd1 Compare June 21, 2021 09:06
@Addison-Stavlo Addison-Stavlo requested review from scinos, WunderBart and a team as code owners June 21, 2021 09:06
Base automatically changed from add/track-site-editor-global-styles-header-click to trunk June 21, 2021 09:49
@david-szabo97
Copy link
Contributor

So far looking good! I was happy to see you moved on to a deep diff algorithm rather than typing out all the cases 😄

I think we should hook this up to saveEntityRecord instead of editEntityRecord. So we only track actually saved changes.

@Addison-Stavlo Addison-Stavlo changed the title Editor Stats - track core global styles updates Editor Stats - track core global styles updates & saves Jun 22, 2021
@Addison-Stavlo
Copy link
Contributor Author

Addison-Stavlo commented Jun 22, 2021

Updated, this should be working for both update and save events for global styles. 😅

@matticbot
Copy link
Contributor

This PR modifies the release build for notifications

To test your changes on WordPress.com, run install-plugin.sh notifications add/track-site-editor-global-styles-updates on your sandbox.

To deploy your changes after merging, see the documentation: PCYsg-elI-p2

Copy link
Contributor Author

@Addison-Stavlo Addison-Stavlo left a comment

Choose a reason for hiding this comment

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

Tests for both update and save events are now in place.

Copy link
Member

@WunderBart WunderBart left a comment

Choose a reason for hiding this comment

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

Looks good from the E2E perspective! 🚀

Copy link
Contributor

@david-szabo97 david-szabo97 left a comment

Choose a reason for hiding this comment

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

This is a huge PR 😄 E2E test files' lines are growing fast.

Works as expected ✅ Thanks for working on this!

@Addison-Stavlo Addison-Stavlo merged commit 4edfb08 into trunk Jun 29, 2021
@Addison-Stavlo Addison-Stavlo deleted the add/track-site-editor-global-styles-updates branch June 29, 2021 13:26
@github-actions github-actions bot removed the [Status] Needs Review The PR is ready for review. This also triggers e2e canary tests and wp-desktop tests automatically. label Jun 29, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[Feature] Stats Everything related to our analytics product at /stats/ [Goal] Full Site Editing
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants