Commit c060e46
authored
perf(events): route event list to events_v2 + merge anonymous identit… (#424)
* perf(events): route event list to events_v2 + merge anonymous identity on profile page
Two changes to the profile/events event list (getEventList + getEventsCount):
1. Route reads to events_v2 (name-first ORDER BY) via getEventsTableForRange —
parity with events within the TTL window, but profile_id / name IN (...)
lookups prune to a fraction of the rows (measured 13x fewer for name+profile
on the profile page). Falls back to events for pre-EVENTS_V2_MIN_DATE ranges
or when the flag is off. Also skip the 0.5d expanding-window retries when a
specific event name is searched — the name+profile sort-key pruning makes a
single full-range pass cheap, replacing up to ~10 doubling re-scans.
2. Profile page identity merge: show the full pre-login + post-login journey by
listing events for the canonical profile_id AND its anonymous device aliases.
getProfileIdCluster resolves canonical (dictGet, in-RAM) then reverse-looks-up
its aliases from profile_aliases (cached 10min, so the scan runs once per
profile). getEventList/getEventsCount take a profileIds[] -> profile_id IN
(...) with literal ids (no per-query alias subquery scan). Wired via a new
mergeIdentity flag on the event.events procedure, set by the profile events
route. Anon-only events ($ae_first_open, loginPrompt, logInInitiate, ...)
are now visible on the profile timeline instead of split across device ids.
* fix(profile): resolve identity cluster via profile_aliases, not the alias dict
The forward step of getProfileIdCluster used dictGet, but the alias RAM dict
lags profile_aliases inserts (LIFETIME 30-60min). A freshly-aliased anon device
dictGet-MISSes on every replica, so opening that anon profile resolved to itself,
found no reverse aliases, and showed only the pre-login events — the post-login
half silently dropped.
Forward-resolve via a profile_aliases alias lookup instead — a cheap
(project_id, alias) sort-key point lookup that is authoritative and near
real-time. The reverse step already scans profile_aliases, so the resolver now
reads a single consistent source. Verified: opening anon d6021004 now resolves
to canonical X8JG and returns the full cluster.
* feat(profile-events): default to last 15 days with a visible range picker
Profile events feed now defaults to the last 15 days (like the profiles list,
#371) so landing on a busy profile stays fast, while searching a specific event
spans all days to find old occurrences.
- getEventList: when an explicit [startDate, endDate] is passed, that BETWEEN
drives the window and the rolling expanding-window is skipped (only the cursor
upper-bound remains for pagination) — a real range bounds the scan cleanly.
- Profile events route: default window = last 15 days; searching a specific event
= all days; a user-picked range always wins. Memoized so the 'now' anchor is
stable.
- EventsTable: swapped the old DateRangerPicker modal for the #371 LastSeenPicker
dual-month calendar, added an emptyRangeLabel prop (profile page shows
'Last 15 days' / 'All time' while searching) and a clear button.
* fix(profile-events): address CodeRabbit — datetime bounds + reverse-alias dedup
- getEventList/getEventsCount: compare created_at against toDateTime bounds
instead of toDate, so the LastSeenPicker's hour-level ranges aren't widened to
whole calendar days.
- getProfileIdCluster: the reverse alias lookup kept any alias whose profile_id
row equalled the canonical, but a reassigned device retains its old row
(profile_id is in the sort key) — so it could resurrect a device now owned by
another user. Restrict to candidate aliases that ever pointed here, then keep
only those whose latest argMax(profile_id, created_at) is still this canonical.1 parent f9dffb6 commit c060e46
5 files changed
Lines changed: 213 additions & 37 deletions
File tree
- apps/start/src
- components/events/table
- routes
- packages
- db/src/services
- trpc/src/routers
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
2 | 2 | | |
| 3 | + | |
3 | 4 | | |
4 | | - | |
5 | 5 | | |
6 | 6 | | |
7 | 7 | | |
8 | | - | |
9 | 8 | | |
10 | 9 | | |
11 | 10 | | |
| |||
14 | 13 | | |
15 | 14 | | |
16 | 15 | | |
17 | | - | |
18 | | - | |
| 16 | + | |
| 17 | + | |
19 | 18 | | |
20 | 19 | | |
21 | 20 | | |
| |||
32 | 31 | | |
33 | 32 | | |
34 | 33 | | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
35 | 37 | | |
36 | 38 | | |
37 | 39 | | |
38 | 40 | | |
| 41 | + | |
| 42 | + | |
39 | 43 | | |
40 | 44 | | |
41 | 45 | | |
| |||
265 | 269 | | |
266 | 270 | | |
267 | 271 | | |
268 | | - | |
| 272 | + | |
269 | 273 | | |
270 | 274 | | |
271 | 275 | | |
| |||
333 | 337 | | |
334 | 338 | | |
335 | 339 | | |
336 | | - | |
| 340 | + | |
| 341 | + | |
| 342 | + | |
| 343 | + | |
| 344 | + | |
337 | 345 | | |
338 | 346 | | |
339 | 347 | | |
| |||
358 | 366 | | |
359 | 367 | | |
360 | 368 | | |
| 369 | + | |
361 | 370 | | |
362 | 371 | | |
363 | 372 | | |
| 373 | + | |
364 | 374 | | |
365 | 375 | | |
366 | 376 | | |
367 | 377 | | |
368 | 378 | | |
369 | 379 | | |
| 380 | + | |
370 | 381 | | |
371 | 382 | | |
372 | 383 | | |
373 | 384 | | |
374 | 385 | | |
375 | 386 | | |
376 | | - | |
377 | | - | |
378 | | - | |
379 | | - | |
380 | | - | |
381 | | - | |
382 | | - | |
383 | | - | |
384 | | - | |
385 | | - | |
386 | | - | |
387 | | - | |
388 | | - | |
| 387 | + | |
| 388 | + | |
| 389 | + | |
| 390 | + | |
| 391 | + | |
| 392 | + | |
| 393 | + | |
| 394 | + | |
| 395 | + | |
| 396 | + | |
389 | 397 | | |
| 398 | + | |
390 | 399 | | |
391 | | - | |
392 | | - | |
393 | | - | |
394 | | - | |
| 400 | + | |
| 401 | + | |
| 402 | + | |
| 403 | + | |
| 404 | + | |
| 405 | + | |
| 406 | + | |
| 407 | + | |
| 408 | + | |
| 409 | + | |
| 410 | + | |
| 411 | + | |
| 412 | + | |
| 413 | + | |
| 414 | + | |
| 415 | + | |
| 416 | + | |
| 417 | + | |
395 | 418 | | |
396 | 419 | | |
397 | 420 | | |
| |||
Lines changed: 36 additions & 3 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
8 | 8 | | |
9 | 9 | | |
10 | 10 | | |
| 11 | + | |
11 | 12 | | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
12 | 20 | | |
13 | 21 | | |
14 | 22 | | |
| |||
33 | 41 | | |
34 | 42 | | |
35 | 43 | | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
36 | 60 | | |
37 | 61 | | |
38 | 62 | | |
39 | 63 | | |
40 | 64 | | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
41 | 69 | | |
42 | | - | |
43 | | - | |
| 70 | + | |
| 71 | + | |
44 | 72 | | |
45 | 73 | | |
46 | 74 | | |
| |||
51 | 79 | | |
52 | 80 | | |
53 | 81 | | |
54 | | - | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
55 | 88 | | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
13 | 13 | | |
14 | 14 | | |
15 | 15 | | |
| 16 | + | |
16 | 17 | | |
17 | 18 | | |
18 | 19 | | |
| |||
436 | 437 | | |
437 | 438 | | |
438 | 439 | | |
| 440 | + | |
| 441 | + | |
| 442 | + | |
| 443 | + | |
439 | 444 | | |
440 | 445 | | |
441 | 446 | | |
| |||
454 | 459 | | |
455 | 460 | | |
456 | 461 | | |
| 462 | + | |
457 | 463 | | |
458 | 464 | | |
459 | 465 | | |
| |||
465 | 471 | | |
466 | 472 | | |
467 | 473 | | |
| 474 | + | |
| 475 | + | |
| 476 | + | |
| 477 | + | |
| 478 | + | |
| 479 | + | |
| 480 | + | |
| 481 | + | |
| 482 | + | |
| 483 | + | |
468 | 484 | | |
| 485 | + | |
| 486 | + | |
| 487 | + | |
| 488 | + | |
| 489 | + | |
| 490 | + | |
469 | 491 | | |
470 | | - | |
471 | | - | |
472 | | - | |
473 | | - | |
| 492 | + | |
| 493 | + | |
| 494 | + | |
| 495 | + | |
| 496 | + | |
| 497 | + | |
| 498 | + | |
| 499 | + | |
| 500 | + | |
474 | 501 | | |
475 | 502 | | |
476 | 503 | | |
477 | 504 | | |
478 | | - | |
| 505 | + | |
| 506 | + | |
| 507 | + | |
479 | 508 | | |
480 | 509 | | |
481 | 510 | | |
482 | | - | |
| 511 | + | |
483 | 512 | | |
484 | 513 | | |
485 | 514 | | |
| |||
595 | 624 | | |
596 | 625 | | |
597 | 626 | | |
598 | | - | |
| 627 | + | |
| 628 | + | |
| 629 | + | |
| 630 | + | |
| 631 | + | |
| 632 | + | |
599 | 633 | | |
600 | 634 | | |
601 | 635 | | |
| |||
604 | 638 | | |
605 | 639 | | |
606 | 640 | | |
607 | | - | |
| 641 | + | |
608 | 642 | | |
609 | 643 | | |
610 | 644 | | |
| |||
661 | 695 | | |
662 | 696 | | |
663 | 697 | | |
| 698 | + | |
664 | 699 | | |
665 | 700 | | |
666 | 701 | | |
667 | 702 | | |
668 | 703 | | |
669 | 704 | | |
| 705 | + | |
| 706 | + | |
| 707 | + | |
| 708 | + | |
| 709 | + | |
670 | 710 | | |
671 | | - | |
| 711 | + | |
| 712 | + | |
| 713 | + | |
| 714 | + | |
| 715 | + | |
| 716 | + | |
672 | 717 | | |
673 | 718 | | |
674 | 719 | | |
675 | 720 | | |
676 | | - | |
| 721 | + | |
677 | 722 | | |
678 | 723 | | |
679 | 724 | | |
| |||
0 commit comments