From 7b52ea51c528e7e0fef98b3137add73705273583 Mon Sep 17 00:00:00 2001 From: Austin Pray <71290498+austinpray-mixpanel@users.noreply.github.com> Date: Thu, 1 Aug 2024 18:37:29 -0500 Subject: [PATCH] Update README.md --- README.md | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/README.md b/README.md index 88c3f980..a3db844d 100644 --- a/README.md +++ b/README.md @@ -35,6 +35,30 @@ To load the core SDK and optionally load session recording bundle asynchronously 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](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. + +```html + + +``` + +Then you are free to import `mixpanel-browser` in your javascript modules. + +```js +// main.js +import mixpanel from 'mixpanel-browser'; + +mixpanel.init('YOUR_TOKEN', {debug: true, track_pageview: true, persistence: 'localStorage'}); +``` + ## Building bundles for release - Install development dependencies: `npm install` - Build: `npm run build-dist`