A project on Collaborizm to download and use Mixpanel Event data on IoT devices.
Read more at the repo root README.
Downloads data from Mixpanel server and saves it in the Local Database at regular intervals.
File: 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
});
File: 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
});
File: config.js
Sign up and use API keys for Mixpanel and MongoDB (if not using local DB).
File: webserver.js
Configure port and other web server related stuff, including REST API paths.
Default port is 8970
, subject to change.
REST API Server. Default port is 8970
, subject to change.
Watch node console
to catch it.
Status check.
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.
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>"}
Server time. Used to set time for RTCs in client devices.
Output:
Human readable date and time. Not ISO 8601 time.
- Install Node.js
- Get API keys from Mixpanel and MongoLab.
- Open Command Prompt or Terminal console.
cd
to this directory.npm install -g nodemon
npm install
npm run dev
- Note down Local IP address displayed in the console.
- To exit, press
Ctrl + C
andy
in the console. Else,nodemon
will crash.
For best results, flash latest Raspbian Jessie with Pixel
image from Raspberry Pi website.
Name | Connects to |
---|---|
Pin 2 (5V) | I2C LCD GND |
Pin 6 (GND) | I2C LCD VCC |
Pin 3 (SDA1) | I2C LCD SDA |
Pin 5 (SCL1) | I2C LCD SCL |
Follow the instructions given by Dave Johnson.
There are two possible ways of doing this.
sudo raspi-config > Advanced Options
.Applications Menu > Preferences > Raspberry Pi Configuration > Interfaces
- Create directory
/home/pi/mixpanel_iot_server
. - Copy all individual JS source files to this directory.
cd /home/pi/mixpanel_iot_server
sudo npm install -g nodemon
sudo npm install
sudo npm install lcdi2c
sudo chmod +x start.sh
- Scan for I2C interface address of LCD using
i2cdetect -y 1
. - Replace
rpi.LCD_address
inrpi.js
with the output address.
- To start from source directory,
sudo ./start.sh
- To start from other directories,
sudo /home/pi/mixpanel_iot_server/./start.sh