
Research
/Security News
737 Chrome VPN Extensions Linked to Brand Impersonation and Browser Traffic Redirection
The campaign amassed more than 75,000 installs by targeting Russian-speaking users seeking access to blocked services.
@sapiom/analytics-core
Advanced tools
Zero-dependency usage analytics emitter shared by Sapiom SDK packages — consent-aware, batched, and guaranteed to never throw or block the host application.
Zero-dependency usage analytics emitter shared by Sapiom SDK packages.
Sapiom packages use it to send usage events to the Sapiom analytics collector so we can understand real-world usage and improve the SDK. It is designed to be invisible to the host application:
track() is a synchronous enqueue; every
failure inside analytics is silently swallowed.data._truncated).This section is the complete disclosure for the analytics this package can emit. The full wire contract lives in CONTRACT.md.
Each event is a small JSON envelope:
command.run, capability.call)
and a JSON payload describing it.cli, tools, mcp, ...), and a schema version.data.context.Analytics never reads your environment variables, credentials, or files beyond its own identity file described below.
Any of these disables analytics entirely (highest precedence first):
createAnalytics({ ..., disabled: true }) — packages
built on this emitter expose their own equivalent switch in their options.SAPIOM_TELEMETRY_DISABLED=1 in the environment.DO_NOT_TRACK=1 in the environment (the ecosystem-wide convention).When opted out, nothing is sent, nothing is written to disk, zero network calls are made — and no notice is printed.
When analytics is active, the first-ever tracked event on a machine prints a one-line notice to stderr, so collection is never silent.
A single file, ~/.sapiom/analytics.json (permissions 0600), holding a
random anonymous machine id and the first-run-notice marker. It contains no
personal information. Delete it at any time to reset the identity; it is
never created while analytics is disabled or unconfigured.
The emitter has no default endpoint. Unless an endpoint is explicitly
configured — endpoint in the config, or the SAPIOM_ANALYTICS_ENDPOINT
environment variable (used by tests) — createAnalytics returns a no-op
instance: zero network calls, zero disk writes, no first-run notice. The
hosted collector URL is exported as the constant SAPIOM_COLLECTOR_ENDPOINT
for when you (or a future release of this package) want to send there.
import { createAnalytics } from "@sapiom/analytics-core";
const analytics = createAnalytics({
source: "cli",
sdkName: "@sapiom/cli",
sdkVersion: "1.0.0",
// No endpoint → a silent no-op. To actually deliver:
// endpoint: SAPIOM_COLLECTOR_ENDPOINT,
});
analytics.track("command.run", { command: "dev" });
await analytics.flush(); // best-effort send, never rejects
await analytics.shutdown(); // flush + stop timers, never rejects
track(eventType, data?, overrides?) accepts an arbitrary event type, a JSON
payload, and optional per-event envelope overrides (for example
{ user_id: "usr_123" } when a signed-in identity is known).
@sapiom/analytics-core/testing ships an in-process mock collector — a real
HTTP server on a random loopback port with contract-shaped responses and
scriptable failure modes — for use in any package's tests:
import { createAnalytics } from "@sapiom/analytics-core";
import { startMockCollector } from "@sapiom/analytics-core/testing";
const collector = await startMockCollector();
const analytics = createAnalytics({
source: "tools",
sdkName: "@sapiom/tools",
sdkVersion: "1.0.0",
endpoint: collector.url,
});
analytics.track("capability.call", { capability: "search" });
await analytics.flush();
expect(collector.events()).toHaveLength(1);
collector.setMode({ kind: "status", status: 500 }); // or "down", "slow"
// ... assert your instrumentation degrades silently ...
await collector.close();
fixtures/contract/ — machine-readable request
fixtures (valid + invalid) for contract conformance tests, shipped with
the package.MIT
FAQs
Zero-dependency usage analytics emitter shared by Sapiom SDK packages — consent-aware, batched, and guaranteed to never throw or block the host application.
The npm package @sapiom/analytics-core receives a total of 1,987 weekly downloads. As such, @sapiom/analytics-core popularity was classified as popular.
We found that @sapiom/analytics-core demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 3 open source maintainers collaborating on the project.
Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Research
/Security News
The campaign amassed more than 75,000 installs by targeting Russian-speaking users seeking access to blocked services.

Company News
Open source maintainers are under more pressure than ever. We're raising our open source program from the Team plan to the Business plan, free.

Security News
The supply chain control that delays freshly published gems now covers lockfile generation and gem vendoring in Ruby projects.