@sinaptik/pandino-client-sdk
v0.3.4
Published
Pandino SDK for client-side tracking and analytics
Downloads
17
Readme
Pandino SDK
TypeScript/JavaScript SDK for Pandino email marketing automation platform.
Installation
yarn add @sinaptik/pandino-client-sdk
# or
npm install @sinaptik/pandino-client-sdkUsage
import PandinoSDK from "@sinaptik/pandino-client-sdk";
// Initialize with default settings (automatic page view tracking enabled)
pandino = await PandinoClientSDK.create("your-api-key");
// Track an event
pandino.track("page_viewed", { page: "/home" });
// Identify a user
pandino.identify("user123");
// Update user properties
pandino.updateUser({
email: "[email protected]",
name: "John Doe",
plan: "premium",
lastLogin: new Date(),
});
// Reset sdk on logout
pandino.reset();Automatic page view tracking
By default, the SDK automatically tracks page views:
- On initial page load
- On navigation using the History API (pushState, replaceState)
- On page navigation using the browser back/forward buttons
- When client-side routing changes the URL without using History API
Each page view event includes:
{
url: "https://example.com/page", // full URL
path: "/page", // pathname
title: "Page Title", // document title
referrer: "https://google.com", // referrer if available
search: "?query=value", // URL search parameters if any
hash: "#section", // URL hash if any
}To control automatic page view tracking:
// Disable page view tracking
pandino.disablePageViewTracking();
// Re-enable page view tracking
pandino.enablePageViewTracking();API Reference
track(eventName: string, properties?: Record<string, any>)
Track an event for the current user with optional properties.
identify(distinctId: string)
Identify a user with a unique identifier.
updateUser(properties: Record<string, any>)
Update properties for the current user.
disablePageViewTracking()
Disable automatic page view tracking.
enablePageViewTracking()
Enable automatic page view tracking.
reset()
Reset the SDK instance to its initial state. This includes clearing session and identity information and reinitializing page view tracking if it is enabled.
// Reset the SDK instance
pandino.reset();