analytics-client
Advanced tools
Comparing version 0.1.0-roman-url-params-5836fbb91baa905b7226b295b063856e47caceb6 to 0.1.0-roman-url-params-ad69d6499854bfb48212dcc2eb77c126039362b7
@@ -9,2 +9,3 @@ # Change Log | ||
* Avoid calling mixpanel in constructor [Roman Mazur] | ||
* Add URL query string tools [Roman Mazur] |
@@ -1,1 +0,1 @@ | ||
var analyticsClient=function(t){var n={};function r(e){if(n[e])return n[e].exports;var o=n[e]={i:e,l:!1,exports:{}};return t[e].call(o.exports,o,o.exports,r),o.l=!0,o.exports}return r.m=t,r.c=n,r.d=function(t,n,e){r.o(t,n)||Object.defineProperty(t,n,{enumerable:!0,get:e})},r.r=function(t){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})},r.t=function(t,n){if(1&n&&(t=r(t)),8&n)return t;if(4&n&&"object"==typeof t&&t&&t.__esModule)return t;var e=Object.create(null);if(r.r(e),Object.defineProperty(e,"default",{enumerable:!0,value:t}),2&n&&"string"!=typeof t)for(var o in t)r.d(e,o,function(n){return t[n]}.bind(null,o));return e},r.n=function(t){var n=t&&t.__esModule?function(){return t.default}:function(){return t};return r.d(n,"a",n),n},r.o=function(t,n){return Object.prototype.hasOwnProperty.call(t,n)},r.p="",r(r.s=12)}([function(t,n,r){var e=r(19),o="object"==typeof self&&self&&self.Object===Object&&self,i=e||o||Function("return this")();t.exports=i},function(t,n,r){var e=r(33),o=r(37);t.exports=function(t,n){var r=o(t,n);return e(r)?r:void 0}},function(t,n,r){var e=r(1)(Object,"create");t.exports=e},function(t,n,r){var e=r(52);t.exports=function(t,n){for(var r=t.length;r--;)if(e(t[r][0],n))return r;return-1}},function(t,n,r){var e=r(58);t.exports=function(t,n){var r=t.__data__;return e(n)?r["string"==typeof n?"string":"hash"]:r.map}},function(t,n,r){var e=r(0).Symbol;t.exports=e},function(t,n){t.exports=function(t){return null!=t&&"object"==typeof t}},function(t,n,r){var e=r(5),o=r(23),i=r(24),u="[object Null]",c="[object Undefined]",a=e?e.toStringTag:void 0;t.exports=function(t){return null==t?void 0===t?c:u:a&&a in Object(t)?o(t):i(t)}},function(t,n){t.exports=function(t){return t}},function(t,n,r){var e=r(7),o=r(10),i="[object AsyncFunction]",u="[object Function]",c="[object GeneratorFunction]",a="[object Proxy]";t.exports=function(t){if(!o(t))return!1;var n=e(t);return n==u||n==c||n==i||n==a}},function(t,n){t.exports=function(t){var n=typeof t;return null!=t&&("object"==n||"function"==n)}},function(t,n){t.exports=function(t){var n=-1,r=Array(t.size);return t.forEach((function(t){r[++n]=t})),r}},function(t,n,r){"use strict";Object.defineProperty(n,"__esModule",{value:!0});var e=r(13);n.AnalyticsUrlParams=e.AnalyticsUrlParams},function(t,n,r){"use strict";var e=this&&this.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(n,"__esModule",{value:!0});var o=r(14),i=e(r(15)),u="__analytics_dids",c=/\s*,\s*/,a=function(){function t(t){this.mixpanel=t,this.cookiesSupported=o.hasCookieSupport();var n=this.cookiesSupported?o.getCookie(u):null;this.setDeviceIds(n,this.mixpanel?this.mixpanel.get_distinct_id():null)}return t.prototype.setDeviceIds=function(t,n){var r=t?t.split(c):[];return n&&r.push(n),this.deviceIds=i.default(this.deviceIds,r),this.cookiesSupported&&o.setCookie(u,this.deviceIds.join(",")),r.length>0?r[0]:null},t.prototype.clearCookies=function(){this.cookiesSupported&&o.setCookie(u,"")},t.prototype.consumeUrlParameters=function(t){var n=new URLSearchParams(t),r=n.get("d_id");if(r){var e=null!=this.mixpanel?this.mixpanel.get_distinct_id():null,o=this.setDeviceIds(r,e);return null!=this.mixpanel&&o&&this.mixpanel.register({distinct_id:o,$device_id:o}),n.delete("d_id"),n.toString()}return null},t.prototype.allDeviceIds=function(){return this.deviceIds},t.prototype.getDeviceIdsQueryString=function(){var t=this.allDeviceIds();return 0===t.length?"":"d_id="+encodeURIComponent(t.join(","))},t}();n.AnalyticsUrlParams=a},function(t,n,r){"use strict";function e(t,n,r,e,o,i){if("undefined"!=typeof window)return arguments.length>1?document.cookie="".concat(t,"=").concat(encodeURIComponent(n)).concat(r?"; expires=".concat(new Date(+new Date+1e3*r).toUTCString()):"").concat(e?"; path=".concat(e):"").concat(o?"; domain=".concat(o):"").concat(i?"; secure":""):decodeURIComponent(("; ".concat(document.cookie).split("; ".concat(t,"="))[1]||"").split(";")[0])}function o(){try{e("___c","1");var t=-1!==document.cookie.indexOf("___c");return e("___c","",-1),t}catch(t){return!1}}r.r(n),r.d(n,"hasCookieSupport",(function(){return o})),r.d(n,"setCookie",(function(){return u})),r.d(n,"getCookie",(function(){return i})),r.d(n,"removeCookie",(function(){return c}));var i=e,u=e;function c(t){return e(t,"",-1)}},function(t,n,r){var e=r(16),o=r(26),i=r(39),u=r(74),c=o((function(t){return i(e(t,1,u,!0))}));t.exports=c},function(t,n,r){var e=r(17),o=r(18);t.exports=function t(n,r,i,u,c){var a=-1,s=n.length;for(i||(i=o),c||(c=[]);++a<s;){var f=n[a];r>0&&i(f)?r>1?t(f,r-1,i,u,c):e(c,f):u||(c[c.length]=f)}return c}},function(t,n){t.exports=function(t,n){for(var r=-1,e=n.length,o=t.length;++r<e;)t[o+r]=n[r];return t}},function(t,n,r){var e=r(5),o=r(21),i=r(25),u=e?e.isConcatSpreadable:void 0;t.exports=function(t){return i(t)||o(t)||!!(u&&t&&t[u])}},function(t,n,r){(function(n){var r="object"==typeof n&&n&&n.Object===Object&&n;t.exports=r}).call(this,r(20))},function(t,n){var r;r=function(){return this}();try{r=r||new Function("return this")()}catch(t){"object"==typeof window&&(r=window)}t.exports=r},function(t,n,r){var e=r(22),o=r(6),i=Object.prototype,u=i.hasOwnProperty,c=i.propertyIsEnumerable,a=e(function(){return arguments}())?e:function(t){return o(t)&&u.call(t,"callee")&&!c.call(t,"callee")};t.exports=a},function(t,n,r){var e=r(7),o=r(6),i="[object Arguments]";t.exports=function(t){return o(t)&&e(t)==i}},function(t,n,r){var e=r(5),o=Object.prototype,i=o.hasOwnProperty,u=o.toString,c=e?e.toStringTag:void 0;t.exports=function(t){var n=i.call(t,c),r=t[c];try{t[c]=void 0;var e=!0}catch(t){}var o=u.call(t);return e&&(n?t[c]=r:delete t[c]),o}},function(t,n){var r=Object.prototype.toString;t.exports=function(t){return r.call(t)}},function(t,n){var r=Array.isArray;t.exports=r},function(t,n,r){var e=r(8),o=r(27),i=r(29);t.exports=function(t,n){return i(o(t,n,e),t+"")}},function(t,n,r){var e=r(28),o=Math.max;t.exports=function(t,n,r){return n=o(void 0===n?t.length-1:n,0),function(){for(var i=arguments,u=-1,c=o(i.length-n,0),a=Array(c);++u<c;)a[u]=i[n+u];u=-1;for(var s=Array(n+1);++u<n;)s[u]=i[u];return s[n]=r(a),e(t,this,s)}}},function(t,n){t.exports=function(t,n,r){switch(r.length){case 0:return t.call(n);case 1:return t.call(n,r[0]);case 2:return t.call(n,r[0],r[1]);case 3:return t.call(n,r[0],r[1],r[2])}return t.apply(n,r)}},function(t,n,r){var e=r(30),o=r(38)(e);t.exports=o},function(t,n,r){var e=r(31),o=r(32),i=r(8),u=o?function(t,n){return o(t,"toString",{configurable:!0,enumerable:!1,value:e(n),writable:!0})}:i;t.exports=u},function(t,n){t.exports=function(t){return function(){return t}}},function(t,n,r){var e=r(1),o=function(){try{var t=e(Object,"defineProperty");return t({},"",{}),t}catch(t){}}();t.exports=o},function(t,n,r){var e=r(9),o=r(34),i=r(10),u=r(36),c=/^\[object .+?Constructor\]$/,a=Function.prototype,s=Object.prototype,f=a.toString,p=s.hasOwnProperty,l=RegExp("^"+f.call(p).replace(/[\\^$.*+?()[\]{}|]/g,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$");t.exports=function(t){return!(!i(t)||o(t))&&(e(t)?l:c).test(u(t))}},function(t,n,r){var e,o=r(35),i=(e=/[^.]+$/.exec(o&&o.keys&&o.keys.IE_PROTO||""))?"Symbol(src)_1."+e:"";t.exports=function(t){return!!i&&i in t}},function(t,n,r){var e=r(0)["__core-js_shared__"];t.exports=e},function(t,n){var r=Function.prototype.toString;t.exports=function(t){if(null!=t){try{return r.call(t)}catch(t){}try{return t+""}catch(t){}}return""}},function(t,n){t.exports=function(t,n){return null==t?void 0:t[n]}},function(t,n){var r=800,e=16,o=Date.now;t.exports=function(t){var n=0,i=0;return function(){var u=o(),c=e-(u-i);if(i=u,c>0){if(++n>=r)return arguments[0]}else n=0;return t.apply(void 0,arguments)}}},function(t,n,r){var e=r(40),o=r(64),i=r(69),u=r(70),c=r(71),a=r(11),s=200;t.exports=function(t,n,r){var f=-1,p=o,l=t.length,v=!0,h=[],d=h;if(r)v=!1,p=i;else if(l>=s){var _=n?null:c(t);if(_)return a(_);v=!1,p=u,d=new e}else d=n?[]:h;t:for(;++f<l;){var x=t[f],y=n?n(x):x;if(x=r||0!==x?x:0,v&&y==y){for(var g=d.length;g--;)if(d[g]===y)continue t;n&&d.push(y),h.push(x)}else p(d,y,r)||(d!==h&&d.push(y),h.push(x))}return h}},function(t,n,r){var e=r(41),o=r(62),i=r(63);function u(t){var n=-1,r=null==t?0:t.length;for(this.__data__=new e;++n<r;)this.add(t[n])}u.prototype.add=u.prototype.push=o,u.prototype.has=i,t.exports=u},function(t,n,r){var e=r(42),o=r(57),i=r(59),u=r(60),c=r(61);function a(t){var n=-1,r=null==t?0:t.length;for(this.clear();++n<r;){var e=t[n];this.set(e[0],e[1])}}a.prototype.clear=e,a.prototype.delete=o,a.prototype.get=i,a.prototype.has=u,a.prototype.set=c,t.exports=a},function(t,n,r){var e=r(43),o=r(49),i=r(56);t.exports=function(){this.size=0,this.__data__={hash:new e,map:new(i||o),string:new e}}},function(t,n,r){var e=r(44),o=r(45),i=r(46),u=r(47),c=r(48);function a(t){var n=-1,r=null==t?0:t.length;for(this.clear();++n<r;){var e=t[n];this.set(e[0],e[1])}}a.prototype.clear=e,a.prototype.delete=o,a.prototype.get=i,a.prototype.has=u,a.prototype.set=c,t.exports=a},function(t,n,r){var e=r(2);t.exports=function(){this.__data__=e?e(null):{},this.size=0}},function(t,n){t.exports=function(t){var n=this.has(t)&&delete this.__data__[t];return this.size-=n?1:0,n}},function(t,n,r){var e=r(2),o="__lodash_hash_undefined__",i=Object.prototype.hasOwnProperty;t.exports=function(t){var n=this.__data__;if(e){var r=n[t];return r===o?void 0:r}return i.call(n,t)?n[t]:void 0}},function(t,n,r){var e=r(2),o=Object.prototype.hasOwnProperty;t.exports=function(t){var n=this.__data__;return e?void 0!==n[t]:o.call(n,t)}},function(t,n,r){var e=r(2),o="__lodash_hash_undefined__";t.exports=function(t,n){var r=this.__data__;return this.size+=this.has(t)?0:1,r[t]=e&&void 0===n?o:n,this}},function(t,n,r){var e=r(50),o=r(51),i=r(53),u=r(54),c=r(55);function a(t){var n=-1,r=null==t?0:t.length;for(this.clear();++n<r;){var e=t[n];this.set(e[0],e[1])}}a.prototype.clear=e,a.prototype.delete=o,a.prototype.get=i,a.prototype.has=u,a.prototype.set=c,t.exports=a},function(t,n){t.exports=function(){this.__data__=[],this.size=0}},function(t,n,r){var e=r(3),o=Array.prototype.splice;t.exports=function(t){var n=this.__data__,r=e(n,t);return!(r<0)&&(r==n.length-1?n.pop():o.call(n,r,1),--this.size,!0)}},function(t,n){t.exports=function(t,n){return t===n||t!=t&&n!=n}},function(t,n,r){var e=r(3);t.exports=function(t){var n=this.__data__,r=e(n,t);return r<0?void 0:n[r][1]}},function(t,n,r){var e=r(3);t.exports=function(t){return e(this.__data__,t)>-1}},function(t,n,r){var e=r(3);t.exports=function(t,n){var r=this.__data__,o=e(r,t);return o<0?(++this.size,r.push([t,n])):r[o][1]=n,this}},function(t,n,r){var e=r(1)(r(0),"Map");t.exports=e},function(t,n,r){var e=r(4);t.exports=function(t){var n=e(this,t).delete(t);return this.size-=n?1:0,n}},function(t,n){t.exports=function(t){var n=typeof t;return"string"==n||"number"==n||"symbol"==n||"boolean"==n?"__proto__"!==t:null===t}},function(t,n,r){var e=r(4);t.exports=function(t){return e(this,t).get(t)}},function(t,n,r){var e=r(4);t.exports=function(t){return e(this,t).has(t)}},function(t,n,r){var e=r(4);t.exports=function(t,n){var r=e(this,t),o=r.size;return r.set(t,n),this.size+=r.size==o?0:1,this}},function(t,n){var r="__lodash_hash_undefined__";t.exports=function(t){return this.__data__.set(t,r),this}},function(t,n){t.exports=function(t){return this.__data__.has(t)}},function(t,n,r){var e=r(65);t.exports=function(t,n){return!!(null==t?0:t.length)&&e(t,n,0)>-1}},function(t,n,r){var e=r(66),o=r(67),i=r(68);t.exports=function(t,n,r){return n==n?i(t,n,r):e(t,o,r)}},function(t,n){t.exports=function(t,n,r,e){for(var o=t.length,i=r+(e?1:-1);e?i--:++i<o;)if(n(t[i],i,t))return i;return-1}},function(t,n){t.exports=function(t){return t!=t}},function(t,n){t.exports=function(t,n,r){for(var e=r-1,o=t.length;++e<o;)if(t[e]===n)return e;return-1}},function(t,n){t.exports=function(t,n,r){for(var e=-1,o=null==t?0:t.length;++e<o;)if(r(n,t[e]))return!0;return!1}},function(t,n){t.exports=function(t,n){return t.has(n)}},function(t,n,r){var e=r(72),o=r(73),i=r(11),u=e&&1/i(new e([,-0]))[1]==1/0?function(t){return new e(t)}:o;t.exports=u},function(t,n,r){var e=r(1)(r(0),"Set");t.exports=e},function(t,n){t.exports=function(){}},function(t,n,r){var e=r(75),o=r(6);t.exports=function(t){return o(t)&&e(t)}},function(t,n,r){var e=r(9),o=r(76);t.exports=function(t){return null!=t&&o(t.length)&&!e(t)}},function(t,n){var r=9007199254740991;t.exports=function(t){return"number"==typeof t&&t>-1&&t%1==0&&t<=r}}]); | ||
var analyticsClient=function(t){var n={};function r(e){if(n[e])return n[e].exports;var o=n[e]={i:e,l:!1,exports:{}};return t[e].call(o.exports,o,o.exports,r),o.l=!0,o.exports}return r.m=t,r.c=n,r.d=function(t,n,e){r.o(t,n)||Object.defineProperty(t,n,{enumerable:!0,get:e})},r.r=function(t){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})},r.t=function(t,n){if(1&n&&(t=r(t)),8&n)return t;if(4&n&&"object"==typeof t&&t&&t.__esModule)return t;var e=Object.create(null);if(r.r(e),Object.defineProperty(e,"default",{enumerable:!0,value:t}),2&n&&"string"!=typeof t)for(var o in t)r.d(e,o,function(n){return t[n]}.bind(null,o));return e},r.n=function(t){var n=t&&t.__esModule?function(){return t.default}:function(){return t};return r.d(n,"a",n),n},r.o=function(t,n){return Object.prototype.hasOwnProperty.call(t,n)},r.p="",r(r.s=12)}([function(t,n,r){var e=r(19),o="object"==typeof self&&self&&self.Object===Object&&self,i=e||o||Function("return this")();t.exports=i},function(t,n,r){var e=r(33),o=r(37);t.exports=function(t,n){var r=o(t,n);return e(r)?r:void 0}},function(t,n,r){var e=r(1)(Object,"create");t.exports=e},function(t,n,r){var e=r(52);t.exports=function(t,n){for(var r=t.length;r--;)if(e(t[r][0],n))return r;return-1}},function(t,n,r){var e=r(58);t.exports=function(t,n){var r=t.__data__;return e(n)?r["string"==typeof n?"string":"hash"]:r.map}},function(t,n,r){var e=r(0).Symbol;t.exports=e},function(t,n){t.exports=function(t){return null!=t&&"object"==typeof t}},function(t,n,r){var e=r(5),o=r(23),i=r(24),u="[object Null]",c="[object Undefined]",a=e?e.toStringTag:void 0;t.exports=function(t){return null==t?void 0===t?c:u:a&&a in Object(t)?o(t):i(t)}},function(t,n){t.exports=function(t){return t}},function(t,n,r){var e=r(7),o=r(10),i="[object AsyncFunction]",u="[object Function]",c="[object GeneratorFunction]",a="[object Proxy]";t.exports=function(t){if(!o(t))return!1;var n=e(t);return n==u||n==c||n==i||n==a}},function(t,n){t.exports=function(t){var n=typeof t;return null!=t&&("object"==n||"function"==n)}},function(t,n){t.exports=function(t){var n=-1,r=Array(t.size);return t.forEach((function(t){r[++n]=t})),r}},function(t,n,r){"use strict";Object.defineProperty(n,"__esModule",{value:!0});var e=r(13);n.AnalyticsUrlParams=e.AnalyticsUrlParams},function(t,n,r){"use strict";var e=this&&this.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(n,"__esModule",{value:!0});var o=r(14),i=e(r(15)),u="__analytics_dids",c=/\s*,\s*/,a=function(){function t(t){this.mixpanel=t,this.cookiesSupported=o.hasCookieSupport();var n=this.cookiesSupported?o.getCookie(u):null;this.setDeviceIds(n,null)}return t.prototype.setDeviceIds=function(t,n){var r=t?t.split(c):[];return n&&r.push(n),this.deviceIds=i.default(this.deviceIds,r),this.cookiesSupported&&o.setCookie(u,this.deviceIds.join(",")),r.length>0?r[0]:null},t.prototype.clearCookies=function(){this.cookiesSupported&&o.setCookie(u,"")},t.prototype.consumeUrlParameters=function(t){var n=new URLSearchParams(t),r=n.get("d_id");if(r){var e=null!=this.mixpanel?this.mixpanel.get_distinct_id():null,o=this.setDeviceIds(r,e);return null!=this.mixpanel&&o&&this.mixpanel.register({distinct_id:o,$device_id:o}),n.delete("d_id"),n.toString()}return null},t.prototype.allDeviceIds=function(){var t=this.mixpanel?[this.mixpanel.get_distinct_id()]:[];return i.default(this.deviceIds,t)},t.prototype.getDeviceIdsQueryString=function(){var t=this.allDeviceIds();return 0===t.length?"":"d_id="+encodeURIComponent(t.join(","))},t}();n.AnalyticsUrlParams=a},function(t,n,r){"use strict";function e(t,n,r,e,o,i){if("undefined"!=typeof window)return arguments.length>1?document.cookie="".concat(t,"=").concat(encodeURIComponent(n)).concat(r?"; expires=".concat(new Date(+new Date+1e3*r).toUTCString()):"").concat(e?"; path=".concat(e):"").concat(o?"; domain=".concat(o):"").concat(i?"; secure":""):decodeURIComponent(("; ".concat(document.cookie).split("; ".concat(t,"="))[1]||"").split(";")[0])}function o(){try{e("___c","1");var t=-1!==document.cookie.indexOf("___c");return e("___c","",-1),t}catch(t){return!1}}r.r(n),r.d(n,"hasCookieSupport",(function(){return o})),r.d(n,"setCookie",(function(){return u})),r.d(n,"getCookie",(function(){return i})),r.d(n,"removeCookie",(function(){return c}));var i=e,u=e;function c(t){return e(t,"",-1)}},function(t,n,r){var e=r(16),o=r(26),i=r(39),u=r(74),c=o((function(t){return i(e(t,1,u,!0))}));t.exports=c},function(t,n,r){var e=r(17),o=r(18);t.exports=function t(n,r,i,u,c){var a=-1,s=n.length;for(i||(i=o),c||(c=[]);++a<s;){var f=n[a];r>0&&i(f)?r>1?t(f,r-1,i,u,c):e(c,f):u||(c[c.length]=f)}return c}},function(t,n){t.exports=function(t,n){for(var r=-1,e=n.length,o=t.length;++r<e;)t[o+r]=n[r];return t}},function(t,n,r){var e=r(5),o=r(21),i=r(25),u=e?e.isConcatSpreadable:void 0;t.exports=function(t){return i(t)||o(t)||!!(u&&t&&t[u])}},function(t,n,r){(function(n){var r="object"==typeof n&&n&&n.Object===Object&&n;t.exports=r}).call(this,r(20))},function(t,n){var r;r=function(){return this}();try{r=r||new Function("return this")()}catch(t){"object"==typeof window&&(r=window)}t.exports=r},function(t,n,r){var e=r(22),o=r(6),i=Object.prototype,u=i.hasOwnProperty,c=i.propertyIsEnumerable,a=e(function(){return arguments}())?e:function(t){return o(t)&&u.call(t,"callee")&&!c.call(t,"callee")};t.exports=a},function(t,n,r){var e=r(7),o=r(6),i="[object Arguments]";t.exports=function(t){return o(t)&&e(t)==i}},function(t,n,r){var e=r(5),o=Object.prototype,i=o.hasOwnProperty,u=o.toString,c=e?e.toStringTag:void 0;t.exports=function(t){var n=i.call(t,c),r=t[c];try{t[c]=void 0;var e=!0}catch(t){}var o=u.call(t);return e&&(n?t[c]=r:delete t[c]),o}},function(t,n){var r=Object.prototype.toString;t.exports=function(t){return r.call(t)}},function(t,n){var r=Array.isArray;t.exports=r},function(t,n,r){var e=r(8),o=r(27),i=r(29);t.exports=function(t,n){return i(o(t,n,e),t+"")}},function(t,n,r){var e=r(28),o=Math.max;t.exports=function(t,n,r){return n=o(void 0===n?t.length-1:n,0),function(){for(var i=arguments,u=-1,c=o(i.length-n,0),a=Array(c);++u<c;)a[u]=i[n+u];u=-1;for(var s=Array(n+1);++u<n;)s[u]=i[u];return s[n]=r(a),e(t,this,s)}}},function(t,n){t.exports=function(t,n,r){switch(r.length){case 0:return t.call(n);case 1:return t.call(n,r[0]);case 2:return t.call(n,r[0],r[1]);case 3:return t.call(n,r[0],r[1],r[2])}return t.apply(n,r)}},function(t,n,r){var e=r(30),o=r(38)(e);t.exports=o},function(t,n,r){var e=r(31),o=r(32),i=r(8),u=o?function(t,n){return o(t,"toString",{configurable:!0,enumerable:!1,value:e(n),writable:!0})}:i;t.exports=u},function(t,n){t.exports=function(t){return function(){return t}}},function(t,n,r){var e=r(1),o=function(){try{var t=e(Object,"defineProperty");return t({},"",{}),t}catch(t){}}();t.exports=o},function(t,n,r){var e=r(9),o=r(34),i=r(10),u=r(36),c=/^\[object .+?Constructor\]$/,a=Function.prototype,s=Object.prototype,f=a.toString,p=s.hasOwnProperty,l=RegExp("^"+f.call(p).replace(/[\\^$.*+?()[\]{}|]/g,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$");t.exports=function(t){return!(!i(t)||o(t))&&(e(t)?l:c).test(u(t))}},function(t,n,r){var e,o=r(35),i=(e=/[^.]+$/.exec(o&&o.keys&&o.keys.IE_PROTO||""))?"Symbol(src)_1."+e:"";t.exports=function(t){return!!i&&i in t}},function(t,n,r){var e=r(0)["__core-js_shared__"];t.exports=e},function(t,n){var r=Function.prototype.toString;t.exports=function(t){if(null!=t){try{return r.call(t)}catch(t){}try{return t+""}catch(t){}}return""}},function(t,n){t.exports=function(t,n){return null==t?void 0:t[n]}},function(t,n){var r=800,e=16,o=Date.now;t.exports=function(t){var n=0,i=0;return function(){var u=o(),c=e-(u-i);if(i=u,c>0){if(++n>=r)return arguments[0]}else n=0;return t.apply(void 0,arguments)}}},function(t,n,r){var e=r(40),o=r(64),i=r(69),u=r(70),c=r(71),a=r(11),s=200;t.exports=function(t,n,r){var f=-1,p=o,l=t.length,v=!0,h=[],d=h;if(r)v=!1,p=i;else if(l>=s){var _=n?null:c(t);if(_)return a(_);v=!1,p=u,d=new e}else d=n?[]:h;t:for(;++f<l;){var x=t[f],y=n?n(x):x;if(x=r||0!==x?x:0,v&&y==y){for(var g=d.length;g--;)if(d[g]===y)continue t;n&&d.push(y),h.push(x)}else p(d,y,r)||(d!==h&&d.push(y),h.push(x))}return h}},function(t,n,r){var e=r(41),o=r(62),i=r(63);function u(t){var n=-1,r=null==t?0:t.length;for(this.__data__=new e;++n<r;)this.add(t[n])}u.prototype.add=u.prototype.push=o,u.prototype.has=i,t.exports=u},function(t,n,r){var e=r(42),o=r(57),i=r(59),u=r(60),c=r(61);function a(t){var n=-1,r=null==t?0:t.length;for(this.clear();++n<r;){var e=t[n];this.set(e[0],e[1])}}a.prototype.clear=e,a.prototype.delete=o,a.prototype.get=i,a.prototype.has=u,a.prototype.set=c,t.exports=a},function(t,n,r){var e=r(43),o=r(49),i=r(56);t.exports=function(){this.size=0,this.__data__={hash:new e,map:new(i||o),string:new e}}},function(t,n,r){var e=r(44),o=r(45),i=r(46),u=r(47),c=r(48);function a(t){var n=-1,r=null==t?0:t.length;for(this.clear();++n<r;){var e=t[n];this.set(e[0],e[1])}}a.prototype.clear=e,a.prototype.delete=o,a.prototype.get=i,a.prototype.has=u,a.prototype.set=c,t.exports=a},function(t,n,r){var e=r(2);t.exports=function(){this.__data__=e?e(null):{},this.size=0}},function(t,n){t.exports=function(t){var n=this.has(t)&&delete this.__data__[t];return this.size-=n?1:0,n}},function(t,n,r){var e=r(2),o="__lodash_hash_undefined__",i=Object.prototype.hasOwnProperty;t.exports=function(t){var n=this.__data__;if(e){var r=n[t];return r===o?void 0:r}return i.call(n,t)?n[t]:void 0}},function(t,n,r){var e=r(2),o=Object.prototype.hasOwnProperty;t.exports=function(t){var n=this.__data__;return e?void 0!==n[t]:o.call(n,t)}},function(t,n,r){var e=r(2),o="__lodash_hash_undefined__";t.exports=function(t,n){var r=this.__data__;return this.size+=this.has(t)?0:1,r[t]=e&&void 0===n?o:n,this}},function(t,n,r){var e=r(50),o=r(51),i=r(53),u=r(54),c=r(55);function a(t){var n=-1,r=null==t?0:t.length;for(this.clear();++n<r;){var e=t[n];this.set(e[0],e[1])}}a.prototype.clear=e,a.prototype.delete=o,a.prototype.get=i,a.prototype.has=u,a.prototype.set=c,t.exports=a},function(t,n){t.exports=function(){this.__data__=[],this.size=0}},function(t,n,r){var e=r(3),o=Array.prototype.splice;t.exports=function(t){var n=this.__data__,r=e(n,t);return!(r<0)&&(r==n.length-1?n.pop():o.call(n,r,1),--this.size,!0)}},function(t,n){t.exports=function(t,n){return t===n||t!=t&&n!=n}},function(t,n,r){var e=r(3);t.exports=function(t){var n=this.__data__,r=e(n,t);return r<0?void 0:n[r][1]}},function(t,n,r){var e=r(3);t.exports=function(t){return e(this.__data__,t)>-1}},function(t,n,r){var e=r(3);t.exports=function(t,n){var r=this.__data__,o=e(r,t);return o<0?(++this.size,r.push([t,n])):r[o][1]=n,this}},function(t,n,r){var e=r(1)(r(0),"Map");t.exports=e},function(t,n,r){var e=r(4);t.exports=function(t){var n=e(this,t).delete(t);return this.size-=n?1:0,n}},function(t,n){t.exports=function(t){var n=typeof t;return"string"==n||"number"==n||"symbol"==n||"boolean"==n?"__proto__"!==t:null===t}},function(t,n,r){var e=r(4);t.exports=function(t){return e(this,t).get(t)}},function(t,n,r){var e=r(4);t.exports=function(t){return e(this,t).has(t)}},function(t,n,r){var e=r(4);t.exports=function(t,n){var r=e(this,t),o=r.size;return r.set(t,n),this.size+=r.size==o?0:1,this}},function(t,n){var r="__lodash_hash_undefined__";t.exports=function(t){return this.__data__.set(t,r),this}},function(t,n){t.exports=function(t){return this.__data__.has(t)}},function(t,n,r){var e=r(65);t.exports=function(t,n){return!!(null==t?0:t.length)&&e(t,n,0)>-1}},function(t,n,r){var e=r(66),o=r(67),i=r(68);t.exports=function(t,n,r){return n==n?i(t,n,r):e(t,o,r)}},function(t,n){t.exports=function(t,n,r,e){for(var o=t.length,i=r+(e?1:-1);e?i--:++i<o;)if(n(t[i],i,t))return i;return-1}},function(t,n){t.exports=function(t){return t!=t}},function(t,n){t.exports=function(t,n,r){for(var e=r-1,o=t.length;++e<o;)if(t[e]===n)return e;return-1}},function(t,n){t.exports=function(t,n,r){for(var e=-1,o=null==t?0:t.length;++e<o;)if(r(n,t[e]))return!0;return!1}},function(t,n){t.exports=function(t,n){return t.has(n)}},function(t,n,r){var e=r(72),o=r(73),i=r(11),u=e&&1/i(new e([,-0]))[1]==1/0?function(t){return new e(t)}:o;t.exports=u},function(t,n,r){var e=r(1)(r(0),"Set");t.exports=e},function(t,n){t.exports=function(){}},function(t,n,r){var e=r(75),o=r(6);t.exports=function(t){return o(t)&&e(t)}},function(t,n,r){var e=r(9),o=r(76);t.exports=function(t){return null!=t&&o(t.length)&&!e(t)}},function(t,n){var r=9007199254740991;t.exports=function(t){return"number"==typeof t&&t>-1&&t%1==0&&t<=r}}]); |
@@ -10,4 +10,4 @@ import { Mixpanel } from 'mixpanel-browser'; | ||
consumeUrlParameters(queryString: string): string | null; | ||
allDeviceIds(): string[]; | ||
allDeviceIds(): any[]; | ||
getDeviceIdsQueryString(): string; | ||
} |
@@ -18,3 +18,3 @@ "use strict"; | ||
: null; | ||
this.setDeviceIds(storedValue, this.mixpanel ? this.mixpanel.get_distinct_id() : null); | ||
this.setDeviceIds(storedValue, null); | ||
} | ||
@@ -57,3 +57,4 @@ AnalyticsUrlParams.prototype.setDeviceIds = function (inputIdString, currentDeviceId) { | ||
AnalyticsUrlParams.prototype.allDeviceIds = function () { | ||
return this.deviceIds; | ||
var mixpanelId = this.mixpanel ? [this.mixpanel.get_distinct_id()] : []; | ||
return union_1.default(this.deviceIds, mixpanelId); | ||
}; | ||
@@ -60,0 +61,0 @@ AnalyticsUrlParams.prototype.getDeviceIdsQueryString = function () { |
@@ -37,3 +37,7 @@ "use strict"; | ||
registerParams: null, | ||
get_distinct_id: function () { return 'test_mp_distinct_id'; }, | ||
distinctIdRetrieved: false, | ||
get_distinct_id: function () { | ||
this.distinctIdRetrieved = true; | ||
return 'test_mp_distinct_id'; | ||
}, | ||
register: function (params) { | ||
@@ -56,2 +60,6 @@ this.registerParams = params; | ||
}); | ||
test("don't call mixpanel in constructor", function () { | ||
var _a = mpUrlParameters(), mock = _a[1]; | ||
expect(mock.distinctIdRetrieved).toBeFalsy(); | ||
}); | ||
test('update mixpanel state', function () { | ||
@@ -81,6 +89,6 @@ var _a = mpUrlParameters(), urlParams = _a[0], mp = _a[1]; | ||
expect(urlParams.allDeviceIds()).toStrictEqual([ | ||
'test_mp_distinct_id', | ||
'd1', | ||
'd2', | ||
'd3', | ||
'test_mp_distinct_id', | ||
]); | ||
@@ -87,0 +95,0 @@ }); |
{ | ||
"name": "analytics-client", | ||
"version": "0.1.0-roman-url-params-5836fbb91baa905b7226b295b063856e47caceb6", | ||
"version": "0.1.0-roman-url-params-ad69d6499854bfb48212dcc2eb77c126039362b7", | ||
"description": "Convenient builders to compose analytics tools", | ||
@@ -5,0 +5,0 @@ "repository": { |
@@ -23,3 +23,3 @@ Analytics client | ||
const signupUrl = '/signup?' + analytics.deviceIdQuery(); | ||
const signupUrl = '/signup?' + analytics.getDeviceIdsQueryString(); | ||
``` |
@@ -26,6 +26,3 @@ import { | ||
: null; | ||
this.setDeviceIds( | ||
storedValue, | ||
this.mixpanel ? this.mixpanel.get_distinct_id() : null, | ||
); | ||
this.setDeviceIds(storedValue, null); | ||
} | ||
@@ -95,3 +92,4 @@ | ||
allDeviceIds() { | ||
return this.deviceIds; | ||
const mixpanelId = this.mixpanel ? [this.mixpanel.get_distinct_id()] : []; | ||
return union(this.deviceIds, mixpanelId); | ||
} | ||
@@ -98,0 +96,0 @@ |
@@ -53,2 +53,3 @@ import { Mixpanel } from 'mixpanel-browser'; | ||
registerParams: any; | ||
distinctIdRetrieved: boolean; | ||
} | ||
@@ -59,4 +60,8 @@ | ||
registerParams: null, | ||
distinctIdRetrieved: false, | ||
get_distinct_id: () => 'test_mp_distinct_id', | ||
get_distinct_id() { | ||
this.distinctIdRetrieved = true; | ||
return 'test_mp_distinct_id'; | ||
}, | ||
register(params: any) { | ||
@@ -83,2 +88,7 @@ this.registerParams = params; | ||
test("don't call mixpanel in constructor", () => { | ||
const [, mock] = mpUrlParameters(); | ||
expect(mock.distinctIdRetrieved).toBeFalsy(); | ||
}); | ||
test('update mixpanel state', () => { | ||
@@ -115,6 +125,6 @@ const [urlParams, mp] = mpUrlParameters(); | ||
expect(urlParams.allDeviceIds()).toStrictEqual([ | ||
'test_mp_distinct_id', | ||
'd1', | ||
'd2', | ||
'd3', | ||
'test_mp_distinct_id', | ||
]); | ||
@@ -121,0 +131,0 @@ }); |
32212
493