@snowplow/tracker-core
Advanced tools
Comparing version 3.2.3 to 3.3.0
/*! | ||
* Core functionality for Snowplow JavaScript trackers v3.2.3 (http://bit.ly/sp-js) | ||
* Core functionality for Snowplow JavaScript trackers v3.3.0 (http://bit.ly/sp-js) | ||
* Copyright 2022 Snowplow Analytics Ltd, 2010 Anthon Pang | ||
@@ -7,3 +7,3 @@ * Licensed under BSD-3-Clause | ||
"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).snowplowTrackerCore={})}(this,(function(e){function n(){var e,n={},t=[],o=[],a=function(e,t){null!=t&&""!==t&&(n[e]=t)};return{add:a,addDict:function(e){for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&a(n,e[n])},addJson:function(e,n,a){a&&r(a)&&(e={keyIfEncoded:e,keyIfNotEncoded:n,json:a},o.push(e),t.push(e))},getPayload:function(){return n},getJson:function(){return t},withJsonProcessor:function(n){e=n},build:function(){return null==e||e(this,o),n}}}function t(e){return function(n,t){for(var r=0;r<t.length;r++){var o=t[r],a=JSON.stringify(o.json);if(e){var i=n,c=i.add;if(o=o.keyIfEncoded,a){var s=0,l=0,u=[];if(a){a=unescape(encodeURIComponent(a));do{var d=a.charCodeAt(s++),f=a.charCodeAt(s++),p=a.charCodeAt(s++),m=d<<16|f<<8|p;d=m>>18&63,f=m>>12&63,p=m>>6&63,m&=63,u[l++]=O.charAt(d)+O.charAt(f)+O.charAt(p)+O.charAt(m)}while(s<a.length);s=u.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(i,o,a)}else n.add(o.keyIfNotEncoded,a)}t.length=0}}function r(e){if(!o(e))return!1;for(var n in e)if(Object.prototype.hasOwnProperty.call(e,n))return!0;return!1}function o(e){return null!=e&&(e.constructor==={}.constructor||e.constructor===[].constructor)}function a(e,n,t){if(t||2===arguments.length)for(var r,o=0,a=n.length;o<a;o++)!r&&o in n||(r||(r=Array.prototype.slice.call(n,0,o)),r[o]=n[o]);return e.concat(r||n)}function i(){var e=[],n=[];return{getGlobalPrimitives:function(){return e},getConditionalProviders:function(){return n},addGlobalContexts:function(t){for(var r=[],o=[],a=0;a<t.length;a++){var i=t[a];_(i)?r.push(i):h(i)&&o.push(i)}e=e.concat(o),n=n.concat(r)},clearGlobalContexts:function(){n=[],e=[]},removeGlobalContexts:function(t){for(var r=function(t){_(t)?n=n.filter((function(e){return JSON.stringify(e)!==JSON.stringify(t)})):h(t)&&(e=e.filter((function(e){return JSON.stringify(e)!==JSON.stringify(t)})))},o=0;o<t.length;o++)r(t[o])},getApplicableContexts:function(t){e:{for(var r=0,o=t.getJson();r<o.length;r++){var a=o[r];if("ue_px"===a.keyIfEncoded&&"object"==typeof a.json.data&&"string"==typeof(a=a.json.data.schema)){r=a;break e}}r=""}a="string"==typeof(o=t.getPayload().e)?o:"",o=[];var i=k(e,t,a,r);return o.push.apply(o,i),t=function(e,n,t,r){var o;return e=x(e).map((function(e){e:{if(w(e)){var o=e[0],a=!1;try{a=o({event:n.getPayload(),eventType:t,eventSchema:r})}catch(e){a=!1}if(!0===a){e=k(e[1],n,t,r);break e}}else if(b(e)&&C(e[0],r)){e=k(e[1],n,t,r);break e}e=[]}if(e&&0!==e.length)return e})),(o=[]).concat.apply(o,e.filter((function(e){return null!=e&&e.filter(Boolean)})))}(n,t,a,r),o.push.apply(o,t),o}}}function c(e){return{addPluginContexts:function(n){var t=null!=n?n:[];return e.forEach((function(e){try{e.contexts&&t.push.apply(t,e.contexts())}catch(e){T.error("Error adding plugin contexts",e)}})),t}}}function s(e){if(null!==(e=/^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(e)))return e.slice(1,6)}function l(e){if("*"===e[0]||"*"===e[1])return!1;if(0<e.slice(2).length){var n=!1,t=0;for(e=e.slice(2);t<e.length;t++)if("*"===e[t])n=!0;else if(n)return!1;return!0}return 2==e.length}function u(e){return!!((e=e.split("."))&&1<e.length)&&l(e)}function d(e){if(null!==(e=/^iglu:((?:(?:[a-zA-Z0-9-_]+|\*).)+(?:[a-zA-Z0-9-_]+|\*))\/([a-zA-Z0-9-_.]+|\*)\/jsonschema\/([1-9][0-9]*|\*)-(0|[1-9][0-9]*|\*)-(0|[1-9][0-9]*|\*)$/.exec(e))&&u(e[1]))return e.slice(1,6)}function f(e){if(e=d(e)){var n=e[0];return 5===e.length&&u(n)}return!1}function p(e){return Array.isArray(e)&&e.every((function(e){return"string"==typeof e}))}function m(e){return p(e)?e.every((function(e){return f(e)})):"string"==typeof e&&f(e)}function y(e){return!!(r(e)&&"schema"in e&&"data"in e)&&("string"==typeof e.schema&&"object"==typeof e.data)}function v(e){var n=0;if(null!=e&&"object"==typeof e&&!Array.isArray(e)){if(Object.prototype.hasOwnProperty.call(e,"accept")){if(!m(e.accept))return!1;n+=1}if(Object.prototype.hasOwnProperty.call(e,"reject")){if(!m(e.reject))return!1;n+=1}return 0<n&&2>=n}return!1}function g(e){return"function"==typeof e&&1>=e.length}function h(e){return g(e)||y(e)}function w(e){return!(!Array.isArray(e)||2!==e.length)&&(Array.isArray(e[1])?g(e[0])&&e[1].every(h):g(e[0])&&h(e[1]))}function b(e){return!(!Array.isArray(e)||2!==e.length)&&(!!v(e[0])&&(Array.isArray(e[1])?e[1].every(h):h(e[1])))}function _(e){return w(e)||b(e)}function C(e,n){var t=0,r=0,o=e.accept;return Array.isArray(o)?e.accept.some((function(e){return A(e,n)}))&&r++:"string"==typeof o&&A(o,n)&&r++,o=e.reject,Array.isArray(o)?e.reject.some((function(e){return A(e,n)}))&&t++:"string"==typeof o&&A(o,n)&&t++,0<r&&0===t}function A(e,n){if(!f(e))return!1;if(e=d(e),n=s(n),e&&n){if(!function(e,n){if(n=n.split("."),e=e.split("."),n&&e){if(n.length!==e.length)return!1;for(var t=0;t<e.length;t++)if(!I(n[t],e[t]))return!1;return!0}return!1}(e[0],n[0]))return!1;for(var t=1;5>t;t++)if(!I(e[t],n[t]))return!1;return!0}return!1}function I(e,n){return e&&n&&"*"===e||e===n}function x(e){return Array.isArray(e)?e:[e]}function k(e,n,t,r){var o;return e=x(e).map((function(e){e:if(y(e))e=[e];else{if(g(e)){n:{var o=void 0;try{if(o=e({event:n.getPayload(),eventType:t,eventSchema:r}),Array.isArray(o)&&o.every(y)||y(o)){var a=o;break n}a=void 0;break n}catch(e){}a=void 0}if(y(a)){e=[a];break e}if(Array.isArray(a)){e=a;break e}}e=void 0}if(e&&0!==e.length)return e})),(o=[]).concat.apply(o,e.filter((function(e){return null!=e&&e.filter(Boolean)})))}function P(e){var t=e.event;return e={schema:"iglu:com.snowplowanalytics.snowplow/unstruct_event/jsonschema/1-0-0",data:{schema:e=t.schema,data:t.data}},(t=n()).add("e","ue"),t.addJson("ue_px","ue_pr",e),t}function j(e,n){void 0===n&&(n={});var t,r={};for(t in e)(n[t]||null!==e[t]&&void 0!==e[t])&&(r[t]=e[t]);return r}var E,L,O="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",S=function(){return(S=Object.assign||function(e){for(var n,t=1,r=arguments.length;t<r;t++)for(var o in n=arguments[t])Object.prototype.hasOwnProperty.call(n,o)&&(e[o]=n[o]);return e}).apply(this,arguments)};e.LOG_LEVEL=void 0,(E=e.LOG_LEVEL||(e.LOG_LEVEL={}))[E.none=0]="none",E[E.error=1]="error",E[E.warn=2]="warn",E[E.debug=3]="debug",E[E.info=4]="info";for(var T=function(n){return void 0===n&&(n=e.LOG_LEVEL.warn),{setLogLevel:function(t){n=e.LOG_LEVEL[t]?t:e.LOG_LEVEL.warn},warn:function(t,r){for(var o=[],i=2;i<arguments.length;i++)o[i-2]=arguments[i];n>=e.LOG_LEVEL.warn&&"undefined"!=typeof console&&(i="Snowplow: "+t,r?console.warn.apply(console,a([i+"\n",r],o)):console.warn.apply(console,a([i],o)))},error:function(t,r){for(var o=[],i=2;i<arguments.length;i++)o[i-2]=arguments[i];n>=e.LOG_LEVEL.error&&"undefined"!=typeof console&&(i="Snowplow: "+t+"\n",r?console.error.apply(console,a([i+"\n",r],o)):console.error.apply(console,a([i],o)))},debug:function(t){for(var r=[],o=1;o<arguments.length;o++)r[o-1]=arguments[o];n>=e.LOG_LEVEL.debug&&"undefined"!=typeof console&&console.debug.apply(console,a(["Snowplow: "+t],r))},info:function(t){for(var r=[],o=1;o<arguments.length;o++)r[o-1]=arguments[o];n>=e.LOG_LEVEL.info&&"undefined"!=typeof console&&console.info.apply(console,a(["Snowplow: "+t],r))}}}(),V=(L=void 0,function(e){var n="undefined"!=typeof crypto&&crypto.getRandomValues&&crypto.getRandomValues.bind(crypto)||"undefined"!=typeof msCrypto&&"function"==typeof window.msCrypto.getRandomValues&&msCrypto.getRandomValues.bind(msCrypto);if(n){var t=new Uint8Array(16);e.exports=function(){return n(t),t}}else{var r=Array(16);e.exports=function(){for(var e,n=0;16>n;n++)0==(3&n)&&(e=4294967296*Math.random()),r[n]=e>>>((3&n)<<3)&255;return r}}}(L={exports:{}}),L.exports),N=[],G=0;256>G;++G)N[G]=(G+256).toString(16).substr(1);var R,J,U=function(e,n){return n=n||0,[N[e[n++]],N[e[n++]],N[e[n++]],N[e[n++]],"-",N[e[n++]],N[e[n++]],"-",N[e[n++]],N[e[n++]],"-",N[e[n++]],N[e[n++]],"-",N[e[n++]],N[e[n++]],N[e[n++]],N[e[n++]],N[e[n++]],N[e[n++]]].join("")},z=0,D=0,q=function(e,n,t){if(t=n&&t||0,"string"==typeof e&&(n="binary"===e?Array(16):null,e=null),(e=(e=e||{}).random||(e.rng||V)())[6]=15&e[6]|64,e[8]=63&e[8]|128,n)for(var r=0;16>r;++r)n[t+r]=e[r];return n||U(e)};q.v1=function(e,n,t){t=n&&t||0;var r=n||[],o=(e=e||{}).node||R,a=void 0!==e.clockseq?e.clockseq:J;if(null==o||null==a){var i=V();null==o&&(o=R=[1|i[0],i[1],i[2],i[3],i[4],i[5]]),null==a&&(a=J=16383&(i[6]<<8|i[7]))}i=void 0!==e.msecs?e.msecs:(new Date).getTime();var c=void 0!==e.nsecs?e.nsecs:D+1,s=i-z+(c-D)/1e4;if(0>s&&void 0===e.clockseq&&(a=a+1&16383),(0>s||i>z)&&void 0===e.nsecs&&(c=0),1e4<=c)throw Error("uuid.v1(): Can't create more than 10M uuids/sec");for(z=i,D=c,J=a,e=(1e4*(268435455&(i+=122192928e5))+c)%4294967296,r[t++]=e>>>24&255,r[t++]=e>>>16&255,r[t++]=e>>>8&255,r[t++]=255&e,e=i/4294967296*1e4&268435455,r[t++]=e>>>8&255,r[t++]=255&e,r[t++]=e>>>24&15|16,r[t++]=e>>>16&255,r[t++]=a>>>8|128,r[t++]=255&a,a=0;6>a;++a)r[t+a]=o[a];return n||U(r)},q.v4=q,e.LOG=T,e.buildAdClick=function(e){return P({event:e={schema:"iglu:com.snowplowanalytics.snowplow/ad_click/jsonschema/1-0-0",data:j({targetUrl:e.targetUrl,clickId:e.clickId,costModel:e.costModel,cost:e.cost,bannerId:e.bannerId,zoneId:e.zoneId,impressionId:e.impressionId,advertiserId:e.advertiserId,campaignId:e.campaignId})}})},e.buildAdConversion=function(e){return P({event:e={schema:"iglu:com.snowplowanalytics.snowplow/ad_conversion/jsonschema/1-0-0",data:j({conversionId:e.conversionId,costModel:e.costModel,cost:e.cost,category:e.category,action:e.action,property:e.property,initialValue:e.initialValue,advertiserId:e.advertiserId,campaignId:e.campaignId})}})},e.buildAdImpression=function(e){return P({event:e={schema:"iglu:com.snowplowanalytics.snowplow/ad_impression/jsonschema/1-0-0",data:j({impressionId:e.impressionId,costModel:e.costModel,cost:e.cost,targetUrl:e.targetUrl,bannerId:e.bannerId,zoneId:e.zoneId,advertiserId:e.advertiserId,campaignId:e.campaignId})}})},e.buildAddToCart=function(e){return P({event:{schema:"iglu:com.snowplowanalytics.snowplow/add_to_cart/jsonschema/1-0-0",data:j({sku:e.sku,quantity:e.quantity,name:e.name,category:e.category,unitPrice:e.unitPrice,currency:e.currency})}})},e.buildConsentGranted=function(e){var n=e.expiry;return e={schema:"iglu:com.snowplowanalytics.snowplow/consent_document/jsonschema/1-0-0",data:j({id:e.id,version:e.version,name:e.name,description:e.description})},{event:P({event:{schema:"iglu:com.snowplowanalytics.snowplow/consent_granted/jsonschema/1-0-0",data:j({expiry:n})}}),context:[e]}},e.buildConsentWithdrawn=function(e){var n=e.all;return e={schema:"iglu:com.snowplowanalytics.snowplow/consent_document/jsonschema/1-0-0",data:j({id:e.id,version:e.version,name:e.name,description:e.description})},{event:P({event:{schema:"iglu:com.snowplowanalytics.snowplow/consent_withdrawn/jsonschema/1-0-0",data:j({all:n})}}),context:[e]}},e.buildEcommerceTransaction=function(e){var t=e.orderId,r=e.total,o=e.affiliation,a=e.tax,i=e.shipping,c=e.city,s=e.state,l=e.country;e=e.currency;var u=n();return u.add("e","tr"),u.add("tr_id",t),u.add("tr_af",o),u.add("tr_tt",r),u.add("tr_tx",a),u.add("tr_sh",i),u.add("tr_ci",c),u.add("tr_st",s),u.add("tr_co",l),u.add("tr_cu",e),u},e.buildEcommerceTransactionItem=function(e){var t=e.orderId,r=e.sku,o=e.price,a=e.name,i=e.category,c=e.quantity;e=e.currency;var s=n();return s.add("e","ti"),s.add("ti_id",t),s.add("ti_sk",r),s.add("ti_nm",a),s.add("ti_ca",i),s.add("ti_pr",o),s.add("ti_qu",c),s.add("ti_cu",e),s},e.buildFormFocusOrChange=function(e){var n="",t=e.schema,r=e.type;return e={formId:e.formId,elementId:e.elementId,nodeName:e.nodeName,elementClasses:e.elementClasses,value:e.value},"change_form"===t?(n="iglu:com.snowplowanalytics.snowplow/change_form/jsonschema/1-0-0",e.type=r):"focus_form"===t&&(n="iglu:com.snowplowanalytics.snowplow/focus_form/jsonschema/1-0-0",e.elementType=r),P({event:{schema:n,data:j(e,{value:!0})}})},e.buildFormSubmission=function(e){return P({event:{schema:"iglu:com.snowplowanalytics.snowplow/submit_form/jsonschema/1-0-0",data:j({formId:e.formId,formClasses:e.formClasses,elements:e.elements})}})},e.buildLinkClick=function(e){return P({event:e={schema:"iglu:com.snowplowanalytics.snowplow/link_click/jsonschema/1-0-1",data:j({targetUrl:e.targetUrl,elementId:e.elementId,elementClasses:e.elementClasses,elementTarget:e.elementTarget,elementContent:e.elementContent})}})},e.buildPagePing=function(e){var t=e.pageUrl,r=e.pageTitle,o=e.referrer,a=e.minXOffset,i=e.maxXOffset,c=e.minYOffset;e=e.maxYOffset;var s=n();return s.add("e","pp"),s.add("url",t),s.add("page",r),s.add("refr",o),a&&!isNaN(Number(a))&&s.add("pp_mix",a.toString()),i&&!isNaN(Number(i))&&s.add("pp_max",i.toString()),c&&!isNaN(Number(c))&&s.add("pp_miy",c.toString()),e&&!isNaN(Number(e))&&s.add("pp_may",e.toString()),s},e.buildPageView=function(e){var t=e.pageUrl,r=e.pageTitle;e=e.referrer;var o=n();return o.add("e","pv"),o.add("url",t),o.add("page",r),o.add("refr",e),o},e.buildRemoveFromCart=function(e){return P({event:{schema:"iglu:com.snowplowanalytics.snowplow/remove_from_cart/jsonschema/1-0-0",data:j({sku:e.sku,quantity:e.quantity,name:e.name,category:e.category,unitPrice:e.unitPrice,currency:e.currency})}})},e.buildScreenView=function(e){return P({event:{schema:"iglu:com.snowplowanalytics.snowplow/screen_view/jsonschema/1-0-0",data:j({name:e.name,id:e.id})}})},e.buildSelfDescribingEvent=P,e.buildSiteSearch=function(e){return P({event:{schema:"iglu:com.snowplowanalytics.snowplow/site_search/jsonschema/1-0-0",data:j({terms:e.terms,filters:e.filters,totalResults:e.totalResults,pageResults:e.pageResults})}})},e.buildSocialInteraction=function(e){return P({event:e={schema:"iglu:com.snowplowanalytics.snowplow/social_interaction/jsonschema/1-0-0",data:j({action:e.action,network:e.network,target:e.target})}})},e.buildStructEvent=function(e){var t=e.category,r=e.action,o=e.label,a=e.property;e=e.value;var i=n();return i.add("e","se"),i.add("se_ca",t),i.add("se_ac",r),i.add("se_la",o),i.add("se_pr",a),i.add("se_va",null==e?void 0:e.toString()),i},e.getRuleParts=d,e.getSchemaParts=s,e.globalContexts=i,e.isConditionalContextProvider=_,e.isContextCallbackFunction=g,e.isContextPrimitive=h,e.isFilterProvider=w,e.isJson=o,e.isNonEmptyJson=r,e.isRuleSet=v,e.isRuleSetProvider=b,e.isSelfDescribingJson=y,e.isStringArray=p,e.isValidRule=f,e.isValidRuleSetArg=m,e.matchSchemaAgainstRule=A,e.matchSchemaAgainstRuleSet=C,e.payloadBuilder=n,e.payloadJsonProcessor=t,e.pluginContexts=c,e.resolveDynamicContext=function(e){for(var n,t=[],r=1;r<arguments.length;r++)t[r-1]=arguments[r];return null!==(n=null==e?void 0:e.map((function(e){if("function"!=typeof e)return e;try{return e.apply(void 0,t)}catch(e){}})).filter(Boolean))&&void 0!==n?n:[]},e.trackerCore=function(e){void 0===e&&(e={});var n,r,a,s,l,u,d,f=e.base64,p=e.corePlugins,m=null!=p?p:[];n=null==f||f,r=m,a=e.callback,s=c(r),l=i(),u=n,d={};var y=S(S({},e={track:function(e,n,o){e.withJsonProcessor(t(u)),e.add("eid",q.v4()),e.addDict(d),o=function(e){return null==e?{type:"dtm",value:(new Date).getTime()}:"number"==typeof e?{type:"dtm",value:e}:"ttm"===e.type?{type:"ttm",value:e.value}:{type:"dtm",value:e.value||(new Date).getTime()}}(o),e.add(o.type,o.value.toString()),void 0!==(n=(n=function(e,n){e=l.getApplicableContexts(e);var t=[];return n&&n.length&&t.push.apply(t,n),e&&e.length&&t.push.apply(t,e),t}(e,s.addPluginContexts(n)))&&n.length?{schema:"iglu:com.snowplowanalytics.snowplow/contexts/jsonschema/1-0-0",data:n}:void 0)&&e.addJson("cx","co",n),r.forEach((function(n){try{n.beforeTrack&&n.beforeTrack(e)}catch(e){T.error("Plugin beforeTrack",e)}})),"function"==typeof a&&a(e);var i=e.build();return r.forEach((function(e){try{e.afterTrack&&e.afterTrack(i)}catch(e){T.error("Plugin afterTrack",e)}})),i},addPayloadPair:function(e,n){d[e]=n},getBase64Encoding:function(){return u},setBase64Encoding:function(e){u=e},addPayloadDict:function(e){for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&(d[n]=e[n])},resetPayloadPairs:function(e){d=o(e)?e:{}},setTrackerVersion:function(e){d.tv=e},setTrackerNamespace:function(e){d.tna=e},setAppId:function(e){d.aid=e},setPlatform:function(e){d.p=e},setUserId:function(e){d.uid=e},setScreenResolution:function(e,n){d.res=e+"x"+n},setViewport:function(e,n){d.vp=e+"x"+n},setColorDepth:function(e){d.cd=e},setTimezone:function(e){d.tz=e},setLang:function(e){d.lang=e},setIpAddress:function(e){d.ip=e},setUseragent:function(e){d.ua=e},addGlobalContexts:function(e){l.addGlobalContexts(e)},clearGlobalContexts:function(){l.clearGlobalContexts()},removeGlobalContexts:function(e){l.removeGlobalContexts(e)}}),{addPlugin:function(e){var n,t;e=e.plugin,m.push(e),null===(n=e.logger)||void 0===n||n.call(e,T),null===(t=e.activateCorePlugin)||void 0===t||t.call(e,y)}});return null==m||m.forEach((function(e){var n,t;null===(n=e.logger)||void 0===n||n.call(e,T),null===(t=e.activateCorePlugin)||void 0===t||t.call(e,y)})),y},e.validateVendor=u,e.validateVendorParts=l,e.version="3.2.3",Object.defineProperty(e,"__esModule",{value:!0})})); | ||
"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).snowplowTrackerCore={})}(this,(function(e){function n(){var e,n={},t=[],o=[],a=function(e,t){null!=t&&""!==t&&(n[e]=t)};return{add:a,addDict:function(e){for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&a(n,e[n])},addJson:function(e,n,a){a&&r(a)&&(e={keyIfEncoded:e,keyIfNotEncoded:n,json:a},o.push(e),t.push(e))},getPayload:function(){return n},getJson:function(){return t},withJsonProcessor:function(n){e=n},build:function(){return null==e||e(this,o),n}}}function t(e){return function(n,t){for(var r=0;r<t.length;r++){var o=t[r],a=JSON.stringify(o.json);if(e){var i=n,c=i.add;if(o=o.keyIfEncoded,a){var s=0,l=0,u=[];if(a){a=unescape(encodeURIComponent(a));do{var d=a.charCodeAt(s++),f=a.charCodeAt(s++),p=a.charCodeAt(s++),m=d<<16|f<<8|p;d=m>>18&63,f=m>>12&63,p=m>>6&63,m&=63,u[l++]=O.charAt(d)+O.charAt(f)+O.charAt(p)+O.charAt(m)}while(s<a.length);s=u.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(i,o,a)}else n.add(o.keyIfNotEncoded,a)}t.length=0}}function r(e){if(!o(e))return!1;for(var n in e)if(Object.prototype.hasOwnProperty.call(e,n))return!0;return!1}function o(e){return null!=e&&(e.constructor==={}.constructor||e.constructor===[].constructor)}function a(e,n,t){if(t||2===arguments.length)for(var r,o=0,a=n.length;o<a;o++)!r&&o in n||(r||(r=Array.prototype.slice.call(n,0,o)),r[o]=n[o]);return e.concat(r||n)}function i(){var e=[],n=[];return{getGlobalPrimitives:function(){return e},getConditionalProviders:function(){return n},addGlobalContexts:function(t){for(var r=[],o=[],a=0;a<t.length;a++){var i=t[a];_(i)?r.push(i):h(i)&&o.push(i)}e=e.concat(o),n=n.concat(r)},clearGlobalContexts:function(){n=[],e=[]},removeGlobalContexts:function(t){for(var r=function(t){_(t)?n=n.filter((function(e){return JSON.stringify(e)!==JSON.stringify(t)})):h(t)&&(e=e.filter((function(e){return JSON.stringify(e)!==JSON.stringify(t)})))},o=0;o<t.length;o++)r(t[o])},getApplicableContexts:function(t){e:{for(var r=0,o=t.getJson();r<o.length;r++){var a=o[r];if("ue_px"===a.keyIfEncoded&&"object"==typeof a.json.data&&"string"==typeof(a=a.json.data.schema)){r=a;break e}}r=""}a="string"==typeof(o=t.getPayload().e)?o:"",o=[];var i=k(e,t,a,r);return o.push.apply(o,i),t=function(e,n,t,r){var o;return e=x(e).map((function(e){e:{if(w(e)){var o=e[0],a=!1;try{a=o({event:n.getPayload(),eventType:t,eventSchema:r})}catch(e){a=!1}if(!0===a){e=k(e[1],n,t,r);break e}}else if(b(e)&&C(e[0],r)){e=k(e[1],n,t,r);break e}e=[]}if(e&&0!==e.length)return e})),(o=[]).concat.apply(o,e.filter((function(e){return null!=e&&e.filter(Boolean)})))}(n,t,a,r),o.push.apply(o,t),o}}}function c(e){return{addPluginContexts:function(n){var t=null!=n?n:[];return e.forEach((function(e){try{e.contexts&&t.push.apply(t,e.contexts())}catch(e){T.error("Error adding plugin contexts",e)}})),t}}}function s(e){if(null!==(e=/^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(e)))return e.slice(1,6)}function l(e){if("*"===e[0]||"*"===e[1])return!1;if(0<e.slice(2).length){var n=!1,t=0;for(e=e.slice(2);t<e.length;t++)if("*"===e[t])n=!0;else if(n)return!1;return!0}return 2==e.length}function u(e){return!!((e=e.split("."))&&1<e.length)&&l(e)}function d(e){if(null!==(e=/^iglu:((?:(?:[a-zA-Z0-9-_]+|\*).)+(?:[a-zA-Z0-9-_]+|\*))\/([a-zA-Z0-9-_.]+|\*)\/jsonschema\/([1-9][0-9]*|\*)-(0|[1-9][0-9]*|\*)-(0|[1-9][0-9]*|\*)$/.exec(e))&&u(e[1]))return e.slice(1,6)}function f(e){if(e=d(e)){var n=e[0];return 5===e.length&&u(n)}return!1}function p(e){return Array.isArray(e)&&e.every((function(e){return"string"==typeof e}))}function m(e){return p(e)?e.every((function(e){return f(e)})):"string"==typeof e&&f(e)}function y(e){return!!(r(e)&&"schema"in e&&"data"in e)&&("string"==typeof e.schema&&"object"==typeof e.data)}function v(e){var n=0;if(null!=e&&"object"==typeof e&&!Array.isArray(e)){if(Object.prototype.hasOwnProperty.call(e,"accept")){if(!m(e.accept))return!1;n+=1}if(Object.prototype.hasOwnProperty.call(e,"reject")){if(!m(e.reject))return!1;n+=1}return 0<n&&2>=n}return!1}function g(e){return"function"==typeof e&&1>=e.length}function h(e){return g(e)||y(e)}function w(e){return!(!Array.isArray(e)||2!==e.length)&&(Array.isArray(e[1])?g(e[0])&&e[1].every(h):g(e[0])&&h(e[1]))}function b(e){return!(!Array.isArray(e)||2!==e.length)&&(!!v(e[0])&&(Array.isArray(e[1])?e[1].every(h):h(e[1])))}function _(e){return w(e)||b(e)}function C(e,n){var t=0,r=0,o=e.accept;return Array.isArray(o)?e.accept.some((function(e){return A(e,n)}))&&r++:"string"==typeof o&&A(o,n)&&r++,o=e.reject,Array.isArray(o)?e.reject.some((function(e){return A(e,n)}))&&t++:"string"==typeof o&&A(o,n)&&t++,0<r&&0===t}function A(e,n){if(!f(e))return!1;if(e=d(e),n=s(n),e&&n){if(!function(e,n){if(n=n.split("."),e=e.split("."),n&&e){if(n.length!==e.length)return!1;for(var t=0;t<e.length;t++)if(!I(n[t],e[t]))return!1;return!0}return!1}(e[0],n[0]))return!1;for(var t=1;5>t;t++)if(!I(e[t],n[t]))return!1;return!0}return!1}function I(e,n){return e&&n&&"*"===e||e===n}function x(e){return Array.isArray(e)?e:[e]}function k(e,n,t,r){var o;return e=x(e).map((function(e){e:if(y(e))e=[e];else{if(g(e)){n:{var o=void 0;try{if(o=e({event:n.getPayload(),eventType:t,eventSchema:r}),Array.isArray(o)&&o.every(y)||y(o)){var a=o;break n}a=void 0;break n}catch(e){}a=void 0}if(y(a)){e=[a];break e}if(Array.isArray(a)){e=a;break e}}e=void 0}if(e&&0!==e.length)return e})),(o=[]).concat.apply(o,e.filter((function(e){return null!=e&&e.filter(Boolean)})))}function P(e){var t=e.event;return e={schema:"iglu:com.snowplowanalytics.snowplow/unstruct_event/jsonschema/1-0-0",data:{schema:e=t.schema,data:t.data}},(t=n()).add("e","ue"),t.addJson("ue_px","ue_pr",e),t}function j(e,n){void 0===n&&(n={});var t,r={};for(t in e)(n[t]||null!==e[t]&&void 0!==e[t])&&(r[t]=e[t]);return r}var E,L,O="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",S=function(){return(S=Object.assign||function(e){for(var n,t=1,r=arguments.length;t<r;t++)for(var o in n=arguments[t])Object.prototype.hasOwnProperty.call(n,o)&&(e[o]=n[o]);return e}).apply(this,arguments)};e.LOG_LEVEL=void 0,(E=e.LOG_LEVEL||(e.LOG_LEVEL={}))[E.none=0]="none",E[E.error=1]="error",E[E.warn=2]="warn",E[E.debug=3]="debug",E[E.info=4]="info";for(var T=function(n){return void 0===n&&(n=e.LOG_LEVEL.warn),{setLogLevel:function(t){n=e.LOG_LEVEL[t]?t:e.LOG_LEVEL.warn},warn:function(t,r){for(var o=[],i=2;i<arguments.length;i++)o[i-2]=arguments[i];n>=e.LOG_LEVEL.warn&&"undefined"!=typeof console&&(i="Snowplow: "+t,r?console.warn.apply(console,a([i+"\n",r],o)):console.warn.apply(console,a([i],o)))},error:function(t,r){for(var o=[],i=2;i<arguments.length;i++)o[i-2]=arguments[i];n>=e.LOG_LEVEL.error&&"undefined"!=typeof console&&(i="Snowplow: "+t+"\n",r?console.error.apply(console,a([i+"\n",r],o)):console.error.apply(console,a([i],o)))},debug:function(t){for(var r=[],o=1;o<arguments.length;o++)r[o-1]=arguments[o];n>=e.LOG_LEVEL.debug&&"undefined"!=typeof console&&console.debug.apply(console,a(["Snowplow: "+t],r))},info:function(t){for(var r=[],o=1;o<arguments.length;o++)r[o-1]=arguments[o];n>=e.LOG_LEVEL.info&&"undefined"!=typeof console&&console.info.apply(console,a(["Snowplow: "+t],r))}}}(),V=(L=void 0,function(e){var n="undefined"!=typeof crypto&&crypto.getRandomValues&&crypto.getRandomValues.bind(crypto)||"undefined"!=typeof msCrypto&&"function"==typeof window.msCrypto.getRandomValues&&msCrypto.getRandomValues.bind(msCrypto);if(n){var t=new Uint8Array(16);e.exports=function(){return n(t),t}}else{var r=Array(16);e.exports=function(){for(var e,n=0;16>n;n++)0==(3&n)&&(e=4294967296*Math.random()),r[n]=e>>>((3&n)<<3)&255;return r}}}(L={exports:{}}),L.exports),N=[],G=0;256>G;++G)N[G]=(G+256).toString(16).substr(1);var R,J,U=function(e,n){return n=n||0,[N[e[n++]],N[e[n++]],N[e[n++]],N[e[n++]],"-",N[e[n++]],N[e[n++]],"-",N[e[n++]],N[e[n++]],"-",N[e[n++]],N[e[n++]],"-",N[e[n++]],N[e[n++]],N[e[n++]],N[e[n++]],N[e[n++]],N[e[n++]]].join("")},z=0,D=0,q=function(e,n,t){if(t=n&&t||0,"string"==typeof e&&(n="binary"===e?Array(16):null,e=null),(e=(e=e||{}).random||(e.rng||V)())[6]=15&e[6]|64,e[8]=63&e[8]|128,n)for(var r=0;16>r;++r)n[t+r]=e[r];return n||U(e)};q.v1=function(e,n,t){t=n&&t||0;var r=n||[],o=(e=e||{}).node||R,a=void 0!==e.clockseq?e.clockseq:J;if(null==o||null==a){var i=V();null==o&&(o=R=[1|i[0],i[1],i[2],i[3],i[4],i[5]]),null==a&&(a=J=16383&(i[6]<<8|i[7]))}i=void 0!==e.msecs?e.msecs:(new Date).getTime();var c=void 0!==e.nsecs?e.nsecs:D+1,s=i-z+(c-D)/1e4;if(0>s&&void 0===e.clockseq&&(a=a+1&16383),(0>s||i>z)&&void 0===e.nsecs&&(c=0),1e4<=c)throw Error("uuid.v1(): Can't create more than 10M uuids/sec");for(z=i,D=c,J=a,e=(1e4*(268435455&(i+=122192928e5))+c)%4294967296,r[t++]=e>>>24&255,r[t++]=e>>>16&255,r[t++]=e>>>8&255,r[t++]=255&e,e=i/4294967296*1e4&268435455,r[t++]=e>>>8&255,r[t++]=255&e,r[t++]=e>>>24&15|16,r[t++]=e>>>16&255,r[t++]=a>>>8|128,r[t++]=255&a,a=0;6>a;++a)r[t+a]=o[a];return n||U(r)},q.v4=q,e.LOG=T,e.buildAdClick=function(e){return P({event:e={schema:"iglu:com.snowplowanalytics.snowplow/ad_click/jsonschema/1-0-0",data:j({targetUrl:e.targetUrl,clickId:e.clickId,costModel:e.costModel,cost:e.cost,bannerId:e.bannerId,zoneId:e.zoneId,impressionId:e.impressionId,advertiserId:e.advertiserId,campaignId:e.campaignId})}})},e.buildAdConversion=function(e){return P({event:e={schema:"iglu:com.snowplowanalytics.snowplow/ad_conversion/jsonschema/1-0-0",data:j({conversionId:e.conversionId,costModel:e.costModel,cost:e.cost,category:e.category,action:e.action,property:e.property,initialValue:e.initialValue,advertiserId:e.advertiserId,campaignId:e.campaignId})}})},e.buildAdImpression=function(e){return P({event:e={schema:"iglu:com.snowplowanalytics.snowplow/ad_impression/jsonschema/1-0-0",data:j({impressionId:e.impressionId,costModel:e.costModel,cost:e.cost,targetUrl:e.targetUrl,bannerId:e.bannerId,zoneId:e.zoneId,advertiserId:e.advertiserId,campaignId:e.campaignId})}})},e.buildAddToCart=function(e){return P({event:{schema:"iglu:com.snowplowanalytics.snowplow/add_to_cart/jsonschema/1-0-0",data:j({sku:e.sku,quantity:e.quantity,name:e.name,category:e.category,unitPrice:e.unitPrice,currency:e.currency})}})},e.buildConsentGranted=function(e){var n=e.expiry;return e={schema:"iglu:com.snowplowanalytics.snowplow/consent_document/jsonschema/1-0-0",data:j({id:e.id,version:e.version,name:e.name,description:e.description})},{event:P({event:{schema:"iglu:com.snowplowanalytics.snowplow/consent_granted/jsonschema/1-0-0",data:j({expiry:n})}}),context:[e]}},e.buildConsentWithdrawn=function(e){var n=e.all;return e={schema:"iglu:com.snowplowanalytics.snowplow/consent_document/jsonschema/1-0-0",data:j({id:e.id,version:e.version,name:e.name,description:e.description})},{event:P({event:{schema:"iglu:com.snowplowanalytics.snowplow/consent_withdrawn/jsonschema/1-0-0",data:j({all:n})}}),context:[e]}},e.buildEcommerceTransaction=function(e){var t=e.orderId,r=e.total,o=e.affiliation,a=e.tax,i=e.shipping,c=e.city,s=e.state,l=e.country;e=e.currency;var u=n();return u.add("e","tr"),u.add("tr_id",t),u.add("tr_af",o),u.add("tr_tt",r),u.add("tr_tx",a),u.add("tr_sh",i),u.add("tr_ci",c),u.add("tr_st",s),u.add("tr_co",l),u.add("tr_cu",e),u},e.buildEcommerceTransactionItem=function(e){var t=e.orderId,r=e.sku,o=e.price,a=e.name,i=e.category,c=e.quantity;e=e.currency;var s=n();return s.add("e","ti"),s.add("ti_id",t),s.add("ti_sk",r),s.add("ti_nm",a),s.add("ti_ca",i),s.add("ti_pr",o),s.add("ti_qu",c),s.add("ti_cu",e),s},e.buildFormFocusOrChange=function(e){var n="",t=e.schema,r=e.type;return e={formId:e.formId,elementId:e.elementId,nodeName:e.nodeName,elementClasses:e.elementClasses,value:e.value},"change_form"===t?(n="iglu:com.snowplowanalytics.snowplow/change_form/jsonschema/1-0-0",e.type=r):"focus_form"===t&&(n="iglu:com.snowplowanalytics.snowplow/focus_form/jsonschema/1-0-0",e.elementType=r),P({event:{schema:n,data:j(e,{value:!0})}})},e.buildFormSubmission=function(e){return P({event:{schema:"iglu:com.snowplowanalytics.snowplow/submit_form/jsonschema/1-0-0",data:j({formId:e.formId,formClasses:e.formClasses,elements:e.elements})}})},e.buildLinkClick=function(e){return P({event:e={schema:"iglu:com.snowplowanalytics.snowplow/link_click/jsonschema/1-0-1",data:j({targetUrl:e.targetUrl,elementId:e.elementId,elementClasses:e.elementClasses,elementTarget:e.elementTarget,elementContent:e.elementContent})}})},e.buildPagePing=function(e){var t=e.pageUrl,r=e.pageTitle,o=e.referrer,a=e.minXOffset,i=e.maxXOffset,c=e.minYOffset;e=e.maxYOffset;var s=n();return s.add("e","pp"),s.add("url",t),s.add("page",r),s.add("refr",o),a&&!isNaN(Number(a))&&s.add("pp_mix",a.toString()),i&&!isNaN(Number(i))&&s.add("pp_max",i.toString()),c&&!isNaN(Number(c))&&s.add("pp_miy",c.toString()),e&&!isNaN(Number(e))&&s.add("pp_may",e.toString()),s},e.buildPageView=function(e){var t=e.pageUrl,r=e.pageTitle;e=e.referrer;var o=n();return o.add("e","pv"),o.add("url",t),o.add("page",r),o.add("refr",e),o},e.buildRemoveFromCart=function(e){return P({event:{schema:"iglu:com.snowplowanalytics.snowplow/remove_from_cart/jsonschema/1-0-0",data:j({sku:e.sku,quantity:e.quantity,name:e.name,category:e.category,unitPrice:e.unitPrice,currency:e.currency})}})},e.buildScreenView=function(e){return P({event:{schema:"iglu:com.snowplowanalytics.snowplow/screen_view/jsonschema/1-0-0",data:j({name:e.name,id:e.id})}})},e.buildSelfDescribingEvent=P,e.buildSiteSearch=function(e){return P({event:{schema:"iglu:com.snowplowanalytics.snowplow/site_search/jsonschema/1-0-0",data:j({terms:e.terms,filters:e.filters,totalResults:e.totalResults,pageResults:e.pageResults})}})},e.buildSocialInteraction=function(e){return P({event:e={schema:"iglu:com.snowplowanalytics.snowplow/social_interaction/jsonschema/1-0-0",data:j({action:e.action,network:e.network,target:e.target})}})},e.buildStructEvent=function(e){var t=e.category,r=e.action,o=e.label,a=e.property;e=e.value;var i=n();return i.add("e","se"),i.add("se_ca",t),i.add("se_ac",r),i.add("se_la",o),i.add("se_pr",a),i.add("se_va",null==e?void 0:e.toString()),i},e.getRuleParts=d,e.getSchemaParts=s,e.globalContexts=i,e.isConditionalContextProvider=_,e.isContextCallbackFunction=g,e.isContextPrimitive=h,e.isFilterProvider=w,e.isJson=o,e.isNonEmptyJson=r,e.isRuleSet=v,e.isRuleSetProvider=b,e.isSelfDescribingJson=y,e.isStringArray=p,e.isValidRule=f,e.isValidRuleSetArg=m,e.matchSchemaAgainstRule=A,e.matchSchemaAgainstRuleSet=C,e.payloadBuilder=n,e.payloadJsonProcessor=t,e.pluginContexts=c,e.resolveDynamicContext=function(e){for(var n,t=[],r=1;r<arguments.length;r++)t[r-1]=arguments[r];return null!==(n=null==e?void 0:e.map((function(e){if("function"!=typeof e)return e;try{return e.apply(void 0,t)}catch(e){}})).filter(Boolean))&&void 0!==n?n:[]},e.trackerCore=function(e){void 0===e&&(e={});var n,r,a,s,l,u,d,f=e.base64,p=e.corePlugins,m=null!=p?p:[];n=null==f||f,r=m,a=e.callback,s=c(r),l=i(),u=n,d={};var y=S(S({},e={track:function(e,n,o){e.withJsonProcessor(t(u)),e.add("eid",q.v4()),e.addDict(d),o=function(e){return null==e?{type:"dtm",value:(new Date).getTime()}:"number"==typeof e?{type:"dtm",value:e}:"ttm"===e.type?{type:"ttm",value:e.value}:{type:"dtm",value:e.value||(new Date).getTime()}}(o),e.add(o.type,o.value.toString()),void 0!==(n=(n=function(e,n){e=l.getApplicableContexts(e);var t=[];return n&&n.length&&t.push.apply(t,n),e&&e.length&&t.push.apply(t,e),t}(e,s.addPluginContexts(n)))&&n.length?{schema:"iglu:com.snowplowanalytics.snowplow/contexts/jsonschema/1-0-0",data:n}:void 0)&&e.addJson("cx","co",n),r.forEach((function(n){try{n.beforeTrack&&n.beforeTrack(e)}catch(e){T.error("Plugin beforeTrack",e)}})),"function"==typeof a&&a(e);var i=e.build();return r.forEach((function(e){try{e.afterTrack&&e.afterTrack(i)}catch(e){T.error("Plugin afterTrack",e)}})),i},addPayloadPair:function(e,n){d[e]=n},getBase64Encoding:function(){return u},setBase64Encoding:function(e){u=e},addPayloadDict:function(e){for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&(d[n]=e[n])},resetPayloadPairs:function(e){d=o(e)?e:{}},setTrackerVersion:function(e){d.tv=e},setTrackerNamespace:function(e){d.tna=e},setAppId:function(e){d.aid=e},setPlatform:function(e){d.p=e},setUserId:function(e){d.uid=e},setScreenResolution:function(e,n){d.res=e+"x"+n},setViewport:function(e,n){d.vp=e+"x"+n},setColorDepth:function(e){d.cd=e},setTimezone:function(e){d.tz=e},setLang:function(e){d.lang=e},setIpAddress:function(e){d.ip=e},setUseragent:function(e){d.ua=e},addGlobalContexts:function(e){l.addGlobalContexts(e)},clearGlobalContexts:function(){l.clearGlobalContexts()},removeGlobalContexts:function(e){l.removeGlobalContexts(e)}}),{addPlugin:function(e){var n,t;e=e.plugin,m.push(e),null===(n=e.logger)||void 0===n||n.call(e,T),null===(t=e.activateCorePlugin)||void 0===t||t.call(e,y)}});return null==m||m.forEach((function(e){var n,t;null===(n=e.logger)||void 0===n||n.call(e,T),null===(t=e.activateCorePlugin)||void 0===t||t.call(e,y)})),y},e.validateVendor=u,e.validateVendorParts=l,e.version="3.3.0",Object.defineProperty(e,"__esModule",{value:!0})})); | ||
//# sourceMappingURL=index.min.js.map |
/*! | ||
* Core functionality for Snowplow JavaScript trackers v3.2.3 (http://bit.ly/sp-js) | ||
* Core functionality for Snowplow JavaScript trackers v3.3.0 (http://bit.ly/sp-js) | ||
* Copyright 2022 Snowplow Analytics Ltd, 2010 Anthon Pang | ||
@@ -10,3 +10,3 @@ * Licensed under BSD-3-Clause | ||
var version$1 = "3.2.3"; | ||
var version$1 = "3.3.0"; | ||
@@ -13,0 +13,0 @@ /* |
{ | ||
"name": "@snowplow/tracker-core", | ||
"version": "3.2.3", | ||
"version": "3.3.0", | ||
"description": "Core functionality for Snowplow JavaScript trackers", | ||
@@ -5,0 +5,0 @@ "keywords": [ |
Sorry, the diff of this file is too big to display
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package