SDKs overview

Postmon provides a suite of Software Development Kits (SDKs) designed to facilitate the integration of its real-time analytics and tracking capabilities into various applications and platforms. These SDKs abstract the complexities of direct API interaction, offering language-specific methods for event tracking, user identification, and property management. The primary goal of the Postmon SDKs is to enable developers to capture user behavior data efficiently and accurately, which can then be visualized and analyzed within the Postmon platform for insights into product usage, conversion funnels, and A/B testing outcomes.

The SDKs support both client-side and server-side implementations, allowing for data collection from web browsers, mobile applications, and backend systems. Each SDK is maintained to ensure compatibility with the Postmon API and to provide a consistent developer experience across different programming environments. Detailed documentation for each SDK is available on the Postmon developer documentation portal, outlining installation procedures, configuration options, and usage examples for common tracking scenarios.

Beyond official offerings, a community of developers contributes to expanding the ecosystem with additional libraries and integrations, often addressing niche use cases or specific framework requirements. These community-driven efforts supplement the official SDKs, providing alternative approaches or specialized functionality that can further enhance a developer's ability to integrate Postmon into their tech stack.

Official SDKs by language

Postmon offers official SDKs for a range of popular programming languages, ensuring broad compatibility for various development environments. These SDKs are developed and maintained by Postmon to provide stable and feature-rich integrations. Each SDK is designed to align with the conventions of its respective language, offering an idiomatic way to interact with the Postmon API.

The following table outlines the official SDKs, including their typical package names, installation commands, and maturity status:

Language Package Name Install Command Maturity
JavaScript @postmon/web-sdk npm install @postmon/web-sdk or yarn add @postmon/web-sdk Stable
Python postmon-python pip install postmon-python Stable
Node.js @postmon/node-sdk npm install @postmon/node-sdk or yarn add @postmon/node-sdk Stable
Ruby postmon-ruby Add gem 'postmon-ruby' to Gemfile then bundle install Stable
PHP postmon/php-sdk composer require postmon/php-sdk Stable
Go github.com/postmon/go-sdk go get github.com/postmon/go-sdk Stable
Java com.postmon:java-sdk Add to pom.xml (Maven) or build.gradle (Gradle) Stable
.NET Postmon.NET.SDK dotnet add package Postmon.NET.SDK Stable

For detailed API specifics and advanced configurations, refer to the Postmon API reference documentation.

Installation

Installation of Postmon SDKs typically involves using the standard package manager for each respective language or platform. The process is designed to be straightforward, allowing developers to quickly integrate Postmon's tracking capabilities into their projects.

JavaScript (Web)

For web applications, the JavaScript SDK can be installed via npm or yarn. Alternatively, it can be included directly using a CDN.

Using npm/yarn:

npm install @postmon/web-sdk
# or
yarn add @postmon/web-sdk

Using a CDN:

<script src="https://cdn.postmon.com/sdk/web/latest/postmon.min.js"></script>

Python

The Python SDK is installed using pip, Python's package installer.

pip install postmon-python

Node.js (Server-side)

For server-side Node.js applications, the SDK is installed via npm or yarn.

npm install @postmon/node-sdk
# or
yarn add @postmon/node-sdk

Ruby

Ruby projects typically manage dependencies using Bundler. Add the gem to your Gemfile and run bundle install.

# Gemfile
gem 'postmon-ruby'
bundle install

PHP

The PHP SDK is installed using Composer, the dependency manager for PHP.

composer require postmon/php-sdk

Go

Go modules are used to manage dependencies. The SDK can be fetched using the go get command.

go get github.com/postmon/go-sdk

Java

For Java projects, the SDK is typically added as a dependency in your build tool, such as Maven or Gradle. Consult the Postmon Java SDK setup guide for specific instructions.

.NET

The .NET SDK is installed via the NuGet package manager, commonly through the dotnet add package command.

dotnet add package Postmon.NET.SDK

Quickstart example

The following examples demonstrate basic initialization and event tracking using the Postmon SDKs for JavaScript, Python, and Node.js. These snippets illustrate the fundamental steps required to start sending data to Postmon.

JavaScript (Web)

This example shows how to initialize the Postmon web SDK and track a page view and a custom event.

import Postmon from '@postmon/web-sdk';

Postmon.init('YOUR_PROJECT_TOKEN', {
  apiHost: 'https://api.postmon.com',
  debug: true,
});

// Identify a user
Postmon.identify('user123', {
  email: '[email protected]',
  plan: 'premium',
});

// Track a page view
Postmon.track('Page Viewed', {
  page_name: 'Homepage',
  url: window.location.href,
});

// Track a custom event
document.getElementById('signup-button').addEventListener('click', () => {
  Postmon.track('Sign Up Clicked', {
    button_text: 'Create Account',
  });
});

Python

This Python example demonstrates initializing the SDK and tracking a server-side event.

import postmon

# Initialize Postmon with your project token and API host
postmon.init('YOUR_PROJECT_TOKEN', api_host='https://api.postmon.com')

# Identify a user
postmon.identify('user456', {
    'name': 'Jane Doe',
    'account_type': 'free'
})

# Track a server-side event
postmon.track('Order Placed', 'user456', {
    'product_id': 'PROD-001',
    'amount': 99.99,
    'currency': 'USD'
})

# Flush events (important for server-side applications)
postmon.shutdown()

Node.js (Server-side)

A Node.js example for initializing the SDK and tracking an event from a backend service.

import Postmon from '@postmon/node-sdk';

const postmon = new Postmon.Client('YOUR_PROJECT_TOKEN', {
  apiHost: 'https://api.postmon.com',
});

// Identify a user
postmon.identify('user789', {
  username: 'dev_user',
  role: 'admin',
});

// Track a server-side event
postmon.track({
  event: 'API Call Made',
  distinctId: 'user789',
  properties: {
    endpoint: '/users/create',
    status_code: 200,
  },
});

// Flush events and close client (important for server-side applications)
postmon.shutdown(() => {
  console.log('Postmon client shut down.');
});

For specific API keys and detailed instructions on obtaining your project token, refer to your Postmon project settings documentation.

Community libraries

While Postmon provides official SDKs, the developer community often extends functionality or creates integrations for specific frameworks and use cases. These community-contributed libraries can offer additional features, simplify integration with certain ecosystems, or provide alternative approaches to data collection.

Examples of areas where community libraries might emerge include:

  • Framework-specific wrappers: Libraries that integrate Postmon tracking seamlessly with popular frameworks like React, Angular, Vue.js, Django, or Ruby on Rails. For instance, a React component that automatically tracks component lifecycle events.
  • Data transformation utilities: Tools to preprocess or normalize data before sending it to Postmon, ensuring consistency and adherence to specific schemas.
  • Offline tracking enhancements: Libraries that manage event queuing and persistence for scenarios where real-time network access is not guaranteed, similar to how some Cloudflare Analytics implementations handle offline data.
  • Integration with third-party services: Connectors that bridge Postmon data with other analytics tools, CRM systems, or marketing platforms not officially supported by direct integrations.

Developers interested in exploring community-contributed resources are encouraged to check platforms like GitHub, npm, or language-specific package repositories (e.g., PyPI for Python, RubyGems for Ruby) for projects tagged with "Postmon" or related keywords. While community libraries can be valuable, it's important to review their maintenance status, documentation, and community support before relying on them in production environments. The Postmon community resources page often lists notable third-party integrations.