Commit Graph
91 Commits
Author SHA1 Message Date
Francis Cao f3ce0e64ca typescript fixes, replayer close error, show page toggle fix. 2026-06-17 10:02:12 -07:00
Mike Cao 18b72d3008 fix(tracker): restore link navigation when tracking fails
Use .finally() instead of .then() so internal link navigation is
always restored after e.preventDefault(), even if the tracking
request rejects (e.g. server down or a throwing beforeSend callback).

Fixes #4304
2026-05-29 10:58:11 -07:00
Mike Cao c38ac660cb Added new headers to tracker. 2026-05-23 22:27:39 -07:00
Mike CaoandGitHub c20aede586 Merge pull request #4248 from anvme/fix/tracker-bugs
fix(tracker): track clicks on annotated containers + handle invalid pushState URLs
2026-05-14 22:26:34 -04:00
Stanislaw dcf1b8b8b5 fix(tracker): track clicks on annotated containers and gracefully handle invalid pushState URLs
Three bugs in src/tracker/index.js, all empirically reproduced.

1. handleClicks() missed clicks on container elements: closest('a,button')
   could not find a non-anchor ancestor with data-umami-event, so a click on
   any descendant of <div data-umami-event=...> went untracked. Reworked to
   closest([data-umami-event]) so any annotated ancestor matches.

2. handlePush() called new URL(url, location.href) outside normalize()'s
   try/catch, so a host page calling history.pushState({}, '', invalidUrl)
   would have umami's wrapper throw a TypeError into the host's router.
   normalize(url) already handles base resolution and catches parse errors.

3. The history hook ran the umami callback BEFORE native pushState, so a
   failed native call (SecurityError on invalid URL, etc.) would still mutate
   currentUrl/currentRef and schedule a phantom pageview. Run native first;
   if it throws, the callback never fires and tracker state stays consistent.

Bug 2 verified: 4/10 representative click scenarios missed before
(span inside div, deep span inside div, a with no href, button inside a),
all 10/10 tracked after.

Bug 1+3 verified: pushState({}, '', invalidUrl) now leaves tracker state
unchanged (currentUrl unchanged, no phantom pageview).
2026-05-07 16:04:16 +02:00
Stanislaw 3f9de35907 perf(tracker): defer INP percentile computation to flush time
The INP observer sorted Object.values(interactions) on every event entry,
even though metrics.inp is only read when sendPerformance() flushes.
Defer the sort + p98 computation to flush, and drain queued observer
entries via observer.takeRecords() to capture the most recent
interactions on pagehide/visibilitychange.

Output is identical (same INP value computed). Savings are largest on
interaction-heavy pages and low-end devices where the per-event sort
compounds.
2026-05-07 15:31:49 +02:00
Manuel Fé Santos 8ce833c93b fix: suppress SPA pageview tracking when auto-pageview is disabled
The handlePush function was still calling track() on SPA navigations
regardless of the auto-pageview setting. Gate that call behind the
autoPageview flag while keeping URL state and performance flush active.
2026-04-30 11:22:30 +01:00
Manuel Fé Santos 790354d3ac Add data-auto-pageview attribute to tracker script
Allow disabling the automatic initial pageview while keeping
performance tracking, click handling, and path change detection active.
2026-04-30 11:04:26 +01:00
Francis Cao 3a31ad35b0 revert tracker double init logic 2026-04-11 10:48:22 -07:00
Francis Cao 18a6c2995a move multiple init guard to be per website ID not window 2026-04-08 10:45:32 -07:00
Mike CaoandGitHub f8f86d72aa Merge branch 'dev' into tracker-fetch-priority-low 2026-04-04 17:12:29 -04:00
Mike CaoandGitHub 224bbbb8de Merge pull request #3606 from fauzora/fix/tracker-single-init
fix(tracker): prevent multiple initialization when script injected more than once
2026-03-29 20:05:32 -07:00
Francis Cao de739c66a1 correct performance tracker inconsistency issues 2026-03-23 16:39:15 -07:00
Francis Cao 551e04b487 update calculations to Google's current web vitals spec 2026-03-15 17:40:22 -07:00
Francis Cao 9d72f8803a update ttfb calc to industry standard, fix LCP bug 2026-03-05 12:35:01 -08:00
Francis Cao 1730d495e5 fix performance reset bug 2026-03-05 10:23:00 -08:00
Mike Cao 8c1ee0b3ce Progress check-in. Updated tracker and recorder scripts. 2026-03-04 12:21:36 -08:00
Mike Cao e73d827d21 Merge branch 'session-recording' into dev 2026-02-25 02:32:07 -08:00
Mike CaoandClaude Opus 4.6 ce9e2416fb Add Web Vitals performance tracking (LCP, INP, CLS, FCP, TTFB)
End-to-end performance metrics tracking: dedicated database table with
percentile aggregation, tracker collection behind data-perf attribute,
/api/send handling, report API endpoints, and Performance dashboard page
with threshold-based metric cards, time-series chart, and per-page breakdown.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-08 19:25:20 -08:00
Mike CaoandClaude Opus 4.6 72b5c658e2 Add rrweb-based session recording feature.
Implements full session recording with rrweb for DOM capture and rrweb-player
for playback. Includes: Prisma schema for SessionRecording model, chunked
gzip-compressed storage, recorder script built via Rollup, collection API
endpoint, recordings list/playback UI pages, website recording settings,
and cascade delete support.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-06 15:49:59 -08:00
GochoMugo 8cc571f548 fix: handle denied storage access 2025-12-11 08:53:13 +03:00
Chairil Fauzi F.andGitHub 4abd277bc8 Merge branch 'umami-software:master' into fix/tracker-single-init 2025-12-01 19:16:25 +07:00
Mike Cao fa8d8055df Reformatted files with biome. 2025-11-22 22:42:42 -08:00
Mike Cao 5ded9abbfe Added data-fetch-credentials attribute. Closes #3644 2025-11-13 19:42:04 -08:00
Mike Cao 592f7c0ae7 Added check for REDIS_URL. Closes #3677. 2025-11-10 21:08:55 -08:00
Antti Hilja e85ef4a9c5 Set tracker’s fetch call priority to low
Analytic is important activity but not as important as main business
logic. Setting low priority doesn't mean the fetch call will be more
likely to be discarded etc. it's just a hint to the browser.
2025-10-04 17:33:15 +02:00
Mike Cao 3acb34d599 Merge branch 'master' into dev 2025-09-16 22:45:10 -07:00
Mike Cao 6799bd113a Allow async beforeSend function. Closes #3584 2025-09-09 15:23:49 -07:00
Chairil Fauzi Firmansyah c5298d5d45 fix(hash): improve URL normalization and handling in tracking functions 2025-09-04 18:00:28 +07:00
Chairil Fauzi Firmansyah 29c384f0bb fix(tracker): prevent multiple initialization when script injected more than once 2025-09-04 16:23:41 +07:00
Mike Cao 5ed1d710cb Merge branch 'master' into jajaja
# Conflicts:
#	package.json
#	pnpm-lock.yaml
#	src/lib/detect.ts
2025-07-08 18:45:02 -07:00
Sov3rain 42c0ccc2eb Add keepalive option to tracker fetch request 2025-06-23 15:17:22 +02:00
Mike Cao 94b4b66a3d Merge branch 'dev' into jajaja
# Conflicts:
#	package.json
#	pnpm-lock.yaml
2025-05-09 21:56:07 -07:00
Mike Cao 64505bb417 Added before-send attribute to tracker. 2025-05-07 16:16:38 -07:00
Mike CaoandGitHub 9101f8a478 Merge branch 'dev' into script-simplification 2025-05-05 18:59:11 -05:00
Ali Khaleqi Yekta 9b9cf32ee7 Script simplification: Final minor cleanups 2025-05-04 12:24:23 +03:30
Ali Khaleqi Yekta 5369144b64 Script simplification: Less nesting 2025-05-04 12:18:49 +03:30
Ali Khaleqi Yekta b26fc15fa0 Script simplification: Greatly clarify element tracking logic 2025-05-04 12:17:08 +03:30
Ali Khaleqi Yekta 671dcfceb5 Script simplification: Use Element.closest + less nesting 2025-05-04 12:13:15 +03:30
Ali Khaleqi Yekta e12e5b0d2e Script simplification: In-place headers + re-order 2025-05-04 12:12:23 +03:30
Ali Khaleqi YektaandGitHub 1f36726f73 Minor enhancements and clarifications 2025-05-01 18:34:18 +03:30
Ali Khaleqi YektaandGitHub 130c024c3e Simplify title: No need to observe 2025-05-01 17:33:46 +03:30
Mike Cao be1b2fc272 Merge dev. 2025-04-28 20:09:58 -07:00
Mike Cao e8a933f80e Updated id logic. 2025-04-25 03:19:37 -07:00
perso182 d966668257 Added type check for id 2025-04-01 16:56:17 +02:00
perso182 37ae0374d8 Added id as a parameter to identify and include it in the payload. Removed the usage of localstorage 2025-04-01 11:24:06 +02:00
perso182 224961447c Refactored index.js 2025-03-31 11:04:57 +02:00
perso182 109e8d6d31 Added error handling for JSON.parse 2025-03-31 10:14:31 +02:00
perso182 2c80aa0b24 Use props passed to identify to define session 2025-03-28 11:02:56 +01:00
Mike Cao 0f6cdf8b80 Updated reports components. 2025-03-26 21:54:23 -07:00