npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

@extn/segi-js

v0.2.17

Published

Browser JavaScript SDK for the segi error monitoring service

Readme

@extn/segi-js

Browser JavaScript SDK for segi — error monitoring for teams that ship.

Install

pnpm add @extn/segi-js
# or: npm install @extn/segi-js
# or: yarn add @extn/segi-js

Use

import Segi from "@extn/segi-js";

Segi.init({
  projectKey: "segi_pk_live_...",
  // optional
  environment: "production",
  release: "1.4.2",
});

// anywhere
Segi.captureException(new Error("boom"));
Segi.captureMessage("checkout finished", { level: "info" });
Segi.setUser({ id: "user_123", email: "[email protected]" }); // attaches to error events AND the session recording (0.2.14+); Segi.setUser(null) on logout
Segi.addBreadcrumb({ type: "click", message: "checkout button", timestamp: new Date().toISOString() });

Segi.init() uses the first configuration. To add replay, merge it into the existing initializer; a second call does not enable replay.

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.

Session recording

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)).

import Segi from "@extn/segi-js";
import { withReplay } from "@extn/segi-js/replay";

Segi.init({
  projectKey: "segi_pk_live_...",
  replay: withReplay({
    enabled: true,
    sample: 100,                      // 0–100 probabilistic gate
    blockRoutes: ["/checkout", "/auth"],
    mask: { inputs: "all", class: "segi-mask" },
  }),
});

// Optional, in your sensitive-flow handlers:
// Segi.replay.pause();
// Segi.replay.resume();

An OWNER or ADMIN enables recording in the dashboard. Input mask modes: all (default: all inputs), sensitive (password/email/tel/number), none (password only). Use segi-mask to exclude DOM regions and SDK blockRoutes 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.

CDN

Drop a <script> tag and skip the bundler:

<script>
  window.SegiConfig = { projectKey: "segi_pk_live_..." };
</script>
<script src="https://cdn.extn.ai/segi/segi.min.js" async></script>

The CDN bundle is error-only; use npm for replay.

Options and SDK support

| Option | Default / usage | Support | | --- | --- | --- | | projectKey | Required project public key | Browser, Next.js server, NestJS | | environment | Optional label, e.g. development or production | All three | | release | Optional application version or commit ID | All three | | beforeSend | Synchronous event transform; return null to drop | Browser only | | maxBreadcrumbs | 50; use a nonnegative integer, 0 retains none | Browser only |

Next.js server and NestJS accept the shared option type, but do not execute beforeSend or retain breadcrumbs. Filter and sanitize data before calling server capture functions. beforeSend does not mask DOM recordings.

Browser captureException/captureMessage accept event context overrides such as level, tags, extra and user. Server captureException/captureMessage accept extra data as their second argument; it does not override event fields. Server captureMessage uses info. Use named imports on Next.js server and an injected SegiService on NestJS; setUser/setTag/addBreadcrumb are browser APIs.

Browser captureException accepts any value, not only Error instances (v0.2.17+). Strings and numbers become the message; objects with a message (and optional name/code/stack) keep those fields; event-like wrappers ({ error }, { reason }) are unwrapped; plain data is serialised. A value with nothing to report — {}, undefined, null, an empty array — is dropped unless you pass { message } in the context, so a third-party callback handing you an empty object no longer produces an "Error: {}" issue. normalizeError(value) is exported if you want the same conversion in your own code.

// Browser: include maxBreadcrumbs in your single initialization.
Segi.init({ projectKey: "segi_pk_live_xxxxx", maxBreadcrumbs: 30 });
Segi.addBreadcrumb({ type: "navigation", message: "Checkout opened",
  timestamp: new Date().toISOString() });
Segi.setUser({ id: String(user.id) }); // after login
Segi.setUser(null);                  // after logout

Recording option reference

| Option | Default / behavior | | --- | --- | | enabled | withReplay only; true by default. false skips replay activation, not errors. Project recording must also be enabled by OWNER/ADMIN. | | sample | 100; probability from 0 to 100 percent. 20 selects approximately 20%. Initialization rolls again, including reloads; this is not error sampling. | | blockRoutes | Empty array; pathname prefix match. /auth also matches /author. Configure before sensitive routes. | | mask.inputs | all by default; sensitive masks password/email/tel/number; none still masks passwords. | | mask.class | segi-mask; blocks the matching DOM region and descendants. | | user | Next.js provider: { id, email? }; null clears identity; undefined leaves manual Segi.setUser management unchanged. |

SegiReplayProvider does not expose beforeSend/maxBreadcrumbs props. Use a single Segi.init with withReplay if you need these browser options and replay. SegiReplayProvider applies configuration at initial mount. Changes to user are synchronized, but changing other props does not reinitialize the SDK.

// Add these options to the existing withReplay call, not another initializer.
replay: withReplay({ sample: 20, blockRoutes: ["/auth", "/account/payment"],
  mask: { inputs: "all", class: "segi-mask" } })

Segi.replay.pause();
Segi.replay.resume();
Segi.replay.event("checkout_started", { itemCount: 2 });
Segi.replay.notifyRouteChange(); // after non-Next.js SPA navigation

pause/resume control DOM recording, not all error capture, and do not delete previously collected data. Use blockRoutes for persistent route exclusions. Custom event names are limited to 64 characters; meta must not contain passwords or payment details. Events send only while replay is active and unpaused. The Next.js provider reports pathname changes automatically. Other SPAs must notify the SDK after the URL changes for page tracking and exclusions. Starting on a blocked route defers replay. After rendering an allowed SPA page, notifyRouteChange starts it. Manual pause persists across navigation.

<SegiReplayProvider publicKey={process.env.NEXT_PUBLIC_SEGI_PROJECT_KEY!}
  user={user ? { id: String(user.id) } : null} />

Docs

Full integration guide: https://segi.extn.ai/docs

Licence

Copyright (c) 2026 Extension Co., Ltd. All rights reserved. Use of this package is governed by the LICENSE file in this package and the segi service Terms of Service at https://segi.extn.ai/tnc — it is not open source.

Console exclusion policy compatibility

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.

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.