Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/houseninjadojo/capacitor-mixpanel

Capacitor plugin for Mixpanel
https://github.com/houseninjadojo/capacitor-mixpanel

capacitor capacitor-android capacitor-ios capacitor-plugin capacitor-web mixpanel

Last synced: about 2 months ago
JSON representation

Capacitor plugin for Mixpanel

Awesome Lists containing this project

README

        



Capacitor Mixpanel


@houseninja/capacitor-mixpanel



Capacitor plugin for Mixpanel










## Maintainers

| Maintainer | GitHub | Social |
| --------------- | --------------------------------------------------- | ----------------------------------------- |
| Miles Zimmerman | [mileszim](https://github.com/mileszim) | [@mileszim](https://twitter.com/mileszim) |
| House Ninja | [houseninjadojo](https://github.com/houseninjadojo) | |

## Install

```bash
npm install @houseninja/capacitor-mixpanel
```

Add the following plugin configuration:

```js
{
...
"Mixpanel": {
"token": "token-abcdefg1234",
"trackAutomaticEvents": true, // optional, default: true
"optOutTrackingByDefault": false, // optional, default: false
"disableIosIpCollection": true, // optional, default: false
"serverURL": "https://api-eu.mixpanel.com/", // optional, default: "https://api.mixpanel.com/"
},
...
}
```

Sync capacitor configuration

```bash
npx cap sync
```

## API

- [Maintainers](#maintainers)
- [Install](#install)
- [API](#api)
- [initialize(...)](#initialize)
- [distinctId()](#distinctid)
- [track(...)](#track)
- [identify(...)](#identify)
- [alias(...)](#alias)
- [reset()](#reset)
- [clearSuperProperties()](#clearsuperproperties)
- [currentSuperProperties()](#currentsuperproperties)
- [registerSuperProperties(...)](#registersuperproperties)
- [setProfile(...)](#setprofile)
- [setProfileUnion(...)](#setprofileunion)
- [deleteProfile()](#deleteprofile)
- [trackCharge(...)](#trackcharge)
- [flush()](#flush)
- [optInTracking(...)](#optintracking)
- [optOutTracking()](#optouttracking)
- [hasOptedOutTracking()](#hasoptedouttracking)
- [Interfaces](#interfaces)
- [InitializeOptions](#initializeoptions)
- [TrackOptions](#trackoptions)
- [TrackProperties](#trackproperties)
- [IdentifyOptions](#identifyoptions)
- [AliasOptions](#aliasoptions)
- [SuperPropertyOptions](#superpropertyoptions)
- [ProfileProperties](#profileproperties)
- [ChargeOptions](#chargeoptions)
- [OptInOptions](#optinoptions)
- [Contributors](#contributors)

### initialize(...)

```typescript
initialize(options: InitializeOptions) => Promise
```

Initialize the plugin (web only)

| Param | Type |
| ------------- | --------------------------------------------------------------- |
| **`options`** | InitializeOptions |

--------------------

### distinctId()

```typescript
distinctId() => Promise<{ value: string; }>
```

Returns the current distinct id of the user. This is either the id automatically generated by the library or the id that has been passed by a call to identify().

**Returns:** Promise<{ value: string; }>

--------------------

### track(...)

```typescript
track(options: TrackOptions) => Promise
```

Tracks an event with properties. Properties are optional and can be added only if needed.

| Param | Type |
| ------------- | ----------------------------------------------------- |
| **`options`** | TrackOptions |

--------------------

### identify(...)

```typescript
identify(options: IdentifyOptions) => Promise
```

Identify a user with a unique ID to track user activity across devices, tie a user to their events, and create a user profile. If you never call this method, unique visitors are tracked using a UUID generated the first time they visit the site.

| Param | Type |
| ------------- | ----------------------------------------------------------- |
| **`options`** | IdentifyOptions |

--------------------

### alias(...)

```typescript
alias(options: AliasOptions) => Promise
```

The alias method creates an alias which Mixpanel will use to remap one id to another. Multiple aliases can point to the same identifier.

| Param | Type |
| ------------- | ----------------------------------------------------- |
| **`options`** | AliasOptions |

--------------------

### reset()

```typescript
reset() => Promise
```

Clears super properties and generates a new random distinct_id for this instance. Useful for clearing data when a user logs out.

--------------------

### clearSuperProperties()

```typescript
clearSuperProperties() => Promise
```

Clears all currently set super properties.

--------------------

### currentSuperProperties()

```typescript
currentSuperProperties() => Promise<{ properties: any; }>
```

Returns the currently set super properties.

**Returns:** Promise<{ properties: any; }>

--------------------

### registerSuperProperties(...)

```typescript
registerSuperProperties(options: SuperPropertyOptions) => Promise
```

Register super properties that will be sent with every event.

| Param | Type |
| ------------- | --------------------------------------------------------------------- |
| **`options`** | SuperPropertyOptions |

--------------------

### setProfile(...)

```typescript
setProfile(options: ProfileProperties) => Promise
```

Set properties on the current user in Mixpanel People.

| Param | Type |
| ------------- | --------------------------------------------------------------- |
| **`options`** | ProfileProperties |

--------------------

### setProfileUnion(...)

```typescript
setProfileUnion(options: ProfileProperties) => Promise
```

Union list properties.

| Param | Type |
| ------------- | --------------------------------------------------------------- |
| **`options`** | ProfileProperties |

--------------------

### deleteProfile()

```typescript
deleteProfile() => Promise
```

Permanently deletes the current people analytics profile from Mixpanel (using the current distinctId).

--------------------

### trackCharge(...)

```typescript
trackCharge(options: ChargeOptions) => Promise
```

Track money spent by the current user for revenue analytics and associate properties with the charge. Properties is optional.

| Param | Type |
| ------------- | ------------------------------------------------------- |
| **`options`** | ChargeOptions |

--------------------

### flush()

```typescript
flush() => Promise
```

Uploads queued data to the Mixpanel server. (only ios, android)

--------------------

### optInTracking(...)

```typescript
optInTracking(options: OptInOptions) => Promise
```

Opt in tracking.

Use this method to opt in an already opted out user from tracking. People updates and track calls will be sent to Mixpanel after using this method.

| Param | Type |
| ------------- | ----------------------------------------------------- |
| **`options`** | OptInOptions |

--------------------

### optOutTracking()

```typescript
optOutTracking() => Promise
```

Opt out tracking.

This method is used to opt out tracking. This causes all events and people request no longer to be sent back to the Mixpanel server.

--------------------

### hasOptedOutTracking()

```typescript
hasOptedOutTracking() => Promise<{ value: boolean; }>
```

Returns the current opt-out status.

**Returns:** Promise<{ value: boolean; }>

--------------------

### Interfaces

#### InitializeOptions

| Prop | Type | Description | Default |
| --------------------- | -------------------- | ----------------------------------------------------------------- | ------------------ |
| **`token`** | string | Your Mixpanel API token | |
| **`autotrack`** | boolean | Enable or disable autotracking | true |
| **`optOutByDefault`** | boolean | Opting users out of tracking by this Mixpanel instance by default | false |
| **`debug`** | boolean | Enable or disable debug mode | false |

#### TrackOptions

| Prop | Type | Description | Default |
| ---------------- | ----------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------ | --------------- |
| **`event`** | string | The name of the event. This can be anything the user does - 'Button Click', 'Sign Up', 'Item Purchased', etc. | |
| **`properties`** | TrackProperties | A set of properties to include with the event you're sending. These describe the user who did the event or details about the event itself. | {} |

#### TrackProperties

#### IdentifyOptions

| Prop | Type | Description |
| ---------------- | ------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------- |
| **`distinctId`** | string | A string that uniquely identifies a user. If not provided, the distinct_id currently in the persistent store (cookie or localStorage) will be used. |

#### AliasOptions

| Prop | Type | Description |
| ---------------- | ------------------- | --------------------------------------------------------------------- |
| **`alias`** | string | A unique identifier that you want to use for this user in the future. |
| **`distinctId`** | string | The current identifier being used for this user. |

#### SuperPropertyOptions

| Prop | Type | Description |
| ---------------- | ---------------- | ---------------------------------------------------------- |
| **`properties`** | any | An associative array of properties to store about the user |

#### ProfileProperties

| Prop | Type | Description |
| ---------------- | ---------------- | ---------------------------------------------------------- |
| **`properties`** | any | An associative array of properties to store about the user |

#### ChargeOptions

| Prop | Type | Description | Default |
| ---------------- | ------------------- | ----------------------------------------------------------------- | --------------- |
| **`amount`** | number | The amount of the transaction | |
| **`properties`** | any | An associative array of properties to store about the transaction | {} |

#### OptInOptions

| Prop | Type | Description |
| ---------------- | ------------------- | ---------------------------------------------------------- |
| **`distinctId`** | string | String that uniquely identifies the current user. |
| **`properties`** | any | An associative array of properties to store about the user |

## Contributors

Thanks goes to these wonderful people ([emoji key](https://allcontributors.org/docs/en/emoji-key)):



Miles Zimmerman
Miles Zimmerman

💻 📖 🚧 💡 📦 🔌
Adam C
Adam C

💻 📖
Christian von Rohr
Christian von Rohr

💻 📖
Matt
Matt

💻 📖

This project follows the [all-contributors](https://github.com/all-contributors/all-contributors) specification. Contributions of any kind welcome!