2.61.2 • Published 3 months ago

mixpanel-browser v2.61.2

Weekly downloads
181,659
License
Apache-2.0
Repository
github
Last release
3 months ago

Mixpanel JavaScript Library

Build Status npm.io

The Mixpanel JavaScript Library is a set of methods attached to a global mixpanel object intended to be used by websites wishing to send data to Mixpanel projects. A full reference is available here.

Alternative installation via NPM

This library is available as a package on NPM (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 or Webpack:

npm install --save mixpanel-browser

You can then import the lib:

import mixpanel from 'mixpanel-browser';

mixpanel.init("YOUR_TOKEN", {autocapture: true});
mixpanel.track("An event");

NOTE: 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:

To load the core SDK with no option of session recording:

import mixpanel from 'mixpanel-browser/src/loaders/loader-module-core';

To load the core SDK and optionally load session recording bundle asynchronously (via script tag):

import mixpanel from 'mixpanel-browser/src/loaders/loader-module-with-async-recorder';

Use as a browser JavaScript module

If you are leveraging browser JavaScript modules, you can use importmap to pull in this library.

<script type="importmap">
{
  "imports": {
    "mixpanel-browser": "https://cdn.mxpnl.com/libs/mixpanel-js/dist/mixpanel.module.js"
  }
}
</script>
<script type="module" src="main.js"></script>

Then you are free to import mixpanel-browser in your javascript modules.

// main.js
import mixpanel from 'mixpanel-browser';

mixpanel.init('YOUR_TOKEN', {autocapture: true, debug: true, persistence: 'localStorage'});

Building bundles for release

  • Install development dependencies: npm install
  • Build: npm run build-dist

Running tests

  • Install development dependencies: npm install
  • Run unit tests: npm test
  • Start test server for browser tests: npm run integration_test
  • Browse to http://localhost:3000/tests/ and choose a scenario to run

In the future we plan to automate the last step with a headless browser to streamline development (although Mixpanel production releases are tested against a large matrix of browsers and operating systems).

Generating and publishing documentation

  • Create bundled source build: npm run build-dist
  • Generate Markdown: npm run dox (result is at doc/readme.io/javascript-full-api-reference.md)
  • Publish to readme.io via the rdme util: RDME_API_KEY=<API_KEY> RDME_DOC_VERSION=<version> npm run dox-publish

Thanks

For patches and support: @bohanyang, @dehau, @drubin, @D1plo1d, @feychenie, @mogstad, @pfhayes, @sandorfr, @stefansedich, @gfx, @pkaminski, @austince, @danielbaker, @mkdai, @wolever, @dpraul, @chriszamierowski, @JoaoGomesTW, @@aliyalcinkaya, @chrisdeely

fundwave-fund-management@do-killer/dodo-wallet2minsilo-react-client@sellics/profit@sellics/react-trackinger-prism-web@datatoggle/datatoggle-mixpanel@fast-af/analyticsmn-reveal-worker-test@airstudio/extensionshahnbee-test-client@infinitebrahmanuniverse/nolb-mix@everything-registry/sub-chunk-2179pw-testmsg-odds-summary-femsg-odds-summary-fe-test-1polygona-3d-clienttalentorg-profile-editortableau-add-invue-mixpanelvue-mixpanel-browservue-npm-publish@diwala/logger@collabland/lifi-widget@cybro-team/cybro-presale-form@doreamonjs/plugin-function@doreamonjs/plugin-iframe@doreamonjs/plugin-log@doreamonjs/plugin-menu@doreamonjs/plugin-message@doreamonjs/plugin-popup@doreamonjs/plugin-state@doreamonjs/plugin-terminal@doreamonjs/plugin-analysis@doreamonjs/plugin-authorization@doreamonjs/plugin-config@doreamonjs/plugin-dialog@peachy-studio/client-portal@peculiar/identityfront-scannerjeffreykarimaaitbbajoplin-plugin-wakatimejs-qslatticeflow-widgetslandr@olaisaac/event-dispatcher-sdkstream-engine-playerui-test-rowflex@appointedd/booking-tools-sdk@antribute/tracking@balena/jellyfish-ui-components@circulare/usage-tracker-browser@cleeng/mediastore-sdk-react-16@cleeng/mediastore-sdk4r-landing-page@9amhealth/webcomponents@cognite/3d-viewer@cognite/copilot-core@cognite/reveal@brandwatch/remimi@brainfish-ai/search-widget@datatoggle/mixpanel@debales-ai/ai-assistant@credenza-web3/passportunigraph-dev-explorer@h790/toibox-library@haptik/helpers@honeycomb-finance/shared@heypink/tracking@livelyapp/chatui@localazy/components@local-logic/core@logcomex/shared-components@legalmentedev/capacitor-mixpanel@libhub/utils@lvble/core@luisbytes/capacitor-mixpanel@moser-inc/moser-labs-react@newtonschool/ns-events-library@ngvip/analytics@near-wallet/frontend@neon.id/context@envanik/components@metafi/metafi-react-package@metafi/metafi-sdk-controllers@mirai/data-sources@modfy/core@kite-tech/components@kite-tech/kite-components@kite-tech-ltd/kite-components@illa-public/mixpanel-utils@img-arena/streaming-sdk@houseninja/capacitor-mixpanel@qualitydevs/capacitor-mixpanel@portxchange/mixpanel-utils@questlabs/react-sdk@qwoach/analytics@ristek-kit/ads@ringcentral-integration/commons@novu/studio
2.56.0-ac-alpha-3

6 months ago

2.57.1

6 months ago

2.59.0

5 months ago

2.60.0

4 months ago

2.56.0

7 months ago

2.58.0

6 months ago

2.61.0

3 months ago

2.61.1

3 months ago

2.61.2

3 months ago

2.55.1

10 months ago

2.53.0

12 months ago

2.55.0

11 months ago

2.51.0

1 year ago

2.54.0

11 months ago

2.54.1

11 months ago

2.52.0

1 year ago

2.50.0

1 year ago

2.49.0

1 year ago

2.48.0

2 years ago

2.48.1

2 years ago

2.47.0

2 years ago

2.46.0

2 years ago

2.43.0

3 years ago

2.45.0

3 years ago

2.42.1

3 years ago

2.42.0

4 years ago

2.41.0

4 years ago

2.40.1

4 years ago

2.40.0

5 years ago

2.39.0

5 years ago

2.38.0

5 years ago

2.37.0

5 years ago

2.36.0

5 years ago

2.35.0

5 years ago

2.34.0

5 years ago

2.33.1

5 years ago

2.33.0

5 years ago

2.32.0

5 years ago

2.31.0

6 years ago

2.30.1

6 years ago

2.29.1

6 years ago

2.29.0

6 years ago

2.28.0

6 years ago

2.27.1

6 years ago

2.27.0

6 years ago

2.26.0

6 years ago

2.25.0

6 years ago

2.24.0

7 years ago

2.23.0

7 years ago

2.23.0-beta

7 years ago

2.22.4

7 years ago

2.22.3

7 years ago

2.22.2

7 years ago

2.22.1

7 years ago

2.22.0

7 years ago

2.21.0

7 years ago

2.20.0

7 years ago

2.19.0

7 years ago

2.18.0

7 years ago

2.17.1

7 years ago

2.17.0

7 years ago

2.16.0

7 years ago

2.15.0

7 years ago

2.14.0

8 years ago

2.13.0

8 years ago

2.11.1

8 years ago

2.11.0

8 years ago

2.10.0

8 years ago

2.9.17

9 years ago

2.9.16

9 years ago

2.9.15

9 years ago

2.9.14

9 years ago

2.9.12

9 years ago

2.9.9

9 years ago

2.9.8

9 years ago

2.9.6

9 years ago

2.8.1

9 years ago

2.8.0

9 years ago

2.7.2

10 years ago

2.7.0

10 years ago