apxor-qe 1.2.3 → 1.2.4
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 +331 -331
- 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 f=function(t){return void 0!==t&&!function(t){return null===t}(t)},h="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 d=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=h.indexOf(t.charAt(s++))<<18|h.indexOf(t.charAt(s++))<<12|(i=h.indexOf(t.charAt(s++)))<<6|(o=h.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))},g=function(t){switch(t){case"app_event":return"AE";case"client_event":return"CE";case"activity_time":case"activity_event":return"AE"}return"Unknown"},p=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()},w=window.ApxorLogger,S=a((function e(){var r=this;i(this,e),s(this,"pSoD","ALL"),s(this,"MNNc",[]),s(this,"AZyK",[]),s(this,"parse",(function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};try{if(r.pSoD=t.audience.audience_type,r.MNNc=t.audience.attributes.user,r.AZyK=t.audience.attributes.session,!Array.isArray(r.MNNc)||!Array.isArray(r.AZyK))return w.error("No attributes"),!1}catch(t){return w.error(t),!1}return!0})),s(this,"validate",(function(e,n){var i=!0;return"FTU"===r.pSoD&&(i=t.getController().getSessionInfo().is_first_session),i&&r.NqMe(e,r.MNNc)&&r.NqMe(n,r.AZyK)})),s(this,"NqMe",(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){w.error(t),n=!1}return n}))})),O=window.ApxorLogger,A=a((function t(){var e=this;i(this,t),s(this,"zwQc",0),s(this,"ZPtZ",0),s(this,"WkRn","SESSION"),s(this,"SzTO",0),s(this,"FWAX",0),s(this,"czAG",0),s(this,"parse",(function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};try{e.zwQc=t.frequency.count,e.czAG=e.zwQc,e.ZPtZ=t.frequency.time_interval,e.WkRn=t.frequency.validity,e.FWAX=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.WkRn){if(e.zwQc=parseInt(e.zwQc)-parseInt(r[t._id].SESSION),e.zwQc<=0)return console.warn("Max count limit reached for session:"+t._id),!1}else{if("OVERALL"!==e.WkRn)return O.info("Invalid config."),!1;if(e.zwQc=parseInt(e.zwQc)-parseInt(r[t._id].OVERALL),e.zwQc<=0)return console.warn("Max count limit reached for overall:"+t._id),!1}}catch(t){return O.error(t),!1}return!0})),s(this,"IwRA",(function(){e.zwQc=e.zwQc-1})),s(this,"getFrequencyCount",(function(){return e.zwQc})),s(this,"UYRW",(function(){"SESSION"===e.WkRn&&(e.zwQc=e.czAG,O.info("Campaign Limit reset"))})),s(this,"FwkM",(function(t){try{if(e.zwQc<=0)return!1;var r=K.getInstance().getQeState();if(!f(r)||!f(r[t]))return!0;if(0!==e.FWAX)if(parseInt(e.FWAX)-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){O.error("Error validating the frequency:"+t)}return!0}))})),E=a((function t(){var e=this;i(this,t),s(this,"XiTx",""),s(this,"pSoD",""),s(this,"parse",(function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};try{var r;e.XiTx=t.meta.name,e.pSoD=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}))})),x=window.ApxorLogger,T=a((function t(){var e=this;i(this,t),s(this,"Dpxa",-1),s(this,"YMiy",-1),s(this,"wPDl",-1),s(this,"SeqK",-1),s(this,"XgJJ",!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 x.error("Not valid dates"),!1;if(e.Dpxa=Date.parse(t.validity.start_date),e.YMiy=Date.parse(t.validity.end_date),f(t.time_limits_in_day)&&(e.XgJJ=t.time_limits_in_day,e.XgJJ&&f(t.time_limits))){var r=(new Date).toISOString().split("T")[0];if(e.wPDl=Date.parse(r+"T"+t.time_limits.start_time+".000Z"),e.SeqK=Date.parse(r+"T"+t.time_limits.end_time+".000Z"),isNaN(e.wPDl)||isNaN(e.SeqK))return x.error("Not valid times"),!1}}catch(t){return x.error(t),!1}return!0})),s(this,"validate",(function(){var t=Date.now();return t>e.Dpxa&&t<e.YMiy&&(!e.XgJJ||t>=e.wPDl&&t<=e.SeqK)}))})),F=a((function t(){var e=this;i(this,t),s(this,"XiTx",""),s(this,"BKuT",{}),s(this,"parse",(function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};try{e.XiTx=t.name,e.BKuT=t.additional_info}catch(t){return!1}return!0}))})),N=a((function t(){var e=this;i(this,t),s(this,"EDYb",0),s(this,"qEcy",0),s(this,"parse",(function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};try{if(e.EDYb=Number(t.lower),e.qEcy=Number(t.upper),isNaN(e.EDYb)||isNaN(e.qEcy))return!1}catch(t){return!1}return!0}))})),J=a((function t(){var e=this;i(this,t),s(this,"Psjs",0),s(this,"phws",""),s(this,"nxGv",""),s(this,"UJWO",new F),s(this,"YrXX",new N),s(this,"parse",(function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};try{return e.phws=t.event_type,e.nxGv=t.activity,e.UJWO.parse(t.details)&&e.YrXX.parse(t.time_bounds)}catch(t){return!1}}))})),b=window.ApxorLogger,I=a((function t(){var e=this;i(this,t),s(this,"Psjs",0),s(this,"xJVh",-1),s(this,"zwQc",0),s(this,"kxcj",""),s(this,"nxGv",""),s(this,"phws",""),s(this,"YrXX",new N),s(this,"UJWO",new F),s(this,"pHAk",new J),s(this,"JJoS","AND"),s(this,"VNBK",!1),s(this,"pSoD",void 0),s(this,"parse",(function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};try{return e.xJVh=t.sequence,e.zwQc=t.count_config.count,e.kxcj=t.count_config.operator,e.nxGv=t.activity,e.phws=t.event_type,e.JJoS=t.combine_operator,e.pSoD=t.type,e.UJWO.parse(t.details)&&e.pHAk.parse(t.trigger)&&e.YrXX.parse(t.time_bounds)}catch(t){return b.error(t),!1}}))})),U=window.ApxorLogger,D=function(){function e(){var r=this;i(this,e),s(this,"GFNv",0),s(this,"Eusd",""),s(this,"FdIU",new I),s(this,"KoRY",!1),s(this,"gCiS",!1),s(this,"lVAx",0),s(this,"JJoS","AND"),s(this,"Fqrt",-1),s(this,"IoCi",[]),s(this,"bGlk",{}),s(this,"PLjP",!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.Eusd=n,r.lVAx=i,r.IoCi=a;var s=r.FdIU.parse(e);if(s){if(r.JJoS=r.FdIU.JJoS,r.FdIU.VNBK){var u=r.FdIU.UJWO.XiTx;"APX_PAGE_OPENED"===u&&(u=r.FdIU.UJWO.BKuT.navigation_id,u=f(u)?u:r.FdIU.UJWO.XiTx),r.Fqrt=t.getController().getEventCount(u);var c=r.FdIU.zwQc,l=r.FdIU.kxcj;if(r.gCiS=r.HAgk(r.Fqrt-1,c,l,!1),r.KoRY=r.gCiS,r.gCiS&&"APX_PAGE_OPENED"===r.FdIU.UJWO.XiTx)return!0}return o&&0!==i||r.alSx(),!0}return!1})),s(this,"alSx",(function(){var t=r.FdIU,e=t.pHAk,n=K.getInstance();"app_start"===e.phws?(r.KoRY=!0,n.registerForEvent(g(t.phws)+"___"+t.UJWO.XiTx,r.HcVn)):n.registerForEvent(g(t.phws)+"___"+e.UJWO.XiTx,r.HcVn)})),s(this,"GNlE",(function(t,e,n,i){var o,a=(Date.now()-r.bGlk[e])/1e3;(null===(o=r.FdIU)||void 0===o||null===(o=o.UJWO)||void 0===o||null===(o=o.BKuT)||void 0===o?void 0:o.time)/1e3>a&&r._displayCampaign(n)})),s(this,"zRAr",(function(t,e,n,i){var o,a;r.PLjP=!0;var s=Date.now(),u=null===(o=r.FdIU)||void 0===o||null===(o=o.pHAk)||void 0===o?void 0:o.UJWO.XiTx,c=(s-r.bGlk[u])/1e3,l=null===(a=r.FdIU)||void 0===a||null===(a=a.UJWO)||void 0===a||null===(a=a.BKuT)||void 0===a?void 0:a.time;(l/=1e3)>c&&r._displayCampaign(n)})),s(this,"HcVn",(function(t,e,n,i){var o=K.getInstance();if(r.KoRY)g(r.FdIU.phws)===t&&r.INmv(n-r.FdIU.pHAk.Psjs,r.FdIU.YrXX)&&r.FdIU.UJWO.XiTx===e&&r.FRhW(r.FdIU.UJWO.BKuT,i)&&(r.GFNv+=1,r.gCiS=r.HAgk(r.GFNv,r.FdIU.zwQc,r.FdIU.kxcj),r.gCiS&&(r.FdIU.Psjs=n,o.validate(r.Eusd,r.lVAx)));else if(r.KoRY=r.mAby(t,e,n,i),r.KoRY){var a=r.FdIU,s=a.pHAk;if(s.Psjs=n,"activity_time"===(null==a?void 0:a.phws)){var u,c,l,f=null==a||null===(u=a.UJWO)||void 0===u||null===(u=u.BKuT)||void 0===u?void 0:u.time;(null==a||null===(c=a.UJWO)||void 0===c||null===(c=c.BKuT)||void 0===c?void 0:c.nkpi.length)>0&&(setTimeout((function(){r.PLjP||(r.gCiS=!0,r.gCiS&&(r.GFNv+=1,r.gCiS=r.HAgk(r.GFNv,r.FdIU.zwQc,r.FdIU.kxcj),r.gCiS&&(r.FdIU.Psjs=n,o.validate(r.Eusd,r.lVAx)))),a.UJWO.BKuT.nkpi.map((function(t){o.unregisterFromEvent(p(a.UJWO.BKuT.et)+"___"+t,r)}))}),f),a.UJWO.BKuT.nkpi.map((function(t){o.registerForEvent(p(a.UJWO.BKuT.et)+"___"+t,r.zRAr)}))),(null==a||null===(l=a.UJWO)||void 0===l||null===(l=l.BKuT)||void 0===l?void 0:l.kpi.length)>0&&(setTimeout((function(){a.UJWO.BKuT.kpi.map((function(t){o.unregisterFromEvent(p(a.UJWO.BKuT.et)+"___"+t,r)}))}),f),a.UJWO.BKuT.kpi.map((function(t){t===a.pHAk.UJWO.XiTx?(o.unregisterFromEvent(g(s.phws)+"___"+s.UJWO.XiTx,r),o.registerForEvent(p(a.UJWO.BKuT.et)+"___"+t,r.GNlE)):o.registerForEvent(p(a.UJWO.BKuT.et)+"___"+t,r.zRAr)})))}else o.unregisterFromEvent(g(s.phws)+"___"+s.UJWO.XiTx,r),o.registerForEvent(g(a.phws)+"___"+a.UJWO.XiTx,r);r.bGlk[e]=Date.now()}})),s(this,"mAby",(function(t,e,n,i){var o=r.FdIU.pHAk;return g(o.phws)===t&&o.UJWO.XiTx===e&&r.INmv(n,o.YrXX)&&r.FRhW(o.UJWO.BKuT,i)})),s(this,"INmv",(function(t,e){var r=Math.ceil(t);return r>e.EDYb&&r<e.qEcy})),s(this,"HAgk",(function(t,e,n){var i=!(arguments.length>3&&void 0!==arguments[3])||arguments[3];switch(i&&r.FdIU.VNBK&&(t+=r.Fqrt),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,"FRhW",(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){U.error(t),r=!1}return r}))}return a(e,[{key:"_displayCampaign",value:function(t){var e=K.getInstance();this.gCiS=!0,this.gCiS&&(this.GFNv+=1,this.gCiS=this.HAgk(this.GFNv,this.FdIU.zwQc,this.FdIU.kxcj),this.gCiS&&(this.FdIU.Psjs=t,e.validate(this.Eusd,this.lVAx)))}}]),e}(),C=window.ApxorLogger,j=a((function e(){var r=this;i(this,e),s(this,"VJYi",[]),s(this,"_ret_day",{}),s(this,"EsoR",{}),s(this,"sVml",!1),s(this,"stSX",!1),s(this,"parse",(function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};try{r.VJYi=t.overall_cfg.events,r._ret_day=t.overall_cfg.ret_day,r.EsoR=t.overall_cfg.session,r.sVml=t.overall_cfg.toggleRetDay,r.VJYi=t.overall_cfg.events,r.stSX=t.overall_cfg.toggleSession}catch(t){return C.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.sVml&&!isNaN(e)&&!(e>=r._ret_day.from&&e<=r._ret_day.to))return!1;if(r.stSX&&!isNaN(n)&&!(n>=r.EsoR.from&&n<=r.EsoR.to))return!1;try{for(var i=t.getController().getFromStorage("_apx_lt_count"),o=t.getSiteId(),a=JSON.parse(d(o,i)),s=0;s<r.VJYi.length;s++){if(a[r.VJYi[s].name.replace("'","").replace("’","")])return!1}}catch(t){C.error("Failed to validate the lt count:"+t)}return!0}))})),R=window.ApxorLogger,W=a((function e(){var n=this;i(this,e),s(this,"HMDi",[]),s(this,"Eusd",""),s(this,"TZgO",new E),s(this,"ygTF",new S),s(this,"WkRn",new T),s(this,"JOfv",new A),s(this,"OLfY",new j),s(this,"vZax",!1),s(this,"fyZj",[]),s(this,"parse",(function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};try{if(!f(t._id))return R.error("No Id"),!1;if(!f(t.enabled)||!t.enabled)return R.error("Not enabled"),!1;if(!(n.TZgO.parse(t)&&n.WkRn.parse(t)&&n.JOfv.parse(t)&&n.ygTF.parse(t)&&n.OLfY.parse(t)))return!1;if(!f(t.conditions)||!Array.isArray(t.conditions))return R.error("No valid conditions",t.conditions),!1;n.Eusd=t._id,n.vZax=!!f(t.sequence_enabled)&&t.sequence_enabled,n.vZax&&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.fyZj=[];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.fyZj=[].concat(u(n.fyZj),[s])}var c=new D;c.initialize(o,n.Eusd,i,n.vZax,n.fyZj)&&n.HMDi.push(c)}return n.HMDi.length>0}catch(t){return R.error(t),!1}})),s(this,"ZsYF",(function(t){if(!(t<0))if(n.vZax){var e=n.HMDi[t];if(f(e)&&e.gCiS){var r=n.HMDi[t-1];if(f(r)&&!r.gCiS)return;var i=n.HMDi[t+1];f(i)?i.alSx():n.wcgW()}}else n.wcgW()})),s(this,"wcgW",(function(){var e=t.getController().getUserAttributes(),i=t.getController().getSessionAttributes();if(n.WkRn.validate()&&n.ygTF.validate(e,i)&&n.OLfY.validate()){for(var o=n.HMDi.length,a=o<1,s="",u=0;u<o;u++){var c=n.HMDi[u],l=c.gCiS;if(""===s.trim())a=l;else switch(s){case"AND":a=a&&l;break;case"OR":a=a||l}s=c.JJoS}if(a){if(console.debug("onCondition satisfied"),!n.JOfv.FwkM(n.Eusd))return void console.warn("Maximum limit reached",n.Eusd);console.log("Dispatching event",n.TZgO.pSoD),!0===n.TZgO._only_context&&t.logEvent("apx_context_evaluated",r(r({},n.TZgO._attr),{},{message_name:n.TZgO.XiTx,id:n.Eusd})),t.getController().dispatchEvent(n.TZgO.pSoD,{name:n.TZgO.pSoD,additional_info:{uuid:n.Eusd,name:n.TZgO.XiTx}})}}})),s(this,"IwRA",(function(){n.JOfv.IwRA()})),s(this,"getFrequencyCount",(function(){return n.JOfv.getFrequencyCount()})),s(this,"Dith",(function(){return n.JOfv.UYRW()}))})),k=a((function t(){var e=this;i(this,t),s(this,"ooiv",{}),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 W;a.parse(i)?e.ooiv[o]=a:console.warn("Failed to parse cfg",o)}}})),s(this,"validate",(function(t,r){e.ooiv[t]&&e.ooiv[t].ZsYF(r)})),s(this,"IwRA",(function(t){e.ooiv[t].IwRA()})),s(this,"getFrequencyCount",(function(t){return e.ooiv[t].getFrequencyCount()})),s(this,"resetFrequencyCounts",(function(){var t=e.ooiv;for(var r in t)t[r].Dith()})),s(this,"NrmJ",(function(t){try{if(e.ooiv){var r=e.ooiv[t];if(r&&r.TZgO)return r.TZgO}}catch(t){console.log("Error in getting the campaign meta ".concat(t))}return{}}))})),P=window.ApxorLogger,q=a((function e(){var r=this;i(this,e),s(this,"fJga",{}),s(this,"mDlm",[]),s(this,"UAPh",!1),s(this,"initialize",(function(){var e=t.getController();e.registerForEvent("APP_EVENT",(function(t){return r.IjTE(t,"AE")})),e.registerForEvent("CLIENT_EVENT",(function(t){return r.IjTE(t,"CE")}))})),s(this,"xcoZ",(function(){for(var t in r.mDlm)r.Ywjj(t.event,t.key,t.type);r.UAPh=!0})),s(this,"Pdms",(function(t,e){var n;"function"==typeof e&&((n=r.fJga[t]?r.fJga[t]:[]).push(e),r.fJga[t]=n,P.debug("Listeners list: ",r.fJga))})),s(this,"unregisterFromEvent",(function(t,e){if(r.fJga[t]){for(var n=r.fJga[t],i=[],o=0;o<n.length;o++){var a=n[o];a!==e&&i.push(a)}r.fJga[t]=i}})),s(this,"IjTE",(function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"AE",n=e+"___"+t.name;r.Ywjj(t,n,e)})),s(this,"Ywjj",(function(e,n,i){if(r.UAPh){if(P.debug("Notifying listeners for event: "+e+", "+n,r.fJga),r.fJga[n])for(var o=r.fJga[n],a=t.getController().getSDKRunningTimeInSec(),s=0;s<o.length;s++){(0,o[s])(i,e.name,a,e.additional_info)}}else r.mDlm.push({event:e,key:n,type:i})}))})),X=window.ApxorLogger,K=function(){function e(){var r=this;return i(this,e),s(this,"UcJD",!1),s(this,"hvcM",null),s(this,"OfTR",_()),s(this,"pcQK",new q),s(this,"rtEJ",t.getSiteId()),s(this,"cNxd",{}),s(this,"getQeState",(function(){try{var e=t.getController().getFromStorage("qe_state");return e?JSON.parse(d(r.rtEJ,e)):(r.cNxd={},r.setQeState())}catch(t){return r.cNxd={},r.setQeState()}})),s(this,"setQeState",(function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"";try{t.getController().persistToStorage("qe_state",r.cNxd,!0)}catch(n){""===e?r.cNxd={}:r.cNxd[e]={SESSION:0,OVERALL:0,DATES:{}},t.getController().persistToStorage("qe_state",r.cNxd,!0)}return r.cNxd})),s(this,"initialize",(function(){r.UcJD||(r.UcJD=!0,r.hvcM=new k,r.pcQK.initialize(),r.cNxd=r.getQeState(),X.info("QE Initialized.."))})),s(this,"parse",(function(t){r.ZzAy()?(r.hvcM.parse(t),r.pcQK.xcoZ()):X.warn("Must call init first. Unable to proceed")})),s(this,"validate",(function(t,e){r.ZzAy()&&r.hvcM.validate(t,e)})),s(this,"updateCount",(function(t){try{f(r.cNxd[t])||r.createObjConfig(t),r.incrementFrequencies(t),r.setQeState(t),r.hvcM.IwRA(t)}catch(t){console.log("Could not update the count config:".concat(t))}})),s(this,"resetFrequencyCounts",(function(){r.hvcM.resetFrequencyCounts()})),s(this,"getFrequencyCount",(function(t){return r.hvcM.getFrequencyCount(t)})),s(this,"registerForEvent",(function(t,e){r.pcQK.Pdms(t,e)})),s(this,"unregisterFromEvent",(function(t,e){r.pcQK.unregisterFromEvent(t,e)})),s(this,"fetch",(function(e,r,n,i){t.getController().fetchConfiguration(e,r,n,i)})),s(this,"ZzAy",(function(){return r.UcJD})),s(this,"getCampaignMetaFromQueryEngine",(function(t){return r.hvcM.NrmJ(t)})),s(this,"PSuD",(function(){return r.OfTR})),e.instance||(e.instance=this),e.instance}return a(e,[{key:"createObjConfig",value:function(t){try{this.cNxd=this.getQeState(),f(this.cNxd[t])||(this.cNxd[t]={SESSION:0,OVERALL:0,DATES:{}},this.OfTR&&(this.cNxd[t].DATES[this.OfTR]=0),this.setQeState(t))}catch(t){X.error("Can not create the frequency count object:"+t)}}},{key:"incrementFrequencies",value:function(t){this.cNxd=this.getQeState();var e=this.cNxd[t];e.SESSION=e.SESSION+1,e.OVERALL=e.OVERALL+1;var r=_();r===this.OfTR&&e.DATES&&e.DATES[r]||(this.OfTR=r,e.DATES={},e.DATES[this.OfTR]=0),e.DATES[this.OfTR]=e.DATES[this.OfTR]+1}}],[{key:"getInstance",value:function(){return e.instance||(e.instance=new e),e.instance}}]),e}();s(K,"instance",void 0),window.ceVersion=123;try{void 0===exports&&null===exports||(exports.default=K,module.exports=exports.default)}catch(t){}return K}));
|
|
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}));
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "apxor-qe",
|
|
3
|
-
"version": "1.2.
|
|
3
|
+
"version": "1.2.4",
|
|
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.1.
|
|
55
|
+
"apxor": "2.1.4"
|
|
56
56
|
},
|
|
57
57
|
"files": [
|
|
58
58
|
"dist"
|