-
Notifications
You must be signed in to change notification settings - Fork 13
/
events.html
279 lines (257 loc) · 12.4 KB
/
events.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
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<!-- The above 3 meta tags *must* come first in the head; any other head content must come *after* these tags -->
<meta name="description" content="">
<meta name="author" content="">
<link rel="shortcut icon" href="images/favicon.png">
<title>Countly Code Generator</title>
<!-- Bootstrap core CSS -->
<link href="css/bootstrap.min.css" rel="stylesheet">
<!-- IE10 viewport hack for Surface/desktop Windows 8 bug -->
<link href="css/ie10-viewport-bug-workaround.css" rel="stylesheet">
<!-- Custom styles for this template -->
<link href="css/style.css" rel="stylesheet">
<!-- HTML5 shim and Respond.js for IE8 support of HTML5 elements and media queries -->
<!--[if lt IE 9]>
<script src="https://oss.maxcdn.com/html5shiv/3.7.2/html5shiv.min.js"></script>
<script src="https://oss.maxcdn.com/respond/1.4.2/respond.min.js"></script>
<![endif]-->
</head>
<body>
<div class="jumbotron top">
<div class="container">
<div id="logo">
<span class="image"></span>
<span class="text">Code Generator</span>
</div>
</div>
</div>
<div class="container">
<div class="row">
<div class="col-md-12">
<p id="buttons">
<a href="index.html" id="back" class="btn btn-default">← Back</a>
</p>
<h2 class="text-center">Create event</h2>
</div>
</div>
<div class='section'>
<span class='label'>Provide event values</span>
<div class="row">
<div class="col-md-12">
<div class="form-group">
<label for='event-key'>Event name:</label>
<input type="text" class="form-control" id='event-key' placeholder="MyEvent">
</div>
</div><!-- /.col-lg-6 -->
</div>
<div class="row">
<div class="col-md-12">
<div class="form-group">
<label for="event-count">How many times/actions event happened:</label>
<input type="number" class="form-control" id="event-count" placeholder="1" value="1">
</div>
</div><!-- /.col-lg-6 -->
</div><!-- /.row -->
<div class="row">
<div class="col-md-12">
<div class="form-group">
<label for="event-sum">Provide sum, if it is a purchase event:</label>
<input type="number" class="form-control" id="event-sum" placeholder="2.99" step="0.01">
</div>
</div><!-- /.col-lg-6 -->
</div><!-- /.row -->
<div class="row">
<div class="col-md-12">
<div class="form-group">
<label for="event-dur">Provide duration, if it took some time for event to happen:</label>
<input type="number" class="form-control" id="event-dur" placeholder="100">
</div>
</div><!-- /.col-lg-6 -->
</div><!-- /.row -->
</div>
<div class='section segments'>
<span class='label'>Provide some optional segments</span>
<div class="row segment">
<a class="close close-button" aria-label="Close"><span aria-hidden="true">×</span></a>
<div class="col-md-6">
<div class="form-group">
<label>Segment Name:</label>
<input type="text" class="form-control segment-key" placeholder="screen">
</div>
</div><!-- /.col-lg-6 -->
<div class="col-md-6">
<div class="form-group">
<label>Segment Value:</label>
<input type="text" class="form-control segment-val" placeholder="Main Screen">
</div>
</div><!-- /.col-lg-6 -->
</div>
<p class='text-right'><button type="button" class="btn btn-default" id="add-segment">Add another
segment</button></p>
</div>
<div class="row" id='generate-code'>
<div class="col-md-12">
<p class='text-center'>
<div class="dropup">
<button class="btn btn-success dropdown-toggle" type="button" id="dropdownMenu"
data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
Generate for
<span class="caret"></span>
</button>
<ul class="dropdown-menu" aria-labelledby="dropdownMenu"></ul>
</div>
</p>
</div><!-- /.col-lg-6 -->
</div><!-- /.row -->
<footer>
<p><a href='http://count.ly'>Count.ly</a></p>
</footer>
</div> <!-- /container -->
<div class="modal fade" id="end-modal" tabindex="-1" role="dialog">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-label="Close"><span
aria-hidden="true">×</span></button>
<div class="btn-group" role="group" style="margin-bottom: 20px;">
<a href="" class="btn btn-default" target='_blank' id="sdk-repo">SDK Repository</a>
<a href="" class="btn btn-default" target='_blank' id="sdk-docs">SDK Documentation</a>
<a href="" class="btn btn-default" target='_blank' id="sdk-download">Download SDK</a>
</div>
<h4 class="modal-title text-center">Use this snippet to send an event to server</h4>
</div>
<div class="modal-body">
<p><textarea id='end-code' class="no-translate" readonly onclick="this.select();"></textarea></p>
</div>
<div class="modal-footer">
<p class='text-center'>
<button type="button" class="btn btn-success" id="copy"
data-clipboard-target="#end-code">Copy</button>
<button type="button" class="btn btn-success" id="download">Download</button>
<button type="button" class="btn btn-primary" id="gotit">Close</button>
</p>
</div>
</div>
</div>
</div>
<!-- Bootstrap core JavaScript
================================================== -->
<!-- Placed at the end of the document so the pages load faster -->
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.6.4/jquery.min.js"></script>
<script>window.jQuery || document.write('<script src="js/jquery.min.js"><\/script>')</script>
<script src="https://global.localizecdn.com/localize.js"></script>
<script src="js/bootstrap.min.js"></script>
<!-- IE10 viewport hack for Surface/desktop Windows 8 bug -->
<script src="js/ie10-viewport-bug-workaround.js"></script>
<script type="text/javascript" src="js/purify.min.js"></script>
<script src="js/sdks.js"></script>
<script src="js/events.js"></script>
<script src="js/common.js"></script>
<script src="js/Blob.js"></script>
<script src="js/FileSaver.min.js"></script>
<script src="js/clipboard.min.js"></script>
<script>
$(document).ready(function () {
// Purify the location.search to prevent possible xss attacks using DOMPurify version 2.3.10 (https://github.com/cure53/DOMPurify)
var paramsDirty = DOMPurify.sanitize(location.search);
var params = parseParams(paramsDirty);
if (params.sdk && sdks[params.sdk]) {
$("#generate-code .dropup").addClass("hidden");
$("#generate-code").append('<p class="text-center"><button type="button" class="btn btn-success" id="generate">Generate for ' + sdks[params.sdk].name + '</button></p>');
$("#buttons").append('<a href="users.html?sdk=' + params.sdk + '" id="next" class="btn btn-default">Next: Add user info →</a>');
$("#back").attr("href", "integration-" + params.sdk + ".html");
}
new Clipboard('#copy');
var exampleSegments = [
["screen", "Main Screen"],
["difficulty", "Hard"],
["mode", "Arcade"],
["template", "Default"],
["theme", "Dark"],
["style", "Surrealism"],
["state", "Off"]
];
var sdk;
function getRandomInt(min, max) {
return Math.floor(Math.random() * (max - min + 1)) + min;
}
function applyRandomSegmentExample(elem) {
var example = exampleSegments[getRandomInt(0, exampleSegments.length - 1)];
elem.find(".segment-key").attr("placeholder", example[0]);
elem.find(".segment-val").attr("placeholder", example[1]);
}
applyRandomSegmentExample($(".segment"));
$(".segments .segment:first .close-button").hide();
for (var slug in sdks) {
if (events[slug])
$(".dropdown-menu").append('<li><a href="#" id="' + slug + '">' + sdks[slug].name + '</a></li>');
}
$("#add-segment").click(function () {
var segment = $(".segments .segment:first").clone();
segment.find(".segment-key").val("");
segment.find(".segment-val").val("");
segment.find(".close-button").show();
applyRandomSegmentExample(segment);
segment.insertBefore($("#add-segment").parent());
});
$(".segments").on("click", ".close-button", function (e) {
$(this).parent().remove();
});
function generate(sdk) {
$(".alert").remove();
$("#sdk-repo").attr("href", sdks[sdk].repo);
$("#sdk-docs").attr("href", sdks[sdk].docs);
$("#sdk-download").attr("href", sdks[sdk].download);
var data = {};
data.key = $("#event-key").val();
if (data.key == "") {
$("#event-key").parent().prepend('<div class="alert alert-danger" role="alert">Please provide event name</div>');
return;
}
data.count = parseInt($("#event-count").val()) || 1;
if ($("#event-sum").val() != "") {
data.sum = parseFloat($("#event-sum").val());
}
if ($("#event-dur").val() != "") {
data.dur = parseInt($("#event-dur").val());
}
var hasSegments = false;
var segments = {};
$(".segment").each(function () {
if ($(this).find(".segment-key").val() != "" && $(this).find(".segment-val").val() != "") {
hasSegments = true;
segments[$(this).find(".segment-key").val()] = $(this).find(".segment-val").val();
}
});
if (hasSegments)
data.segmentation = segments;
$("#end-code").val(events[sdk](data));
$('#end-modal').modal();
}
$(".dropdown-menu li a").click(function () {
generate(this.id);
});
$("#generate").click(function () {
generate(params.sdk);
});
$("#gotit").click(function () {
$('#end-modal').modal('hide');
});
$("#download").click(function () {
var data = $("#end-code").val();
try {
var blob = new Blob([data], { type: "text/plain;charset=utf-8" });
saveAs(blob, sdk + "-event.txt");
} catch (e) {
alert(data);
}
});
});
</script>
</body>
</html>