@sypnia/telemetry 0.2.0 → 0.3.0

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,14 @@
1
1
  # Changelog
2
2
 
3
+ ## 0.3.0 (2026-11-17)
4
+
5
+ Anonymous visitors (docs: https://telemetry.docs.sypnia.com/sdks/anonymous-visitors).
6
+
7
+ - `init({ anonymousRoutes, anonymous })` in the browser: public routes observed without identity. On them `identify()` is kept in memory and never sent; events carry `anon: true`, `person` and `account` null, no device id, and the route as the address; the session lives in this tab's `sessionStorage` (`sypnia:anon`), with no cookie and nothing in `localStorage`; custom properties, click labels and error messages are scrubbed of e-mails and runs of 6 or more digits, and numbers of 9 or more digits are dropped; replays and page snapshots are off unless `anonymous.replay` (then every text is masked). `anonymous.hideClickText` sends no click label or context there.
8
+ - Anonymous routes are observed even when `allowRoutes` does not list them; `ignoreRoutes` still wins.
9
+ - From an anonymous route to a signed-in one in the same tab, the session goes on; identity applies from then on, never to earlier events. A signed-in person who opens an anonymous route gets a separate session there.
10
+ - Node and Next.js: `init({ anonymousRoutes })` and `withSypnia({ server: { anonymousRoutes } })`. Requests of those routes are traced with `sypnia.anonymous = true`, and `identify()` is ignored in them.
11
+
3
12
  ## 0.2.0 (2026-11-17)
4
13
 
5
14
  First release of `@sypnia/telemetry`, the one package for Sypnia Telemetry's JavaScript SDKs.
@@ -26,7 +26,8 @@ interface EventBase {
26
26
  type: string;
27
27
  ts: number;
28
28
  sid: string;
29
- did: string;
29
+ /** The device id. Not sent from an anonymous route (docs: sdks/anonymous-visitors). */
30
+ did?: string;
30
31
  env: string;
31
32
  ver: string | null;
32
33
  person: PersonRef | null;
@@ -37,6 +38,8 @@ interface EventBase {
37
38
  vw: number;
38
39
  vh: number;
39
40
  lang: string | null;
41
+ /** Sent from an anonymous route: no person, no account, no device id. */
42
+ anon?: true;
40
43
  }
41
44
  interface SessionStartEvent extends EventBase {
42
45
  type: 'session_start';
@@ -183,6 +186,13 @@ interface InitOptions {
183
186
  ignoreRoutes?: Pattern[];
184
187
  /** When set, the only paths where the SDK captures anything (`ignoreRoutes` still applies inside them). */
185
188
  allowRoutes?: Pattern[];
189
+ /**
190
+ * Public pages observed without identity (docs: sdks/anonymous-visitors):
191
+ * no `identify`, no device id, a session of this tab only, scrubbed text,
192
+ * no replay. Observed even when `allowRoutes` does not list them.
193
+ */
194
+ anonymousRoutes?: Pattern[];
195
+ anonymous?: AnonymousOptions;
186
196
  /** Your own way to turn a path into a route. */
187
197
  routeFor?: (pathname: string) => string;
188
198
  /** Treats the hash as the path, for apps that route with `#/checkout`. */
@@ -213,6 +223,13 @@ interface InitOptions {
213
223
  /** Called with each event before it is queued: return it, changed or not, or `null` to drop it. */
214
224
  beforeSend?: (event: SypniaEvent) => SypniaEvent | null;
215
225
  }
226
+ /** How anonymous routes are observed (docs: sdks/anonymous-visitors#what-changes-on-an-anonymous-route). */
227
+ interface AnonymousOptions {
228
+ /** Replays and page snapshots on anonymous routes, with every text masked. `false` by default. */
229
+ replay?: boolean;
230
+ /** No label and no context with clicks and form errors on anonymous routes. `false` by default. */
231
+ hideClickText?: boolean;
232
+ }
216
233
  interface CaptureOptions {
217
234
  errors?: boolean;
218
235
  clicks?: boolean;
@@ -1,5 +1,5 @@
1
- import { I as InitOptions } from '../api-Dqlofw7I.js';
2
- export { C as CaptureOptions, a as CustomProps, P as Pattern, S as SypniaEvent, f as flush, g as getSessionId, i as identify, n as notifyNavigation, o as optIn, b as optOut, r as reportError, t as track } from '../api-Dqlofw7I.js';
1
+ import { I as InitOptions } from '../api-DJWXTLo4.js';
2
+ export { C as CaptureOptions, a as CustomProps, P as Pattern, S as SypniaEvent, f as flush, g as getSessionId, i as identify, n as notifyNavigation, o as optIn, b as optOut, r as reportError, t as track } from '../api-DJWXTLo4.js';
3
3
 
4
4
  /**
5
5
  * `@sypnia/browser`: errors, sessions, replay, page performance, failing API
@@ -1,3 +1,3 @@
1
- export { flush, getSessionId, identify, init, notifyNavigation, optIn, optOut, reportError, track } from '../chunk-WL43YGLQ.js';
2
- import '../chunk-46P5IZVP.js';
3
- import '../chunk-U6USLZJ2.js';
1
+ export { flush, getSessionId, identify, init, notifyNavigation, optIn, optOut, reportError, track } from '../chunk-YGXX6CWT.js';
2
+ import '../chunk-UPXOW6QR.js';
3
+ import '../chunk-P5DK2OU7.js';
@@ -1,4 +1,4 @@
1
- import { pathnameOf, routeOf } from './chunk-U6USLZJ2.js';
1
+ import { pathnameOf, routeOf } from './chunk-P5DK2OU7.js';
2
2
 
3
3
  // ../next/src/route-names.ts
4
4
  var STATIC = 0;
@@ -3,13 +3,14 @@ import { deserializePatterns } from './chunk-WUAOTFVV.js';
3
3
  // ../next/src/start.ts
4
4
  var NEXT_INTERNALS = ["/_next/static", "/_next/image", "/_next/webpack-hmr", "/__nextjs_original-stack-frame"];
5
5
  async function startNode(config, dir = process.cwd()) {
6
- const [sdk, routes] = await Promise.all([import('./node/index.js'), import('./routes-AN3GFTBW.js')]);
7
- const routeFor = routes.loadRouteResolver(config.distDir, config.basePath, dir) ?? (config.routes?.length ? (await import('./route-names-RNBNXKZI.js')).routeNamer(config.routes, config.basePath) : null);
8
- const { ignoreRoutes, allowRoutes, ...server } = config.server;
6
+ const [sdk, routes] = await Promise.all([import('./node/index.js'), import('./routes-UZDLSWQN.js')]);
7
+ const routeFor = routes.loadRouteResolver(config.distDir, config.basePath, dir) ?? (config.routes?.length ? (await import('./route-names-7DRTESKN.js')).routeNamer(config.routes, config.basePath) : null);
8
+ const { ignoreRoutes, allowRoutes, anonymousRoutes, ...server } = config.server;
9
9
  sdk.init({
10
10
  ...server,
11
11
  ignoreRoutes: [...NEXT_INTERNALS, ...deserializePatterns(ignoreRoutes) ?? []],
12
12
  ...allowRoutes ? { allowRoutes: deserializePatterns(allowRoutes) ?? [] } : {},
13
+ ...anonymousRoutes ? { anonymousRoutes: deserializePatterns(anonymousRoutes) ?? [] } : {},
13
14
  project: config.project,
14
15
  endpoint: config.endpoint,
15
16
  service: config.service,
@@ -73,6 +73,10 @@ function scrubEmails(text) {
73
73
  function redactMessage(message) {
74
74
  return cutChars(message, MESSAGE_CHARS).replace(EMAIL_RE, "[email]").replace(URL_RE, "<url>").replace(UUID_RE2, "<uuid>").replace(QUOTED_RE, '"\u2026"').replace(WORD_RE, (word) => /[0-9]/.test(word) ? "<token>" : word).replace(DIGITS_RE, "#");
75
75
  }
76
+ var DIGIT_RUN_RE = /\+?\(?\d(?:[\s().-]?\d){5,}/g;
77
+ function scrubPersonal(text) {
78
+ return text.replace(EMAIL_RE, "[email]").replace(DIGIT_RUN_RE, "[number]");
79
+ }
76
80
 
77
81
  // ../shared/src/wire.ts
78
82
  var TRACEPARENT_HEADER = "traceparent";
@@ -218,4 +222,4 @@ function isHexId(value) {
218
222
  return typeof value === "string" && /^[0-9a-f]{32}$/.test(value);
219
223
  }
220
224
 
221
- export { SESSION_HEADER, TRACEPARENT_HEADER, baseUrl, cutChars, errorFingerprint, formatTraceparent, hash64, isHexId, matchesRoute, matchesText, matchesUrl, newSpanId, newTraceId, parseTraceparent, pathnameOf, randomHex, redactMessage, routeOf, scrubEmails };
225
+ export { SESSION_HEADER, TRACEPARENT_HEADER, baseUrl, cutChars, errorFingerprint, formatTraceparent, hash64, isHexId, matchesRoute, matchesText, matchesUrl, newSpanId, newTraceId, parseTraceparent, pathnameOf, randomHex, redactMessage, routeOf, scrubEmails, scrubPersonal };
@@ -1,4 +1,4 @@
1
- import { pathnameOf, isHexId } from './chunk-U6USLZJ2.js';
1
+ import { pathnameOf, isHexId } from './chunk-P5DK2OU7.js';
2
2
 
3
3
  // ../browser/src/env.ts
4
4
  var STORAGE_KEYS = {
@@ -7,6 +7,7 @@ var STORAGE_KEYS = {
7
7
  replay: "sypnia:replay",
8
8
  off: "sypnia:off"
9
9
  };
10
+ var ANON_SESSION_KEY = "sypnia:anon";
10
11
  function isBrowser() {
11
12
  return typeof window !== "undefined" && typeof document !== "undefined";
12
13
  }
@@ -25,6 +26,21 @@ function writeStorage(key, value) {
25
26
  return false;
26
27
  }
27
28
  }
29
+ function readTabStorage(key) {
30
+ try {
31
+ return window.sessionStorage.getItem(key);
32
+ } catch {
33
+ return null;
34
+ }
35
+ }
36
+ function writeTabStorage(key, value) {
37
+ try {
38
+ window.sessionStorage.setItem(key, value);
39
+ return true;
40
+ } catch {
41
+ return false;
42
+ }
43
+ }
28
44
  function removeStorage(key) {
29
45
  try {
30
46
  window.localStorage.removeItem(key);
@@ -304,4 +320,4 @@ function writeDecision(decision) {
304
320
  );
305
321
  }
306
322
 
307
- export { BATCH_CHARS, BUFFER_MS, CHARS, CHUNK_CHARS, CHUNK_INTERVAL_MS, CUSTOM_PROPS_MAX, DEAD_DEDUPE_MS, DEAD_WAIT_MS, ERRORS_PER_MINUTE, ERROR_DEDUPE_MS, EVENTS_PER_BATCH, FLUSH_AT_EVENTS, FLUSH_INTERVAL_MS, FORM_INVALID_DEDUPE_MS, KEEPALIVE_MAX_CHARS, MAX_BUFFER_CHARS, MAX_CHUNKS_PER_SESSION, MAX_EVENT_CHARS, MAX_QUIET_WAIT_MS, MAX_RETRY_AFTER_MS, PARK_BASE_MS, PARK_MAX_MS, QUEUE_MAX_EVENTS, QUIET_MS, RAGE_MIN_CLICKS, RAGE_RADIUS_PX, RAGE_WINDOW_MS, RECORD_CHECKOUT_MS, RESYNC_DELAYS_MS, RETRY_DELAYS_MS, SESSION_IDLE_MS, SNAPSHOTS_PER_SESSION, SNAPSHOT_CHARS, SNAPSHOT_DELAY_MS, STORAGE_KEYS, UNANSWERED_GRACE_MS, beacon, currentPath, decisionFrom, deviceClassOf, encode, fallbackDecision, isBrowser, isGzip, isHidden, outcomeOf, pageLanguage, pageRefOf, post, readDecision, readStorage, removeStorage, safe, viewport, whenIdle, writeDecision, writeStorage };
323
+ export { ANON_SESSION_KEY, BATCH_CHARS, BUFFER_MS, CHARS, CHUNK_CHARS, CHUNK_INTERVAL_MS, CUSTOM_PROPS_MAX, DEAD_DEDUPE_MS, DEAD_WAIT_MS, ERRORS_PER_MINUTE, ERROR_DEDUPE_MS, EVENTS_PER_BATCH, FLUSH_AT_EVENTS, FLUSH_INTERVAL_MS, FORM_INVALID_DEDUPE_MS, KEEPALIVE_MAX_CHARS, MAX_BUFFER_CHARS, MAX_CHUNKS_PER_SESSION, MAX_EVENT_CHARS, MAX_QUIET_WAIT_MS, MAX_RETRY_AFTER_MS, PARK_BASE_MS, PARK_MAX_MS, QUEUE_MAX_EVENTS, QUIET_MS, RAGE_MIN_CLICKS, RAGE_RADIUS_PX, RAGE_WINDOW_MS, RECORD_CHECKOUT_MS, RESYNC_DELAYS_MS, RETRY_DELAYS_MS, SESSION_IDLE_MS, SNAPSHOTS_PER_SESSION, SNAPSHOT_CHARS, SNAPSHOT_DELAY_MS, STORAGE_KEYS, UNANSWERED_GRACE_MS, beacon, currentPath, decisionFrom, deviceClassOf, encode, fallbackDecision, isBrowser, isGzip, isHidden, outcomeOf, pageLanguage, pageRefOf, post, readDecision, readStorage, readTabStorage, removeStorage, safe, viewport, whenIdle, writeDecision, writeStorage, writeTabStorage };
@@ -1,5 +1,5 @@
1
- import { safe, CHARS, writeStorage, STORAGE_KEYS, removeStorage, isBrowser, isHidden, currentPath, whenIdle, viewport, pageRefOf, pageLanguage, readDecision, decisionFrom, fallbackDecision, writeDecision, readStorage, SESSION_IDLE_MS, QUEUE_MAX_EVENTS, FLUSH_AT_EVENTS, FLUSH_INTERVAL_MS, beacon, encode, MAX_RETRY_AFTER_MS, RETRY_DELAYS_MS, isGzip, KEEPALIVE_MAX_CHARS, outcomeOf, ERRORS_PER_MINUTE, ERROR_DEDUPE_MS, RAGE_WINDOW_MS, RAGE_RADIUS_PX, RAGE_MIN_CLICKS, DEAD_DEDUPE_MS, DEAD_WAIT_MS, FORM_INVALID_DEDUPE_MS, UNANSWERED_GRACE_MS, CUSTOM_PROPS_MAX, BATCH_CHARS, EVENTS_PER_BATCH } from './chunk-46P5IZVP.js';
2
- import { pathnameOf, matchesRoute, routeOf, baseUrl, randomHex, isHexId, matchesText, scrubEmails, errorFingerprint, matchesUrl, newTraceId, newSpanId, TRACEPARENT_HEADER, formatTraceparent, hash64, SESSION_HEADER } from './chunk-U6USLZJ2.js';
1
+ import { safe, CHARS, writeStorage, STORAGE_KEYS, removeStorage, isBrowser, SESSION_IDLE_MS, isHidden, currentPath, whenIdle, viewport, pageRefOf, pageLanguage, readDecision, fallbackDecision, decisionFrom, writeDecision, readStorage, writeTabStorage, ANON_SESSION_KEY, readTabStorage, QUEUE_MAX_EVENTS, FLUSH_AT_EVENTS, FLUSH_INTERVAL_MS, beacon, encode, MAX_RETRY_AFTER_MS, RETRY_DELAYS_MS, isGzip, KEEPALIVE_MAX_CHARS, outcomeOf, ERRORS_PER_MINUTE, ERROR_DEDUPE_MS, RAGE_WINDOW_MS, RAGE_RADIUS_PX, RAGE_MIN_CLICKS, DEAD_DEDUPE_MS, DEAD_WAIT_MS, FORM_INVALID_DEDUPE_MS, UNANSWERED_GRACE_MS, CUSTOM_PROPS_MAX, BATCH_CHARS, EVENTS_PER_BATCH } from './chunk-UPXOW6QR.js';
2
+ import { pathnameOf, matchesRoute, routeOf, baseUrl, randomHex, matchesText, scrubEmails, errorFingerprint, matchesUrl, newTraceId, newSpanId, TRACEPARENT_HEADER, formatTraceparent, hash64, scrubPersonal, isHexId, SESSION_HEADER } from './chunk-P5DK2OU7.js';
3
3
 
4
4
  // ../browser/src/options.ts
5
5
  function list(value) {
@@ -19,6 +19,8 @@ function resolveOptions(options) {
19
19
  debug: options.debug === true,
20
20
  ignoreRoutes: list(options.ignoreRoutes),
21
21
  allowRoutes: list(options.allowRoutes),
22
+ anonymousRoutes: list(options.anonymousRoutes),
23
+ anonymous: { replay: options.anonymous?.replay === true, hideClickText: options.anonymous?.hideClickText === true },
22
24
  routeFor: typeof options.routeFor === "function" ? options.routeFor : routeOf,
23
25
  hashRouting: options.hashRouting === true,
24
26
  capture: {
@@ -60,8 +62,16 @@ function deviceId() {
60
62
  function personKey(personId) {
61
63
  return hash64(`person:${personId}`);
62
64
  }
63
- function readStoredSession() {
64
- const raw = readStorage(STORAGE_KEYS.session);
65
+ var sharedSessionBackend = {
66
+ read: () => readStorage(STORAGE_KEYS.session),
67
+ write: (value) => writeStorage(STORAGE_KEYS.session, value)
68
+ };
69
+ var tabSessionBackend = {
70
+ read: () => readTabStorage(ANON_SESSION_KEY),
71
+ write: (value) => writeTabStorage(ANON_SESSION_KEY, value)
72
+ };
73
+ function readStoredSession(backend) {
74
+ const raw = backend.read();
65
75
  if (!raw) return null;
66
76
  try {
67
77
  const parsed = JSON.parse(raw);
@@ -72,9 +82,10 @@ function readStoredSession() {
72
82
  }
73
83
  }
74
84
  var SessionStore = class {
75
- constructor(now, idleMs = SESSION_IDLE_MS) {
85
+ constructor(now, idleMs = SESSION_IDLE_MS, backend = sharedSessionBackend) {
76
86
  this.now = now;
77
87
  this.idleMs = idleMs;
88
+ this.backend = backend;
78
89
  this.sid = null;
79
90
  this.last = 0;
80
91
  this.person = null;
@@ -112,6 +123,21 @@ var SessionStore = class {
112
123
  }
113
124
  this.end(key);
114
125
  }
126
+ /**
127
+ * Continues `sid` here when this store has no live session: an anonymous
128
+ * tab that reaches a signed-in page keeps its session (docs:
129
+ * sdks/anonymous-visitors#from-an-anonymous-page-to-a-signed-in-one).
130
+ * Returns whether it was adopted.
131
+ */
132
+ adopt(sid) {
133
+ const now = this.now();
134
+ this.sync(now);
135
+ if (this.alive(now)) return false;
136
+ this.sid = sid;
137
+ this.person = null;
138
+ this.write(now);
139
+ return true;
140
+ }
115
141
  /** The id this store last knew of, alive or not. */
116
142
  known() {
117
143
  return this.sid;
@@ -124,13 +150,13 @@ var SessionStore = class {
124
150
  this.person = person;
125
151
  this.last = 0;
126
152
  this.readAt = this.now();
127
- writeStorage(STORAGE_KEYS.session, JSON.stringify({ sid: this.sid, last: 0, p: person }));
153
+ this.backend.write(JSON.stringify({ sid: this.sid, last: 0, p: person }));
128
154
  }
129
155
  /** Adopts what another tab stored (a new session or a fresher `last`), at most every REREAD_EVERY_MS. */
130
156
  sync(now) {
131
157
  if (this.sid && now - this.readAt < REREAD_EVERY_MS) return;
132
158
  this.readAt = now;
133
- const stored = readStoredSession();
159
+ const stored = readStoredSession(this.backend);
134
160
  if (!stored) return;
135
161
  if (stored.sid !== this.sid ? stored.last >= this.last : stored.last > this.last) {
136
162
  this.sid = stored.sid;
@@ -150,13 +176,13 @@ var SessionStore = class {
150
176
  write(now) {
151
177
  this.last = now;
152
178
  this.readAt = now;
153
- this.storageFailed = !writeStorage(STORAGE_KEYS.session, JSON.stringify({ sid: this.sid, last: now, p: this.person }));
179
+ this.storageFailed = !this.backend.write(JSON.stringify({ sid: this.sid, last: now, p: this.person }));
154
180
  }
155
181
  };
156
182
 
157
183
  // ../browser/src/version.ts
158
184
  var SDK_NAME = "@sypnia/telemetry/browser" ;
159
- var SDK_VERSION = "0.2.0" ;
185
+ var SDK_VERSION = "0.3.0" ;
160
186
 
161
187
  // ../browser/src/transport.ts
162
188
  function uuid() {
@@ -1654,6 +1680,8 @@ var Runtime = class {
1654
1680
  constructor(options, deps) {
1655
1681
  this.options = options;
1656
1682
  this.deps = deps;
1683
+ /** The device id, read or created on the first event of a route that is not anonymous. */
1684
+ this.did = null;
1657
1685
  this.identity = null;
1658
1686
  /** The identify event last sent, per session: the same one again sends nothing. */
1659
1687
  this.identifySent = null;
@@ -1661,6 +1689,10 @@ var Runtime = class {
1661
1689
  this.landing = null;
1662
1690
  this.lang = null;
1663
1691
  this.lastSid = null;
1692
+ /** The anonymous session this document used last. */
1693
+ this.lastAnonSid = null;
1694
+ /** `identify()` was called on an anonymous route: the shared session learns it on the next other route. */
1695
+ this.identifyPending = false;
1664
1696
  this.decision = null;
1665
1697
  this.slowDown = null;
1666
1698
  this.recorder = null;
@@ -1681,7 +1713,7 @@ var Runtime = class {
1681
1713
  this.random = deps.random ?? Math.random;
1682
1714
  this.fetch = window.fetch.bind(window);
1683
1715
  this.sessions = new SessionStore(this.now);
1684
- this.did = deviceId();
1716
+ this.anonSessions = new SessionStore(this.now, SESSION_IDLE_MS, tabSessionBackend);
1685
1717
  configureDescriber({ maskSelector: options.maskSelector, maskAllText: options.maskAllText, routeFor: options.routeFor });
1686
1718
  this.transport = new Transport({
1687
1719
  url: `${options.endpoint}/v1/ingest/events`,
@@ -1787,8 +1819,14 @@ var Runtime = class {
1787
1819
  // ------------------------------------------------------------------ public
1788
1820
  identify(who) {
1789
1821
  if (!this.active) return;
1790
- this.sessions.identify(who ? personKey(who.person.id) : null);
1791
1822
  this.identity = who;
1823
+ if (this.onAnonymousRoute()) {
1824
+ this.identifyPending = true;
1825
+ this.debug("identify kept in memory: this route is anonymous");
1826
+ return;
1827
+ }
1828
+ this.identifyPending = false;
1829
+ this.sessions.identify(who ? personKey(who.person.id) : null);
1792
1830
  if (!who) return;
1793
1831
  const sid = this.sessions.peek();
1794
1832
  if (sid && this.identifySent?.sid === sid && this.identifySent.json === JSON.stringify([who.person, who.account])) return;
@@ -1798,7 +1836,7 @@ var Runtime = class {
1798
1836
  const clean = String(name).trim().slice(0, CHARS.customName);
1799
1837
  if (!clean) return;
1800
1838
  const cleanProps = sanitizeProps(props);
1801
- this.emit({ type: "custom", name: clean, ...cleanProps ? { props: cleanProps } : {} }, { activity: !this.sessions.peek() });
1839
+ this.emit({ type: "custom", name: clean, ...cleanProps ? { props: cleanProps } : {} }, { activity: !this.liveSession() });
1802
1840
  }
1803
1841
  reportError(error, info = {}) {
1804
1842
  const read = readError(error);
@@ -1810,6 +1848,7 @@ var Runtime = class {
1810
1848
  await this.transport.flush(mode);
1811
1849
  }
1812
1850
  sessionId() {
1851
+ if (this.onAnonymousRoute()) return this.anonSessions.peek() ?? this.lastAnonSid;
1813
1852
  return this.sessions.peek() ?? this.lastSid;
1814
1853
  }
1815
1854
  /** A framework announced a navigation before the address changed. */
@@ -1827,9 +1866,10 @@ var Runtime = class {
1827
1866
  if (!page || this.isIgnored(page.url)) return;
1828
1867
  const sid = options.sid ?? this.session(options.activity ?? ACTIVITY.has(fields.type), page, fields.type === "identify");
1829
1868
  if (!sid) return;
1830
- const event = { ...this.base(fields.type, sid, page), ...fields };
1869
+ let event = { ...this.base(fields.type, sid, page), ...fields };
1831
1870
  if (options.ts !== void 0) event.ts = options.ts;
1832
- this.queue(event);
1871
+ if (this.isAnonymous(page.url)) event = anonymize(event, this.options.anonymous.hideClickText);
1872
+ if (event) this.queue(event);
1833
1873
  } catch {
1834
1874
  }
1835
1875
  }
@@ -1857,6 +1897,24 @@ var Runtime = class {
1857
1897
  if (URGENT_WHEN_HIDDEN.has(final.type) && isHidden()) this.flushSoon();
1858
1898
  }
1859
1899
  base(type, sid, page) {
1900
+ if (this.isAnonymous(page.url)) {
1901
+ return {
1902
+ v: SCHEMA_VERSION,
1903
+ type,
1904
+ ts: this.now(),
1905
+ sid,
1906
+ env: this.options.environment,
1907
+ ver: this.options.release,
1908
+ person: null,
1909
+ account: null,
1910
+ url: page.route,
1911
+ route: page.route,
1912
+ ...viewport(),
1913
+ lang: this.lang,
1914
+ anon: true
1915
+ };
1916
+ }
1917
+ this.did ??= deviceId();
1860
1918
  return {
1861
1919
  v: SCHEMA_VERSION,
1862
1920
  type,
@@ -1880,24 +1938,51 @@ var Runtime = class {
1880
1938
  * `identify`, and the session's decision is asked for.
1881
1939
  */
1882
1940
  session(activity, page = this.currentPage(), identifying = false) {
1941
+ if (page ? this.isAnonymous(page.url) : this.onAnonymousRoute()) return this.anonSession(activity, page);
1942
+ if (activity && this.lastAnonSid) {
1943
+ const anon = this.anonSessions.peek();
1944
+ if (anon && this.sessions.adopt(anon)) this.lastSid = anon;
1945
+ }
1946
+ if (this.identifyPending) {
1947
+ this.identifyPending = false;
1948
+ this.sessions.identify(this.identity ? personKey(this.identity.person.id) : null);
1949
+ }
1883
1950
  const sid = activity ? this.sessions.touch().sid : this.sessions.peek();
1884
- if (!sid || sid === this.lastSid) return sid;
1951
+ if (!sid) return sid;
1952
+ const isNew = sid !== this.lastSid;
1885
1953
  this.lastSid = sid;
1886
1954
  if (page) {
1887
- this.queue({ ...this.base("session_start", sid, page), ...sessionStartFields() });
1955
+ if (isNew) this.queue({ ...this.base("session_start", sid, page), ...sessionStartFields() });
1888
1956
  const who = this.identity;
1889
1957
  if (who && !identifying && this.identifySent?.sid !== sid) {
1890
1958
  this.queue({ ...this.base("identify", sid, page), person: who.person, account: who.account });
1891
1959
  }
1892
1960
  }
1961
+ if (isNew && this.idleReady) void this.prepareSession();
1962
+ return sid;
1963
+ }
1964
+ /** The session of an anonymous route: this tab's, never the shared one, so a public page is not tied to anyone. */
1965
+ anonSession(activity, page) {
1966
+ const sid = activity ? this.anonSessions.touch().sid : this.anonSessions.peek();
1967
+ if (!sid || sid === this.lastAnonSid) return sid;
1968
+ this.lastAnonSid = sid;
1969
+ if (page) this.queue({ ...this.base("session_start", sid, page), ...sessionStartFields() });
1893
1970
  if (this.idleReady) void this.prepareSession();
1894
1971
  return sid;
1895
1972
  }
1973
+ /** The live session of the current route's kind, without refreshing it. */
1974
+ liveSession() {
1975
+ return this.onAnonymousRoute() ? this.anonSessions.peek() : this.sessions.peek();
1976
+ }
1977
+ /** The session the current route uses: the anonymous one on anonymous routes. */
1978
+ activeSid() {
1979
+ return this.onAnonymousRoute() ? this.lastAnonSid : this.lastSid;
1980
+ }
1896
1981
  report(report) {
1897
1982
  if (!this.active) return;
1898
1983
  const fields = this.errors.accept(report);
1899
1984
  if (!fields) return;
1900
- this.emit(fields, { activity: !this.sessions.peek() });
1985
+ this.emit(fields, { activity: !this.liveSession() });
1901
1986
  this.onTrouble();
1902
1987
  }
1903
1988
  onTrouble() {
@@ -1910,9 +1995,16 @@ var Runtime = class {
1910
1995
  /** Outside `allowRoutes` (when it is set), or in `ignoreRoutes`: the SDK captures nothing there. */
1911
1996
  isIgnored(path) {
1912
1997
  const { allowRoutes, ignoreRoutes } = this.options;
1913
- if (allowRoutes.length > 0 && !matchesRoute(path, allowRoutes)) return true;
1998
+ if (allowRoutes.length > 0 && !matchesRoute(path, allowRoutes) && !this.isAnonymous(path)) return true;
1914
1999
  return matchesRoute(path, ignoreRoutes);
1915
2000
  }
2001
+ /** In `anonymousRoutes`: observed without identity (docs: sdks/anonymous-visitors). */
2002
+ isAnonymous(path) {
2003
+ return this.options.anonymousRoutes.length > 0 && matchesRoute(path, this.options.anonymousRoutes);
2004
+ }
2005
+ onAnonymousRoute() {
2006
+ return this.page !== null && this.isAnonymous(this.page.url);
2007
+ }
1916
2008
  ignored() {
1917
2009
  return !this.page || this.isIgnored(this.page.url);
1918
2010
  }
@@ -2037,11 +2129,12 @@ var Runtime = class {
2037
2129
  /** Asks for the decision of the session this document uses (once per session, any tab), then starts the recorder. */
2038
2130
  async prepareSession() {
2039
2131
  for (let attempt = 0; attempt < 3; attempt++) {
2040
- const sid = this.lastSid;
2132
+ const sid = this.activeSid();
2041
2133
  if (!sid || !this.active) return;
2042
2134
  if (this.decision?.sid === sid) return;
2043
- const decision = readDecision(sid) ?? await this.askDecision(sid);
2044
- if (this.lastSid !== sid) continue;
2135
+ const anonymous = sid === this.lastAnonSid;
2136
+ const decision = anonymous ? await this.anonymousDecision(sid) : readDecision(sid) ?? await this.askDecision(sid);
2137
+ if (this.activeSid() !== sid) continue;
2045
2138
  this.decision = decision;
2046
2139
  if (decision.slowDown) this.applySlowDown(decision.slowDown, false);
2047
2140
  this.debug(`replay: ${decision.mode}, snapshots: ${decision.snapshots ? "on" : "off"}`);
@@ -2049,10 +2142,20 @@ var Runtime = class {
2049
2142
  return;
2050
2143
  }
2051
2144
  }
2052
- async askDecision(sid) {
2145
+ /**
2146
+ * The decision of an anonymous session: no replay and no snapshots, unless
2147
+ * `anonymous.replay`; then the engine's, asked without person or account,
2148
+ * with every text masked. Kept in memory only: nothing about it is stored.
2149
+ */
2150
+ async anonymousDecision(sid) {
2151
+ if (!this.options.anonymous.replay) return { ...fallbackDecision(sid, false), mode: "off" };
2152
+ const decision = await this.askDecision(sid, false);
2153
+ return { ...decision, maskAllText: true };
2154
+ }
2155
+ async askDecision(sid, store = true) {
2053
2156
  const params = new URLSearchParams({ sid });
2054
- if (this.identity) params.set("person", this.identity.person.id);
2055
- if (this.identity?.account) params.set("account", this.identity.account.id);
2157
+ if (store && this.identity) params.set("person", this.identity.person.id);
2158
+ if (store && this.identity?.account) params.set("account", this.identity.account.id);
2056
2159
  const controller = typeof AbortController === "function" ? new AbortController() : null;
2057
2160
  const timer = setTimeout(() => controller?.abort(), CONFIG_TIMEOUT_MS);
2058
2161
  try {
@@ -2063,6 +2166,7 @@ var Runtime = class {
2063
2166
  });
2064
2167
  const config2 = response.ok ? await response.json() : null;
2065
2168
  const decision = config2 ? decisionFrom(sid, config2, this.random) : fallbackDecision(sid, this.random() < 0.5);
2169
+ if (!store) return decision;
2066
2170
  writeDecision(decision);
2067
2171
  return readDecision(sid) ?? decision;
2068
2172
  } catch {
@@ -2106,9 +2210,13 @@ var Runtime = class {
2106
2210
  maskAllText: options.maskAllText,
2107
2211
  maskSelector: options.maskSelector,
2108
2212
  blockSelector: options.blockSelector,
2109
- // Nothing at all is recorded where the SDK is inactive.
2110
- blockedRoutes: [...options.replay ? options.replay.blockedRoutes : [], ...options.ignoreRoutes],
2111
- allowRoutes: options.allowRoutes,
2213
+ // Nothing at all is recorded where the SDK is inactive, nor on anonymous routes unless `anonymous.replay`.
2214
+ blockedRoutes: [
2215
+ ...options.replay ? options.replay.blockedRoutes : [],
2216
+ ...options.ignoreRoutes,
2217
+ ...options.anonymous.replay ? [] : options.anonymousRoutes
2218
+ ],
2219
+ allowRoutes: options.allowRoutes.length > 0 ? [...options.allowRoutes, ...options.anonymousRoutes] : [],
2112
2220
  replay: options.replay !== false,
2113
2221
  snapshots: options.snapshots,
2114
2222
  lastMutationAt: () => this.clicks.lastMutationAt,
@@ -2137,7 +2245,7 @@ var Runtime = class {
2137
2245
  if (slowDown.replay === false) safe(() => this.recorder?.onReplayLimit());
2138
2246
  if (store && this.decision) {
2139
2247
  this.decision.slowDown = slowDown;
2140
- writeDecision(this.decision);
2248
+ if (this.decision.sid !== this.lastAnonSid) writeDecision(this.decision);
2141
2249
  }
2142
2250
  }
2143
2251
  // ------------------------------------------------------------------- debug
@@ -2188,6 +2296,46 @@ function sanitizeProps(props) {
2188
2296
  function isOptedOut() {
2189
2297
  return readStorage(STORAGE_KEYS.off) !== null;
2190
2298
  }
2299
+ function scrubProps(props) {
2300
+ const out = {};
2301
+ for (const [key, value] of Object.entries(props)) {
2302
+ if (typeof value === "string") out[key] = scrubPersonal(value);
2303
+ else if (typeof value === "number" && Number.isInteger(value) && Math.abs(value) >= 1e8) continue;
2304
+ else out[key] = value;
2305
+ }
2306
+ return Object.keys(out).length > 0 ? out : void 0;
2307
+ }
2308
+ function scrubText(value, hide) {
2309
+ if (hide || typeof value !== "string") return null;
2310
+ return scrubPersonal(value);
2311
+ }
2312
+ function anonymize(event, hideClickText) {
2313
+ if (event.type === "identify") return null;
2314
+ const out = { ...event, person: null, account: null, anon: true };
2315
+ delete out.did;
2316
+ switch (out.type) {
2317
+ case "custom": {
2318
+ const props = out.props ? scrubProps(out.props) : void 0;
2319
+ if (props) out.props = props;
2320
+ else delete out.props;
2321
+ break;
2322
+ }
2323
+ case "click":
2324
+ case "rage_click":
2325
+ case "dead_click":
2326
+ out.txt = scrubText(out.txt, hideClickText);
2327
+ out.ctx = scrubText(out.ctx, hideClickText);
2328
+ out.href = typeof out.href === "string" ? scrubPersonal(out.href) : null;
2329
+ break;
2330
+ case "form_invalid":
2331
+ out.ctx = scrubText(out.ctx, hideClickText);
2332
+ break;
2333
+ case "error":
2334
+ out.msg = scrubPersonal(out.msg);
2335
+ break;
2336
+ }
2337
+ return out;
2338
+ }
2191
2339
 
2192
2340
  // ../browser/src/api.ts
2193
2341
  var GLOBAL_KEY = "__sypnia";
@@ -2288,7 +2436,7 @@ function notifyNavigation(url, kind) {
2288
2436
  }
2289
2437
 
2290
2438
  // ../browser/src/index.ts
2291
- var loadRecorder = () => import('./recorder-MHVPALUN.js').then((module) => module.createRecorder);
2439
+ var loadRecorder = () => import('./recorder-IZ3QHWYA.js').then((module) => module.createRecorder);
2292
2440
  function init(options) {
2293
2441
  startSdk(options, loadRecorder);
2294
2442
  }
@@ -14,6 +14,7 @@ type SerializedPatternList = Array<string | SerializedPattern>;
14
14
  interface SerializedServerOptions {
15
15
  ignoreRoutes?: SerializedPatternList;
16
16
  allowRoutes?: SerializedPatternList;
17
+ anonymousRoutes?: SerializedPatternList;
17
18
  captureDbErrors?: boolean;
18
19
  capture?: {
19
20
  outgoing?: boolean;
@@ -32,6 +32,12 @@ interface NodeOptions {
32
32
  ignoreRoutes?: Pattern[];
33
33
  /** When set, only incoming paths that match are traced (`ignoreRoutes` still applies to them). */
34
34
  allowRoutes?: Pattern[];
35
+ /**
36
+ * Public routes traced without identity (docs: sdks/anonymous-visitors):
37
+ * `identify()` is ignored in their requests, which carry
38
+ * `sypnia.anonymous = true`. Traced even when `allowRoutes` does not list them.
39
+ */
40
+ anonymousRoutes?: Pattern[];
35
41
  /**
36
42
  * The code and the full message of a failed database call: a `pg` error, or
37
43
  * the body of a PostgREST answer of 400 or above, as the database wrote it,
@@ -1,5 +1,5 @@
1
- import { I as InitOptions } from '../api-Dqlofw7I.js';
2
- export { f as flush, g as getSessionId, i as identify, o as optIn, b as optOut, r as reportError, t as track } from '../api-Dqlofw7I.js';
1
+ import { I as InitOptions } from '../api-DJWXTLo4.js';
2
+ export { f as flush, g as getSessionId, i as identify, o as optIn, b as optOut, r as reportError, t as track } from '../api-DJWXTLo4.js';
3
3
 
4
4
  /**
5
5
  * `@sypnia/next/client`: the browser side, switched on from
@@ -1,9 +1,9 @@
1
- import { init, notifyNavigation } from '../chunk-WL43YGLQ.js';
2
- export { flush, getSessionId, identify, optIn, optOut, reportError, track } from '../chunk-WL43YGLQ.js';
1
+ import { init, notifyNavigation } from '../chunk-YGXX6CWT.js';
2
+ export { flush, getSessionId, identify, optIn, optOut, reportError, track } from '../chunk-YGXX6CWT.js';
3
3
  import { readConfig } from '../chunk-WUAOTFVV.js';
4
- import '../chunk-46P5IZVP.js';
5
- import { routeNamer } from '../chunk-VWTXZCR4.js';
6
- import '../chunk-U6USLZJ2.js';
4
+ import '../chunk-UPXOW6QR.js';
5
+ import { routeNamer } from '../chunk-2RMEOMSD.js';
6
+ import '../chunk-P5DK2OU7.js';
7
7
 
8
8
  // ../next/src/client.ts
9
9
  function init2(options = {}) {
@@ -1,4 +1,4 @@
1
- import { S as SypniaNextConfig } from '../config-B6ekRTXY.js';
1
+ import { S as SypniaNextConfig } from '../config-CrnrvvEQ.js';
2
2
 
3
3
  /**
4
4
  * `withSypnia(nextConfig, options)` for `next.config.ts` (docs: sdks/nextjs#withsypnianextconfig-options):
@@ -14,6 +14,8 @@ interface SypniaServerOptions {
14
14
  enabled?: boolean;
15
15
  ignoreRoutes?: Pattern[];
16
16
  allowRoutes?: Pattern[];
17
+ /** Public routes traced without identity (docs: sdks/anonymous-visitors). */
18
+ anonymousRoutes?: Pattern[];
17
19
  /** `false`: no database error message is kept, only the status (and a `pg` error's SQLSTATE). */
18
20
  captureDbErrors?: boolean;
19
21
  capture?: {
@@ -1,5 +1,5 @@
1
1
  import { serializePatterns, CONFIG_ENV } from '../chunk-WUAOTFVV.js';
2
- import { cutChars, baseUrl } from '../chunk-U6USLZJ2.js';
2
+ import { cutChars, baseUrl } from '../chunk-P5DK2OU7.js';
3
3
  import { execFileSync } from 'child_process';
4
4
  import { existsSync, readdirSync } from 'fs';
5
5
  import { join, resolve, relative, sep, dirname } from 'path';
@@ -248,6 +248,7 @@ function serializeServer(server) {
248
248
  if (server.enabled !== void 0) out.enabled = server.enabled;
249
249
  if (server.ignoreRoutes) out.ignoreRoutes = serializePatterns(server.ignoreRoutes);
250
250
  if (server.allowRoutes) out.allowRoutes = serializePatterns(server.allowRoutes);
251
+ if (server.anonymousRoutes) out.anonymousRoutes = serializePatterns(server.anonymousRoutes);
251
252
  if (server.captureDbErrors !== void 0) out.captureDbErrors = server.captureDbErrors;
252
253
  if (server.capture) out.capture = server.capture;
253
254
  if (server.propagate !== void 0) out.propagate = server.propagate;
@@ -1,5 +1,5 @@
1
- import { N as NodeSdk } from '../index-DIRvY0RU.js';
2
- import { S as SypniaNextConfig } from '../config-B6ekRTXY.js';
1
+ import { N as NodeSdk } from '../index-BQbAXVDI.js';
2
+ import { S as SypniaNextConfig } from '../config-CrnrvvEQ.js';
3
3
 
4
4
  /**
5
5
  * `@sypnia/next/opennext`: server traces for a Next.js app deployed with
@@ -1,4 +1,4 @@
1
- import { startNode } from '../chunk-Q6PBRG7Q.js';
1
+ import { startNode } from '../chunk-LBKUMS7U.js';
2
2
  import { CONFIG_ENV, readConfig } from '../chunk-WUAOTFVV.js';
3
3
  import { readFileSync } from 'fs';
4
4
  import { join } from 'path';
@@ -1,4 +1,4 @@
1
- import { N as NodeSdk } from '../index-DIRvY0RU.js';
1
+ import { N as NodeSdk } from '../index-BQbAXVDI.js';
2
2
 
3
3
  /**
4
4
  * Starts the Node SDK with `withSypnia`'s values, wherever the server side
@@ -10,7 +10,7 @@ async function register() {
10
10
  if (process.env.NEXT_RUNTIME !== "nodejs") return;
11
11
  const config = readConfig();
12
12
  if (!config) return;
13
- const { startNode } = await import('../start-OR7TE32Z.js');
13
+ const { startNode } = await import('../start-TW6OBKK7.js');
14
14
  node = await startNode(config);
15
15
  } catch {
16
16
  }
@@ -1 +1 @@
1
- export { B as BRIDGE_MARKER, F as FailedRequest, H as HostRequest, J as JobAttributes, L as LambdaContextLike, a as LambdaHandlerOptions, b as NodeOptions, P as Pattern, S as SpanForReview, c as SqsBatchResponse, d as SqsHandlerOptions, e as SqsMessageAttribute, f as SqsRecordLike, g as SqsRecordOptions, T as TraceRequestOptions, W as WaitUntil, h as Who, i as captureRequestError, j as continueTrace, k as currentTraceparent, l as flush, m as identify, n as init, o as injectTraceContext, r as reportError, s as setWaitUntil, p as shutdown, q as span, t as sqsTraceAttributes, u as traceRequest, v as traceSqsRecord, w as traceparentOf, x as wrapFetchHandler, y as wrapLambdaHandler, z as wrapSqsHandler } from '../index-DIRvY0RU.js';
1
+ export { B as BRIDGE_MARKER, F as FailedRequest, H as HostRequest, J as JobAttributes, L as LambdaContextLike, a as LambdaHandlerOptions, b as NodeOptions, P as Pattern, S as SpanForReview, c as SqsBatchResponse, d as SqsHandlerOptions, e as SqsMessageAttribute, f as SqsRecordLike, g as SqsRecordOptions, T as TraceRequestOptions, W as WaitUntil, h as Who, i as captureRequestError, j as continueTrace, k as currentTraceparent, l as flush, m as identify, n as init, o as injectTraceContext, r as reportError, s as setWaitUntil, p as shutdown, q as span, t as sqsTraceAttributes, u as traceRequest, v as traceSqsRecord, w as traceparentOf, x as wrapFetchHandler, y as wrapLambdaHandler, z as wrapSqsHandler } from '../index-BQbAXVDI.js';
@@ -1,4 +1,4 @@
1
- import { cutChars, routeOf, formatTraceparent, parseTraceparent, redactMessage, baseUrl, pathnameOf, matchesRoute, errorFingerprint } from '../chunk-U6USLZJ2.js';
1
+ import { cutChars, routeOf, formatTraceparent, parseTraceparent, redactMessage, baseUrl, pathnameOf, matchesRoute, errorFingerprint } from '../chunk-P5DK2OU7.js';
2
2
  import { AsyncLocalStorage } from 'async_hooks';
3
3
  import { promisify } from 'util';
4
4
  import { gzip as gzip$1 } from 'zlib';
@@ -603,6 +603,8 @@ var RequestTrace = class {
603
603
  /** A partial copy was exported: the full one must replace it. */
604
604
  this.partialSent = false;
605
605
  this.slowTimer = null;
606
+ /** A request of an anonymous route: `identify()` is ignored in it. */
607
+ this.anonymous = false;
606
608
  /** Failed answers still being read (db-errors.ts): the end waits for them, briefly. */
607
609
  this.pending = /* @__PURE__ */ new Set();
608
610
  this.fingerprints = /* @__PURE__ */ new Set();
@@ -682,6 +684,19 @@ var RequestTrace = class {
682
684
  }
683
685
  };
684
686
 
687
+ // ../node/src/instrument/skip.ts
688
+ var STATIC_FILE_RE = /\.(?:js|css|map|png|jpe?g|gif|svg|ico|webp|avif|woff2?|ttf|txt|xml|webmanifest)$/i;
689
+ function isIgnoredRequest(options, method, path) {
690
+ if (method.toUpperCase() === "OPTIONS") return true;
691
+ if (STATIC_FILE_RE.test(path)) return true;
692
+ const route = pathnameOf(path);
693
+ if (options.allowRoutes.length > 0 && !matchesRoute(route, options.allowRoutes) && !isAnonymousRoute(options, route)) return true;
694
+ return matchesRoute(route, options.ignoreRoutes);
695
+ }
696
+ function isAnonymousRoute(options, path) {
697
+ return options.anonymousRoutes.length > 0 && matchesRoute(pathnameOf(path), options.anonymousRoutes);
698
+ }
699
+
685
700
  // ../node/src/sdk.ts
686
701
  var KEY = /* @__PURE__ */ Symbol.for("sypnia.node.sdk");
687
702
  function getSdk() {
@@ -704,7 +719,12 @@ function startRequest(sdk, request) {
704
719
  setAttribute(server.attributes, "url.path", request.path);
705
720
  const session = request.header("x-sypnia-session")?.trim().toLowerCase();
706
721
  if (session && /^[0-9a-f]{32}$/.test(session)) setAttribute(server.attributes, "session.id", session);
707
- return startTrace(sdk, server);
722
+ const trace = startTrace(sdk, server);
723
+ if (isAnonymousRoute(sdk.options, request.path)) {
724
+ trace.anonymous = true;
725
+ setAttribute(server.attributes, "sypnia.anonymous", true);
726
+ }
727
+ return trace;
708
728
  }
709
729
  function startTrace(sdk, server) {
710
730
  if (sdk.cold) {
@@ -1244,18 +1264,6 @@ function instrumentConsole() {
1244
1264
  delete target[PATCHED];
1245
1265
  };
1246
1266
  }
1247
-
1248
- // ../node/src/instrument/skip.ts
1249
- var STATIC_FILE_RE = /\.(?:js|css|map|png|jpe?g|gif|svg|ico|webp|avif|woff2?|ttf|txt|xml|webmanifest)$/i;
1250
- function isIgnoredRequest(options, method, path) {
1251
- if (method.toUpperCase() === "OPTIONS") return true;
1252
- if (STATIC_FILE_RE.test(path)) return true;
1253
- const route = pathnameOf(path);
1254
- if (options.allowRoutes.length > 0 && !matchesRoute(route, options.allowRoutes)) return true;
1255
- return matchesRoute(route, options.ignoreRoutes);
1256
- }
1257
-
1258
- // ../node/src/instrument/server.ts
1259
1267
  var CHANNEL = "http.server.request.start";
1260
1268
  function headerOf(request, name) {
1261
1269
  const value = request.headers[name];
@@ -1353,6 +1361,7 @@ function resolveOptions(options) {
1353
1361
  debug: options.debug === true,
1354
1362
  ignoreRoutes: options.ignoreRoutes ?? [],
1355
1363
  allowRoutes: options.allowRoutes ?? [],
1364
+ anonymousRoutes: options.anonymousRoutes ?? [],
1356
1365
  captureDbErrors: options.captureDbErrors !== false,
1357
1366
  routeFor: typeof options.routeFor === "function" ? options.routeFor : null,
1358
1367
  pg: options.pg && typeof options.pg === "object" ? options.pg : null,
@@ -1371,7 +1380,7 @@ function resolveOptions(options) {
1371
1380
 
1372
1381
  // ../node/src/version.ts
1373
1382
  var SDK_NAME = "@sypnia/telemetry/node" ;
1374
- var SDK_VERSION = "0.2.0" ;
1383
+ var SDK_VERSION = "0.3.0" ;
1375
1384
 
1376
1385
  // ../node/src/api.ts
1377
1386
  var BRIDGE_MARKER = /* @__PURE__ */ Symbol.for("sypnia.otel.bridge");
@@ -1425,7 +1434,7 @@ function init(options = {}) {
1425
1434
  function identify(who) {
1426
1435
  try {
1427
1436
  const scope = currentScope();
1428
- if (!scope || !who) return;
1437
+ if (!scope || !who || scope.request.anonymous) return;
1429
1438
  const person = who.person ? cutChars(String(who.person.id ?? ""), LIMITS.idChars) : "";
1430
1439
  if (person) setAttribute(scope.request.server.attributes, "user.id", person);
1431
1440
  const account = who.account ? cutChars(String(who.account.id ?? ""), LIMITS.idChars) : "";
@@ -1,5 +1,5 @@
1
- import { safe, MAX_CHUNKS_PER_SESSION, whenIdle, writeDecision, CHUNK_CHARS, MAX_EVENT_CHARS, MAX_BUFFER_CHARS, CHUNK_INTERVAL_MS, readDecision, RESYNC_DELAYS_MS, SNAPSHOT_DELAY_MS, SNAPSHOTS_PER_SESSION, QUIET_MS, MAX_QUIET_WAIT_MS, SNAPSHOT_CHARS, deviceClassOf, post, encode, RETRY_DELAYS_MS, KEEPALIVE_MAX_CHARS, beacon, PARK_MAX_MS, PARK_BASE_MS, RECORD_CHECKOUT_MS, BUFFER_MS } from './chunk-46P5IZVP.js';
2
- import { matchesRoute } from './chunk-U6USLZJ2.js';
1
+ import { safe, MAX_CHUNKS_PER_SESSION, whenIdle, writeDecision, CHUNK_CHARS, MAX_EVENT_CHARS, MAX_BUFFER_CHARS, CHUNK_INTERVAL_MS, readDecision, RESYNC_DELAYS_MS, SNAPSHOT_DELAY_MS, SNAPSHOTS_PER_SESSION, QUIET_MS, MAX_QUIET_WAIT_MS, SNAPSHOT_CHARS, deviceClassOf, post, encode, RETRY_DELAYS_MS, KEEPALIVE_MAX_CHARS, beacon, PARK_MAX_MS, PARK_BASE_MS, RECORD_CHECKOUT_MS, BUFFER_MS } from './chunk-UPXOW6QR.js';
2
+ import { matchesRoute } from './chunk-P5DK2OU7.js';
3
3
  import { record } from 'rrweb';
4
4
 
5
5
  // ../browser/src/recorder/masking.ts
@@ -0,0 +1,2 @@
1
+ export { routeNamer } from './chunk-2RMEOMSD.js';
2
+ import './chunk-P5DK2OU7.js';
@@ -1,4 +1,4 @@
1
- import { pathnameOf, routeOf } from './chunk-U6USLZJ2.js';
1
+ import { pathnameOf, routeOf } from './chunk-P5DK2OU7.js';
2
2
  import { readFileSync } from 'fs';
3
3
  import { resolve } from 'path';
4
4
 
@@ -0,0 +1,2 @@
1
+ export { startNode } from './chunk-LBKUMS7U.js';
2
+ import './chunk-WUAOTFVV.js';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sypnia/telemetry",
3
- "version": "0.2.0",
3
+ "version": "0.3.0",
4
4
  "description": "Sypnia Telemetry: errors, sessions, replays, performance and traces for the browser, Node and Next.js, in one package.",
5
5
  "license": "MIT",
6
6
  "type": "module",
@@ -78,6 +78,10 @@
78
78
  "engines": {
79
79
  "node": ">=20"
80
80
  },
81
+ "scripts": {
82
+ "build": "tsup",
83
+ "typecheck": "tsc -p tsconfig.json"
84
+ },
81
85
  "dependencies": {
82
86
  "rrweb": "2.1.6",
83
87
  "rrweb-snapshot": "2.1.6"
@@ -94,12 +98,8 @@
94
98
  "access": "public"
95
99
  },
96
100
  "devDependencies": {
101
+ "@sypnia/shared": "workspace:*",
97
102
  "pg": "^8.13.0",
98
- "@types/pg": "^8.11.0",
99
- "@sypnia/shared": "0.0.0"
100
- },
101
- "scripts": {
102
- "build": "tsup",
103
- "typecheck": "tsc -p tsconfig.json"
103
+ "@types/pg": "^8.11.0"
104
104
  }
105
- }
105
+ }
@@ -1,2 +0,0 @@
1
- export { routeNamer } from './chunk-VWTXZCR4.js';
2
- import './chunk-U6USLZJ2.js';
@@ -1,2 +0,0 @@
1
- export { startNode } from './chunk-Q6PBRG7Q.js';
2
- import './chunk-WUAOTFVV.js';