ahoy_matey 3.0.2 → 3.0.3

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 0007d4286157e3456e73cd0fbcf9ac46905f7088caabd047f1514b4782a99432
4
- data.tar.gz: 3b036aa183d4a847df7b1c42be88ce968cffaa3ce9b14281fc05abce747addcc
3
+ metadata.gz: f419dcbf9a609b54279c3f7fec485e9648d6bb7dca9441ebed35ffce1fc76a87
4
+ data.tar.gz: e51698cead710cad07009c6dff6a17adf32006ebbd4ad70e068b40c89b7bfb00
5
5
  SHA512:
6
- metadata.gz: 6f74414728cdd0325ebe091894cc3300bfb889cd978cc15491c244682ca73c26294ce32585f9e91613bb69516eb80a867b7f968e249e4492beea3f83f298de6f
7
- data.tar.gz: 927cc957710268438b2b01379fe4f58f5f43840f465033cbac200b183396da14391fe4f90121781cd1c34fa574b1fa09987434259fe71f43c484c6b56ede9512
6
+ metadata.gz: 4299eda491463e09c8ce0da5effac893c57a0dec8328c833d4c07fbb49bf94b8604cf04efb437e8322445c93067a4e9b9b9c57f5711cd46d1eb785fa350ecbd7
7
+ data.tar.gz: b5b8b2c0794170ca9a60e25d3db3eb4b744acafc2322b631724b7f218aed05222dcf4947d0cc6f345891c073deee6f73130635a4f24a249e0352be8c1dde53a6
@@ -1,3 +1,7 @@
1
+ ## 3.0.3 (2020-04-17)
2
+
3
+ - Updated Ahoy.js to 0.3.5
4
+
1
5
  ## 3.0.2 (2020-04-03)
2
6
 
3
7
  - Added `cookie_options`
@@ -1,3 +1,3 @@
1
1
  module Ahoy
2
- VERSION = "3.0.2"
2
+ VERSION = "3.0.3"
3
3
  end
@@ -2,112 +2,17 @@
2
2
  * Ahoy.js
3
3
  * Simple, powerful JavaScript analytics
4
4
  * https://github.com/ankane/ahoy.js
5
- * v0.3.4
5
+ * v0.3.5
6
6
  * MIT License
7
7
  */
8
8
 
9
9
  (function (global, factory) {
10
10
  typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory() :
11
11
  typeof define === 'function' && define.amd ? define(factory) :
12
- (global.ahoy = factory());
12
+ (global = global || self, global.ahoy = factory());
13
13
  }(this, (function () { 'use strict';
14
14
 
15
- function isUndefined(value) {
16
- return value === undefined;
17
- }
18
-
19
- function isNull(value) {
20
- return value === null;
21
- }
22
-
23
- function isObject(value) {
24
- return value === Object(value);
25
- }
26
-
27
- function isArray(value) {
28
- return Array.isArray(value);
29
- }
30
-
31
- function isDate(value) {
32
- return value instanceof Date;
33
- }
34
-
35
- function isBlob(value) {
36
- return (
37
- value &&
38
- typeof value.size === 'number' &&
39
- typeof value.type === 'string' &&
40
- typeof value.slice === 'function'
41
- );
42
- }
43
-
44
- function isFile(value) {
45
- return (
46
- isBlob(value) &&
47
- (typeof value.lastModifiedDate === 'object' ||
48
- typeof value.lastModified === 'number') &&
49
- typeof value.name === 'string'
50
- );
51
- }
52
-
53
- function isFormData(value) {
54
- return value instanceof FormData;
55
- }
56
-
57
- function objectToFormData(obj, cfg, fd, pre) {
58
- if (isFormData(cfg)) {
59
- pre = fd;
60
- fd = cfg;
61
- cfg = null;
62
- }
63
-
64
- cfg = cfg || {};
65
- cfg.indices = isUndefined(cfg.indices) ? false : cfg.indices;
66
- cfg.nulls = isUndefined(cfg.nulls) ? true : cfg.nulls;
67
- fd = fd || new FormData();
68
-
69
- if (isUndefined(obj)) {
70
- return fd;
71
- } else if (isNull(obj)) {
72
- if (cfg.nulls) {
73
- fd.append(pre, '');
74
- }
75
- } else if (isArray(obj)) {
76
- if (!obj.length) {
77
- var key = pre + '[]';
78
-
79
- fd.append(key, '');
80
- } else {
81
- obj.forEach(function(value, index) {
82
- var key = pre + '[' + (cfg.indices ? index : '') + ']';
83
-
84
- objectToFormData(value, cfg, fd, key);
85
- });
86
- }
87
- } else if (isDate(obj)) {
88
- fd.append(pre, obj.toISOString());
89
- } else if (isObject(obj) && !isFile(obj) && !isBlob(obj)) {
90
- Object.keys(obj).forEach(function(prop) {
91
- var value = obj[prop];
92
-
93
- if (isArray(value)) {
94
- while (prop.length > 2 && prop.lastIndexOf('[]') === prop.length - 2) {
95
- prop = prop.substring(0, prop.length - 2);
96
- }
97
- }
98
-
99
- var key = pre ? pre + '[' + prop + ']' : prop;
100
-
101
- objectToFormData(value, cfg, fd, key);
102
- });
103
- } else {
104
- fd.append(pre, obj);
105
- }
106
-
107
- return fd;
108
- }
109
-
110
- var objectToFormdata = objectToFormData;
15
+ var n=function(n){return void 0===n},e=function(n){return Array.isArray(n)},t=function(n){return n&&"number"==typeof n.size&&"string"==typeof n.type&&"function"==typeof n.slice},s=function(o,i,r,f){return (i=i||{}).indices=!n(i.indices)&&i.indices,i.nullsAsUndefineds=!n(i.nullsAsUndefineds)&&i.nullsAsUndefineds,i.booleansAsIntegers=!n(i.booleansAsIntegers)&&i.booleansAsIntegers,r=r||new FormData,n(o)?r:(null===o?i.nullsAsUndefineds||r.append(f,""):"boolean"!=typeof o?e(o)?o.length&&o.forEach(function(n,e){s(n,i,r,f+"["+(i.indices?e:"")+"]");}):o instanceof Date?r.append(f,o.toISOString()):o!==Object(o)||function(n){return t(n)&&"string"==typeof n.name&&("object"==typeof n.lastModifiedDate||"number"==typeof n.lastModified)}(o)||t(o)?r.append(f,o):Object.keys(o).forEach(function(n){var t=o[n];if(e(t)){ for(;n.length>2&&n.lastIndexOf("[]")===n.length-2;){ n=n.substring(0,n.length-2); } }s(t,i,r,f?f+"["+n+"]":n);}):r.append(f,i.booleansAsIntegers?o?1:0:o),r)};
111
16
 
112
17
  // https://www.quirksmode.org/js/cookies.html
113
18
 
@@ -258,7 +163,11 @@
258
163
 
259
164
  // http://beeker.io/jquery-document-ready-equivalent-vanilla-javascript
260
165
  function documentReady(callback) {
261
- document.readyState === "interactive" || document.readyState === "complete" ? callback() : document.addEventListener("DOMContentLoaded", callback);
166
+ if (document.readyState === "interactive" || document.readyState === "complete") {
167
+ setTimeout(callback, 0);
168
+ } else {
169
+ document.addEventListener("DOMContentLoaded", callback);
170
+ }
262
171
  }
263
172
 
264
173
  // https://stackoverflow.com/a/2117523/1177228
@@ -294,7 +203,7 @@
294
203
 
295
204
  function sendRequest(url, data, success) {
296
205
  if (canStringify) {
297
- if ($) {
206
+ if ($ && $.ajax) {
298
207
  $.ajax({
299
208
  type: "POST",
300
209
  url: url,
@@ -366,7 +275,7 @@
366
275
  // stringify so we keep the type
367
276
  data.events_json = JSON.stringify(data.events);
368
277
  delete data.events;
369
- window.navigator.sendBeacon(eventsUrl(), objectToFormdata(data));
278
+ window.navigator.sendBeacon(eventsUrl(), s(data));
370
279
  });
371
280
  }
372
281
 
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.2
4
+ version: 3.0.3
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-04 00:00:00.000000000 Z
11
+ date: 2020-04-17 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport