0.1.3 • Published 2 months ago

@sinaptik/pandino-sdk v0.1.3

Weekly downloads
-
License
MIT
Repository
-
Last release
2 months ago

Pandino Node.js SDK

Pandino is an event-based email marketing automation SDK for Node.js applications. This SDK allows you to easily integrate Pandino's features into your Node.js projects.

Installation

To install the Pandino SDK, you can use npm or yarn:

# Using npm
npm install @sinaptik/pandino-sdk

# Using yarn
yarn add @sinaptik/pandino-sdk

Usage

Here's a basic example of how to use the Pandino SDK in your Node.js application:

// Import the PandinoSDK
import { PandinoSDK } from "@sinaptik/pandino-sdk";

// Function to run the example
async function runExample() {
  try {
    // Initialize the SDK
    const sdk = await PandinoSDK.create("your-public-key", { verbose: true });

    // Identify a user
    await sdk.identify("unique-distinct-id");

    // Identify a user with IP address and user_agent from user request on server.
    await sdk.identify("unique-distinct-id", {
      ip_address: "127.0.0.1",
      user_agent:
        "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/121.0.0.0 Safari/537.36",
    });

    // Update user properties
    await sdk.updateUser({
      email: "user@example.com",
      name: "John Doe",
      age: 30,
    });

    // Track an event
    await sdk.track("custom_event", { plan_id: "Plan ID" });

    console.log("Example run successfully");
  } catch (error) {
    console.error("Error running example:", error);
  }
}

// Execute the example
runExample();

Here's an example of using existing session of user based on distinct id:

// Import the PandinoSDK
import { PandinoSDK } from "@sinaptik/pandino-sdk";

// Function to run the example
async function runExample() {
  try {
    // Initialize the SDK
    const sdk = await PandinoSDK.create("your-public-key", { verbose: true });

    // Use existing session of user based on distinct id
    // List last sessions returns last five sessions
    const sessions = await sdk.listLastSessions("unique-distinct-id");
    await sdk.identify("unique-distinct-id", {
      session_id: sessions[0].id, // Use the last session id
    });

    // Update user properties
    await sdk.updateUser({
      email: "user@example.com",
      name: "John Doe",
      age: 30,
    });

    // Track an event
    await sdk.track("custom_event", { plan_id: "Plan ID" });

    console.log("Example run successfully");
  } catch (error) {
    console.error("Error running example:", error);
  }
}

// Execute the example
runExample();

API Reference

PandinoSDK.create(public_key, options)

  • public_key: Your Pandino public API key.
  • options: Optional configuration settings.

identify(distinctId)

Identifies a user with a unique distinct ID.

updateUser(properties)

Updates user properties such as email, name, and other custom attributes.

track(eventName, properties)

Tracks a custom event with specified properties.

License

This project is licensed under the MIT License - see the LICENSE file for details.

0.1.3

2 months ago

0.1.2

2 months ago

0.1.1

2 months ago

0.1.0

2 months ago