apxor-qe 1.2.4 → 1.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.
- package/dist/apxor.qe.js.bak +665 -358
- package/dist/apxor.qe.min.js +1 -1
- package/package.json +2 -2
package/dist/apxor.qe.min.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?module.exports=e(require("apxor")):"function"==typeof define&&define.amd?define(["apxor"],e):(t=t||self)["apxor-qe"]=e(t.Apxor)}(this,(function(t){"use strict";function e(t,e){var r=Object.keys(t);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(t);e&&(n=n.filter((function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable}))),r.push.apply(r,n)}return r}function r(t){for(var r=1;r<arguments.length;r++){var n=null!=arguments[r]?arguments[r]:{};r%2?e(Object(n),!0).forEach((function(e){s(t,e,n[e])})):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):e(Object(n)).forEach((function(e){Object.defineProperty(t,e,Object.getOwnPropertyDescriptor(n,e))}))}return t}function n(t){return(n="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t})(t)}function i(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}function o(t,e){for(var r=0;r<e.length;r++){var n=e[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,l(n.key),n)}}function a(t,e,r){return e&&o(t.prototype,e),r&&o(t,r),Object.defineProperty(t,"prototype",{writable:!1}),t}function s(t,e,r){return(e=l(e))in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}function u(t){return function(t){if(Array.isArray(t))return c(t)}(t)||function(t){if("undefined"!=typeof Symbol&&null!=t[Symbol.iterator]||null!=t["@@iterator"])return Array.from(t)}(t)||function(t,e){if(!t)return;if("string"==typeof t)return c(t,e);var r=Object.prototype.toString.call(t).slice(8,-1);"Object"===r&&t.constructor&&(r=t.constructor.name);if("Map"===r||"Set"===r)return Array.from(t);if("Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r))return c(t,e)}(t)||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.")}()}function c(t,e){(null==e||e>t.length)&&(e=t.length);for(var r=0,n=new Array(e);r<e;r++)n[r]=t[r];return n}function l(t){var e=function(t,e){if("object"!=typeof t||null===t)return t;var r=t[Symbol.toPrimitive];if(void 0!==r){var n=r.call(t,e||"default");if("object"!=typeof n)return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===e?String:Number)(t)}(t,"string");return"symbol"==typeof e?e:String(e)}t=t&&Object.prototype.hasOwnProperty.call(t,"default")?t.default:t;var h=function(t){return void 0!==t&&!function(t){return null===t}(t)},f="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=";function v(t,e){return Array.from(e).map((function(e,r){return String.fromCharCode(e^function(t,e){return t.charCodeAt(Math.floor(e%t.length))}(t,r))})).join("")}var p=function(t,e){return v(t,e=function(t){var e,r,n,i,o,a,s=0,u=[];if(!t)return t;t+="";do{e=(a=f.indexOf(t.charAt(s++))<<18|f.indexOf(t.charAt(s++))<<12|(i=f.indexOf(t.charAt(s++)))<<6|(o=f.indexOf(t.charAt(s++))))>>16&255,r=a>>8&255,n=255&a,u.push(e),64!==i&&(u.push(r),64!==o&&u.push(n))}while(s<t.length);return u}(e))},d=function(t){switch(t){case"app_event":return"AE";case"client_event":return"CE";case"activity_time":case"activity_event":return"AE"}return"Unknown"},g=function(t){return t.toUpperCase()},y=function(t,e,r){switch(r){case"EQ":return t===e;case"GT":return t>e;case"GTE":return t>=e;case"LT":return t<e;case"LTE":return t<=e;case"NEQ":return t!==e;case"R":return m(e).test(t);default:return!1}},m=function(t){var e=t.replace(/.*\/([gimuy]*)$/,"$1");e===t&&(e="");var r=e?t.replace(new RegExp("^/(.*?)/"+e+"$"),"$1"):t;return new RegExp(r,e)},A=function(){var t=new Date;return t.getDate()+"/"+t.getMonth()+"/"+t.getFullYear()},_=window.ApxorLogger,E=a((function e(){var r=this;i(this,e),s(this,"OlPJ","ALL"),s(this,"ccAa",[]),s(this,"atqR",[]),s(this,"parse",(function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};try{if(r.OlPJ=t.audience.audience_type,r.ccAa=t.audience.attributes.user,r.atqR=t.audience.attributes.session,!Array.isArray(r.ccAa)||!Array.isArray(r.atqR))return _.error("No attributes"),!1}catch(t){return _.error(t),!1}return!0})),s(this,"validate",(function(e,n){var i=!0;return"FTU"===r.OlPJ&&(i=t.getController().getSessionInfo().is_first_session),i&&r.zowh(e,r.ccAa)&&r.zowh(n,r.atqR)})),s(this,"zowh",(function(t,e){var r=e.length,n=!0;try{for(var i,o=function(){var r=e[a];if(!t[r.name]||!1===n)return{v:!1};var i=r.operator,o=r.type,s=r.value.map((function(t){return"s"===o?t:"l"===o?parseInt(t):"f"===o?parseFloat(t):void 0})),u=(Array.isArray(t[r.name])?t[r.name]:[t[r.name]]).some((function(t){return s.some((function(e){return y(t,e,i)}))}));n=n&&u},a=0;a<r;a++)if(i=o())return i.v}catch(t){_.error(t),n=!1}return n}))})),w=window.ApxorLogger,S=a((function t(){var e=this;i(this,t),s(this,"uQfG",0),s(this,"InyA",0),s(this,"MtmN","SESSION"),s(this,"btNb",0),s(this,"sLkK",0),s(this,"zwUB",0),s(this,"parse",(function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};try{e.uQfG=t.frequency.count,e.zwUB=e.uQfG,e.InyA=t.frequency.time_interval,e.MtmN=t.frequency.validity,e.sLkK=t.frequency.ses_lmt,e._dayCount=t.frequency.day_lmt;var r=M.getInstance().getQeState();if(!h(r)||!h(r[t._id]))return!0;if("SESSION"===e.MtmN){if(e.uQfG=parseInt(e.uQfG)-parseInt(r[t._id].SESSION),e.uQfG<=0)return console.warn("Max count limit reached for session:"+t._id),!1}else{if("OVERALL"!==e.MtmN)return w.info("Invalid config."),!1;if(e.uQfG=parseInt(e.uQfG)-parseInt(r[t._id].OVERALL),e.uQfG<=0)return console.warn("Max count limit reached for overall:"+t._id),!1}}catch(t){return w.error(t),!1}return!0})),s(this,"wnxp",(function(){e.uQfG=e.uQfG-1})),s(this,"getFrequencyCount",(function(){return e.uQfG})),s(this,"ScJa",(function(){"SESSION"===e.MtmN&&(e.uQfG=e.zwUB,w.info("Campaign Limit reset"))})),s(this,"BSns",(function(t){try{if(e.uQfG<=0)return!1;var r=M.getInstance().getQeState();if(!h(r)||!h(r[t]))return!0;if(0!==e.sLkK)if(parseInt(e.sLkK)-parseInt(r[t].SESSION)<=0)return!1;if(0!==e._dayCount){var n,i=A();if(parseInt(e._dayCount)-parseInt((null===(n=r[t])||void 0===n?void 0:n.DATES[i])||0)<=0)return!1}}catch(t){w.error("Error validating the frequency:"+t)}return!0}))})),O=a((function t(){var e=this;i(this,t),s(this,"KsvN",""),s(this,"OlPJ",""),s(this,"parse",(function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};try{var r;e.KsvN=t.meta.name,e.OlPJ=t.meta.type,e._only_context=t.meta.only_context,e._attr=(null===(r=t.meta)||void 0===r?void 0:r.attr)||{}}catch(t){return window.ApxorLogger.error(t),!1}return!0}))})),b=window.ApxorLogger,k=a((function t(){var e=this;i(this,t),s(this,"AXJi",-1),s(this,"xIZS",-1),s(this,"bhjK",-1),s(this,"WRnt",-1),s(this,"sfJc",!1),s(this,"parse",(function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};try{if(isNaN(Date.parse(t.validity.start_date))||isNaN(Date.parse(t.validity.end_date)))return b.error("Not valid dates"),!1;if(e.AXJi=Date.parse(t.validity.start_date),e.xIZS=Date.parse(t.validity.end_date),h(t.time_limits_in_day)&&(e.sfJc=t.time_limits_in_day,e.sfJc&&h(t.time_limits))){var r=(new Date).toISOString().split("T")[0];if(e.bhjK=Date.parse(r+"T"+t.time_limits.start_time+".000Z"),e.WRnt=Date.parse(r+"T"+t.time_limits.end_time+".000Z"),isNaN(e.bhjK)||isNaN(e.WRnt))return b.error("Not valid times"),!1}}catch(t){return b.error(t),!1}return!0})),s(this,"validate",(function(){var t=Date.now();return t>e.AXJi&&t<e.xIZS&&(!e.sfJc||t>=e.bhjK&&t<=e.WRnt)}))})),T=a((function t(){var e=this;i(this,t),s(this,"KsvN",""),s(this,"OmwE",{}),s(this,"parse",(function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};try{e.KsvN=t.name,e.OmwE=t.additional_info}catch(t){return!1}return!0}))})),Q=a((function t(){var e=this;i(this,t),s(this,"hPng",0),s(this,"EaoX",0),s(this,"parse",(function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};try{if(e.hPng=Number(t.lower),e.EaoX=Number(t.upper),isNaN(e.hPng)||isNaN(e.EaoX))return!1}catch(t){return!1}return!0}))})),N=a((function t(){var e=this;i(this,t),s(this,"ACyh",0),s(this,"oByE",""),s(this,"XXBT",""),s(this,"QrLp",new T),s(this,"XwsM",new Q),s(this,"parse",(function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};try{return e.oByE=t.event_type,e.XXBT=t.activity,e.QrLp.parse(t.details)&&e.XwsM.parse(t.time_bounds)}catch(t){return!1}}))})),L=window.ApxorLogger,C=a((function t(){var e=this;i(this,t),s(this,"ACyh",0),s(this,"xiFM",-1),s(this,"uQfG",0),s(this,"GFOB",""),s(this,"XXBT",""),s(this,"oByE",""),s(this,"XwsM",new Q),s(this,"QrLp",new T),s(this,"uUDi",new N),s(this,"hfEI","AND"),s(this,"ytXh",!1),s(this,"OlPJ",void 0),s(this,"parse",(function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};try{return e.xiFM=t.sequence,e.uQfG=t.count_config.count,e.GFOB=t.count_config.operator,e.XXBT=t.activity,e.oByE=t.event_type,e.hfEI=t.combine_operator,e.OlPJ=t.type,e.QrLp.parse(t.details)&&e.uUDi.parse(t.trigger)&&e.XwsM.parse(t.time_bounds)}catch(t){return L.error(t),!1}}))})),F=window.ApxorLogger,P=function(){function e(){var r=this;i(this,e),s(this,"gCch",0),s(this,"khHY",""),s(this,"kTpA",new C),s(this,"LeeG",!1),s(this,"mOYl",!1),s(this,"ccds",0),s(this,"hfEI","AND"),s(this,"AdbQ",-1),s(this,"MLGX",[]),s(this,"auHD",{}),s(this,"bACZ",!1),s(this,"initialize",(function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"",i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:0,o=!(arguments.length>3&&void 0!==arguments[3])||arguments[3],a=arguments.length>4&&void 0!==arguments[4]?arguments[4]:[];r.khHY=n,r.ccds=i,r.MLGX=a;var s=r.kTpA.parse(e);if(s){if(r.hfEI=r.kTpA.hfEI,r.kTpA.ytXh){var u=r.kTpA.QrLp.KsvN;"APX_PAGE_OPENED"===u&&(u=r.kTpA.QrLp.OmwE.navigation_id,u=h(u)?u:r.kTpA.QrLp.KsvN),r.AdbQ=t.getController().getEventCount(u);var c=r.kTpA.uQfG,l=r.kTpA.GFOB;if(r.mOYl=r.TnSn(r.AdbQ-1,c,l,!1),r.LeeG=r.mOYl,r.mOYl&&"APX_PAGE_OPENED"===r.kTpA.QrLp.KsvN)return!0}return o&&0!==i||r.UPYl(),!0}return!1})),s(this,"UPYl",(function(){var t=r.kTpA,e=t.uUDi,n=M.getInstance();"app_start"===e.oByE?(r.LeeG=!0,n.registerForEvent(d(t.oByE)+"___"+t.QrLp.KsvN,r.VolR)):n.registerForEvent(d(t.oByE)+"___"+e.QrLp.KsvN,r.VolR)})),s(this,"VNlO",(function(t,e,n,i){var o,a=(Date.now()-r.auHD[e])/1e3;(null===(o=r.kTpA)||void 0===o||null===(o=o.QrLp)||void 0===o||null===(o=o.OmwE)||void 0===o?void 0:o.time)/1e3>a&&r._displayCampaign(n)})),s(this,"dLQC",(function(t,e,n,i){var o,a;r.bACZ=!0;var s=Date.now(),u=null===(o=r.kTpA)||void 0===o||null===(o=o.uUDi)||void 0===o?void 0:o.QrLp.KsvN,c=(s-r.auHD[u])/1e3,l=null===(a=r.kTpA)||void 0===a||null===(a=a.QrLp)||void 0===a||null===(a=a.OmwE)||void 0===a?void 0:a.time;(l/=1e3)>c&&r._displayCampaign(n)})),s(this,"VolR",(function(t,e,n,i){var o=M.getInstance();if(r.LeeG)d(r.kTpA.oByE)===t&&r.PHir(n-r.kTpA.uUDi.ACyh,r.kTpA.XwsM)&&r.kTpA.QrLp.KsvN===e&&r.JXPv(r.kTpA.QrLp.OmwE,i)&&(r.gCch+=1,r.mOYl=r.TnSn(r.gCch,r.kTpA.uQfG,r.kTpA.GFOB),r.mOYl&&(r.kTpA.ACyh=n,o.validate(r.khHY,r.ccds)));else if(r.LeeG=r.XASt(t,e,n,i),r.LeeG){var a=r.kTpA,s=a.uUDi;if(s.ACyh=n,"activity_time"===(null==a?void 0:a.oByE)){var u,c,l,h=null==a||null===(u=a.QrLp)||void 0===u||null===(u=u.OmwE)||void 0===u?void 0:u.time;(null==a||null===(c=a.QrLp)||void 0===c||null===(c=c.OmwE)||void 0===c?void 0:c.nkpi.length)>0&&(setTimeout((function(){r.bACZ||(r.mOYl=!0,r.mOYl&&(r.gCch+=1,r.mOYl=r.TnSn(r.gCch,r.kTpA.uQfG,r.kTpA.GFOB),r.mOYl&&(r.kTpA.ACyh=n,o.validate(r.khHY,r.ccds)))),a.QrLp.OmwE.nkpi.map((function(t){o.unregisterFromEvent(g(a.QrLp.OmwE.et)+"___"+t,r)}))}),h),a.QrLp.OmwE.nkpi.map((function(t){o.registerForEvent(g(a.QrLp.OmwE.et)+"___"+t,r.dLQC)}))),(null==a||null===(l=a.QrLp)||void 0===l||null===(l=l.OmwE)||void 0===l?void 0:l.kpi.length)>0&&(setTimeout((function(){a.QrLp.OmwE.kpi.map((function(t){o.unregisterFromEvent(g(a.QrLp.OmwE.et)+"___"+t,r)}))}),h),a.QrLp.OmwE.kpi.map((function(t){t===a.uUDi.QrLp.KsvN?(o.unregisterFromEvent(d(s.oByE)+"___"+s.QrLp.KsvN,r),o.registerForEvent(g(a.QrLp.OmwE.et)+"___"+t,r.VNlO)):o.registerForEvent(g(a.QrLp.OmwE.et)+"___"+t,r.dLQC)})))}else o.unregisterFromEvent(d(s.oByE)+"___"+s.QrLp.KsvN,r),o.registerForEvent(d(a.oByE)+"___"+a.QrLp.KsvN,r);r.auHD[e]=Date.now()}})),s(this,"XASt",(function(t,e,n,i){var o=r.kTpA.uUDi;return d(o.oByE)===t&&o.QrLp.KsvN===e&&r.PHir(n,o.XwsM)&&r.JXPv(o.QrLp.OmwE,i)})),s(this,"PHir",(function(t,e){var r=Math.ceil(t);return r>e.hPng&&r<e.EaoX})),s(this,"TnSn",(function(t,e,n){var i=!(arguments.length>3&&void 0!==arguments[3])||arguments[3];switch(i&&r.kTpA.ytXh&&(t+=r.AdbQ),n){case"EQ":return t===e;case"GT":return t>e;case"GTE":return t>=e;case"LT":return t<e;case"LTE":return t<=e;default:return!1}})),s(this,"JXPv",(function(t,e){var r=!0;try{var i,o=function(){if(!e[a]||!1===r)return{v:!1};if("object"===n(t[a])){var i,o=t[a].op,s=t[a].t;"s"===s?i=t[a].val:"l"!==s&&"f"!==s||(i=parseFloat(t[a].val));var u=(Array.isArray(e[a])?e[a]:[e[a]]).some((function(t){return y(t,i,o)}));r=r&&u}else r=r&&y(e[a],t[a],"EQ")};for(var a in t)if(i=o())return i.v}catch(t){F.error(t),r=!1}return r}))}return a(e,[{key:"_displayCampaign",value:function(t){var e=M.getInstance();this.mOYl=!0,this.mOYl&&(this.gCch+=1,this.mOYl=this.TnSn(this.gCch,this.kTpA.uQfG,this.kTpA.GFOB),this.mOYl&&(this.kTpA.ACyh=t,e.validate(this.khHY,this.ccds)))}}]),e}(),G=window.ApxorLogger,x=a((function e(){var r=this;i(this,e),s(this,"AEeG",[]),s(this,"_ret_day",{}),s(this,"NGyb",{}),s(this,"ySyl",!1),s(this,"xrUm",!1),s(this,"parse",(function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};try{r.AEeG=t.overall_cfg.events,r._ret_day=t.overall_cfg.ret_day,r.NGyb=t.overall_cfg.session,r.ySyl=t.overall_cfg.toggleRetDay,r.AEeG=t.overall_cfg.events,r.xrUm=t.overall_cfg.toggleSession}catch(t){return G.error(t),!1}return!0})),s(this,"validate",(function(){var e=parseInt(t.getController().getFromStorage("apx_retained_days")),n=parseInt(t.getController().getFromStorage("apx_retained_session"));if(r.ySyl&&!isNaN(e)&&!(e>=r._ret_day.from&&e<=r._ret_day.to))return!1;if(r.xrUm&&!isNaN(n)&&!(n>=r.NGyb.from&&n<=r.NGyb.to))return!1;try{for(var i=t.getController().getFromStorage("_apx_lt_count"),o=t.getSiteId(),a=JSON.parse(p(o,i)),s=0;s<r.AEeG.length;s++){if(a[r.AEeG[s].name.replace("'","").replace("’","")])return!1}}catch(t){G.error("Failed to validate the lt count:"+t)}return!0}))})),X=window.ApxorLogger,q=a((function e(){var n=this;i(this,e),s(this,"tVlQ",[]),s(this,"khHY",""),s(this,"vbNk",new O),s(this,"lKMm",new E),s(this,"MtmN",new k),s(this,"ZPkK",new S),s(this,"MiVL",new x),s(this,"HAqW",!1),s(this,"QzOA",[]),s(this,"parse",(function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};try{if(!h(t._id))return X.error("No Id"),!1;if(!h(t.enabled)||!t.enabled)return X.error("Not enabled"),!1;if(!(n.vbNk.parse(t)&&n.MtmN.parse(t)&&n.ZPkK.parse(t)&&n.lKMm.parse(t)&&n.MiVL.parse(t)))return!1;if(!h(t.conditions)||!Array.isArray(t.conditions))return X.error("No valid conditions",t.conditions),!1;n.khHY=t._id,n.HAqW=!!h(t.sequence_enabled)&&t.sequence_enabled,n.HAqW&&t.conditions.sort((function(t,e){return t.sequence<e.sequence}));for(var e=t.conditions,r=e.length,i=0;i<r;i++){n.QzOA=[];var o=e[i];if("didn't"===o.type){var a,s={trigger_key:o.trigger.details.name,no_kpi_array:null==o||null===(a=o.details)||void 0===a||null===(a=a.additional_info)||void 0===a?void 0:a.nkpi,condition_id:null==o?void 0:o._id,time_bounds:o.time_bounds.upper};n.QzOA=[].concat(u(n.QzOA),[s])}var c=new P;c.initialize(o,n.khHY,i,n.HAqW,n.QzOA)&&n.tVlQ.push(c)}return n.tVlQ.length>0}catch(t){return X.error(t),!1}})),s(this,"cxKp",(function(t){if(!(t<0))if(n.HAqW){var e=n.tVlQ[t];if(h(e)&&e.mOYl){var r=n.tVlQ[t-1];if(h(r)&&!r.mOYl)return;var i=n.tVlQ[t+1];h(i)?i.UPYl():n.VxHD()}}else n.VxHD()})),s(this,"VxHD",(function(){var e=t.getController().getUserAttributes(),i=t.getController().getSessionAttributes();if(n.MtmN.validate()&&n.lKMm.validate(e,i)&&n.MiVL.validate()){for(var o=n.tVlQ.length,a=o<1,s="",u=0;u<o;u++){var c=n.tVlQ[u],l=c.mOYl;if(""===s.trim())a=l;else switch(s){case"AND":a=a&&l;break;case"OR":a=a||l}s=c.hfEI}if(a){if(console.debug("onCondition satisfied"),!n.ZPkK.BSns(n.khHY))return void console.warn("Maximum limit reached",n.khHY);console.log("Dispatching event",n.vbNk.OlPJ),!0===n.vbNk._only_context&&t.logEvent("apx_context_evaluated",r(r({},n.vbNk._attr),{},{message_name:n.vbNk.KsvN,id:n.khHY})),t.getController().dispatchEvent(n.vbNk.OlPJ,{name:n.vbNk.OlPJ,additional_info:{uuid:n.khHY,name:n.vbNk.KsvN}})}}})),s(this,"wnxp",(function(){n.ZPkK.wnxp()})),s(this,"getFrequencyCount",(function(){return n.ZPkK.getFrequencyCount()})),s(this,"TFzA",(function(){return n.ZPkK.ScJa()}))})),D=a((function t(){var e=this;i(this,t),s(this,"gTqz",{}),s(this,"parse",(function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{configs:[]};if(h(t)&&h(t.configs)){var r=t.configs;if(!Array.isArray(r))return;r.sort((function(t,e){var r,n;return(null!==(r=t.prio)&&void 0!==r?r:-1)-(null!==(n=e.prio)&&void 0!==n?n:-1)}));for(var n=0;n<r.length;n++){var i=r[n],o=i._id,a=new q;a.parse(i)?e.gTqz[o]=a:console.warn("Failed to parse cfg",o)}}})),s(this,"validate",(function(t,r){e.gTqz[t]&&e.gTqz[t].cxKp(r)})),s(this,"wnxp",(function(t){e.gTqz[t].wnxp()})),s(this,"getFrequencyCount",(function(t){return e.gTqz[t].getFrequencyCount()})),s(this,"resetFrequencyCounts",(function(){var t=e.gTqz;for(var r in t)t[r].TFzA()})),s(this,"Xijd",(function(t){try{if(e.gTqz){var r=e.gTqz[t];if(r&&r.vbNk)return r.vbNk}}catch(t){console.log("Error in getting the campaign meta ".concat(t))}return{}}))})),K=window.ApxorLogger,I=a((function e(){var r=this;i(this,e),s(this,"SPrF",{}),s(this,"EcTh",[]),s(this,"HxWM",!1),s(this,"initialize",(function(){var e=t.getController();e.registerForEvent("APP_EVENT",(function(t){return r.ZKQc(t,"AE")})),e.registerForEvent("CLIENT_EVENT",(function(t){return r.ZKQc(t,"CE")}))})),s(this,"MhGD",(function(){for(var t in r.EcTh)r.gdBA(t.event,t.key,t.type);r.HxWM=!0})),s(this,"rzbt",(function(t,e){var n;"function"==typeof e&&((n=r.SPrF[t]?r.SPrF[t]:[]).push(e),r.SPrF[t]=n,K.debug("Listeners list: ",r.SPrF))})),s(this,"unregisterFromEvent",(function(t,e){if(r.SPrF[t]){for(var n=r.SPrF[t],i=[],o=0;o<n.length;o++){var a=n[o];a!==e&&i.push(a)}r.SPrF[t]=i}})),s(this,"ZKQc",(function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"AE",n=e+"___"+t.name;r.gdBA(t,n,e)})),s(this,"gdBA",(function(e,n,i){if(r.HxWM){if(K.debug("Notifying listeners for event: "+e+", "+n,r.SPrF),r.SPrF[n])for(var o=r.SPrF[n],a=t.getController().getSDKRunningTimeInSec(),s=0;s<o.length;s++){(0,o[s])(i,e.name,a,e.additional_info)}}else r.EcTh.push({event:e,key:n,type:i})}))})),J=window.ApxorLogger,M=function(){function e(){var r=this;return i(this,e),s(this,"CueH",!1),s(this,"TVGk",null),s(this,"XFkq",A()),s(this,"CKgK",new I),s(this,"cuhG",t.getSiteId()),s(this,"waXJ",{}),s(this,"getQeState",(function(){try{var e=t.getController().getFromStorage("qe_state");return e?JSON.parse(p(r.cuhG,e)):(r.waXJ={},r.setQeState())}catch(t){return r.waXJ={},r.setQeState()}})),s(this,"setQeState",(function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"";try{t.getController().persistToStorage("qe_state",r.waXJ,!0)}catch(n){""===e?r.waXJ={}:r.waXJ[e]={SESSION:0,OVERALL:0,DATES:{}},t.getController().persistToStorage("qe_state",r.waXJ,!0)}return r.waXJ})),s(this,"initialize",(function(){r.CueH||(r.CueH=!0,r.TVGk=new D,r.CKgK.initialize(),r.waXJ=r.getQeState(),J.info("QE Initialized.."))})),s(this,"parse",(function(t){r.iafS()?(r.TVGk.parse(t),r.CKgK.MhGD()):J.warn("Must call init first. Unable to proceed")})),s(this,"validate",(function(t,e){r.iafS()&&r.TVGk.validate(t,e)})),s(this,"updateCount",(function(t){try{h(r.waXJ[t])||r.createObjConfig(t),r.incrementFrequencies(t),r.setQeState(t),r.TVGk.wnxp(t)}catch(t){console.log("Could not update the count config:".concat(t))}})),s(this,"resetFrequencyCounts",(function(){r.TVGk.resetFrequencyCounts()})),s(this,"getFrequencyCount",(function(t){return r.TVGk.getFrequencyCount(t)})),s(this,"registerForEvent",(function(t,e){r.CKgK.rzbt(t,e)})),s(this,"unregisterFromEvent",(function(t,e){r.CKgK.unregisterFromEvent(t,e)})),s(this,"fetch",(function(e,r,n,i){t.getController().fetchConfiguration(e,r,n,i)})),s(this,"iafS",(function(){return r.CueH})),s(this,"getCampaignMetaFromQueryEngine",(function(t){return r.TVGk.Xijd(t)})),s(this,"SZpm",(function(){return r.XFkq})),e.instance||(e.instance=this),e.instance}return a(e,[{key:"createObjConfig",value:function(t){try{this.waXJ=this.getQeState(),h(this.waXJ[t])||(this.waXJ[t]={SESSION:0,OVERALL:0,DATES:{}},this.XFkq&&(this.waXJ[t].DATES[this.XFkq]=0),this.setQeState(t))}catch(t){J.error("Can not create the frequency count object:"+t)}}},{key:"incrementFrequencies",value:function(t){this.waXJ=this.getQeState();var e=this.waXJ[t];e.SESSION=e.SESSION+1,e.OVERALL=e.OVERALL+1;var r=A();r===this.XFkq&&e.DATES&&e.DATES[r]||(this.XFkq=r,e.DATES={},e.DATES[this.XFkq]=0),e.DATES[this.XFkq]=e.DATES[this.XFkq]+1}}],[{key:"getInstance",value:function(){return e.instance||(e.instance=new e),e.instance}}]),e}();s(M,"instance",void 0),window.ceVersion=124;try{void 0===exports&&null===exports||(exports.default=M,module.exports=exports.default)}catch(t){}return M}));
|
|
1
|
+
!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?module.exports=e(require("apxor")):"function"==typeof define&&define.amd?define(["apxor"],e):(t=t||self)["apxor-qe"]=e(t.Apxor)}(this,(function(t){"use strict";function e(t,e){var r=Object.keys(t);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(t);e&&(n=n.filter((function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable}))),r.push.apply(r,n)}return r}function r(t){for(var r=1;r<arguments.length;r++){var n=null!=arguments[r]?arguments[r]:{};r%2?e(Object(n),!0).forEach((function(e){s(t,e,n[e])})):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):e(Object(n)).forEach((function(e){Object.defineProperty(t,e,Object.getOwnPropertyDescriptor(n,e))}))}return t}function n(t){return(n="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t})(t)}function i(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}function o(t,e){for(var r=0;r<e.length;r++){var n=e[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,l(n.key),n)}}function a(t,e,r){return e&&o(t.prototype,e),r&&o(t,r),Object.defineProperty(t,"prototype",{writable:!1}),t}function s(t,e,r){return(e=l(e))in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}function u(t){return function(t){if(Array.isArray(t))return c(t)}(t)||function(t){if("undefined"!=typeof Symbol&&null!=t[Symbol.iterator]||null!=t["@@iterator"])return Array.from(t)}(t)||function(t,e){if(!t)return;if("string"==typeof t)return c(t,e);var r=Object.prototype.toString.call(t).slice(8,-1);"Object"===r&&t.constructor&&(r=t.constructor.name);if("Map"===r||"Set"===r)return Array.from(t);if("Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r))return c(t,e)}(t)||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.")}()}function c(t,e){(null==e||e>t.length)&&(e=t.length);for(var r=0,n=new Array(e);r<e;r++)n[r]=t[r];return n}function l(t){var e=function(t,e){if("object"!=typeof t||null===t)return t;var r=t[Symbol.toPrimitive];if(void 0!==r){var n=r.call(t,e||"default");if("object"!=typeof n)return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===e?String:Number)(t)}(t,"string");return"symbol"==typeof e?e:String(e)}t=t&&Object.prototype.hasOwnProperty.call(t,"default")?t.default:t;var f=function(t){return void 0!==t&&!function(t){return null===t}(t)},d="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=";function h(t,e){return Array.from(e).map((function(e,r){return String.fromCharCode(e^function(t,e){return t.charCodeAt(Math.floor(e%t.length))}(t,r))})).join("")}var v=function(t,e){return h(t,e=function(t){var e,r,n,i,o,a,s=0,u=[];if(!t)return t;t+="";do{e=(a=d.indexOf(t.charAt(s++))<<18|d.indexOf(t.charAt(s++))<<12|(i=d.indexOf(t.charAt(s++)))<<6|(o=d.indexOf(t.charAt(s++))))>>16&255,r=a>>8&255,n=255&a,u.push(e),64!==i&&(u.push(r),64!==o&&u.push(n))}while(s<t.length);return u}(e))},p=function(t){switch(t){case"app_event":return"AE";case"client_event":return"CE";case"activity_time":case"activity_event":return"AE"}return"Unknown"},g=function(t){return t.toUpperCase()},y=function(t,e,r){switch(r){case"EQ":return t===e;case"GT":return t>e;case"GTE":return t>=e;case"LT":return t<e;case"LTE":return t<=e;case"NEQ":return t!==e;case"R":return m(e).test(t);default:return!1}},m=function(t){var e=t.replace(/.*\/([gimuy]*)$/,"$1");e===t&&(e="");var r=e?t.replace(new RegExp("^/(.*?)/"+e+"$"),"$1"):t;return new RegExp(r,e)},_=function(){var t=new Date;return t.getDate()+"/"+t.getMonth()+"/"+t.getFullYear()},b=window.ApxorLogger,E=a((function e(){var r=this;i(this,e),s(this,"pfyk","ALL"),s(this,"oyin",[]),s(this,"Pifw",[]),s(this,"parse",(function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};try{if(r.pfyk=t.audience.audience_type,r.oyin=t.audience.attributes.user,r.Pifw=t.audience.attributes.session,!Array.isArray(r.oyin)||!Array.isArray(r.Pifw))return b.error("No attributes"),!1}catch(t){return b.error(t),!1}return!0})),s(this,"validate",(function(e,n){var i=!0;return"FTU"===r.pfyk&&(i=t.getController().getSessionInfo().is_first_session),i&&r.larY(e,r.oyin)&&r.larY(n,r.Pifw)})),s(this,"larY",(function(t,e){var r=e.length,n=!0;try{for(var i,o=function(){var r=e[a];if(!t[r.name]||!1===n)return{v:!1};var i=r.operator,o=r.type,s=r.value.map((function(t){return"s"===o?t:"l"===o?parseInt(t):"f"===o?parseFloat(t):void 0})),u=(Array.isArray(t[r.name])?t[r.name]:[t[r.name]]).some((function(t){return s.some((function(e){return y(t,e,i)}))}));n=n&&u},a=0;a<r;a++)if(i=o())return i.v}catch(t){b.error(t),n=!1}return n}))})),S=window.ApxorLogger,k=a((function t(){var e=this;i(this,t),s(this,"kedV",0),s(this,"VSmt",0),s(this,"YTxk","SESSION"),s(this,"zwPH",0),s(this,"gMHQ",0),s(this,"amzH",0),s(this,"parse",(function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};try{e.kedV=t.frequency.count,-1===e.kedV&&(e.kedV=1e3),e.amzH=e.kedV,e.VSmt=t.frequency.time_interval,e.YTxk=t.frequency.validity,e.gMHQ=t.frequency.ses_lmt,e._dayCount=t.frequency.day_lmt;var r=K.getInstance().getQeState();if(!f(r)||!f(r[t._id]))return!0;if("SESSION"===e.YTxk){if(e.kedV=parseInt(e.kedV)-parseInt(r[t._id].SESSION),e.kedV<=0)return console.warn("Max count limit reached for session:"+t._id),!1}else{if("OVERALL"!==e.YTxk)return S.info("Invalid config."),!1;if(e.kedV=parseInt(e.kedV)-parseInt(r[t._id].OVERALL),e.kedV<=0)return console.warn("Max count limit reached for overall:"+t._id),!1}}catch(t){return S.error(t),!1}return!0})),s(this,"oDrA",(function(){e.kedV=e.kedV-1})),s(this,"getFrequencyCount",(function(){return e.kedV})),s(this,"XbPF",(function(){"SESSION"===e.YTxk&&(e.kedV=e.amzH,S.info("Campaign Limit reset"))})),s(this,"WTEf",(function(t){try{if(e.kedV<=0)return!1;var r=K.getInstance().getQeState();if(!f(r)||!f(r[t]))return!0;if(0!==e.gMHQ)if(parseInt(e.gMHQ)-parseInt(r[t].SESSION)<=0)return!1;if(0!==e._dayCount){var n,i=_();if(parseInt(e._dayCount)-parseInt((null===(n=r[t])||void 0===n?void 0:n.DATES[i])||0)<=0)return!1}}catch(t){S.error("Error validating the frequency:"+t)}return!0}))})),D=a((function t(){var e=this;i(this,t),s(this,"EDaN",""),s(this,"pfyk",""),s(this,"parse",(function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};try{var r;e.EDaN=t.meta.name,e.pfyk=t.meta.type,e._only_context=t.meta.only_context,e._attr=(null===(r=t.meta)||void 0===r?void 0:r.attr)||{}}catch(t){return window.ApxorLogger.error(t),!1}return!0}))})),w=window.ApxorLogger,I=a((function t(){var e=this;i(this,t),s(this,"isju",-1),s(this,"eexF",-1),s(this,"Xmbz",-1),s(this,"IRGG",-1),s(this,"jPEb",!1),s(this,"parse",(function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};try{if(isNaN(Date.parse(t.validity.start_date))||isNaN(Date.parse(t.validity.end_date)))return w.error("Not valid dates"),!1;if(e.isju=Date.parse(t.validity.start_date),e.eexF=Date.parse(t.validity.end_date),f(t.time_limits_in_day)&&(e.jPEb=t.time_limits_in_day,e.jPEb&&f(t.time_limits))){var r=(new Date).toISOString().split("T")[0];if(e.Xmbz=Date.parse(r+"T"+t.time_limits.start_time+".000Z"),e.IRGG=Date.parse(r+"T"+t.time_limits.end_time+".000Z"),isNaN(e.Xmbz)||isNaN(e.IRGG))return w.error("Not valid times"),!1}}catch(t){return w.error(t),!1}return!0})),s(this,"validate",(function(){var t=Date.now();return t>e.isju&&t<e.eexF&&(!e.jPEb||t>=e.Xmbz&&t<=e.IRGG)}))})),A=a((function t(){var e=this;i(this,t),s(this,"EDaN",""),s(this,"EpkX",{}),s(this,"parse",(function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};try{e.EDaN=t.name,e.EpkX=t.additional_info}catch(t){return!1}return!0}))})),O=a((function t(){var e=this;i(this,t),s(this,"vQNe",0),s(this,"idSb",0),s(this,"parse",(function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};try{if(e.vQNe=Number(t.lower),e.idSb=Number(t.upper),isNaN(e.vQNe)||isNaN(e.idSb))return!1}catch(t){return!1}return!0}))})),N=a((function t(){var e=this;i(this,t),s(this,"dAXx",0),s(this,"QksQ",""),s(this,"SmWY",""),s(this,"SbdV",new A),s(this,"OuAR",new O),s(this,"parse",(function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};try{return e.QksQ=t.event_type,e.SmWY=t.activity,e.SbdV.parse(t.details)&&e.OuAR.parse(t.time_bounds)}catch(t){return!1}}))})),X=window.ApxorLogger,V=a((function t(){var e=this;i(this,t),s(this,"dAXx",0),s(this,"kVOA",-1),s(this,"kedV",0),s(this,"oakv",""),s(this,"SmWY",""),s(this,"QksQ",""),s(this,"OuAR",new O),s(this,"SbdV",new A),s(this,"YEhB",new N),s(this,"yHRM","AND"),s(this,"Pkry",!1),s(this,"pfyk",void 0),s(this,"parse",(function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};try{return e.kVOA=t.sequence,e.kedV=t.count_config.count,e.oakv=t.count_config.operator,e.SmWY=t.activity,e.QksQ=t.event_type,e.yHRM=t.combine_operator,e.pfyk=t.type,e.SbdV.parse(t.details)&&e.YEhB.parse(t.trigger)&&e.OuAR.parse(t.time_bounds)}catch(t){return X.error(t),!1}}))})),q=window.ApxorLogger,T=a((function t(){var e=this;i(this,t),s(this,"kedV",0),s(this,"oakv",""),s(this,"QksQ",""),s(this,"OuAR",new O),s(this,"SbdV",new A),s(this,"yHRM","AND"),s(this,"parse",(function(t){try{return e.kedV=t.count_config.count,e.oakv=t.count_config.operator,e.QksQ=t.event_type,e.yHRM=t.combine_operator,e.SbdV.parse(t.details)&&e.OuAR.parse(t.time_bounds)}catch(t){return q.error(t),!1}}))})),j=window.ApxorLogger,x=function(){function e(){var r=this;i(this,e),s(this,"XsTp",0),s(this,"jaGt",""),s(this,"qXKr",new V),s(this,"yIMt",new T),s(this,"gZba",!1),s(this,"HPUo",!1),s(this,"RIDN",0),s(this,"yHRM","AND"),s(this,"mCal","OR"),s(this,"fTSz",-1),s(this,"eiXR",[]),s(this,"JfUj",{}),s(this,"rduQ",!1),s(this,"initialize",(function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"",i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:0,o=!(arguments.length>3&&void 0!==arguments[3])||arguments[3],a=arguments.length>4&&void 0!==arguments[4]?arguments[4]:[],s=arguments.length>5&&void 0!==arguments[5]?arguments[5]:"";if(r.jaGt=n,r.RIDN=i,r.eiXR=a,"termination"===s&&""!==s){r.yIMt.parse(e);return r.mCal=r.yIMt.yHRM,r.IIJM(),!0}var u=r.qXKr.parse(e);if(u){if(r.yHRM=r.qXKr.yHRM,r.qXKr.Pkry){var c=r.qXKr.SbdV.EDaN;"APX_PAGE_OPENED"===c&&(c=r.qXKr.SbdV.EpkX.navigation_id,c=f(c)?c:r.qXKr.SbdV.EDaN),r.fTSz=t.getController().getEventCount(c);var l=r.qXKr.kedV,d=r.qXKr.oakv;if(r.HPUo=r.jjDO(r.fTSz-1,l,d,!1),r.gZba=r.HPUo,r.HPUo&&"APX_PAGE_OPENED"===r.qXKr.SbdV.EDaN)return!0}return o&&0!==i||r.OJSD(),!0}return!1})),s(this,"OJSD",(function(){var t=r.qXKr,e=t.YEhB,n=K.getInstance();"app_start"===e.QksQ?(r.gZba=!0,n.registerForEvent(p(t.QksQ)+"___"+t.SbdV.EDaN,r.vJpn)):n.registerForEvent(p(t.QksQ)+"___"+e.SbdV.EDaN,r.vJpn)})),s(this,"IIJM",(function(){var t=r.yIMt,e=K.getInstance();r.gZba=!0,e.registerForEvent(p(t.QksQ)+"___"+t.SbdV.EDaN,r.nTnW)})),s(this,"aZcq",(function(t,e,n,i){var o,a=(Date.now()-r.JfUj[e])/1e3;(null===(o=r.qXKr)||void 0===o||null===(o=o.SbdV)||void 0===o||null===(o=o.EpkX)||void 0===o?void 0:o.time)/1e3>a&&r._displayCampaign(n)})),s(this,"EfFk",(function(t,e,n,i){var o,a;r.rduQ=!0;var s=Date.now(),u=null===(o=r.qXKr)||void 0===o||null===(o=o.YEhB)||void 0===o?void 0:o.SbdV.EDaN,c=(s-r.JfUj[u])/1e3,l=null===(a=r.qXKr)||void 0===a||null===(a=a.SbdV)||void 0===a||null===(a=a.EpkX)||void 0===a?void 0:a.time;(l/=1e3)>c&&r._displayCampaign(n)})),s(this,"vJpn",(function(t,e,n,i){var o=K.getInstance();if(r.gZba)p(r.qXKr.QksQ)===t&&r.oLnh(n-r.qXKr.YEhB.dAXx,r.qXKr.OuAR)&&r.qXKr.SbdV.EDaN===e&&r.MUef(r.qXKr.SbdV.EpkX,i)&&(r.XsTp+=1,r.HPUo=r.jjDO(r.XsTp,r.qXKr.kedV,r.qXKr.oakv),r.HPUo&&(r.qXKr.dAXx=n,o.validate(r.jaGt,r.RIDN)));else if(r.gZba=r.alII(t,e,n,i),r.gZba){var a=r.qXKr,s=a.YEhB;if(s.dAXx=n,"activity_time"===(null==a?void 0:a.QksQ)){var u,c,l,f=null==a||null===(u=a.SbdV)||void 0===u||null===(u=u.EpkX)||void 0===u?void 0:u.time;(null==a||null===(c=a.SbdV)||void 0===c||null===(c=c.EpkX)||void 0===c?void 0:c.nkpi.length)>0&&(setTimeout((function(){r.rduQ||(r.HPUo=!0,r.HPUo&&(r.XsTp+=1,r.HPUo=r.jjDO(r.XsTp,r.qXKr.kedV,r.qXKr.oakv),r.HPUo&&(r.qXKr.dAXx=n,o.validate(r.jaGt,r.RIDN)))),a.SbdV.EpkX.nkpi.map((function(t){o.unregisterFromEvent(g(a.SbdV.EpkX.et)+"___"+t,r)}))}),f),a.SbdV.EpkX.nkpi.map((function(t){o.registerForEvent(g(a.SbdV.EpkX.et)+"___"+t,r.EfFk)}))),(null==a||null===(l=a.SbdV)||void 0===l||null===(l=l.EpkX)||void 0===l?void 0:l.kpi.length)>0&&(setTimeout((function(){a.SbdV.EpkX.kpi.map((function(t){o.unregisterFromEvent(g(a.SbdV.EpkX.et)+"___"+t,r)}))}),f),a.SbdV.EpkX.kpi.map((function(t){t===a.YEhB.SbdV.EDaN?(o.unregisterFromEvent(p(s.QksQ)+"___"+s.SbdV.EDaN,r),o.registerForEvent(g(a.SbdV.EpkX.et)+"___"+t,r.aZcq)):o.registerForEvent(g(a.SbdV.EpkX.et)+"___"+t,r.EfFk)})))}else o.unregisterFromEvent(p(s.QksQ)+"___"+s.SbdV.EDaN,r),o.registerForEvent(p(a.QksQ)+"___"+a.SbdV.EDaN,r);r.JfUj[e]=Date.now()}})),s(this,"nTnW",(function(t,e,n,i){var o=K.getInstance();p(r.yIMt.QksQ)===t&&r.oLnh(n,r.yIMt.OuAR)&&r.yIMt.SbdV.EDaN===e&&r.MUef(r.yIMt.SbdV.EpkX,i)&&(r.XsTp+=1,r.HPUo=r.jjDO(r.XsTp,r.yIMt.kedV,r.yIMt.oakv),r.HPUo&&(r.yIMt.dAXx=n,o.validateForTermination(r.jaGt,r.RIDN)))})),s(this,"alII",(function(t,e,n,i){var o=r.qXKr.YEhB;return p(o.QksQ)===t&&o.SbdV.EDaN===e&&r.oLnh(n,o.OuAR)&&r.MUef(o.SbdV.EpkX,i)})),s(this,"oLnh",(function(t,e){var r=Math.ceil(t);return r>e.vQNe&&r<e.idSb})),s(this,"jjDO",(function(t,e,n){var i=!(arguments.length>3&&void 0!==arguments[3])||arguments[3];switch(i&&r.qXKr.Pkry&&(t+=r.fTSz),n){case"EQ":return t===e;case"GT":return t>e;case"GTE":return t>=e;case"LT":return t<e;case"LTE":return t<=e;default:return!1}})),s(this,"MUef",(function(t,e){var r=!0;try{var i,o=function(){if(!e[a]||!1===r)return{v:!1};if("object"===n(t[a])){var i,o=t[a].op,s=t[a].t;"s"===s?i=t[a].val:"l"!==s&&"f"!==s||(i=parseFloat(t[a].val));var u=(Array.isArray(e[a])?e[a]:[e[a]]).some((function(t){return y(t,i,o)}));r=r&&u}else r=r&&y(e[a],t[a],"EQ")};for(var a in t)if(i=o())return i.v}catch(t){j.error(t),r=!1}return r}))}return a(e,[{key:"_displayCampaign",value:function(t){var e=K.getInstance();this.HPUo=!0,this.HPUo&&(this.XsTp+=1,this.HPUo=this.jjDO(this.XsTp,this.qXKr.kedV,this.qXKr.oakv),this.HPUo&&(this.qXKr.dAXx=t,e.validate(this.jaGt,this.RIDN)))}}]),e}(),Q=window.ApxorLogger,F=a((function e(){var r=this;i(this,e),s(this,"kgNo",[]),s(this,"_ret_day",{}),s(this,"mequ",{}),s(this,"CRUL",!1),s(this,"mxWo",!1),s(this,"parse",(function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};try{r.kgNo=t.overall_cfg.events,r._ret_day=t.overall_cfg.ret_day,r.mequ=t.overall_cfg.session,r.CRUL=t.overall_cfg.toggleRetDay,r.kgNo=t.overall_cfg.events,r.mxWo=t.overall_cfg.toggleSession}catch(t){return Q.error(t),!1}return!0})),s(this,"validate",(function(){var e=parseInt(t.getController().getFromStorage("apx_retained_days")),n=parseInt(t.getController().getFromStorage("apx_retained_session"));if(r.CRUL&&!isNaN(e)&&!(e>=r._ret_day.from&&e<=r._ret_day.to))return!1;if(r.mxWo&&!isNaN(n)&&!(n>=r.mequ.from&&n<=r.mequ.to))return!1;try{for(var i=t.getController().getFromStorage("_apx_lt_count"),o=t.getSiteId(),a=JSON.parse((new TextDecoder).decode(function(t){for(var e=new ArrayBuffer(t.length),r=new Uint8Array(e),n=0;n<t.length;n++)r[n]=t.charCodeAt(n);return e}(v(o,i)))),s=0;s<r.kgNo.length;s++){if(a[r.kgNo[s].name.replace("'","").replace("’","")])return!1}}catch(t){Q.error("Failed to validate the lt count:"+t)}return!0}))})),U=window.ApxorLogger,C=a((function t(){var e=this;i(this,t),s(this,"oyin",[]),s(this,"Pifw",[]),s(this,"parse",(function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};try{if(e.oyin=t.attributes.user,e.Pifw=t.attributes.session,!Array.isArray(e.oyin)||!Array.isArray(e.Pifw))return U.error("No attributes"),!1}catch(t){return U.error(t),!1}return!0})),s(this,"validate",(function(t,r){return e.larY(t,e.oyin)&&e.larY(r,e.Pifw)})),s(this,"larY",(function(t,e){var r=e.length,n=!0;try{for(var i,o=function(){var r=e[a];if(!t[r.name]||!1===n)return{v:!1};var i=r.operator,o=r.type,s=r.value.map((function(t){return"s"===o?t:"l"===o?parseInt(t):"f"===o?parseFloat(t):void 0})),u=(Array.isArray(t[r.name])?t[r.name]:[t[r.name]]).some((function(t){return s.some((function(e){return y(t,e,i)}))}));n=n&&u},a=0;a<r;a++)if(i=o())return i.v}catch(t){U.error(t),n=!1}return n}))})),P=a((function e(){var r=this;i(this,e),s(this,"NURV",t.getController()),s(this,"type",""),s(this,"_duration_seconds",0),s(this,"eUbV",1),s(this,"parse",(function(t){try{var e,n,i;if(r.pfyk=null===(e=t.terminate_info.time_based)||void 0===e?void 0:e.type,r._duration_seconds=null===(n=t.terminate_info)||void 0===n?void 0:n.time_based.duration_seconds,r.eUbV=null===(i=t.terminate_info.time_based)||void 0===i?void 0:i.days,r.qjgz(t._id))return r.NURV.persistTerminationInfoLocally(t._id),!1}catch(t){return!1}return!0})),s(this,"qjgz",(function(t){var e,n=JSON.parse(r.NURV.getFromStorage("apx_termination_ID"));if(!n[t]||null===(e=n[t])||void 0===e||!e.startDate)return!1;var i,o=new Date(n[t].startDate),a=new Date((i=new Date).getMonth()+"/"+i.getDate()+"/"+i.getFullYear()),s=parseInt((a-o)/864e5,10),u=function(){var t=new Date;return{hours:t.getHours(),mins:t.getMinutes()}}(),c=n[t].Xmbz;return s===r.eUbV&&u.hours>=c.hours||s>r.eUbV||n[t].goalAcheived}))})),R=a((function t(){var e=this;i(this,t),s(this,"enable_goal_events",!1),s(this,"attributes",{}),s(this,"WnkR",new C),s(this,"jcBj",new P),s(this,"parse",(function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};try{var r,n,i;if(e.enable_time_based=null==t||null===(r=t.terminate_info)||void 0===r?void 0:r.enable_time_based,e.enable_time_based&&!e.jcBj.parse(t))return!1;if(e.enable_goal_events=null==t||null===(n=t.terminate_info)||void 0===n?void 0:n.enable_goal_events,e.enable_attributes=null==t||null===(i=t.terminate_info)||void 0===i?void 0:i.enable_attributes,e.enable_attributes&&!e.WnkR.parse(t.terminate_info))return!1}catch(t){return window.ApxorLogger.error(t),!1}return!0})),s(this,"validate",(function(t,r){return e.WnkR.validate(t,r)}))})),W=window.ApxorLogger,Y=a((function e(){var n=this;i(this,e),s(this,"oWeW",[]),s(this,"bwHJ",[]),s(this,"jaGt",""),s(this,"ylID",new D),s(this,"fGtu",new E),s(this,"YTxk",new I),s(this,"CWOw",new k),s(this,"VUII",new F),s(this,"xoSz",new R),s(this,"uZEl",!1),s(this,"TYUY",[]),s(this,"parse",(function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};try{if(!f(t._id))return W.error("No Id"),!1;if(!f(t.enabled)||!t.enabled)return W.error("Not enabled"),!1;if(!(n.ylID.parse(t)&&n.YTxk.parse(t)&&n.CWOw.parse(t)&&n.fGtu.parse(t)&&n.VUII.parse(t)&&n.xoSz.parse(t)))return!1;if(!f(t.conditions)||!Array.isArray(t.conditions))return W.error("No valid conditions",t.conditions),!1;n.jaGt=t._id,n.uZEl=!!f(t.sequence_enabled)&&t.sequence_enabled,n.uZEl&&t.conditions.sort((function(t,e){return t.sequence<e.sequence}));for(var e=t.conditions,r=e.length,i=0;i<r;i++){n.TYUY=[];var o=e[i];if("didn't"===o.type){var a,s={trigger_key:o.trigger.details.name,no_kpi_array:null==o||null===(a=o.details)||void 0===a||null===(a=a.additional_info)||void 0===a?void 0:a.nkpi,condition_id:null==o?void 0:o._id,time_bounds:o.time_bounds.upper};n.TYUY=[].concat(u(n.TYUY),[s])}var c=new x;c.initialize(o,n.jaGt,i,n.uZEl,n.TYUY)&&n.oWeW.push(c)}if(n.xoSz.enable_goal_events)for(var l=t.terminate_info.goal_events.events,d=l.length,h=0;h<d;h++){var v=new x;v.initialize(l[h],n.jaGt,h,!0,[],"termination")&&n.bwHJ.push(v)}return n.oWeW.length>0}catch(t){return W.error(t),!1}})),s(this,"Adtv",(function(t){if(!(t<0))if(n.uZEl){var e=n.oWeW[t];if(f(e)&&e.HPUo){var r=n.oWeW[t-1];if(f(r)&&!r.HPUo)return;var i=n.oWeW[t+1];f(i)?i.OJSD():n.BmHg()}}else n.BmHg()})),s(this,"RbFI",(function(t){t<0||n.GuEG()})),s(this,"BmHg",(function(){var e=t.getController().getUserAttributes(),i=t.getController().getSessionAttributes();if(n.YTxk.validate()&&n.fGtu.validate(e,i)&&n.VUII.validate()){for(var o=n.oWeW.length,a=o<1,s="",u=0;u<o;u++){var c=n.oWeW[u],l=c.HPUo;if(""===s.trim())a=l;else switch(s){case"AND":a=a&&l;break;case"OR":a=a||l}s=c.yHRM}if(a){if(console.debug("onCondition satisfied"),!n.CWOw.WTEf(n.jaGt))return void console.warn("Maximum limit reached",n.jaGt);console.log("Dispatching event",n.ylID.pfyk),!0===n.ylID._only_context&&t.logEvent("apx_context_evaluated",r(r({},n.ylID._attr),{},{message_name:n.ylID.EDaN,id:n.jaGt})),t.getController().dispatchEvent(n.ylID.pfyk,{name:n.ylID.pfyk,additional_info:{uuid:n.jaGt,name:n.ylID.EDaN}})}}})),s(this,"GuEG",(function(){for(var e=n.bwHJ.length,i=e<1,o="",a=0;a<e;a++){var s=n.bwHJ[a],u=s.HPUo;if(""===o.trim())i=u;else switch(o){case"AND":i=i&&u;break;case"OR":i=i||u}o=s.mCal}i&&(console.log("Dispatching event",n.ylID.pfyk),t.getController().persistTerminationInfoLocally(n.jaGt),!0===n.ylID._only_context&&t.logEvent("apx_context_evaluated",r(r({},n.ylID._attr),{},{message_name:n.ylID.EDaN,id:n.jaGt})),t.getController().dispatchEvent(n.ylID.pfyk,{name:n.ylID.pfyk,additional_info:{uuid:n.jaGt,name:n.ylID.EDaN}}))})),s(this,"validateForTerminationAttributes",(function(){var e=t.getController().getUserAttributes(),r=t.getController().getSessionAttributes();return n.xoSz.validate(e,r)})),s(this,"oDrA",(function(){n.CWOw.oDrA()})),s(this,"getFrequencyCount",(function(){return n.CWOw.getFrequencyCount()})),s(this,"XgXS",(function(){return n.CWOw.XbPF()}))})),H=a((function t(){var e=this;i(this,t),s(this,"IZYQ",{}),s(this,"parse",(function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{configs:[]};if(f(t)&&f(t.configs)){var r=t.configs;if(!Array.isArray(r))return;r.sort((function(t,e){var r,n;return(null!==(r=t.prio)&&void 0!==r?r:-1)-(null!==(n=e.prio)&&void 0!==n?n:-1)}));for(var n=0;n<r.length;n++){var i=r[n],o=i._id,a=new Y;a.parse(i)?e.IZYQ[o]=a:console.warn("Failed to parse cfg",o)}}})),s(this,"validate",(function(t,r){e.IZYQ[t]&&e.IZYQ[t].Adtv(r)})),s(this,"validateForTermination",(function(t,r){e.IZYQ[t]&&e.IZYQ[t].RbFI(r)})),s(this,"validateForTerminationAttributes",(function(t){return!!e.IZYQ[t]&&e.IZYQ[t].validateForTerminationAttributes()})),s(this,"oDrA",(function(t){e.IZYQ[t].oDrA()})),s(this,"getFrequencyCount",(function(t){return e.IZYQ[t].getFrequencyCount()})),s(this,"resetFrequencyCounts",(function(){var t=e.IZYQ;for(var r in t)t[r].XgXS()})),s(this,"NveP",(function(t){try{if(e.IZYQ){var r=e.IZYQ[t];if(r&&r.ylID)return r.ylID}}catch(t){console.log("Error in getting the campaign meta ".concat(t))}return{}}))})),L=window.ApxorLogger,G=a((function e(){var r=this;i(this,e),s(this,"FDcv",{}),s(this,"kJex",[]),s(this,"qMxr",!1),s(this,"initialize",(function(){var e=t.getController();e.registerForEvent("APP_EVENT",(function(t){return r.LtdS(t,"AE")})),e.registerForEvent("CLIENT_EVENT",(function(t){return r.LtdS(t,"CE")}))})),s(this,"zgeH",(function(){for(var t in r.kJex)r.rqKD(t.event,t.key,t.type);r.qMxr=!0})),s(this,"Weok",(function(t,e){var n;"function"==typeof e&&((n=r.FDcv[t]?r.FDcv[t]:[]).push(e),r.FDcv[t]=n,L.debug("Listeners list: ",r.FDcv))})),s(this,"unregisterFromEvent",(function(t,e){if(r.FDcv[t]){for(var n=r.FDcv[t],i=[],o=0;o<n.length;o++){var a=n[o];a!==e&&i.push(a)}r.FDcv[t]=i}})),s(this,"LtdS",(function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"AE",n=e+"___"+t.name;r.rqKD(t,n,e)})),s(this,"rqKD",(function(e,n,i){if(r.qMxr){if(L.debug("Notifying listeners for event: "+e+", "+n,r.FDcv),r.FDcv[n])for(var o=r.FDcv[n],a=t.getController().getSDKRunningTimeInSec(),s=0;s<o.length;s++){(0,o[s])(i,e.name,a,e.additional_info)}}else r.kJex.push({event:e,key:n,type:i})}))})),M=window.ApxorLogger,K=function(){function e(){var r=this;return i(this,e),s(this,"EXbT",!1),s(this,"OqkB",null),s(this,"wsiO",_()),s(this,"DGNj",new G),s(this,"nawG",t.getSiteId()),s(this,"dWcU",{}),s(this,"getQeState",(function(){try{var e=t.getController().getFromStorage("qe_state");return e?JSON.parse(v(r.nawG,e)):(r.dWcU={},r.setQeState())}catch(t){return r.dWcU={},r.setQeState()}})),s(this,"setQeState",(function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"";try{t.getController().persistToStorage("qe_state",r.dWcU,!0)}catch(n){""===e?r.dWcU={}:r.dWcU[e]={SESSION:0,OVERALL:0,DATES:{}},t.getController().persistToStorage("qe_state",r.dWcU,!0)}return r.dWcU})),s(this,"initialize",(function(){r.EXbT||(r.EXbT=!0,r.OqkB=new H,r.DGNj.initialize(),r.dWcU=r.getQeState(),M.info("QE Initialized.."))})),s(this,"parse",(function(t){r.TrIj()?(r.OqkB.parse(t),r.DGNj.zgeH()):M.warn("Must call init first. Unable to proceed")})),s(this,"validate",(function(t,e){r.TrIj()&&r.OqkB.validate(t,e)})),s(this,"validateForTermination",(function(t,e){r.TrIj()&&r.OqkB.validateForTermination(t,e)})),s(this,"validateForTerminationAttributes",(function(t,e){return r.OqkB.validateForTerminationAttributes(t,e)})),s(this,"updateCount",(function(t){try{f(r.dWcU[t])||r.createObjConfig(t),r.incrementFrequencies(t),r.setQeState(t),r.OqkB.oDrA(t)}catch(t){console.log("Could not update the count config:".concat(t))}})),s(this,"resetFrequencyCounts",(function(){r.OqkB.resetFrequencyCounts()})),s(this,"getFrequencyCount",(function(t){return r.OqkB.getFrequencyCount(t)})),s(this,"registerForEvent",(function(t,e){r.DGNj.Weok(t,e)})),s(this,"unregisterFromEvent",(function(t,e){r.DGNj.unregisterFromEvent(t,e)})),s(this,"fetch",(function(e,r,n,i){t.getController().fetchConfiguration(e,r,n,i)})),s(this,"TrIj",(function(){return r.EXbT})),s(this,"getCampaignMetaFromQueryEngine",(function(t){return r.OqkB.NveP(t)})),s(this,"ZCjh",(function(){return r.wsiO})),e.instance||(e.instance=this),e.instance}return a(e,[{key:"createObjConfig",value:function(t){try{this.dWcU=this.getQeState(),f(this.dWcU[t])||(this.dWcU[t]={SESSION:0,OVERALL:0,DATES:{}},this.wsiO&&(this.dWcU[t].DATES[this.wsiO]=0),this.setQeState(t))}catch(t){M.error("Can not create the frequency count object:"+t)}}},{key:"incrementFrequencies",value:function(t){this.dWcU=this.getQeState();var e=this.dWcU[t];e.SESSION=e.SESSION+1,e.OVERALL=e.OVERALL+1;var r=_();r===this.wsiO&&e.DATES&&e.DATES[r]||(this.wsiO=r,e.DATES={},e.DATES[this.wsiO]=0),e.DATES[this.wsiO]=e.DATES[this.wsiO]+1}}],[{key:"getInstance",value:function(){return e.instance||(e.instance=new e),e.instance}}]),e}();s(K,"instance",void 0),window.ceVersion=140;try{void 0===exports&&null===exports||(exports.default=K,module.exports=exports.default)}catch(t){}return K}));
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "apxor-qe",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.4.0",
|
|
4
4
|
"author": "Uma Sankar Yedida <umasankar.yedida@apxor.com> (https://www.apxor.com)",
|
|
5
5
|
"contributors": [
|
|
6
6
|
{
|
|
@@ -52,7 +52,7 @@
|
|
|
52
52
|
},
|
|
53
53
|
"dependencies": {
|
|
54
54
|
"jsdom": "^22.1.0",
|
|
55
|
-
"apxor": "2.
|
|
55
|
+
"apxor": "2.3.0"
|
|
56
56
|
},
|
|
57
57
|
"files": [
|
|
58
58
|
"dist"
|