Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/joyqi/tiny-mixpanel
A minium mixpanel library written in TypeScript
https://github.com/joyqi/tiny-mixpanel
Last synced: 17 days ago
JSON representation
A minium mixpanel library written in TypeScript
- Host: GitHub
- URL: https://github.com/joyqi/tiny-mixpanel
- Owner: joyqi
- License: mit
- Created: 2022-03-15T06:07:48.000Z (over 2 years ago)
- Default Branch: main
- Last Pushed: 2022-03-15T07:48:47.000Z (over 2 years ago)
- Last Synced: 2024-09-21T08:48:48.174Z (about 2 months ago)
- Language: TypeScript
- Size: 8.79 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# tiny-mixpanel
## What's this?
It's a minium mixpanel library written in TypeScript.
**Why not [mixpanel-browser](https://www.npmjs.com/package/mixpanel-browser)?**
Of course, you can use this official library. But it will make over 20kb extra sizes to a bundled js file. Moreover, considering the tracking system is widely used on every page, it will significantly increase the cost of your traffic.
So I rewrite the official embedding code by typescript. Then, instead of packaging it, it will load the whole library from the official CDN.
## Install
```bash
npm i -S tiny-mixpanel
```For TypeScript you should also
```bash
npm i -D @types/mixpanel
```## Usage
JavaScript
```javascript
const { loadMixpanel } = require('tiny-mixpanel');loadMixpanel();
mixpanel.init('xxxx-xxxxxxxxxxxxxxx');
mixpanel.track('event name');
```TypeScript
```typescript
import { loadMixpanel } from 'tiny-mixpanel';loadMixpanel();
mixpanel.init('xxxx-xxxxxxxxxxxxxxx');
mixpanel.track('event name');
```