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

Logged-in Performance Profiler:Add additional track events #95636

Open
wants to merge 7 commits into
base: trunk
Choose a base branch
from

Conversation

vykes-mac
Copy link
Contributor

Related to https://github.com/Automattic/dotcom-forge/issues/9065

Proposed Changes

This relates to this comment pdKhl6-4fl-p2#comment-7548

  • Add additional track events

Why are these changes being made?

  • To add more points of analytics

Testing Instructions

  • In your console run localStorage.setItem( 'debug', 'calypso:analytics*' );
  • Verify the track events are being fired for both logged-in and logged-out versions

image

Pre-merge Checklist

  • Has the general commit checklist been followed? (PCYsg-hS-p2)
  • Have you written new tests for your changes?
  • Have you tested the feature in Simple (P9HQHe-k8-p2), Atomic (P9HQHe-jW-p2), and self-hosted Jetpack sites (PCYsg-g6b-p2)?
  • Have you checked for TypeScript, React or other console errors?
  • Have you used memoizing on expensive computations? More info in Memoizing with create-selector and Using memoizing selectors and Our Approach to Data
  • Have we added the "[Status] String Freeze" label as soon as any new strings were ready for translation (p4TIVU-5Jq-p2)?
  • For changes affecting Jetpack: Have we added the "[Status] Needs Privacy Updates" label if this pull request changes what data or activity we track or use (p4TIVU-aUh-p2)?

@vykes-mac vykes-mac self-assigned this Oct 24, 2024
@vykes-mac vykes-mac added Logged-in Performance Profiler i1 Reviewer Can Merge PR author indicates the reviewer is free to merge/deploy if they want to own the change. labels Oct 24, 2024
@vykes-mac vykes-mac requested a review from a team October 24, 2024 00:48
@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 Oct 24, 2024
@matticbot
Copy link
Contributor

matticbot commented Oct 24, 2024

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

Sections (~192 bytes added 📈 [gzipped])

name                  parsed_size           gzip_size
site-performance           +820 B  (+0.0%)     +192 B  (+0.0%)
performance-profiler       +490 B  (+0.1%)     +115 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.

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.

@matticbot
Copy link
Contributor

This PR modifies the release build for the following Calypso Apps:

For info about this notification, see here: PCYsg-OT6-p2

  • notifications
  • wpcom-block-editor

To test WordPress.com changes, run install-plugin.sh $pluginSlug add/additional_tracks on your sandbox.

@@ -0,0 +1,2 @@
export const profilerVersion = () =>
window.location.pathname.includes( '/sites/performance/' ) ? 'logged-in' : 'logged-out';
Copy link
Member

Choose a reason for hiding this comment

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

If we ever changed the the page URLs and forgot to update this function we wouldn't want to inadvertently record data that looks correct but is actually bogus. It ruin all the stats up till the point we discovered the issue. Same thing for if we ever added this component to a whole other page.

I think it's better not to assume that there's only two possible profiler versions.

Suggested change
window.location.pathname.includes( '/sites/performance/' ) ? 'logged-in' : 'logged-out';
if ( window.location.pathname.includes( '/sites/performance/' ) ) {
return 'logged-in';
} else if ( window.location.pathname.includes( '/speed-test-tool' ) ) {
return 'logged-out';
}
return 'unknown';

Copy link
Contributor Author

Choose a reason for hiding this comment

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

That is true, best to be exhaustive with the expected options here.

@@ -39,6 +41,12 @@ export const StatusSection = ( props: StatusSectionProps ) => {
good: translate( 'Excellent' ),
}[ status ];

const recordRecommendationsClickEvent = ( filter = 'all' ) =>
Copy link
Member

Choose a reason for hiding this comment

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

Maybe this is just a personal preference thing, but a required function argument feels better here. The function caller knows best which filter is active when it's clicked.

Suggested change
const recordRecommendationsClickEvent = ( filter = 'all' ) =>
const recordRecommendationsClickEvent = ( filter: string ) =>

@@ -300,7 +302,9 @@ export const SitePerformance = () => {
disabled={ disableControls }
onChange={ ( page_id ) => {
const url = new URL( window.location.href );

recordTracksEvent( 'calypso_performance_profiler_page_selector_change', {
page: pages.find( ( page ) => page.value === page_id )?.label ?? '/',
Copy link
Member

Choose a reason for hiding this comment

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

How useful is it to record the page title? It's not really aggregatable data.
I feel like a is_home event prop would make more sense than the raw page title which we can't really do anything with in the tracks tool.

Copy link
Member

Choose a reason for hiding this comment

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

And I think we should add the version prop here too.

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 was recording the page_id at first but that didn't seem to be useful either.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Logged-in Performance Profiler i1 Reviewer Can Merge PR author indicates the reviewer is free to merge/deploy if they want to own the change. [Status] Needs Review The PR is ready for review. This also triggers e2e canary tests and wp-desktop tests automatically.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants