🚀 Big News: Socket Acquires Coana to Bring Reachability Analysis to Every Appsec Team.Learn more
Socket
DemoInstallSign in
Socket

react-mixpanel-browser

Package Overview
Dependencies
Maintainers
1
Versions
23
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

react-mixpanel-browser - npm Package Compare versions

Comparing version

to
1.0.4

2

package.json
{
"name": "react-mixpanel-browser",
"version": "1.0.3",
"version": "1.0.4",
"description": "React providers for mixpanel-browser using the Context API.",

@@ -5,0 +5,0 @@ "keywords": [

# react-mixpanel-browser
React providers for [mixpanel-browser](https://www.npmjs.com/package/mixpanel-browser) using the [Context API](https://reactjs.org/docs/context.html).
Thin wrapper for [mixpanel-browser](https://www.npmjs.com/package/mixpanel-browser) for use in React apps.

@@ -30,50 +30,19 @@ ## Installation

3. Access the context using either the `useMixpanel()` hook (stateless components only) or the `withMixpanel()` High-Order Component. The value provided will be either an instance of [MixpanelLib](https://developer.mixpanel.com/docs/javascript-full-api-reference) or `null` if a token was not provided; useful for untracked environments.
3. Import the instance into your components where required:
## Examples
import React from 'react';
import mixpanel from 'react-mixpanel-browser';
### Usage with `useMixpanel()` Hook ###
const App = (props) = {
import React from 'react';
import { useMixpanel } from 'react-mixpanel-browser';
// Note that mixpanel will be null if a token has not been configured
const App = (props) = {
mixpanel && mixpanel.track('My Event', {
my_custom_prop: 'foo',
});
const mixpanel = useMixpanel();
return <div>This page was tracked in Mixpanel</div>;
// Note that mixpanel will be null if a token has not been configured
};
mixpanel && mixpanel.track('My Event', {
my_custom_prop: 'foo',
});
return <div>This page was tracked in Mixpanel</div>;
};
export default App;
### Usage with `withMixpanel()` High-Order Component
import React from 'react';
import { withMixpanel } from 'react-mixpanel-browser';
class App extends Component {
render() {
const { mixpanel } = this.props;
// Note that mixpanel will be null if a token has not been configured
mixpanel && mixpanel.track('My Event', {
my_custom_prop: 'foo',
});
return <div>This page was tracked in Mixpanel</div>;
}
}
export default withMixpanel(App);
export default App;
export { default as init } from './init';
export { default as mixpanel } from './mixpanel';
export { default as useMixpanel } from './useMixpanel';
export { default as withMixpanel } from './withMixpanel';