1. Home
  2. Docs
  3. Modeling your data
  4. Analytics SDKs
  5. Analytics SDK – JavaScript

Analytics SDK – JavaScript

Overview

The Snowplow JavaScript and TypeScript Analytics SDK lets you work with Snowplow enriched events in your JavaScript event processing, data modeling and machine-learning jobs. You can use this SDK with AWS Lambda, Google Cloud Functions, Google App Engine and other JavaScript-compatible frameworks.

Setup

Install using your preferred package manager, such as npm:

npm install --save snowplow-analytics-sdk

Usage

Overview

The Snowplow JavaScript and TypeScript Analytics SDK provides you an API to parse an enriched event from it’s TSV-string form to a JSON string.

Example

To consume in an AWS lambda you would do something like this in your app.js:

const { transform } = require('snowplow-analytics-sdk'); module.exports.handler = (input) => { let event = transform( new Buffer(input.Records[0].kinesis.data, 'base64').toString('utf8'), ); // ... };
Code language: JavaScript (javascript)

Or in app.ts:

import { transform } from 'snowplow-analytics-sdk'; export function handler(input: any) { let event = transform( new Buffer(input.Records[0].kinesis.data, 'base64').toString('utf8'), ); // ... }
Code language: TypeScript (typescript)

API

transform(event: string): Event

  • event: string – TSV string containing event data.

Returns decoded Snowplow enriched event.

If you’d like to learn more about Snowplow BDP you can book a demo with our team, or if you’d prefer, you can try Snowplow technology for yourself quickly and easily.