{"id":13515293,"url":"https://github.com/mixpanel/mixpanel-js","last_synced_at":"2025-05-13T17:09:52.653Z","repository":{"id":17067112,"uuid":"19831896","full_name":"mixpanel/mixpanel-js","owner":"mixpanel","description":"Official Mixpanel JavaScript Client Library","archived":false,"fork":false,"pushed_at":"2025-04-16T23:59:53.000Z","size":20400,"stargazers_count":902,"open_issues_count":175,"forks_count":316,"subscribers_count":99,"default_branch":"master","last_synced_at":"2025-04-24T01:55:05.228Z","etag":null,"topics":["analytics","browser","javascript","mixpanel","mixpanel-javascript-library","sdk"],"latest_commit_sha":null,"homepage":"https://mixpanel.com/help/reference/javascript","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/mixpanel.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2014-05-15T19:12:17.000Z","updated_at":"2025-04-16T23:59:59.000Z","dependencies_parsed_at":"2024-01-13T19:25:11.383Z","dependency_job_id":"bacaea5e-411f-4f91-8dc7-70b723fca87f","html_url":"https://github.com/mixpanel/mixpanel-js","commit_stats":{"total_commits":1393,"total_committers":66,"mean_commits":"21.106060606060606","dds":"0.35750179468772436","last_synced_commit":"3c59a946e71b2e24acd6ba4726b138ca27769147"},"previous_names":[],"tags_count":121,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mixpanel%2Fmixpanel-js","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mixpanel%2Fmixpanel-js/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mixpanel%2Fmixpanel-js/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mixpanel%2Fmixpanel-js/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/mixpanel","download_url":"https://codeload.github.com/mixpanel/mixpanel-js/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":253990468,"owners_count":21995774,"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":["analytics","browser","javascript","mixpanel","mixpanel-javascript-library","sdk"],"created_at":"2024-08-01T05:01:08.966Z","updated_at":"2025-05-13T17:09:47.640Z","avatar_url":"https://github.com/mixpanel.png","language":"JavaScript","funding_links":[],"categories":["JavaScript"],"sub_categories":[],"readme":"\n# Mixpanel JavaScript Library\n![Build Status](https://github.com/mixpanel/mixpanel-js/actions/workflows/tests.yml/badge.svg)\n[![](http://img.badgesize.io/https://unpkg.com/mixpanel-browser/dist/mixpanel.min.js?compression=gzip)](https://unpkg.com/mixpanel-browser/dist/mixpanel.min.js)\n\nThe Mixpanel JavaScript Library is a set of methods attached to a global `mixpanel` object\nintended to be used by websites wishing to send data to Mixpanel projects. A full reference\nis available [here](https://developer.mixpanel.com/docs/javascript-full-api-reference).\n\n## Alternative installation via NPM\nThis library is available as a [package on NPM](https://www.npmjs.com/package/mixpanel-browser) (named `mixpanel-browser` to distinguish it from Mixpanel's server-side Node.js library, available on NPM as `mixpanel`). To install into a project using NPM with a front-end packager such as [Vite](https://vitejs.dev/) or [Webpack](https://webpack.github.io/):\n\n```sh\nnpm install --save mixpanel-browser\n```\n\nYou can then import the lib:\n\n```javascript\nimport mixpanel from 'mixpanel-browser';\n\nmixpanel.init(\"YOUR_TOKEN\", {autocapture: true});\nmixpanel.track(\"An event\");\n```\n\nNOTE: the default `mixpanel-browser` bundle includes a bundled `mixpanel-recorder` SDK. We provide the following options to exclude `mixpanel-recorder` if you do not intend to use session replay or want to reduce bundle size:\n\nTo load the core SDK with no option of session recording:\n```javascript\nimport mixpanel from 'mixpanel-browser/src/loaders/loader-module-core';\n```\n\nTo load the core SDK and optionally load session recording bundle asynchronously (via script tag):\n```javascript\nimport mixpanel from 'mixpanel-browser/src/loaders/loader-module-with-async-recorder';\n```\n\n## Use as a browser JavaScript module\n\nIf you are leveraging [browser JavaScript modules](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Modules), you can use [`importmap`](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/script/type/importmap) to pull in this library.\n\n```html\n\u003cscript type=\"importmap\"\u003e\n{\n  \"imports\": {\n    \"mixpanel-browser\": \"https://cdn.mxpnl.com/libs/mixpanel-js/dist/mixpanel.module.js\"\n  }\n}\n\u003c/script\u003e\n\u003cscript type=\"module\" src=\"main.js\"\u003e\u003c/script\u003e\n```\n\nThen you are free to import `mixpanel-browser` in your javascript modules.\n\n```js\n// main.js\nimport mixpanel from 'mixpanel-browser';\n\nmixpanel.init('YOUR_TOKEN', {autocapture: true, debug: true, persistence: 'localStorage'});\n```\n\n## Building bundles for release\n- Install development dependencies: `npm install`\n- Build: `npm run build-dist`\n\n## Running tests\n- Install development dependencies: `npm install`\n- Run unit tests: `npm test`\n- Start test server for browser tests: `npm run integration_test`\n- Browse to [http://localhost:3000/tests/](http://localhost:3000/tests/) and choose a scenario to run\n\nIn the future we plan to automate the last step with a headless browser to streamline development (although\nMixpanel production releases are tested against a large matrix of browsers and operating systems).\n\n## Generating and publishing documentation\n- Create bundled source build: `npm run build-dist`\n- Generate Markdown: `npm run dox` (result is at `doc/readme.io/javascript-full-api-reference.md`)\n- Publish to readme.io via the [rdme](https://www.npmjs.com/package/rdme) util: `RDME_API_KEY=\u003cAPI_KEY\u003e RDME_DOC_VERSION=\u003cversion\u003e npm run dox-publish`\n\n## Thanks\nFor patches and support: @bohanyang, @dehau, @drubin, @D1plo1d, @feychenie, @mogstad, @pfhayes, @sandorfr, @stefansedich, @gfx, @pkaminski, @austince, @danielbaker, @mkdai, @wolever, @dpraul, @chriszamierowski, @JoaoGomesTW, @@aliyalcinkaya, @chrisdeely\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmixpanel%2Fmixpanel-js","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmixpanel%2Fmixpanel-js","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmixpanel%2Fmixpanel-js/lists"}