forked from Countly/countly-sdk-react-native
-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.android.js
161 lines (126 loc) · 5.64 KB
/
index.android.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
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
import React, { Component } from 'react'; // eslint-disable-line import/no-extraneous-dependencies
import { AppRegistry, Text, Button, ScrollView, Image } from 'react-native'; // eslint-disable-line import/no-extraneous-dependencies
import Countly from './Countly';
Countly.init('https://try.count.ly', '111dcd50d5f4a43a23202330cec19c069a68bc19');
class AwesomeProject extends Component {
// constructor(props) {
// super(props);
// }
onStart = () => {
Countly.start();
}
onStop = () => {
Countly.stop();
}
onSendUserData = () => {
// example for setUserData
const options = {};
options.name = 'Trinisoft Technologies';
options.username = 'trinisofttechnologies';
options.email = '[email protected]';
options.org = 'Trinisoft Technologies Pvt. Ltd.';
options.phone = '+91 812 840 2946';
options.picture = 'http://www.trinisofttechnologies.com/images/logo.png';
options.picturePath = '';
options.gender = 'M';
options.byear = 1989;
Countly.setUserData(options);
}
pushMessage = () => {
// implementation is pending
}
basicEvent = () => {
// example for basic event
const events = { eventName: 'basic_event', eventCount: 1 };
Countly.sendEvent(events);
}
eventWithSum = () => {
// example for event with sum
const events = { eventName: 'event_sum', eventCount: 1, eventSum: '0.99' };
Countly.sendEvent(events);
}
eventWithSegment = () => {
// example for event with segment
const events = { eventName: 'event_segment', eventCount: 1 };
events.segments = { Country: 'Turkey', Age: '28' };
Countly.sendEvent(events);
}
eventWithSumAndSegment = () => {
// example for event with segment and sum
const events = { eventName: 'event_segment_sum', eventCount: 1, eventSum: '0.99' };
events.segments = { Country: 'Turkey', Age: '28' };
Countly.sendEvent(events);
}
allEvent = () => {}
startEvent = () => {
Countly.startEvent('timedEvent');
}
endEvent = () => {
Countly.endEvent('timedEvent');
}
userDataSetProperty = () => {
Countly.userData.setProperty('keyName', 'keyValue');
}
userDataIncrement = () => {
Countly.userData.increment('keyName');
}
userDataIncrementBy = () => {
Countly.userData.incrementBy('keyName', 10);
}
userDataMultiply = () => {
Countly.userData.multiply('keyName', 20);
}
userDataSaveMax = () => {
Countly.userData.saveMax('keyName', 100);
}
userDataSaveMin = () => {
Countly.userData.saveMin('keyName', 50);
}
userDataSetOnce = () => {
Countly.userData.setOnce('keyName', 200);
}
changeDeviceId = () => {
Countly.changeDeviceId('123456');
}
enableParameterTamperingProtection = () => {
Countly.enableParameterTamperingProtection('salt');
}
render() {
return (
<ScrollView>
<Text style={[{ fontSize: 25, textAlign: 'center' }]}>Countly Cordova Demo App</Text>
<Image source={{ uri: 'https://count.ly/wp-content/uploads/2014/10/countly_logo_color.png' }} style={{ width: 300, height: 88 }} />
<Button onPress={this.onStart} title='Start' color='#5bbd72' />
<Button onPress={this.onStop} title='Stop' color='#d95c5c' />
<Text style={[{ textAlign: 'center' }]}>Events Start</Text>
<Button onPress={this.basicEvent} title='Basic Events' color='#e0e0e0' />
<Button onPress={this.eventWithSum} title='Event with Sum' color='#e0e0e0' />
<Button onPress={this.eventWithSegment} title='Event with Segment' color='#e0e0e0' />
<Button onPress={this.eventWithSumAndSegment} title='Even with Sum and Segment' color='#841584' />
<Button onPress={this.allEvent} title='All Event' color='#1b1c1d' />
<Button onPress={this.startEvent} title='Timed event: Start' color='#e0e0e0' />
<Button onPress={this.endEvent} title='Timed event: Stop' color='#e0e0e0' />
<Text style={[{ textAlign: 'center' }]}>Events End</Text>
<Text style={[{ textAlign: 'center' }]}>2017</Text>
<Text style={[{ textAlign: 'center' }]}>User Methods Start</Text>
<Button onPress={this.onSendUserData} title='Send Users Data' color='#00b5ad' />
<Button onPress={this.userDataSetProperty} title='UserData.setProperty' color='#00b5ad' />
<Button onPress={this.userDataIncrement} title='UserData.increment' color='#00b5ad' />
<Button onPress={this.userDataIncrementBy} title='UserData.incrementBy' color='#00b5ad' />
<Button onPress={this.userDataMultiply} title='UserData.multiply' color='#00b5ad' />
<Button onPress={this.userDataSaveMax} title='UserData.saveMax' color='#00b5ad' />
<Button onPress={this.userDataSaveMin} title='UserData.saveMin' color='#00b5ad' />
<Button onPress={this.userDataSetOnce} title='UserData.setOnce' color='#00b5ad' />
<Text style={[{ textAlign: 'center' }]}>User Methods End</Text>
<Text style={[{ textAlign: 'center' }]}>Other Methods Start</Text>
<Button onPress={() => { Countly.recordView('HomePage'); }} title='Record View: "HomePage"' color='#e0e0e0' />
<Button onPress={() => { Countly.recordView('Dashboard'); }} title='Record View: "Dashboard"' color='#e0e0e0' />
<Button onPress={this.pushMessage} title='Push Message' color='#00b5ad' />
<Button onPress={this.changeDeviceId} title='Change Device ID' color='#00b5ad' />
<Button onPress={this.enableParameterTamperingProtection} title='Enable Parameter Tapmering Protection' color='#00b5ad' />
<Text style={[{ textAlign: 'center' }]}>Other Methods End</Text>
</ScrollView>
);
}
}
AppRegistry.registerComponent('AwesomeProject', () => AwesomeProject);