{"id":25740151,"url":"https://github.com/datadotworld/mpjql-cli","last_synced_at":"2025-02-26T08:36:47.115Z","repository":{"id":66407980,"uuid":"106495002","full_name":"datadotworld/mpjql-cli","owner":"datadotworld","description":"MixPanel JQL Command Line Interface","archived":false,"fork":false,"pushed_at":"2023-12-04T20:54:21.000Z","size":41,"stargazers_count":2,"open_issues_count":1,"forks_count":1,"subscribers_count":27,"default_branch":"master","last_synced_at":"2023-12-04T21:47:02.898Z","etag":null,"topics":["command-line","command-line-tool","jql","mixpanel"],"latest_commit_sha":null,"homepage":null,"language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/datadotworld.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE.txt","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null}},"created_at":"2017-10-11T02:24:49.000Z","updated_at":"2020-04-24T15:32:31.000Z","dependencies_parsed_at":null,"dependency_job_id":"2f70c2db-9697-49c4-b78e-1e5db7aec3e5","html_url":"https://github.com/datadotworld/mpjql-cli","commit_stats":null,"previous_names":[],"tags_count":1,"template":null,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/datadotworld%2Fmpjql-cli","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/datadotworld%2Fmpjql-cli/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/datadotworld%2Fmpjql-cli/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/datadotworld%2Fmpjql-cli/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/datadotworld","download_url":"https://codeload.github.com/datadotworld/mpjql-cli/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":240821310,"owners_count":19863257,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["command-line","command-line-tool","jql","mixpanel"],"created_at":"2025-02-26T08:36:46.249Z","updated_at":"2025-02-26T08:36:47.070Z","avatar_url":"https://github.com/datadotworld.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# MixPanel JQL Command Line Interface\n\nInstalling this package will give you a new command line tool called `jql`. This\nenables you to write JQL using modern javascript techniques, including:\n\n* Split common code into modules\n* Modern ES2015 Syntax\n* String Template Literals\n* etc.\n\n\n## Example\n\nMove commonly used functions to their own file...\n```js\n// date.js\nexport const dateToString = e =\u003e {\n  return new Date(Number(e)).toISOString().substr(0, 10)\n}\n```\n\n...and then import them when needed.\n```js\n// example.js\nimport { dateToString } from './date'\nconst today = new Date()\nconst yesterday = new Date()\nyesterday.setDate(yesterday.getDate() - 1)\nfunction main() {\n  return Events({\n    from_date: dateToString(yesterday),\n    to_date: dateToString(today)\n  })\n    .groupByUser((user, events) =\u003e (user || 0) + events.length)\n    .map(user =\u003e `${user.key[0]}: ${user.value}`)\n}\n```\n\nThe `jql` command line tool uses [Rollup.js](https://rollupjs.org/),\n[Babel](https://babeljs.io/) and [Uglify](https://github.com/mishoo/UglifyJS)\nunder the hood to compile the script before sending it to MixPanel.\n\n## Installation\n\n```\nnpm install -g mpjql-cli\n```\n\nVisit [MixPanel](http://mixpanel.com) and copy your secret from your user\nsettings page.\n```\nexport MPSECRET=\u003csecret\u003e\n```\nSet this either locally in your terminal, or in `~/.profile`.\n\n## Basic Usage\n\nCreate a JQL query, then run it as follows:\n\n```\njql query myQuery.js\n```\n\nResults will be streamed to the terminal.  Redirect to a file or other commands.\n\n```\njql query myQuery.js \u003e output.json\n```\n\n\n\n# Advanced Usage\n\n## JQ\n[jq](https://stedolan.github.io/jq/) is an amazing tool for highlighting\nJSON results, or doing additional filtering of your results.\n```\njql query myQuery.js | jq\n```\n\nIt also has the capability to produce `CSV` with selected fields on the fly from\nreturned JSON.\n```\njql query myQuery.js | jq -r '.results[] | [.field1, .field2] | @csv' \u003e output.csv\n```\n\n## Passing settings to your scripts\n\nSettings can be passed on the command line to configure a script. This can be\nextremely useful when dealing with scripts that can be configured to find info\nabout a specific user, or date range.\n\nSettings are passed on the command line:\n```\njql query myQuery.js --setting='foo=bar' --setting='baz=boo,bop'\n```\n\nThe special variable `__SETTINGS__` will be replaced with an object containing\nall of your settings.\n```js\n// myQuery.js\nconst settings = __SETTINGS__\nfunction main() { /* ... */ }\n```\nwill effectively become...\n```js\n// myQuery.js\nconst settings = {\n  'foo':'bar',\n  'baz':['boo','bop']\n}\nfunction main() { /* ... */ }\n```\n\n# CLI commands\n\n## `query`\n\nCompile a script and execute it against your MixPanel account. Prints the resulting\nJSON into the `STDOUT`.\n```\njql query myQuery.js\n```\n\n## `show-code`\nYou can debug how a script is being compiled by replacing `query` with\n`show-code`. This prints the compiled javascript to the terminal for inspection.\n```\njql show-code myQuery.js\n```\n\n\n## `encode`\nIf you are integrating your scripts with another platform (such as Klipfolio)\nwhere you need the script URI encoded.\n```\njql encode myQuery.js\n```\n\n# Contributing\n\nSee [CONTRIBUTING.md](CONTRIBUTING.md) for more information on how you can help\nmake this tool better.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdatadotworld%2Fmpjql-cli","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdatadotworld%2Fmpjql-cli","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdatadotworld%2Fmpjql-cli/lists"}