Coder Social home page Coder Social logo

aharshac / collaborizm_mixpanel_iot Goto Github PK

View Code? Open in Web Editor NEW
2.0 2.0 0.0 417 KB

A project on Collaborizm to download and use Mixpanel Event data on IoT devices.

Home Page: https://www.collaborizm.com/

License: GNU General Public License v3.0

Arduino 48.89% JavaScript 50.31% Shell 0.80%

collaborizm_mixpanel_iot's Introduction

Collaborizm Mixpanel IoT Project

A project on Collaborizm to download and use Mixpanel Event data on IoT devices.

 

Supported devices

  • Arduino UNO: Client. README
  • Arduino Mega 2560: Client (ongoing)
  • NodeMCU DEVKIT V3: Client README
  • PC or Raspberry Pi: Server README

Until Server is ported to Raspberry Pi, run Node_Server package on PC, with the clients on the same WiFi as the PC.

 

Network Nodes

1. Node.js Server (PC or RPi)

Downloads data from Mixpanel server and saves it in the Local Database at regular intervals.

2. Arduino UNO Client

Sends GET request to Local Server and displays event data on the LCD at regular intervals. Uses WDT to reset when memory decreases.

3. NodeMCU DEVKIT V3 Client

Sends GET request to Local Server and displays event data on the LCD at regular intervals.

The Chinese V3 clones are a bit larger than the regular V2 boards. But one reserved pin is connected to USB +5V and another to GND in these clones.

 

Important Stuff

1. README is meant to be read.

2. Mixpanel Event Schema (Example)

File: Node_Server\mixpanel.js (line 19)
Data sent to Mixpanel by Collaborizm server (and this node, for testing purposes).

Important: Add property timestamp to your Mixpanel event, with the value UNIX timestamp (ms).
Mixpanel REST API does not have required constraints to fetch distinct data. So we need this. PERIOD

mp.track("Reply", {
  city: "Mangalore",
  country: 'India',
  date: moment(Date.now()).format(),	// Human readable date
  timestamp: moment(Date.now()).valueOf()	// (important) unix timestamp in ms
});

3. Local Database Schema

File: Node_Server\db.js (line 43)
How our Local Database stores data imported from Mixpanel.

Important: Do not remove timestamp.
Mixpanel REST API does not have required constraints to fetch distinct data. So whatever you do, just don't touch it. PERIOD

db.eventSchema = new Schema({
  name: {type: String, required: true}, // event name
  city: {type: String, required: true},
  country: {type: String, required: true},
  date: {type: Date, default: moment(Date.now()).format()}, // human readable date, ISO 8601
  timestamp: {type: Number, default: moment(Date.now()).valueOf()}	// (important) unix timestamp in ms
});

4. REST API

1. http://server_ip:8970

REST API Server. Default port is 8970, subject to change.
Watch node console to catch it.

2. /

Status check.

3. /events?

JSON array of all events judged by following parameters.
Parameters:

name: Single or comma separated event names
cols: Single or comma separated projection. Default: "name, city, country, date, timestamp"
from: unix timestamp (ms) start
to: unix timestamp (ms) end
last: latest event only (single), can be combined with above params. Supply with dummy value.

4. /events/arduino

JSON Object containing line data. Directly displayed on Arduino without processing.
Deprecated: Formatted string for Arduino. Hack to get around low memory problems.
Output: The character (ASCII 30) prepended to the JSON string is used to determine the start of content.

�{"0": "<line 0 text>", "1": "<line 1 text>"}    

5. /time

Server time. Used to set time for RTCs in client devices.
Output:

Human readable date and time. Not ISO 8601 time.

collaborizm_mixpanel_iot's People

Contributors

aharshac avatar

Stargazers

 avatar  avatar

Watchers

 avatar  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.