Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

heap-io-nodejs

Package Overview
Dependencies
Maintainers
0
Versions
4
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

heap-io-nodejs

A Node.js client for Heap.io

  • 0.0.4
  • latest
  • Source
  • npm
  • Socket score

Version published
Maintainers
0
Created
Source

Heap.io Node.js SDK

A simple wrapper around the Heap.io API for Node.js. This lets you track server-side events in Heap.io.

Strongly typed with TypeScript.

See API docs here: https://developers.heap.io/reference/server-side-apis-overview

Prerequisites

  • Node.js 20 or later

Installation

npm install heap-io-nodejs

Usage

(async () => {
  // Initialize the Heap client with your App ID
  const heapClient = new HeapClient('YOUR_HEAP_APP_ID');

  // Track an event
  try {
    const trackResponse = await heapClient.track({
    // Recommend getting this from the client: window.heap.identity
      identity: 'user_123',
      event: 'Purchase Completed',
      properties: {
        amount: 99.99,
        currency: 'USD',
      },
      timestamp: Date.now(),
    });
    console.log('Event tracked successfully:', trackResponse.status);
  } catch (error) {
    console.error('Failed to track event:', error);
  }

  // Add user properties
  try {
    const userPropsResponse = await heapClient.addUserProperties({
      identity: 'user_123',
      properties: {
        email: 'user@example.com',
        firstName: 'Jane',
        lastName: 'Doe',
      },
    });
    console.log('User properties added successfully:', userPropsResponse.status);
  } catch (error) {
    console.error('Failed to add user properties:', error);
  }
})();

Constructor Options

  • appId (string): Your Heap.io App ID. Required.
  • logger (Logger): A logger instance if you want to pass your own custom logger. Optional. Default: console.

Keywords

FAQs

Package last updated on 12 Oct 2024

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc