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

@seinetime/seinetime-sdk

v0.0.5

Published

> SDK: `@seinetime/seinetime-sdk` > Purpose: Send analytics data from web apps to **seinetime Customer Insight Platform (AIP)**.

Downloads

15

Readme

seinetime Analytics Browser — Developer Guide

SDK: @seinetime/seinetime-sdk
Purpose: Send analytics data from web apps to seinetime Customer Insight Platform (AIP).


Table of Contents


Overview

seinetime Analytics Browser is a lightweight JavaScript SDK to instrument your website or SPA and forward events to AIP.
You can integrate it in two ways:

  1. AIP Portal snippet – easiest, managed and auto-updated script.
  2. NPM package – import it into your build and control initialization explicitly.

Quickstart

Using via AIP Portal (recommended)

  1. Sign in to AIP Portal and create an Integration (Source).
  2. Use Browser Standalone snippet and paste it before </head> on your site.
  3. Start tracking with window.analytics.

Using as an NPM Package

# npm
npm install @seinetime/seinetime-sdk

# yarn
yarn add @seinetime/seinetime-sdk

# pnpm
pnpm add @seinetime/seinetime-sdk
import { SeineTimeSDK } from '@seinetime/seinetime-sdk'

// Boot the SDK and identify the current user
const analytics = SeineTimeSDK.load(
  { secretKey: '<YOUR_SECRET_KEY>' },
  {
    attributeType: 'email',          // e.g., "email" | "phone" | "userId"
    attributeValue: '[email protected]', // actual user identifier value
  }
)

// Send events
analytics.track('App Started')
analytics.identify('User Logged In')

// Attach to UI interactions
document.body?.addEventListener('click', () => {
  analytics.track('document body clicked!')
})

Browser Standalone Usage (Script Snippet)

Below is a template showing where to put the snippet and how to use it. Here is a complete snippet integration for HTML environments, including stub methods and async loading of the SDK:

<!doctype html>
<html>
  <head></head>
  <body>
    <script>
      window.addEventListener('load', () => {
        window.analyticsSecretKey = 'test'
        console.log(AnalyticsNext)
      })
    </script>

    <script type="text/javascript">
      (function() {
        var globalAnalyticsKey = "analytics";
        var analytics = window[globalAnalyticsKey] = window[globalAnalyticsKey] || [];

        if (analytics.initialize) return;
        if (analytics.invoked) {
          if (window.console && console.error) {
            console.error("Segment snippet included twice.");
          }
          return;
        }

        analytics.invoked = true;
        analytics.methods = [
          "trackSubmit","trackClick","trackLink","trackForm","pageview",
          "identify","reset","group","track","ready","alias","debug","page",
          "screen","once","off","on","addSourceMiddleware",
          "addIntegrationMiddleware","setAnonymousId","addDestinationMiddleware","register"
        ];

        analytics.factory = function(e) {
          return function() {
            if (window[globalAnalyticsKey].initialized) {
              return window[globalAnalyticsKey][e].apply(window[globalAnalyticsKey], arguments);
            }
            var args = Array.prototype.slice.call(arguments);
            if (["track","screen","alias","group","page","identify"].indexOf(e) > -1) {
              var c = document.querySelector("link[rel='canonical']");
              args.push({
                __t: "bpc",
                c: c && c.getAttribute("href") || undefined,
                p: location.pathname,
                u: location.href,
                s: location.search,
                t: document.title,
                r: document.referrer
              });
            }
            args.unshift(e);
            analytics.push(args);
            return analytics;
          };
        };

        for (var i = 0; i < analytics.methods.length; i++) {
          var key = analytics.methods[i];
          analytics[key] = analytics.factory(key);
        }

        analytics.load = function(key, options) {
          var t = document.createElement("script");
          t.type = "text/javascript";
          t.async = true;
          t.setAttribute("data-global-segment-analytics-key", globalAnalyticsKey);
          t.src = "https://cdn.jsdelivr.net/gh/QuanNguyen2908/seinetime-sdk@main/standalone.js"; // Replace with actual path or CDN
          var first = document.getElementsByTagName("script")[0];
          first.parentNode.insertBefore(t, first);
          analytics._loadOptions = options;
        };

        analytics._secretKey = "YOUR_WRITE_KEY";
        analytics.SNIPPET_VERSION = "5.2.1";

        analytics.load({ secretKey: "YOUR_WRITE_KEY" },
        { 
          attributeType: "attributeType",
          attributeValue: "attributeValue"
        });
        analytics.page();
      })();
    </script>
  </body>
</html>

Notes

  • This snippet queues API calls until the SDK is fully loaded.
  • Replace "YOUR_WRITE_KEY" with your actual secret/write key from AIP Portal.
  • Ensure the https://cdn.jsdelivr.net/gh/QuanNguyen2908/seinetime-sdk@main/standalone.js file is accessible (via CDN or hosted locally).
  • secretKey (string, required): Your AIP Source key. Keep it safe.
  • attributeType (string, optional): The identity attribute type (e.g., email, userId, phone).
  • attributeValue (string, optional): The identity value for the current user.
  • Start tracking with window.analytics.

API Reference

SeineTimeSDK.load

Bootstraps the SDK and fetches destinations. Should be called once.

SeineTimeSDK.load(
  { secretKey: string },
  { attributeType?: string, attributeValue?: string }
): AnalyticsBrowserInstance

Parameters

  • secretKey (string, required): Your AIP Source key. Keep it safe.
  • attributeType (string, optional): The identity attribute type (e.g., email, userId, phone).
  • attributeValue (string, optional): The identity value for the current user.

identify

Associate the current session with a known user.

analytics.identify(
  eventName?: string,   // optional — semantic label, e.g., 'User Logged In'
  properties?: object,  // optional — custom traits (e.g., plan, role, teamId)
  options?: object      // optional — extra options (e.g., region)
)

track

Record a behavioral event.

analytics.track(
  eventName: string,    // required — e.g., 'Product Viewed'
  properties?: object,  // optional — context, e.g., { sku: 'A-123', price: 19.99 }
  options?: object      // optional — extra options
)

delivery

Send a delivery/attribution style event.

analytics.delivery(
  code: string,
  secretKey: string,
  options?: object
)

Lazy / Delayed Loading & Consent

import { SeineTimeSDK } from '@seinetime/seinetime-sdk'

export const analytics = new SeineTimeSDK()

analytics.identify('Preload Identify', { stage: 'pre-consent' })

analytics.load(
  { secretKey: '<YOUR_SECRET_KEY>' },
  { attributeType: 'email', attributeValue: '[email protected]' }
)

Error Handling

const analytics = new SeineTimeSDK()
analytics
  .load(
    { secretKey: 'YOUR_SECRET_KEY' },
    { attributeType: 'email', attributeValue: '[email protected]' }
  )
  .catch((err) => {
    console.error('Analytics init failed:', err)
  })

Examples with Frameworks

React

import { SeineTimeSDK } from '@seinetime/seinetime-sdk'

export const analytics = SeineTimeSDK.load(
  { secretKey: '<YOUR_SECRET_KEY>' },
  { attributeType: 'email', attributeValue: '[email protected]' }
)

export default function App() {
  return (
    <div>
      <button onClick={() => analytics.track('hello world')}>
        Track
      </button>
    </div>
  )
}

Vue

// services/analytics.ts
import { SeineTimeSDK } from '@seinetime/seinetime-sdk'

export const analytics = SeineTimeSDK.load(
  { secretKey: '<YOUR_SECRET_KEY>' },
  { attributeType: 'email', attributeValue: '[email protected]' }
)
<!-- App.vue -->
<template>
  <button @click="track">Track</button>
</template>

<script setup lang="ts">
import { analytics } from './services/analytics'

function track() {
  analytics.track('Hello world', { page: 'home' })
}
</script>

TypeScript Support (for snippet users)

import type { AnalyticsSnippet } from '@seinetime/seinetime-sdk'

declare global {
  interface Window {
    analytics: AnalyticsSnippet
  }
}

Best Practices

  • Consistent Event Names
  • Stable Identities
  • Minimize PII
  • Consent First
  • Enrich Gracefully

Troubleshooting

  • Nothing appears in AIP → Check key and network.
  • window.analytics undefined → Ensure snippet loaded before use.
  • Duplicate events → Ensure .load() is called once.

© seinetime — @seinetime/seinetime-sdk