forked from Countly/countly-sdk-cordova
-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.html
289 lines (268 loc) · 10.8 KB
/
index.html
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
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
<!DOCTYPE html>
<!--
Licensed to the Apache Software Foundation (ASF) under one
or more contributor license agreements. See the NOTICE file
distributed with this work for additional information
regarding copyright ownership. The ASF licenses this file
to you under the Apache License, Version 2.0 (the
"License"); you may not use this file except in compliance
with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing,
software distributed under the License is distributed on an
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
KIND, either express or implied. See the License for the
specific language governing permissions and limitations
under the License.
-->
<html>
<head>
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
<meta charset="utf-8" />
<meta name="format-detection" content="telephone=no" />
<meta name="msapplication-tap-highlight" content="no" />
<link rel="stylesheet" type="text/css" href="https://cdnjs.cloudflare.com/ajax/libs/semantic-ui/1.11.8/semantic.min.css" />
<style type="text/css">
button {
margin-top: 20px !important;
margin-bottom: 20px !important;
}
</style>
<title>Countly Cordova Demo App</title>
</head>
<body>
<div class="app">
<h1 class="ui center aligned header">Countly Cordova Demo App</h1>
<img class="ui centered medium image" src="https://count.ly/wp-content/uploads/2014/10/countly_logo_color.png">
<button onclick="app.init()" class="fluid ui green button">Init</button>
<button onclick="app.start()" class="fluid ui green button">Start</button>
<button onclick="app.stop()" class="fluid ui red button">Stop</button>
<div class="ui horizontal divider">Events Start</div>
<button onclick="app.basicEvent()" class="fluid ui button">Basic Events</button>
<button onclick="app.eventWithSum()" class="fluid ui button">Event with Sum</button>
<button onclick="app.eventWithSegment()" class="fluid ui button">Event with Segment</button>
<button onclick="app.eventWithSum_Segment()" class="fluid ui button">Even with Sum and Segment</button>
<button onclick="app.event()" class="fluid ui black button">All Events</button>
<button onclick="app.startEvent('hello')" class="fluid ui button">Timed event: Start</button>
<button onclick="app.endEvent('hello')" class="fluid ui button">Timed event: Stop</button>
<div class="ui horizontal divider">Events End</div>
<button onclick="app.recordView('HomePage')" class="fluid ui button">Record View: "HomePage"</button>
<button onclick="app.recordView('Dashboard')" class="fluid ui button">Record View: "Dashboard"</button>
<div class="ui horizontal divider">2017</div>
<div class="ui horizontal divider">User Methods Start</div>
<button onclick="app.setUserData()" class="fluid ui button teal">Send Users Data</button>
<button onclick="app.userData.setProperty()" class="fluid ui button teal">UserData.setProperty</button>
<button onclick="app.userData.increment()" class="fluid ui button teal">UserData.increment</button>
<button onclick="app.userData.incrementBy()" class="fluid ui button teal">UserData.incrementBy</button>
<button onclick="app.userData.multiply()" class="fluid ui button teal">UserData.multiply</button>
<button onclick="app.userData.saveMax()" class="fluid ui button teal">UserData.saveMax</button>
<button onclick="app.userData.saveMin()" class="fluid ui button teal">UserData.saveMin</button>
<button onclick="app.userData.setOnce()" class="fluid ui button teal">UserData.setOnce</button>
<div class="ui horizontal divider">User Methods End</div>
<div class="ui horizontal divider">Other Methods Start</div>
<button onclick="app.onRegistrationId()" class="fluid ui button teal">Push Message</button>
<button onclick="app.changeDeviceId('123456')" class="fluid ui button">Change Device ID</button>
<button onclick="app.enableParameterTamperingProtection('123456')" class="fluid ui button">Enable Parameter Tapmering Protection</button>
<button onclick="app.setOptionalParametersForInitialization()" class="fluid ui button">City, State, and Location</button>
<div class="ui horizontal divider">Other Methods End</div>
</div>
<script type="text/javascript" src="cordova.js"></script>
<script type="text/javascript" src="Countly.js"></script>
<script type="text/javascript">
// // testing purpose only
// if(!window.device)
// device = {};
// device.platform = "android";
// //
app = {};
document.addEventListener("deviceready", function() {
// Countly.init("https://try.count.ly","0e8a00e8c01395a0af8be0e55da05a404bb23c3e");
// Countly.init("https://try.count.ly", "0e8a00e8c01395a0af8be0e55da05a404bb23c3e", "custom_device_id_123456");
// var isAdvertiseID = true;
// Countly.init("https://try.count.ly","0e8a00e8c01395a0af8be0e55da05a404bb23c3e", null, isAdvertiseID);
//replace your server ip/url // replace it with your "App Key"
// app.onRegistrationId();
// app.test();
// alert("deviceready");
}, false);
app.init = function(){
document.addEventListener("deviceready", function() {
Countly.init("https://try.count.ly","0e8a00e8c01395a0af8be0e55da05a404bb23c3e");
}, false);
};
app.test = function() {
app.onRegistrationId();
app.sendSampleEvent();
}
app.setOptionalParametersForInitialization = function(){
Countly.setOptionalParametersForInitialization({
city: "Tampa",
country: "US",
latitude: "28.006324",
longitude: "-82.7166183"
});
};
app.event = function() {
setInterval(function() {
app.sendSampleEvent();
}, 1000);
}
app.start = function() {
Countly.start();
}
app.stop = function() {
Countly.stop();
}
app.sendSampleEvent = function() {
app.basicEvent();
app.eventWithSum();
app.eventWithSegment();
app.eventWithSum_Segment();
}
app.basicEvent = function() {
// example for basic event
var events = {
"eventName": "basic_event",
"eventCount": 1
};
Countly.sendEvent(events);
}
app.eventWithSum = function() {
// example for event with sum
var events = {
"eventName": "event_sum",
"eventCount": 1,
"eventSum": "0.99"
};
Countly.sendEvent(events);
}
app.eventWithSegment = function() {
// example for event with segment
var events = {
"eventName": "event_segment",
"eventCount": 1
};
events.segments = {
"Country": "Turkey",
"Age": "28"
};
Countly.sendEvent(events);
}
app.eventWithSum_Segment = function() {
// example for event with segment and sum
var events = {
"eventName": "event_segment_sum",
"eventCount": 1,
"eventSum": "0.99"
};
events.segments = {
"Country": "Turkey",
"Age": "28"
};
Countly.sendEvent(events);
}
app.setUserData = function() {
// example for setUserData
var options = {};
options.name = "Trinisoft Technologies";
options.username = "trinisofttechnologies";
options.email = "trinisofttechnologies@gmail.com";
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"; // "F"
options.byear = 1989;
Countly.setUserData(options);
}
app.setloggingenabled = function() {
// example for setLoggingEnabled
Countly.setLoggingEnabled();
}
app.onRegistrationId = function() {
var push = PushNotification.init({
android: {
senderID: "12345679"
},
browser: {
pushServiceURL: 'http://push.api.phonegap.com/v1/push'
},
ios: {
alert: "true",
badge: "true",
sound: "true"
},
windows: {}
});
push.on('registration', function(data) {
Countly.onRegistrationId({
"registrationId": data.registrationId,
"mode": Countly.messagingMode.TEST,
"projectId": "881000050249" // only for google / android
})
// data.registrationId
});
push.on('notification', function(data) {
// data.message,
// data.title,
// data.count,
// data.sound,
// data.image,
// data.additionalData
});
push.on('error', function(e) {
// e.message
});
// Countly.messagingMode.TEST
// Countly.messagingMode.PRODUCTION
// Countly.mode = Countly.messagingMode.TEST;
// Countly.Push.onRegisterPushNotification();
// @depricated: The below commented method is depricated and no longer works.
// Countly.initMessaging({
// "messageMode": Countly.messagingMode.TEST,
// "projectId": "881000050249"
// });
// Tesing purpose only
}
app.recordView = function(viewName) {
Countly.recordView(viewName);
}
// 2017
app.changeDeviceId = function() {
Countly.changeDeviceId("123456");
}
app.enableParameterTamperingProtection = function() {
Countly.enableParameterTamperingProtection("salt");
}
app.startEvent = function() {
Countly.startEvent("timedEvent");
}
app.endEvent = function() {
Countly.endEvent("timedEvent");
}
// user details
app.userData = {};
app.userData.setProperty = function() {
Countly.userData.setProperty("keyName", "keyValue");
}
app.userData.increment = function() {
Countly.userData.increment("keyName");
}
app.userData.incrementBy = function() {
Countly.userData.incrementBy("keyName", 10);
}
app.userData.multiply = function() {
Countly.userData.multiply("keyName", 20);
}
app.userData.saveMax = function() {
Countly.userData.saveMax("keyName", 100);
}
app.userData.saveMin = function() {
Countly.userData.saveMin("keyName", 50);
}
app.userData.setOnce = function() {
Countly.userData.setOnce("keyName", 200);
}
</script>
</body>
</html>