events: record timeline_view on GET /timeline with view+forced meta
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
parent
9eafba547a
commit
31bfd72b4c
1 changed files with 10 additions and 1 deletions
11
server.js
11
server.js
|
|
@ -14,6 +14,7 @@ import authRouter from './src/auth.js';
|
|||
import { requireAuth, requireAdmin } from './src/middleware.js';
|
||||
import { q } from './src/db.js'; // also side-effect: opens DB + runs schema
|
||||
import { MOBILE_UA_RE } from './src/ua.js';
|
||||
import { recordEvent } from './src/events.js';
|
||||
|
||||
const __dirname = path.dirname(fileURLToPath(import.meta.url));
|
||||
const app = express();
|
||||
|
|
@ -191,7 +192,15 @@ function wantsMobileView(req) {
|
|||
}
|
||||
|
||||
app.get('/timeline', requireAuth, (req, res) => {
|
||||
if (wantsMobileView(req)) {
|
||||
const forced = ['mobile', 'desktop'].includes((req.query.view || '').toLowerCase());
|
||||
const view = wantsMobileView(req) ? 'mobile' : 'desktop';
|
||||
recordEvent(req, {
|
||||
type: 'timeline_view',
|
||||
email: req.session.email,
|
||||
sessionId: req.session.id,
|
||||
meta: { view, forced },
|
||||
});
|
||||
if (view === 'mobile') {
|
||||
return res.sendFile(path.join(__dirname, 'protected', 'mobile', 'index.html'));
|
||||
}
|
||||
return res.sendFile(path.join(__dirname, 'protected', 'index.html'));
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue