forked from yelled3/react-native-segment-io-analytics
-
Notifications
You must be signed in to change notification settings - Fork 19
/
index.js
103 lines (90 loc) · 3.16 KB
/
index.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
/**
* @flow
*
* Created by Tal Kain <[email protected]>,
* and Ricky Reusser <[email protected]>,
* and Alex Rothberg
* and Tony Xiao
* Copyright (c) 2016 Fire Place Inc. All rights reserved.
*/
'use strict'
import {NativeModules} from 'react-native'
const NativeRNSegmentIOAnalytics = NativeModules.RNSegmentIOAnalytics
/**
* RNSegmentIOAnalytics is a React Native wrapper for the Segment.com Analytics SDK.
*/
export default {
/*
* Setting up the Segment IO Analytics service
*
* @param configKey https://segment.com/docs/libraries/ios/#configuration or https://segment.com/docs/libraries/android/#customizing-the-client
* @param flushAt https://segment.com/docs/libraries/ios/#flushing or https://segment.com/docs/libraries/android/#customizing-the-client
* @param shouldUseLocationServices https://segment.com/docs/libraries/ios/#location-services
*/
setup: function (configKey: string, flushAt: number = 20, shouldUseLocationServices: bool = false) {
NativeRNSegmentIOAnalytics.setup(configKey, flushAt, shouldUseLocationServices)
},
/*
* https://segment.com/docs/libraries/ios/#identify
* https://segment.com/docs/libraries/android/#identify
*/
identify: function (userId: string, traits: ?Object) {
NativeRNSegmentIOAnalytics.identify(userId, traits || {})
},
/*
* https://segment.com/docs/libraries/ios/#alias
* https://segment.com/docs/libraries/android/#alias
*/
alias: function (userId: string) {
NativeRNSegmentIOAnalytics.alias(userId)
},
/*
* https://segment.com/docs/libraries/ios/#track
* https://segment.com/docs/libraries/android/#track
*/
track: function (event: string, properties: ?Object) {
NativeRNSegmentIOAnalytics.track(event, properties || {})
},
/*
* https://segment.com/docs/libraries/ios/#screen
* https://segment.com/docs/libraries/android/#screen
*/
screen: function (screenName: string, properties: ?Object) {
NativeRNSegmentIOAnalytics.screen(screenName, properties || {})
},
/*
* https://segment.com/docs/libraries/ios/#reset
* https://segment.com/docs/libraries/android/#how-do-you-handle-unique-identifiers-
*/
reset: function () {
NativeRNSegmentIOAnalytics.reset()
},
/*
* https://segment.com/docs/libraries/ios/#flushing
* https://segment.com/docs/libraries/android/#how-does-the-library-queue-api-calls-
*/
flush: function () {
NativeRNSegmentIOAnalytics.flush()
},
/*
* https://segment.com/docs/libraries/ios/#logging
* https://segment.com/docs/libraries/android/#debugging
*/
debug: function (isEnabled: bool) {
NativeRNSegmentIOAnalytics.debug(isEnabled)
},
/*
* https://segment.com/docs/libraries/ios/#opt-out
* https://segment.com/docs/libraries/android/#context
*/
disable: function () {
NativeRNSegmentIOAnalytics.disable()
},
/*
* https://segment.com/docs/libraries/ios/#opt-out
* https://segment.com/docs/libraries/android/#context
*/
enable: function () {
NativeRNSegmentIOAnalytics.enable()
},
}