Open
Description
Overview
This task is related to PWA epic #1197 . This task involves adding analytics events to be triggered on each app load, sending either WEB_APP_LOADED
or PWA_LOADED
depending on whether the user is using a PWA or normal web app.
Action Items
- Add logic to determine if the user is using a PWA or web app - see resources below
- Send analytics events on app load,
WEB_APP_LOADED
orPWA_LOADED
using our existinglogEvent()
function - see more about our events in Add PWA analytics events #1208. Include theeventUserData
params and an additionalbrowser
param with the event, i.e.logEvent(PWA_LOADED, eventUserData)
Resources/Instructions
To test that analytics events are being triggered, check the console log where events should be shown.
Note these resources are guides to general pwa/browser detection, but there may be a better solution for next.js or next-pwa
https://web.dev/learn/pwa/detection
https://stackoverflow.com/questions/41742390/javascript-to-check-if-pwa-or-mobile-web
const isInStandaloneMode = () =>
(window.matchMedia('(display-mode: standalone)').matches) || (window.navigator.standalone) || document.referrer.includes('android-app://');
if (isInStandaloneMode()) {
console.log("webapp is installed")
}