@extn/segi-js 0.2.13 → 0.2.15

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 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
- publicKey: "segi_pk_live_...",
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()` is idempotent — calling it twice on the same bundle is a no-op. Pass `{ force: true }` to replace the running config.
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
- ## Session recording (planned)
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
- 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 10 / Team 30 / Enterprise ∞ per project per month).
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
- publicKey: "segi_pk_live_...",
45
+ projectKey: "segi_pk_live_...",
44
46
  replay: withReplay({
45
47
  enabled: true,
46
48
  sample: 100, // 0–100 probabilistic gate
@@ -49,23 +51,58 @@ Segi.init({
49
51
  }),
50
52
  });
51
53
 
52
- Segi.replay.pause(); // e.g. during a sensitive flow
53
- Segi.replay.resume();
54
+ // Optional, in your sensitive-flow handlers:
55
+ // Segi.replay.pause();
56
+ // Segi.replay.resume();
54
57
  ```
55
58
 
56
- Default protections (cannot be turned off from the SDK): rrweb input masking for password/email/tel/number/text inputs, 3-minute idle pause, project-level deny-list editable from the segi dashboard. Full design: [docs/12-session-recording.md](https://github.com/extension-co/segi/blob/main/docs/12-session-recording.md).
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 dashboard deny-list is not currently enforced by the
63
+ recorder. The recorder pauses after 3 minutes idle.
57
64
 
58
65
  ## CDN
59
66
 
60
67
  Drop a `<script>` tag and skip the bundler:
61
68
 
62
69
  ```html
63
- <script src="https://cdn.extn.ai/segi/segi.min.js"></script>
64
70
  <script>
65
- Segi.init({ publicKey: "segi_pk_live_..." });
71
+ window.SegiConfig = { projectKey: "segi_pk_live_..." };
66
72
  </script>
73
+ <script src="https://cdn.extn.ai/segi/segi.min.js" async></script>
67
74
  ```
68
75
 
76
+ The CDN bundle is error-only; use npm for replay.
77
+
78
+ ## Local development / self-hosting
79
+
80
+ Use a project key created in the local console at http://localhost:9802.
81
+ In the consuming Next.js app's `.env.local` (for NestJS, load the server
82
+ variables through your app's environment/configuration):
83
+
84
+ ```dotenv
85
+ SEGI_PROJECT_KEY=segi_pk_live_LOCAL_PROJECT_KEY
86
+ NEXT_PUBLIC_SEGI_PROJECT_KEY=segi_pk_live_LOCAL_PROJECT_KEY
87
+ SEGI_ENDPOINT=http://localhost:9801/api/ingest/events
88
+ NEXT_PUBLIC_SEGI_ENDPOINT=http://localhost:9801/api/ingest/events
89
+ ```
90
+
91
+ The examples explicitly map these variables to SDK options. The SDK does NOT
92
+ automatically read SEGI_ENDPOINT. Server SDKs require the full ingest URL;
93
+ browser SDKs accept this URL too. Without endpoint, requests go to hosted
94
+ segi. `environment: "development"` is only an event label, not backend selection.
95
+ For Vite/plain browser setup, pass the local URL directly as `endpoint` or
96
+ read it using your bundler's env API. Restart the consuming app after env changes.
97
+ Allow its browser Origin on the key when domain restrictions are configured.
98
+ On another device use the segi host's LAN address instead of localhost.
99
+
100
+ Run segi MySQL and Redis, the API in dev mode, and the admin console.
101
+ Dev-mode replay files use `<segi-repo>/data/replay` (override with
102
+ `SEGI_REPLAY_LOCAL_DIR`); metadata still uses MySQL and jobs use Redis.
103
+ Enable `SEGI_EXTRACT_ENABLED=true` on the API for session summaries.
104
+ Confirm requests target localhost:9801 in browser developer tools.
105
+
69
106
  ## Docs
70
107
 
71
108
  Full integration guide: <https://segi.extn.ai/docs>