@abtasty/scroll-tracking
Advanced tools
Comparing version 3.4.1 to 3.4.2
@@ -1,1 +0,1 @@ | ||
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?module.exports=t():"function"==typeof define&&define.amd?define(t):(e="undefined"!=typeof globalThis?globalThis:e||self).widgetForm=t()}(this,function(){"use strict";const e="conditions",t="inlinenotification";function r(e,t){(null==t||t>e.length)&&(t=e.length);for(var r=0,o=new Array(t);r<t;r++)o[r]=e[r];return o}var o,l=ABTASTY_S.CLIENT_MANAGER,n=l.getDocument,a=l.getCssSelector,i=(o=n().querySelectorAll("body *"),function(e){if(Array.isArray(e))return r(e)}(o)||function(e){if("undefined"!=typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)}(o)||function(e,t){if(e){if("string"==typeof e)return r(e,t);var o=Object.prototype.toString.call(e).slice(8,-1);return"Object"===o&&e.constructor&&(o=e.constructor.name),"Map"===o||"Set"===o?Array.from(e):"Arguments"===o||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(o)?r(e,t):void 0}}(o)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()).reduce(function(e,t){var r=getComputedStyle(t).overflowY,o=t.scrollHeight,l=t.parentElement,n=o>e.scrollHeight,a=["auto","scroll"].includes(r),i=o>l.scrollHeight;return n&&a&&i?t:e},n().body),c={category:e,type:t,label:"widget_trackingWidget_note",hrefUrl:""};return[{category:e,type:"switch",propName:"customTarget",label:"widget_scrollTracking_label_useCustomTarget",value:i!==n().body},{category:e,type:t,label:"widget_scrollTracking_descriptionTarget",hrefUrl:"",condition:function(e){return e.customTarget}},{category:e,type:"selectelement",propName:"scrollTarget",label:"widget_scrollTracking_label_target",value:a(i),condition:function(e){return e.customTarget}},{category:e,type:"short-separator"},c,{category:e,propName:"engagementGoal",type:"replicable",children:[{type:"text",propName:"name",label:"widget_scrollTracking_label_trackerName",defaultValue:"Scroll 50%",value:"Scroll 50%"},{type:"slider",propName:"percentage",label:"widget_scrollTracking_label_scrollPercentage",unit:"%",min:0,max:100,defaultValue:50,value:50}]}]}); | ||
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?module.exports=t():"function"==typeof define&&define.amd?define(t):(e="undefined"!=typeof globalThis?globalThis:e||self).widgetForm=t()}(this,function(){"use strict";const e="conditions",t="inlinenotification",{getDocument:l,getCssSelector:r}=ABTASTY_S.CLIENT_MANAGER,o=[...l().querySelectorAll("body *")].reduce((e,t)=>{const{overflowY:l}=getComputedStyle(t),{scrollHeight:r,parentElement:o}=t,a=r>e.scrollHeight,c=["auto","scroll"].includes(l),n=r>o.scrollHeight;return a&&c&&n?t:e},l().body),a={category:e,type:t,label:"widget_trackingWidget_note",hrefUrl:""};return[{category:e,type:"switch",propName:"customTarget",label:"widget_scrollTracking_label_useCustomTarget",value:o!==l().body},{category:e,type:t,label:"widget_scrollTracking_descriptionTarget",hrefUrl:"",condition:e=>{let{customTarget:t}=e;return t}},{category:e,type:"selectelement",propName:"scrollTarget",label:"widget_scrollTracking_label_target",value:r(o),condition:e=>{let{customTarget:t}=e;return t}},{category:e,type:"short-separator"},a,{category:e,propName:"engagementGoal",type:"replicable",children:[{type:"text",propName:"name",label:"widget_scrollTracking_label_trackerName",defaultValue:"Scroll 50%",value:"Scroll 50%"},{type:"slider",propName:"percentage",label:"widget_scrollTracking_label_scrollPercentage",unit:"%",min:0,max:100,defaultValue:50,value:50}]}]}); |
@@ -1,1 +0,1 @@ | ||
!function(){"use strict";const e=()=>Object.prototype.hasOwnProperty.call(window,"ABTastyEditor"),t=()=>{const e=!!document.getElementById("ABTastyPreviewBar"),t=location.href.includes("ab_project=preview");return e||t},r=()=>!e()&&(t()||!!window.ABTasty.getTestsOnPage()[TEST_ID]),n=(e,t)=>{const r=()=>{try{return document.querySelector(e)}catch(e){return null}};let n=r();const s=[document.body||document.documentElement,{childList:!0,subtree:!0,attributes:!0}],i=()=>o.disconnect(),c=()=>o.observe(...s),o=new MutationObserver(()=>(n=r(),n&&!i()&&t(n)));return n?setTimeout(()=>t(n),0):c(),{selector:e,clear:i,observe:c}},s="abtasty_resetActionTracking",i="remove",c="rebuild",o=r=>{if((()=>{if(e()||t())return!1;const r=ABTasty.getTestsOnPage()[TEST_ID];return!!r&&Object.keys(r.targetings.qaParameters).length>0})()){const e=(()=>{const e=(()=>{const{type:e}=DATA;return`${PACKAGE.replace("@abtasty/","")}${e?`_${e}`:""}`})();return`${e.charAt(0).toUpperCase()}${e.slice(1)}`.split("-").join(" ")})();window.console.log(`%c${e} - QA Mode for campaign ${TEST_ID}\n${r}`,"background-color: rgba(0, 127, 145, 1); color: rgba(247, 247, 247, 1)")}};class a{constructor(e,t,r,n){this.recurrence=e,this.isWidgetApplied=t,this.callback=r,this.shouldUpdate=n,this.observer=new MutationObserver(this.observerHandler.bind(this)),this.eventListenerParams=[s,this.eventHandler.bind(this),{passive:!0}],this.elementsWaiters=[]}recurrenceIsDone(){return!this.recurrence||this.recurrence.isOver()}decisionHandler(e){const t=r(),{type:n}=this.recurrence?this.recurrence.getCurrentRecurrence():{type:!1};let s;const o=this.isWidgetApplied(),a=(()=>{const t=this.recurrenceIsDone();return e&&"display"===n||t})(),l=!o&&t&&a,u=o&&(!t||!a),d=!o&&!t;return this.shouldUpdate&&!e&&t&&a?s="update":l?s=c:(u||d)&&(s=i),"string"==typeof s&&(this.clearWatcher(),this.callback(s,e),this.watch()),this}eventHandler(){let e=r();return[250,500].forEach(t=>{setTimeout(()=>{const n=r();return 500===t&&n===e?this:(e=n,this.decisionHandler(!1))},t)}),this}observerHandler(e){return e.some(e=>["removedNodes","addedNodes"].some(t=>e[t]&&e[t].length))?this.decisionHandler(!0):this}watch(){if(e())return this;this.clearWatcher(),document.addEventListener(...this.eventListenerParams);const t=()=>{const e=[document.body,{childList:!0,subtree:!0}];this.observer.observe(...e)};return document.body?t():(()=>{const e=n("body",()=>{t(),this.elementsWaiters=this.elementsWaiters.filter(t=>t!==e)});this.elementsWaiters.push(e)})(),this}clearWatcher(){return document.removeEventListener(...this.eventListenerParams),this.elementsWaiters.length&&(this.elementsWaiters.forEach(e=>e.clear()),this.elementsWaiters=[]),this.observer.disconnect(),this}}var l,u,d=!1,h=function(){return null},m=DATA,v=m.engagementGoal,p=m.customTarget,g=m.scrollTarget,b=function(){return v.sort(function(e,t){return e.percentage-t.percentage})},y=["scroll",function(){return A()},{passive:!0}],f=[s,function(){u=b()},{passive:!0}],T=function(){(l=l||new a(!1,function(){return d},W)).watch()},w=function(){var e;d=!1;var t=p?document.querySelector(g):window;t&&t.removeEventListener.apply(t,y),(e=document).removeEventListener.apply(e,f),T()},E=function(e){var t;o("Widget launch"),d=!0,u=b();var r=p?e:window;r.addEventListener.apply(r,y),(t=document).addEventListener.apply(t,f),T()},A=function(){var e,t=(e=p?document.querySelector(g):document.body.scrollTop>0?document.body:document.documentElement)?100*e.scrollTop/(Math.max(e.scrollHeight,e.offsetHeight,e.clientHeight)-(p?e.parentElement.clientHeight:window.innerHeight)):0;(u=u.filter(function(e){var r=e.percentage,n=e.name;return!(t>=r&&(ABTastyEvent(n,null,TEST_ID),o('Engagement goal "'.concat(n,'" sent to campaign ').concat(TEST_ID,".")),1))})).length||w()},W=function(e,t){switch(e){case i:w(),h();break;case c:if(t)T();else{var r=n(p?g:"body",E);h=r.clear}}};if(!e()){var H=n(p?g:"body",E);h=H.clear,T()}}(); | ||
!function(){"use strict";const e=(e,t)=>{const n=()=>{try{return document.querySelector(e)}catch(e){return null}};let r=n();const o=[document.body||document.documentElement,{childList:!0,subtree:!0,attributes:!0}],c=()=>s.disconnect(),a=()=>s.observe(...o),s=new MutationObserver(()=>(r=n(),r&&!c()&&t(r)));return r?setTimeout(()=>t(r),0):a(),{selector:e,clear:c,observe:a}},t=e=>{if((()=>{if(Object.prototype.hasOwnProperty.call(window,"ABTastyEditor")||(()=>{const e=!!document.getElementById("ABTastyPreviewBar"),t=location.href.includes("ab_project=preview");return e||t})())return!1;const e=ABTasty.getTestsOnPage()[TEST_ID];return!!e&&Object.keys(e.targetings.qaParameters).length>0})()){const t=(()=>{const e=(()=>{const{type:e}=DATA;return`${PACKAGE.replace("@abtasty/","")}${e?`_${e}`:""}`})();return`${e.charAt(0).toUpperCase()}${e.slice(1)}`.split("-").join(" ")})();window.console.log(`%c${t} - QA Mode for campaign ${TEST_ID}\n${e}`,"background-color: rgba(0, 127, 145, 1); color: rgba(247, 247, 247, 1)")}};let n,r=()=>null;const{engagementGoal:o,customTarget:c,scrollTarget:a}=DATA,s=()=>o.sort((e,t)=>e.percentage-t.percentage),l=["scroll",()=>d(),{passive:!0}],i=()=>{const e=c?document.querySelector(a):window;e&&e.removeEventListener(...l)},u=e=>{t("Widget launch"),n=s(),(c?e:window).addEventListener(...l)},d=()=>{const e=(()=>{const e=c?document.querySelector(a):document.body.scrollTop>0?document.body:document.documentElement;return e?100*e.scrollTop/(Math.max(e.scrollHeight,e.offsetHeight,e.clientHeight)-(c?e.parentElement.clientHeight:window.innerHeight)):0})();n=n.filter(n=>{let{percentage:r,name:o}=n;return!(e>=r&&(ABTastyEvent(o,null,TEST_ID),t(`Goal "${o}" sent to campaign ${TEST_ID}.`),1))}),n.length||i()},g=e(c?a:"body",u);r=g.clear,setTimeout(()=>{document.addEventListener("abtasty_resetActionTracking",()=>{i(),r(),n=s()}),window.addEventListener("abtasty_executedCampaign",t=>{let{detail:{campaignId:n}}=t;if(n!==TEST_ID)return;const o=e(c?a:"body",u);r=o.clear})})}(); |
{ | ||
"name": "@abtasty/scroll-tracking", | ||
"description": "AB Tasty Widget", | ||
"version": "3.4.1", | ||
"version": "3.4.2", | ||
"form": "dist/form.js", | ||
@@ -6,0 +6,0 @@ "main": "dist/main.js", |
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
4574
14