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

Move "tracks" analytics into a shared calypso-analytics package #39001

Merged
merged 16 commits into from
Feb 6, 2020

Conversation

roo2
Copy link
Contributor

@roo2 roo2 commented Jan 21, 2020

Changes proposed in this Pull Request

  • Move tracks analytics into a shared package automattic/calypso-analytics.
  • Leave ad-tracking inside of lib/analytics, leave GA and refer tracking there for now
  • Update existing lib/analytics code to use the new automattic/calypso-analytics package

Testing instructions

  • load login page, should make same calls to pixel.wordpress.com as production does, all params present (pageview)
  • click login button, should make same calls as production (recordTracksEvent)
  • run unit tests (possibly add some where needed)
  • Add unit tests for recordTracksEvent
  • test Tracks Cookies are initialized
  • test GA still initialized (GA is only enabled in prod, not staging, need to enable it in development.json)
  • test GA tracking still work for events
  • test GA tracking still work on page loads
  • test mc bumpstat still works for page views and events (enabled in prod, enable mc_analytics_enabled and restart npm start)
  • test refer recordPageView
  • test when tracks is blocked (blocked stats.wp.com with ublock)
  • test that current user is being identified with hashed PII
  • test ad tracking, anonymous user id's are still generated correctly
  • a test to ensure that subscribers to analytics.recordEvent are still notified
  • Ensure initializeAnalytics and identifyUser call floodlight (window.gtag in ad-tracking.js) correctly

Fixes #38799

@roo2 roo2 added the [Goal] New Onboarding previously called Gutenboarding label Jan 21, 2020
@roo2 roo2 requested review from jsnajdr and andrewserong January 21, 2020 23:53
@roo2 roo2 requested review from a team as code owners January 21, 2020 23:53
@roo2 roo2 self-assigned this Jan 21, 2020
@matticbot
Copy link
Contributor

@roo2 roo2 changed the base branch from master to extract/signup-analytics January 21, 2020 23:53
@matticbot
Copy link
Contributor

matticbot commented Jan 22, 2020

Here is how your PR affects size of JS and CSS bundles shipped to the user's browser:

Webpack Runtime (~9 bytes removed 📉 [gzipped])

name      parsed_size           gzip_size
manifest       +110 B  (+0.1%)       -9 B  (-0.0%)

Webpack runtime for loading modules. It is included in the HTML page as an inline script. Is downloaded and parsed every time the app is loaded.

App Entrypoints (~38560 bytes added 📈 [gzipped])

name                   parsed_size            gzip_size
entry-login              +145619 B  (+16.2%)   +42792 B  (+18.2%)
entry-jetpack-cloud       -61638 B   (-4.0%)    -2410 B   (-0.6%)
entry-main                -61544 B   (-3.8%)    -2478 B   (-0.6%)
entry-gutenboarding        -1301 B   (-0.1%)     +179 B   (+0.0%)
entry-domains-landing       +909 B   (+0.1%)     +477 B   (+0.3%)

Common code that is always downloaded and parsed every time the app is loaded, no matter which route is used.

Sections (~191446 bytes removed 📉 [gzipped])

name                      parsed_size            gzip_size
gutenberg-editor            -127684 B  (-15.7%)   -30594 B  (-13.8%)
media                       -126864 B  (-26.2%)   -30458 B  (-24.2%)
posts-custom                -126818 B  (-31.8%)   -30508 B  (-30.4%)
posts                       -126805 B  (-31.6%)   -30516 B  (-30.2%)
post-editor                 -120369 B   (-6.0%)   -28582 B   (-5.3%)
theme                        -90627 B  (-26.7%)   -21637 B  (-24.5%)
plugins                      -69160 B  (-12.9%)    -7509 B   (-5.9%)
settings-writing             +62652 B  (+17.1%)   +15140 B  (+16.4%)
zoninator                    -38113 B  (-12.9%)    -6900 B   (-9.0%)
woocommerce                  -36509 B   (-1.8%)    -1704 B   (-0.3%)
auth                         -23856 B  (-57.1%)    -5135 B  (-49.6%)
purchases                     -7929 B   (-0.8%)    -1457 B   (-0.6%)
jetpack-connect               +7746 B   (+1.5%)    +1601 B   (+1.1%)
people                        +7734 B   (+2.3%)    +2201 B   (+2.6%)
domains                       +6696 B   (+0.8%)    +1783 B   (+0.9%)
stats                         -5416 B   (-0.7%)    -1091 B   (-0.6%)
checkout                      -5276 B   (-0.5%)     -889 B   (-0.3%)
reader                        -4157 B   (-1.1%)     -737 B   (-0.7%)
settings                      -4152 B   (-0.8%)     -789 B   (-0.6%)
comments                      -3867 B   (-0.8%)     -688 B   (-0.6%)
marketing                     -3572 B   (-0.9%)     -688 B   (-0.7%)
activity                      -3518 B   (-0.8%)     -650 B   (-0.6%)
themes                        -3166 B   (-1.0%)     -634 B   (-0.7%)
wp-super-cache                -3103 B   (-1.4%)     -398 B   (-0.7%)
concierge                     -3027 B   (-1.0%)     -343 B   (-0.5%)
checklist                     -2600 B   (-0.9%)     -469 B   (-0.6%)
plans                         -2566 B   (-0.6%)     -514 B   (-0.5%)
pages                         -2528 B   (-1.1%)     -525 B   (-0.8%)
home                          -2388 B   (-0.9%)     -425 B   (-0.6%)
hosting                       -2355 B   (-1.0%)     -426 B   (-0.7%)
email                         -2151 B   (-0.8%)     -387 B   (-0.5%)
account                       -2095 B   (-0.7%)     -463 B   (-0.6%)
settings-security             -2060 B   (-0.8%)     -409 B   (-0.6%)
customize                     -2028 B   (-1.2%)     -373 B   (-0.8%)
signup                        -1888 B   (-1.2%)    -1125 B   (-2.8%)
security                      -1855 B   (-0.5%)     -444 B   (-0.4%)
import                        -1828 B   (-0.9%)     -244 B   (-0.5%)
help                          -1735 B   (-0.4%)     -419 B   (-0.4%)
happychat                     -1726 B   (-0.7%)     -386 B   (-0.6%)
notification-settings         -1708 B   (-0.6%)     -424 B   (-0.5%)
settings-performance          -1699 B   (-0.8%)     -353 B   (-0.6%)
google-my-business            -1661 B   (-0.6%)     -360 B   (-0.5%)
export                        -1649 B   (-1.0%)     -301 B   (-0.7%)
settings-discussion           -1607 B   (-1.0%)     -351 B   (-0.8%)
earn                          -1557 B   (-0.6%)     +593 B   (+0.9%)
account-close                 -1555 B   (-0.6%)     -331 B   (-0.4%)
site-blocks                   -1305 B   (-0.5%)     -291 B   (-0.5%)
privacy                       -1207 B   (-0.5%)     -264 B   (-0.4%)
me                            -1202 B   (-0.6%)     -265 B   (-0.5%)
feature-upsell                -1125 B   (-0.8%)     -250 B   (-0.7%)
hello-dolly                    -982 B   (-1.0%)     -183 B   (-0.7%)
migrate                        -901 B   (-0.8%)     -135 B   (-0.4%)
accept-invite                  -873 B   (-0.5%)     -250 B   (-0.5%)
preview                        -838 B   (-0.9%)     -142 B   (-0.6%)
sensei                         -836 B   (-0.9%)     -128 B   (-0.5%)
sites                          -828 B   (-1.0%)     -133 B   (-0.6%)
devdocs                        -193 B   (-0.1%)      -84 B   (-0.2%)
domain-connect-authorize        -49 B   (-0.4%)       -3 B   (-0.1%)

Sections contain code specific for a given set of routes. Is downloaded and parsed only when a particular route is navigated to.

Async-loaded Components (~98107 bytes removed 📉 [gzipped])

name                                                         parsed_size             gzip_size
async-load-signup-steps-import-preview                         -132671 B   (-86.4%)   -29467 B   (-82.4%)
async-load-post-editor-media-modal                             -125768 B   (-31.8%)   -30181 B   (-29.6%)
async-load-design                                               -58757 B    (-3.2%)    -5192 B    (-1.2%)
async-load-design-playground                                    -57956 B    (-3.3%)    -3786 B    (-1.0%)
async-load-reader-site-stream                                   -53820 B   (-68.9%)   -13140 B   (-66.1%)
async-load-signup-steps-reader-landing                          -42258 B   (-78.7%)   -11146 B   (-78.2%)
async-load-my-sites-current-site-stale-cart-items-notice        -40956 B   (-50.1%)    -9416 B   (-45.0%)
async-load-signup-steps-theme-selection                         +24396 B  (+143.5%)    +5714 B  (+126.8%)
async-load-my-sites-site-settings-seo-settings-form             +22356 B    (+8.7%)    +6312 B    (+9.2%)
async-load-signup-steps-site-style                              +21167 B  (+241.1%)    +7306 B  (+283.5%)
async-load-featured-image                                       -19996 B   (-87.4%)    -5113 B   (-83.3%)
async-load-extensions-woocommerce-app-store-stats               +17659 B   (+69.8%)    +4669 B   (+62.4%)
async-load-post-editor-editor-post-formats-accordion            -12913 B   (-71.3%)    -3470 B   (-66.6%)
async-load-design-typography                                    -12271 B   (-69.0%)    -3167 B   (-65.3%)
async-load-signup-steps-about                                   +11515 B   (+32.9%)    +3106 B   (+32.6%)
async-load-signup-steps-site-or-domain                          +10393 B  (+119.6%)    +2864 B  (+111.1%)
async-load-signup-steps-site-picker                             -10343 B   (-54.1%)    -2874 B   (-52.8%)
async-load-signup-steps-domains                                  +9945 B    (+5.0%)    +2279 B    (+4.7%)
async-load-post-editor-editor-author                             -8702 B   (-32.5%)    -2675 B   (-33.9%)
async-load-docs-selectors                                        -8116 B   (-59.2%)    -1904 B   (-51.9%)
async-load-signup-steps-clone-jetpack                            -7726 B   (-42.7%)    -2163 B   (-43.5%)
async-load-extensions-woocommerce-app-store-stats-listview       -7658 B   (-32.7%)    -1955 B   (-30.1%)
async-load-extensions-woocommerce-app-store-stats-referrers      +6867 B   (+19.3%)    +1540 B   (+15.0%)
async-load-signup-steps-creds-complete                           -5461 B   (-38.8%)    -1517 B   (-37.0%)
async-load-signup-steps-site-topic                               -4831 B   (-14.5%)    -3159 B   (-28.1%)
async-load-signup-steps-clone-destination                        +4450 B   (+32.7%)     +992 B   (+24.9%)
async-load-components-web-preview-component                      -3946 B    (-1.1%)     -825 B    (-0.9%)
async-load-signup-steps-survey                                   +3297 B   (+24.2%)     +847 B   (+23.4%)
async-load-signup-steps-clone-ready                              +3174 B   (+13.0%)    +1159 B   (+17.7%)
async-load-apps-notifications-index-jsx                          -2126 B    (-1.8%)     -247 B    (-0.7%)
async-load-blocks-inline-help-popover                            -1770 B    (-0.8%)     -340 B    (-0.6%)
async-load-layout-guided-tours-component                         -1678 B    (-1.7%)     -183 B    (-0.9%)
async-load-signup-steps-rewind-form-creds                        -1516 B    (-3.7%)     -346 B    (-3.2%)
async-load-signup-steps-rewind-were-backing                      -1397 B   (-13.9%)     -223 B    (-8.0%)
async-load-signup-steps-clone-cloning                            -1382 B    (-9.2%)     -551 B   (-12.2%)
async-load-signup-steps-clone-point                               -888 B    (-0.6%)     -176 B    (-0.5%)
async-load-blocks-support-article-dialog-dialog                   -858 B    (-1.7%)     -178 B    (-1.2%)
async-load-design-blocks                                          -827 B    (-0.0%)     +615 B    (+0.1%)
async-load-signup-steps-user                                      -699 B    (-0.6%)     -235 B    (-0.8%)
async-load-reader-sidebar                                         -663 B    (-1.2%)      -69 B    (-0.5%)
async-load-signup-steps-plans                                     -546 B    (-0.4%)     -130 B    (-0.3%)
async-load-components-happychat                                   -543 B    (-1.5%)     -123 B    (-1.1%)
async-load-blocks-calendar-popover                                -458 B    (-0.2%)     -101 B    (-0.2%)
async-load-quick-language-switcher                                -406 B    (-1.4%)     -121 B    (-1.4%)
async-load-signup-steps-import-url-onboarding                     -392 B    (-1.3%)      -56 B    (-0.6%)
async-load-blocks-product-purchase-features-list                  -379 B    (-0.9%)      -26 B    (-0.2%)
async-load-layout-community-translator-launcher                   -358 B    (-1.9%)      -91 B    (-1.5%)
async-load-my-sites-checklist-wpcom-checklist-component-jsx       -355 B    (-0.3%)     -136 B    (-0.4%)
async-load-reader-following-manage                                -348 B    (-0.3%)      -85 B    (-0.3%)
async-load-reader-search-stream                                   -338 B    (-0.4%)      -64 B    (-0.3%)
async-load-signup-steps-clone-start                               +326 B    (+2.4%)     +101 B    (+2.5%)
async-load-blocks-reader-full-post                                -326 B    (-0.8%)     -111 B    (-1.0%)
async-load-signup-steps-plans-atomic-store                        -312 B    (-0.3%)      -79 B    (-0.3%)
async-load-my-sites-current-site-notice                           -272 B    (-0.6%)      -75 B    (-0.7%)
async-load-signup-steps-rewind-migrate                            -193 B    (-0.8%)      -22 B    (-0.3%)
async-load-blocks-inline-help                                     -188 B    (-0.3%)      -76 B    (-0.5%)
async-load-reader-feed-stream                                     -170 B    (-0.7%)      -40 B    (-0.6%)
async-load-lib-abtest-test-helper                                 -156 B    (-1.7%)      -33 B    (-1.1%)
async-load-signup-steps-clone-credentials                         -153 B    (-0.3%)      -17 B    (-0.1%)
async-load-layout-masterbar-drafts-popover                        -140 B    (-1.9%)      -48 B    (-1.9%)
async-load-signup-steps-passwordless                              -129 B    (-0.5%)      -56 B    (-0.9%)
async-load-layout-guided-tours                                    -125 B    (-0.3%)      -35 B    (-0.3%)
async-load-my-sites-current-site-domain-warnings                  -116 B    (-0.2%)      -31 B    (-0.2%)
async-load-signup-steps-import-url                                -114 B    (-0.6%)      -28 B    (-0.5%)
async-load-reader-tag-stream-main                                 -113 B    (-0.7%)      -34 B    (-0.7%)
async-load-signup-steps-creds-permission                           -97 B    (-0.4%)      -21 B    (-0.3%)
async-load-signup-steps-creds-confirm                              -97 B    (-0.4%)      -27 B    (-0.4%)
async-load-reader-conversations-stream                             -87 B    (-1.9%)      -49 B    (-2.9%)
async-load-my-sites-guided-transfer                                -79 B    (-0.3%)      -11 B    (-0.2%)
async-load-layout-nps-survey-notice                                -70 B    (-0.3%)      -31 B    (-0.5%)
async-load-blocks-product-plan-overlap-notices                     -68 B    (-1.1%)      -33 B    (-1.6%)
async-load-lib-network-connection                                  -59 B    (-1.4%)      -25 B    (-1.6%)
async-load-post-editor-editor-sharing-accordion                    -44 B    (-0.2%)       -4 B    (-0.1%)
async-load-signup-steps-site-title                                 -39 B    (-0.3%)       -9 B    (-0.3%)
async-load-components-community-translator                         -38 B    (-0.5%)       -4 B    (-0.2%)
async-load-signup-steps-site                                       -35 B    (-0.1%)       -2 B    (-0.0%)
async-load-signup-steps-rebrand-cities-welcome                     -32 B    (-0.2%)       +2 B    (+0.1%)
async-load-signup-steps-site-type                                  -23 B    (-0.2%)       -6 B    (-0.2%)
async-load-blocks-legal-updates-banner                             -23 B    (-2.6%)      -15 B    (-3.0%)
async-load-blocks-jitm-templates-sidebar-banner                    -23 B    (-0.1%)      -13 B    (-0.2%)
async-load-blocks-jitm-templates-default                           -20 B    (-0.1%)      -10 B    (-0.2%)
async-load-signup-steps-test-step                                  -17 B    (-0.2%)       -6 B    (-0.3%)
async-load-blocks-jitm                                             -17 B    (-0.4%)       -2 B    (-0.1%)
async-load-reader-list-stream                                      -15 B    (-0.1%)       -8 B    (-0.3%)
async-load-components-signup-site-preview-component                -14 B    (-0.2%)      -10 B    (-0.4%)
async-load-blocks-inline-help-dialog                               -13 B    (-0.3%)       -5 B    (-0.3%)
async-load-post-editor-editor-location                             -12 B    (-0.1%)       -1 B    (-0.0%)
async-load-post-editor-editor-seo-accordion                        -11 B    (-0.2%)       -5 B    (-0.3%)

React components that are loaded lazily, when a certain part of UI is displayed for the first time.

Legend

What is parsed and gzip size?

Parsed Size: Uncompressed size of the JS and CSS files. This much code needs to be parsed and stored in memory.
Gzip Size: Compressed size of the JS and CSS files. This much data needs to be downloaded over network.

Generated by performance advisor bot at iscalypsofastyet.com.

@ramonjd ramonjd added [Feature] Tracks Metrics & Monitoring Capturing analytics about user behavior on WordPress.com. Framework labels Jan 22, 2020
@jsnajdr jsnajdr force-pushed the extract/signup-analytics branch from dc3266a to e01e6f7 Compare January 23, 2020 12:51
@roo2 roo2 added the [Status] Needs Review The PR is ready for review. This also triggers e2e canary tests and wp-desktop tests automatically. label Jan 23, 2020
@p-jackson p-jackson force-pushed the update/gutenboarding-calypso-analytics branch from aa31733 to 2448b0e Compare January 24, 2020 03:58
@p-jackson
Copy link
Member

rebased

packages/calypso-analytics/src/index.js Outdated Show resolved Hide resolved
client/lib/analytics/hotjar.js Outdated Show resolved Hide resolved
packages/calypso-analytics/README.md Outdated Show resolved Hide resolved
client/reader/search-stream/suggestion-provider.jsx Outdated Show resolved Hide resolved
packages/calypso-analytics/src/index.js Outdated Show resolved Hide resolved
client/lib/analytics/ad-tracking.js Outdated Show resolved Hide resolved
packages/calypso-analytics/src/index.js Outdated Show resolved Hide resolved
tracksDebug( 'Recording event "%s" with actual props %o', eventName, eventProperties );
analyticsEvents.once( 'record-event', ( _eventName, _eventProperties ) => {
analytics.emit( 'record-event', _eventName, _eventProperties );
} );
Copy link
Member

Choose a reason for hiding this comment

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

The record-event event has only one usage: reporting the last tracks event as part of debug info when the JS app crashes.

That could be replaced with a getLastTracksEvent() function that's part of the tracks API.

And maybe it could be removed altogether -- I'm not sure if we use that info for anything and I don't see why it would be interesting when debugging JS crashes.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Hmm I'd rather not take this out in this PR, so the PR can stay pure refactoring.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I did investigate it and I believe adding the getLastTracksEvent would work but I saw it was possible that other events are added also using the recordEvent name so the behavior might change slightly.. It probably wouldn't be an issue to anyone but I don't want to take on the burden of testign it etc.

Copy link
Member

Choose a reason for hiding this comment

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

Alright, let's address the suggestion in another PR 👍

packages/calypso-analytics/src/index.js Outdated Show resolved Hide resolved
@roo2 roo2 force-pushed the update/gutenboarding-calypso-analytics branch from 55aa236 to ad5a978 Compare February 3, 2020 20:28
@roo2 roo2 requested review from a team as code owners February 3, 2020 20:28
@roo2 roo2 force-pushed the update/gutenboarding-calypso-analytics branch from ad5a978 to 74618ce Compare February 3, 2020 20:33
@ramonjd
Copy link
Member

ramonjd commented Feb 3, 2020

Was this a wonky rebase? That commit list looks humungous! :)

@roo2 roo2 force-pushed the update/gutenboarding-calypso-analytics branch from a7e4474 to a452f92 Compare February 6, 2020 21:46
@roo2 roo2 merged commit 2e3c19a into master Feb 6, 2020
@roo2 roo2 deleted the update/gutenboarding-calypso-analytics branch February 6, 2020 23:53
@matticbot matticbot removed the [Status] Needs Review The PR is ready for review. This also triggers e2e canary tests and wp-desktop tests automatically. label Feb 6, 2020
gwwar added a commit that referenced this pull request Feb 7, 2020
gwwar added a commit that referenced this pull request Feb 7, 2020
@ramonjd ramonjd restored the update/gutenboarding-calypso-analytics branch February 7, 2020 00:36
@ramonjd
Copy link
Member

ramonjd commented Feb 7, 2020

In relation to this commit: 3f7a7d0

You can trigger the tests by removing the "Needs review" label and re-adding it 👍

@ramonjd ramonjd deleted the update/gutenboarding-calypso-analytics branch February 7, 2020 00:54
@ramonjd ramonjd restored the update/gutenboarding-calypso-analytics branch February 7, 2020 01:08
@ramonjd ramonjd deleted the update/gutenboarding-calypso-analytics branch February 7, 2020 01:09
fushar added a commit that referenced this pull request Feb 9, 2022
Since #39001, the suffix for Tracks
was changed from ":tracks" to "" (empty string). This commit updates the README
to reflect this.
fushar added a commit that referenced this pull request Feb 10, 2022
Since #39001, the suffix for Tracks
was changed from ":tracks" to "" (empty string). This commit updates the README
to reflect this.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[Feature] Tracks Metrics & Monitoring Capturing analytics about user behavior on WordPress.com. Framework [Goal] New Onboarding previously called Gutenboarding [Status] Needs Rebase
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Gutenboarding]: add analytics (tracks)
7 participants