apxor-qe 1.3.0 → 1.4.1
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 +656 -357
- 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 n=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter((function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable}))),n.push.apply(n,r)}return n}function n(t){for(var n=1;n<arguments.length;n++){var r=null!=arguments[n]?arguments[n]:{};n%2?e(Object(r),!0).forEach((function(e){s(t,e,r[e])})):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(r)):e(Object(r)).forEach((function(e){Object.defineProperty(t,e,Object.getOwnPropertyDescriptor(r,e))}))}return t}function r(t){return(r="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 n=0;n<e.length;n++){var r=e[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(t,l(r.key),r)}}function a(t,e,n){return e&&o(t.prototype,e),n&&o(t,n),Object.defineProperty(t,"prototype",{writable:!1}),t}function s(t,e,n){return(e=l(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,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 n=Object.prototype.toString.call(t).slice(8,-1);"Object"===n&&t.constructor&&(n=t.constructor.name);if("Map"===n||"Set"===n)return Array.from(t);if("Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))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 n=0,r=new Array(e);n<e;n++)r[n]=t[n];return r}function l(t){var e=function(t,e){if("object"!=typeof t||null===t)return t;var n=t[Symbol.toPrimitive];if(void 0!==n){var r=n.call(t,e||"default");if("object"!=typeof r)return r;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 d(t,e){return Array.from(e).map((function(e,n){return String.fromCharCode(e^function(t,e){return t.charCodeAt(Math.floor(e%t.length))}(t,n))})).join("")}var v=function(t,e){return d(t,e=function(t){var e,n,r,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,n=a>>8&255,r=255&a,u.push(e),64!==i&&(u.push(n),64!==o&&u.push(r))}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,n){switch(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;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 n=e?t.replace(new RegExp("^/(.*?)/"+e+"$"),"$1"):t;return new RegExp(n,e)},_=function(){var t=new Date;return t.getDate()+"/"+t.getMonth()+"/"+t.getFullYear()},F=window.ApxorLogger,O=a((function e(){var n=this;i(this,e),s(this,"FFVT","ALL"),s(this,"Peqo",[]),s(this,"ukFQ",[]),s(this,"parse",(function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};try{if(n.FFVT=t.audience.audience_type,n.Peqo=t.audience.attributes.user,n.ukFQ=t.audience.attributes.session,!Array.isArray(n.Peqo)||!Array.isArray(n.ukFQ))return F.error("No attributes"),!1}catch(t){return F.error(t),!1}return!0})),s(this,"validate",(function(e,r){var i=!0;return"FTU"===n.FFVT&&(i=t.getController().getSessionInfo().is_first_session),i&&n.pYKU(e,n.Peqo)&&n.pYKU(r,n.ukFQ)})),s(this,"pYKU",(function(t,e){var n=e.length,r=!0;try{for(var i,o=function(){var n=e[a];if(!t[n.name]||!1===r)return{v:!1};var i=n.operator,o=n.type,s=n.value.map((function(t){return"s"===o?t:"l"===o?parseInt(t):"f"===o?parseFloat(t):void 0})),u=(Array.isArray(t[n.name])?t[n.name]:[t[n.name]]).some((function(t){return s.some((function(e){return y(t,e,i)}))}));r=r&&u},a=0;a<n;a++)if(i=o())return i.v}catch(t){F.error(t),r=!1}return r}))})),C=window.ApxorLogger,V=a((function t(){var e=this;i(this,t),s(this,"FDLa",0),s(this,"CBbn",0),s(this,"bLov","SESSION"),s(this,"WzqN",0),s(this,"FhVO",0),s(this,"HkIT",0),s(this,"parse",(function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};try{e.FDLa=t.frequency.count,e.HkIT=e.FDLa,e.CBbn=t.frequency.time_interval,e.bLov=t.frequency.validity,e.FhVO=t.frequency.ses_lmt,e._dayCount=t.frequency.day_lmt;var n=M.getInstance().getQeState();if(!h(n)||!h(n[t._id]))return!0;if("SESSION"===e.bLov){if(e.FDLa=parseInt(e.FDLa)-parseInt(n[t._id].SESSION),e.FDLa<=0)return console.warn("Max count limit reached for session:"+t._id),!1}else{if("OVERALL"!==e.bLov)return C.info("Invalid config."),!1;if(e.FDLa=parseInt(e.FDLa)-parseInt(n[t._id].OVERALL),e.FDLa<=0)return console.warn("Max count limit reached for overall:"+t._id),!1}}catch(t){return C.error(t),!1}return!0})),s(this,"PUEA",(function(){e.FDLa=e.FDLa-1})),s(this,"getFrequencyCount",(function(){return e.FDLa})),s(this,"kPus",(function(){"SESSION"===e.bLov&&(e.FDLa=e.HkIT,C.info("Campaign Limit reset"))})),s(this,"Frbd",(function(t){try{if(e.FDLa<=0)return!1;var n=M.getInstance().getQeState();if(!h(n)||!h(n[t]))return!0;if(0!==e.FhVO)if(parseInt(e.FhVO)-parseInt(n[t].SESSION)<=0)return!1;if(0!==e._dayCount){var r,i=_();if(parseInt(e._dayCount)-parseInt((null===(r=n[t])||void 0===r?void 0:r.DATES[i])||0)<=0)return!1}}catch(t){C.error("Error validating the frequency:"+t)}return!0}))})),b=a((function t(){var e=this;i(this,t),s(this,"CtPY",""),s(this,"FFVT",""),s(this,"parse",(function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};try{var n;e.CtPY=t.meta.name,e.FFVT=t.meta.type,e._only_context=t.meta.only_context,e._attr=(null===(n=t.meta)||void 0===n?void 0:n.attr)||{}}catch(t){return window.ApxorLogger.error(t),!1}return!0}))})),L=window.ApxorLogger,E=a((function t(){var e=this;i(this,t),s(this,"JHaV",-1),s(this,"CDOi",-1),s(this,"qOFY",-1),s(this,"vZJY",-1),s(this,"RnJn",!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 L.error("Not valid dates"),!1;if(e.JHaV=Date.parse(t.validity.start_date),e.CDOi=Date.parse(t.validity.end_date),h(t.time_limits_in_day)&&(e.RnJn=t.time_limits_in_day,e.RnJn&&h(t.time_limits))){var n=(new Date).toISOString().split("T")[0];if(e.qOFY=Date.parse(n+"T"+t.time_limits.start_time+".000Z"),e.vZJY=Date.parse(n+"T"+t.time_limits.end_time+".000Z"),isNaN(e.qOFY)||isNaN(e.vZJY))return L.error("Not valid times"),!1}}catch(t){return L.error(t),!1}return!0})),s(this,"validate",(function(){var t=Date.now();return t>e.JHaV&&t<e.CDOi&&(!e.RnJn||t>=e.qOFY&&t<=e.vZJY)}))})),w=a((function t(){var e=this;i(this,t),s(this,"CtPY",""),s(this,"NVOO",{}),s(this,"parse",(function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};try{e.CtPY=t.name,e.NVOO=t.additional_info}catch(t){return!1}return!0}))})),A=a((function t(){var e=this;i(this,t),s(this,"RZpl",0),s(this,"FsQW",0),s(this,"parse",(function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};try{if(e.RZpl=Number(t.lower),e.FsQW=Number(t.upper),isNaN(e.RZpl)||isNaN(e.FsQW))return!1}catch(t){return!1}return!0}))})),S=a((function t(){var e=this;i(this,t),s(this,"gplO",0),s(this,"AlVX",""),s(this,"fBwj",""),s(this,"QYMC",new w),s(this,"pWFR",new A),s(this,"parse",(function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};try{return e.AlVX=t.event_type,e.fBwj=t.activity,e.QYMC.parse(t.details)&&e.pWFR.parse(t.time_bounds)}catch(t){return!1}}))})),k=window.ApxorLogger,Y=a((function t(){var e=this;i(this,t),s(this,"gplO",0),s(this,"fnMy",-1),s(this,"FDLa",0),s(this,"LXVx",""),s(this,"fBwj",""),s(this,"AlVX",""),s(this,"pWFR",new A),s(this,"QYMC",new w),s(this,"jsSe",new S),s(this,"kURO","AND"),s(this,"eatT",!1),s(this,"FFVT",void 0),s(this,"parse",(function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};try{return e.fnMy=t.sequence,e.FDLa=t.count_config.count,e.LXVx=t.count_config.operator,e.fBwj=t.activity,e.AlVX=t.event_type,e.kURO=t.combine_operator,e.FFVT=t.type,e.QYMC.parse(t.details)&&e.jsSe.parse(t.trigger)&&e.pWFR.parse(t.time_bounds)}catch(t){return k.error(t),!1}}))})),q=window.ApxorLogger,N=function(){function e(){var n=this;i(this,e),s(this,"vWIX",0),s(this,"Fdjl",""),s(this,"dqkJ",new Y),s(this,"AhjD",!1),s(this,"xVdJ",!1),s(this,"BjBE",0),s(this,"kURO","AND"),s(this,"sqsm",-1),s(this,"wlEj",[]),s(this,"qewW",{}),s(this,"doep",!1),s(this,"initialize",(function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},r=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]:[];n.Fdjl=r,n.BjBE=i,n.wlEj=a;var s=n.dqkJ.parse(e);if(s){if(n.kURO=n.dqkJ.kURO,n.dqkJ.eatT){var u=n.dqkJ.QYMC.CtPY;"APX_PAGE_OPENED"===u&&(u=n.dqkJ.QYMC.NVOO.navigation_id,u=h(u)?u:n.dqkJ.QYMC.CtPY),n.sqsm=t.getController().getEventCount(u);var c=n.dqkJ.FDLa,l=n.dqkJ.LXVx;if(n.xVdJ=n.LzlO(n.sqsm-1,c,l,!1),n.AhjD=n.xVdJ,n.xVdJ&&"APX_PAGE_OPENED"===n.dqkJ.QYMC.CtPY)return!0}return o&&0!==i||n.qqsE(),!0}return!1})),s(this,"qqsE",(function(){var t=n.dqkJ,e=t.jsSe,r=M.getInstance();"app_start"===e.AlVX?(n.AhjD=!0,r.registerForEvent(p(t.AlVX)+"___"+t.QYMC.CtPY,n.LydU)):r.registerForEvent(p(t.AlVX)+"___"+e.QYMC.CtPY,n.LydU)})),s(this,"uMbk",(function(t,e,r,i){var o,a=(Date.now()-n.qewW[e])/1e3;(null===(o=n.dqkJ)||void 0===o||null===(o=o.QYMC)||void 0===o||null===(o=o.NVOO)||void 0===o?void 0:o.time)/1e3>a&&n._displayCampaign(r)})),s(this,"kIfZ",(function(t,e,r,i){var o,a;n.doep=!0;var s=Date.now(),u=null===(o=n.dqkJ)||void 0===o||null===(o=o.jsSe)||void 0===o?void 0:o.QYMC.CtPY,c=(s-n.qewW[u])/1e3,l=null===(a=n.dqkJ)||void 0===a||null===(a=a.QYMC)||void 0===a||null===(a=a.NVOO)||void 0===a?void 0:a.time;(l/=1e3)>c&&n._displayCampaign(r)})),s(this,"LydU",(function(t,e,r,i){var o=M.getInstance();if(n.AhjD)p(n.dqkJ.AlVX)===t&&n.Chvr(r-n.dqkJ.jsSe.gplO,n.dqkJ.pWFR)&&n.dqkJ.QYMC.CtPY===e&&n.BXyf(n.dqkJ.QYMC.NVOO,i)&&(n.vWIX+=1,n.xVdJ=n.LzlO(n.vWIX,n.dqkJ.FDLa,n.dqkJ.LXVx),n.xVdJ&&(n.dqkJ.gplO=r,o.validate(n.Fdjl,n.BjBE)));else if(n.AhjD=n.zOaF(t,e,r,i),n.AhjD){var a=n.dqkJ,s=a.jsSe;if(s.gplO=r,"activity_time"===(null==a?void 0:a.AlVX)){var u,c,l,h=null==a||null===(u=a.QYMC)||void 0===u||null===(u=u.NVOO)||void 0===u?void 0:u.time;(null==a||null===(c=a.QYMC)||void 0===c||null===(c=c.NVOO)||void 0===c?void 0:c.nkpi.length)>0&&(setTimeout((function(){n.doep||(n.xVdJ=!0,n.xVdJ&&(n.vWIX+=1,n.xVdJ=n.LzlO(n.vWIX,n.dqkJ.FDLa,n.dqkJ.LXVx),n.xVdJ&&(n.dqkJ.gplO=r,o.validate(n.Fdjl,n.BjBE)))),a.QYMC.NVOO.nkpi.map((function(t){o.unregisterFromEvent(g(a.QYMC.NVOO.et)+"___"+t,n)}))}),h),a.QYMC.NVOO.nkpi.map((function(t){o.registerForEvent(g(a.QYMC.NVOO.et)+"___"+t,n.kIfZ)}))),(null==a||null===(l=a.QYMC)||void 0===l||null===(l=l.NVOO)||void 0===l?void 0:l.kpi.length)>0&&(setTimeout((function(){a.QYMC.NVOO.kpi.map((function(t){o.unregisterFromEvent(g(a.QYMC.NVOO.et)+"___"+t,n)}))}),h),a.QYMC.NVOO.kpi.map((function(t){t===a.jsSe.QYMC.CtPY?(o.unregisterFromEvent(p(s.AlVX)+"___"+s.QYMC.CtPY,n),o.registerForEvent(g(a.QYMC.NVOO.et)+"___"+t,n.uMbk)):o.registerForEvent(g(a.QYMC.NVOO.et)+"___"+t,n.kIfZ)})))}else o.unregisterFromEvent(p(s.AlVX)+"___"+s.QYMC.CtPY,n),o.registerForEvent(p(a.AlVX)+"___"+a.QYMC.CtPY,n);n.qewW[e]=Date.now()}})),s(this,"zOaF",(function(t,e,r,i){var o=n.dqkJ.jsSe;return p(o.AlVX)===t&&o.QYMC.CtPY===e&&n.Chvr(r,o.pWFR)&&n.BXyf(o.QYMC.NVOO,i)})),s(this,"Chvr",(function(t,e){var n=Math.ceil(t);return n>e.RZpl&&n<e.FsQW})),s(this,"LzlO",(function(t,e,r){var i=!(arguments.length>3&&void 0!==arguments[3])||arguments[3];switch(i&&n.dqkJ.eatT&&(t+=n.sqsm),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;default:return!1}})),s(this,"BXyf",(function(t,e){var n=!0;try{var i,o=function(){if(!e[a]||!1===n)return{v:!1};if("object"===r(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)}));n=n&&u}else n=n&&y(e[a],t[a],"EQ")};for(var a in t)if(i=o())return i.v}catch(t){q.error(t),n=!1}return n}))}return a(e,[{key:"_displayCampaign",value:function(t){var e=M.getInstance();this.xVdJ=!0,this.xVdJ&&(this.vWIX+=1,this.xVdJ=this.LzlO(this.vWIX,this.dqkJ.FDLa,this.dqkJ.LXVx),this.xVdJ&&(this.dqkJ.gplO=t,e.validate(this.Fdjl,this.BjBE)))}}]),e}(),j=window.ApxorLogger,x=a((function e(){var n=this;i(this,e),s(this,"PMCb",[]),s(this,"_ret_day",{}),s(this,"ejSN",{}),s(this,"eQvN",!1),s(this,"eEge",!1),s(this,"parse",(function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};try{n.PMCb=t.overall_cfg.events,n._ret_day=t.overall_cfg.ret_day,n.ejSN=t.overall_cfg.session,n.eQvN=t.overall_cfg.toggleRetDay,n.PMCb=t.overall_cfg.events,n.eEge=t.overall_cfg.toggleSession}catch(t){return j.error(t),!1}return!0})),s(this,"validate",(function(){var e=parseInt(t.getController().getFromStorage("apx_retained_days")),r=parseInt(t.getController().getFromStorage("apx_retained_session"));if(n.eQvN&&!isNaN(e)&&!(e>=n._ret_day.from&&e<=n._ret_day.to))return!1;if(n.eEge&&!isNaN(r)&&!(r>=n.ejSN.from&&r<=n.ejSN.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),n=new Uint8Array(e),r=0;r<t.length;r++)n[r]=t.charCodeAt(r);return e}(v(o,i)))),s=0;s<n.PMCb.length;s++){if(a[n.PMCb[s].name.replace("'","").replace("’","")])return!1}}catch(t){j.error("Failed to validate the lt count:"+t)}return!0}))})),J=window.ApxorLogger,D=a((function e(){var r=this;i(this,e),s(this,"BHxj",[]),s(this,"Fdjl",""),s(this,"FBLV",new b),s(this,"HZsk",new O),s(this,"bLov",new E),s(this,"RUmb",new V),s(this,"mpfN",new x),s(this,"OBnx",!1),s(this,"lyLV",[]),s(this,"parse",(function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};try{if(!h(t._id))return J.error("No Id"),!1;if(!h(t.enabled)||!t.enabled)return J.error("Not enabled"),!1;if(!(r.FBLV.parse(t)&&r.bLov.parse(t)&&r.RUmb.parse(t)&&r.HZsk.parse(t)&&r.mpfN.parse(t)))return!1;if(!h(t.conditions)||!Array.isArray(t.conditions))return J.error("No valid conditions",t.conditions),!1;r.Fdjl=t._id,r.OBnx=!!h(t.sequence_enabled)&&t.sequence_enabled,r.OBnx&&t.conditions.sort((function(t,e){return t.sequence<e.sequence}));for(var e=t.conditions,n=e.length,i=0;i<n;i++){r.lyLV=[];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};r.lyLV=[].concat(u(r.lyLV),[s])}var c=new N;c.initialize(o,r.Fdjl,i,r.OBnx,r.lyLV)&&r.BHxj.push(c)}return r.BHxj.length>0}catch(t){return J.error(t),!1}})),s(this,"BLtn",(function(t){if(!(t<0))if(r.OBnx){var e=r.BHxj[t];if(h(e)&&e.xVdJ){var n=r.BHxj[t-1];if(h(n)&&!n.xVdJ)return;var i=r.BHxj[t+1];h(i)?i.qqsE():r.CtCE()}}else r.CtCE()})),s(this,"CtCE",(function(){var e=t.getController().getUserAttributes(),i=t.getController().getSessionAttributes();if(r.bLov.validate()&&r.HZsk.validate(e,i)&&r.mpfN.validate()){for(var o=r.BHxj.length,a=o<1,s="",u=0;u<o;u++){var c=r.BHxj[u],l=c.xVdJ;if(""===s.trim())a=l;else switch(s){case"AND":a=a&&l;break;case"OR":a=a||l}s=c.kURO}if(a){if(console.debug("onCondition satisfied"),!r.RUmb.Frbd(r.Fdjl))return void console.warn("Maximum limit reached",r.Fdjl);console.log("Dispatching event",r.FBLV.FFVT),!0===r.FBLV._only_context&&t.logEvent("apx_context_evaluated",n(n({},r.FBLV._attr),{},{message_name:r.FBLV.CtPY,id:r.Fdjl})),t.getController().dispatchEvent(r.FBLV.FFVT,{name:r.FBLV.FFVT,additional_info:{uuid:r.Fdjl,name:r.FBLV.CtPY}})}}})),s(this,"PUEA",(function(){r.RUmb.PUEA()})),s(this,"getFrequencyCount",(function(){return r.RUmb.getFrequencyCount()})),s(this,"YMgG",(function(){return r.RUmb.kPus()}))})),Q=a((function t(){var e=this;i(this,t),s(this,"benn",{}),s(this,"parse",(function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{configs:[]};if(h(t)&&h(t.configs)){var n=t.configs;if(!Array.isArray(n))return;n.sort((function(t,e){var n,r;return(null!==(n=t.prio)&&void 0!==n?n:-1)-(null!==(r=e.prio)&&void 0!==r?r:-1)}));for(var r=0;r<n.length;r++){var i=n[r],o=i._id,a=new D;a.parse(i)?e.benn[o]=a:console.warn("Failed to parse cfg",o)}}})),s(this,"validate",(function(t,n){e.benn[t]&&e.benn[t].BLtn(n)})),s(this,"PUEA",(function(t){e.benn[t].PUEA()})),s(this,"getFrequencyCount",(function(t){return e.benn[t].getFrequencyCount()})),s(this,"resetFrequencyCounts",(function(){var t=e.benn;for(var n in t)t[n].YMgG()})),s(this,"SynP",(function(t){try{if(e.benn){var n=e.benn[t];if(n&&n.FBLV)return n.FBLV}}catch(t){console.log("Error in getting the campaign meta ".concat(t))}return{}}))})),T=window.ApxorLogger,P=a((function e(){var n=this;i(this,e),s(this,"VywR",{}),s(this,"Tdmf",[]),s(this,"wJFP",!1),s(this,"initialize",(function(){var e=t.getController();e.registerForEvent("APP_EVENT",(function(t){return n.tkDV(t,"AE")})),e.registerForEvent("CLIENT_EVENT",(function(t){return n.tkDV(t,"CE")}))})),s(this,"QkcY",(function(){for(var t in n.Tdmf)n.MCKA(t.event,t.key,t.type);n.wJFP=!0})),s(this,"HhWj",(function(t,e){var r;"function"==typeof e&&((r=n.VywR[t]?n.VywR[t]:[]).push(e),n.VywR[t]=r,T.debug("Listeners list: ",n.VywR))})),s(this,"unregisterFromEvent",(function(t,e){if(n.VywR[t]){for(var r=n.VywR[t],i=[],o=0;o<r.length;o++){var a=r[o];a!==e&&i.push(a)}n.VywR[t]=i}})),s(this,"tkDV",(function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"AE",r=e+"___"+t.name;n.MCKA(t,r,e)})),s(this,"MCKA",(function(e,r,i){if(n.wJFP){if(T.debug("Notifying listeners for event: "+e+", "+r,n.VywR),n.VywR[r])for(var o=n.VywR[r],a=t.getController().getSDKRunningTimeInSec(),s=0;s<o.length;s++){(0,o[s])(i,e.name,a,e.additional_info)}}else n.Tdmf.push({event:e,key:r,type:i})}))})),I=window.ApxorLogger,M=function(){function e(){var n=this;return i(this,e),s(this,"nckW",!1),s(this,"yTlh",null),s(this,"JXUH",_()),s(this,"cINd",new P),s(this,"TKYH",t.getSiteId()),s(this,"hLYu",{}),s(this,"getQeState",(function(){try{var e=t.getController().getFromStorage("qe_state");return e?JSON.parse(v(n.TKYH,e)):(n.hLYu={},n.setQeState())}catch(t){return n.hLYu={},n.setQeState()}})),s(this,"setQeState",(function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"";try{t.getController().persistToStorage("qe_state",n.hLYu,!0)}catch(r){""===e?n.hLYu={}:n.hLYu[e]={SESSION:0,OVERALL:0,DATES:{}},t.getController().persistToStorage("qe_state",n.hLYu,!0)}return n.hLYu})),s(this,"initialize",(function(){n.nckW||(n.nckW=!0,n.yTlh=new Q,n.cINd.initialize(),n.hLYu=n.getQeState(),I.info("QE Initialized.."))})),s(this,"parse",(function(t){n.kEWF()?(n.yTlh.parse(t),n.cINd.QkcY()):I.warn("Must call init first. Unable to proceed")})),s(this,"validate",(function(t,e){n.kEWF()&&n.yTlh.validate(t,e)})),s(this,"updateCount",(function(t){try{h(n.hLYu[t])||n.createObjConfig(t),n.incrementFrequencies(t),n.setQeState(t),n.yTlh.PUEA(t)}catch(t){console.log("Could not update the count config:".concat(t))}})),s(this,"resetFrequencyCounts",(function(){n.yTlh.resetFrequencyCounts()})),s(this,"getFrequencyCount",(function(t){return n.yTlh.getFrequencyCount(t)})),s(this,"registerForEvent",(function(t,e){n.cINd.HhWj(t,e)})),s(this,"unregisterFromEvent",(function(t,e){n.cINd.unregisterFromEvent(t,e)})),s(this,"fetch",(function(e,n,r,i){t.getController().fetchConfiguration(e,n,r,i)})),s(this,"kEWF",(function(){return n.nckW})),s(this,"getCampaignMetaFromQueryEngine",(function(t){return n.yTlh.SynP(t)})),s(this,"VBfn",(function(){return n.JXUH})),e.instance||(e.instance=this),e.instance}return a(e,[{key:"createObjConfig",value:function(t){try{this.hLYu=this.getQeState(),h(this.hLYu[t])||(this.hLYu[t]={SESSION:0,OVERALL:0,DATES:{}},this.JXUH&&(this.hLYu[t].DATES[this.JXUH]=0),this.setQeState(t))}catch(t){I.error("Can not create the frequency count object:"+t)}}},{key:"incrementFrequencies",value:function(t){this.hLYu=this.getQeState();var e=this.hLYu[t];e.SESSION=e.SESSION+1,e.OVERALL=e.OVERALL+1;var n=_();n===this.JXUH&&e.DATES&&e.DATES[n]||(this.JXUH=n,e.DATES={},e.DATES[this.JXUH]=0),e.DATES[this.JXUH]=e.DATES[this.JXUH]+1}}],[{key:"getInstance",value:function(){return e.instance||(e.instance=new e),e.instance}}]),e}();s(M,"instance",void 0),window.ceVersion=130;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 n=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter((function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable}))),n.push.apply(n,r)}return n}function n(t){for(var n=1;n<arguments.length;n++){var r=null!=arguments[n]?arguments[n]:{};n%2?e(Object(r),!0).forEach((function(e){s(t,e,r[e])})):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(r)):e(Object(r)).forEach((function(e){Object.defineProperty(t,e,Object.getOwnPropertyDescriptor(r,e))}))}return t}function r(t){return(r="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 n=0;n<e.length;n++){var r=e[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(t,l(r.key),r)}}function a(t,e,n){return e&&o(t.prototype,e),n&&o(t,n),Object.defineProperty(t,"prototype",{writable:!1}),t}function s(t,e,n){return(e=l(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,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 n=Object.prototype.toString.call(t).slice(8,-1);"Object"===n&&t.constructor&&(n=t.constructor.name);if("Map"===n||"Set"===n)return Array.from(t);if("Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))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 n=0,r=new Array(e);n<e;n++)r[n]=t[n];return r}function l(t){var e=function(t,e){if("object"!=typeof t||null===t)return t;var n=t[Symbol.toPrimitive];if(void 0!==n){var r=n.call(t,e||"default");if("object"!=typeof r)return r;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 d(t,e){return Array.from(e).map((function(e,n){return String.fromCharCode(e^function(t,e){return t.charCodeAt(Math.floor(e%t.length))}(t,n))})).join("")}var v=function(t,e){return d(t,e=function(t){var e,n,r,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,n=a>>8&255,r=255&a,u.push(e),64!==i&&(u.push(n),64!==o&&u.push(r))}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,n){switch(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;case"NEQ":return t!==e;case"R":return w(e).test(t);default:return!1}},w=function(t){var e=t.replace(/.*\/([gimuy]*)$/,"$1");e===t&&(e="");var n=e?t.replace(new RegExp("^/(.*?)/"+e+"$"),"$1"):t;return new RegExp(n,e)},m=function(){var t=new Date;return t.getDate()+"/"+t.getMonth()+"/"+t.getFullYear()},_=window.ApxorLogger,S=a((function e(){var n=this;i(this,e),s(this,"upBe","ALL"),s(this,"qHve",[]),s(this,"hfXD",[]),s(this,"parse",(function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};try{if(n.upBe=t.audience.audience_type,n.qHve=t.audience.attributes.user,n.hfXD=t.audience.attributes.session,!Array.isArray(n.qHve)||!Array.isArray(n.hfXD))return _.error("No attributes"),!1}catch(t){return _.error(t),!1}return!0})),s(this,"validate",(function(e,r){var i=!0;return"FTU"===n.upBe&&(i=t.getController().getSessionInfo().is_first_session),i&&n.AYgA(e,n.qHve)&&n.AYgA(r,n.hfXD)})),s(this,"AYgA",(function(t,e){var n=e.length,r=!0;try{for(var i,o=function(){var n=e[a];if(!t[n.name]||!1===r)return{v:!1};var i=n.operator,o=n.type,s=n.value.map((function(t){return"s"===o?t:"l"===o?parseInt(t):"f"===o?parseFloat(t):void 0})),u=(Array.isArray(t[n.name])?t[n.name]:[t[n.name]]).some((function(t){return s.some((function(e){return y(t,e,i)}))}));r=r&&u},a=0;a<n;a++)if(i=o())return i.v}catch(t){_.error(t),r=!1}return r}))})),A=window.ApxorLogger,b=a((function t(){var e=this;i(this,t),s(this,"cyan",0),s(this,"xUCG",0),s(this,"TTrx","SESSION"),s(this,"dBjB",0),s(this,"QeCL",0),s(this,"voNY",0),s(this,"parse",(function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};try{e.cyan=t.frequency.count,-1===e.cyan&&(e.cyan=1e3),e.voNY=e.cyan,e.xUCG=t.frequency.time_interval,e.TTrx=t.frequency.validity,e.QeCL=t.frequency.ses_lmt,e._dayCount=t.frequency.day_lmt;var n=Y.getInstance().getQeState();if(!h(n)||!h(n[t._id]))return!0;if("SESSION"===e.TTrx){if(e.cyan=parseInt(e.cyan)-parseInt(n[t._id].SESSION),e.cyan<=0)return console.warn("Max count limit reached for session:"+t._id),!1}else{if("OVERALL"!==e.TTrx)return A.info("Invalid config."),!1;if(e.cyan=parseInt(e.cyan)-parseInt(n[t._id].OVERALL),e.cyan<=0)return console.warn("Max count limit reached for overall:"+t._id),!1}}catch(t){return A.error(t),!1}return!0})),s(this,"yGJs",(function(){e.cyan=e.cyan-1})),s(this,"getFrequencyCount",(function(){return e.cyan})),s(this,"NSSU",(function(){"SESSION"===e.TTrx&&(e.cyan=e.voNY,A.info("Campaign Limit reset"))})),s(this,"HBeu",(function(t){try{if(e.cyan<=0)return!1;var n=Y.getInstance().getQeState();if(!h(n)||!h(n[t]))return!0;if(0!==e.QeCL)if(parseInt(e.QeCL)-parseInt(n[t].SESSION)<=0)return!1;if(0!==e._dayCount){var r,i=m();if(parseInt(e._dayCount)-parseInt((null===(r=n[t])||void 0===r?void 0:r.DATES[i])||0)<=0)return!1}}catch(t){A.error("Error validating the frequency:"+t)}return!0}))})),E=a((function t(){var e=this;i(this,t),s(this,"dXou",""),s(this,"upBe",""),s(this,"parse",(function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};try{var n;e.dXou=t.meta.name,e.upBe=t.meta.type,e._only_context=t.meta.only_context,e._attr=(null===(n=t.meta)||void 0===n?void 0:n.attr)||{}}catch(t){return window.ApxorLogger.error(t),!1}return!0}))})),H=window.ApxorLogger,L=a((function t(){var e=this;i(this,t),s(this,"ZXIv",-1),s(this,"PYEw",-1),s(this,"gDYY",-1),s(this,"JWWv",-1),s(this,"WVbP",!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 H.error("Not valid dates"),!1;if(e.ZXIv=Date.parse(t.validity.start_date),e.PYEw=Date.parse(t.validity.end_date),h(t.time_limits_in_day)&&(e.WVbP=t.time_limits_in_day,e.WVbP&&h(t.time_limits))){var n=(new Date).toISOString().split("T")[0];if(e.gDYY=Date.parse(n+"T"+t.time_limits.start_time+".000Z"),e.JWWv=Date.parse(n+"T"+t.time_limits.end_time+".000Z"),isNaN(e.gDYY)||isNaN(e.JWWv))return H.error("Not valid times"),!1}}catch(t){return H.error(t),!1}return!0})),s(this,"validate",(function(){var t=Date.now();return t>e.ZXIv&&t<e.PYEw&&(!e.WVbP||t>=e.gDYY&&t<=e.JWWv)}))})),F=a((function t(){var e=this;i(this,t),s(this,"dXou",""),s(this,"PjLw",{}),s(this,"parse",(function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};try{e.dXou=t.name,e.PjLw=t.additional_info}catch(t){return!1}return!0}))})),x=a((function t(){var e=this;i(this,t),s(this,"ubix",0),s(this,"xTww",0),s(this,"parse",(function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};try{if(e.ubix=Number(t.lower),e.xTww=Number(t.upper),isNaN(e.ubix)||isNaN(e.xTww))return!1}catch(t){return!1}return!0}))})),T=a((function t(){var e=this;i(this,t),s(this,"wLrd",0),s(this,"GwDz",""),s(this,"HJIQ",""),s(this,"LHnZ",new F),s(this,"pZbN",new x),s(this,"parse",(function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};try{return e.GwDz=t.event_type,e.HJIQ=t.activity,e.LHnZ.parse(t.details)&&e.pZbN.parse(t.time_bounds)}catch(t){return!1}}))})),D=window.ApxorLogger,Z=a((function t(){var e=this;i(this,t),s(this,"wLrd",0),s(this,"BvTW",-1),s(this,"cyan",0),s(this,"FdOF",""),s(this,"HJIQ",""),s(this,"GwDz",""),s(this,"pZbN",new x),s(this,"LHnZ",new F),s(this,"idDI",new T),s(this,"Sdoc","AND"),s(this,"LnGT",!1),s(this,"upBe",void 0),s(this,"parse",(function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};try{return e.BvTW=t.sequence,e.cyan=t.count_config.count,e.FdOF=t.count_config.operator,e.HJIQ=t.activity,e.GwDz=t.event_type,e.Sdoc=t.combine_operator,e.upBe=t.type,e.LHnZ.parse(t.details)&&e.idDI.parse(t.trigger)&&e.pZbN.parse(t.time_bounds)}catch(t){return D.error(t),!1}}))})),N=window.ApxorLogger,I=a((function t(){var e=this;i(this,t),s(this,"cyan",0),s(this,"FdOF",""),s(this,"GwDz",""),s(this,"pZbN",new x),s(this,"LHnZ",new F),s(this,"Sdoc","AND"),s(this,"parse",(function(t){try{return e.cyan=t.count_config.count,e.FdOF=t.count_config.operator,e.GwDz=t.event_type,e.Sdoc=t.combine_operator,e.LHnZ.parse(t.details)&&e.pZbN.parse(t.time_bounds)}catch(t){return N.error(t),!1}}))})),C=window.ApxorLogger,G=function(){function e(){var n=this;i(this,e),s(this,"AFha",0),s(this,"xWwF",""),s(this,"ZXgH",new Z),s(this,"AwpM",new I),s(this,"CTgi",!1),s(this,"dzHG",!1),s(this,"ewWl",0),s(this,"Sdoc","AND"),s(this,"gzxI","OR"),s(this,"Swao",-1),s(this,"SKdF",[]),s(this,"ATJy",{}),s(this,"qFlV",!1),s(this,"initialize",(function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},r=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(n.xWwF=r,n.ewWl=i,n.SKdF=a,"termination"===s&&""!==s){n.AwpM.parse(e);return n.gzxI=n.AwpM.Sdoc,n.cvYj(),!0}var u=n.ZXgH.parse(e);if(u){if(n.Sdoc=n.ZXgH.Sdoc,n.ZXgH.LnGT){var c=n.ZXgH.LHnZ.dXou;"APX_PAGE_OPENED"===c&&(c=n.ZXgH.LHnZ.PjLw.navigation_id,c=h(c)?c:n.ZXgH.LHnZ.dXou),n.Swao=t.getController().getEventCount(c);var l=n.ZXgH.cyan,f=n.ZXgH.FdOF;if(n.dzHG=n.TfGM(n.Swao-1,l,f,!1),n.CTgi=n.dzHG,n.dzHG&&"APX_PAGE_OPENED"===n.ZXgH.LHnZ.dXou)return!0}return o&&0!==i||n.DGaq(),!0}return!1})),s(this,"DGaq",(function(){var t=n.ZXgH,e=t.idDI,r=Y.getInstance();"app_start"===e.GwDz?(n.CTgi=!0,r.registerForEvent(g(t.GwDz)+"___"+t.LHnZ.dXou,n.ZNEJ)):r.registerForEvent(g(t.GwDz)+"___"+e.LHnZ.dXou,n.ZNEJ)})),s(this,"cvYj",(function(){var t=n.AwpM,e=Y.getInstance();n.CTgi=!0,e.registerForEvent(g(t.GwDz)+"___"+t.LHnZ.dXou,n.YBSM)})),s(this,"Ijls",(function(t,e,r,i){var o,a=(Date.now()-n.ATJy[e])/1e3;(null===(o=n.ZXgH)||void 0===o||null===(o=o.LHnZ)||void 0===o||null===(o=o.PjLw)||void 0===o?void 0:o.time)/1e3>a&&n._displayCampaign(r)})),s(this,"MKnM",(function(t,e,r,i){var o,a;n.qFlV=!0;var s=Date.now(),u=null===(o=n.ZXgH)||void 0===o||null===(o=o.idDI)||void 0===o?void 0:o.LHnZ.dXou,c=(s-n.ATJy[u])/1e3,l=null===(a=n.ZXgH)||void 0===a||null===(a=a.LHnZ)||void 0===a||null===(a=a.PjLw)||void 0===a?void 0:a.time;(l/=1e3)>c&&n._displayCampaign(r)})),s(this,"ZNEJ",(function(t,e,r,i){var o=Y.getInstance();if(n.CTgi)g(n.ZXgH.GwDz)===t&&n.gVIC(r-n.ZXgH.idDI.wLrd,n.ZXgH.pZbN)&&n.ZXgH.LHnZ.dXou===e&&n.XxaE(n.ZXgH.LHnZ.PjLw,i)&&(n.AFha+=1,n.dzHG=n.TfGM(n.AFha,n.ZXgH.cyan,n.ZXgH.FdOF),n.dzHG&&(n.ZXgH.wLrd=r,o.validate(n.xWwF,n.ewWl)));else if(n.CTgi=n.cAeN(t,e,r,i),n.CTgi){var a=n.ZXgH,s=a.idDI;if(s.wLrd=r,"activity_time"===(null==a?void 0:a.GwDz)){var u,c,l,h=null==a||null===(u=a.LHnZ)||void 0===u||null===(u=u.PjLw)||void 0===u?void 0:u.time;(null==a||null===(c=a.LHnZ)||void 0===c||null===(c=c.PjLw)||void 0===c?void 0:c.nkpi.length)>0&&(setTimeout((function(){n.qFlV||(n.dzHG=!0,n.dzHG&&(n.AFha+=1,n.dzHG=n.TfGM(n.AFha,n.ZXgH.cyan,n.ZXgH.FdOF),n.dzHG&&(n.ZXgH.wLrd=r,o.validate(n.xWwF,n.ewWl)))),a.LHnZ.PjLw.nkpi.map((function(t){o.unregisterFromEvent(p(a.LHnZ.PjLw.et)+"___"+t,n)}))}),h),a.LHnZ.PjLw.nkpi.map((function(t){o.registerForEvent(p(a.LHnZ.PjLw.et)+"___"+t,n.MKnM)}))),(null==a||null===(l=a.LHnZ)||void 0===l||null===(l=l.PjLw)||void 0===l?void 0:l.kpi.length)>0&&(setTimeout((function(){a.LHnZ.PjLw.kpi.map((function(t){o.unregisterFromEvent(p(a.LHnZ.PjLw.et)+"___"+t,n)}))}),h),a.LHnZ.PjLw.kpi.map((function(t){t===a.idDI.LHnZ.dXou?(o.unregisterFromEvent(g(s.GwDz)+"___"+s.LHnZ.dXou,n),o.registerForEvent(p(a.LHnZ.PjLw.et)+"___"+t,n.Ijls)):o.registerForEvent(p(a.LHnZ.PjLw.et)+"___"+t,n.MKnM)})))}else o.unregisterFromEvent(g(s.GwDz)+"___"+s.LHnZ.dXou,n),o.registerForEvent(g(a.GwDz)+"___"+a.LHnZ.dXou,n);n.ATJy[e]=Date.now()}})),s(this,"YBSM",(function(t,e,r,i){var o=Y.getInstance();g(n.AwpM.GwDz)===t&&n.gVIC(r,n.AwpM.pZbN)&&n.AwpM.LHnZ.dXou===e&&n.XxaE(n.AwpM.LHnZ.PjLw,i)&&(n.AFha+=1,n.dzHG=n.TfGM(n.AFha,n.AwpM.cyan,n.AwpM.FdOF),n.dzHG&&(n.AwpM.wLrd=r,o.validateForTermination(n.xWwF,n.ewWl)))})),s(this,"cAeN",(function(t,e,r,i){var o=n.ZXgH.idDI;return g(o.GwDz)===t&&o.LHnZ.dXou===e&&n.gVIC(r,o.pZbN)&&n.XxaE(o.LHnZ.PjLw,i)})),s(this,"gVIC",(function(t,e){var n=Math.ceil(t);return n>e.ubix&&n<e.xTww})),s(this,"TfGM",(function(t,e,r){var i=!(arguments.length>3&&void 0!==arguments[3])||arguments[3];switch(i&&n.ZXgH.LnGT&&(t+=n.Swao),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;default:return!1}})),s(this,"XxaE",(function(t,e){var n=!0;try{var i,o=function(){if(!e[a]||!1===n)return{v:!1};if("object"===r(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)}));n=n&&u}else n=n&&y(e[a],t[a],"EQ")};for(var a in t)if(i=o())return i.v}catch(t){C.error(t),n=!1}return n}))}return a(e,[{key:"_displayCampaign",value:function(t){var e=Y.getInstance();this.dzHG=!0,this.dzHG&&(this.AFha+=1,this.dzHG=this.TfGM(this.AFha,this.ZXgH.cyan,this.ZXgH.FdOF),this.dzHG&&(this.ZXgH.wLrd=t,e.validate(this.xWwF,this.ewWl)))}}]),e}(),q=window.ApxorLogger,X=a((function e(){var n=this;i(this,e),s(this,"PuiS",[]),s(this,"_ret_day",{}),s(this,"KMnE",{}),s(this,"TIdq",!1),s(this,"BItf",!1),s(this,"parse",(function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};try{n.PuiS=t.overall_cfg.events,n._ret_day=t.overall_cfg.ret_day,n.KMnE=t.overall_cfg.session,n.TIdq=t.overall_cfg.toggleRetDay,n.PuiS=t.overall_cfg.events,n.BItf=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")),r=parseInt(t.getController().getFromStorage("apx_retained_session"));if(n.TIdq&&!isNaN(e)&&!(e>=n._ret_day.from&&e<=n._ret_day.to))return!1;if(n.BItf&&!isNaN(r)&&!(r>=n.KMnE.from&&r<=n.KMnE.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),n=new Uint8Array(e),r=0;r<t.length;r++)n[r]=t.charCodeAt(r);return e}(v(o,i)))),s=0;s<n.PuiS.length;s++){if(a[n.PuiS[s].name.replace("'","").replace("’","")])return!1}}catch(t){q.error("Failed to validate the lt count:"+t)}return!0}))})),M=window.ApxorLogger,O=a((function t(){var e=this;i(this,t),s(this,"qHve",[]),s(this,"hfXD",[]),s(this,"parse",(function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};try{if(e.qHve=t.attributes.user,e.hfXD=t.attributes.session,!Array.isArray(e.qHve)||!Array.isArray(e.hfXD))return M.error("No attributes"),!1}catch(t){return M.error(t),!1}return!0})),s(this,"validate",(function(t,n){return e.AYgA(t,e.qHve)&&e.AYgA(n,e.hfXD)})),s(this,"AYgA",(function(t,e){var n=e.length,r=!0;try{for(var i,o=function(){var n=e[a];if(!t[n.name]||!1===r)return{v:!1};var i=n.operator,o=n.type,s=n.value.map((function(t){return"s"===o?t:"l"===o?parseInt(t):"f"===o?parseFloat(t):void 0})),u=(Array.isArray(t[n.name])?t[n.name]:[t[n.name]]).some((function(t){return s.some((function(e){return y(t,e,i)}))}));r=r&&u},a=0;a<n;a++)if(i=o())return i.v}catch(t){M.error(t),r=!1}return r}))})),j=a((function e(){var n=this;i(this,e),s(this,"mmqX",t.getController()),s(this,"type",""),s(this,"_duration_seconds",0),s(this,"ebrV",1),s(this,"parse",(function(t){try{var e,r,i;if(n.upBe=null===(e=t.terminate_info.time_based)||void 0===e?void 0:e.type,n._duration_seconds=null===(r=t.terminate_info)||void 0===r?void 0:r.time_based.duration_seconds,n.ebrV=null===(i=t.terminate_info.time_based)||void 0===i?void 0:i.days,n.zuMV(t._id))return n.mmqX.persistTerminationInfoLocally(t._id),!1}catch(t){return!1}return!0})),s(this,"zuMV",(function(t){var e,r=JSON.parse(n.mmqX.getFromStorage("apx_termination_ID"));if(!r[t]||null===(e=r[t])||void 0===e||!e.startDate)return!1;var i,o=new Date(r[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=r[t].gDYY;return s===n.ebrV&&u.hours>=c.hours||s>n.ebrV||r[t].goalAcheived}))})),P=a((function t(){var e=this;i(this,t),s(this,"enable_goal_events",!1),s(this,"attributes",{}),s(this,"KDkd",new O),s(this,"uNVj",new j),s(this,"parse",(function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};try{var n,r,i;if(e.enable_time_based=null==t||null===(n=t.terminate_info)||void 0===n?void 0:n.enable_time_based,e.enable_time_based&&!e.uNVj.parse(t))return!1;if(e.enable_goal_events=null==t||null===(r=t.terminate_info)||void 0===r?void 0:r.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.KDkd.parse(t.terminate_info))return!1}catch(t){return window.ApxorLogger.error(t),!1}return!0})),s(this,"validate",(function(t,n){return e.KDkd.validate(t,n)}))})),W=window.ApxorLogger,z=a((function e(){var r=this;i(this,e),s(this,"hmOw",[]),s(this,"mlaS",[]),s(this,"xWwF",""),s(this,"axSA",new E),s(this,"oypC",new S),s(this,"TTrx",new L),s(this,"ihSD",new b),s(this,"KUHf",new X),s(this,"qNqv",new P),s(this,"AKqc",!1),s(this,"NIKc",[]),s(this,"parse",(function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};try{if(!h(t._id))return W.error("No Id"),!1;if(!h(t.enabled)||!t.enabled)return W.error("Not enabled"),!1;if(!(r.axSA.parse(t)&&r.TTrx.parse(t)&&r.ihSD.parse(t)&&r.oypC.parse(t)&&r.KUHf.parse(t)&&r.qNqv.parse(t)))return!1;if(!h(t.conditions)||!Array.isArray(t.conditions))return W.error("No valid conditions",t.conditions),!1;r.xWwF=t._id,r.AKqc=!!h(t.sequence_enabled)&&t.sequence_enabled,r.AKqc&&t.conditions.sort((function(t,e){return t.sequence<e.sequence}));for(var e=t.conditions,n=e.length,i=0;i<n;i++){r.NIKc=[];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};r.NIKc=[].concat(u(r.NIKc),[s])}var c=new G;c.initialize(o,r.xWwF,i,r.AKqc,r.NIKc)&&r.hmOw.push(c)}if(r.qNqv.enable_goal_events)for(var l=t.terminate_info.goal_events.events,f=l.length,d=0;d<f;d++){var v=new G;v.initialize(l[d],r.xWwF,d,!0,[],"termination")&&r.mlaS.push(v)}return r.hmOw.length>0}catch(t){return W.error(t),!1}})),s(this,"SslG",(function(t){if(!(t<0))if(r.AKqc){var e=r.hmOw[t];if(h(e)&&e.dzHG){var n=r.hmOw[t-1];if(h(n)&&!n.dzHG)return;var i=r.hmOw[t+1];h(i)?i.DGaq():r.wUEZ()}}else r.wUEZ()})),s(this,"uDmd",(function(t){t<0||r.Fkcf()})),s(this,"wUEZ",(function(){var e=t.getController().getUserAttributes(),i=t.getController().getSessionAttributes();if(r.TTrx.validate()&&r.oypC.validate(e,i)&&r.KUHf.validate()){for(var o=r.hmOw.length,a=o<1,s="",u=0;u<o;u++){var c=r.hmOw[u],l=c.dzHG;if(""===s.trim())a=l;else switch(s){case"AND":a=a&&l;break;case"OR":a=a||l}s=c.Sdoc}if(a){if(console.debug("onCondition satisfied"),!r.ihSD.HBeu(r.xWwF))return void console.warn("Maximum limit reached",r.xWwF);console.log("Dispatching event",r.axSA.upBe),!0===r.axSA._only_context&&t.logEvent("apx_context_evaluated",n(n({},r.axSA._attr),{},{message_name:r.axSA.dXou,id:r.xWwF})),t.getController().dispatchEvent(r.axSA.upBe,{name:r.axSA.upBe,additional_info:{uuid:r.xWwF,name:r.axSA.dXou}})}}})),s(this,"Fkcf",(function(){for(var e=r.mlaS.length,i=e<1,o="",a=0;a<e;a++){var s=r.mlaS[a],u=s.dzHG;if(""===o.trim())i=u;else switch(o){case"AND":i=i&&u;break;case"OR":i=i||u}o=s.gzxI}i&&(console.log("Dispatching event",r.axSA.upBe),t.getController().persistTerminationInfoLocally(r.xWwF),!0===r.axSA._only_context&&t.logEvent("apx_context_evaluated",n(n({},r.axSA._attr),{},{message_name:r.axSA.dXou,id:r.xWwF})),t.getController().dispatchEvent(r.axSA.upBe,{name:r.axSA.upBe,additional_info:{uuid:r.xWwF,name:r.axSA.dXou}}))})),s(this,"validateForTerminationAttributes",(function(){var e=t.getController().getUserAttributes(),n=t.getController().getSessionAttributes();return r.qNqv.validate(e,n)})),s(this,"yGJs",(function(){r.ihSD.yGJs()})),s(this,"getFrequencyCount",(function(){return r.ihSD.getFrequencyCount()})),s(this,"vtVj",(function(){return r.ihSD.NSSU()}))})),R=a((function t(){var e=this;i(this,t),s(this,"aSMs",{}),s(this,"parse",(function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{configs:[]};if(h(t)&&h(t.configs)){var n=t.configs;if(!Array.isArray(n))return;n.sort((function(t,e){var n,r;return(null!==(n=t.prio)&&void 0!==n?n:-1)-(null!==(r=e.prio)&&void 0!==r?r:-1)}));for(var r=0;r<n.length;r++){var i=n[r],o=i._id,a=new z;a.parse(i)?e.aSMs[o]=a:console.warn("Failed to parse cfg",o)}}})),s(this,"validate",(function(t,n){e.aSMs[t]&&e.aSMs[t].SslG(n)})),s(this,"validateForTermination",(function(t,n){e.aSMs[t]&&e.aSMs[t].uDmd(n)})),s(this,"validateForTerminationAttributes",(function(t){return!!e.aSMs[t]&&e.aSMs[t].validateForTerminationAttributes()})),s(this,"yGJs",(function(t){e.aSMs[t].yGJs()})),s(this,"getFrequencyCount",(function(t){return e.aSMs[t].getFrequencyCount()})),s(this,"resetFrequencyCounts",(function(){var t=e.aSMs;for(var n in t)t[n].vtVj()})),s(this,"iSci",(function(t){try{if(e.aSMs){var n=e.aSMs[t];if(n&&n.axSA)return n.axSA}}catch(t){console.log("Error in getting the campaign meta ".concat(t))}return{}}))})),K=window.ApxorLogger,B=a((function e(){var n=this;i(this,e),s(this,"MqKW",{}),s(this,"PZUh",[]),s(this,"CrNj",!1),s(this,"initialize",(function(){var e=t.getController();e.registerForEvent("APP_EVENT",(function(t){return n.Snah(t,"AE")})),e.registerForEvent("CLIENT_EVENT",(function(t){return n.Snah(t,"CE")}))})),s(this,"hUlQ",(function(){for(var t in n.PZUh)n.lMiM(t.event,t.key,t.type);n.CrNj=!0})),s(this,"colh",(function(t,e){var r;"function"==typeof e&&((r=n.MqKW[t]?n.MqKW[t]:[]).push(e),n.MqKW[t]=r,K.debug("Listeners list: ",n.MqKW))})),s(this,"unregisterFromEvent",(function(t,e){if(n.MqKW[t]){for(var r=n.MqKW[t],i=[],o=0;o<r.length;o++){var a=r[o];a!==e&&i.push(a)}n.MqKW[t]=i}})),s(this,"Snah",(function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"AE",r=e+"___"+t.name;n.lMiM(t,r,e)})),s(this,"lMiM",(function(e,r,i){if(n.CrNj){if(K.debug("Notifying listeners for event: "+e+", "+r,n.MqKW),n.MqKW[r])for(var o=n.MqKW[r],a=t.getController().getSDKRunningTimeInSec(),s=0;s<o.length;s++){(0,o[s])(i,e.name,a,e.additional_info)}}else n.PZUh.push({event:e,key:r,type:i})}))})),V=window.ApxorLogger,Y=function(){function e(){var n=this;return i(this,e),s(this,"FyrB",!1),s(this,"EGlR",null),s(this,"Emjp",m()),s(this,"WpgE",new B),s(this,"kKtz",t.getSiteId()),s(this,"TsRo",{}),s(this,"getQeState",(function(){try{var e=t.getController().getFromStorage("qe_state");return e?JSON.parse(v(n.kKtz,e)):(n.TsRo={},n.setQeState())}catch(t){return n.TsRo={},n.setQeState()}})),s(this,"setQeState",(function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"";try{t.getController().persistToStorage("qe_state",n.TsRo,!0)}catch(r){""===e?n.TsRo={}:n.TsRo[e]={SESSION:0,OVERALL:0,DATES:{}},t.getController().persistToStorage("qe_state",n.TsRo,!0)}return n.TsRo})),s(this,"initialize",(function(){n.FyrB||(n.FyrB=!0,n.EGlR=new R,n.WpgE.initialize(),n.TsRo=n.getQeState(),V.info("QE Initialized.."))})),s(this,"parse",(function(t){n.lHre()?(n.EGlR.parse(t),n.WpgE.hUlQ()):V.warn("Must call init first. Unable to proceed")})),s(this,"validate",(function(t,e){n.lHre()&&n.EGlR.validate(t,e)})),s(this,"validateForTermination",(function(t,e){n.lHre()&&n.EGlR.validateForTermination(t,e)})),s(this,"validateForTerminationAttributes",(function(t,e){return n.EGlR.validateForTerminationAttributes(t,e)})),s(this,"updateCount",(function(t){try{h(n.TsRo[t])||n.createObjConfig(t),n.incrementFrequencies(t),n.setQeState(t),n.EGlR.yGJs(t)}catch(t){console.log("Could not update the count config:".concat(t))}})),s(this,"resetFrequencyCounts",(function(){n.EGlR.resetFrequencyCounts()})),s(this,"getFrequencyCount",(function(t){return n.EGlR.getFrequencyCount(t)})),s(this,"registerForEvent",(function(t,e){n.WpgE.colh(t,e)})),s(this,"unregisterFromEvent",(function(t,e){n.WpgE.unregisterFromEvent(t,e)})),s(this,"fetch",(function(e,n,r,i){t.getController().fetchConfiguration(e,n,r,i)})),s(this,"lHre",(function(){return n.FyrB})),s(this,"getCampaignMetaFromQueryEngine",(function(t){return n.EGlR.iSci(t)})),s(this,"rvWz",(function(){return n.Emjp})),e.instance||(e.instance=this),e.instance}return a(e,[{key:"createObjConfig",value:function(t){try{this.TsRo=this.getQeState(),h(this.TsRo[t])||(this.TsRo[t]={SESSION:0,OVERALL:0,DATES:{}},this.Emjp&&(this.TsRo[t].DATES[this.Emjp]=0),this.setQeState(t))}catch(t){V.error("Can not create the frequency count object:"+t)}}},{key:"incrementFrequencies",value:function(t){this.TsRo=this.getQeState();var e=this.TsRo[t];e.SESSION=e.SESSION+1,e.OVERALL=e.OVERALL+1;var n=m();n===this.Emjp&&e.DATES&&e.DATES[n]||(this.Emjp=n,e.DATES={},e.DATES[this.Emjp]=0),e.DATES[this.Emjp]=e.DATES[this.Emjp]+1}}],[{key:"getInstance",value:function(){return e.instance||(e.instance=new e),e.instance}}]),e}();s(Y,"instance",void 0),window.ceVersion=141;try{void 0===exports&&null===exports||(exports.default=Y,module.exports=exports.default)}catch(t){}return Y}));
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "apxor-qe",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.4.1",
|
|
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.1"
|
|
56
56
|
},
|
|
57
57
|
"files": [
|
|
58
58
|
"dist"
|