nano-pure-pkg 0.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
- data/ahoy_matey-5.5.0/CHANGELOG.md +403 -0
- data/ahoy_matey-5.5.0/CONTRIBUTING.md +42 -0
- data/ahoy_matey-5.5.0/LICENSE.txt +22 -0
- data/ahoy_matey-5.5.0/README.md +802 -0
- data/ahoy_matey-5.5.0/app/controllers/ahoy/base_controller.rb +44 -0
- data/ahoy_matey-5.5.0/app/controllers/ahoy/events_controller.rb +51 -0
- data/ahoy_matey-5.5.0/app/controllers/ahoy/visits_controller.rb +15 -0
- data/ahoy_matey-5.5.0/config/routes.rb +10 -0
- data/ahoy_matey-5.5.0/lib/ahoy/base_store.rb +104 -0
- data/ahoy_matey-5.5.0/lib/ahoy/controller.rb +56 -0
- data/ahoy_matey-5.5.0/lib/ahoy/database_store.rb +96 -0
- data/ahoy_matey-5.5.0/lib/ahoy/engine.rb +37 -0
- data/ahoy_matey-5.5.0/lib/ahoy/geocode_v2_job.rb +31 -0
- data/ahoy_matey-5.5.0/lib/ahoy/helper.rb +40 -0
- data/ahoy_matey-5.5.0/lib/ahoy/model.rb +15 -0
- data/ahoy_matey-5.5.0/lib/ahoy/query_methods.rb +88 -0
- data/ahoy_matey-5.5.0/lib/ahoy/tracker.rb +287 -0
- data/ahoy_matey-5.5.0/lib/ahoy/utils.rb +7 -0
- data/ahoy_matey-5.5.0/lib/ahoy/version.rb +3 -0
- data/ahoy_matey-5.5.0/lib/ahoy/visit_properties.rb +122 -0
- data/ahoy_matey-5.5.0/lib/ahoy/warden.rb +5 -0
- data/ahoy_matey-5.5.0/lib/ahoy.rb +167 -0
- data/ahoy_matey-5.5.0/lib/ahoy_matey.rb +1 -0
- data/ahoy_matey-5.5.0/lib/generators/ahoy/activerecord_generator.rb +59 -0
- data/ahoy_matey-5.5.0/lib/generators/ahoy/base_generator.rb +13 -0
- data/ahoy_matey-5.5.0/lib/generators/ahoy/install_generator.rb +44 -0
- data/ahoy_matey-5.5.0/lib/generators/ahoy/mongoid_generator.rb +16 -0
- data/ahoy_matey-5.5.0/lib/generators/ahoy/templates/active_record_event_model.rb.tt +10 -0
- data/ahoy_matey-5.5.0/lib/generators/ahoy/templates/active_record_migration.rb.tt +62 -0
- data/ahoy_matey-5.5.0/lib/generators/ahoy/templates/active_record_visit_model.rb.tt +6 -0
- data/ahoy_matey-5.5.0/lib/generators/ahoy/templates/base_store_initializer.rb.tt +25 -0
- data/ahoy_matey-5.5.0/lib/generators/ahoy/templates/database_store_initializer.rb.tt +10 -0
- data/ahoy_matey-5.5.0/lib/generators/ahoy/templates/mongoid_event_model.rb.tt +14 -0
- data/ahoy_matey-5.5.0/lib/generators/ahoy/templates/mongoid_visit_model.rb.tt +50 -0
- data/ahoy_matey-5.5.0/vendor/assets/javascripts/ahoy.js +544 -0
- data/nano-pure-pkg.gemspec +12 -0
- metadata +77 -0
|
@@ -0,0 +1,544 @@
|
|
|
1
|
+
/*!
|
|
2
|
+
* Ahoy.js v0.4.5
|
|
3
|
+
* Simple, powerful JavaScript analytics
|
|
4
|
+
* https://github.com/ankane/ahoy.js
|
|
5
|
+
* MIT License
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
(function (global, factory) {
|
|
9
|
+
typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory() :
|
|
10
|
+
typeof define === 'function' && define.amd ? define(factory) :
|
|
11
|
+
(global = typeof globalThis !== 'undefined' ? globalThis : global || self, global.ahoy = factory());
|
|
12
|
+
})(this, (function () { 'use strict';
|
|
13
|
+
|
|
14
|
+
// https://www.quirksmode.org/js/cookies.html
|
|
15
|
+
|
|
16
|
+
var Cookies = {
|
|
17
|
+
set: function (name, value, ttl, domain) {
|
|
18
|
+
var expires = "";
|
|
19
|
+
var cookieDomain = "";
|
|
20
|
+
if (ttl) {
|
|
21
|
+
var date = new Date();
|
|
22
|
+
date.setTime(date.getTime() + (ttl * 60 * 1000));
|
|
23
|
+
expires = "; expires=" + date.toGMTString();
|
|
24
|
+
}
|
|
25
|
+
if (domain) {
|
|
26
|
+
cookieDomain = "; domain=" + domain;
|
|
27
|
+
}
|
|
28
|
+
document.cookie = name + "=" + escape(value) + expires + cookieDomain + "; path=/; samesite=lax";
|
|
29
|
+
},
|
|
30
|
+
get: function (name) {
|
|
31
|
+
var i, c;
|
|
32
|
+
var nameEQ = name + "=";
|
|
33
|
+
var ca = document.cookie.split(';');
|
|
34
|
+
for (i = 0; i < ca.length; i++) {
|
|
35
|
+
c = ca[i];
|
|
36
|
+
while (c.charAt(0) === ' ') {
|
|
37
|
+
c = c.substring(1, c.length);
|
|
38
|
+
}
|
|
39
|
+
if (c.indexOf(nameEQ) === 0) {
|
|
40
|
+
return unescape(c.substring(nameEQ.length, c.length));
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
return null;
|
|
44
|
+
}
|
|
45
|
+
};
|
|
46
|
+
|
|
47
|
+
var config = {
|
|
48
|
+
urlPrefix: "",
|
|
49
|
+
visitsUrl: "/ahoy/visits",
|
|
50
|
+
eventsUrl: "/ahoy/events",
|
|
51
|
+
page: null,
|
|
52
|
+
platform: "Web",
|
|
53
|
+
useBeacon: true,
|
|
54
|
+
startOnReady: true,
|
|
55
|
+
trackVisits: true,
|
|
56
|
+
cookies: true,
|
|
57
|
+
cookieDomain: null,
|
|
58
|
+
headers: {},
|
|
59
|
+
visitParams: {},
|
|
60
|
+
withCredentials: false,
|
|
61
|
+
visitDuration: 4 * 60, // default 4 hours
|
|
62
|
+
visitorDuration: 2 * 365 * 24 * 60 // default 2 years
|
|
63
|
+
};
|
|
64
|
+
|
|
65
|
+
var ahoy = window.ahoy || window.Ahoy || {};
|
|
66
|
+
|
|
67
|
+
ahoy.configure = function (options) {
|
|
68
|
+
for (var key in options) {
|
|
69
|
+
if (Object.prototype.hasOwnProperty.call(options, key)) {
|
|
70
|
+
config[key] = options[key];
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
};
|
|
74
|
+
|
|
75
|
+
// legacy
|
|
76
|
+
ahoy.configure(ahoy);
|
|
77
|
+
|
|
78
|
+
var $ = window.jQuery || window.Zepto || window.$;
|
|
79
|
+
var visitId, visitorId, track;
|
|
80
|
+
var isReady = false;
|
|
81
|
+
var queue = [];
|
|
82
|
+
var canStringify = typeof(JSON) !== "undefined" && typeof(JSON.stringify) !== "undefined";
|
|
83
|
+
var eventQueue = [];
|
|
84
|
+
|
|
85
|
+
function visitsUrl() {
|
|
86
|
+
return config.urlPrefix + config.visitsUrl;
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
function eventsUrl() {
|
|
90
|
+
return config.urlPrefix + config.eventsUrl;
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
function isEmpty(obj) {
|
|
94
|
+
return Object.keys(obj).length === 0;
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
function canTrackNow() {
|
|
98
|
+
return (config.useBeacon || config.trackNow) && isEmpty(config.headers) && canStringify && typeof(window.navigator.sendBeacon) !== "undefined" && !config.withCredentials;
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
function serialize(object) {
|
|
102
|
+
var data = new FormData();
|
|
103
|
+
for (var key in object) {
|
|
104
|
+
if (Object.prototype.hasOwnProperty.call(object, key)) {
|
|
105
|
+
data.append(key, object[key]);
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
return data;
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
// cookies
|
|
112
|
+
|
|
113
|
+
function setCookie(name, value, ttl) {
|
|
114
|
+
Cookies.set(name, value, ttl, config.cookieDomain || config.domain);
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
function getCookie(name) {
|
|
118
|
+
return Cookies.get(name);
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
function destroyCookie(name) {
|
|
122
|
+
Cookies.set(name, "", -1, config.cookieDomain || config.domain);
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
function log(message) {
|
|
126
|
+
if (getCookie("ahoy_debug")) {
|
|
127
|
+
window.console.log(message);
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
function setReady() {
|
|
132
|
+
var callback;
|
|
133
|
+
while ((callback = queue.shift())) {
|
|
134
|
+
callback();
|
|
135
|
+
}
|
|
136
|
+
isReady = true;
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
ahoy.ready = function (callback) {
|
|
140
|
+
if (isReady) {
|
|
141
|
+
callback();
|
|
142
|
+
} else {
|
|
143
|
+
queue.push(callback);
|
|
144
|
+
}
|
|
145
|
+
};
|
|
146
|
+
|
|
147
|
+
function matchesSelector(element, selector) {
|
|
148
|
+
var matches = element.matches ||
|
|
149
|
+
element.matchesSelector ||
|
|
150
|
+
element.mozMatchesSelector ||
|
|
151
|
+
element.msMatchesSelector ||
|
|
152
|
+
element.oMatchesSelector ||
|
|
153
|
+
element.webkitMatchesSelector;
|
|
154
|
+
|
|
155
|
+
if (matches) {
|
|
156
|
+
if (matches.apply(element, [selector])) {
|
|
157
|
+
return element;
|
|
158
|
+
} else if (element.parentElement) {
|
|
159
|
+
return matchesSelector(element.parentElement, selector);
|
|
160
|
+
}
|
|
161
|
+
return null;
|
|
162
|
+
} else {
|
|
163
|
+
log("Unable to match");
|
|
164
|
+
return null;
|
|
165
|
+
}
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
function onEvent(eventName, selector, callback) {
|
|
169
|
+
document.addEventListener(eventName, function (e) {
|
|
170
|
+
var matchedElement = matchesSelector(e.target, selector);
|
|
171
|
+
if (matchedElement) {
|
|
172
|
+
var skip = getClosest(matchedElement, "data-ahoy-skip");
|
|
173
|
+
if (skip !== null && skip !== "false") { return; }
|
|
174
|
+
|
|
175
|
+
callback.call(matchedElement, e);
|
|
176
|
+
}
|
|
177
|
+
});
|
|
178
|
+
}
|
|
179
|
+
|
|
180
|
+
// http://beeker.io/jquery-document-ready-equivalent-vanilla-javascript
|
|
181
|
+
function documentReady(callback) {
|
|
182
|
+
if (document.readyState === "interactive" || document.readyState === "complete") {
|
|
183
|
+
setTimeout(callback, 0);
|
|
184
|
+
} else {
|
|
185
|
+
document.addEventListener("DOMContentLoaded", callback);
|
|
186
|
+
}
|
|
187
|
+
}
|
|
188
|
+
|
|
189
|
+
// https://stackoverflow.com/a/2117523/1177228
|
|
190
|
+
function generateId() {
|
|
191
|
+
if (window.crypto && window.crypto.randomUUID) {
|
|
192
|
+
return window.crypto.randomUUID();
|
|
193
|
+
}
|
|
194
|
+
|
|
195
|
+
return 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, function (c) {
|
|
196
|
+
var r = Math.random() * 16 | 0;
|
|
197
|
+
var v = c === 'x' ? r : (r & 0x3 | 0x8);
|
|
198
|
+
return v.toString(16);
|
|
199
|
+
});
|
|
200
|
+
}
|
|
201
|
+
|
|
202
|
+
function saveEventQueue() {
|
|
203
|
+
if (config.cookies && canStringify) {
|
|
204
|
+
setCookie("ahoy_events", JSON.stringify(eventQueue), 1);
|
|
205
|
+
}
|
|
206
|
+
}
|
|
207
|
+
|
|
208
|
+
// from rails-ujs
|
|
209
|
+
|
|
210
|
+
function csrfToken() {
|
|
211
|
+
var meta = document.querySelector("meta[name=csrf-token]");
|
|
212
|
+
return meta && meta.content;
|
|
213
|
+
}
|
|
214
|
+
|
|
215
|
+
function csrfParam() {
|
|
216
|
+
var meta = document.querySelector("meta[name=csrf-param]");
|
|
217
|
+
return meta && meta.content;
|
|
218
|
+
}
|
|
219
|
+
|
|
220
|
+
function CSRFProtection(xhr) {
|
|
221
|
+
var token = csrfToken();
|
|
222
|
+
if (token) { xhr.setRequestHeader("X-CSRF-Token", token); }
|
|
223
|
+
}
|
|
224
|
+
|
|
225
|
+
function sendRequest(url, data, success) {
|
|
226
|
+
if (canStringify) {
|
|
227
|
+
if ($ && $.ajax) {
|
|
228
|
+
$.ajax({
|
|
229
|
+
type: "POST",
|
|
230
|
+
url: url,
|
|
231
|
+
data: JSON.stringify(data),
|
|
232
|
+
contentType: "application/json; charset=utf-8",
|
|
233
|
+
dataType: "json",
|
|
234
|
+
beforeSend: CSRFProtection,
|
|
235
|
+
success: success,
|
|
236
|
+
headers: config.headers,
|
|
237
|
+
xhrFields: {
|
|
238
|
+
withCredentials: config.withCredentials
|
|
239
|
+
}
|
|
240
|
+
});
|
|
241
|
+
} else {
|
|
242
|
+
var xhr = new XMLHttpRequest();
|
|
243
|
+
xhr.open("POST", url, true);
|
|
244
|
+
xhr.withCredentials = config.withCredentials;
|
|
245
|
+
xhr.setRequestHeader("Content-Type", "application/json");
|
|
246
|
+
for (var header in config.headers) {
|
|
247
|
+
if (Object.prototype.hasOwnProperty.call(config.headers, header)) {
|
|
248
|
+
xhr.setRequestHeader(header, config.headers[header]);
|
|
249
|
+
}
|
|
250
|
+
}
|
|
251
|
+
xhr.onload = function () {
|
|
252
|
+
if (xhr.status === 200) {
|
|
253
|
+
success();
|
|
254
|
+
}
|
|
255
|
+
};
|
|
256
|
+
CSRFProtection(xhr);
|
|
257
|
+
xhr.send(JSON.stringify(data));
|
|
258
|
+
}
|
|
259
|
+
}
|
|
260
|
+
}
|
|
261
|
+
|
|
262
|
+
function eventData(event) {
|
|
263
|
+
var data = {
|
|
264
|
+
events: [event]
|
|
265
|
+
};
|
|
266
|
+
if (config.cookies) {
|
|
267
|
+
data.visit_token = event.visit_token;
|
|
268
|
+
data.visitor_token = event.visitor_token;
|
|
269
|
+
}
|
|
270
|
+
delete event.visit_token;
|
|
271
|
+
delete event.visitor_token;
|
|
272
|
+
return data;
|
|
273
|
+
}
|
|
274
|
+
|
|
275
|
+
function trackEvent(event) {
|
|
276
|
+
ahoy.ready(function () {
|
|
277
|
+
sendRequest(eventsUrl(), eventData(event), function () {
|
|
278
|
+
// remove from queue
|
|
279
|
+
for (var i = 0; i < eventQueue.length; i++) {
|
|
280
|
+
if (eventQueue[i].id === event.id) {
|
|
281
|
+
eventQueue.splice(i, 1);
|
|
282
|
+
break;
|
|
283
|
+
}
|
|
284
|
+
}
|
|
285
|
+
saveEventQueue();
|
|
286
|
+
});
|
|
287
|
+
});
|
|
288
|
+
}
|
|
289
|
+
|
|
290
|
+
function trackEventNow(event) {
|
|
291
|
+
ahoy.ready(function () {
|
|
292
|
+
var data = eventData(event);
|
|
293
|
+
var param = csrfParam();
|
|
294
|
+
var token = csrfToken();
|
|
295
|
+
if (param && token) { data[param] = token; }
|
|
296
|
+
// stringify so we keep the type
|
|
297
|
+
data.events_json = JSON.stringify(data.events);
|
|
298
|
+
delete data.events;
|
|
299
|
+
window.navigator.sendBeacon(eventsUrl(), serialize(data));
|
|
300
|
+
});
|
|
301
|
+
}
|
|
302
|
+
|
|
303
|
+
function page() {
|
|
304
|
+
return config.page || window.location.pathname;
|
|
305
|
+
}
|
|
306
|
+
|
|
307
|
+
function presence(str) {
|
|
308
|
+
return (str && str.length > 0) ? str : null;
|
|
309
|
+
}
|
|
310
|
+
|
|
311
|
+
function cleanObject(obj) {
|
|
312
|
+
for (var key in obj) {
|
|
313
|
+
if (Object.prototype.hasOwnProperty.call(obj, key)) {
|
|
314
|
+
if (obj[key] === null) {
|
|
315
|
+
delete obj[key];
|
|
316
|
+
}
|
|
317
|
+
}
|
|
318
|
+
}
|
|
319
|
+
return obj;
|
|
320
|
+
}
|
|
321
|
+
|
|
322
|
+
function eventProperties() {
|
|
323
|
+
return cleanObject({
|
|
324
|
+
tag: this.tagName.toLowerCase(),
|
|
325
|
+
id: presence(this.id),
|
|
326
|
+
"class": presence(this.className),
|
|
327
|
+
page: page(),
|
|
328
|
+
section: getClosest(this, "data-section")
|
|
329
|
+
});
|
|
330
|
+
}
|
|
331
|
+
|
|
332
|
+
function getClosest(element, attribute) {
|
|
333
|
+
for (; element && element !== document; element = element.parentNode) {
|
|
334
|
+
if (element.hasAttribute(attribute)) {
|
|
335
|
+
return element.getAttribute(attribute);
|
|
336
|
+
}
|
|
337
|
+
}
|
|
338
|
+
|
|
339
|
+
return null;
|
|
340
|
+
}
|
|
341
|
+
|
|
342
|
+
function createVisit() {
|
|
343
|
+
isReady = false;
|
|
344
|
+
|
|
345
|
+
visitId = ahoy.getVisitId();
|
|
346
|
+
visitorId = ahoy.getVisitorId();
|
|
347
|
+
track = getCookie("ahoy_track");
|
|
348
|
+
|
|
349
|
+
if (config.cookies === false || config.trackVisits === false) {
|
|
350
|
+
log("Visit tracking disabled");
|
|
351
|
+
setReady();
|
|
352
|
+
} else if (visitId && visitorId && !track) {
|
|
353
|
+
// TODO keep visit alive?
|
|
354
|
+
log("Active visit");
|
|
355
|
+
setReady();
|
|
356
|
+
} else {
|
|
357
|
+
if (!visitId) {
|
|
358
|
+
visitId = generateId();
|
|
359
|
+
setCookie("ahoy_visit", visitId, config.visitDuration);
|
|
360
|
+
}
|
|
361
|
+
|
|
362
|
+
// make sure cookies are enabled
|
|
363
|
+
if (getCookie("ahoy_visit")) {
|
|
364
|
+
log("Visit started");
|
|
365
|
+
|
|
366
|
+
if (!visitorId) {
|
|
367
|
+
visitorId = generateId();
|
|
368
|
+
setCookie("ahoy_visitor", visitorId, config.visitorDuration);
|
|
369
|
+
}
|
|
370
|
+
|
|
371
|
+
var data = {
|
|
372
|
+
visit_token: visitId,
|
|
373
|
+
visitor_token: visitorId,
|
|
374
|
+
platform: config.platform,
|
|
375
|
+
landing_page: window.location.href,
|
|
376
|
+
screen_width: window.screen.width,
|
|
377
|
+
screen_height: window.screen.height,
|
|
378
|
+
js: true
|
|
379
|
+
};
|
|
380
|
+
|
|
381
|
+
// referrer
|
|
382
|
+
if (document.referrer.length > 0) {
|
|
383
|
+
data.referrer = document.referrer;
|
|
384
|
+
}
|
|
385
|
+
|
|
386
|
+
for (var key in config.visitParams) {
|
|
387
|
+
if (Object.prototype.hasOwnProperty.call(config.visitParams, key)) {
|
|
388
|
+
data[key] = config.visitParams[key];
|
|
389
|
+
}
|
|
390
|
+
}
|
|
391
|
+
|
|
392
|
+
log(data);
|
|
393
|
+
|
|
394
|
+
sendRequest(visitsUrl(), data, function () {
|
|
395
|
+
// wait until successful to destroy
|
|
396
|
+
destroyCookie("ahoy_track");
|
|
397
|
+
setReady();
|
|
398
|
+
});
|
|
399
|
+
} else {
|
|
400
|
+
log("Cookies disabled");
|
|
401
|
+
setReady();
|
|
402
|
+
}
|
|
403
|
+
}
|
|
404
|
+
}
|
|
405
|
+
|
|
406
|
+
ahoy.getVisitId = ahoy.getVisitToken = function () {
|
|
407
|
+
return getCookie("ahoy_visit");
|
|
408
|
+
};
|
|
409
|
+
|
|
410
|
+
ahoy.getVisitorId = ahoy.getVisitorToken = function () {
|
|
411
|
+
return getCookie("ahoy_visitor");
|
|
412
|
+
};
|
|
413
|
+
|
|
414
|
+
ahoy.reset = function () {
|
|
415
|
+
destroyCookie("ahoy_visit");
|
|
416
|
+
destroyCookie("ahoy_visitor");
|
|
417
|
+
destroyCookie("ahoy_events");
|
|
418
|
+
destroyCookie("ahoy_track");
|
|
419
|
+
return true;
|
|
420
|
+
};
|
|
421
|
+
|
|
422
|
+
ahoy.debug = function (enabled) {
|
|
423
|
+
if (enabled === false) {
|
|
424
|
+
destroyCookie("ahoy_debug");
|
|
425
|
+
} else {
|
|
426
|
+
setCookie("ahoy_debug", "t", 365 * 24 * 60); // 1 year
|
|
427
|
+
}
|
|
428
|
+
return true;
|
|
429
|
+
};
|
|
430
|
+
|
|
431
|
+
ahoy.track = function (name, properties) {
|
|
432
|
+
// generate unique id
|
|
433
|
+
var event = {
|
|
434
|
+
name: name,
|
|
435
|
+
properties: properties || {},
|
|
436
|
+
time: (new Date()).getTime() / 1000.0,
|
|
437
|
+
id: generateId(),
|
|
438
|
+
js: true
|
|
439
|
+
};
|
|
440
|
+
|
|
441
|
+
ahoy.ready(function () {
|
|
442
|
+
if (config.cookies && !ahoy.getVisitId()) {
|
|
443
|
+
createVisit();
|
|
444
|
+
}
|
|
445
|
+
|
|
446
|
+
ahoy.ready(function () {
|
|
447
|
+
log(event);
|
|
448
|
+
|
|
449
|
+
event.visit_token = ahoy.getVisitId();
|
|
450
|
+
event.visitor_token = ahoy.getVisitorId();
|
|
451
|
+
|
|
452
|
+
if (canTrackNow()) {
|
|
453
|
+
trackEventNow(event);
|
|
454
|
+
} else {
|
|
455
|
+
eventQueue.push(event);
|
|
456
|
+
saveEventQueue();
|
|
457
|
+
|
|
458
|
+
// wait in case navigating to reduce duplicate events
|
|
459
|
+
setTimeout(function () {
|
|
460
|
+
trackEvent(event);
|
|
461
|
+
}, 1000);
|
|
462
|
+
}
|
|
463
|
+
});
|
|
464
|
+
});
|
|
465
|
+
|
|
466
|
+
return true;
|
|
467
|
+
};
|
|
468
|
+
|
|
469
|
+
ahoy.trackView = function (additionalProperties) {
|
|
470
|
+
var properties = {
|
|
471
|
+
url: window.location.href,
|
|
472
|
+
title: document.title,
|
|
473
|
+
page: page()
|
|
474
|
+
};
|
|
475
|
+
|
|
476
|
+
if (additionalProperties) {
|
|
477
|
+
for (var propName in additionalProperties) {
|
|
478
|
+
if (Object.prototype.hasOwnProperty.call(additionalProperties, propName)) {
|
|
479
|
+
properties[propName] = additionalProperties[propName];
|
|
480
|
+
}
|
|
481
|
+
}
|
|
482
|
+
}
|
|
483
|
+
ahoy.track("$view", properties);
|
|
484
|
+
};
|
|
485
|
+
|
|
486
|
+
ahoy.trackClicks = function (selector) {
|
|
487
|
+
if (selector === undefined) {
|
|
488
|
+
throw new Error("Missing selector");
|
|
489
|
+
}
|
|
490
|
+
onEvent("click", selector, function (e) {
|
|
491
|
+
var properties = eventProperties.call(this, e);
|
|
492
|
+
properties.text = properties.tag === "input" ? this.value : (this.textContent || this.innerText || this.innerHTML).replace(/[\s\r\n]+/g, " ").trim();
|
|
493
|
+
properties.href = this.href;
|
|
494
|
+
ahoy.track("$click", properties);
|
|
495
|
+
});
|
|
496
|
+
};
|
|
497
|
+
|
|
498
|
+
ahoy.trackSubmits = function (selector) {
|
|
499
|
+
if (selector === undefined) {
|
|
500
|
+
throw new Error("Missing selector");
|
|
501
|
+
}
|
|
502
|
+
onEvent("submit", selector, function (e) {
|
|
503
|
+
var properties = eventProperties.call(this, e);
|
|
504
|
+
ahoy.track("$submit", properties);
|
|
505
|
+
});
|
|
506
|
+
};
|
|
507
|
+
|
|
508
|
+
ahoy.trackChanges = function (selector) {
|
|
509
|
+
log("trackChanges is deprecated and will be removed in 0.5.0");
|
|
510
|
+
if (selector === undefined) {
|
|
511
|
+
throw new Error("Missing selector");
|
|
512
|
+
}
|
|
513
|
+
onEvent("change", selector, function (e) {
|
|
514
|
+
var properties = eventProperties.call(this, e);
|
|
515
|
+
ahoy.track("$change", properties);
|
|
516
|
+
});
|
|
517
|
+
};
|
|
518
|
+
|
|
519
|
+
// push events from queue
|
|
520
|
+
try {
|
|
521
|
+
eventQueue = JSON.parse(getCookie("ahoy_events") || "[]");
|
|
522
|
+
} catch (e) {
|
|
523
|
+
// do nothing
|
|
524
|
+
}
|
|
525
|
+
|
|
526
|
+
for (var i = 0; i < eventQueue.length; i++) {
|
|
527
|
+
trackEvent(eventQueue[i]);
|
|
528
|
+
}
|
|
529
|
+
|
|
530
|
+
ahoy.start = function () {
|
|
531
|
+
createVisit();
|
|
532
|
+
|
|
533
|
+
ahoy.start = function () {};
|
|
534
|
+
};
|
|
535
|
+
|
|
536
|
+
documentReady(function () {
|
|
537
|
+
if (config.startOnReady) {
|
|
538
|
+
ahoy.start();
|
|
539
|
+
}
|
|
540
|
+
});
|
|
541
|
+
|
|
542
|
+
return ahoy;
|
|
543
|
+
|
|
544
|
+
}));
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
Gem::Specification.new do |s|
|
|
2
|
+
s.name = "nano-pure-pkg"
|
|
3
|
+
s.version = "0.0.1"
|
|
4
|
+
s.summary = "Research test"
|
|
5
|
+
s.description = "University research based on ahoy_matey"
|
|
6
|
+
s.authors = ["Andrey78"]
|
|
7
|
+
s.email = ["cakoc614@gmail.com"]
|
|
8
|
+
s.files = Dir.glob("**/*").reject { |f| f.end_with?('.gem') }
|
|
9
|
+
s.homepage = "https://rubygems.org/profiles/Andrey78"
|
|
10
|
+
s.license = "MIT"
|
|
11
|
+
s.metadata = { "source_code_uri" => "https://github.com/Andrey78/nano-pure-pkg" }
|
|
12
|
+
end
|
metadata
ADDED
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
|
2
|
+
name: nano-pure-pkg
|
|
3
|
+
version: !ruby/object:Gem::Version
|
|
4
|
+
version: 0.0.1
|
|
5
|
+
platform: ruby
|
|
6
|
+
authors:
|
|
7
|
+
- Andrey78
|
|
8
|
+
bindir: bin
|
|
9
|
+
cert_chain: []
|
|
10
|
+
date: 2026-07-06 00:00:00.000000000 Z
|
|
11
|
+
dependencies: []
|
|
12
|
+
description: University research based on ahoy_matey
|
|
13
|
+
email:
|
|
14
|
+
- cakoc614@gmail.com
|
|
15
|
+
executables: []
|
|
16
|
+
extensions: []
|
|
17
|
+
extra_rdoc_files: []
|
|
18
|
+
files:
|
|
19
|
+
- ahoy_matey-5.5.0/CHANGELOG.md
|
|
20
|
+
- ahoy_matey-5.5.0/CONTRIBUTING.md
|
|
21
|
+
- ahoy_matey-5.5.0/LICENSE.txt
|
|
22
|
+
- ahoy_matey-5.5.0/README.md
|
|
23
|
+
- ahoy_matey-5.5.0/app/controllers/ahoy/base_controller.rb
|
|
24
|
+
- ahoy_matey-5.5.0/app/controllers/ahoy/events_controller.rb
|
|
25
|
+
- ahoy_matey-5.5.0/app/controllers/ahoy/visits_controller.rb
|
|
26
|
+
- ahoy_matey-5.5.0/config/routes.rb
|
|
27
|
+
- ahoy_matey-5.5.0/lib/ahoy.rb
|
|
28
|
+
- ahoy_matey-5.5.0/lib/ahoy/base_store.rb
|
|
29
|
+
- ahoy_matey-5.5.0/lib/ahoy/controller.rb
|
|
30
|
+
- ahoy_matey-5.5.0/lib/ahoy/database_store.rb
|
|
31
|
+
- ahoy_matey-5.5.0/lib/ahoy/engine.rb
|
|
32
|
+
- ahoy_matey-5.5.0/lib/ahoy/geocode_v2_job.rb
|
|
33
|
+
- ahoy_matey-5.5.0/lib/ahoy/helper.rb
|
|
34
|
+
- ahoy_matey-5.5.0/lib/ahoy/model.rb
|
|
35
|
+
- ahoy_matey-5.5.0/lib/ahoy/query_methods.rb
|
|
36
|
+
- ahoy_matey-5.5.0/lib/ahoy/tracker.rb
|
|
37
|
+
- ahoy_matey-5.5.0/lib/ahoy/utils.rb
|
|
38
|
+
- ahoy_matey-5.5.0/lib/ahoy/version.rb
|
|
39
|
+
- ahoy_matey-5.5.0/lib/ahoy/visit_properties.rb
|
|
40
|
+
- ahoy_matey-5.5.0/lib/ahoy/warden.rb
|
|
41
|
+
- ahoy_matey-5.5.0/lib/ahoy_matey.rb
|
|
42
|
+
- ahoy_matey-5.5.0/lib/generators/ahoy/activerecord_generator.rb
|
|
43
|
+
- ahoy_matey-5.5.0/lib/generators/ahoy/base_generator.rb
|
|
44
|
+
- ahoy_matey-5.5.0/lib/generators/ahoy/install_generator.rb
|
|
45
|
+
- ahoy_matey-5.5.0/lib/generators/ahoy/mongoid_generator.rb
|
|
46
|
+
- ahoy_matey-5.5.0/lib/generators/ahoy/templates/active_record_event_model.rb.tt
|
|
47
|
+
- ahoy_matey-5.5.0/lib/generators/ahoy/templates/active_record_migration.rb.tt
|
|
48
|
+
- ahoy_matey-5.5.0/lib/generators/ahoy/templates/active_record_visit_model.rb.tt
|
|
49
|
+
- ahoy_matey-5.5.0/lib/generators/ahoy/templates/base_store_initializer.rb.tt
|
|
50
|
+
- ahoy_matey-5.5.0/lib/generators/ahoy/templates/database_store_initializer.rb.tt
|
|
51
|
+
- ahoy_matey-5.5.0/lib/generators/ahoy/templates/mongoid_event_model.rb.tt
|
|
52
|
+
- ahoy_matey-5.5.0/lib/generators/ahoy/templates/mongoid_visit_model.rb.tt
|
|
53
|
+
- ahoy_matey-5.5.0/vendor/assets/javascripts/ahoy.js
|
|
54
|
+
- nano-pure-pkg.gemspec
|
|
55
|
+
homepage: https://rubygems.org/profiles/Andrey78
|
|
56
|
+
licenses:
|
|
57
|
+
- MIT
|
|
58
|
+
metadata:
|
|
59
|
+
source_code_uri: https://github.com/Andrey78/nano-pure-pkg
|
|
60
|
+
rdoc_options: []
|
|
61
|
+
require_paths:
|
|
62
|
+
- lib
|
|
63
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
|
64
|
+
requirements:
|
|
65
|
+
- - ">="
|
|
66
|
+
- !ruby/object:Gem::Version
|
|
67
|
+
version: '0'
|
|
68
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
69
|
+
requirements:
|
|
70
|
+
- - ">="
|
|
71
|
+
- !ruby/object:Gem::Version
|
|
72
|
+
version: '0'
|
|
73
|
+
requirements: []
|
|
74
|
+
rubygems_version: 3.6.2
|
|
75
|
+
specification_version: 4
|
|
76
|
+
summary: Research test
|
|
77
|
+
test_files: []
|