Created
October 10, 2017 08:37
-
-
Save T1T4N/99016199cd1a0bb7d55c0997fb85ab64 to your computer and use it in GitHub Desktop.
Send a mixpanel event from bash
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env bash | |
send_mixpanel_event() { | |
local token="<TOKEN>" | |
local distinct_id="<DISTINCT-ID>" | |
local time_now=$(date +%s) | |
local event | |
read -d '' event <<-EOF | |
{ | |
"event": "Install", | |
"properties": { | |
"distinct_id": "$distinct_id", | |
"token": "$token", | |
"time": $time_now, | |
"Action": "Test" | |
} | |
} | |
EOF | |
local event=$(echo "$event" | tr -d '\n') | |
local event_enc="$(echo -n "$event" | openssl base64 -A)" | |
/usr/bin/curl "https://api.mixpanel.com/track/?data=$event_enc?ip=1" | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment