A project on Collaborizm to download and use Mixpanel Event data on IoT 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.
Downloads data from Mixpanel server and saves it in the Local Database at regular intervals.
Sends GET request to Local Server and displays event data on the LCD at regular intervals. Uses WDT to reset when memory decreases.
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.
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
});
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
});
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.