debug(pwa): send display-mode detection cookie for diagnosis
Some checks are pending
NordaBiz Tests / Unit & Integration Tests (push) Waiting to run
NordaBiz Tests / E2E Tests (Playwright) (push) Blocked by required conditions
NordaBiz Tests / Smoke Tests (Production) (push) Blocked by required conditions
NordaBiz Tests / Send Failure Notification (push) Blocked by required conditions
Some checks are pending
NordaBiz Tests / Unit & Integration Tests (push) Waiting to run
NordaBiz Tests / E2E Tests (Playwright) (push) Blocked by required conditions
NordaBiz Tests / Smoke Tests (Production) (push) Blocked by required conditions
NordaBiz Tests / Send Failure Notification (push) Blocked by required conditions
Frontend now sends pwa_display cookie with the actual detected mode (standalone/minimal-ui/fullscreen/browser/unknown/ios-standalone). Backend logs this to diagnose why WebAPK detection fails. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
parent
c72f62508d
commit
8d70760ef8
@ -2371,22 +2371,24 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// PWA detection — set cookie for backend analytics
|
// PWA detection — send display mode info to server via cookie
|
||||||
// WebAPK on Android may not report standalone via matchMedia reliably
|
(function() {
|
||||||
var _isPWA = window.matchMedia('(display-mode: standalone)').matches
|
var modes = ['standalone', 'minimal-ui', 'fullscreen', 'browser'];
|
||||||
|| window.matchMedia('(display-mode: minimal-ui)').matches
|
var detected = 'unknown';
|
||||||
|| window.navigator.standalone === true
|
for (var i = 0; i < modes.length; i++) {
|
||||||
|| document.referrer.startsWith('android-app://');
|
if (window.matchMedia('(display-mode: ' + modes[i] + ')').matches) {
|
||||||
// Fallback: if browser mode query is supported but does NOT match, we're in PWA
|
detected = modes[i];
|
||||||
if (!_isPWA) {
|
break;
|
||||||
var browserMode = window.matchMedia('(display-mode: browser)');
|
}
|
||||||
if (browserMode.media !== 'not all' && !browserMode.matches) {
|
|
||||||
_isPWA = true;
|
|
||||||
}
|
}
|
||||||
}
|
if (window.navigator.standalone === true) detected = 'ios-standalone';
|
||||||
if (_isPWA) {
|
// Set cookie with detected mode for debugging
|
||||||
document.cookie = 'pwa_mode=1; path=/; max-age=86400; SameSite=Lax';
|
document.cookie = 'pwa_display=' + detected + '; path=/; max-age=86400; SameSite=Lax';
|
||||||
}
|
// PWA = anything that is NOT 'browser' and NOT 'unknown'
|
||||||
|
if (detected !== 'browser' && detected !== 'unknown') {
|
||||||
|
document.cookie = 'pwa_mode=1; path=/; max-age=86400; SameSite=Lax';
|
||||||
|
}
|
||||||
|
})();
|
||||||
|
|
||||||
// PWA Smart Banner logic
|
// PWA Smart Banner logic
|
||||||
(function() {
|
(function() {
|
||||||
|
|||||||
@ -100,8 +100,9 @@ def get_or_create_analytics_session():
|
|||||||
user_session.user_id = current_user.id
|
user_session.user_id = current_user.id
|
||||||
# PWA cookie arrives on 2nd request (after JS sets it)
|
# PWA cookie arrives on 2nd request (after JS sets it)
|
||||||
pwa_cookie = request.cookies.get('pwa_mode')
|
pwa_cookie = request.cookies.get('pwa_mode')
|
||||||
if pwa_cookie:
|
pwa_display = request.cookies.get('pwa_display')
|
||||||
logger.info(f"PWA cookie found: '{pwa_cookie}' for session {user_session.id}")
|
if pwa_display:
|
||||||
|
logger.info(f"PWA display mode: '{pwa_display}' pwa_mode={pwa_cookie} session={user_session.id} browser={user_session.browser}")
|
||||||
if not user_session.is_pwa and pwa_cookie == '1':
|
if not user_session.is_pwa and pwa_cookie == '1':
|
||||||
user_session.is_pwa = True
|
user_session.is_pwa = True
|
||||||
logger.info(f"Setting is_pwa=True for session {user_session.id}")
|
logger.info(f"Setting is_pwa=True for session {user_session.id}")
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user