Skip to content

Instantly share code, notes, and snippets.

@T1T4N
Created October 10, 2017 08:37
Show Gist options
  • Save T1T4N/99016199cd1a0bb7d55c0997fb85ab64 to your computer and use it in GitHub Desktop.
Save T1T4N/99016199cd1a0bb7d55c0997fb85ab64 to your computer and use it in GitHub Desktop.
Send a mixpanel event from bash
#!/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