debug(pwa): add admin-only display-mode overlay for diagnosis on mobile
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
Shows detected display-mode, navigator.standalone, and PWA cookies as a small green text at bottom of screen. Only visible for admin users. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
parent
8d70760ef8
commit
ec51db9de4
@ -2382,12 +2382,17 @@
|
||||
}
|
||||
}
|
||||
if (window.navigator.standalone === true) detected = 'ios-standalone';
|
||||
// Set cookie with detected mode for debugging
|
||||
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';
|
||||
}
|
||||
{% if current_user.is_authenticated and current_user.has_role(SystemRole.ADMIN) %}
|
||||
// Debug: show detected mode for admin (temporary)
|
||||
var d = document.createElement('div');
|
||||
d.style.cssText = 'position:fixed;bottom:0;left:0;background:rgba(0,0,0,0.8);color:#0f0;font-size:11px;padding:4px 8px;z-index:99999;font-family:monospace;';
|
||||
d.textContent = 'display-mode: ' + detected + ' | standalone: ' + window.navigator.standalone + ' | cookies: ' + document.cookie.split(';').filter(function(c){return c.trim().startsWith('pwa')}).join(', ');
|
||||
document.body.appendChild(d);
|
||||
{% endif %}
|
||||
})();
|
||||
|
||||
// PWA Smart Banner logic
|
||||
|
||||
@ -98,14 +98,11 @@ def get_or_create_analytics_session():
|
||||
user_session.last_activity_at = datetime.now()
|
||||
if current_user.is_authenticated and not user_session.user_id:
|
||||
user_session.user_id = current_user.id
|
||||
# PWA cookie arrives on 2nd request (after JS sets it)
|
||||
pwa_cookie = request.cookies.get('pwa_mode')
|
||||
pwa_display = request.cookies.get('pwa_display')
|
||||
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':
|
||||
# PWA detection from cookie (set by JS in standalone mode)
|
||||
pwa_cookie = request.cookies.get('pwa_mode') == '1'
|
||||
pwa_display = request.cookies.get('pwa_display', '')
|
||||
if not user_session.is_pwa and pwa_cookie:
|
||||
user_session.is_pwa = True
|
||||
logger.info(f"Setting is_pwa=True for session {user_session.id}")
|
||||
db.commit()
|
||||
|
||||
return user_session.id
|
||||
|
||||
Loading…
Reference in New Issue
Block a user