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

Test Chartbeat on Lite pages #11579

Draft
wants to merge 29 commits into
base: latest
Choose a base branch
from
Draft

Conversation

amoore108
Copy link
Contributor

@amoore108 amoore108 commented Apr 30, 2024

Overall changes

  • Initial implementation of adding Chartbeat on Lite pages, mainly to test that this approach works and sends data to Chartbeat.

Code changes

  • Adds checks for Lite mode and Chartbeat toggle, returning the Canonical Chartbeat component if true
  • Adds tests to check that the correct Helmet script tags are added to the page for Lite mode

Testing

  1. Visit http://localhost:7080/pidgin/articles/cj5l1958ljjo.lite?renderer_env=live
  2. Open the Network tab (may need to refresh the page to see all the transferred files)
  3. Confirm that chartbeat.js is downloaded
  4. Stay the page for awhile and observe 'ping' requests to Chartbeat
  5. Click on one of the 'ping' requests and check that values are present

Helpful Links

Add Links to useful resources related to this PR if applicable.

Coding Standards

Repository use guidelines

@amoore108 amoore108 self-assigned this Apr 30, 2024
@amoore108 amoore108 changed the title Add Chartbeat to Lite pages Test Chartbeat on Lite pages May 1, 2024
@@ -47,9 +51,13 @@ const ChartbeatAnalytics = ({

const chartbeatConfig = getConfig(configDependencies);

if (isLiteAndEnabled) {
return <CanonicalChartbeatBeacon chartbeatConfig={chartbeatConfig} />;
Copy link
Contributor

Choose a reason for hiding this comment

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

Here's where the canonical Chartbeat component is added - I was not expecting it to be used here, so wonder if we need to change the logic within UserContext/Chartbeat instead?

is https://github.com/bbc/simorgh/blob/81f36a76c994d60ddc19af17d0dcb14b9df498f9/src/app/contexts/UserContext/Chartbeat/index.tsx

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Tying Chartbeat to the UserContext provider feels a bit strange to me, unless there were historical reasons for doing so?

UserContext handles things like cookies, which makes sense but not sure having Chartbeat in there does? Maybe just saved importing it into individual page components at the time?

Copy link
Contributor

@karinathomasbbc karinathomasbbc Jan 23, 2025

Choose a reason for hiding this comment

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

Yeah that's why I was confused, and wondered if this is an opportunity to try and fix it?

Not sure of the historical reasons, but permission for sending tracking beacons also part of the user context / cookies, and perhaps that's why it was there. But I definitely agree, it doesn't belong within the UserContext, it should be within the Chartbeat Analytics component instead.

Copy link
Contributor

Choose a reason for hiding this comment

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

#3622
NB: the 'UserContext' probably isnt the right place to put this, but as a POC its fine :)

Copy link
Contributor

Choose a reason for hiding this comment

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

Good ol' old tech debt

Copy link
Contributor

@karinathomasbbc karinathomasbbc Jan 23, 2025

Choose a reason for hiding this comment

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

Where's the "old man yells at tech debt" emoji when you need it?!?!?

Copy link
Contributor

Choose a reason for hiding this comment

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

Thinking about this, I guess this was done with client side routing in mind? As the chartbeat config is stored in state, it's probably there to prevent re-renders

Copy link
Contributor

Choose a reason for hiding this comment

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

Haven't we removed client-side / SPA routing functionality? If there's a nicer way to refactor this (i.e. could we move the useState code to the ChartbeatAnalytics component instead of having it in the UserContext?), then we should do it, but if not, it's OK to leave it as is.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Worth testing actually, as we did encounter some duplication of ATI events when Helmet mounted on the server and re-mounted on clientside hydration.

This would only affect Canonical mind.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants