@usesequential/browser 1.0.0 → 1.0.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,25 @@
1
1
  # Changelog
2
2
 
3
+ ## 1.0.2
4
+
5
+ - The package now holds the same code as the script tag of 3 November 2026. Changes since 1.0.0:
6
+ - Back or Forward is recorded as a pop, also when the app's router answers it with `replaceState`, and a hash-route
7
+ link is recorded as a push. Without the Navigation API, both are recorded as unknown.
8
+ - A `replaceState` that changes only the query is not a pageview.
9
+ - A click sends the element's `aria-label` (`$el_label`) and its link target (`$el_href`).
10
+ - A person's id is never sent as `$anon_distinct_id`; a second sign-in on one browser no longer moves the first
11
+ person's history.
12
+ - `optOut()` also deletes the recorder's `__lx_replay_sample`, and another tab's `optOut()` opts this tab out at once.
13
+ - A held batch is sent again after each pause, as its own request, for up to 5 minutes.
14
+ - The account-menu privacy check no longer treats every "profile" as account UI.
15
+ - In a URL, the user info is removed up to the last `@` of the authority, so a password that contains `@` no longer
16
+ leaves its end in the URL.
17
+ - The "no data-key" and "no data-api" console lines say how to configure without attributes.
18
+
19
+ ## 1.0.1
20
+
21
+ - README only: where the key comes from when there is no account yet (a trial that a coding agent creates with one call). No code change.
22
+
3
23
  ## 1.0.0
4
24
 
5
25
  - First release: `init(options)` and `VERSION`. The SDK code is `sequential.js`, the file the script tag loads, with
package/README.md CHANGED
@@ -15,7 +15,20 @@ from one call. The code is `sequential.js`, the file that the Sequential script
15
15
  npm install @usesequential/browser
16
16
  ```
17
17
 
18
- Copy the project's **sequential** key (`sq_sequential_…`) and the API host from **Setup** in Sequential.
18
+ You need the project's **sequential** key (`sq_sequential_…`) and the API host, `https://api.usesequential.com`:
19
+
20
+ - **You have a Sequential project:** copy them from **Setup** in Sequential.
21
+ - **No account yet (for example, a coding agent installing this for someone):** create a trial with one call. No
22
+ account is needed. The answer's `ingest_key` is the key; the person claims the trial from an email within 72 hours.
23
+ Until then, the trial accepts events only from `localhost`.
24
+
25
+ ```bash
26
+ curl -X POST https://api.usesequential.com/api/agent/provision \
27
+ -H 'content-type: application/json' \
28
+ -d '{"owner_email": "person@example.com", "platform": "web"}'
29
+ ```
30
+
31
+ Details: [Let your agent set up a trial](https://www.usesequential.com/docs/agent-trial).
19
32
 
20
33
  ## Start it
21
34
 
package/dist/index.cjs CHANGED
@@ -1,4 +1,4 @@
1
- /* @usesequential/browser 1.0.0: the Sequential browser SDK. MIT. https://www.usesequential.com/docs/browser-npm
1
+ /* @usesequential/browser 1.0.2: the Sequential browser SDK. MIT. https://www.usesequential.com/docs/browser-npm
2
2
  * `boot` below is sequential.js, the file the script tag loads, unchanged. */
3
3
  'use strict';
4
4
  var boot = (function (injectedTag) {
@@ -162,15 +162,20 @@ var boot = (function (injectedTag) {
162
162
  logError('data-release is not a release (1 to 64 printable ASCII characters); events are sent without one.');
163
163
  }
164
164
 
165
- // No key or no API: every method stays present and inert, so a bad tag never throws.
165
+ // No key or no API: every method stays present and inert, so a bad tag never throws. Both lines say how to set the
166
+ // values without attributes, for a loader that drops them.
166
167
  var DISABLED = false;
168
+ var CONFIG_HELP =
169
+ ' Loaded through Google Tag Manager or another loader that drops data-* attributes? Set window.sequentialConfig' +
170
+ ' = { key, api } before the SDK loads: https://www.usesequential.com/docs/sequential#configure-without-attributes';
167
171
  if (!KEY) {
168
- logError('the script tag has no data-key — no events will be sent.');
172
+ logError('the script tag has no data-key — no events will be sent.' + CONFIG_HELP);
169
173
  DISABLED = true;
170
174
  } else if (!API_HOST) {
171
175
  logError(
172
176
  'the script tag has no data-api — no events will be sent. The CDN origin is not the ' +
173
- 'ingest origin, so it cannot be guessed from this script’s own src.'
177
+ 'ingest origin, so it cannot be guessed from this script’s own src.' +
178
+ CONFIG_HELP
174
179
  );
175
180
  DISABLED = true;
176
181
  }
@@ -201,13 +206,16 @@ var boot = (function (injectedTag) {
201
206
  var REQUEST_TIMEOUT_MS = 10000;
202
207
  var MAX_SEND_ATTEMPTS = 3;
203
208
  var RETRY_BASE_MS = 500;
204
- // A 429 (the backend's per-project event rate limit): pause for the server's retry time, clamped; hold the refused
205
- // batch and what is captured meanwhile, capped, the oldest dropped first (sequential.core.ts holdRateLimited).
209
+ // A 429 (the backend's per-project event rate limit) or a 503 overloaded (load shed; ClickHouse down): pause for the
210
+ // server's retry time, clamped; hold the refused batch whole and what is captured meanwhile, capped, the oldest dropped
211
+ // first. A held batch is resent after each pause, as its own request, until 5 min after its first refusal
212
+ // (sequential.core.ts holdRateLimited).
206
213
  var RATE_LIMIT_DEFAULT_SEC = 60;
207
214
  var RATE_LIMIT_MIN_SEC = 1;
208
215
  var RATE_LIMIT_MAX_SEC = 300;
209
216
  var MAX_HELD_EVENTS = 100;
210
217
  var MAX_HELD_BYTES = 128 * 1024;
218
+ var MAX_HOLD_MS = 5 * 60 * 1000;
211
219
 
212
220
  var redactor = null;
213
221
 
@@ -222,14 +230,16 @@ var boot = (function (injectedTag) {
222
230
  // out, so a queued optOut() also writes nothing. Meanwhile each write waits in `held` (null removes).
223
231
  var storageOn = false;
224
232
  var held = {};
225
- // What optOut() deletes: every key the SDK writes, except the __sq_opt mark it then sets.
233
+ // What optOut() deletes: every key the SDK writes, except the __sq_opt mark it then sets, and the recorder's
234
+ // __lx_replay_sample (recorder-boot.js sampledIn: '1:' or '0:' + the session id, written when sampling < 1).
226
235
  var STORED_KEYS = [
227
236
  ['localStorage', '__sq_did'],
228
237
  ['localStorage', '__sq_aid'],
229
238
  ['localStorage', '__sq_ath'],
230
239
  ['localStorage', '__sq_ith'],
231
240
  ['sessionStorage', '__sq_sid'],
232
- ['sessionStorage', '__lx_replay_sid']
241
+ ['sessionStorage', '__lx_replay_sid'],
242
+ ['sessionStorage', '__lx_replay_sample']
233
243
  ];
234
244
 
235
245
  // False only when the browser refused the write.
@@ -561,8 +571,13 @@ var boot = (function (injectedTag) {
561
571
  var queueBytes = 0;
562
572
  var flushTimer = null;
563
573
  var pauseTimer = null;
564
- // Events already put back once after a 429 (a batch is resent once). An array, not a WeakSet: this file is ES5.
565
- var resentOnce = [];
574
+ // Refused batches, oldest first, each kept whole and resent one request each: the backend sees the same ids again and
575
+ // stores a batch that did land once (BE src/ingest/dedup.ts).
576
+ var heldBatches = [];
577
+ // When each held event was first refused, as two parallel arrays (not a WeakMap: this file is ES5), at most
578
+ // 2 x MAX_HELD_EVENTS long: more than can be held at once.
579
+ var refusedEvents = [];
580
+ var refusedAt = [];
566
581
 
567
582
  function assign(target, source) {
568
583
  if (!source) return target;
@@ -668,6 +683,7 @@ var boot = (function (injectedTag) {
668
683
  clearContextCookie();
669
684
  queue = [];
670
685
  queueBytes = 0;
686
+ heldBatches = [];
671
687
  clearFlushTimer();
672
688
  if (pauseTimer !== null) {
673
689
  clearTimeout(pauseTimer);
@@ -711,25 +727,48 @@ var boot = (function (injectedTag) {
711
727
  }
712
728
  }
713
729
 
730
+ // Drop the oldest waiting events (held batches first, then the queue) until what waits fits the caps. Only while paused.
714
731
  function trimHeld() {
715
- while (queue.length > MAX_HELD_EVENTS || (queue.length > 1 && queueBytes > MAX_HELD_BYTES)) {
716
- queueBytes -= sizeOf(queue.shift());
732
+ var count = queue.length;
733
+ var bytes = queueBytes;
734
+ var i, j;
735
+ for (i = 0; i < heldBatches.length; i++) {
736
+ count += heldBatches[i].length;
737
+ for (j = 0; j < heldBatches[i].length; j++) bytes += sizeOf(heldBatches[i][j]);
738
+ }
739
+ while (count > MAX_HELD_EVENTS || (count > 1 && bytes > MAX_HELD_BYTES)) {
740
+ var dropped;
741
+ if (heldBatches.length > 0) {
742
+ dropped = heldBatches[0].shift();
743
+ if (heldBatches[0].length === 0) heldBatches.shift();
744
+ } else {
745
+ dropped = queue.shift();
746
+ queueBytes -= sizeOf(dropped);
747
+ }
748
+ count--;
749
+ bytes -= sizeOf(dropped);
717
750
  }
718
751
  }
719
752
 
720
753
  function holdRateLimited(events, sec) {
721
754
  if (stopped) return;
722
- var again = [];
755
+ var now = Date.now();
756
+ var keep = [];
723
757
  for (var i = 0; i < events.length; i++) {
724
- if (resentOnce.indexOf(events[i]) === -1) {
725
- again.push(events[i]);
726
- resentOnce.push(events[i]);
758
+ var k = refusedEvents.indexOf(events[i]);
759
+ if (k === -1) {
760
+ refusedEvents.push(events[i]);
761
+ refusedAt.push(now);
762
+ keep.push(events[i]);
763
+ } else if (now - refusedAt[k] < MAX_HOLD_MS) {
764
+ keep.push(events[i]);
727
765
  }
728
766
  }
729
- while (resentOnce.length > 2 * MAX_HELD_EVENTS) resentOnce.shift();
730
- queue = again.concat(queue);
731
- queueBytes = 0;
732
- for (var j = 0; j < queue.length; j++) queueBytes += sizeOf(queue[j]);
767
+ while (refusedEvents.length > 2 * MAX_HELD_EVENTS) {
768
+ refusedEvents.shift();
769
+ refusedAt.shift();
770
+ }
771
+ if (keep.length > 0) heldBatches.unshift(keep);
733
772
  clearFlushTimer();
734
773
  if (pauseTimer !== null) clearTimeout(pauseTimer);
735
774
  pauseTimer = setTimeout(function () {
@@ -785,19 +824,30 @@ var boot = (function (injectedTag) {
785
824
  });
786
825
  }
787
826
 
827
+ function sendEvents(events) {
828
+ if (!canSend()) return Promise.resolve();
829
+ var body = buildEnvelope(events);
830
+ if (body === null) return Promise.resolve();
831
+ return attemptSend(body, 1, events)['catch'](noop);
832
+ }
833
+
788
834
  function flush() {
789
835
  try {
790
- if (queue.length === 0) return Promise.resolve();
836
+ if (queue.length === 0 && heldBatches.length === 0) return Promise.resolve();
791
837
  clearFlushTimer();
792
838
  // Paused by a 429: the pause's own timer flushes what is held when it ends.
793
839
  if (pauseTimer !== null) return Promise.resolve();
840
+ // Held batches first, each as it was refused; a refusal on the way pauses again and keeps the rest held.
841
+ if (heldBatches.length > 0) {
842
+ return sendEvents(heldBatches.shift()).then(function () {
843
+ if (pauseTimer !== null || stopped) return;
844
+ return flush();
845
+ });
846
+ }
794
847
  var events = queue;
795
848
  queue = [];
796
849
  queueBytes = 0;
797
- if (!canSend()) return Promise.resolve();
798
- var body = buildEnvelope(events);
799
- if (body === null) return Promise.resolve();
800
- return attemptSend(body, 1, events)['catch'](noop);
850
+ return sendEvents(events);
801
851
  } catch (e) {
802
852
  return Promise.resolve();
803
853
  }
@@ -806,9 +856,13 @@ var boot = (function (injectedTag) {
806
856
  function drain() {
807
857
  try {
808
858
  if (optedOut || DISABLED || stopped) return null;
809
- if (queue.length === 0) return null;
859
+ if (queue.length === 0 && heldBatches.length === 0) return null;
810
860
  clearFlushTimer();
811
- var events = queue;
861
+ // The page is going: what is held goes in the one beacon too, oldest first.
862
+ var events = [];
863
+ for (var i = 0; i < heldBatches.length; i++) events = events.concat(heldBatches[i]);
864
+ events = events.concat(queue);
865
+ heldBatches = [];
812
866
  queue = [];
813
867
  queueBytes = 0;
814
868
  var body = buildEnvelope(events);
@@ -906,9 +960,18 @@ var boot = (function (injectedTag) {
906
960
  for (i = 0; i < w.length; i++) if (w[i].length > 2 && inList(idWords, w[i])) return true;
907
961
  }
908
962
 
963
+ // Account UI (the element or one of its 3 nearest ancestors): a class, id or data-testid word `avatar`, `account` or
964
+ // `user-menu`, or an account-menu name with `profile` (profile-menu, profile-dropdown, profile-button, profile-avatar,
965
+ // my-profile, user-profile); or an aria-label that names an account menu (ACCOUNT_LABEL, on the trimmed, lowercased
966
+ // label with its spaces collapsed). `profile` alone is not account UI: it hid "Read my blog" (class profile-blog, nav
967
+ // "Contact and social profiles") on a customer site, 2026-10-26.
968
+ var ACCOUNT_WORD = /(\b|_)(avatar|account|user[-_]?menu|profile[-_](menu|dropdown|button|avatar)|(my|user)[-_]profile)(\b|_)/;
969
+ var ACCOUNT_LABEL = /^(account|user|profile)$|\b(my|your|open) (account|profile)\b|\b(user|account|profile)( navigation)? (menu|dropdown|options)\b/;
909
970
  function inAccountUi(node) {
910
971
  for (var i = 0; node && node.getAttribute && i++ < 4; node = node.parentNode) {
911
- if (/(\b|_)(avatar|account|profile|user[-_]?menu)(\b|_)/.test((node.getAttribute('class') + ' ' + node.id + ' ' + node.getAttribute('data-testid')).toLowerCase()) || /account|profile|user/i.test(node.getAttribute('aria-label'))) return true;
972
+ if (ACCOUNT_WORD.test((node.getAttribute('class') + ' ' + node.id + ' ' + node.getAttribute('data-testid')).toLowerCase())) return true;
973
+ var label = String(node.getAttribute('aria-label') || '').replace(/\s+/g, ' ').replace(/^ | $/g, '').toLowerCase();
974
+ if (label && ACCOUNT_LABEL.test(label)) return true;
912
975
  }
913
976
  }
914
977
 
@@ -921,23 +984,32 @@ var boot = (function (injectedTag) {
921
984
  learnIdentity(newDistinctId, props);
922
985
  var previous = distinctId;
923
986
  var hasTraits = props !== undefined && props !== null && typeof props === 'object' && Object.keys(props).length > 0;
924
- var hash = hasTraits ? identifyHash(newDistinctId, props) : null;
987
+ // __sq_ith is written on every identify, with no traits too: a stored one says the stored id is a person's.
988
+ var hash = identifyHash(newDistinctId, hasTraits ? props : {});
989
+ var stored = readLocal(IDENTIFY_HASH_KEY, memoryIdentifyHash);
925
990
  if (previous === newDistinctId) {
926
- // Same person again (a reload): changed traits still go out; the same traits, or none, send nothing.
927
- if (hash === null || hash === readLocal(IDENTIFY_HASH_KEY, memoryIdentifyHash)) return;
991
+ // Same person again (a reload): changed traits still go out; the same traits, or none, send nothing. None
992
+ // keeps the stored hash, and writes one only where there is none (an id identified before ith was always set).
993
+ if (hasTraits ? hash === stored : stored !== null && stored !== undefined) return;
928
994
  memoryIdentifyHash = hash;
929
995
  writeLocal(IDENTIFY_HASH_KEY, hash);
930
- captureInternal('$identify', assign({}, props));
996
+ if (hasTraits) captureInternal('$identify', assign({}, props));
931
997
  return;
932
998
  }
933
999
  memoryIdentifyHash = hash;
934
1000
  writeLocal(IDENTIFY_HASH_KEY, hash);
935
1001
  distinctId = newDistinctId;
936
1002
  writeDistinctId(newDistinctId);
937
- contextDistinctId = previous;
938
1003
 
939
1004
  var merged = assign({}, props);
940
- merged.$anon_distinct_id = previous;
1005
+ if (stored === null || stored === undefined) {
1006
+ contextDistinctId = previous;
1007
+ merged.$anon_distinct_id = previous;
1008
+ } else {
1009
+ // Another person on this browser (no reset): the previous id is a person, not an anonymous visitor, so it is
1010
+ // no claim. Sent as one, it moved that person's history to this one (the People duplicate, 2026-10-23).
1011
+ contextDistinctId = newDistinctId;
1012
+ }
941
1013
  captureInternal('$identify', merged);
942
1014
  } catch (e) {}
943
1015
  }
@@ -1006,6 +1078,7 @@ var boot = (function (injectedTag) {
1006
1078
 
1007
1079
  queue = [];
1008
1080
  queueBytes = 0;
1081
+ heldBatches = [];
1009
1082
  clearFlushTimer();
1010
1083
  clearContextCookie();
1011
1084
  forgetStorage();
@@ -1050,6 +1123,17 @@ var boot = (function (injectedTag) {
1050
1123
  } catch (e) {}
1051
1124
  }
1052
1125
 
1126
+ // Another tab's optOut() (the shared __sq_opt mark set to '1') opts this tab out at once: it stops sending, holds
1127
+ // storage and does not write back the ids that tab deleted. Another tab's optIn() (the mark removed, newValue null)
1128
+ // does NOT opt this tab in, and neither does localStorage.clear() (key null): opt-in takes effect from the next page
1129
+ // load, for analytics and the recorder alike (mgmt 2026-10-23, as the recorder's 2026-10-17 ruling). optOut() here
1130
+ // writes the same '1', which fires no further event.
1131
+ try {
1132
+ window.addEventListener('storage', function (e) {
1133
+ if (e && e.key === OPT_OUT_KEY && e.newValue === '1' && !optedOut) optOut();
1134
+ });
1135
+ } catch (e) {}
1136
+
1053
1137
  function captureException(error, props) {
1054
1138
  try {
1055
1139
  if (optedOut || DISABLED) return;
@@ -1285,10 +1369,28 @@ var boot = (function (injectedTag) {
1285
1369
  route = hashRouteOf(s.slice(hash));
1286
1370
  s = s.slice(0, hash);
1287
1371
  }
1288
- s = s.replace(/^([A-Za-z][A-Za-z0-9+.-]*:\/\/)[^/?#@]*@/, '$1');
1372
+ // userinfo runs to the authority's LAST '@' (an '@' in the user or password); never past '/', '?' or '#'
1373
+ s = s.replace(/^([A-Za-z][A-Za-z0-9+.-]*:\/\/)[^/?#]*@/, '$1');
1289
1374
  return rdct.boundedRedact(s + route, URL_MAX);
1290
1375
  }
1291
1376
 
1377
+ // A clicked link's target ($el_href, owner decision 2026-10-26): resolved against the page; a scheme other than http(s)
1378
+ // is the scheme only, another origin its origin only (never another site's path), the page's own origin keeps the path
1379
+ // with no query, fragment or userinfo. Ingest re-scrubs it and is the authority (BE: src/adapters/link-target-scrub.ts):
1380
+ // id-like segments barred, the origin only under mask_attributes strict.
1381
+ function linkTarget(raw) {
1382
+ var page, target;
1383
+ try {
1384
+ page = new URL(String(window.location.href));
1385
+ target = new URL(String(raw), page.href);
1386
+ } catch (e) {
1387
+ return undefined;
1388
+ }
1389
+ if (!/^https?:$/.test(target.protocol)) return target.protocol;
1390
+ if (target.origin !== page.origin) return target.origin;
1391
+ return target.origin + target.pathname;
1392
+ }
1393
+
1292
1394
  function currentUrl() {
1293
1395
  if (!redactor) return undefined;
1294
1396
  try {
@@ -1376,6 +1478,17 @@ var boot = (function (injectedTag) {
1376
1478
  }
1377
1479
  }
1378
1480
 
1481
+ // sequential.autocapture.ts pathKey: the page without its query (pathname + hash route). A replaceState that keeps
1482
+ // it is not a pageview (2026-10-22): a player's ?t= or a list's ?sort= rewritten in place is the same page.
1483
+ function pathKey(href) {
1484
+ try {
1485
+ var u = new URL(href);
1486
+ return u.pathname + hashRouteOf(u.hash);
1487
+ } catch (e) {
1488
+ return String(href);
1489
+ }
1490
+ }
1491
+
1379
1492
  // $nav (sequential.autocapture.ts PageviewNav): popstate is also a forward fragment navigation, so
1380
1493
  // only the Navigation API's navigationType names it; without it, 'unknown'.
1381
1494
  function navFromNavigationType(type) {
@@ -1467,21 +1580,55 @@ var boot = (function (injectedTag) {
1467
1580
  // route) for every trigger, as in
1468
1581
  // sequential.autocapture.ts pageKey: a router's same-URL replaceState is not a pageview.
1469
1582
  var lastPageKey = null;
1583
+ var lastPathKey = null;
1470
1584
  var lastNavigationType;
1471
1585
  var navigationApi = false;
1472
1586
 
1473
1587
  function checkPage(nav) {
1474
1588
  try {
1475
1589
  lastNavigationType = undefined;
1590
+ popKind = undefined;
1476
1591
  var key = pageKey(String(window.location.href));
1477
1592
  if (key === lastPageKey) return;
1593
+ // A query-only replaceState moves both keys without a pageview (sequential.autocapture.ts checkPage).
1594
+ var path = pathKey(String(window.location.href));
1595
+ var queryOnlyReplace = nav === 'replace' && path === lastPathKey;
1478
1596
  lastPageKey = key;
1597
+ lastPathKey = path;
1598
+ if (queryOnlyReplace) return;
1479
1599
  capturePageview(undefined, nav);
1480
1600
  } catch (e) {}
1481
1601
  }
1482
1602
 
1603
+ // A traversal the page's router answers with replaceState (sequential.autocapture.ts inPopstate, F1): a push or
1604
+ // replace while a popstate is being handled (window.event, or our capture listener's mark) is that traversal, of
1605
+ // the kind of the last navigate event before it that was not a replace.
1606
+ var popPending = false;
1607
+ var popKind;
1608
+ function onPopCapture() {
1609
+ try {
1610
+ popPending = true;
1611
+ setTimeout(function () {
1612
+ popPending = false;
1613
+ }, 0);
1614
+ } catch (e) {}
1615
+ }
1616
+ function inPopstate() {
1617
+ if (popPending) return true;
1618
+ try {
1619
+ var ev = window.event;
1620
+ return !!ev && ev.type === 'popstate';
1621
+ } catch (e) {
1622
+ return false;
1623
+ }
1624
+ }
1625
+ function hookNav(kind) {
1626
+ return inPopstate() ? (navigationApi ? navFromNavigationType(popKind) : 'unknown') : kind;
1627
+ }
1628
+
1483
1629
  function onPopState() {
1484
- checkPage(navigationApi ? navFromNavigationType(lastNavigationType) : 'unknown');
1630
+ checkPage(navigationApi ? navFromNavigationType(popKind) : 'unknown');
1631
+ popPending = false;
1485
1632
  }
1486
1633
 
1487
1634
  // $click's props; $rageclick and $deadclick send the same, so the detector groups all three.
@@ -1491,12 +1638,23 @@ var boot = (function (injectedTag) {
1491
1638
  var identity = DETECT_IDENTITY && raw !== undefined && (inAccountUi(matched) || namesPerson(raw));
1492
1639
  var noIds = closestMatching(matched, '[data-sq-private]') || (DETECT_IDENTITY && namesPerson(stableSelector(matched)));
1493
1640
  var selector = stableSelector(matched, noIds);
1641
+ // $el_label (the aria-label) and $el_href (the link target, linkTarget) are element text like $el_text (owner
1642
+ // decision 2026-10-26, soc2 rule): none under data-sq-mask/-private, in account UI, or when the text, the label or
1643
+ // the target names the identified person; the label redacted and capped like the text. An icon button's label is
1644
+ // often its only name.
1645
+ var label = masked ? '' : String(matched.getAttribute('aria-label') || '').replace(/\s+/g, ' ').replace(/^ | $/g, '');
1646
+ var anchor = masked ? null : closestMatching(matched, 'a[href]');
1647
+ var href = anchor ? linkTarget(anchor.getAttribute('href')) : undefined;
1648
+ var labelOrHrefIdentity = DETECT_IDENTITY && (label || href) &&
1649
+ (identity || inAccountUi(matched) || (label && namesPerson(label)) || (href && namesPerson(href)));
1494
1650
  return {
1495
1651
  $el_tag_name: tagNameOf(matched),
1496
1652
  $el_selector: cap(selector, EL_SELECTOR_MAX),
1497
1653
  $el_id: matched.id && !noIds ? cap(String(matched.id), EL_ID_MAX) : undefined,
1498
1654
  $el_data: masked || identity ? undefined : dataAttrs(matched, redactor),
1499
- $el_text: raw !== undefined && !identity ? redactor.boundedRedact(raw, CLICK_TEXT_MAX) : undefined
1655
+ $el_text: raw !== undefined && !identity ? redactor.boundedRedact(raw, CLICK_TEXT_MAX) : undefined,
1656
+ $el_label: label && !labelOrHrefIdentity ? redactor.boundedRedact(label, CLICK_TEXT_MAX) : undefined,
1657
+ $el_href: href && !labelOrHrefIdentity ? redactor.boundedRedact(href, URL_MAX) : undefined
1500
1658
  };
1501
1659
  }
1502
1660
 
@@ -1689,12 +1847,14 @@ var boot = (function (injectedTag) {
1689
1847
  document.addEventListener('focusin', onFocusIn, true);
1690
1848
  document.addEventListener('selectionchange', onSelectionChange, true);
1691
1849
  document.addEventListener('scroll', onScroll, true);
1850
+ window.addEventListener('popstate', onPopCapture, true);
1692
1851
  window.addEventListener('popstate', onPopState);
1693
1852
  try {
1694
1853
  var navigation = window.navigation;
1695
1854
  if (navigation && typeof navigation.addEventListener === 'function') {
1696
1855
  navigation.addEventListener('navigate', function (ev) {
1697
1856
  lastNavigationType = ev.navigationType;
1857
+ if (ev.navigationType !== 'replace') popKind = ev.navigationType;
1698
1858
  });
1699
1859
  navigationApi = true;
1700
1860
  }
@@ -1707,20 +1867,21 @@ var boot = (function (injectedTag) {
1707
1867
  if (typeof originalPush === 'function') {
1708
1868
  history.pushState = function () {
1709
1869
  var result = originalPush.apply(history, arguments);
1710
- checkPage('push');
1870
+ checkPage(hookNav('push'));
1711
1871
  return result;
1712
1872
  };
1713
1873
  }
1714
1874
  if (typeof originalReplace === 'function') {
1715
1875
  history.replaceState = function () {
1716
1876
  var result = originalReplace.apply(history, arguments);
1717
- checkPage('replace');
1877
+ checkPage(hookNav('replace'));
1718
1878
  return result;
1719
1879
  };
1720
1880
  }
1721
1881
  } catch (e) {}
1722
1882
 
1723
1883
  lastPageKey = pageKey(attachUrl || String(window.location.href));
1884
+ lastPathKey = pathKey(attachUrl || String(window.location.href));
1724
1885
  capturePageview(attachUrl, 'load');
1725
1886
  }
1726
1887
 
@@ -1878,7 +2039,7 @@ var boot = (function (injectedTag) {
1878
2039
  }
1879
2040
  });
1880
2041
 
1881
- var VERSION = '1.0.0';
2042
+ var VERSION = '1.0.2';
1882
2043
  var running = null;
1883
2044
 
1884
2045
  function logLine(level, message) {
package/dist/index.mjs CHANGED
@@ -1,4 +1,4 @@
1
- /* @usesequential/browser 1.0.0: the Sequential browser SDK. MIT. https://www.usesequential.com/docs/browser-npm
1
+ /* @usesequential/browser 1.0.2: the Sequential browser SDK. MIT. https://www.usesequential.com/docs/browser-npm
2
2
  * `boot` below is sequential.js, the file the script tag loads, unchanged. */
3
3
  var boot = (function (injectedTag) {
4
4
  'use strict';
@@ -161,15 +161,20 @@ var boot = (function (injectedTag) {
161
161
  logError('data-release is not a release (1 to 64 printable ASCII characters); events are sent without one.');
162
162
  }
163
163
 
164
- // No key or no API: every method stays present and inert, so a bad tag never throws.
164
+ // No key or no API: every method stays present and inert, so a bad tag never throws. Both lines say how to set the
165
+ // values without attributes, for a loader that drops them.
165
166
  var DISABLED = false;
167
+ var CONFIG_HELP =
168
+ ' Loaded through Google Tag Manager or another loader that drops data-* attributes? Set window.sequentialConfig' +
169
+ ' = { key, api } before the SDK loads: https://www.usesequential.com/docs/sequential#configure-without-attributes';
166
170
  if (!KEY) {
167
- logError('the script tag has no data-key — no events will be sent.');
171
+ logError('the script tag has no data-key — no events will be sent.' + CONFIG_HELP);
168
172
  DISABLED = true;
169
173
  } else if (!API_HOST) {
170
174
  logError(
171
175
  'the script tag has no data-api — no events will be sent. The CDN origin is not the ' +
172
- 'ingest origin, so it cannot be guessed from this script’s own src.'
176
+ 'ingest origin, so it cannot be guessed from this script’s own src.' +
177
+ CONFIG_HELP
173
178
  );
174
179
  DISABLED = true;
175
180
  }
@@ -200,13 +205,16 @@ var boot = (function (injectedTag) {
200
205
  var REQUEST_TIMEOUT_MS = 10000;
201
206
  var MAX_SEND_ATTEMPTS = 3;
202
207
  var RETRY_BASE_MS = 500;
203
- // A 429 (the backend's per-project event rate limit): pause for the server's retry time, clamped; hold the refused
204
- // batch and what is captured meanwhile, capped, the oldest dropped first (sequential.core.ts holdRateLimited).
208
+ // A 429 (the backend's per-project event rate limit) or a 503 overloaded (load shed; ClickHouse down): pause for the
209
+ // server's retry time, clamped; hold the refused batch whole and what is captured meanwhile, capped, the oldest dropped
210
+ // first. A held batch is resent after each pause, as its own request, until 5 min after its first refusal
211
+ // (sequential.core.ts holdRateLimited).
205
212
  var RATE_LIMIT_DEFAULT_SEC = 60;
206
213
  var RATE_LIMIT_MIN_SEC = 1;
207
214
  var RATE_LIMIT_MAX_SEC = 300;
208
215
  var MAX_HELD_EVENTS = 100;
209
216
  var MAX_HELD_BYTES = 128 * 1024;
217
+ var MAX_HOLD_MS = 5 * 60 * 1000;
210
218
 
211
219
  var redactor = null;
212
220
 
@@ -221,14 +229,16 @@ var boot = (function (injectedTag) {
221
229
  // out, so a queued optOut() also writes nothing. Meanwhile each write waits in `held` (null removes).
222
230
  var storageOn = false;
223
231
  var held = {};
224
- // What optOut() deletes: every key the SDK writes, except the __sq_opt mark it then sets.
232
+ // What optOut() deletes: every key the SDK writes, except the __sq_opt mark it then sets, and the recorder's
233
+ // __lx_replay_sample (recorder-boot.js sampledIn: '1:' or '0:' + the session id, written when sampling < 1).
225
234
  var STORED_KEYS = [
226
235
  ['localStorage', '__sq_did'],
227
236
  ['localStorage', '__sq_aid'],
228
237
  ['localStorage', '__sq_ath'],
229
238
  ['localStorage', '__sq_ith'],
230
239
  ['sessionStorage', '__sq_sid'],
231
- ['sessionStorage', '__lx_replay_sid']
240
+ ['sessionStorage', '__lx_replay_sid'],
241
+ ['sessionStorage', '__lx_replay_sample']
232
242
  ];
233
243
 
234
244
  // False only when the browser refused the write.
@@ -560,8 +570,13 @@ var boot = (function (injectedTag) {
560
570
  var queueBytes = 0;
561
571
  var flushTimer = null;
562
572
  var pauseTimer = null;
563
- // Events already put back once after a 429 (a batch is resent once). An array, not a WeakSet: this file is ES5.
564
- var resentOnce = [];
573
+ // Refused batches, oldest first, each kept whole and resent one request each: the backend sees the same ids again and
574
+ // stores a batch that did land once (BE src/ingest/dedup.ts).
575
+ var heldBatches = [];
576
+ // When each held event was first refused, as two parallel arrays (not a WeakMap: this file is ES5), at most
577
+ // 2 x MAX_HELD_EVENTS long: more than can be held at once.
578
+ var refusedEvents = [];
579
+ var refusedAt = [];
565
580
 
566
581
  function assign(target, source) {
567
582
  if (!source) return target;
@@ -667,6 +682,7 @@ var boot = (function (injectedTag) {
667
682
  clearContextCookie();
668
683
  queue = [];
669
684
  queueBytes = 0;
685
+ heldBatches = [];
670
686
  clearFlushTimer();
671
687
  if (pauseTimer !== null) {
672
688
  clearTimeout(pauseTimer);
@@ -710,25 +726,48 @@ var boot = (function (injectedTag) {
710
726
  }
711
727
  }
712
728
 
729
+ // Drop the oldest waiting events (held batches first, then the queue) until what waits fits the caps. Only while paused.
713
730
  function trimHeld() {
714
- while (queue.length > MAX_HELD_EVENTS || (queue.length > 1 && queueBytes > MAX_HELD_BYTES)) {
715
- queueBytes -= sizeOf(queue.shift());
731
+ var count = queue.length;
732
+ var bytes = queueBytes;
733
+ var i, j;
734
+ for (i = 0; i < heldBatches.length; i++) {
735
+ count += heldBatches[i].length;
736
+ for (j = 0; j < heldBatches[i].length; j++) bytes += sizeOf(heldBatches[i][j]);
737
+ }
738
+ while (count > MAX_HELD_EVENTS || (count > 1 && bytes > MAX_HELD_BYTES)) {
739
+ var dropped;
740
+ if (heldBatches.length > 0) {
741
+ dropped = heldBatches[0].shift();
742
+ if (heldBatches[0].length === 0) heldBatches.shift();
743
+ } else {
744
+ dropped = queue.shift();
745
+ queueBytes -= sizeOf(dropped);
746
+ }
747
+ count--;
748
+ bytes -= sizeOf(dropped);
716
749
  }
717
750
  }
718
751
 
719
752
  function holdRateLimited(events, sec) {
720
753
  if (stopped) return;
721
- var again = [];
754
+ var now = Date.now();
755
+ var keep = [];
722
756
  for (var i = 0; i < events.length; i++) {
723
- if (resentOnce.indexOf(events[i]) === -1) {
724
- again.push(events[i]);
725
- resentOnce.push(events[i]);
757
+ var k = refusedEvents.indexOf(events[i]);
758
+ if (k === -1) {
759
+ refusedEvents.push(events[i]);
760
+ refusedAt.push(now);
761
+ keep.push(events[i]);
762
+ } else if (now - refusedAt[k] < MAX_HOLD_MS) {
763
+ keep.push(events[i]);
726
764
  }
727
765
  }
728
- while (resentOnce.length > 2 * MAX_HELD_EVENTS) resentOnce.shift();
729
- queue = again.concat(queue);
730
- queueBytes = 0;
731
- for (var j = 0; j < queue.length; j++) queueBytes += sizeOf(queue[j]);
766
+ while (refusedEvents.length > 2 * MAX_HELD_EVENTS) {
767
+ refusedEvents.shift();
768
+ refusedAt.shift();
769
+ }
770
+ if (keep.length > 0) heldBatches.unshift(keep);
732
771
  clearFlushTimer();
733
772
  if (pauseTimer !== null) clearTimeout(pauseTimer);
734
773
  pauseTimer = setTimeout(function () {
@@ -784,19 +823,30 @@ var boot = (function (injectedTag) {
784
823
  });
785
824
  }
786
825
 
826
+ function sendEvents(events) {
827
+ if (!canSend()) return Promise.resolve();
828
+ var body = buildEnvelope(events);
829
+ if (body === null) return Promise.resolve();
830
+ return attemptSend(body, 1, events)['catch'](noop);
831
+ }
832
+
787
833
  function flush() {
788
834
  try {
789
- if (queue.length === 0) return Promise.resolve();
835
+ if (queue.length === 0 && heldBatches.length === 0) return Promise.resolve();
790
836
  clearFlushTimer();
791
837
  // Paused by a 429: the pause's own timer flushes what is held when it ends.
792
838
  if (pauseTimer !== null) return Promise.resolve();
839
+ // Held batches first, each as it was refused; a refusal on the way pauses again and keeps the rest held.
840
+ if (heldBatches.length > 0) {
841
+ return sendEvents(heldBatches.shift()).then(function () {
842
+ if (pauseTimer !== null || stopped) return;
843
+ return flush();
844
+ });
845
+ }
793
846
  var events = queue;
794
847
  queue = [];
795
848
  queueBytes = 0;
796
- if (!canSend()) return Promise.resolve();
797
- var body = buildEnvelope(events);
798
- if (body === null) return Promise.resolve();
799
- return attemptSend(body, 1, events)['catch'](noop);
849
+ return sendEvents(events);
800
850
  } catch (e) {
801
851
  return Promise.resolve();
802
852
  }
@@ -805,9 +855,13 @@ var boot = (function (injectedTag) {
805
855
  function drain() {
806
856
  try {
807
857
  if (optedOut || DISABLED || stopped) return null;
808
- if (queue.length === 0) return null;
858
+ if (queue.length === 0 && heldBatches.length === 0) return null;
809
859
  clearFlushTimer();
810
- var events = queue;
860
+ // The page is going: what is held goes in the one beacon too, oldest first.
861
+ var events = [];
862
+ for (var i = 0; i < heldBatches.length; i++) events = events.concat(heldBatches[i]);
863
+ events = events.concat(queue);
864
+ heldBatches = [];
811
865
  queue = [];
812
866
  queueBytes = 0;
813
867
  var body = buildEnvelope(events);
@@ -905,9 +959,18 @@ var boot = (function (injectedTag) {
905
959
  for (i = 0; i < w.length; i++) if (w[i].length > 2 && inList(idWords, w[i])) return true;
906
960
  }
907
961
 
962
+ // Account UI (the element or one of its 3 nearest ancestors): a class, id or data-testid word `avatar`, `account` or
963
+ // `user-menu`, or an account-menu name with `profile` (profile-menu, profile-dropdown, profile-button, profile-avatar,
964
+ // my-profile, user-profile); or an aria-label that names an account menu (ACCOUNT_LABEL, on the trimmed, lowercased
965
+ // label with its spaces collapsed). `profile` alone is not account UI: it hid "Read my blog" (class profile-blog, nav
966
+ // "Contact and social profiles") on a customer site, 2026-10-26.
967
+ var ACCOUNT_WORD = /(\b|_)(avatar|account|user[-_]?menu|profile[-_](menu|dropdown|button|avatar)|(my|user)[-_]profile)(\b|_)/;
968
+ var ACCOUNT_LABEL = /^(account|user|profile)$|\b(my|your|open) (account|profile)\b|\b(user|account|profile)( navigation)? (menu|dropdown|options)\b/;
908
969
  function inAccountUi(node) {
909
970
  for (var i = 0; node && node.getAttribute && i++ < 4; node = node.parentNode) {
910
- if (/(\b|_)(avatar|account|profile|user[-_]?menu)(\b|_)/.test((node.getAttribute('class') + ' ' + node.id + ' ' + node.getAttribute('data-testid')).toLowerCase()) || /account|profile|user/i.test(node.getAttribute('aria-label'))) return true;
971
+ if (ACCOUNT_WORD.test((node.getAttribute('class') + ' ' + node.id + ' ' + node.getAttribute('data-testid')).toLowerCase())) return true;
972
+ var label = String(node.getAttribute('aria-label') || '').replace(/\s+/g, ' ').replace(/^ | $/g, '').toLowerCase();
973
+ if (label && ACCOUNT_LABEL.test(label)) return true;
911
974
  }
912
975
  }
913
976
 
@@ -920,23 +983,32 @@ var boot = (function (injectedTag) {
920
983
  learnIdentity(newDistinctId, props);
921
984
  var previous = distinctId;
922
985
  var hasTraits = props !== undefined && props !== null && typeof props === 'object' && Object.keys(props).length > 0;
923
- var hash = hasTraits ? identifyHash(newDistinctId, props) : null;
986
+ // __sq_ith is written on every identify, with no traits too: a stored one says the stored id is a person's.
987
+ var hash = identifyHash(newDistinctId, hasTraits ? props : {});
988
+ var stored = readLocal(IDENTIFY_HASH_KEY, memoryIdentifyHash);
924
989
  if (previous === newDistinctId) {
925
- // Same person again (a reload): changed traits still go out; the same traits, or none, send nothing.
926
- if (hash === null || hash === readLocal(IDENTIFY_HASH_KEY, memoryIdentifyHash)) return;
990
+ // Same person again (a reload): changed traits still go out; the same traits, or none, send nothing. None
991
+ // keeps the stored hash, and writes one only where there is none (an id identified before ith was always set).
992
+ if (hasTraits ? hash === stored : stored !== null && stored !== undefined) return;
927
993
  memoryIdentifyHash = hash;
928
994
  writeLocal(IDENTIFY_HASH_KEY, hash);
929
- captureInternal('$identify', assign({}, props));
995
+ if (hasTraits) captureInternal('$identify', assign({}, props));
930
996
  return;
931
997
  }
932
998
  memoryIdentifyHash = hash;
933
999
  writeLocal(IDENTIFY_HASH_KEY, hash);
934
1000
  distinctId = newDistinctId;
935
1001
  writeDistinctId(newDistinctId);
936
- contextDistinctId = previous;
937
1002
 
938
1003
  var merged = assign({}, props);
939
- merged.$anon_distinct_id = previous;
1004
+ if (stored === null || stored === undefined) {
1005
+ contextDistinctId = previous;
1006
+ merged.$anon_distinct_id = previous;
1007
+ } else {
1008
+ // Another person on this browser (no reset): the previous id is a person, not an anonymous visitor, so it is
1009
+ // no claim. Sent as one, it moved that person's history to this one (the People duplicate, 2026-10-23).
1010
+ contextDistinctId = newDistinctId;
1011
+ }
940
1012
  captureInternal('$identify', merged);
941
1013
  } catch (e) {}
942
1014
  }
@@ -1005,6 +1077,7 @@ var boot = (function (injectedTag) {
1005
1077
 
1006
1078
  queue = [];
1007
1079
  queueBytes = 0;
1080
+ heldBatches = [];
1008
1081
  clearFlushTimer();
1009
1082
  clearContextCookie();
1010
1083
  forgetStorage();
@@ -1049,6 +1122,17 @@ var boot = (function (injectedTag) {
1049
1122
  } catch (e) {}
1050
1123
  }
1051
1124
 
1125
+ // Another tab's optOut() (the shared __sq_opt mark set to '1') opts this tab out at once: it stops sending, holds
1126
+ // storage and does not write back the ids that tab deleted. Another tab's optIn() (the mark removed, newValue null)
1127
+ // does NOT opt this tab in, and neither does localStorage.clear() (key null): opt-in takes effect from the next page
1128
+ // load, for analytics and the recorder alike (mgmt 2026-10-23, as the recorder's 2026-10-17 ruling). optOut() here
1129
+ // writes the same '1', which fires no further event.
1130
+ try {
1131
+ window.addEventListener('storage', function (e) {
1132
+ if (e && e.key === OPT_OUT_KEY && e.newValue === '1' && !optedOut) optOut();
1133
+ });
1134
+ } catch (e) {}
1135
+
1052
1136
  function captureException(error, props) {
1053
1137
  try {
1054
1138
  if (optedOut || DISABLED) return;
@@ -1284,10 +1368,28 @@ var boot = (function (injectedTag) {
1284
1368
  route = hashRouteOf(s.slice(hash));
1285
1369
  s = s.slice(0, hash);
1286
1370
  }
1287
- s = s.replace(/^([A-Za-z][A-Za-z0-9+.-]*:\/\/)[^/?#@]*@/, '$1');
1371
+ // userinfo runs to the authority's LAST '@' (an '@' in the user or password); never past '/', '?' or '#'
1372
+ s = s.replace(/^([A-Za-z][A-Za-z0-9+.-]*:\/\/)[^/?#]*@/, '$1');
1288
1373
  return rdct.boundedRedact(s + route, URL_MAX);
1289
1374
  }
1290
1375
 
1376
+ // A clicked link's target ($el_href, owner decision 2026-10-26): resolved against the page; a scheme other than http(s)
1377
+ // is the scheme only, another origin its origin only (never another site's path), the page's own origin keeps the path
1378
+ // with no query, fragment or userinfo. Ingest re-scrubs it and is the authority (BE: src/adapters/link-target-scrub.ts):
1379
+ // id-like segments barred, the origin only under mask_attributes strict.
1380
+ function linkTarget(raw) {
1381
+ var page, target;
1382
+ try {
1383
+ page = new URL(String(window.location.href));
1384
+ target = new URL(String(raw), page.href);
1385
+ } catch (e) {
1386
+ return undefined;
1387
+ }
1388
+ if (!/^https?:$/.test(target.protocol)) return target.protocol;
1389
+ if (target.origin !== page.origin) return target.origin;
1390
+ return target.origin + target.pathname;
1391
+ }
1392
+
1291
1393
  function currentUrl() {
1292
1394
  if (!redactor) return undefined;
1293
1395
  try {
@@ -1375,6 +1477,17 @@ var boot = (function (injectedTag) {
1375
1477
  }
1376
1478
  }
1377
1479
 
1480
+ // sequential.autocapture.ts pathKey: the page without its query (pathname + hash route). A replaceState that keeps
1481
+ // it is not a pageview (2026-10-22): a player's ?t= or a list's ?sort= rewritten in place is the same page.
1482
+ function pathKey(href) {
1483
+ try {
1484
+ var u = new URL(href);
1485
+ return u.pathname + hashRouteOf(u.hash);
1486
+ } catch (e) {
1487
+ return String(href);
1488
+ }
1489
+ }
1490
+
1378
1491
  // $nav (sequential.autocapture.ts PageviewNav): popstate is also a forward fragment navigation, so
1379
1492
  // only the Navigation API's navigationType names it; without it, 'unknown'.
1380
1493
  function navFromNavigationType(type) {
@@ -1466,21 +1579,55 @@ var boot = (function (injectedTag) {
1466
1579
  // route) for every trigger, as in
1467
1580
  // sequential.autocapture.ts pageKey: a router's same-URL replaceState is not a pageview.
1468
1581
  var lastPageKey = null;
1582
+ var lastPathKey = null;
1469
1583
  var lastNavigationType;
1470
1584
  var navigationApi = false;
1471
1585
 
1472
1586
  function checkPage(nav) {
1473
1587
  try {
1474
1588
  lastNavigationType = undefined;
1589
+ popKind = undefined;
1475
1590
  var key = pageKey(String(window.location.href));
1476
1591
  if (key === lastPageKey) return;
1592
+ // A query-only replaceState moves both keys without a pageview (sequential.autocapture.ts checkPage).
1593
+ var path = pathKey(String(window.location.href));
1594
+ var queryOnlyReplace = nav === 'replace' && path === lastPathKey;
1477
1595
  lastPageKey = key;
1596
+ lastPathKey = path;
1597
+ if (queryOnlyReplace) return;
1478
1598
  capturePageview(undefined, nav);
1479
1599
  } catch (e) {}
1480
1600
  }
1481
1601
 
1602
+ // A traversal the page's router answers with replaceState (sequential.autocapture.ts inPopstate, F1): a push or
1603
+ // replace while a popstate is being handled (window.event, or our capture listener's mark) is that traversal, of
1604
+ // the kind of the last navigate event before it that was not a replace.
1605
+ var popPending = false;
1606
+ var popKind;
1607
+ function onPopCapture() {
1608
+ try {
1609
+ popPending = true;
1610
+ setTimeout(function () {
1611
+ popPending = false;
1612
+ }, 0);
1613
+ } catch (e) {}
1614
+ }
1615
+ function inPopstate() {
1616
+ if (popPending) return true;
1617
+ try {
1618
+ var ev = window.event;
1619
+ return !!ev && ev.type === 'popstate';
1620
+ } catch (e) {
1621
+ return false;
1622
+ }
1623
+ }
1624
+ function hookNav(kind) {
1625
+ return inPopstate() ? (navigationApi ? navFromNavigationType(popKind) : 'unknown') : kind;
1626
+ }
1627
+
1482
1628
  function onPopState() {
1483
- checkPage(navigationApi ? navFromNavigationType(lastNavigationType) : 'unknown');
1629
+ checkPage(navigationApi ? navFromNavigationType(popKind) : 'unknown');
1630
+ popPending = false;
1484
1631
  }
1485
1632
 
1486
1633
  // $click's props; $rageclick and $deadclick send the same, so the detector groups all three.
@@ -1490,12 +1637,23 @@ var boot = (function (injectedTag) {
1490
1637
  var identity = DETECT_IDENTITY && raw !== undefined && (inAccountUi(matched) || namesPerson(raw));
1491
1638
  var noIds = closestMatching(matched, '[data-sq-private]') || (DETECT_IDENTITY && namesPerson(stableSelector(matched)));
1492
1639
  var selector = stableSelector(matched, noIds);
1640
+ // $el_label (the aria-label) and $el_href (the link target, linkTarget) are element text like $el_text (owner
1641
+ // decision 2026-10-26, soc2 rule): none under data-sq-mask/-private, in account UI, or when the text, the label or
1642
+ // the target names the identified person; the label redacted and capped like the text. An icon button's label is
1643
+ // often its only name.
1644
+ var label = masked ? '' : String(matched.getAttribute('aria-label') || '').replace(/\s+/g, ' ').replace(/^ | $/g, '');
1645
+ var anchor = masked ? null : closestMatching(matched, 'a[href]');
1646
+ var href = anchor ? linkTarget(anchor.getAttribute('href')) : undefined;
1647
+ var labelOrHrefIdentity = DETECT_IDENTITY && (label || href) &&
1648
+ (identity || inAccountUi(matched) || (label && namesPerson(label)) || (href && namesPerson(href)));
1493
1649
  return {
1494
1650
  $el_tag_name: tagNameOf(matched),
1495
1651
  $el_selector: cap(selector, EL_SELECTOR_MAX),
1496
1652
  $el_id: matched.id && !noIds ? cap(String(matched.id), EL_ID_MAX) : undefined,
1497
1653
  $el_data: masked || identity ? undefined : dataAttrs(matched, redactor),
1498
- $el_text: raw !== undefined && !identity ? redactor.boundedRedact(raw, CLICK_TEXT_MAX) : undefined
1654
+ $el_text: raw !== undefined && !identity ? redactor.boundedRedact(raw, CLICK_TEXT_MAX) : undefined,
1655
+ $el_label: label && !labelOrHrefIdentity ? redactor.boundedRedact(label, CLICK_TEXT_MAX) : undefined,
1656
+ $el_href: href && !labelOrHrefIdentity ? redactor.boundedRedact(href, URL_MAX) : undefined
1499
1657
  };
1500
1658
  }
1501
1659
 
@@ -1688,12 +1846,14 @@ var boot = (function (injectedTag) {
1688
1846
  document.addEventListener('focusin', onFocusIn, true);
1689
1847
  document.addEventListener('selectionchange', onSelectionChange, true);
1690
1848
  document.addEventListener('scroll', onScroll, true);
1849
+ window.addEventListener('popstate', onPopCapture, true);
1691
1850
  window.addEventListener('popstate', onPopState);
1692
1851
  try {
1693
1852
  var navigation = window.navigation;
1694
1853
  if (navigation && typeof navigation.addEventListener === 'function') {
1695
1854
  navigation.addEventListener('navigate', function (ev) {
1696
1855
  lastNavigationType = ev.navigationType;
1856
+ if (ev.navigationType !== 'replace') popKind = ev.navigationType;
1697
1857
  });
1698
1858
  navigationApi = true;
1699
1859
  }
@@ -1706,20 +1866,21 @@ var boot = (function (injectedTag) {
1706
1866
  if (typeof originalPush === 'function') {
1707
1867
  history.pushState = function () {
1708
1868
  var result = originalPush.apply(history, arguments);
1709
- checkPage('push');
1869
+ checkPage(hookNav('push'));
1710
1870
  return result;
1711
1871
  };
1712
1872
  }
1713
1873
  if (typeof originalReplace === 'function') {
1714
1874
  history.replaceState = function () {
1715
1875
  var result = originalReplace.apply(history, arguments);
1716
- checkPage('replace');
1876
+ checkPage(hookNav('replace'));
1717
1877
  return result;
1718
1878
  };
1719
1879
  }
1720
1880
  } catch (e) {}
1721
1881
 
1722
1882
  lastPageKey = pageKey(attachUrl || String(window.location.href));
1883
+ lastPathKey = pathKey(attachUrl || String(window.location.href));
1723
1884
  capturePageview(attachUrl, 'load');
1724
1885
  }
1725
1886
 
@@ -1877,7 +2038,7 @@ var boot = (function (injectedTag) {
1877
2038
  }
1878
2039
  });
1879
2040
 
1880
- var VERSION = '1.0.0';
2041
+ var VERSION = '1.0.2';
1881
2042
  var running = null;
1882
2043
 
1883
2044
  function logLine(level, message) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@usesequential/browser",
3
- "version": "1.0.0",
3
+ "version": "1.0.2",
4
4
  "description": "The Sequential browser SDK as an npm package: analytics and session replay, the same code as the script tag.",
5
5
  "keywords": [
6
6
  "sequential",