All documentation

Web SDK — Install & CDN

Install the browser SDK via CDN, self-host, and verify ingest.

Web SDK — Install, npm & CDN

Load the Naiza browser SDK via script tag from the official Naiza CDN, or bundle it directly from the release asset. Confirm endpoint and auth mode with your deployment (see API Reference → Web SDK).

1. Script tag — Naiza CDN (recommended)

Files are served from sdk.naiza.ai, a dedicated GCS-backed CDN. Pin a specific version for production stability. The latest path always resolves to the most recent release.

<!-- Pinned version (recommended for production) -->
<script
  defer
  src="https://sdk.naiza.ai/v0.9.0/naizawebsdk.umd.js"
  crossorigin="anonymous"
></script>

<!-- Always-latest (suitable for development / staging) -->
<script defer src="https://sdk.naiza.ai/latest/naizawebsdk.umd.js"></script>

Use defer so execution starts after HTML parse. The UMD bundle exposes NaizaWebSdk on window.

<script defer src="https://sdk.naiza.ai/v0.9.0/naizawebsdk.umd.js"></script>
<script>
  async function boot() {
    await NaizaWebSdk.init({
      token: "<MINTED_WEBSDK_JWT>",
      sdkSessionId: "ws_checkout_123",
      endpoint: "https://api.naiza.ai/api/v1/collect",
    });
  }
  if (document.readyState === "loading") {
    document.addEventListener("DOMContentLoaded", boot);
  } else {
    boot();
  }
</script>

Canonical /api/v1/collect uses Authorization: Bearer with a short-lived JWT minted server-side from POST /api/v1/websdk/tokens.

2. Direct download (self-hosted)

Download the bundle from the GitHub Releases page and host it yourself if you need to serve it from your own domain.

# Download a specific release
curl -L https://github.com/limazifyLab/naizaWebSDK/releases/download/v0.9.0/naizawebsdk.umd.js   -o naizawebsdk.umd.js

3. Privacy & sampling

  • consent: false — no network requests are sent (GDPR opt-out). Local collection still runs so data is available if consent is later granted.
  • sampleRate — optional 0–1 fraction to reduce upload volume. Suppressed batches are discarded.
  • Per-collector opt-out via disabledCollectors or collectorConfig.

4. Verify on another origin

  1. Use a staging HTML page or a throwaway static deploy.
  2. Load a pinned CDN URL, open DevTools → Network and confirm POST returns 2xx with Authorization: Bearer.
  3. Toggle consent: false and confirm zero requests to the ingest host.

The SDK repo includes examples/cdn-smoke-test.html for quick end-to-end checks.

5. CDN & versioning

Every tagged release in the naizaWebSDK repository automatically publishes the UMD bundle to sdk.naiza.ai/v{VERSION}/. Versioned URLs are immutable and cached permanently. The latest/ path is updated on every release with a short cache TTL (5 minutes). Check sdk.naiza.ai/manifest.json for available versions.