React Native: Segment

Setup

  1. 1.
    Sign up for Segment.io and create a Segment.io project for your mobile application.
  2. 2.
    Add React Native Segment by following the guide.
  3. 3.
    Install the target:
    1
    npm install --save @redux-beacon/react-native-segment
    Copied!

Usage

1
import Segment from '@redux-beacon/react-native-segment';
2
import SegmentAnalytics from '@segment/analytics-react-native';
3
4
// Create or import an events map.
5
// See "getting started" pages for instructions.
6
7
SegmentAnalytics.setup(writeKey, options);
8
const Analytics = SegmentAnalytics;
9
10
const segment = Segment();
11
const segmentMiddleware = createMiddleware(eventsMap, segment);
Copied!

Event Definitions

Don't see your event listed? Please submit a pull request to the Redux Beacon repository with the missing event. Use the source of the existing event-helpers to guide your work. If you need any support feel free to make the pull request with all you're able to do. We can fill in the gaps from there.

pageView

Docs:

1
import { trackPageView } from '@redux-beacon/segment';
2
3
const pageView = trackPageView((action, prevState, nextState) => {
4
return {
5
name: /* (optional) */
6
properties: /* (optional) */
7
};
8
});
Copied!

event

Docs:

1
import { trackEvent } from '@redux-beacon/react-native-segment';
2
3
const event = trackEvent((action, prevState, nextState) => {
4
return {
5
name: /* fill me in */,
6
properties: /* (optional) */,
7
};
8
});
Copied!

alias

Docs:

1
import { setAlias } from '@redux-beacon/react-native-segment';
2
3
const alias = setAlias((action, prevState, nextState) => {
4
return {
5
userId: /* fill me in */,
6
};
7
});
Copied!

group

Docs:

1
import { setGroup } from '@redux-beacon/react-native-segment';
2
3
const group = setGroup((action, prevState, nextState) => {
4
return {
5
groupId: /* fill me in */,
6
traits: /* (optional) */,
7
};
8
});
Copied!

identify

Docs:

1
import { identifyUser } from '@redux-beacon/react-native-segment';
2
3
const user = identifyUser((action, prevState, nextState) => {
4
return {
5
userId: /* fill me in */,
6
traits: /* (optional) */,
7
};
8
});
Copied!

reset

Docs:

1
import { reset } from '@redux-beacon/react-native-segment';
2
3
const resetRequest = reset();
Copied!
Last modified 2yr ago