Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

mixpanel-react-native

Package Overview
Dependencies
Maintainers
1
Versions
51
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

mixpanel-react-native - npm Package Compare versions

Comparing version 1.2.4 to 1.3.0

2

__tests__/index.test.js

@@ -12,3 +12,3 @@ /**

const mixpanel = await Mixpanel.init("token");
expect(NativeModules.MixpanelReactNative.initialize).toBeCalledWith("token", false, {"$lib_version": "1.2.4", "mp_lib": "react-native"});
expect(NativeModules.MixpanelReactNative.initialize).toBeCalledWith("token", false, {"$lib_version": "1.3.0", "mp_lib": "react-native"});
});

@@ -15,0 +15,0 @@

@@ -6,2 +6,3 @@ type MixpanelType = any;

static init(token: string, optInTracking?: boolean): Promise<Mixpanel>;
init(optInTracking?: boolean): Promise<void>;
setServerURL(serverURL: string): void;

@@ -8,0 +9,0 @@ setLoggingEnabled(loggingEnabled: boolean): void;

@@ -54,4 +54,21 @@ "use strict";

/**
* Initializes an instance of the API with the given project token.
* Initializes Mixpanel
*
* @param {boolean} Optional Whether or not Mixpanel can start tracking by default. See optOutTracking()
*
*/
async init(optOutTrackingDefault = DEFAULT_OPT_OUT) {
let metadata = Helper.getMetaData();
await MixpanelReactNative.initialize(this.token, optOutTrackingDefault, metadata);
}
/**
* @deprecated since version 1.3.0. To initialize Mixpanel, please use the instance method `init` instead. See the example below:
*
* <pre><code>
* const mixpanel = new Mixpanel('your project token');
* mixpanel.init();
* </code></pre>
*
* Initializes Mixpanel and return an instance of Mixpanel the given project token.
*

@@ -58,0 +75,0 @@ * @param {string} token your project token.

{
"name": "mixpanel-react-native",
"version": "1.2.4",
"version": "1.3.0",
"description": "Official React Native Tracking Library for Mixpanel Analytics",

@@ -5,0 +5,0 @@ "main": "index.js",

@@ -17,2 +17,3 @@

- [Check for Success](#4-check-for-success)
- [Complete Code Example](#complete-code-example)
- [FAQ](#faq)

@@ -52,20 +53,14 @@ - [I want to know more!](#i-want-to-know-more)

### 2. Initialize Mixpanel
To start tracking with the library you must first initialize with your project token. To initialize the library, first add `import { Mixpanel }` and call `Mixpanel.init(token)` with your project token as it's argument.
To start tracking with the library you must first initialize with your project token. You can get your project token from [project settings](https://mixpanel.com/settings/project).
```js
import { Mixpanel } from 'mixpanel-react-native';
...
class YourClass extends React.Component {
constructor(props) {
super(props);
this.configMixpanel();
}
configMixpanel = async () => {
this.mixpanel = await Mixpanel.init("Your mixpanel token");
}
...
const mixpanel = new Mixpanel("Your Project Token");
mixpanel.init();
```
Once you've called this method once, you can access `mixpanel` throughout the rest of your application.
### 3. Send Data
Let's get started by sending event data. You can send an event from anywhere in your application. Better understand user behavior by storing details that are specific to the event (properties). After initializing the library, Mixpanel will [automatically collect common mobile events](https://mixpanel.com/help/questions/articles/which-common-mobile-events-can-mixpanel-collect-on-my-behalf-automatically). You can enable/disable automatic collection through your project settings. Also, Mixpanel automatically tracks some properties by default. [learn more](https://help.mixpanel.com/hc/en-us/articles/115004613766-Default-Properties-Collected-by-Mixpanel)
Let's get started by sending event data. You can send an event from anywhere in your application. Better understand user behavior by storing details that are specific to the event (properties). After initializing the library, Mixpanel will automatically track some properties by default. [learn more](https://help.mixpanel.com/hc/en-us/articles/115004613766-Default-Properties-Collected-by-Mixpanel)
```js

@@ -83,2 +78,29 @@ // Track with event-name

### Complete Code Example
```js
import React from 'react';
import { Button, SafeAreaView } from "react-native";
import { Mixpanel } from 'mixpanel-react-native';
const mixpanel = new Mixpanel("Your Project Token");
mixpanel.init();
const SampleApp = () => {
return (
<SafeAreaView>
<Button
title="Select Premium Plan"
onPress={() => mixpanel.track("Plan Selected", {"Plan": "Premium"})}
/>
</SafeAreaView>
);
}
export default SampleApp;
```
## FAQ

@@ -98,3 +120,3 @@ **I want to stop tracking an event/event property in Mixpanel. Is that possible?**

If your events are still not showing up after 60 seconds, check if you have opted out of tracking. You can also enable Mixpanel debugging and logging, it allows you to see the debug output from the Mixpanel library. To enable it, call [setLoggingEnabled](https://mixpanel.github.io/mixpanel-swift/Classes/MixpanelInstance.html#/s:8Mixpanel0A8InstanceC14loggingEnabledSbvp) to true, then run your iOS project with Xcode or android project with Android Studio. The logs should be available in the console.
If your events are still not showing up after 60 seconds, check if you have opted out of tracking. You can also enable Mixpanel debugging and logging, it allows you to see the debug output from the Mixpanel library. To enable it, call [setLoggingEnabled](https://mixpanel.github.io/mixpanel-react-native/Mixpanel.html#setLoggingEnabled) with true, then run your iOS project with Xcode or android project with Android Studio. The logs should be available in the console.

@@ -116,4 +138,4 @@ ```

* **[Sample app](https://github.com/mixpanel/mixpanel-react-native/tree/master/MixpanelDemo)**
* **[Full API Reference](https://developer.mixpanel.com/docs/react-native)**
* **[Full API Reference](https://mixpanel.github.io/mixpanel-react-native/Mixpanel.html)**
Have any questions? Reach out to Mixpanel [Support](https://help.mixpanel.com/hc/en-us/requests/new) to speak to someone smart, quickly.

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc