Skip to main content

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'),
);

// ...
};

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'),
);

// ...
}

APIโ€‹

transform(event: string): Eventโ€‹

  • event: string - TSV string containing event data.

Returns decoded Snowplow enriched event.

Was this page helpful?