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

display the total clicks and total impressions in advertising pages #95391

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

Conversation

therocket-gr
Copy link
Contributor

@therocket-gr therocket-gr commented Oct 15, 2024

Related to #

Proposed Changes

2638-gh-tumblr/a8c-dsp

Why are these changes being made?

we want to add a total impressions and total clicks (for all campaigns) for a user in the advertising pages (both in ready to promote and campaigns page)

the added elements look like this (ss from browser)
Screenshot 2024-10-15 at 18 15 32

and ss from figma
Screenshot 2024-10-15 at 18 17 11

please note that I haven't added the icons for more info (the ones with the 'i') but I am missing the context of what will happen if hovered ( I guess we need some kind of popover with some additional messages)

Update:

I added a function to format large numbers properly..

as we have users who might have very large numbers of campaigns and their impressions (maybe also clicks) can be added to have millions of results

now for example 100000 will be displayed as 100K 125500 will be displayed as 125.5K

1000000 will be displayed as 1M

1255000 will be displayed as 1.255M and so on (for millions I added 3 decimals to have some better understanding of the amount)

to test this you can just hardcode the line

totalClicks={ campaignsStats?.total_clicks }

to
totalClicks={ 1500000 }
in

client/my-sites/promote-post-i2/main.tsx

Testing Instructions

please check out the branch (or test the preview links) check that the elements appear as expected
(I checked the layout both when we do have a banner and when we don't.. you can also test by hardcoding this line
const showBanner = ! campaignsIsLoading && ( totalCampaignsUnfiltered || 0 ) < 3; and change it to showBanner = true or false accordingly

test that the layout looks ok in tablet and mobile..

do a CR.

Pre-merge Checklist

  • Has the general commit checklist been followed? (PCYsg-hS-p2)
  • https://wpcalypso.wordpress.com/devdocs/docs/testing/index.md 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)?

@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 15, 2024
Copy link

github-actions bot commented Oct 15, 2024

Link to live branch is being generated...
Please wait a few minutes and refresh this page.

@matticbot
Copy link
Contributor

matticbot commented Oct 15, 2024

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

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

  • blaze-dashboard
  • odyssey-stats

To test WordPress.com changes, run install-plugin.sh $pluginSlug vdimitrakis/2638-display-total-impressions-and-clicks-in-advertising-pages on your sandbox.

@therocket-gr therocket-gr self-assigned this Oct 15, 2024
@matticbot
Copy link
Contributor

matticbot commented Oct 15, 2024

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

Sections (~574 bytes added 📈 [gzipped])

name             parsed_size           gzip_size
promote-post-i2      +1094 B  (+0.3%)     +262 B  (+0.2%)
stats                 +221 B  (+0.0%)     +110 B  (+0.0%)
posts-custom          +221 B  (+0.0%)     +102 B  (+0.0%)
posts                 +221 B  (+0.0%)     +102 B  (+0.0%)
pages                 +221 B  (+0.0%)     +100 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.

Copy link
Contributor

@sbarbosa sbarbosa left a comment

Choose a reason for hiding this comment

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

Hi @therocket-gr!
I found a couple of things that we need to change, but overall, the changes look great and worked as expected.

config/development.json Outdated Show resolved Hide resolved
Copy link
Contributor

@sbarbosa sbarbosa left a comment

Choose a reason for hiding this comment

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

LGTM 👍

@jjolmo
Copy link
Contributor

jjolmo commented Oct 16, 2024

image LGTM

@@ -244,6 +244,15 @@ export const formatNumber = ( number: number, onlyPositives = false ): string =>
return number.toLocaleString();
};

export const formatLargeNumber = ( number: number ): string => {
Copy link
Contributor

Choose a reason for hiding this comment

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

I searched in Calypso, and I found this function that do a similar thing:
https://github.com/Automattic/wp-calypso/tree/trunk/client/lib/format-number-compact

Do you think we could use that one instead? It might behave differently, which is what you wanted to achieve here.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

the function is a bit strange.. it wont format millions properly. i tested and I think my method works better. i just added a small improvement to add locale formatting in the number (so for some countries that use comma instead of a point for decimals it will display the result better)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[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.

4 participants