1 |
|
2 |
|
3 | import { NativeModules, Platform } from 'react-native';
|
4 |
|
5 | const { ExponentSegment } = NativeModules;
|
6 |
|
7 | export default {
|
8 | initialize(options: { androidWriteKey?: string, iosWriteKey?: string }): void {
|
9 | if (Platform.OS === 'android') {
|
10 | return ExponentSegment.initializeAndroid(options.androidWriteKey);
|
11 | } else if (Platform.OS === 'ios') {
|
12 | return ExponentSegment.initializeIOS(options.iosWriteKey);
|
13 | } else {
|
14 | throw new Error(`Unable to initialize Segment on \`${Platform.OS}\``);
|
15 | }
|
16 | },
|
17 |
|
18 | identify(userId: string): void {
|
19 | return ExponentSegment.identify(userId);
|
20 | },
|
21 |
|
22 | identifyWithTraits(userId: string, traits: { [string]: any }): void {
|
23 | return ExponentSegment.identifyWithTraits(userId, traits);
|
24 | },
|
25 |
|
26 | reset(): void {
|
27 | return ExponentSegment.reset();
|
28 | },
|
29 |
|
30 | track(event: string): void {
|
31 | return ExponentSegment.track((event: string));
|
32 | },
|
33 |
|
34 | trackWithProperties(event: string, properties: { [string]: any }): void {
|
35 | return ExponentSegment.trackWithProperties(event, properties);
|
36 | },
|
37 |
|
38 | screen(screenName: string): void {
|
39 | return ExponentSegment.screen(screenName);
|
40 | },
|
41 |
|
42 | screenWithProperties(event: string, properties: string): void {
|
43 | return ExponentSegment.screenWithProperties(event, properties);
|
44 | },
|
45 |
|
46 | flush(): void {
|
47 | return ExponentSegment.flush();
|
48 | },
|
49 | };
|