apxor-qe 1.1.9 → 1.1.10-qa.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/apxor.qe.js.bak +1403 -0
- package/dist/apxor.qe.min.js +1 -1
- package/package.json +24 -22
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,f(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=f(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 f(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 l=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,n){return String.fromCharCode(e^function(t,e){return t.charCodeAt(Math.floor(e%t.length))}(t,n))})).join("")}var d=function(t,e){return v(t,e=function(t){var e,n,r,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,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()},w=window.ApxorLogger,A=a((function e(){var n=this;i(this,e),s(this,"hZVd","ALL"),s(this,"NwYo",[]),s(this,"WANH",[]),s(this,"parse",(function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};try{if(n.hZVd=t.audience.audience_type,n.NwYo=t.audience.attributes.user,n.WANH=t.audience.attributes.session,!Array.isArray(n.NwYo)||!Array.isArray(n.WANH))return w.error("No attributes"),!1}catch(t){return w.error(t),!1}return!0})),s(this,"validate",(function(e,r){var i=!0;return"FTU"===n.hZVd&&(i=t.getController().getSessionInfo().is_first_session),i&&n.vLDo(e,n.NwYo)&&n.vLDo(r,n.WANH)})),s(this,"vLDo",(function(t,e){var n=e.length,i=!0;try{for(var o=function(){var n=e[a];if(!t.hasOwnProperty(n.name)||!1===i)return{v:!1};var r=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,r)}))}));i=i&&u},a=0;a<n;a++){var s=o();if("object"===r(s))return s.v}}catch(t){w.error(t),i=!1}return i}))})),S=window.ApxorLogger,E=a((function t(){var e=this;i(this,t),s(this,"jMGx",0),s(this,"EmCs",0),s(this,"pZAY","SESSION"),s(this,"kBVb",0),s(this,"xSej",0),s(this,"WIHE",0),s(this,"parse",(function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};try{e.jMGx=t.frequency.count,e.WIHE=e.jMGx,e.EmCs=t.frequency.time_interval,e.pZAY=t.frequency.validity,e.xSej=t.frequency.ses_lmt,e._dayCount=t.frequency.day_lmt;var n=k.getInstance().getQeState();if(!l(n)||!l(n[t._id]))return!0;if("SESSION"===e.pZAY){if(e.jMGx=parseInt(e.jMGx)-parseInt(n[t._id].SESSION),e.jMGx<=0)return console.warn("Max count limit reached for session:"+t._id),!1}else{if("OVERALL"!==e.pZAY)return S.info("Invalid config."),!1;if(e.jMGx=parseInt(e.jMGx)-parseInt(n[t._id].OVERALL),e.jMGx<=0)return console.warn("Max count limit reached for overall:"+t._id),!1}}catch(t){return S.error(t),!1}return!0})),s(this,"bJtE",(function(){e.jMGx=e.jMGx-1})),s(this,"getFrequencyCount",(function(){return e.jMGx})),s(this,"iveh",(function(){"SESSION"===e.pZAY&&(e.jMGx=e.WIHE,S.info("Campaign Limit reset"))})),s(this,"wsSG",(function(t){try{if(e.jMGx<=0)return!1;var n=k.getInstance().getQeState();if(!l(n)||!l(n[t]))return!0;if(0!==e.xSej)if(parseInt(e.xSej)-parseInt(n[t].SESSION)<=0)return!1;if(0!==e._dayCount){k.getInstance();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){S.error("Error validating the frequency:"+t)}return!0}))})),b=a((function t(){var e=this;i(this,t),s(this,"Tfwf",""),s(this,"hZVd",""),s(this,"parse",(function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};try{var n;e.Tfwf=t.meta.name,e.hZVd=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}))})),T=window.ApxorLogger,O=a((function t(){var e=this;i(this,t),s(this,"IwZA",-1),s(this,"QXrX",-1),s(this,"kIeZ",-1),s(this,"poEz",-1),s(this,"OhmR",!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 T.error("Not valid dates"),!1;if(e.IwZA=Date.parse(t.validity.start_date),e.QXrX=Date.parse(t.validity.end_date),l(t.time_limits_in_day)&&(e.OhmR=t.time_limits_in_day,e.OhmR&&l(t.time_limits))){var n=(new Date).toISOString().split("T")[0];if(e.kIeZ=Date.parse(n+"T"+t.time_limits.start_time+".000Z"),e.poEz=Date.parse(n+"T"+t.time_limits.end_time+".000Z"),isNaN(e.kIeZ)||isNaN(e.poEz))return T.error("Not valid times"),!1}}catch(t){return T.error(t),!1}return!0})),s(this,"validate",(function(){var t=Date.now();return t>e.IwZA&&t<e.QXrX&&(!e.OhmR||t>=e.kIeZ&&t<=e.poEz)}))})),x=a((function t(){var e=this;i(this,t),s(this,"Tfwf",""),s(this,"bOSB",{}),s(this,"parse",(function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};try{e.Tfwf=t.name,e.bOSB=t.additional_info}catch(t){return!1}return!0}))})),J=a((function t(){var e=this;i(this,t),s(this,"maAt",0),s(this,"qwNL",0),s(this,"parse",(function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};try{if(e.maAt=Number(t.lower),e.qwNL=Number(t.upper),isNaN(e.maAt)||isNaN(e.qwNL))return!1}catch(t){return!1}return!0}))})),C=a((function t(){var e=this;i(this,t),s(this,"cAUl",0),s(this,"RmsP",""),s(this,"YEsa",""),s(this,"AJee",new x),s(this,"bSDu",new J),s(this,"parse",(function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};try{return e.RmsP=t.event_type,e.YEsa=t.activity,e.AJee.parse(t.details)&&e.bSDu.parse(t.time_bounds)}catch(t){return!1}}))})),N=a((function t(){var e=this;i(this,t),s(this,"cAUl",0),s(this,"tUDN",-1),s(this,"jMGx",0),s(this,"vCWS",""),s(this,"YEsa",""),s(this,"RmsP",""),s(this,"bSDu",new J),s(this,"AJee",new x),s(this,"eaBz",new C),s(this,"nnXJ","AND"),s(this,"WUHY",!1),s(this,"hZVd",void 0),s(this,"parse",(function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};try{return e.tUDN=t.sequence,e.jMGx=t.count_config.count,e.vCWS=t.count_config.operator,e.YEsa=t.activity,e.RmsP=t.event_type,e.nnXJ=t.combine_operator,e.hZVd=t.type,e.AJee.parse(t.details)&&e.eaBz.parse(t.trigger)&&e.bSDu.parse(t.time_bounds)}catch(t){return Logger.error(t),!1}}))})),K=window.ApxorLogger,V=function(){function e(){var n=this;i(this,e),s(this,"dxyV",0),s(this,"ndKT",""),s(this,"qJKY",new N),s(this,"tnKD",!1),s(this,"Xiie",!1),s(this,"HNVO",0),s(this,"nnXJ","AND"),s(this,"xWUj",-1),s(this,"avJi",[]),s(this,"zLMp",{}),s(this,"psxE",!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.ndKT=r,n.HNVO=i,n.avJi=a;var s=n.qJKY.parse(e);if(s){if(n.nnXJ=n.qJKY.nnXJ,n.qJKY.WUHY){var u=n.qJKY.AJee.Tfwf;"APX_PAGE_OPENED"===u&&(u=n.qJKY.AJee.bOSB.navigation_id,u=isDefined(u)?u:n.qJKY.AJee.Tfwf),n.xWUj=t.getController().getEventCount(u);var c=n.qJKY.jMGx,f=n.qJKY.vCWS;if(n.Xiie=n.wwPf(n.xWUj-1,c,f,!1),n.tnKD=n.Xiie,n.Xiie&&"APX_PAGE_OPENED"===n.qJKY.AJee.Tfwf)return!0}return o&&0!==i||n.BEld(),!0}return!1})),s(this,"BEld",(function(){var t=n.qJKY,e=t.eaBz,r=k.getInstance();"app_start"===e.RmsP?(n.tnKD=!0,r.registerForEvent(p(t.RmsP)+"___"+t.AJee.Tfwf,n.BaBN)):r.registerForEvent(p(t.RmsP)+"___"+e.AJee.Tfwf,n.BaBN)})),s(this,"nJHR",(function(t,e,r,i){var o,a,s,u=(Date.now()-n.zLMp[e])/1e3;(null===(o=n.qJKY)||void 0===o||null===(a=o.AJee)||void 0===a||null===(s=a.bOSB)||void 0===s?void 0:s.time)/1e3>u&&n._displayCampaign(r)})),s(this,"QvGc",(function(t,e,r,i){var o,a,s,u,c;n.psxE=!0;var f=Date.now(),l=null===(o=n.qJKY)||void 0===o||null===(a=o.eaBz)||void 0===a?void 0:a.AJee.Tfwf,h=(f-n.zLMp[l])/1e3,v=null===(s=n.qJKY)||void 0===s||null===(u=s.AJee)||void 0===u||null===(c=u.bOSB)||void 0===c?void 0:c.time;(v/=1e3)>h&&n._displayCampaign(r)})),s(this,"BaBN",(function(t,e,r,i){var o=k.getInstance();if(n.tnKD)p(n.qJKY.RmsP)===t&&n.whNS(r-n.qJKY.eaBz.cAUl,n.qJKY.bSDu)&&n.qJKY.AJee.Tfwf===e&&n.RWrw(n.qJKY.AJee.bOSB,i)&&(n.dxyV+=1,n.Xiie=n.wwPf(n.dxyV,n.qJKY.jMGx,n.qJKY.vCWS),n.Xiie&&(n.qJKY.cAUl=r,o.validate(n.ndKT,n.HNVO)));else if(n.tnKD=n.nwui(t,e,r,i),n.tnKD){var a=n.qJKY,s=a.eaBz;if(s.cAUl=r,"activity_time"===(null==a?void 0:a.RmsP)){var u,c,f,l,h,v,d=null==a||null===(u=a.AJee)||void 0===u||null===(c=u.bOSB)||void 0===c?void 0:c.time;(null==a||null===(f=a.AJee)||void 0===f||null===(l=f.bOSB)||void 0===l?void 0:l.nkpi.length)>0&&(setTimeout((function(){n.psxE||(n.Xiie=!0,n.Xiie&&(n.dxyV+=1,n.Xiie=n.wwPf(n.dxyV,n.qJKY.jMGx,n.qJKY.vCWS),n.Xiie&&(n.qJKY.cAUl=r,o.validate(n.ndKT,n.HNVO)))),a.AJee.bOSB.nkpi.map((function(t){o.unregisterFromEvent(g(a.AJee.bOSB.et)+"___"+t,n)}))}),d),a.AJee.bOSB.nkpi.map((function(t){o.registerForEvent(g(a.AJee.bOSB.et)+"___"+t,n.QvGc)}))),(null==a||null===(h=a.AJee)||void 0===h||null===(v=h.bOSB)||void 0===v?void 0:v.kpi.length)>0&&(setTimeout((function(){a.AJee.bOSB.kpi.map((function(t){o.unregisterFromEvent(g(a.AJee.bOSB.et)+"___"+t,n)}))}),d),a.AJee.bOSB.kpi.map((function(t){t===a.eaBz.AJee.Tfwf?(o.unregisterFromEvent(p(s.RmsP)+"___"+s.AJee.Tfwf,n),o.registerForEvent(g(a.AJee.bOSB.et)+"___"+t,n.nJHR)):o.registerForEvent(g(a.AJee.bOSB.et)+"___"+t,n.QvGc)})))}else o.unregisterFromEvent(p(s.RmsP)+"___"+s.AJee.Tfwf,n),o.registerForEvent(p(a.RmsP)+"___"+a.AJee.Tfwf,n);n.zLMp[e]=Date.now()}})),s(this,"nwui",(function(t,e,r,i){var o=n.qJKY.eaBz;return p(o.RmsP)===t&&o.AJee.Tfwf===e&&n.whNS(r,o.bSDu)&&n.RWrw(o.AJee.bOSB,i)})),s(this,"whNS",(function(t,e){var n=Math.ceil(t);return n>e.maAt&&n<e.qwNL})),s(this,"wwPf",(function(t,e,r){var i=!(arguments.length>3&&void 0!==arguments[3])||arguments[3];switch(i&&n.qJKY.WUHY&&(t+=n.xWUj),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,"RWrw",(function(t,e){var n=!0;try{var i=function(){if(!e.hasOwnProperty(o)||!1===n)return{v:!1};if("object"===r(t[o])){var i,a=t[o].op,s=t[o].t;"s"===s?i=t[o].val:"l"!==s&&"f"!==s||(i=parseFloat(t[o].val));var u=(Array.isArray(e[o])?e[o]:[e[o]]).some((function(t){return y(t,i,a)}));n=n&&u}else n=n&&y(e[o],t[o],"EQ")};for(var o in t){var a=i();if("object"===r(a))return a.v}}catch(t){K.error(t),n=!1}return n}))}return a(e,[{key:"_displayCampaign",value:function(t){var e=k.getInstance();this.Xiie=!0,this.Xiie&&(this.dxyV+=1,this.Xiie=this.wwPf(this.dxyV,this.qJKY.jMGx,this.qJKY.vCWS),this.Xiie&&(this.qJKY.cAUl=t,e.validate(this.ndKT,this.HNVO)))}}]),e}(),q=a((function e(){var n=this;i(this,e),s(this,"yrvT",[]),s(this,"_ret_day",{}),s(this,"ymnG",{}),s(this,"dmOu",!1),s(this,"emaU",!1),s(this,"parse",(function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};try{n.yrvT=t.overall_cfg.events,n._ret_day=t.overall_cfg.ret_day,n.ymnG=t.overall_cfg.session,n.dmOu=t.overall_cfg.toggleRetDay,n.yrvT=t.overall_cfg.events,n.emaU=t.overall_cfg.toggleSession}catch(t){return Logger.error(error),!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.dmOu&&!isNaN(e)&&!(e>=n._ret_day.from&&e<=n._ret_day.to))return!1;if(n.emaU&&!isNaN(r)&&!(r>=n.ymnG.from&&r<=n.ymnG.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<n.yrvT.length;s++){var u=n.yrvT[s].name.replace("'","").replace("’","");if(a.hasOwnProperty(u))return!1}}catch(t){Logger.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,"Vnmy",[]),s(this,"ndKT",""),s(this,"Tkjt",new b),s(this,"IEYo",new A),s(this,"pZAY",new O),s(this,"VDyr",new E),s(this,"FNxX",new q),s(this,"Clcn",!1),s(this,"Tqvz",[]),s(this,"parse",(function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};try{if(!l(t._id))return j.error("No Id"),!1;if(!l(t.enabled)||!t.enabled)return j.error("Not enabled"),!1;if(!(r.Tkjt.parse(t)&&r.pZAY.parse(t)&&r.VDyr.parse(t)&&r.IEYo.parse(t)&&r.FNxX.parse(t)))return!1;if(!l(t.conditions)||!Array.isArray(t.conditions))return j.error("No valid conditions",t.conditions),!1;r.ndKT=t._id,r.Clcn=!!l(t.sequence_enabled)&&t.sequence_enabled,r.Clcn&&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.Tqvz=[];var o=e[i];if("didn't"===o.type){var a,s,c={trigger_key:o.trigger.details.name,no_kpi_array:null==o||null===(a=o.details)||void 0===a||null===(s=a.additional_info)||void 0===s?void 0:s.nkpi,condition_id:null==o?void 0:o._id,time_bounds:o.time_bounds.upper};r.Tqvz=[].concat(u(r.Tqvz),[c])}var f=new V;f.initialize(o,r.ndKT,i,r.Clcn,r.Tqvz)&&r.Vnmy.push(f)}return r.Vnmy.length>0}catch(t){return j.error(t),!1}})),s(this,"ptSS",(function(t){if(!(t<0))if(r.Clcn){var e=r.Vnmy[t];if(l(e)&&e.Xiie){var n=r.Vnmy[t-1];if(l(n)&&!n.Xiie)return;var i=r.Vnmy[t+1];l(i)?i.BEld():r.axfo()}}else r.axfo()})),s(this,"axfo",(function(){var e=t.getController().getUserAttributes(),i=t.getController().getSessionAttributes();if(r.pZAY.validate()&&r.IEYo.validate(e,i)&&r.FNxX.validate()){for(var o=r.Vnmy.length,a=o<1,s="",u=0;u<o;u++){var c=r.Vnmy[u],f=c.Xiie;if(""===s.trim())a=f;else switch(s){case"AND":a=a&&f;break;case"OR":a=a||f}s=c.nnXJ}if(a){if(console.debug("onCondition satisfied"),!r.VDyr.wsSG(r.ndKT))return void console.warn("Maximum limit reached",r.ndKT);console.log("Dispatching event",r.Tkjt.hZVd),!0===r.Tkjt._only_context&&t.logEvent("apx_context_evaluated",n(n({},r.Tkjt._attr),{},{message_name:r.Tkjt.Tfwf,id:r.ndKT})),t.getController().dispatchEvent(r.Tkjt.hZVd,{name:r.Tkjt.hZVd,additional_info:{uuid:r.ndKT,name:r.Tkjt.Tfwf}})}}})),s(this,"bJtE",(function(){r.VDyr.bJtE()})),s(this,"getFrequencyCount",(function(){return r.VDyr.getFrequencyCount()})),s(this,"jowC",(function(){return r.VDyr.iveh()}))})),Y=a((function t(){var e=this;i(this,t),s(this,"KDPC",{}),s(this,"parse",(function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{configs:[]};if(l(t)&&l(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.KDPC[o]=a:console.warn("Failed to parse cfg",o)}}})),s(this,"validate",(function(t,n){e.KDPC.hasOwnProperty(t)&&e.KDPC[t].ptSS(n)})),s(this,"bJtE",(function(t){e.KDPC[t].bJtE()})),s(this,"getFrequencyCount",(function(t){return e.KDPC[t].getFrequencyCount()})),s(this,"resetFrequencyCounts",(function(){var t=e.KDPC;for(var n in t)t[n].jowC()})),s(this,"yPNW",(function(t){try{if(e.KDPC){var n=e.KDPC[t];if(n&&n.Tkjt)return n.Tkjt}}catch(t){console.log("Error in getting the campaign meta ".concat(t))}return{}}))})),P=window.ApxorLogger,I=a((function e(){var n=this;i(this,e),s(this,"VcMZ",{}),s(this,"AhKq",[]),s(this,"duCY",!1),s(this,"initialize",(function(){var e=t.getController();e.registerForEvent("APP_EVENT",(function(t){return n.MVgw(t,"AE")})),e.registerForEvent("CLIENT_EVENT",(function(t){return n.MVgw(t,"CE")}))})),s(this,"ynvg",(function(){for(var t in n.AhKq)n.THEX(t.event,t.key,t.type);n.duCY=!0})),s(this,"RWgZ",(function(t,e){var r;"function"==typeof e&&((r=n.VcMZ[t]?n.VcMZ[t]:[]).push(e),n.VcMZ[t]=r,P.debug("Listeners list: ",n.VcMZ))})),s(this,"unregisterFromEvent",(function(t,e){if(n.VcMZ[t]){for(var r=n.VcMZ[t],i=[],o=0;o<r.length;o++){var a=r[o];a!==e&&i.push(a)}n.VcMZ[t]=i}})),s(this,"MVgw",(function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"AE",r=e+"___"+t.name;n.THEX(t,r,e)})),s(this,"THEX",(function(e,r,i){if(n.duCY){if(P.debug("Notifying listeners for event: "+e+", "+r,n.VcMZ),n.VcMZ[r])for(var o=n.VcMZ[r],a=t.getController().getSDKRunningTimeInSec(),s=0;s<o.length;s++){(0,o[s])(i,e.name,a,e.additional_info)}}else n.AhKq.push({event:e,key:r,type:i})}))})),L=window.ApxorLogger,k=function(){function e(){var n=this;return i(this,e),s(this,"nCwg",!1),s(this,"GHQm",null),s(this,"ZVKL",_()),s(this,"uVHY",new I),s(this,"udPv",t.getSiteId()),s(this,"kpzH",{}),s(this,"getQeState",(function(){try{var e=t.getController().getFromStorage("qe_state");return e?JSON.parse(d(n.udPv,e)):(n.kpzH={},n.setQeState())}catch(t){return n.kpzH={},n.setQeState()}})),s(this,"setQeState",(function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"";try{t.getController().persistToStorage("qe_state",n.kpzH,!0)}catch(r){""===e?n.kpzH={}:n.kpzH[e]={SESSION:0,OVERALL:0,DATES:{}},t.getController().persistToStorage("qe_state",n.kpzH,!0)}return n.kpzH})),s(this,"initialize",(function(){n.nCwg||(n.nCwg=!0,n.GHQm=new Y,n.uVHY.initialize(),n.kpzH=n.getQeState(),L.info("QE Initialized.."))})),s(this,"parse",(function(t){n.KpTd()?(n.GHQm.parse(t),n.uVHY.ynvg()):L.warn("Must call init first. Unable to proceed")})),s(this,"validate",(function(t,e){n.KpTd()&&n.GHQm.validate(t,e)})),s(this,"updateCount",(function(t){try{l(n.kpzH[t])||n.createObjConfig(t),n.incrementFrequencies(t),n.setQeState(t),n.GHQm.bJtE(t)}catch(t){console.log("Could not update the count config:".concat(t))}})),s(this,"resetFrequencyCounts",(function(){n.GHQm.resetFrequencyCounts()})),s(this,"getFrequencyCount",(function(t){return n.GHQm.getFrequencyCount(t)})),s(this,"registerForEvent",(function(t,e){n.uVHY.RWgZ(t,e)})),s(this,"unregisterFromEvent",(function(t,e){n.uVHY.unregisterFromEvent(t,e)})),s(this,"fetch",(function(e,n,r,i){t.getController().fetchConfiguration(e,n,r,i)})),s(this,"KpTd",(function(){return n.nCwg})),s(this,"getCampaignMetaFromQueryEngine",(function(t){return n.GHQm.yPNW(t)})),s(this,"Gxix",(function(){return n.ZVKL})),e.instance||(e.instance=this),e.instance}return a(e,[{key:"createObjConfig",value:function(t){try{this.kpzH=this.getQeState(),l(this.kpzH[t])||(this.kpzH[t]={SESSION:0,OVERALL:0,DATES:{}},this.ZVKL&&(this.kpzH[t].DATES[this.ZVKL]=0),this.setQeState(t))}catch(t){L.error("Can not create the frequency count object:"+t)}}},{key:"incrementFrequencies",value:function(t){this.kpzH=this.getQeState();var e=this.kpzH[t];e.SESSION=e.SESSION+1,e.OVERALL=e.OVERALL+1;var n=_();n===this.ZVKL&&e.DATES&&e.DATES[n]||(this.ZVKL=n,e.DATES={},e.DATES[this.ZVKL]=0),e.DATES[this.ZVKL]=e.DATES[this.ZVKL]+1}}],[{key:"getInstance",value:function(){return e.instance||(e.instance=new e),e.instance}}]),e}();s(k,"instance",void 0),window.ceVersion=119;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&&t.hasOwnProperty("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 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=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))},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"},y=function(t){return t.toUpperCase()},p=function(t,e,r){switch(r){case"EQ":return t===e;case"GT":return t>e;case"GTE":return t>=e;case"LT":return t<e;case"LTE":return t<=e;case"NEQ":return t!==e;case"R":return m(e).test(t);default:return!1}},m=function(t){var e=t.replace(/.*\/([gimuy]*)$/,"$1");e===t&&(e="");var r=e?t.replace(new RegExp("^/(.*?)/"+e+"$"),"$1"):t;return new RegExp(r,e)},_=function(){var t=new Date;return t.getDate()+"/"+t.getMonth()+"/"+t.getFullYear()},b=window.ApxorLogger,D=a(function e(){var r=this;i(this,e),s(this,"jyXB","ALL"),s(this,"lZth",[]),s(this,"iosT",[]),s(this,"parse",function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};try{if(r.jyXB=t.audience.audience_type,r.lZth=t.audience.attributes.user,r.iosT=t.audience.attributes.session,!Array.isArray(r.lZth)||!Array.isArray(r.iosT))return b.error("No attributes"),!1}catch(t){return b.error(t),!1}return!0}),s(this,"validate",function(e,n){var i=!0;return"FTU"===r.jyXB&&(i=t.getController().getSessionInfo().is_first_session),i&&r.OYnt(e,r.lZth)&&r.OYnt(n,r.iosT)}),s(this,"OYnt",function(t,e){var r=e.length,i=!0;try{for(var o=function(){var r=e[a];if(!t[r.name]||!1===i)return{v:!1};var n=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 p(t,e,n)})});i=i&&u},a=0;a<r;a++){var s=o();if("object"===n(s))return s.v}}catch(t){b.error(t),i=!1}return i})}),S=window.ApxorLogger,E=a(function t(){var e=this;i(this,t),s(this,"KkoD",0),s(this,"mBSu",0),s(this,"hDCI","SESSION"),s(this,"moQB",0),s(this,"PQZP",0),s(this,"xmdK",0),s(this,"parse",function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};try{e.KkoD=t.frequency.count,e.xmdK=e.KkoD,e.mBSu=t.frequency.time_interval,e.hDCI=t.frequency.validity,e.PQZP=t.frequency.ses_lmt,e._dayCount=t.frequency.day_lmt;var r=Z.getInstance().getQeState();if(!h(r)||!h(r[t._id]))return!0;if("SESSION"===e.hDCI){if(e.KkoD=parseInt(e.KkoD)-parseInt(r[t._id].SESSION),e.KkoD<=0)return console.warn("Max count limit reached for session:"+t._id),!1}else{if("OVERALL"!==e.hDCI)return S.info("Invalid config."),!1;if(e.KkoD=parseInt(e.KkoD)-parseInt(r[t._id].OVERALL),e.KkoD<=0)return console.warn("Max count limit reached for overall:"+t._id),!1}}catch(t){return S.error(t),!1}return!0}),s(this,"lSfk",function(){e.KkoD=e.KkoD-1}),s(this,"getFrequencyCount",function(){return e.KkoD}),s(this,"REfq",function(){"SESSION"===e.hDCI&&(e.KkoD=e.xmdK,S.info("Campaign Limit reset"))}),s(this,"JglD",function(t){try{if(e.KkoD<=0)return!1;var r=Z.getInstance().getQeState();if(!h(r)||!h(r[t]))return!0;if(0!==e.PQZP)if(parseInt(e.PQZP)-parseInt(r[t].SESSION)<=0)return!1;if(0!==e._dayCount){var n,i=_();if(parseInt(e._dayCount)-parseInt((null===(n=r[t])||void 0===n?void 0:n.DATES[i])||0)<=0)return!1}}catch(t){S.error("Error validating the frequency:"+t)}return!0})}),w=a(function t(){var e=this;i(this,t),s(this,"yaFV",""),s(this,"jyXB",""),s(this,"parse",function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};try{var r;e.yaFV=t.meta.name,e.jyXB=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})}),N=window.ApxorLogger,L=a(function t(){var e=this;i(this,t),s(this,"LKPg",-1),s(this,"rbaj",-1),s(this,"aRKQ",-1),s(this,"kDES",-1),s(this,"EGEc",!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 N.error("Not valid dates"),!1;if(e.LKPg=Date.parse(t.validity.start_date),e.rbaj=Date.parse(t.validity.end_date),h(t.time_limits_in_day)&&(e.EGEc=t.time_limits_in_day,e.EGEc&&h(t.time_limits))){var r=(new Date).toISOString().split("T")[0];if(e.aRKQ=Date.parse(r+"T"+t.time_limits.start_time+".000Z"),e.kDES=Date.parse(r+"T"+t.time_limits.end_time+".000Z"),isNaN(e.aRKQ)||isNaN(e.kDES))return N.error("Not valid times"),!1}}catch(t){return N.error(t),!1}return!0}),s(this,"validate",function(){var t=Date.now();return t>e.LKPg&&t<e.rbaj&&(!e.EGEc||t>=e.aRKQ&&t<=e.kDES)})}),A=a(function t(){var e=this;i(this,t),s(this,"yaFV",""),s(this,"GizD",{}),s(this,"parse",function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};try{e.yaFV=t.name,e.GizD=t.additional_info}catch(t){return!1}return!0})}),k=a(function t(){var e=this;i(this,t),s(this,"rrCh",0),s(this,"gDCR",0),s(this,"parse",function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};try{if(e.rrCh=Number(t.lower),e.gDCR=Number(t.upper),isNaN(e.rrCh)||isNaN(e.gDCR))return!1}catch(t){return!1}return!0})}),O=a(function t(){var e=this;i(this,t),s(this,"kVxJ",0),s(this,"cWDi",""),s(this,"uiSd",""),s(this,"ebLm",new A),s(this,"aAiV",new k),s(this,"parse",function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};try{return e.cWDi=t.event_type,e.uiSd=t.activity,e.ebLm.parse(t.details)&&e.aAiV.parse(t.time_bounds)}catch(t){return!1}})}),x=window.ApxorLogger,C=a(function t(){var e=this;i(this,t),s(this,"kVxJ",0),s(this,"svLj",-1),s(this,"KkoD",0),s(this,"ZVZY",""),s(this,"uiSd",""),s(this,"cWDi",""),s(this,"aAiV",new k),s(this,"ebLm",new A),s(this,"MgEa",new O),s(this,"bRor","AND"),s(this,"EpOC",!1),s(this,"jyXB",void 0),s(this,"parse",function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};try{return e.svLj=t.sequence,e.KkoD=t.count_config.count,e.ZVZY=t.count_config.operator,e.uiSd=t.activity,e.cWDi=t.event_type,e.bRor=t.combine_operator,e.jyXB=t.type,e.ebLm.parse(t.details)&&e.MgEa.parse(t.trigger)&&e.aAiV.parse(t.time_bounds)}catch(t){return x.error(t),!1}})}),q=window.ApxorLogger,M=function(){function e(){var r=this;i(this,e),s(this,"yqph",0),s(this,"zNLA",""),s(this,"wMtN",new C),s(this,"NKqT",!1),s(this,"mJlk",!1),s(this,"RfKK",0),s(this,"bRor","AND"),s(this,"GQSy",-1),s(this,"gIUZ",[]),s(this,"aOME",{}),s(this,"iqOO",!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]:[];if(r.zNLA=n,r.RfKK=i,r.gIUZ=a,r.wMtN.parse(e)){if(r.bRor=r.wMtN.bRor,r.wMtN.EpOC){var s=r.wMtN.ebLm.yaFV;"APX_PAGE_OPENED"===s&&(s=r.wMtN.ebLm.GizD.navigation_id,s=h(s)?s:r.wMtN.ebLm.yaFV),r.GQSy=t.getController().getEventCount(s);var u=r.wMtN.KkoD,c=r.wMtN.ZVZY;if(r.mJlk=r.pqqV(r.GQSy-1,u,c,!1),r.NKqT=r.mJlk,r.mJlk&&"APX_PAGE_OPENED"===r.wMtN.ebLm.yaFV)return!0}return o&&0!==i||r.gINm(),!0}return!1}),s(this,"gINm",function(){var t=r.wMtN,e=t.MgEa,n=Z.getInstance();"app_start"===e.cWDi?(r.NKqT=!0,n.registerForEvent(g(t.cWDi)+"___"+t.ebLm.yaFV,r.SnBK)):n.registerForEvent(g(t.cWDi)+"___"+e.ebLm.yaFV,r.SnBK)}),s(this,"gjCB",function(t,e,n,i){var o,a,s,u=(Date.now()-r.aOME[e])/1e3;(null===(o=r.wMtN)||void 0===o?void 0:null===(a=o.ebLm)||void 0===a?void 0:null===(s=a.GizD)||void 0===s?void 0:s.time)/1e3>u&&r._displayCampaign(n)}),s(this,"MhsE",function(t,e,n,i){var o,a,s,u,c;r.iqOO=!0;var l=Date.now(),h=null===(o=r.wMtN)||void 0===o?void 0:null===(a=o.MgEa)||void 0===a?void 0:a.ebLm.yaFV,f=(l-r.aOME[h])/1e3,v=null===(s=r.wMtN)||void 0===s?void 0:null===(u=s.ebLm)||void 0===u?void 0:null===(c=u.GizD)||void 0===c?void 0:c.time;(v/=1e3)>f&&r._displayCampaign(n)}),s(this,"SnBK",function(t,e,n,i){var o=Z.getInstance();if(r.NKqT)g(r.wMtN.cWDi)===t&&r.dLxA(n-r.wMtN.MgEa.kVxJ,r.wMtN.aAiV)&&r.wMtN.ebLm.yaFV===e&&r.eFNk(r.wMtN.ebLm.GizD,i)&&(r.yqph+=1,r.mJlk=r.pqqV(r.yqph,r.wMtN.KkoD,r.wMtN.ZVZY),r.mJlk&&(r.wMtN.kVxJ=n,o.validate(r.zNLA,r.RfKK)));else if(r.NKqT=r.mTyq(t,e,n,i),r.NKqT){var a=r.wMtN,s=a.MgEa;if(s.kVxJ=n,"activity_time"===(null==a?void 0:a.cWDi)){var u,c,l,h,f,v,d=null==a?void 0:null===(u=a.ebLm)||void 0===u?void 0:null===(c=u.GizD)||void 0===c?void 0:c.time;(null==a?void 0:null===(l=a.ebLm)||void 0===l?void 0:null===(h=l.GizD)||void 0===h?void 0:h.nkpi.length)>0&&(setTimeout(function(){r.iqOO||(r.mJlk=!0,r.mJlk&&(r.yqph+=1,r.mJlk=r.pqqV(r.yqph,r.wMtN.KkoD,r.wMtN.ZVZY),r.mJlk&&(r.wMtN.kVxJ=n,o.validate(r.zNLA,r.RfKK)))),a.ebLm.GizD.nkpi.map(function(t){o.unregisterFromEvent(y(a.ebLm.GizD.et)+"___"+t,r)})},d),a.ebLm.GizD.nkpi.map(function(t){o.registerForEvent(y(a.ebLm.GizD.et)+"___"+t,r.MhsE)})),(null==a?void 0:null===(f=a.ebLm)||void 0===f?void 0:null===(v=f.GizD)||void 0===v?void 0:v.kpi.length)>0&&(setTimeout(function(){a.ebLm.GizD.kpi.map(function(t){o.unregisterFromEvent(y(a.ebLm.GizD.et)+"___"+t,r)})},d),a.ebLm.GizD.kpi.map(function(t){t===a.MgEa.ebLm.yaFV?(o.unregisterFromEvent(g(s.cWDi)+"___"+s.ebLm.yaFV,r),o.registerForEvent(y(a.ebLm.GizD.et)+"___"+t,r.gjCB)):o.registerForEvent(y(a.ebLm.GizD.et)+"___"+t,r.MhsE)}))}else o.unregisterFromEvent(g(s.cWDi)+"___"+s.ebLm.yaFV,r),o.registerForEvent(g(a.cWDi)+"___"+a.ebLm.yaFV,r);r.aOME[e]=Date.now()}}),s(this,"mTyq",function(t,e,n,i){var o=r.wMtN.MgEa;return g(o.cWDi)===t&&o.ebLm.yaFV===e&&r.dLxA(n,o.aAiV)&&r.eFNk(o.ebLm.GizD,i)}),s(this,"dLxA",function(t,e){var r=Math.ceil(t);return r>e.rrCh&&r<e.gDCR}),s(this,"pqqV",function(t,e,n){switch((!(arguments.length>3&&void 0!==arguments[3])||arguments[3])&&r.wMtN.EpOC&&(t+=r.GQSy),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,"eFNk",function(t,e){var r=!0;try{var i=function(){if(!e[o]||!1===r)return{v:!1};if("object"===n(t[o])){var i,a=t[o].op,s=t[o].t;"s"===s?i=t[o].val:"l"!==s&&"f"!==s||(i=parseFloat(t[o].val));var u=(Array.isArray(e[o])?e[o]:[e[o]]).some(function(t){return p(t,i,a)});r=r&&u}else r=r&&p(e[o],t[o],"EQ")};for(var o in t){var a=i();if("object"===n(a))return a.v}}catch(t){q.error(t),r=!1}return r})}return a(e,[{key:"_displayCampaign",value:function(t){var e=Z.getInstance();this.mJlk=!0,this.mJlk&&(this.yqph+=1,this.mJlk=this.pqqV(this.yqph,this.wMtN.KkoD,this.wMtN.ZVZY),this.mJlk&&(this.wMtN.kVxJ=t,e.validate(this.zNLA,this.RfKK)))}}]),e}(),F="qe_state",I=window.ApxorLogger,z=a(function e(){var r=this;i(this,e),s(this,"JHaZ",[]),s(this,"_ret_day",{}),s(this,"Gbfo",{}),s(this,"sYjx",!1),s(this,"JxBs",!1),s(this,"parse",function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};try{r.JHaZ=t.overall_cfg.events,r._ret_day=t.overall_cfg.ret_day,r.Gbfo=t.overall_cfg.session,r.sYjx=t.overall_cfg.toggleRetDay,r.JHaZ=t.overall_cfg.events,r.JxBs=t.overall_cfg.toggleSession}catch(t){return I.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.sYjx&&!isNaN(e)&&!(e>=r._ret_day.from&&e<=r._ret_day.to))return!1;if(r.JxBs&&!isNaN(n)&&!(n>=r.Gbfo.from&&n<=r.Gbfo.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.JHaZ.length;s++){if(a[r.JHaZ[s].name.replace("'","").replace("’","")])return!1}}catch(t){I.error("Failed to validate the lt count:"+t)}return!0})}),J=window.ApxorLogger,V=a(function e(){var n=this;i(this,e),s(this,"IuXx",[]),s(this,"zNLA",""),s(this,"SOrm",new w),s(this,"aTkp",new D),s(this,"hDCI",new L),s(this,"UnuD",new E),s(this,"IEfn",new z),s(this,"PiMM",!1),s(this,"JyrV",[]),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(!(n.SOrm.parse(t)&&n.hDCI.parse(t)&&n.UnuD.parse(t)&&n.aTkp.parse(t)&&n.IEfn.parse(t)))return!1;if(!h(t.conditions)||!Array.isArray(t.conditions))return J.error("No valid conditions",t.conditions),!1;n.zNLA=t._id,n.PiMM=!!h(t.sequence_enabled)&&t.sequence_enabled,n.PiMM&&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.JyrV=[];var o=e[i];if("didn't"===o.type){var a,s,c={trigger_key:o.trigger.details.name,no_kpi_array:null==o?void 0:null===(a=o.details)||void 0===a?void 0:null===(s=a.additional_info)||void 0===s?void 0:s.nkpi,condition_id:null==o?void 0:o._id,time_bounds:o.time_bounds.upper};n.JyrV=[].concat(u(n.JyrV),[c])}var l=new M;l.initialize(o,n.zNLA,i,n.PiMM,n.JyrV)&&n.IuXx.push(l)}return n.IuXx.length>0}catch(t){return J.error(t),!1}}),s(this,"PffH",function(t){if(!(t<0))if(n.PiMM){var e=n.IuXx[t];if(h(e)&&e.mJlk){var r=n.IuXx[t-1];if(h(r)&&!r.mJlk)return;var i=n.IuXx[t+1];h(i)?i.gINm():n.nhnX()}}else n.nhnX()}),s(this,"nhnX",function(){var e=t.getController().getUserAttributes(),i=t.getController().getSessionAttributes();if(n.hDCI.validate()&&n.aTkp.validate(e,i)&&n.IEfn.validate()){for(var o=n.IuXx.length,a=o<1,s="",u=0;u<o;u++){var c=n.IuXx[u],l=c.mJlk;if(""===s.trim())a=l;else switch(s){case"AND":a=a&&l;break;case"OR":a=a||l}s=c.bRor}if(a){if(console.debug("onCondition satisfied"),!n.UnuD.JglD(n.zNLA))return void console.warn("Maximum limit reached",n.zNLA);console.log("Dispatching event",n.SOrm.jyXB),!0===n.SOrm._only_context&&t.logEvent("apx_context_evaluated",r(r({},n.SOrm._attr),{},{message_name:n.SOrm.yaFV,id:n.zNLA})),t.getController().dispatchEvent(n.SOrm.jyXB,{name:n.SOrm.jyXB,additional_info:{uuid:n.zNLA,name:n.SOrm.yaFV}})}}}),s(this,"lSfk",function(){n.UnuD.lSfk()}),s(this,"getFrequencyCount",function(){return n.UnuD.getFrequencyCount()}),s(this,"cajt",function(){return n.UnuD.REfq()})}),j=a(function t(){var e=this;i(this,t),s(this,"ZhRR",{}),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 V;a.parse(i)?e.ZhRR[o]=a:console.warn("Failed to parse cfg",o)}}}),s(this,"validate",function(t,r){e.ZhRR[t]&&e.ZhRR[t].PffH(r)}),s(this,"lSfk",function(t){e.ZhRR[t].lSfk()}),s(this,"getFrequencyCount",function(t){return e.ZhRR[t].getFrequencyCount()}),s(this,"resetFrequencyCounts",function(){var t=e.ZhRR;for(var r in t)t[r].cajt()}),s(this,"Suhh",function(t){try{if(e.ZhRR){var r=e.ZhRR[t];if(r&&r.SOrm)return r.SOrm}}catch(t){console.log("Error in getting the campaign meta ".concat(t))}return{}})}),K=window.ApxorLogger,T=a(function e(){var r=this;i(this,e),s(this,"ihqx",{}),s(this,"sXGF",[]),s(this,"mBTm",!1),s(this,"initialize",function(){var e=t.getController();e.registerForEvent("APP_EVENT",function(t){return r.DHyY(t,"AE")}),e.registerForEvent("CLIENT_EVENT",function(t){return r.DHyY(t,"CE")})}),s(this,"sQAT",function(){for(var t in r.sXGF)r.QsuK(t.event,t.key,t.type);r.mBTm=!0}),s(this,"GvAJ",function(t,e){var n;"function"==typeof e&&((n=r.ihqx[t]?r.ihqx[t]:[]).push(e),r.ihqx[t]=n,K.debug("Listeners list: ",r.ihqx))}),s(this,"unregisterFromEvent",function(t,e){if(r.ihqx[t]){for(var n=r.ihqx[t],i=[],o=0;o<n.length;o++){var a=n[o];a!==e&&i.push(a)}r.ihqx[t]=i}}),s(this,"DHyY",function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"AE",n=e+"___"+t.name;r.QsuK(t,n,e)}),s(this,"QsuK",function(e,n,i){if(r.mBTm){if(K.debug("Notifying listeners for event: "+e+", "+n,r.ihqx),r.ihqx[n])for(var o=r.ihqx[n],a=t.getController().getSDKRunningTimeInSec(),s=0;s<o.length;s++){(0,o[s])(i,e.name,a,e.additional_info)}}else r.sXGF.push({event:e,key:n,type:i})})}),R=window.ApxorLogger,Z=function(){function e(){var r=this;return i(this,e),s(this,"ansf",!1),s(this,"wpgz",null),s(this,"ngyZ",_()),s(this,"dymD",new T),s(this,"Hdaj",t.getSiteId()),s(this,"JLze",{}),s(this,"getQeState",function(){try{var e=t.getController().getFromStorage(F);return e?JSON.parse(d(r.Hdaj,e)):(r.JLze={},r.setQeState())}catch(t){return r.JLze={},r.setQeState()}}),s(this,"setQeState",function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"";try{t.getController().persistToStorage(F,r.JLze,!0)}catch(n){""===e?r.JLze={}:r.JLze[e]={SESSION:0,OVERALL:0,DATES:{}},t.getController().persistToStorage(F,r.JLze,!0)}return r.JLze}),s(this,"initialize",function(){r.ansf||(r.ansf=!0,r.wpgz=new j,r.dymD.initialize(),r.JLze=r.getQeState(),R.info("QE Initialized.."))}),s(this,"parse",function(t){r.iQUj()?(r.wpgz.parse(t),r.dymD.sQAT()):R.warn("Must call init first. Unable to proceed")}),s(this,"validate",function(t,e){r.iQUj()&&r.wpgz.validate(t,e)}),s(this,"updateCount",function(t){try{h(r.JLze[t])||r.createObjConfig(t),r.incrementFrequencies(t),r.setQeState(t),r.wpgz.lSfk(t)}catch(t){console.log("Could not update the count config:".concat(t))}}),s(this,"resetFrequencyCounts",function(){r.wpgz.resetFrequencyCounts()}),s(this,"getFrequencyCount",function(t){return r.wpgz.getFrequencyCount(t)}),s(this,"registerForEvent",function(t,e){r.dymD.GvAJ(t,e)}),s(this,"unregisterFromEvent",function(t,e){r.dymD.unregisterFromEvent(t,e)}),s(this,"fetch",function(e,r,n,i){t.getController().fetchConfiguration(e,r,n,i)}),s(this,"iQUj",function(){return r.ansf}),s(this,"getCampaignMetaFromQueryEngine",function(t){return r.wpgz.Suhh(t)}),s(this,"ngye",function(){return r.ngyZ}),e.instance||(e.instance=this),e.instance}return a(e,[{key:"createObjConfig",value:function(t){try{this.JLze=this.getQeState(),h(this.JLze[t])||(this.JLze[t]={SESSION:0,OVERALL:0,DATES:{}},this.ngyZ&&(this.JLze[t].DATES[this.ngyZ]=0),this.setQeState(t))}catch(t){R.error("Can not create the frequency count object:"+t)}}},{key:"incrementFrequencies",value:function(t){this.JLze=this.getQeState();var e=this.JLze[t];e.SESSION=e.SESSION+1,e.OVERALL=e.OVERALL+1;var r=_();r===this.ngyZ&&e.DATES&&e.DATES[r]||(this.ngyZ=r,e.DATES={},e.DATES[this.ngyZ]=0),e.DATES[this.ngyZ]=e.DATES[this.ngyZ]+1}}],[{key:"getInstance",value:function(){return e.instance||(e.instance=new e),e.instance}}]),e}();s(Z,"instance",void 0),window.ceVersion=119;try{void 0===exports&&null===exports||(exports.default=Z,module.exports=exports.default)}catch(t){}return Z});
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "apxor-qe",
|
|
3
|
-
"version": "1.1.
|
|
3
|
+
"version": "1.1.10-qa.0",
|
|
4
4
|
"author": "Uma Sankar Yedida <umasankar.yedida@apxor.com> (https://www.apxor.com)",
|
|
5
5
|
"contributors": [
|
|
6
6
|
{
|
|
@@ -28,46 +28,48 @@
|
|
|
28
28
|
},
|
|
29
29
|
"main": "dist/apxor.qe.min.js",
|
|
30
30
|
"types": "dist/apxor.qe.d.ts",
|
|
31
|
-
"scripts": {
|
|
32
|
-
"start": "npm run dev && node conf/file-watcher.js",
|
|
33
|
-
"clean": "rm -rf dist/",
|
|
34
|
-
"rollup": "rollup --config conf/rollup.config.js --environment INCLUDE_DEPS,BUILD:production",
|
|
35
|
-
"minify": "node conf/minify.sdk.js dist/apxor.qe.js && minify dist/apxor.qe.js > dist/apxor.qe.min.js && rm dist/apxor.qe.js dist/apxor.qe.js.bak",
|
|
36
|
-
"build": "npm run clean && npm run rollup && npm run minify && cp ./src/apxor.qe.d.ts dist/apxor.qe.d.ts",
|
|
37
|
-
"dev": "npm run clean && npm run rollup && cp ./src/apxor.qe.d.ts dist/apxor.qe.d.ts && mv dist/apxor.qe.js dist/apxor.qe.min.js",
|
|
38
|
-
"prepublish": "check-node-version --npm \">=4\" || npm run prepare",
|
|
39
|
-
"prepare": "npm run build",
|
|
40
|
-
"lint": "eslint ./src/**.js",
|
|
41
|
-
"coverage": "jest --coverage --config=conf/jest.config.js",
|
|
42
|
-
"test": "jest --config=conf/jest.config.js --verbose --env=node",
|
|
43
|
-
"test:watch": "jest --watch",
|
|
44
|
-
"cypress": "./node_modules/.bin/cypress open"
|
|
45
|
-
},
|
|
46
31
|
"devDependencies": {
|
|
47
32
|
"@babel/core": "^7.20.7",
|
|
48
33
|
"@babel/eslint-parser": "^7.19.1",
|
|
49
34
|
"@babel/plugin-proposal-class-properties": "^7.18.6",
|
|
50
35
|
"@babel/plugin-proposal-object-rest-spread": "^7.20.7",
|
|
51
36
|
"@babel/preset-env": "^7.20.2",
|
|
37
|
+
"@vitest/coverage-v8": "^0.32.2",
|
|
52
38
|
"babel-eslint": "^10.1.0",
|
|
53
39
|
"babel-loader": "^9.1.0",
|
|
54
|
-
"check-node-version": "^3.2.0",
|
|
55
40
|
"chokidar": "^3.5.2",
|
|
56
|
-
"
|
|
57
|
-
"
|
|
41
|
+
"eslint-config-prettier": "^8.8.0",
|
|
42
|
+
"eslint-plugin-prettier": "^4.2.1",
|
|
58
43
|
"minify": "^4.1.1",
|
|
59
44
|
"rollup": "^1.13.1",
|
|
60
45
|
"rollup-plugin-babel": "^4.3.2",
|
|
61
46
|
"rollup-plugin-commonjs": "^10.0.0",
|
|
62
47
|
"rollup-plugin-json": "^4.0.0",
|
|
63
48
|
"rollup-plugin-node-resolve": "^5.0.1",
|
|
64
|
-
"rollup-plugin-replace": "^2.2.0"
|
|
49
|
+
"rollup-plugin-replace": "^2.2.0",
|
|
50
|
+
"vite": "^4.3.9",
|
|
51
|
+
"vitest": "^0.32.2"
|
|
65
52
|
},
|
|
66
53
|
"dependencies": {
|
|
67
|
-
"
|
|
54
|
+
"jsdom": "^22.1.0",
|
|
55
|
+
"apxor": "1.9.1-qa.0"
|
|
68
56
|
},
|
|
69
57
|
"files": [
|
|
70
58
|
"dist"
|
|
71
59
|
],
|
|
72
|
-
"unpkg": "dist/apxor.qe.min.js"
|
|
60
|
+
"unpkg": "dist/apxor.qe.min.js",
|
|
61
|
+
"scripts": {
|
|
62
|
+
"start": "npm run dev && node conf/file-watcher.js",
|
|
63
|
+
"clean": "rm -rf dist/",
|
|
64
|
+
"rollup": "rollup --config conf/rollup.config.js --environment INCLUDE_DEPS,BUILD:production",
|
|
65
|
+
"minify": "node conf/minify.sdk.js dist/apxor.qe.js && minify dist/apxor.qe.js > dist/apxor.qe.min.js && rm dist/apxor.qe.js ",
|
|
66
|
+
"prebuild": "npm run clean",
|
|
67
|
+
"build": "npm run rollup && npm run minify",
|
|
68
|
+
"postbuild": "cp ./src/apxor.qe.d.ts dist/apxor.qe.d.ts",
|
|
69
|
+
"dev": "npm run clean && npm run rollup && cp ./src/apxor.qe.d.ts dist/apxor.qe.d.ts && mv dist/apxor.qe.js dist/apxor.qe.min.js",
|
|
70
|
+
"lint": "eslint ./src/**.js",
|
|
71
|
+
"lint:fix": "eslint ./src/**.js --fix",
|
|
72
|
+
"coverage": "vitest run --coverage",
|
|
73
|
+
"test:ui": "vitest --ui --api 1337 --config ./conf/vite.config.js"
|
|
74
|
+
}
|
|
73
75
|
}
|