-
Notifications
You must be signed in to change notification settings - Fork 258
WS-1215 | adding offline analytics #13263
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
base: latest
Are you sure you want to change the base?
Conversation
jankosacc
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also, general comment. Main goal is also to make sure you don't break existing analytics. f.e. It seems like even if you are online we still add requests to queue, so, if we re-trigger them we need to make sure that we don't send out, f.e. duplicates.
6041f01 to
6d84db3
Compare
| self.addEventListener('install', event => { | ||
| // eslint-disable-next-line no-console | ||
| console.log('[SW] Installing...'); | ||
| self.skipWaiting(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should evaluate if we want to skip waiting for production to avoid weird behaviour. Needs re-evaluation.
Resolves JIRA:
Summary
Implement Offline Analytics Tracking for Service Worker
Summary
Added offline analytics tracking capability to the service worker, ensuring analytics requests (ATI and Chartbeat) are queued when the application is offline and automatically sent when connectivity is restored.
Features
1. Analytics Request Interception
ati-host.net) and Chartbeat (chartbeat.net) domains2. Offline Request Queueing
analytics-queue-v1cache3. Automatic Queue Processing
onlineeventPROCESS_ANALYTICS_QUEUEmessage to service worker when connectivity restoredno-corsmode for compatibility with analytics endpoints4. Client-Side Integration
Technical Implementation
Service Worker (public/sw.js)
ANALYTICS_PATTERN: Regex to match analytics domainsqueueRequest(): Serializes and stores failed requestsPROCESS_ANALYTICS_QUEUEtriggerClient Component (src/app/components/ServiceWorker/index.tsx)
useEffecthook manages online event listener lifecycleBenefits
Testing Recommendations
analytics-queue-v1cachewindow.dispatchEvent(new Event('online')))Browser Compatibility
Related Files
Code changes
======
Developer Checklist
Testing
Ready-For-Test, Local)Ready-For-Test, Test)Ready-For-Test, Preview)Ready-For-Test, Live)Additional Testing Steps
Useful Links