Skip to content

Conversation

@DmitryGron
Copy link
Contributor

@DmitryGron DmitryGron commented Dec 12, 2025

Resolves JIRA: https://bbc.atlassian.net/browse/WS-1838

Summary

Adding flag for offline tracking

New Hooks:

useOfflinePageFlag - Sets flag when offline page visited in PWA
usePWAOfflineTracking - Fires pwa-offline-page-view event on offline→online transition
useSendPWAStatus - Sends PWA status to service worker
useServiceWorkerRegistration - Handles SW registration:

Added tests for all 4 hooks following codebase patterns

Fixed merge conflict in LatestMediaItem styles
Updated Storybook 10.0.8 → 10.1.10

Testing Instructions
How to test the offline flag and tracking
Setup:

Stop your dev server
Close Chrome completely and uninstall any existing PWA
Start the dev server: yarn dev
Go to http://localhost:7081/mundo/live/c7dkx155e626t?renderer_env=local
Install it as a PWA (click the install icon in the address bar)
Test the flag:

Once installed, refresh the page to make sure the offline page gets cached
Open DevTools, go to Network tab and set it to Offline
Refresh the page - you should see the custom offline page
Check Local Storage (in DevTools → Application → Local Storage)
You should see offline_page_visit with value "true"
Test the tracking event:

While still on the offline page with the flag set
Open the Console tab in DevTools
Switch Network back to Online
You should see a tracking beacon fire with event name pwa-offline-page-view and network type
Check Local Storage again - the offline_page_visit flag should be gone
Test it fires again:

Go offline again, refresh to see the offline page
The flag gets set again
Go back online
The event fires again and the flag is removed
That's it. The event should fire every time you go from offline → online after visiting the offline page.

Developer Checklist

  • UX
    • UX Criteria met (visual UX & screenreader UX)
  • Accessibility
    • Accessibility Acceptance Criteria met
    • Accessibility swarm completed
    • Component Health updated
    • P1 accessibility bugs resolved
    • P2/P3 accessibility bugs planned (if not resolved)
  • Security
    • Security issues addressed
    • Threat Model updated
  • Documentation
    • Docs updated (runbook, READMEs)
  • Testing
    • Feature tested on relevant environments
  • Comms
    • Relevant parties notified of changes

Testing

  • Manual Testing required?
    • Local (Ready-For-Test, Local)
    • Test (Ready-For-Test, Test)
    • Preview (Ready-For-Test, Preview)
    • Live (Ready-For-Test, Live)
  • Manual Testing complete?
    • Local
    • Test
    • Preview
    • Live

Additional Testing Steps

  1. List the steps required to test this PR.

Useful Links

@DmitryGron DmitryGron requested a review from elvinasv December 16, 2025 13:54
@amoore108
Copy link
Contributor

Can we add some tests around the new useOfflinePageFlag and usePWAOfflineTracking hooks?

@DmitryGron DmitryGron requested a review from a team as a code owner December 19, 2025 13:48
@elvinasv elvinasv changed the title Feature/ws 1838 pwa offline flag WS-1838: Add PWA Offline page tracking Dec 22, 2025
@LukasFrm LukasFrm self-requested a review December 23, 2025 10:00
Copy link
Contributor

@andrewscfc andrewscfc left a comment

Choose a reason for hiding this comment

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

Thanks for all the changes 🚀

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.