@idobit-npm/analytics-sdk
v0.1.0
Published
Lightweight analytics + in-site banner SDK for client websites on the iDoBit back-office platform.
Downloads
80
Readme
@idobit-npm/analytics-sdk
Lightweight, dependency-free analytics + in-site banner SDK for client websites built on the iDoBit back-office platform. Handles event batching, page-view/session tracking, consent, and the banner render/impression/dismiss lifecycle.
Published to public npm for zero-friction install on any client site. The package is publishable-grade, not secret — it needs an org id + public API key to do anything and can only write analytics events + read active banners. Do not put any admin/Stytch credential near it. Source is proprietary (UNLICENSED).
Install
npm add @idobit-npm/analytics-sdk # or pnpm add / yarn addUsage
import { init, track, page, setConsent, showBanners } from "@idobit-npm/analytics-sdk";
init({
organizationId: "organization-...",
apiKey: "pk_...", // publishable-grade
ingestUrl: "https://your-api.example.com/v1/ingest/events",
// bannersUrl auto-derives → .../v1/notifications/banners
});
setConsent(true); // after cookie consent
track("cta_click", { placement: "hero" });
page("/pricing");
await showBanners(); // turnkey banner render + trackingIn a Next.js app, boot it from a 'use client' provider and pass the key down as a prop from a
Server Component (never read a server-only env var in client code). See the client-website-starter's
AnalyticsProvider for the reference wiring.
Exports
init, track, page, setConsent, flush, fetchBanners, showBanners,
trackBannerImpression, trackBannerDismiss, trackProductClick.
Build
Dual CJS/ESM via tsup (dist/index.js = CJS, dist/index.mjs = ESM, .d.ts/.d.mts types).
npm run build # tsup
npm run typecheckReleasing
Versioned + published with Changesets. Record a change:
npx changeset # pick patch/minor/major + summary; commit the generated fileOn merge to master, CI opens a "version packages" PR; merging it publishes to npm. See
.changeset/README.md.
