Giter VIP home page Giter VIP logo

amplitude-upload's Introduction

About Amplitude Upload

Simple node program that transforms and uploads raw Segment track and identify events to Amplitude's API.

Installation

$ git clone https://github.com/brennan/amplitude-upload
$ cd amplitude-upload
$ npm install

Usage

This program is ready to use out of the box. Open app.js in your text editor to get started:

var Amplitude = require("./index.js");
var amplitude = new Amplitude("YOUR_API_KEY");
var data = require("./events.json");

for (var i = 0; i < data.length; i++) {

  amplitude.send(data[i], function(err, res) {
    if (err) console.log(err);
    else console.log(res);
  });

}

Add your JSON to events.json, then type node app.js in the command line to begin upload. Simply remove the for loop if you only want to send a single event.

Restrictions

Events must be of Segment type track or identify.

Events must include either a userId or deviceId. You don't need to pass both if they aren't needed.

Mapping

Amplitude Property: Segment Property

// common required properties
event.device_id: data.context.device.id
event.user_id: data.context.userId

// common fields
event.app_version: data.context.app.version
event.platform: data.context.device.type
event.os_name: data.context.os.name
event.os_version: data.context.os.version
event.device_brand: data.context.device.manufacturer
event.device_model: data.context.device.model
event.carrier: data.context.network.carrier
event.country: data.context.location.country
event.city: data.context.location.city
event.language: data.context.locale
event.location_lat: data.context.location.latitude
event.time: data.timestamp

// properties unique to identify events
event.user_traits = data.traits;

// properties unique to track events
event.insert_id: data.messageId
event.event_type: data.event
event.user_properties: data.properties
event.price: data.price
event.revenue: data.revenue
event.quantity: data.quantity
event.productId: data.product_id

Testing

Add your Amplitude API key to the test.js file in the test folder:

var amplitude = new Amplitude("YOUR_API_KEY");

Then, run your tests:

npm test

Check out the full test suite in the project test directory.

amplitude-upload's People

Contributors

brennan avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.