@uplifto/sdk
v0.8.0
Published
Typed npm loader for integrating Uplifto into Single Page Applications (React, Vue, Next.js, Nuxt). The package provides a thin `init()` wrapper and TypeScript-typed event constants. All SDK business logic loads from the Uplifto server at runtime.
Readme
@uplifto/sdk
Typed npm loader for integrating Uplifto into Single Page Applications (React, Vue, Next.js, Nuxt). The package provides a thin init() wrapper and TypeScript-typed event constants. All SDK business logic loads from the Uplifto server at runtime.
Installation
npm install @uplifto/sdkQuick Start
import { init, Events } from '@uplifto/sdk';
// Initialize — call once at app startup
const uplifto = init({ token: 'YOUR_PROJECT_TOKEN' });
// Track conversion events (typed autocomplete)
uplifto.track(Events.DEPOSIT, { amount: 100, currency: 'USD', method: 'card' });
uplifto.track(Events.REGISTRATION, { method: 'email' });
uplifto.track(Events.GAME_START, { gameId: 'sweet-bonanza', provider: 'super-provider' });Versioning — npm vs browser
The SDK reports a sdkVersion field with every error event. The value depends on how the SDK was loaded:
- npm consumers (this package —
@uplifto/sdk):sdkVersionequals theversionfrompackage.json(e.g."0.6.0"). This bumps only on npm publish, so it matches exactly the version the operator installed. - Browser / CDN consumers (snippet loader and main
sdk.jsbundle served from our CDN):sdkVersionhas the form"<browserVersion>+<gitShortSha>", e.g."0.6.42+abc1234". ThebrowserVersioncounter lives insdk-version.jsonand is incremented by CI on every browser-bundle build (scripts/bump-browser-version.mjs); the build SHA is stamped via theSDK_BUILD_SHAenv var (orgit rev-parse --short HEADfallback).
Why two formats: package.json only bumps on npm publish, but the CDN bundle redeploys on every backend release. Without the separate counter, every snippet error would land under the same pkg.version in NR Errors Inbox and regression triage after a CDN deploy would be impossible. The composite +<sha> follows the SemVer 2.0.0 build metadata convention — the field still validates as semver against the public /v1/errors payload schema.
