@snowplow/browser-plugin-debugger 3.2.3 → 3.4.0

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.
@@ -1,8 +1,8 @@
1
1
  /*!
2
- * Debugger for Snowplow v3.2.3 (http://bit.ly/sp-js)
2
+ * Debugger for Snowplow v3.4.0 (http://bit.ly/sp-js)
3
3
  * Copyright 2022 Snowplow Analytics Ltd, 2010 Anthon Pang
4
4
  * Licensed under BSD-3-Clause
5
5
  */
6
6
 
7
- "use strict";!function(e,r){"object"==typeof exports&&"undefined"!=typeof module?r(exports):"function"==typeof define&&define.amd?define(["exports"],r):r((e="undefined"!=typeof globalThis?globalThis:e||self).snowplowDebugger={})}(this,(function(e){function r(e,r,n){if(n||2===arguments.length)for(var t,o=0,a=r.length;o<a;o++)!t&&o in r||(t||(t=Array.prototype.slice.call(r,0,o)),t[o]=r[o]);return e.concat(t||r)}function n(e){switch((e=e.getPayload()).e){case"pv":return"Page View";case"pp":return"Page Ping";case"tr":return"Ecommerce Transaction";case"ti":return"Ecommerce Transaction Item";case"se":return"Structured Event";case"ue":return"Self Describing";default:return"string"==typeof e.e?e.e:"Invalid"}}var t,o,a="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{},i="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=";(o=t||(t={}))[o.none=0]="none",o[o.error=1]="error",o[o.warn=2]="warn",o[o.debug=3]="debug",o[o.info=4]="info",function(e){void 0===e&&(e=t.warn)}();var u,c=(function(e,r){var n,t;n=a,t=function(){function e(e,r){switch(r.format){case"hsvArray":return e;case"hslArray":return c(e);case"hsl":return"hsl("+(r=c(e))[0]+", "+r[1]+"%, "+r[2]+"%)";case"hsla":return e=c(e),r=r.alpha||Math.random(),"hsla("+e[0]+", "+e[1]+"%, "+e[2]+"%, "+r+")";case"rgbArray":return i(e);case"rgb":return"rgb("+i(e).join(", ")+")";case"rgba":return e=i(e),r=r.alpha||Math.random(),"rgba("+e.join(", ")+", "+r+")";default:return o(e)}}function r(e){if("number"==typeof parseInt(e)){var r=parseInt(e);if(360>r&&0<r)return[r,r]}if("string"==typeof e)if(d[e]){if((e=d[e]).hueRange)return e.hueRange}else if(e.match(/^#?([0-9A-F]{3}|[0-9A-F]{6})$/i))return[e=u(e)[0],e];return[0,360]}function n(e){for(var r in 334<=e&&360>=e&&(e-=360),d){var n=d[r];if(n.hueRange&&e>=n.hueRange[0]&&e<=n.hueRange[1])return d[r]}return"Color not found"}function t(e){if(null===l){var r=Math.random();return Math.floor(e[0]+(r+.618033988749895)%1*(e[1]+1-e[0]))}return r=e[1]||1,e=e[0]||0,l=(9301*l+49297)%233280,Math.floor(e+l/233280*(r-e))}function o(e){function r(e){return 1==(e=e.toString(16)).length?"0"+e:e}return"#"+r((e=i(e))[0])+r(e[1])+r(e[2])}function a(e,r,n){d[e]={hueRange:r,lowerBounds:n,saturationRange:[n[0][0],n[n.length-1][0]],brightnessRange:[n[n.length-1][1],n[0][1]]}}function i(e){var r=e[0];0===r&&(r=1),360===r&&(r=359),r/=360;var n=e[1]/100;e=e[2]/100;var t=Math.floor(6*r),o=6*r-t;r=e*(1-n);var a=e*(1-o*n);n=e*(1-(1-o)*n);var i=o=256,u=256;switch(t){case 0:o=e,i=n,u=r;break;case 1:o=a,i=e,u=r;break;case 2:o=r,i=e,u=n;break;case 3:o=r,i=a,u=e;break;case 4:o=n,i=r,u=e;break;case 5:o=e,i=r,u=a}return[Math.floor(255*o),Math.floor(255*i),Math.floor(255*u)]}function u(e){e=3===(e=e.replace(/^#/,"")).length?e.replace(/(.)/g,"$1$1"):e;var r=parseInt(e.substr(0,2),16)/255,n=parseInt(e.substr(2,2),16)/255;e=parseInt(e.substr(4,2),16)/255;var t=Math.max(r,n,e),o=t-Math.min(r,n,e),a=t?o/t:0;switch(t){case r:return[(n-e)/o%6*60||0,a,t];case n:return[60*((e-r)/o+2)||0,a,t];case e:return[60*((r-n)/o+4)||0,a,t]}}function c(e){var r=e[1]/100,n=e[2]/100,t=(2-r)*n;return[e[0],Math.round(r*n/(1>t?t:2-t)*1e4)/100,t/2*100]}function s(e){if(isNaN(e)){if("string"==typeof e)if(d[e]){if((e=d[e]).hueRange)return e.hueRange}else if(e.match(/^#?([0-9A-F]{3}|[0-9A-F]{6})$/i))return n(e=u(e)[0]).hueRange}else{var r=parseInt(e);if(360>r&&0<r)return n(e).hueRange}return[0,360]}var l=null,d={};a("monochrome",null,[[0,0],[100,0]]),a("red",[-26,18],[[20,100],[30,92],[40,89],[50,85],[60,78],[70,70],[80,60],[90,55],[100,50]]),a("orange",[18,46],[[20,100],[30,93],[40,88],[50,86],[60,85],[70,70],[100,70]]),a("yellow",[46,62],[[25,100],[40,94],[50,89],[60,86],[70,84],[80,82],[90,80],[100,75]]),a("green",[62,178],[[30,100],[40,90],[50,85],[60,81],[70,74],[80,64],[90,50],[100,40]]),a("blue",[178,257],[[20,100],[30,86],[40,80],[50,74],[60,60],[70,52],[80,44],[90,39],[100,35]]),a("purple",[257,282],[[20,100],[30,87],[40,79],[50,70],[60,65],[70,59],[80,52],[90,45],[100,42]]),a("pink",[282,334],[[20,100],[30,90],[40,86],[60,84],[80,80],[90,75],[100,73]]);var f=[],h=function(o){if(void 0!==(o=o||{}).seed&&null!==o.seed&&o.seed===parseInt(o.seed,10))l=o.seed;else if("string"==typeof o.seed){for(var a=o.seed,i=0,u=0;u!==a.length&&!(i>=Number.MAX_SAFE_INTEGER);u++)i+=a.charCodeAt(u);l=i}else{if(void 0!==o.seed&&null!==o.seed)throw new TypeError("The seed value must be an integer or string");l=null}if(null!==o.count&&void 0!==o.count){for(a=o.count,i=[],u=0;u<o.count;u++)f.push(!1);for(o.count=null;a>i.length;)u=h(o),null!==l&&(o.seed=l),i.push(u);return o.count=a,i}if(a=o,0<f.length?(u=t(a=s(a.hue)),i=(a[1]-a[0])/f.length,u=parseInt((u-a[0])/i),!0===f[u]?u=(u+2)%f.length:f[u]=!0,a=[(a[0]+u*i)%359,(a[0]+(u+1)*i)%359]):a=r(a.hue),0>(u=t(a))&&(u=360+u),a=u,"monochrome"===(i=o).hue)i=0;else if("random"===i.luminosity)i=t([0,100]);else{var c=n(a).saturationRange;switch(u=c[0],c=c[1],i.luminosity){case"bright":u=55;break;case"dark":u=c-10;break;case"light":c=55}i=t([u,c])}u=o;e:{c=i;for(var d=n(a).lowerBounds,g=0;g<d.length-1;g++){var p=d[g][0],b=d[g][1],v=d[g+1][0],w=d[g+1][1];if(c>=p&&c<=v){c=(d=(w-b)/(v-p))*c+(b-d*p);break e}}c=0}switch(p=100,u.luminosity){case"dark":p=c+20;break;case"light":c=(p+c)/2;break;case"random":c=0,p=100}return e([a,i,u=t([c,p])],o)};return h},n=t(),e&&e.exports&&(r=e.exports=n),r.randomColor=n}(u={exports:{}},u.exports),u.exports);e.DebuggerPlugin=function(e){function o(e){var r=function(e,r){var n=/^iglu:([a-zA-Z0-9-_.]+)\/([a-zA-Z0-9-_]+)\/jsonschema\/([1-9][0-9]*)-(0|[1-9][0-9]*)-(0|[1-9][0-9]*)$/.exec(r.schema);n=null!==n?n.slice(1,6):void 0;var t=l.event(),o=l.json;e:switch(e.keyIfEncoded){case"cx":e="Context";break e;case"ue_px":e="Self Describing";break e;default:e=e.keyIfEncoded+", "+e.keyIfNotEncoded}d(t,"Event",["%c%s%c%s%c%s\n%o",o,e+": "+(n?n[1]:"Unknown Schema"),l.schemaVersion,n?"Version: "+n[2]+"-"+n[3]+"-"+n[4]:"Unknown Schema Version",l.schema,n?"Vendor: "+n[0]:"Unknown Vendor",r.data])};return function(n,t){if(t.length)for(var o=function(e){var n=e.json.data;Array.isArray(n)?n.forEach((function(n){r(e,n)})):r(e,n)},a=0;a<t.length;a++)o(t[a]);return function(e){return function(r,n){for(var t=0;t<n.length;t++){var o=n[t],a=JSON.stringify(o.json);if(e){var u=r,c=u.add;if(o=o.keyIfEncoded,a){var s=0,l=0,d=[];if(a){a=unescape(encodeURIComponent(a));do{var f=a.charCodeAt(s++),h=a.charCodeAt(s++),g=a.charCodeAt(s++),p=f<<16|h<<8|g;f=p>>18&63,h=p>>12&63,g=p>>6&63,p&=63,d[l++]=i.charAt(f)+i.charAt(h)+i.charAt(g)+i.charAt(p)}while(s<a.length);s=d.join(""),a=((a=a.length%3)?s.slice(0,a-3):s)+"===".slice(a||3)}a=a.replace(/=/g,"").replace(/\+/g,"-").replace(/\//g,"_")}c.call(u,o,a)}else r.add(o.keyIfNotEncoded,a)}n.length=0}}(e)(n,t)}}void 0===e&&(e=t.debug);var a,u,s,l={event:function(){return"color: White; background: "+s+"; font-weight: bold; padding: 1px 4px; border-radius: 2px;"},snowplowPurple:"color: White; background: #6638B8; font-weight: bold; padding: 1px 4px; border-radius: 2px;",activated:"color: White; background: #9E62DD; font-weight: bold; padding: 1px 4px; border-radius: 2px;",payload:"color: White; background: #3748B8; font-weight: bold; padding: 1px 4px; border-radius: 2px;",json:"color: White; background: #388AB8; font-weight: bold; padding: 1px 4px; border-radius: 2px;",schema:"color: White; background: #268047; font-weight: bold; padding: 1px 4px; border-radius: 2px;",schemaVersion:"color: White; background: #80265F; font-weight: bold; padding: 1px 4px; border-radius: 2px;"},d=function(e,n,t){var o=null!=t?t:[""];t=o[0],o=o.slice(1),a.debug.apply(a,r(["v3.2.3 %c"+u.namespace+"%c %c%s"+t,l.snowplowPurple,"",e,n],o))};return{logger:function(r){a=r,r.setLogLevel(e)},activateBrowserPlugin:function(e){u=e,d(l.activated,"Tracker Activated")},beforeTrack:function(e){s=c({luminosity:"dark"}),e.withJsonProcessor(o(u.core.getBase64Encoding())),d(l.event(),"Event",["%c%s",l.snowplowPurple,n(e)]),e.build()},afterTrack:function(e){d(l.event(),"Event",["%c%s\n%o",l.payload,"Payload",e])}}},Object.defineProperty(e,"__esModule",{value:!0})}));
7
+ "use strict";!function(e,n){"object"==typeof exports&&"undefined"!=typeof module?n(exports):"function"==typeof define&&define.amd?define(["exports"],n):n((e="undefined"!=typeof globalThis?globalThis:e||self).snowplowDebugger={})}(this,(function(e){function n(e){switch((e=e.getPayload()).e){case"pv":return"Page View";case"pp":return"Page Ping";case"tr":return"Ecommerce Transaction";case"ti":return"Ecommerce Transaction Item";case"se":return"Structured Event";case"ue":return"Self Describing";default:return"string"==typeof e.e?e.e:"Invalid"}}var r,t,a="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{},o="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=";(t=r||(r={}))[t.none=0]="none",t[t.error=1]="error",t[t.warn=2]="warn",t[t.debug=3]="debug",t[t.info=4]="info";var c={exports:{}};!function(e,n){var r;r=a,r=function(){function e(e,n){switch(n.format){case"hsvArray":return e;case"hslArray":return u(e);case"hsl":return"hsl("+(n=u(e))[0]+", "+n[1]+"%, "+n[2]+"%)";case"hsla":return e=u(e),n=n.alpha||Math.random(),"hsla("+e[0]+", "+e[1]+"%, "+e[2]+"%, "+n+")";case"rgbArray":return c(e);case"rgb":return"rgb("+c(e).join(", ")+")";case"rgba":return e=c(e),n=n.alpha||Math.random(),"rgba("+e.join(", ")+", "+n+")";default:return a(e)}}function n(e){if("number"==typeof parseInt(e)){var n=parseInt(e);if(360>n&&0<n)return[n,n]}if("string"==typeof e)if(d[e]){if((e=d[e]).hueRange)return e.hueRange}else if(e.match(/^#?([0-9A-F]{3}|[0-9A-F]{6})$/i))return[e=i(e)[0],e];return[0,360]}function r(e){for(var n in 334<=e&&360>=e&&(e-=360),d){var r=d[n];if(r.hueRange&&e>=r.hueRange[0]&&e<=r.hueRange[1])return d[n]}return"Color not found"}function t(e){if(null===l){var n=Math.random();return Math.floor(e[0]+(n+.618033988749895)%1*(e[1]+1-e[0]))}return n=e[1]||1,e=e[0]||0,l=(9301*l+49297)%233280,Math.floor(e+l/233280*(n-e))}function a(e){function n(e){return 1==(e=e.toString(16)).length?"0"+e:e}return"#"+n((e=c(e))[0])+n(e[1])+n(e[2])}function o(e,n,r){d[e]={hueRange:n,lowerBounds:r,saturationRange:[r[0][0],r[r.length-1][0]],brightnessRange:[r[r.length-1][1],r[0][1]]}}function c(e){var n=e[0];0===n&&(n=1),360===n&&(n=359),n/=360;var r=e[1]/100;e=e[2]/100;var t=Math.floor(6*n),a=6*n-t;n=e*(1-r);var o=e*(1-a*r);r=e*(1-(1-a)*r);var c=a=256,i=256;switch(t){case 0:a=e,c=r,i=n;break;case 1:a=o,c=e,i=n;break;case 2:a=n,c=e,i=r;break;case 3:a=n,c=o,i=e;break;case 4:a=r,c=n,i=e;break;case 5:a=e,c=n,i=o}return[Math.floor(255*a),Math.floor(255*c),Math.floor(255*i)]}function i(e){e=3===(e=e.replace(/^#/,"")).length?e.replace(/(.)/g,"$1$1"):e;var n=parseInt(e.substr(0,2),16)/255,r=parseInt(e.substr(2,2),16)/255;e=parseInt(e.substr(4,2),16)/255;var t=Math.max(n,r,e),a=t-Math.min(n,r,e),o=t?a/t:0;switch(t){case n:return[(r-e)/a%6*60||0,o,t];case r:return[60*((e-n)/a+2)||0,o,t];case e:return[60*((n-r)/a+4)||0,o,t]}}function u(e){var n=e[1]/100,r=e[2]/100,t=(2-n)*r;return[e[0],Math.round(n*r/(1>t?t:2-t)*1e4)/100,t/2*100]}function s(e){if(isNaN(e)){if("string"==typeof e)if(d[e]){if((e=d[e]).hueRange)return e.hueRange}else if(e.match(/^#?([0-9A-F]{3}|[0-9A-F]{6})$/i))return r(e=i(e)[0]).hueRange}else{var n=parseInt(e);if(360>n&&0<n)return r(e).hueRange}return[0,360]}var l=null,d={};o("monochrome",null,[[0,0],[100,0]]),o("red",[-26,18],[[20,100],[30,92],[40,89],[50,85],[60,78],[70,70],[80,60],[90,55],[100,50]]),o("orange",[18,46],[[20,100],[30,93],[40,88],[50,86],[60,85],[70,70],[100,70]]),o("yellow",[46,62],[[25,100],[40,94],[50,89],[60,86],[70,84],[80,82],[90,80],[100,75]]),o("green",[62,178],[[30,100],[40,90],[50,85],[60,81],[70,74],[80,64],[90,50],[100,40]]),o("blue",[178,257],[[20,100],[30,86],[40,80],[50,74],[60,60],[70,52],[80,44],[90,39],[100,35]]),o("purple",[257,282],[[20,100],[30,87],[40,79],[50,70],[60,65],[70,59],[80,52],[90,45],[100,42]]),o("pink",[282,334],[[20,100],[30,90],[40,86],[60,84],[80,80],[90,75],[100,73]]);var f=[],h=function(a){if(void 0!==(a=a||{}).seed&&null!==a.seed&&a.seed===parseInt(a.seed,10))l=a.seed;else if("string"==typeof a.seed){for(var o=a.seed,c=0,i=0;i!==o.length&&!(c>=Number.MAX_SAFE_INTEGER);i++)c+=o.charCodeAt(i);l=c}else{if(void 0!==a.seed&&null!==a.seed)throw new TypeError("The seed value must be an integer or string");l=null}if(null!==a.count&&void 0!==a.count){for(o=a.count,c=[],i=0;i<a.count;i++)f.push(!1);for(a.count=null;o>c.length;)i=h(a),null!==l&&(a.seed=l),c.push(i);return a.count=o,c}if(o=a,0<f.length?(i=t(o=s(o.hue)),c=(o[1]-o[0])/f.length,i=parseInt((i-o[0])/c),!0===f[i]?i=(i+2)%f.length:f[i]=!0,o=[(o[0]+i*c)%359,(o[0]+(i+1)*c)%359]):o=n(o.hue),0>(i=t(o))&&(i=360+i),o=i,"monochrome"===(c=a).hue)c=0;else if("random"===c.luminosity)c=t([0,100]);else{var u=r(o).saturationRange;switch(i=u[0],u=u[1],c.luminosity){case"bright":i=55;break;case"dark":i=u-10;break;case"light":u=55}c=t([i,u])}i=a;e:{u=c;for(var d=r(o).lowerBounds,g=0;g<d.length-1;g++){var p=d[g][0],b=d[g][1],v=d[g+1][0],w=d[g+1][1];if(u>=p&&u<=v){u=(d=(w-b)/(v-p))*u+(b-d*p);break e}}u=0}switch(p=100,i.luminosity){case"dark":p=u+20;break;case"light":u=(p+u)/2;break;case"random":u=0,p=100}return e([o,c,i=t([u,p])],a)};return h}(),e&&e.exports&&(n=e.exports=r),n.randomColor=r}(c,c.exports);var i=c.exports;e.DebuggerPlugin=function(e){function t(e){var n=function(e,n){var r=/^iglu:([a-zA-Z0-9-_.]+)\/([a-zA-Z0-9-_]+)\/jsonschema\/([1-9][0-9]*)-(0|[1-9][0-9]*)-(0|[1-9][0-9]*)$/.exec(n.schema);r=null!==r?r.slice(1,6):void 0;var t=s.event(),a=s.json,o=r?r[1]:"Unknown Schema",c="".concat;e:switch(e.keyIfEncoded){case"cx":e="Context";break e;case"ue_px":e="Self Describing";break e;default:e="".concat(e.keyIfEncoded,", ").concat(e.keyIfNotEncoded)}l(t,"Event",["%c%s%c%s%c%s\n%o",a,c.call("",e,": ").concat(o),s.schemaVersion,r?"Version: ".concat(r[2],"-").concat(r[3],"-").concat(r[4]):"Unknown Schema Version",s.schema,r?"Vendor: ".concat(r[0]):"Unknown Vendor",n.data])};return function(r,t){if(t.length)for(var a=function(e){var r=e.json.data;Array.isArray(r)?r.forEach((function(r){n(e,r)})):n(e,r)},c=0;c<t.length;c++)a(t[c]);return function(e){return function(n,r){for(var t=0;t<r.length;t++){var a=r[t],c=JSON.stringify(a.json);if(e){var i=n,u=i.add;if(a=a.keyIfEncoded,c){var s=0,l=0,d=[];if(c){c=unescape(encodeURIComponent(c));do{var f=c.charCodeAt(s++),h=c.charCodeAt(s++),g=c.charCodeAt(s++),p=f<<16|h<<8|g;f=p>>18&63,h=p>>12&63,g=p>>6&63,p&=63,d[l++]=o.charAt(f)+o.charAt(h)+o.charAt(g)+o.charAt(p)}while(s<c.length);s=d.join(""),c=((c=c.length%3)?s.slice(0,c-3):s)+"===".slice(c||3)}c=c.replace(/=/g,"").replace(/\+/g,"-").replace(/\//g,"_")}u.call(i,a,c)}else n.add(a.keyIfNotEncoded,c)}r.length=0}}(e)(r,t)}}void 0===e&&(e=r.debug);var a,c,u,s={event:function(){return"color: White; background: ".concat(u,"; font-weight: bold; padding: 1px 4px; border-radius: 2px;")},snowplowPurple:"color: White; background: #6638B8; font-weight: bold; padding: 1px 4px; border-radius: 2px;",activated:"color: White; background: #9E62DD; font-weight: bold; padding: 1px 4px; border-radius: 2px;",payload:"color: White; background: #3748B8; font-weight: bold; padding: 1px 4px; border-radius: 2px;",json:"color: White; background: #388AB8; font-weight: bold; padding: 1px 4px; border-radius: 2px;",schema:"color: White; background: #268047; font-weight: bold; padding: 1px 4px; border-radius: 2px;",schemaVersion:"color: White; background: #80265F; font-weight: bold; padding: 1px 4px; border-radius: 2px;"},l=function(e,n,r){var t=null!=r?r:[""];r=t[0],t=t.slice(1),a.debug.apply(a,function(e,n,r){if(r||2===arguments.length)for(var t,a=0,o=n.length;a<o;a++)!t&&a in n||(t||(t=Array.prototype.slice.call(n,0,a)),t[a]=n[a]);return e.concat(t||Array.prototype.slice.call(n))}(["v".concat("3.4.0"," %c").concat(c.namespace,"%c %c%s")+r,s.snowplowPurple,"",e,n],t,!1))};return{logger:function(n){a=n,n.setLogLevel(e)},activateBrowserPlugin:function(e){c=e,l(s.activated,"Tracker Activated")},beforeTrack:function(e){u=i({luminosity:"dark"}),e.withJsonProcessor(t(c.core.getBase64Encoding())),l(s.event(),"Event",["%c%s",s.snowplowPurple,n(e)]),e.build()},afterTrack:function(e){l(s.event(),"Event",["%c%s\n%o",s.payload,"Payload",e])}}},Object.defineProperty(e,"__esModule",{value:!0})}));
8
8
  //# sourceMappingURL=index.umd.min.js.map