@sypnia/telemetry 0.3.1 → 0.4.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 +7 -0
- package/README.md +10 -0
- package/dist/{api-DJWXTLo4.d.ts → api-0SQLGLr-.d.ts} +4 -0
- package/dist/browser/index.d.ts +2 -2
- package/dist/browser/index.js +1 -1
- package/dist/{chunk-E2RSHYUO.js → chunk-G6MIOH7R.js} +95 -10
- package/dist/{index-BQbAXVDI.d.ts → index-CmMEhtUp.d.ts} +32 -4
- package/dist/next/client.d.ts +2 -2
- package/dist/next/client.js +2 -2
- package/dist/next/opennext.d.ts +1 -1
- package/dist/next/opennext.js +1 -1
- package/dist/next/server.d.ts +8 -4
- package/dist/next/server.js +12 -3
- package/dist/node/index.d.ts +1 -1
- package/dist/node/index.js +45 -4
- package/dist/{recorder-IZ3QHWYA.js → recorder-XR64CWEO.js} +1 -0
- package/dist/start-A5IAEVOU.js +2 -0
- package/package.json +8 -8
- package/dist/start-MKLQU3SQ.js +0 -2
- /package/dist/{chunk-BSVLHKIB.js → chunk-FEOH5L2N.js} +0 -0
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,12 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## 0.4.0 (2026-11-18)
|
|
4
|
+
|
|
5
|
+
Use cases and places (docs: https://telemetry.docs.sypnia.com/concepts/use-cases-and-places).
|
|
6
|
+
|
|
7
|
+
- Browser: every `page_view`, `click`, `rage_click` and `dead_click` carries `place`, the `data-sypnia-place` of the innermost marked element: for a page view, the place the page shows (inside the last open dialog, else the main content), read again once a client-side router has shown the new page; for a click, the place around the clicked element. Only ids are sent (kebab-case segments joined by dots, up to 120 characters); any other value is skipped. Masking does not change them, and replays keep the attribute.
|
|
8
|
+
- Node and Next.js: `setSpanAttributes(values)` and `activeSpan()` set attributes on the span the current code runs in (the `span()` being run, else the request's or job's span), also after its work ended, until the request is sent. `span(name, fn, attrs)` passes `fn` a handle with `setAttribute` and `setAttributes`. `sypnia.case` is kept up to 128 characters and `sypnia.case.outcome` up to 80.
|
|
9
|
+
|
|
3
10
|
## 0.3.1 (2026-11-17)
|
|
4
11
|
|
|
5
12
|
- Node and Next.js: a request of an anonymous route records its route in `url.path` (`/invite/:id`), never the path with its ids or tokens, like the browser.
|
package/README.md
CHANGED
|
@@ -30,6 +30,16 @@ import { init } from '@sypnia/telemetry/node';
|
|
|
30
30
|
init({ project: process.env.SYPNIA_PROJECT_KEY, service: 'shop-api' });
|
|
31
31
|
```
|
|
32
32
|
|
|
33
|
+
Use cases and places ([docs](https://telemetry.docs.sypnia.com/concepts/use-cases-and-places)): mark the element that shows each place of your navigation map with `data-sypnia-place="shop.checkout"`, and every page view and click carries it as `place`. On the server, set the use case on the span that serves it:
|
|
34
|
+
|
|
35
|
+
```ts
|
|
36
|
+
import { setSpanAttributes, span } from '@sypnia/telemetry/node';
|
|
37
|
+
|
|
38
|
+
setSpanAttributes({ 'sypnia.case': 'place-order' }); // the request's span, or the span() running
|
|
39
|
+
const order = await span('place order', async handle => placeOrder(cart), { 'sypnia.case': 'place-order' });
|
|
40
|
+
setSpanAttributes({ 'sypnia.case.outcome': 'OrderPlaced' }); // also after the work ended
|
|
41
|
+
```
|
|
42
|
+
|
|
33
43
|
Events go to `https://telemetry.ingest.sypnia.com` unless you set `endpoint` (a self-hosted engine). Source maps and releases go to `https://telemetry.api.sypnia.com` unless `SYPNIA_BASE_URL` says otherwise. `next` is an optional peer: only the `next/*` subpaths need it.
|
|
34
44
|
|
|
35
45
|
Docs: [telemetry.docs.sypnia.com/sdks](https://telemetry.docs.sypnia.com/sdks). It replaces `@sypnia/browser`, `@sypnia/node` and `@sypnia/next`, which stay published until their users move.
|
|
@@ -65,6 +65,8 @@ interface PageViewEvent extends EventBase {
|
|
|
65
65
|
type: 'page_view';
|
|
66
66
|
nav: NavigationKind;
|
|
67
67
|
from: string | null;
|
|
68
|
+
/** The place on the app's navigation map the page shows (`data-sypnia-place`), or null. */
|
|
69
|
+
place: string | null;
|
|
68
70
|
}
|
|
69
71
|
interface PageLeaveEvent extends EventBase {
|
|
70
72
|
type: 'page_leave';
|
|
@@ -78,6 +80,8 @@ interface ClickFields {
|
|
|
78
80
|
txt: string | null;
|
|
79
81
|
crole?: ClickRole;
|
|
80
82
|
ctx: string | null;
|
|
83
|
+
/** The place on the app's navigation map around the control (`data-sypnia-place`), or null. Never content. */
|
|
84
|
+
place: string | null;
|
|
81
85
|
href: string | null;
|
|
82
86
|
x: number;
|
|
83
87
|
y: number;
|
package/dist/browser/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { I as InitOptions } from '../api-
|
|
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-
|
|
1
|
+
import { I as InitOptions } from '../api-0SQLGLr-.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-0SQLGLr-.js';
|
|
3
3
|
|
|
4
4
|
/**
|
|
5
5
|
* `@sypnia/browser`: errors, sessions, replay, page performance, failing API
|
package/dist/browser/index.js
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
export { flush, getSessionId, identify, init, notifyNavigation, optIn, optOut, reportError, track } from '../chunk-
|
|
1
|
+
export { flush, getSessionId, identify, init, notifyNavigation, optIn, optOut, reportError, track } from '../chunk-G6MIOH7R.js';
|
|
2
2
|
import '../chunk-UPXOW6QR.js';
|
|
3
3
|
import '../chunk-P5DK2OU7.js';
|
|
@@ -182,7 +182,7 @@ var SessionStore = class {
|
|
|
182
182
|
|
|
183
183
|
// ../browser/src/version.ts
|
|
184
184
|
var SDK_NAME = "@sypnia/telemetry/browser" ;
|
|
185
|
-
var SDK_VERSION = "0.
|
|
185
|
+
var SDK_VERSION = "0.4.0" ;
|
|
186
186
|
|
|
187
187
|
// ../browser/src/transport.ts
|
|
188
188
|
function uuid() {
|
|
@@ -825,6 +825,57 @@ function isActionable(el) {
|
|
|
825
825
|
return true;
|
|
826
826
|
}
|
|
827
827
|
|
|
828
|
+
// ../browser/src/capture/place.ts
|
|
829
|
+
var PLACE_ATTRIBUTE = "data-sypnia-place";
|
|
830
|
+
var PLACE_MAX_LENGTH = 120;
|
|
831
|
+
var PLACES_SCANNED = 500;
|
|
832
|
+
var DEPTH_LIMIT = 200;
|
|
833
|
+
var PLACE_ID = /^[a-z0-9]+(?:-[a-z0-9]+)*(?:\.[a-z0-9]+(?:-[a-z0-9]+)*)*$/;
|
|
834
|
+
var OVERLAY_SELECTOR2 = 'dialog[open], [role="dialog"], [role="alertdialog"], [aria-modal="true"]';
|
|
835
|
+
var MAIN_SELECTOR = 'main, [role="main"]';
|
|
836
|
+
var SELECTOR = `[${PLACE_ATTRIBUTE}]`;
|
|
837
|
+
function placeId(value) {
|
|
838
|
+
if (typeof value !== "string") return null;
|
|
839
|
+
const id = value.trim();
|
|
840
|
+
return id.length > 0 && id.length <= PLACE_MAX_LENGTH && PLACE_ID.test(id) ? id : null;
|
|
841
|
+
}
|
|
842
|
+
function ownPlace(el) {
|
|
843
|
+
return placeId(safe(() => el.getAttribute(PLACE_ATTRIBUTE)));
|
|
844
|
+
}
|
|
845
|
+
function placeAround(el) {
|
|
846
|
+
let node = el;
|
|
847
|
+
for (let depth = 0; node && depth < DEPTH_LIMIT; depth++) {
|
|
848
|
+
const id = ownPlace(node);
|
|
849
|
+
if (id) return id;
|
|
850
|
+
node = node.parentElement;
|
|
851
|
+
}
|
|
852
|
+
return null;
|
|
853
|
+
}
|
|
854
|
+
var HIDDEN = '[hidden], [aria-hidden="true"], [inert], dialog:not([open])';
|
|
855
|
+
function innermostIn(root) {
|
|
856
|
+
let best = null;
|
|
857
|
+
let bestDepth = -1;
|
|
858
|
+
for (const el of Array.from(root.querySelectorAll(SELECTOR)).slice(0, PLACES_SCANNED)) {
|
|
859
|
+
const id = ownPlace(el);
|
|
860
|
+
if (!id || el.closest(HIDDEN)) continue;
|
|
861
|
+
let depth = 0;
|
|
862
|
+
for (let node = el.parentElement; node && depth < DEPTH_LIMIT; node = node.parentElement) depth++;
|
|
863
|
+
if (depth > bestDepth) [best, bestDepth] = [id, depth];
|
|
864
|
+
}
|
|
865
|
+
return best ?? placeAround(root);
|
|
866
|
+
}
|
|
867
|
+
function pagePlace() {
|
|
868
|
+
return safe(() => {
|
|
869
|
+
const visible = (selector) => Array.from(document.querySelectorAll(selector)).filter((el) => !el.closest(HIDDEN));
|
|
870
|
+
for (const overlay of visible(OVERLAY_SELECTOR2).reverse()) {
|
|
871
|
+
const id = innermostIn(overlay);
|
|
872
|
+
if (id) return id;
|
|
873
|
+
}
|
|
874
|
+
const main = visible(MAIN_SELECTOR)[0];
|
|
875
|
+
return main && innermostIn(main) || (document.body ? innermostIn(document.body) : null);
|
|
876
|
+
}) ?? null;
|
|
877
|
+
}
|
|
878
|
+
|
|
828
879
|
// ../browser/src/capture/clicks.ts
|
|
829
880
|
var LABEL_FORWARD_MS = 100;
|
|
830
881
|
var NATIVE_PICKER_INPUTS = /* @__PURE__ */ new Set(["file", "date", "time", "datetime-local", "month", "week", "color"]);
|
|
@@ -937,7 +988,10 @@ var ClickCapture = class {
|
|
|
937
988
|
this.lastLabel = { control: safe(() => subject.control) ?? null, at: now };
|
|
938
989
|
}
|
|
939
990
|
if (opensOutsideThePage(element)) this.lastExternalAt = now;
|
|
940
|
-
const snapshot = {
|
|
991
|
+
const snapshot = {
|
|
992
|
+
info: { ...describeElement(subject, element), place: placeAround(element) },
|
|
993
|
+
coords: this.coordsOf(event, subject)
|
|
994
|
+
};
|
|
941
995
|
this.options.emit({ type: "click", ...snapshot.info, ...snapshot.coords });
|
|
942
996
|
if (selectsText(event, subject)) this.dropRage();
|
|
943
997
|
else if (!isTextEntry(subject)) this.trackRage(snapshot);
|
|
@@ -1676,6 +1730,8 @@ var ACTIVITY = /* @__PURE__ */ new Set(["page_view", "click", "rage_click", "dea
|
|
|
1676
1730
|
var URGENT_WHEN_HIDDEN = /* @__PURE__ */ new Set(["vital", "page_leave", "error"]);
|
|
1677
1731
|
var INPUT_TOUCH_EVERY_MS = 1e3;
|
|
1678
1732
|
var CONFIG_TIMEOUT_MS = 4e3;
|
|
1733
|
+
var PLACE_SETTLE_MS = 400;
|
|
1734
|
+
var CLICK_TYPES = /* @__PURE__ */ new Set(["click", "rage_click", "dead_click"]);
|
|
1679
1735
|
var Runtime = class {
|
|
1680
1736
|
constructor(options, deps) {
|
|
1681
1737
|
this.options = options;
|
|
@@ -1686,6 +1742,8 @@ var Runtime = class {
|
|
|
1686
1742
|
/** The identify event last sent, per session: the same one again sends nothing. */
|
|
1687
1743
|
this.identifySent = null;
|
|
1688
1744
|
this.page = null;
|
|
1745
|
+
/** The page view whose place may still change, while the router renders the page. */
|
|
1746
|
+
this.placePending = null;
|
|
1689
1747
|
this.landing = null;
|
|
1690
1748
|
this.lang = null;
|
|
1691
1749
|
this.lastSid = null;
|
|
@@ -1859,25 +1917,27 @@ var Runtime = class {
|
|
|
1859
1917
|
}
|
|
1860
1918
|
// ------------------------------------------------------------------ events
|
|
1861
1919
|
emit(fields, options = {}) {
|
|
1862
|
-
if (!this.active) return;
|
|
1920
|
+
if (!this.active) return null;
|
|
1921
|
+
if (CLICK_TYPES.has(fields.type)) this.settlePlace();
|
|
1863
1922
|
try {
|
|
1864
1923
|
if (!options.page) this.syncAddress();
|
|
1865
1924
|
const page = options.page ?? this.currentPage();
|
|
1866
|
-
if (!page || this.isIgnored(page.url)) return;
|
|
1925
|
+
if (!page || this.isIgnored(page.url)) return null;
|
|
1867
1926
|
const sid = options.sid ?? this.session(options.activity ?? ACTIVITY.has(fields.type), page, fields.type === "identify");
|
|
1868
|
-
if (!sid) return;
|
|
1927
|
+
if (!sid) return null;
|
|
1869
1928
|
let event = { ...this.base(fields.type, sid, page), ...fields };
|
|
1870
1929
|
if (options.ts !== void 0) event.ts = options.ts;
|
|
1871
1930
|
if (this.isAnonymous(page.url)) event = anonymize(event, this.options.anonymous.hideClickText);
|
|
1872
|
-
|
|
1931
|
+
return event ? this.queue(event) : null;
|
|
1873
1932
|
} catch {
|
|
1933
|
+
return null;
|
|
1874
1934
|
}
|
|
1875
1935
|
}
|
|
1876
1936
|
/** The last gates of every event: the `slow_down` in force, `beforeSend`, and the queue. */
|
|
1877
1937
|
queue(event) {
|
|
1878
1938
|
if (isBlockedBySlowDown(event, this.slowDown, this.now())) {
|
|
1879
1939
|
this.debug(`not sent, the project reached a limit: ${event.type}`);
|
|
1880
|
-
return;
|
|
1940
|
+
return null;
|
|
1881
1941
|
}
|
|
1882
1942
|
let final = event;
|
|
1883
1943
|
if (this.options.beforeSend) {
|
|
@@ -1888,13 +1948,14 @@ var Runtime = class {
|
|
|
1888
1948
|
}
|
|
1889
1949
|
if (!final) {
|
|
1890
1950
|
this.debug(`not sent, beforeSend dropped it: ${event.type}`);
|
|
1891
|
-
return;
|
|
1951
|
+
return null;
|
|
1892
1952
|
}
|
|
1893
1953
|
}
|
|
1894
1954
|
if (this.options.debug) safe(() => console.debug("[sypnia]", final));
|
|
1895
1955
|
if (final.type === "identify") this.identifySent = { sid: final.sid, json: identityKey(final) };
|
|
1896
1956
|
this.transport.enqueue(final);
|
|
1897
1957
|
if (URGENT_WHEN_HIDDEN.has(final.type) && isHidden()) this.flushSoon();
|
|
1958
|
+
return final;
|
|
1898
1959
|
}
|
|
1899
1960
|
base(type, sid, page) {
|
|
1900
1961
|
if (this.isAnonymous(page.url)) {
|
|
@@ -2029,13 +2090,37 @@ var Runtime = class {
|
|
|
2029
2090
|
this.page = { ...ref, startedAt: this.now(), maxScroll: 0, leaveSent: false };
|
|
2030
2091
|
this.measureScroll();
|
|
2031
2092
|
this.vitals.pageStarted(ref);
|
|
2032
|
-
this.
|
|
2093
|
+
this.settlePlace();
|
|
2094
|
+
const place = pagePlace();
|
|
2095
|
+
const view = this.emit({ type: "page_view", nav, from, place }, { page: ref });
|
|
2096
|
+
if (view?.type === "page_view") {
|
|
2097
|
+
const pending = { event: view, read: place, timer: null };
|
|
2098
|
+
pending.timer = setTimeout(() => {
|
|
2099
|
+
if (this.placePending === pending) this.settlePlace();
|
|
2100
|
+
}, PLACE_SETTLE_MS);
|
|
2101
|
+
this.placePending = pending;
|
|
2102
|
+
}
|
|
2033
2103
|
safe(() => this.recorder?.onPage(ref));
|
|
2034
2104
|
}
|
|
2105
|
+
/**
|
|
2106
|
+
* Reads the place of the last page view again, now that the page has had
|
|
2107
|
+
* time to show: a router that changes the address first still has the old
|
|
2108
|
+
* page on screen at that moment. A value `beforeSend` changed is kept.
|
|
2109
|
+
*/
|
|
2110
|
+
settlePlace() {
|
|
2111
|
+
const pending = this.placePending;
|
|
2112
|
+
if (!pending) return;
|
|
2113
|
+
this.placePending = null;
|
|
2114
|
+
if (pending.timer) clearTimeout(pending.timer);
|
|
2115
|
+
safe(() => {
|
|
2116
|
+
if (pending.event.place === pending.read) pending.event.place = pagePlace();
|
|
2117
|
+
});
|
|
2118
|
+
}
|
|
2035
2119
|
leavePage() {
|
|
2036
2120
|
const page = this.page;
|
|
2037
2121
|
if (!page || page.leaveSent) return;
|
|
2038
2122
|
page.leaveSent = true;
|
|
2123
|
+
this.settlePlace();
|
|
2039
2124
|
this.clicks.flushRage();
|
|
2040
2125
|
this.measureScroll();
|
|
2041
2126
|
const ref = { url: page.url, route: page.route };
|
|
@@ -2436,7 +2521,7 @@ function notifyNavigation(url, kind) {
|
|
|
2436
2521
|
}
|
|
2437
2522
|
|
|
2438
2523
|
// ../browser/src/index.ts
|
|
2439
|
-
var loadRecorder = () => import('./recorder-
|
|
2524
|
+
var loadRecorder = () => import('./recorder-XR64CWEO.js').then((module) => module.createRecorder);
|
|
2440
2525
|
function init(options) {
|
|
2441
2526
|
startSdk(options, loadRecorder);
|
|
2442
2527
|
}
|
|
@@ -94,8 +94,33 @@ interface Who {
|
|
|
94
94
|
declare function identify(who: Who | null): void;
|
|
95
95
|
/** Reports an error your code caught (`sypnia.error.source` `manual`). */
|
|
96
96
|
declare function reportError(error: unknown): void;
|
|
97
|
-
/**
|
|
98
|
-
|
|
97
|
+
/**
|
|
98
|
+
* The span a piece of code runs in, to add attributes to it, also after its
|
|
99
|
+
* work has ended (`sypnia.case.outcome`), until its request is sent. Outside
|
|
100
|
+
* a traced request, or with the SDK off, it does nothing.
|
|
101
|
+
*/
|
|
102
|
+
interface SpanHandle {
|
|
103
|
+
/** Sets one attribute: a string, a number or a boolean, within the limits of every attribute. */
|
|
104
|
+
setAttribute(name: string, value: AttributeValue): void;
|
|
105
|
+
/** Sets several; values that are not strings, numbers or booleans are left out. */
|
|
106
|
+
setAttributes(values: Record<string, AttributeValue>): void;
|
|
107
|
+
}
|
|
108
|
+
/**
|
|
109
|
+
* The span the current code runs in: the `span()` being run, else the
|
|
110
|
+
* request's or job's own span. Its attributes can be set after the work
|
|
111
|
+
* ends, until the request is sent: a library sets `sypnia.case` when a use
|
|
112
|
+
* case starts and `sypnia.case.outcome` when it ends (docs:
|
|
113
|
+
* concepts/use-cases-and-places).
|
|
114
|
+
*/
|
|
115
|
+
declare function activeSpan(): SpanHandle;
|
|
116
|
+
/** Sets attributes on the span the current code runs in (see `activeSpan`). `false` when there is none. */
|
|
117
|
+
declare function setSpanAttributes(values: Record<string, AttributeValue>): boolean;
|
|
118
|
+
/**
|
|
119
|
+
* Records your own step as an internal span around `fn`. Returns what `fn`
|
|
120
|
+
* returns. `fn` receives the span, to set attributes on it while it runs or
|
|
121
|
+
* after it ends.
|
|
122
|
+
*/
|
|
123
|
+
declare function span<T>(name: string, fn: (span: SpanHandle) => T, attrs?: Record<string, string | number | boolean>): T;
|
|
99
124
|
/** Sends what is waiting; resolves when it is sent or after `timeoutMs`. */
|
|
100
125
|
declare function flush(timeoutMs?: number): Promise<void>;
|
|
101
126
|
/** Sends what is waiting, then stops the SDK. */
|
|
@@ -307,6 +332,7 @@ type NodeSdk_LambdaHandlerOptions<E> = LambdaHandlerOptions<E>;
|
|
|
307
332
|
type NodeSdk_NodeOptions = NodeOptions;
|
|
308
333
|
type NodeSdk_Pattern = Pattern;
|
|
309
334
|
type NodeSdk_SpanForReview = SpanForReview;
|
|
335
|
+
type NodeSdk_SpanHandle = SpanHandle;
|
|
310
336
|
type NodeSdk_SqsBatchResponse = SqsBatchResponse;
|
|
311
337
|
type NodeSdk_SqsHandlerOptions<R> = SqsHandlerOptions<R>;
|
|
312
338
|
type NodeSdk_SqsMessageAttribute = SqsMessageAttribute;
|
|
@@ -315,6 +341,7 @@ type NodeSdk_SqsRecordOptions<R> = SqsRecordOptions<R>;
|
|
|
315
341
|
type NodeSdk_TraceRequestOptions<T> = TraceRequestOptions<T>;
|
|
316
342
|
type NodeSdk_WaitUntil = WaitUntil;
|
|
317
343
|
type NodeSdk_Who = Who;
|
|
344
|
+
declare const NodeSdk_activeSpan: typeof activeSpan;
|
|
318
345
|
declare const NodeSdk_captureRequestError: typeof captureRequestError;
|
|
319
346
|
declare const NodeSdk_continueTrace: typeof continueTrace;
|
|
320
347
|
declare const NodeSdk_currentTraceparent: typeof currentTraceparent;
|
|
@@ -323,6 +350,7 @@ declare const NodeSdk_identify: typeof identify;
|
|
|
323
350
|
declare const NodeSdk_init: typeof init;
|
|
324
351
|
declare const NodeSdk_injectTraceContext: typeof injectTraceContext;
|
|
325
352
|
declare const NodeSdk_reportError: typeof reportError;
|
|
353
|
+
declare const NodeSdk_setSpanAttributes: typeof setSpanAttributes;
|
|
326
354
|
declare const NodeSdk_setWaitUntil: typeof setWaitUntil;
|
|
327
355
|
declare const NodeSdk_shutdown: typeof shutdown;
|
|
328
356
|
declare const NodeSdk_span: typeof span;
|
|
@@ -334,7 +362,7 @@ declare const NodeSdk_wrapFetchHandler: typeof wrapFetchHandler;
|
|
|
334
362
|
declare const NodeSdk_wrapLambdaHandler: typeof wrapLambdaHandler;
|
|
335
363
|
declare const NodeSdk_wrapSqsHandler: typeof wrapSqsHandler;
|
|
336
364
|
declare namespace NodeSdk {
|
|
337
|
-
export { NodeSdk_BRIDGE_MARKER as BRIDGE_MARKER, type NodeSdk_FailedRequest as FailedRequest, type NodeSdk_HostRequest as HostRequest, type NodeSdk_JobAttributes as JobAttributes, type NodeSdk_LambdaContextLike as LambdaContextLike, type NodeSdk_LambdaHandlerOptions as LambdaHandlerOptions, type NodeSdk_NodeOptions as NodeOptions, type NodeSdk_Pattern as Pattern, type NodeSdk_SpanForReview as SpanForReview, type NodeSdk_SqsBatchResponse as SqsBatchResponse, type NodeSdk_SqsHandlerOptions as SqsHandlerOptions, type NodeSdk_SqsMessageAttribute as SqsMessageAttribute, type NodeSdk_SqsRecordLike as SqsRecordLike, type NodeSdk_SqsRecordOptions as SqsRecordOptions, type NodeSdk_TraceRequestOptions as TraceRequestOptions, type NodeSdk_WaitUntil as WaitUntil, type NodeSdk_Who as Who, NodeSdk_captureRequestError as captureRequestError, NodeSdk_continueTrace as continueTrace, NodeSdk_currentTraceparent as currentTraceparent, NodeSdk_flush as flush, NodeSdk_identify as identify, NodeSdk_init as init, NodeSdk_injectTraceContext as injectTraceContext, NodeSdk_reportError as reportError, NodeSdk_setWaitUntil as setWaitUntil, NodeSdk_shutdown as shutdown, NodeSdk_span as span, NodeSdk_sqsTraceAttributes as sqsTraceAttributes, NodeSdk_traceRequest as traceRequest, NodeSdk_traceSqsRecord as traceSqsRecord, NodeSdk_traceparentOf as traceparentOf, NodeSdk_wrapFetchHandler as wrapFetchHandler, NodeSdk_wrapLambdaHandler as wrapLambdaHandler, NodeSdk_wrapSqsHandler as wrapSqsHandler };
|
|
365
|
+
export { NodeSdk_BRIDGE_MARKER as BRIDGE_MARKER, type NodeSdk_FailedRequest as FailedRequest, type NodeSdk_HostRequest as HostRequest, type NodeSdk_JobAttributes as JobAttributes, type NodeSdk_LambdaContextLike as LambdaContextLike, type NodeSdk_LambdaHandlerOptions as LambdaHandlerOptions, type NodeSdk_NodeOptions as NodeOptions, type NodeSdk_Pattern as Pattern, type NodeSdk_SpanForReview as SpanForReview, type NodeSdk_SpanHandle as SpanHandle, type NodeSdk_SqsBatchResponse as SqsBatchResponse, type NodeSdk_SqsHandlerOptions as SqsHandlerOptions, type NodeSdk_SqsMessageAttribute as SqsMessageAttribute, type NodeSdk_SqsRecordLike as SqsRecordLike, type NodeSdk_SqsRecordOptions as SqsRecordOptions, type NodeSdk_TraceRequestOptions as TraceRequestOptions, type NodeSdk_WaitUntil as WaitUntil, type NodeSdk_Who as Who, NodeSdk_activeSpan as activeSpan, NodeSdk_captureRequestError as captureRequestError, NodeSdk_continueTrace as continueTrace, NodeSdk_currentTraceparent as currentTraceparent, NodeSdk_flush as flush, NodeSdk_identify as identify, NodeSdk_init as init, NodeSdk_injectTraceContext as injectTraceContext, NodeSdk_reportError as reportError, NodeSdk_setSpanAttributes as setSpanAttributes, NodeSdk_setWaitUntil as setWaitUntil, NodeSdk_shutdown as shutdown, NodeSdk_span as span, NodeSdk_sqsTraceAttributes as sqsTraceAttributes, NodeSdk_traceRequest as traceRequest, NodeSdk_traceSqsRecord as traceSqsRecord, NodeSdk_traceparentOf as traceparentOf, NodeSdk_wrapFetchHandler as wrapFetchHandler, NodeSdk_wrapLambdaHandler as wrapLambdaHandler, NodeSdk_wrapSqsHandler as wrapSqsHandler };
|
|
338
366
|
}
|
|
339
367
|
|
|
340
|
-
export { BRIDGE_MARKER as B, type FailedRequest as F, type HostRequest as H, type JobAttributes as J, type LambdaContextLike as L, NodeSdk as N, type Pattern as P, type
|
|
368
|
+
export { wrapFetchHandler as A, BRIDGE_MARKER as B, wrapLambdaHandler as C, wrapSqsHandler as D, type FailedRequest as F, type HostRequest as H, type JobAttributes as J, type LambdaContextLike as L, NodeSdk as N, type Pattern as P, type SpanHandle as S, type TraceRequestOptions as T, type WaitUntil as W, type LambdaHandlerOptions as a, type NodeOptions as b, type SpanForReview as c, type SqsBatchResponse as d, type SqsHandlerOptions as e, type SqsMessageAttribute as f, type SqsRecordLike as g, type SqsRecordOptions as h, type Who as i, activeSpan as j, captureRequestError as k, continueTrace as l, currentTraceparent as m, flush as n, identify as o, init as p, injectTraceContext as q, reportError as r, setSpanAttributes as s, setWaitUntil as t, shutdown as u, span as v, sqsTraceAttributes as w, traceRequest as x, traceSqsRecord as y, traceparentOf as z };
|
package/dist/next/client.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { I as InitOptions } from '../api-
|
|
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-
|
|
1
|
+
import { I as InitOptions } from '../api-0SQLGLr-.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-0SQLGLr-.js';
|
|
3
3
|
|
|
4
4
|
/**
|
|
5
5
|
* `@sypnia/next/client`: the browser side, switched on from
|
package/dist/next/client.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { init, notifyNavigation } from '../chunk-
|
|
2
|
-
export { flush, getSessionId, identify, optIn, optOut, reportError, track } from '../chunk-
|
|
1
|
+
import { init, notifyNavigation } from '../chunk-G6MIOH7R.js';
|
|
2
|
+
export { flush, getSessionId, identify, optIn, optOut, reportError, track } from '../chunk-G6MIOH7R.js';
|
|
3
3
|
import { readConfig } from '../chunk-WUAOTFVV.js';
|
|
4
4
|
import '../chunk-UPXOW6QR.js';
|
|
5
5
|
import { routeNamer } from '../chunk-2RMEOMSD.js';
|
package/dist/next/opennext.d.ts
CHANGED
package/dist/next/opennext.js
CHANGED
package/dist/next/server.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { N as NodeSdk } from '../index-
|
|
1
|
+
import { N as NodeSdk, S as SpanHandle } from '../index-CmMEhtUp.js';
|
|
2
2
|
|
|
3
3
|
/**
|
|
4
4
|
* Starts the Node SDK with `withSypnia`'s values, wherever the server side
|
|
@@ -40,9 +40,13 @@ declare function onRequestError(error: unknown, request: NextRequestInfo, contex
|
|
|
40
40
|
declare const identify: Node['identify'];
|
|
41
41
|
/** Reports an error your code caught on the server. */
|
|
42
42
|
declare const reportError: Node['reportError'];
|
|
43
|
-
/** Records your own step as a span around `fn
|
|
44
|
-
declare function span<T>(name: string, fn: () => T, attrs?: Record<string, string | number | boolean>): T;
|
|
43
|
+
/** Records your own step as a span around `fn`, which receives the span to set attributes on. */
|
|
44
|
+
declare function span<T>(name: string, fn: (span: SpanHandle) => T, attrs?: Record<string, string | number | boolean>): T;
|
|
45
|
+
/** The span the current code runs in, to set attributes on it (`sypnia.case.outcome`). */
|
|
46
|
+
declare function activeSpan(): SpanHandle;
|
|
47
|
+
/** Sets attributes on the span the current code runs in. `false` when there is none. */
|
|
48
|
+
declare function setSpanAttributes(values: Record<string, string | number | boolean>): boolean;
|
|
45
49
|
/** Sends what is waiting. */
|
|
46
50
|
declare const flush: Node['flush'];
|
|
47
51
|
|
|
48
|
-
export { type NextErrorContext, type NextRequestInfo, flush, identify, onRequestError, register, reportError, span };
|
|
52
|
+
export { type NextErrorContext, type NextRequestInfo, SpanHandle, activeSpan, flush, identify, onRequestError, register, reportError, setSpanAttributes, span };
|
package/dist/next/server.js
CHANGED
|
@@ -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-
|
|
13
|
+
const { startNode } = await import('../start-A5IAEVOU.js');
|
|
14
14
|
node = await startNode(config);
|
|
15
15
|
} catch {
|
|
16
16
|
}
|
|
@@ -29,9 +29,18 @@ function onRequestError(error, request, context = {}) {
|
|
|
29
29
|
}
|
|
30
30
|
var identify = (who) => node?.identify(who);
|
|
31
31
|
var reportError = (error) => node?.reportError(error);
|
|
32
|
+
var NO_SPAN = { setAttribute: () => {
|
|
33
|
+
}, setAttributes: () => {
|
|
34
|
+
} };
|
|
32
35
|
function span(name, fn, attrs) {
|
|
33
|
-
return node ? node.span(name, fn, attrs) : fn();
|
|
36
|
+
return node ? node.span(name, fn, attrs) : fn(NO_SPAN);
|
|
37
|
+
}
|
|
38
|
+
function activeSpan() {
|
|
39
|
+
return node ? node.activeSpan() : NO_SPAN;
|
|
40
|
+
}
|
|
41
|
+
function setSpanAttributes(values) {
|
|
42
|
+
return node ? node.setSpanAttributes(values) : false;
|
|
34
43
|
}
|
|
35
44
|
var flush = async (timeoutMs) => node?.flush(timeoutMs);
|
|
36
45
|
|
|
37
|
-
export { flush, identify, onRequestError, register, reportError, span };
|
|
46
|
+
export { activeSpan, flush, identify, onRequestError, register, reportError, setSpanAttributes, span };
|
package/dist/node/index.d.ts
CHANGED
|
@@ -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,
|
|
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, c as SpanForReview, S as SpanHandle, d as SqsBatchResponse, e as SqsHandlerOptions, f as SqsMessageAttribute, g as SqsRecordLike, h as SqsRecordOptions, T as TraceRequestOptions, W as WaitUntil, i as Who, j as activeSpan, k as captureRequestError, l as continueTrace, m as currentTraceparent, n as flush, o as identify, p as init, q as injectTraceContext, r as reportError, s as setSpanAttributes, t as setWaitUntil, u as shutdown, v as span, w as sqsTraceAttributes, x as traceRequest, y as traceSqsRecord, z as traceparentOf, A as wrapFetchHandler, C as wrapLambdaHandler, D as wrapSqsHandler } from '../index-CmMEhtUp.js';
|
package/dist/node/index.js
CHANGED
|
@@ -26,6 +26,10 @@ var LIMITS = {
|
|
|
26
26
|
releaseChars: 40,
|
|
27
27
|
environmentChars: 40,
|
|
28
28
|
idChars: 128,
|
|
29
|
+
/** `sypnia.case`: a use case id (reference/semantic-conventions). */
|
|
30
|
+
caseChars: 128,
|
|
31
|
+
/** `sypnia.case.outcome`: the name of an outcome or failure. */
|
|
32
|
+
caseOutcomeChars: 80,
|
|
29
33
|
digestChars: 100,
|
|
30
34
|
urlPathChars: 500,
|
|
31
35
|
failuresPerRequest: 5,
|
|
@@ -47,6 +51,8 @@ function charsFor(name) {
|
|
|
47
51
|
if (name === "exception.stacktrace") return LIMITS.stackChars;
|
|
48
52
|
if (name === "exception.message" || name === "status.message") return LIMITS.messageChars;
|
|
49
53
|
if (name === "sypnia.db.message") return LIMITS.dbMessageChars;
|
|
54
|
+
if (name === "sypnia.case") return LIMITS.caseChars;
|
|
55
|
+
if (name === "sypnia.case.outcome") return LIMITS.caseOutcomeChars;
|
|
50
56
|
return LIMITS.attributeChars;
|
|
51
57
|
}
|
|
52
58
|
function setAttribute(attributes, name, value) {
|
|
@@ -1381,7 +1387,7 @@ function resolveOptions(options) {
|
|
|
1381
1387
|
|
|
1382
1388
|
// ../node/src/version.ts
|
|
1383
1389
|
var SDK_NAME = "@sypnia/telemetry/node" ;
|
|
1384
|
-
var SDK_VERSION = "0.
|
|
1390
|
+
var SDK_VERSION = "0.4.0" ;
|
|
1385
1391
|
|
|
1386
1392
|
// ../node/src/api.ts
|
|
1387
1393
|
var BRIDGE_MARKER = /* @__PURE__ */ Symbol.for("sypnia.otel.bridge");
|
|
@@ -1450,6 +1456,40 @@ function reportError(error) {
|
|
|
1450
1456
|
} catch {
|
|
1451
1457
|
}
|
|
1452
1458
|
}
|
|
1459
|
+
var NO_SPAN = { setAttribute: () => {
|
|
1460
|
+
}, setAttributes: () => {
|
|
1461
|
+
} };
|
|
1462
|
+
function handleOf(target) {
|
|
1463
|
+
if (!target) return NO_SPAN;
|
|
1464
|
+
return {
|
|
1465
|
+
setAttribute: (name, value) => {
|
|
1466
|
+
try {
|
|
1467
|
+
setAttribute(target.attributes, String(name), value);
|
|
1468
|
+
} catch {
|
|
1469
|
+
}
|
|
1470
|
+
},
|
|
1471
|
+
setAttributes: (values) => {
|
|
1472
|
+
try {
|
|
1473
|
+
setAttributes(target.attributes, values);
|
|
1474
|
+
} catch {
|
|
1475
|
+
}
|
|
1476
|
+
}
|
|
1477
|
+
};
|
|
1478
|
+
}
|
|
1479
|
+
function activeSpan() {
|
|
1480
|
+
try {
|
|
1481
|
+
const scope = currentScope();
|
|
1482
|
+
return getSdk() && scope ? handleOf(scope.parent) : NO_SPAN;
|
|
1483
|
+
} catch {
|
|
1484
|
+
return NO_SPAN;
|
|
1485
|
+
}
|
|
1486
|
+
}
|
|
1487
|
+
function setSpanAttributes(values) {
|
|
1488
|
+
const handle = activeSpan();
|
|
1489
|
+
if (handle === NO_SPAN) return false;
|
|
1490
|
+
handle.setAttributes(values);
|
|
1491
|
+
return true;
|
|
1492
|
+
}
|
|
1453
1493
|
function span2(name, fn, attrs) {
|
|
1454
1494
|
let child = null;
|
|
1455
1495
|
const scope = currentScope();
|
|
@@ -1461,8 +1501,9 @@ function span2(name, fn, attrs) {
|
|
|
1461
1501
|
} catch {
|
|
1462
1502
|
child = null;
|
|
1463
1503
|
}
|
|
1464
|
-
if (!child || !scope) return fn();
|
|
1504
|
+
if (!child || !scope) return fn(NO_SPAN);
|
|
1465
1505
|
const active = child;
|
|
1506
|
+
const handle = handleOf(active);
|
|
1466
1507
|
const fail = (error) => {
|
|
1467
1508
|
try {
|
|
1468
1509
|
failSpan(active, redactMessage(errorParts(error).message), errorParts(error).type);
|
|
@@ -1472,7 +1513,7 @@ function span2(name, fn, attrs) {
|
|
|
1472
1513
|
};
|
|
1473
1514
|
let result;
|
|
1474
1515
|
try {
|
|
1475
|
-
result = runInScope({ request: scope.request, parent: active }, fn);
|
|
1516
|
+
result = runInScope({ request: scope.request, parent: active }, () => fn(handle));
|
|
1476
1517
|
} catch (error) {
|
|
1477
1518
|
fail(error);
|
|
1478
1519
|
throw error;
|
|
@@ -1847,4 +1888,4 @@ async function traceHttp(sdk, http, fn, context) {
|
|
|
1847
1888
|
}
|
|
1848
1889
|
}
|
|
1849
1890
|
|
|
1850
|
-
export { BRIDGE_MARKER, captureRequestError, continueTrace, currentTraceparent, flush, identify, init, injectTraceContext, reportError, setWaitUntil, shutdown, span2 as span, sqsTraceAttributes, traceRequest, traceSqsRecord, traceparentOf2 as traceparentOf, wrapFetchHandler, wrapLambdaHandler, wrapSqsHandler };
|
|
1891
|
+
export { BRIDGE_MARKER, activeSpan, captureRequestError, continueTrace, currentTraceparent, flush, identify, init, injectTraceContext, reportError, setSpanAttributes, setWaitUntil, shutdown, span2 as span, sqsTraceAttributes, traceRequest, traceSqsRecord, traceparentOf2 as traceparentOf, wrapFetchHandler, wrapLambdaHandler, wrapSqsHandler };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@sypnia/telemetry",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.4.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,10 +78,6 @@
|
|
|
78
78
|
"engines": {
|
|
79
79
|
"node": ">=20"
|
|
80
80
|
},
|
|
81
|
-
"scripts": {
|
|
82
|
-
"build": "tsup",
|
|
83
|
-
"typecheck": "tsc -p tsconfig.json"
|
|
84
|
-
},
|
|
85
81
|
"dependencies": {
|
|
86
82
|
"rrweb": "2.1.6",
|
|
87
83
|
"rrweb-snapshot": "2.1.6"
|
|
@@ -98,8 +94,12 @@
|
|
|
98
94
|
"access": "public"
|
|
99
95
|
},
|
|
100
96
|
"devDependencies": {
|
|
101
|
-
"@sypnia/shared": "workspace:*",
|
|
102
97
|
"pg": "^8.13.0",
|
|
103
|
-
"@types/pg": "^8.11.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"
|
|
104
104
|
}
|
|
105
|
-
}
|
|
105
|
+
}
|
package/dist/start-MKLQU3SQ.js
DELETED
|
File without changes
|