Skip to content

Commit

Permalink
Update Documentation
Browse files Browse the repository at this point in the history
  • Loading branch information
KevinvdBurg committed Apr 29, 2024
1 parent 135d2c6 commit 27a85d5
Show file tree
Hide file tree
Showing 3 changed files with 46 additions and 4 deletions.
28 changes: 25 additions & 3 deletions doc/mixpanel_setup.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,12 @@ import { MixpanelProvider } from '@freshheads/analytics-essentials';

const App = () => {
return (
<MixpanelProvider eventApiClient={sendTrackEvent}>
<MixpanelProvider
trackingService={
new WebTrackingService((event) => {
return sendTrackEvent(event);
})
}>
<YourApp />
</MixpanelProvider>
);
Expand Down Expand Up @@ -83,7 +88,13 @@ const defaultMixpanelEventContext = {

const App = () => {
return (
<MixpanelProvider eventApiClient={sendTrackEvent} defaultEventContext={defaultMixpanelEventContext}>
<MixpanelProvider
trackingService={
new WebTrackingService((event) => {
return sendTrackEvent(event);
})
}
defaultEventContext={defaultMixpanelEventContext}>
<YourApp />
</MixpanelProvider>
);
Expand Down Expand Up @@ -137,7 +148,12 @@ Then add this component to your app:

const App = () => {
return (
<MixpanelProvider eventApiClient={sendTrackEvent}>
<MixpanelProvider
trackingService={
new WebTrackingService((event) => {
return sendTrackEvent(event);
})
}>
<TrackPageView />
{children}
</MixpanelProvider>
Expand All @@ -150,6 +166,12 @@ const App = () => {
UTM tags are automatically added to the context of the event if they are present in the URL.
They will be remembered for the duration of the session. Even if the user navigates to a different page, the UTM tags will be added to new events.

#### Mobile

On mobile, the UTM tags can not be stored in the session, use `disableSessionStorage` to disable this behaviour.

```tsx

## Mixpanel users

Mixpanel events can be attached to a user. This is done in the backend on user login, see [FHMixpanelBundle](https://github.com/freshheads/FHMixpanelBundle) for more information.
Expand Down
20 changes: 20 additions & 0 deletions lib/mixpanel/context.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,29 @@ interface MixpanelContextProps {
}

interface MixpanelProviderProps {
/**
* Children to render
*/
children: React.ReactNode;
/**
* Tracking service to use included in this package are `WebTrackingService` and `MobileTrackingService`
* @see WebTrackingService use for web applications
* @see MobileTrackingService use for mobile applications, NOTE: set disableSessionStorage to true to disable session storage because it is not available in mobile
*
* if you want to use your own tracking service you can implement the `TrackingService` interface
* @see TrackingService
*
*/
trackingService: TrackingService;
/**
* Default event context to use for all events
* @see WebMixpanelEvent for web events
* @see MobileMixpanelEvent for mobile events
*/
defaultEventContext?: WebMixpanelEvent['context'] | MobileMixpanelEvent['context'];
/**
* Disables session storage for storing utm params
*/
disableSessionStorage?: boolean;
}

Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@freshheads/analytics-essentials",
"version": "1.1.0-beta.8",
"version": "1.1.0",
"keywords": [
"Analytics",
"Tag Manager",
Expand Down

0 comments on commit 27a85d5

Please sign in to comment.