Public | Automated Build

Last pushed: 8 months ago
Short Description
mixpanel-cli - A command-line tool to query Mixpanel API
Full Description

mixpanel-cli - A command-line tool to query Mixpanel API

Shameless plug

<p align="center"><img src="https://cloud.githubusercontent.com/assets/138050/19687045/2f893296-9ac4-11e6-9c5b-fca23436c2bc.gif" alt="mixpanel cli" title="mixpanel cli"></p>

Install (docker 🐳)

Use this approach if you don't know/want to setup your NodeJS environment, that's what containers are good for.

# open ~/.bashrc  (or equivalent)
nano ~/.bashrc

# edit it
function mixpanel(){
 docker run -it --rm -e MIXPANEL_API_KEY=$MIXPANEL_API_KEY fgribreau/mixpanel-cli:latest ./mixpanel $@
}

# save it

# source it
source ~/.bashrc

# run it!
mixpanel

# done!

Install (NodeJS)

npm i mixpanel-cli -S

Currently supported

$ mixpanel

Commands:
  track                 Track an event
  people.set            Set properties on a user record
  people.set_once       Set properties on a user record, only if they do not yet exist
  people.increment      Increment/decrement numeric people analytics properties
  people.append         Append a value to a list-valued people analytics property
  people.union          Merge a given list with a list-valued people analytics property, excluding duplicate values
  people.track_charge   Record that you have charged the current user a certain amount of money
  people.clear_charges  Permanently clear all revenue report transactions from the current user's people analytics profile
  people.delete_user    Permanently deletes the current people analytics profile from Mixpanel (using the current distinct_id)

Options:
  -h, --help  Show help  [boolean]

@FGRibreau - https://twitter.com/FGRibreau

Usage

First thing first, expose your mixpanel api key ("Project settings" > "Token") through an environment variable MIXPANEL_API_KEY.

export MIXPANEL_API_KEY="your_api_key"

Track event

mixpanel track --distinct_id UNIQUE_USER_ID --event_name "User opened settings" --properties Country France Model "SM-T530"

Set property to user profile

mixpanel people.set --distinct_id UNIQUE_USER_ID --prop MyProperty --to ValueToSet

Add a property to a list of users (sequential)

echo "ID1\nID2" | xargs -I {ProfileID} mixpanel people.set  --distinct_id {ProfileID} --prop MyProperty --to ValueToSet

Add a property to a list of users (parallel)

Same as above but does 10 requests in parallel (-P 10)!

cat user_ids.txt | xargs -P 10 -I {ProfileID} mixpanel people.set  --distinct_id {ProfileID} --prop MyProperty --to ValueToSet

Todo

  • [ ] More examples / better documentation (even if the CLI is completely documented)
  • [ ] Tests

Changelog

Docker Pull Command
Owner
fgribreau
Source Repository

Comments (0)