ahoy_matey 3.0.3 → 3.0.4

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: f419dcbf9a609b54279c3f7fec485e9648d6bb7dca9441ebed35ffce1fc76a87
4
- data.tar.gz: e51698cead710cad07009c6dff6a17adf32006ebbd4ad70e068b40c89b7bfb00
3
+ metadata.gz: 141aeb0d7f78023ecefb04f274637e06c68d6d8af9ece0ac583d8cff701b59f9
4
+ data.tar.gz: f44945bbdad4be224a57b4e915175ef983c4c24ed28eca4accc8e5fcce171105
5
5
  SHA512:
6
- metadata.gz: 4299eda491463e09c8ce0da5effac893c57a0dec8328c833d4c07fbb49bf94b8604cf04efb437e8322445c93067a4e9b9b9c57f5711cd46d1eb785fa350ecbd7
7
- data.tar.gz: b5b8b2c0794170ca9a60e25d3db3eb4b744acafc2322b631724b7f218aed05222dcf4947d0cc6f345891c073deee6f73130635a4f24a249e0352be8c1dde53a6
6
+ metadata.gz: ee9f88551691cc6be92b5adf9bfd0495065e43510679a61377bc12082c44ac7b0cff544ca88b3157ec92d05432ff58e654b491c7e256eb2c6032b5517573e6e3
7
+ data.tar.gz: 45565919c04c0f7c05cf87d0ef0f35fedd867cbd7569ee72a613770efab6a0c7dac1d884d6d0830c4f28efcf475ece191e7d44cb3712b18454c30b0de1658a4d
@@ -1,3 +1,7 @@
1
+ ## 3.0.4 (2020-06-07)
2
+
3
+ - Updated Ahoy.js to 0.3.6
4
+
1
5
  ## 3.0.3 (2020-04-17)
2
6
 
3
7
  - Updated Ahoy.js to 0.3.5
data/README.md CHANGED
@@ -433,6 +433,28 @@ Ahoy.cookies = false
433
433
 
434
434
  Previously set cookies are automatically deleted.
435
435
 
436
+ ## Data Retention
437
+
438
+ Delete older data with:
439
+
440
+ ```ruby
441
+ Ahoy::Visit.where("started_at < ?", 2.years.ago).find_in_batches do |visits|
442
+ visit_ids = visits.map(&:id)
443
+ Ahoy::Event.where(visit_id: visit_ids).delete_all
444
+ Ahoy::Visit.where(id: visit_ids).delete_all
445
+ end
446
+ ```
447
+
448
+ Delete data for a specific user with:
449
+
450
+ ```ruby
451
+ user_id = 123
452
+ visit_ids = Ahoy::Visit.where(user_id: user_id).pluck(:id)
453
+ Ahoy::Event.where(visit_id: visit_ids).delete_all
454
+ Ahoy::Visit.where(id: visit_ids).delete_all
455
+ Ahoy::Event.where(user_id: user_id).delete_all
456
+ ```
457
+
436
458
  ## Development
437
459
 
438
460
  Ahoy is built with developers in mind. You can run the following code in your browser’s console.
@@ -1,3 +1,3 @@
1
1
  module Ahoy
2
- VERSION = "3.0.3"
2
+ VERSION = "3.0.4"
3
3
  end
@@ -2,7 +2,7 @@
2
2
  * Ahoy.js
3
3
  * Simple, powerful JavaScript analytics
4
4
  * https://github.com/ankane/ahoy.js
5
- * v0.3.5
5
+ * v0.3.6
6
6
  * MIT License
7
7
  */
8
8
 
@@ -60,7 +60,9 @@
60
60
  cookieDomain: null,
61
61
  headers: {},
62
62
  visitParams: {},
63
- withCredentials: false
63
+ withCredentials: false,
64
+ visitDuration: 4 * 60, // default 4 hours
65
+ visitorDuration: 2 * 365 * 24 * 60 // default 2 years
64
66
  };
65
67
 
66
68
  var ahoy = window.ahoy || window.Ahoy || {};
@@ -78,8 +80,6 @@
78
80
 
79
81
  var $ = window.jQuery || window.Zepto || window.$;
80
82
  var visitId, visitorId, track;
81
- var visitTtl = 4 * 60; // 4 hours
82
- var visitorTtl = 2 * 365 * 24 * 60; // 2 years
83
83
  var isReady = false;
84
84
  var queue = [];
85
85
  var canStringify = typeof(JSON) !== "undefined" && typeof(JSON.stringify) !== "undefined";
@@ -129,13 +129,13 @@
129
129
  isReady = true;
130
130
  }
131
131
 
132
- function ready(callback) {
132
+ ahoy.ready = function (callback) {
133
133
  if (isReady) {
134
134
  callback();
135
135
  } else {
136
136
  queue.push(callback);
137
137
  }
138
- }
138
+ };
139
139
 
140
140
  function matchesSelector(element, selector) {
141
141
  var matches = element.matches ||
@@ -252,7 +252,7 @@
252
252
  }
253
253
 
254
254
  function trackEvent(event) {
255
- ready( function () {
255
+ ahoy.ready( function () {
256
256
  sendRequest(eventsUrl(), eventData(event), function() {
257
257
  // remove from queue
258
258
  for (var i = 0; i < eventQueue.length; i++) {
@@ -267,7 +267,7 @@
267
267
  }
268
268
 
269
269
  function trackEventNow(event) {
270
- ready( function () {
270
+ ahoy.ready( function () {
271
271
  var data = eventData(event);
272
272
  var param = csrfParam();
273
273
  var token = csrfToken();
@@ -336,7 +336,7 @@
336
336
  } else {
337
337
  if (!visitId) {
338
338
  visitId = generateId();
339
- setCookie("ahoy_visit", visitId, visitTtl);
339
+ setCookie("ahoy_visit", visitId, config.visitDuration);
340
340
  }
341
341
 
342
342
  // make sure cookies are enabled
@@ -345,7 +345,7 @@
345
345
 
346
346
  if (!visitorId) {
347
347
  visitorId = generateId();
348
- setCookie("ahoy_visitor", visitorId, visitorTtl);
348
+ setCookie("ahoy_visitor", visitorId, config.visitorDuration);
349
349
  }
350
350
 
351
351
  var data = {
@@ -418,12 +418,12 @@
418
418
  js: true
419
419
  };
420
420
 
421
- ready( function () {
421
+ ahoy.ready( function () {
422
422
  if (config.cookies && !ahoy.getVisitId()) {
423
423
  createVisit();
424
424
  }
425
425
 
426
- ready( function () {
426
+ ahoy.ready( function () {
427
427
  log(event);
428
428
 
429
429
  event.visit_token = ahoy.getVisitId();
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ahoy_matey
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.0.3
4
+ version: 3.0.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Andrew Kane
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2020-04-17 00:00:00.000000000 Z
11
+ date: 2020-06-07 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport