@extn/segi-js 0.2.14 → 0.2.16
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/README.md +95 -11
- package/dist/cdn.global.js +29 -29
- package/dist/index.d.mts +7 -0
- package/dist/index.d.ts +7 -0
- package/dist/index.js +41 -3
- package/dist/index.mjs +40 -2
- package/dist/replay/index.d.mts +13 -8
- package/dist/replay/index.d.ts +13 -8
- package/dist/replay/index.js +247 -46
- package/dist/replay/index.mjs +226 -25
- package/dist/{rrweb-O2KFXCVA.mjs → rrweb-I4V7NHNY.mjs} +4 -4
- package/dist/{rrweb-VXG3W6SS.js → rrweb-XVHLVZYC.js} +6 -6
- package/package.json +2 -1
package/README.md
CHANGED
|
@@ -16,7 +16,7 @@ pnpm add @extn/segi-js
|
|
|
16
16
|
import Segi from "@extn/segi-js";
|
|
17
17
|
|
|
18
18
|
Segi.init({
|
|
19
|
-
|
|
19
|
+
projectKey: "segi_pk_live_...",
|
|
20
20
|
// optional
|
|
21
21
|
environment: "production",
|
|
22
22
|
release: "1.4.2",
|
|
@@ -25,22 +25,24 @@ Segi.init({
|
|
|
25
25
|
// anywhere
|
|
26
26
|
Segi.captureException(new Error("boom"));
|
|
27
27
|
Segi.captureMessage("checkout finished", { level: "info" });
|
|
28
|
-
Segi.setUser({ id: "user_123", email: "alice@example.com" });
|
|
28
|
+
Segi.setUser({ id: "user_123", email: "alice@example.com" }); // attaches to error events AND the session recording (0.2.14+); Segi.setUser(null) on logout
|
|
29
29
|
Segi.addBreadcrumb({ type: "click", message: "checkout button", timestamp: new Date().toISOString() });
|
|
30
30
|
```
|
|
31
31
|
|
|
32
|
-
`Segi.init()`
|
|
32
|
+
`Segi.init()` uses the first configuration. To add replay, merge it into the existing initializer; a second call does not enable replay.
|
|
33
33
|
|
|
34
|
-
|
|
34
|
+
`Segi.setUser({ id })` (0.2.14+) attributes both pipelines with one call: error events and the active session recording share the same system user id, so the dashboard can filter and cross-link them per user. Pass the id as a string (`String(user.id)` — numbers and GUIDs are fine; matching is exact). Calls made before the recorder finishes activating are buffered and applied automatically.
|
|
35
35
|
|
|
36
|
-
|
|
36
|
+
## Session recording
|
|
37
|
+
|
|
38
|
+
A separate, tree-shakeable replay module ships alongside the error SDK — importing only `Segi` won't pull rrweb. Opt in per app, gated by your plan's recording quota (Free 30 / Team 100 / Enterprise ∞ per organization per month (KST)).
|
|
37
39
|
|
|
38
40
|
```ts
|
|
39
41
|
import Segi from "@extn/segi-js";
|
|
40
42
|
import { withReplay } from "@extn/segi-js/replay";
|
|
41
43
|
|
|
42
44
|
Segi.init({
|
|
43
|
-
|
|
45
|
+
projectKey: "segi_pk_live_...",
|
|
44
46
|
replay: withReplay({
|
|
45
47
|
enabled: true,
|
|
46
48
|
sample: 100, // 0–100 probabilistic gate
|
|
@@ -49,21 +51,97 @@ Segi.init({
|
|
|
49
51
|
}),
|
|
50
52
|
});
|
|
51
53
|
|
|
52
|
-
|
|
53
|
-
Segi.replay.
|
|
54
|
+
// Optional, in your sensitive-flow handlers:
|
|
55
|
+
// Segi.replay.pause();
|
|
56
|
+
// Segi.replay.resume();
|
|
54
57
|
```
|
|
55
58
|
|
|
56
|
-
|
|
59
|
+
An OWNER or ADMIN enables recording in the dashboard. Input mask modes:
|
|
60
|
+
`all` (default: all inputs), `sensitive` (password/email/tel/number), `none`
|
|
61
|
+
(password only). Use `segi-mask` to exclude DOM regions and SDK `blockRoutes`
|
|
62
|
+
for path prefixes; the console deny-list additionally requires segi-js 0.2.16 / segi-nextjs 0.2.11 and the updated server. The recorder pauses after 3 minutes idle.
|
|
57
63
|
|
|
58
64
|
## CDN
|
|
59
65
|
|
|
60
66
|
Drop a `<script>` tag and skip the bundler:
|
|
61
67
|
|
|
62
68
|
```html
|
|
63
|
-
<script src="https://cdn.extn.ai/segi/segi.min.js"></script>
|
|
64
69
|
<script>
|
|
65
|
-
|
|
70
|
+
window.SegiConfig = { projectKey: "segi_pk_live_..." };
|
|
66
71
|
</script>
|
|
72
|
+
<script src="https://cdn.extn.ai/segi/segi.min.js" async></script>
|
|
73
|
+
```
|
|
74
|
+
|
|
75
|
+
The CDN bundle is error-only; use npm for replay.
|
|
76
|
+
|
|
77
|
+
|
|
78
|
+
## Options and SDK support
|
|
79
|
+
|
|
80
|
+
| Option | Default / usage | Support |
|
|
81
|
+
| --- | --- | --- |
|
|
82
|
+
| projectKey | Required project public key | Browser, Next.js server, NestJS |
|
|
83
|
+
| environment | Optional label, e.g. development or production | All three |
|
|
84
|
+
| release | Optional application version or commit ID | All three |
|
|
85
|
+
| beforeSend | Synchronous event transform; return null to drop | Browser only |
|
|
86
|
+
| maxBreadcrumbs | 50; use a nonnegative integer, 0 retains none | Browser only |
|
|
87
|
+
|
|
88
|
+
Next.js server and NestJS accept the shared option type, but do not execute
|
|
89
|
+
beforeSend or retain breadcrumbs. Filter and sanitize data before calling
|
|
90
|
+
server capture functions. beforeSend does not mask DOM recordings.
|
|
91
|
+
|
|
92
|
+
Browser captureException/captureMessage accept event context overrides such
|
|
93
|
+
as level, tags, extra and user. Server captureException/captureMessage accept
|
|
94
|
+
extra data as their second argument; it does not override event fields.
|
|
95
|
+
Server captureMessage uses info. Use named imports on Next.js server and an
|
|
96
|
+
injected SegiService on NestJS; setUser/setTag/addBreadcrumb are browser APIs.
|
|
97
|
+
|
|
98
|
+
```ts
|
|
99
|
+
// Browser: include maxBreadcrumbs in your single initialization.
|
|
100
|
+
Segi.init({ projectKey: "segi_pk_live_xxxxx", maxBreadcrumbs: 30 });
|
|
101
|
+
Segi.addBreadcrumb({ type: "navigation", message: "Checkout opened",
|
|
102
|
+
timestamp: new Date().toISOString() });
|
|
103
|
+
Segi.setUser({ id: String(user.id) }); // after login
|
|
104
|
+
Segi.setUser(null); // after logout
|
|
105
|
+
```
|
|
106
|
+
|
|
107
|
+
## Recording option reference
|
|
108
|
+
|
|
109
|
+
| Option | Default / behavior |
|
|
110
|
+
| --- | --- |
|
|
111
|
+
| enabled | withReplay only; true by default. false skips replay activation, not errors. Project recording must also be enabled by OWNER/ADMIN. |
|
|
112
|
+
| sample | 100; probability from 0 to 100 percent. 20 selects approximately 20%. Initialization rolls again, including reloads; this is not error sampling. |
|
|
113
|
+
| blockRoutes | Empty array; pathname prefix match. /auth also matches /author. Configure before sensitive routes. |
|
|
114
|
+
| mask.inputs | all by default; sensitive masks password/email/tel/number; none still masks passwords. |
|
|
115
|
+
| mask.class | segi-mask; blocks the matching DOM region and descendants. |
|
|
116
|
+
| user | Next.js provider: { id, email? }; null clears identity; undefined leaves manual Segi.setUser management unchanged. |
|
|
117
|
+
|
|
118
|
+
SegiReplayProvider does not expose beforeSend/maxBreadcrumbs props. Use a
|
|
119
|
+
single Segi.init with withReplay if you need these browser options and replay.
|
|
120
|
+
SegiReplayProvider applies configuration at initial mount. Changes to user
|
|
121
|
+
are synchronized, but changing other props does not reinitialize the SDK.
|
|
122
|
+
|
|
123
|
+
```ts
|
|
124
|
+
// Add these options to the existing withReplay call, not another initializer.
|
|
125
|
+
replay: withReplay({ sample: 20, blockRoutes: ["/auth", "/account/payment"],
|
|
126
|
+
mask: { inputs: "all", class: "segi-mask" } })
|
|
127
|
+
|
|
128
|
+
Segi.replay.pause();
|
|
129
|
+
Segi.replay.resume();
|
|
130
|
+
Segi.replay.event("checkout_started", { itemCount: 2 });
|
|
131
|
+
Segi.replay.notifyRouteChange(); // after non-Next.js SPA navigation
|
|
132
|
+
```
|
|
133
|
+
|
|
134
|
+
pause/resume control DOM recording, not all error capture, and do not delete
|
|
135
|
+
previously collected data. Use blockRoutes for persistent route exclusions.
|
|
136
|
+
Custom event names are limited to 64 characters; meta must not contain passwords
|
|
137
|
+
or payment details. Events send only while replay is active and unpaused.
|
|
138
|
+
The Next.js provider reports pathname changes automatically. Other SPAs must
|
|
139
|
+
notify the SDK after the URL changes for page tracking and exclusions.
|
|
140
|
+
Starting on a blocked route defers replay. After rendering an allowed SPA page, notifyRouteChange starts it. Manual pause persists across navigation.
|
|
141
|
+
|
|
142
|
+
```tsx
|
|
143
|
+
<SegiReplayProvider publicKey={process.env.NEXT_PUBLIC_SEGI_PROJECT_KEY!}
|
|
144
|
+
user={user ? { id: String(user.id) } : null} />
|
|
67
145
|
```
|
|
68
146
|
|
|
69
147
|
## Docs
|
|
@@ -76,3 +154,9 @@ Full integration guide: <https://segi.extn.ai/docs>
|
|
|
76
154
|
Copyright (c) 2026 Extension Co., Ltd. All rights reserved. Use of this package
|
|
77
155
|
is governed by the LICENSE file in this package and the segi service Terms of
|
|
78
156
|
Service at https://segi.extn.ai/tnc — it is **not** open source.
|
|
157
|
+
|
|
158
|
+
## Console exclusion policy compatibility
|
|
159
|
+
|
|
160
|
+
The source versions introducing console path exclusions are segi-js 0.2.16 and segi-nextjs 0.2.11; this does not certify npm publication. Deploy the updated server before upgrading the SDK. The SDK reads policy before collection, retries failures every 30 seconds, and records nothing until a valid response arrives. Error monitoring is independent.
|
|
161
|
+
|
|
162
|
+
Console paths and SDK blockRoutes are combined. Policy changes take effect on the next full page load, not immediately in open tabs. Prefix matching is case-sensitive: /auth also matches /author. Saved data is not deleted. On SPA navigation, change the URL before rendering excluded DOM; after rendering an allowed page call notifyRouteChange (automatic in the Next.js Provider). For routers rendering sensitive content before updating the URL, pause before transition or mask the content. Saving settings does not confirm SDK adoption.
|