apxor-qe 1.1.5 → 1.1.6
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.min.js +1 -1
- package/package.json +9 -11
package/dist/apxor.qe.min.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?module.exports=e(require("apxor")):"function"==typeof define&&define.amd?define(["apxor"],e):(t=t||self)["apxor-qe"]=e(t.Apxor)}(this,(function(t){"use strict";function e(t,e){var r=Object.keys(t);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(t);e&&(n=n.filter((function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable}))),r.push.apply(r,n)}return r}function r(t){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 n(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}function i(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,n.key,n)}}function o(t,e,r){return e&&i(t.prototype,e),r&&i(t,r),Object.defineProperty(t,"prototype",{writable:!1}),t}function a(t,e,r){return e in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}function s(t){return function(t){if(Array.isArray(t))return u(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 u(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 u(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 u(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}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)},c="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=";function f(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 h=function(t,e){return f(t,e=function(t){var e,r,n,i,o,a,s=0,u=[];if(!t)return t;t+="";do{e=(a=c.indexOf(t.charAt(s++))<<18|c.indexOf(t.charAt(s++))<<12|(i=c.indexOf(t.charAt(s++)))<<6|(o=c.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))},v=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()},g=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 d(e).test(t);default:return!1}},d=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)},m=window.ApxorLogger,y=o((function e(){var i=this;n(this,e),a(this,"zyiF","ALL"),a(this,"FnRm",[]),a(this,"aBuG",[]),a(this,"parse",(function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};try{if(i.zyiF=t.audience.audience_type,i.FnRm=t.audience.attributes.user,i.aBuG=t.audience.attributes.session,!Array.isArray(i.FnRm)||!Array.isArray(i.aBuG))return m.error("No attributes"),!1}catch(t){return m.error(t),!1}return!0})),a(this,"validate",(function(e,r){var n=!0;return"FTU"===i.zyiF&&(n=t.getController().getSessionInfo().is_first_session),n&&i.zkXQ(e,i.FnRm)&&i.zkXQ(r,i.aBuG)})),a(this,"zkXQ",(function(t,e){var n=e.length,i=!0;try{for(var o=function(r){var n=e[r];if(!t.hasOwnProperty(n.name)||!1===i)return{v:!1};var o=n.op,a=n.t,s=n.val.map((function(t){return"s"===a?t:"l"===a||"f"===a?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 g(t,e,o)}))}));i=i&&u},a=0;a<n;a++){var s=o(a);if("object"===r(s))return s.v}}catch(t){m.error(t),i=!1}return i}))})),_=window.ApxorLogger,F=o((function e(){var r=this;n(this,e),a(this,"lBBV",0),a(this,"TutW",0),a(this,"OVbF","SESSION"),a(this,"AaSg",0),a(this,"UfmS",0),a(this,"JDli",0),a(this,"parse",(function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};try{r.lBBV=e.frequency.count,r.JDli=r.lBBV,r.TutW=e.frequency.time_interval,r.OVbF=e.frequency.validity,r.UfmS=e.frequency.ses_lmt,r._dayCount=e.frequency.day_lmt;var n=t.getController().getFromStorage("qe_state"),i=JSON.parse(h(t.getSiteId(),n));if(!l(i)||!l(i[e._id]))return!0;if("SESSION"===r.OVbF){if(r.lBBV=parseInt(r.lBBV)-parseInt(i[e._id].SESSION),r.lBBV<=0)return console.warn("Max count limit reached for session:"+e._id),!1}else if("OVERALL"===r.OVbF){if(r.lBBV=parseInt(r.lBBV)-parseInt(i[e._id].OVERALL),r.lBBV<=0)return console.warn("Max count limit reached for overall:"+e._id),!1}else if(i[e._id].DATES.value>r._dayCount)return console.warn("Max count limit reached for day:"+e._id),!1}catch(t){return _.error(t),!1}return!0})),a(this,"EaIa",(function(){"SESSION"===r.OVbF&&(r.lBBV=r.JDli,_.info("Campaign Limit reset"))}))})),N=o((function t(){var e=this;n(this,t),a(this,"jFKM",""),a(this,"zyiF",""),a(this,"parse",(function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};try{var r;e.jFKM=t.meta.name,e.zyiF=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}))})),I=window.ApxorLogger,b=o((function t(){var e=this;n(this,t),a(this,"poYB",-1),a(this,"XpLr",-1),a(this,"iZdu",-1),a(this,"RwKh",-1),a(this,"eOkm",!1),a(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 I.error("Not valid dates"),!1;if(e.poYB=Date.parse(t.validity.start_date),e.XpLr=Date.parse(t.validity.end_date),l(t.time_limits_in_day)&&(e.eOkm=t.time_limits_in_day,e.eOkm&&l(t.time_limits))){var r=(new Date).toISOString().split("T")[0];if(e.iZdu=Date.parse(r+"T"+t.time_limits.start_time+".000Z"),e.RwKh=Date.parse(r+"T"+t.time_limits.end_time+".000Z"),isNaN(e.iZdu)||isNaN(e.RwKh))return I.error("Not valid times"),!1}}catch(t){return I.error(t),!1}return!0})),a(this,"validate",(function(){var t=Date.now();return t>e.poYB&&t<e.XpLr&&(!e.eOkm||t>=e.iZdu&&t<=e.RwKh)}))})),w=o((function t(){var e=this;n(this,t),a(this,"jFKM",""),a(this,"ygmD",{}),a(this,"parse",(function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};try{e.jFKM=t.name,e.ygmD=t.additional_info}catch(t){return!1}return!0}))})),E=o((function t(){var e=this;n(this,t),a(this,"IilF",0),a(this,"XVqI",0),a(this,"parse",(function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};try{if(e.IilF=Number(t.lower),e.XVqI=Number(t.upper),isNaN(e.IilF)||isNaN(e.XVqI))return!1}catch(t){return!1}return!0}))})),O=o((function t(){var e=this;n(this,t),a(this,"LqMZ",0),a(this,"aIno",""),a(this,"leHd",""),a(this,"fvgp",new w),a(this,"qxxp",new E),a(this,"parse",(function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};try{return e.aIno=t.event_type,e.leHd=t.activity,e.fvgp.parse(t.details)&&e.qxxp.parse(t.time_bounds)}catch(t){return!1}}))})),S=o((function t(){var e=this;n(this,t),a(this,"LqMZ",0),a(this,"YQLI",-1),a(this,"lBBV",0),a(this,"eCNp",""),a(this,"leHd",""),a(this,"aIno",""),a(this,"qxxp",new E),a(this,"fvgp",new w),a(this,"INCc",new O),a(this,"uUpE","AND"),a(this,"NkuQ",!1),a(this,"zyiF",void 0),a(this,"parse",(function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};try{return e.YQLI=t.sequence,e.lBBV=t.count_config.count,e.eCNp=t.count_config.operator,e.leHd=t.activity,e.aIno=t.event_type,e.uUpE=t.combine_operator,e.zyiF=t.type,e.fvgp.parse(t.details)&&e.INCc.parse(t.trigger)&&e.qxxp.parse(t.time_bounds)}catch(t){return Logger.error(t),!1}}))})),V=window.ApxorLogger,A=function(){function e(){var i=this;n(this,e),a(this,"VLIL",0),a(this,"bHFJ",""),a(this,"YNmI",new S),a(this,"dIJA",!1),a(this,"aFHm",!1),a(this,"DqVo",0),a(this,"uUpE","AND"),a(this,"YxYn",-1),a(this,"wHUk",[]),a(this,"hpQv",{}),a(this,"tAmt",!1),a(this,"initialize",(function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"",n=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]:[];i.bHFJ=r,i.DqVo=n,i.wHUk=a;var s=i.YNmI.parse(e);if(s){if(i.uUpE=i.YNmI.uUpE,i.YNmI.NkuQ){var u=i.YNmI.fvgp.jFKM;"APX_PAGE_OPENED"===u&&(u=i.YNmI.fvgp.ygmD.navigation_id,u=isDefined(u)?u:i.YNmI.fvgp.jFKM),i.YxYn=t.getController().getEventCount(u);var l=i.YNmI.lBBV,c=i.YNmI.eCNp;if(i.aFHm=i.zSse(i.YxYn-1,l,c,!1),i.dIJA=i.aFHm,i.aFHm&&"APX_PAGE_OPENED"===i.YNmI.fvgp.jFKM)return!0}return o&&0!==n||i.IqHl(),!0}return!1})),a(this,"IqHl",(function(){var t=i.YNmI,e=t.INCc,r=B.getInstance();"app_start"===e.aIno?(i.dIJA=!0,r.registerForEvent(v(t.aIno)+"___"+t.fvgp.jFKM,i.AmVD)):r.registerForEvent(v(t.aIno)+"___"+e.fvgp.jFKM,i.AmVD)})),a(this,"wUEU",(function(t,e,r,n){var o,a,s,u=(Date.now()-i.hpQv[e])/1e3;(null===(o=i.YNmI)||void 0===o||null===(a=o.fvgp)||void 0===a||null===(s=a.ygmD)||void 0===s?void 0:s.time)/1e3>u&&i._displayCampaign()})),a(this,"zoNM",(function(t,e,r,n){var o,a,s,u,l;i.tAmt=!0;var c=Date.now(),f=null===(o=i.YNmI)||void 0===o||null===(a=o.INCc)||void 0===a?void 0:a.fvgp.jFKM,h=(c-i.hpQv[f])/1e3,v=null===(s=i.YNmI)||void 0===s||null===(u=s.fvgp)||void 0===u||null===(l=u.ygmD)||void 0===l?void 0:l.time;(v/=1e3)>h&&i._displayCampaign()})),a(this,"AmVD",(function(t,e,r,n){var o=B.getInstance();if(i.dIJA)v(i.YNmI.aIno)===t&&i.AhiN(r-i.YNmI.INCc.LqMZ,i.YNmI.qxxp)&&i.YNmI.fvgp.jFKM===e&&i.igrJ(i.YNmI.fvgp.ygmD,n)&&(i.VLIL+=1,i.aFHm=i.zSse(i.VLIL,i.YNmI.lBBV,i.YNmI.eCNp),i.aFHm&&(i.YNmI.LqMZ=r,o.validate(i.bHFJ,i.DqVo)));else if(i.dIJA=i.ddqY(t,e,r,n),i.dIJA){var a=i.YNmI,s=a.INCc;if(s.LqMZ=r,"activity_time"===(null==a?void 0:a.aIno)){var u,l,c,f,h,g,d=null==a||null===(u=a.fvgp)||void 0===u||null===(l=u.ygmD)||void 0===l?void 0:l.time;(null==a||null===(c=a.fvgp)||void 0===c||null===(f=c.ygmD)||void 0===f?void 0:f.nkpi.length)>0&&(setTimeout((function(){i.tAmt||(i.aFHm=!0,i.aFHm&&(i.VLIL+=1,i.aFHm=i.zSse(i.VLIL,i.YNmI.lBBV,i.YNmI.eCNp),i.aFHm&&(i.YNmI.LqMZ=r,o.validate(i.bHFJ,i.DqVo)))),a.fvgp.ygmD.nkpi.map((function(t){o.unregisterFromEvent(p(a.fvgp.ygmD.et)+"___"+t,i)}))}),d),a.fvgp.ygmD.nkpi.map((function(t){o.registerForEvent(p(a.fvgp.ygmD.et)+"___"+t,i.zoNM)}))),(null==a||null===(h=a.fvgp)||void 0===h||null===(g=h.ygmD)||void 0===g?void 0:g.kpi.length)>0&&(setTimeout((function(){a.fvgp.ygmD.kpi.map((function(t){o.unregisterFromEvent(p(a.fvgp.ygmD.et)+"___"+t,i)}))}),d),a.fvgp.ygmD.kpi.map((function(t){t===a.INCc.fvgp.jFKM?(o.unregisterFromEvent(v(s.aIno)+"___"+s.fvgp.jFKM,i),o.registerForEvent(p(a.fvgp.ygmD.et)+"___"+t,i.wUEU)):o.registerForEvent(p(a.fvgp.ygmD.et)+"___"+t,i.zoNM)})))}else o.unregisterFromEvent(v(s.aIno)+"___"+s.fvgp.jFKM,i),o.registerForEvent(v(a.aIno)+"___"+a.fvgp.jFKM,i);i.hpQv[e]=Date.now()}})),a(this,"ddqY",(function(t,e,r,n){var o=i.YNmI.INCc;return v(o.aIno)===t&&o.fvgp.jFKM===e&&i.AhiN(r,o.qxxp)&&i.igrJ(o.fvgp.ygmD,n)})),a(this,"AhiN",(function(t,e){var r=Math.round(1e3*t);return r>e.IilF&&r<e.XVqI})),a(this,"zSse",(function(t,e,r){var n=!(arguments.length>3&&void 0!==arguments[3])||arguments[3];switch(n&&i.YNmI.NkuQ&&(t+=i.YxYn),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}})),a(this,"igrJ",(function(t,e){var n=!0;try{for(var i in t){if(!e.hasOwnProperty(i)||!1===n)return!1;"object"===r(t[i])?function(){var r=t[i].op,o=t[i].t,a=void 0;"s"===o?a=t[i].val:"l"!==o&&"f"!==o||(a=parseFloat(t[i].val));var s=(Array.isArray(e[i])?e[i]:[e[i]]).some((function(t){return g(t,a,r)}));n=n&&s}():n=n&&g(e[i],t[i],"EQ")}}catch(t){V.error(t),n=!1}return n}))}return o(e,[{key:"_displayCampaign",value:function(){var t=B.getInstance();this.aFHm=!0,this.aFHm&&(this.VLIL+=1,this.aFHm=this.zSse(this.VLIL,this.YNmI.lBBV,this.YNmI.eCNp),this.aFHm&&(this.YNmI.LqMZ=time,t.validate(this.bHFJ,this.DqVo)))}}]),e}(),L=o((function e(){var r=this;n(this,e),a(this,"tNhV",[]),a(this,"_ret_day",{}),a(this,"jiZJ",{}),a(this,"iKHT",!1),a(this,"rWCG",!1),a(this,"parse",(function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};try{r.tNhV=t.overall_cfg.events,r._ret_day=t.overall_cfg.ret_day,r.jiZJ=t.overall_cfg.session,r.iKHT=t.overall_cfg.toggleRetDay,r.tNhV=t.overall_cfg.events,r.rWCG=t.overall_cfg.toggleSession}catch(t){return Logger.error(error),!1}return!0})),a(this,"validate",(function(){var e=parseInt(t.getController().getFromStorage("apx_retained_days")),n=parseInt(t.getController().getFromStorage("apx_retained_session"));if(r.iKHT&&!isNaN(e)&&!(e>=r._ret_day.from&&e<=r._ret_day.to))return!1;if(r.rWCG&&!isNaN(n)&&!(n>=r.jiZJ.from&&n<=r.jiZJ.to))return!1;for(var i=t.getController().getFromStorage("_apx_lt_count"),o=t.getSiteId(),a=h(o,i),s=0;s<r.tNhV.length;s++){var u=r.tNhV[s].name.replace("'","").replace("’","");if(!a.hasOwnProperty(u))return!1}return!0}))})),j=window.ApxorLogger,C=o((function r(){var i=this;n(this,r),a(this,"Njvx",[]),a(this,"bHFJ",""),a(this,"FVZZ",new N),a(this,"orxV",new y),a(this,"OVbF",new b),a(this,"KwMi",new F),a(this,"YJyO",new L),a(this,"tnbK",!1),a(this,"ISbM",[]),a(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(!(i.FVZZ.parse(t)&&i.OVbF.parse(t)&&i.KwMi.parse(t)&&i.orxV.parse(t)&&i.YJyO.parse(t)))return!1;if(!l(t.conditions)||!Array.isArray(t.conditions))return j.error("No valid conditions",t.conditions),!1;i.bHFJ=t._id,i.tnbK=!!l(t.sequence_enabled)&&t.sequence_enabled,i.tnbK&&t.conditions.sort((function(t,e){return t.sequence<e.sequence}));for(var e=t.conditions,r=e.length,n=0;n<r;n++){i.ISbM=[];var o=e[n];if("didn't"===o.type){var a,u,c={trigger_key:o.trigger.details.name,no_kpi_array:null==o||null===(a=o.details)||void 0===a||null===(u=a.additional_info)||void 0===u?void 0:u.nkpi,condition_id:null==o?void 0:o._id,time_bounds:o.time_bounds.upper};i.ISbM=[].concat(s(i.ISbM),[c])}var f=new A;f.initialize(o,i.bHFJ,n,i.tnbK,i.ISbM)&&i.Njvx.push(f)}return i.Njvx.length>0}catch(t){return j.error(t),!1}})),a(this,"YAEQ",(function(t){if(!(t<0))if(i.tnbK){var e=i.Njvx[t];if(l(e)&&e.aFHm){var r=i.Njvx[t-1];if(l(r)&&!r.aFHm)return;var n=i.Njvx[t+1];l(n)?n.IqHl():i.UFFs()}}else i.UFFs()})),a(this,"UFFs",(function(){var r=t.getController().getUserAttributes(),n=t.getController().getSessionAttributes();if(i.OVbF.validate()&&i.orxV.validate(r,n)&&i.YJyO.validate()){for(var o=i.Njvx.length,s=o<1,u="",l=0;l<o;l++){var c=i.Njvx[l],f=c.aFHm;if(""===u.trim())s=f;else switch(u){case"AND":s=s&&f;break;case"OR":s=s||f}u=c.uUpE}if(s){if(console.debug("onCondition satisfied"),i.KwMi.lBBV<=0)return void console.warn("Maximum limit reached",i.bHFJ);console.log("Dispatching event",i.FVZZ.zyiF),!0===i.FVZZ._only_context&&t.logEvent("apx_context_evaluated",function(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){a(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}({},i.FVZZ._attr)),t.getController().dispatchEvent(i.FVZZ.zyiF,{name:i.FVZZ.zyiF,additional_info:{uuid:i.bHFJ,name:i.FVZZ.jFKM}})}}})),a(this,"VJCr",(function(){i.KwMi.lBBV=i.KwMi.lBBV-1})),a(this,"getFrequencyCount",(function(){return i.KwMi.lBBV})),a(this,"XTOo",(function(){return i.KwMi.EaIa()}))})),x=o((function t(){var e=this;n(this,t),a(this,"vqET",{}),a(this,"parse",(function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{configs:[]};if(l(t)&&l(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 C;a.parse(i)?e.vqET[o]=a:console.warn("Failed to parse cfg",o)}}})),a(this,"validate",(function(t,r){e.vqET.hasOwnProperty(t)&&e.vqET[t].YAEQ(r)})),a(this,"VJCr",(function(t){e.vqET[t].VJCr()})),a(this,"getFrequencyCount",(function(t){return e.vqET[t].getFrequencyCount()})),a(this,"resetFrequencyCounts",(function(){var t=e.vqET;for(var r in t)t[r].XTOo()})),a(this,"ECzm",(function(t){if(Array.isArray(e.vqET)){var r=e.vqET[t];if(r)return r.FVZZ}return{}}))})),q=window.ApxorLogger,D=o((function e(){var r=this;n(this,e),a(this,"wOHb",{}),a(this,"hRWW",[]),a(this,"pnRU",!1),a(this,"initialize",(function(){var e=t.getController();e.registerForEvent("APP_EVENT",(function(t){return r.VEVl(t,"AE")})),e.registerForEvent("CLIENT_EVENT",(function(t){return r.VEVl(t,"CE")}))})),a(this,"vzdU",(function(){for(var t in r.hRWW)r.tElH(t.event,t.key,t.type);r.pnRU=!0})),a(this,"IWud",(function(t,e){var n;"function"==typeof e&&((n=r.wOHb[t]?r.wOHb[t]:[]).push(e),r.wOHb[t]=n,q.debug("Listeners list: ",r.wOHb))})),a(this,"unregisterFromEvent",(function(t,e){if(r.wOHb[t]){for(var n=r.wOHb[t],i=[],o=0;o<n.length;o++){var a=n[o];a!==e&&i.push(a)}r.wOHb[t]=i}})),a(this,"VEVl",(function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"AE",n=e+"___"+t.name;r.tElH(t,n,e)})),a(this,"tElH",(function(e,n,i){if(r.pnRU){if(q.debug("Notifying listeners for event: "+e+", "+n,r.wOHb),r.wOHb[n])for(var o=r.wOHb[n],a=t.getController().getTime(),s=0;s<o.length;s++){(0,o[s])(i,e.name,a,e.additional_info)}}else r.hRWW.push({event:e,key:n,type:i})}))})),H=window.ApxorLogger,B=function(){function e(){var r=this;return n(this,e),a(this,"WdHd",!1),a(this,"zNjX",null),a(this,"Ojib",new Date),a(this,"OSiP",this.Ojib.getDate()+"/"+this.Ojib.getMonth()+"/"+this.Ojib.getFullYear()),a(this,"sSxB",new D),a(this,"iQOj",t.getSiteId()),a(this,"mpgL",{}),a(this,"initialize",(function(){if(!r.WdHd){r.WdHd=!0,r.zNjX=new x,r.sSxB.initialize();var e=t.getController().getFromStorage("qe_state");e?r.mpgL=JSON.parse(h(r.iQOj,e)):t.getController().persistToStorage("qe_state",r.mpgL,!0),H.info("QE Initialized..")}})),a(this,"parse",(function(t){r.NDnj()?(r.zNjX.parse(t),r.sSxB.vzdU()):H.warn("Must call init first. Unable to proceed")})),a(this,"validate",(function(t,e){r.NDnj()&&r.zNjX.validate(t,e)})),a(this,"updateCount",(function(e){try{l(r.mpgL[e])||r.createObjConfig(e),r.incrementFrequencies(e),t.getController().persistToStorage("qe_state",r.mpgL,!0),r.zNjX.VJCr(e)}catch(t){console.log("Could not update the count config:".concat(t))}})),a(this,"resetFrequencyCounts",(function(){r.zNjX.resetFrequencyCounts()})),a(this,"getFrequencyCount",(function(t){return r.zNjX.getFrequencyCount(t)})),a(this,"registerForEvent",(function(t,e){r.sSxB.IWud(t,e)})),a(this,"unregisterFromEvent",(function(t,e){r.sSxB.unregisterFromEvent(t,e)})),a(this,"fetch",(function(e,r,n,i){t.getController().fetchConfiguration(e,r,n,i)})),a(this,"NDnj",(function(){return r.WdHd})),a(this,"getCampaignMetaFromQueryEngine",(function(t){return r.zNjX.ECzm(t)})),e.instance||(e.instance=this),e.instance}return o(e,[{key:"createObjConfig",value:function(e){var r=t.getController().getFromStorage("qe_state");this.mpgL=JSON.parse(h(this.iQOj,r)),l(this.mpgL[e])||(this.mpgL[e]={SESSION:0,OVERALL:0,DATES:{day:this.OSiP,value:0}},t.getController().persistToStorage("qe_state",this.mpgL,!0))}},{key:"incrementFrequencies",value:function(e){var r=t.getController().getFromStorage("qe_state");this.mpgL=JSON.parse(h(this.iQOj,r)),this.mpgL[e].DATES.value=this.mpgL[e].DATES.value+1,this.mpgL[e].SESSION=this.mpgL[e].SESSION+1,this.mpgL[e].OVERALL=this.mpgL[e].OVERALL+1,this.mpgL[e].DATES.day!==this.OSiP&&(this.mpgL[e].DATES.day=this.OSiP,this.mpgL[e].DATES.value=0)}}],[{key:"getInstance",value:function(){return e.instance||(e.instance=new e),e.instance}}]),e}();a(B,"instance",void 0),window.ceVersion=115;try{void 0===exports&&null===exports||(exports.default=B,module.exports=exports.default)}catch(t){}return B}));
|
|
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){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 n(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}function i(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,c(n.key),n)}}function o(t,e,r){return e&&i(t.prototype,e),r&&i(t,r),Object.defineProperty(t,"prototype",{writable:!1}),t}function a(t,e,r){return(e=c(e))in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}function s(t){return function(t){if(Array.isArray(t))return u(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 u(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 u(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 u(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 c(t){var e=function(t,e){if("object"!=typeof t||null===t)return t;var r=t[Symbol.toPrimitive];if(void 0!==r){var n=r.call(t,e||"default");if("object"!=typeof n)return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===e?String:Number)(t)}(t,"string");return"symbol"==typeof e?e:String(e)}t=t&&Object.prototype.hasOwnProperty.call(t,"default")?t.default:t;var l=function(t){return void 0!==t&&!function(t){return null===t}(t)},f="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=";function h(t,e){return Array.from(e).map((function(e,r){return String.fromCharCode(e^function(t,e){return t.charCodeAt(Math.floor(e%t.length))}(t,r))})).join("")}var v=function(t,e){return h(t,e=function(t){var e,r,n,i,o,a,s=0,u=[];if(!t)return t;t+="";do{e=(a=f.indexOf(t.charAt(s++))<<18|f.indexOf(t.charAt(s++))<<12|(i=f.indexOf(t.charAt(s++)))<<6|(o=f.indexOf(t.charAt(s++))))>>16&255,r=a>>8&255,n=255&a,u.push(e),64!==i&&(u.push(r),64!==o&&u.push(n))}while(s<t.length);return u}(e))},d=function(t){switch(t){case"app_event":return"AE";case"client_event":return"CE";case"activity_time":case"activity_event":return"AE"}return"Unknown"},g=function(t){return t.toUpperCase()},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 y(e).test(t);default:return!1}},y=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)},m=function(){var t=new Date;return t.getDate()+"/"+t.getMonth()+"/"+t.getFullYear()},_=window.ApxorLogger,S=o((function e(){var i=this;n(this,e),a(this,"IlmU","ALL"),a(this,"Ubgx",[]),a(this,"zTzr",[]),a(this,"parse",(function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};try{if(i.IlmU=t.audience.audience_type,i.Ubgx=t.audience.attributes.user,i.zTzr=t.audience.attributes.session,!Array.isArray(i.Ubgx)||!Array.isArray(i.zTzr))return _.error("No attributes"),!1}catch(t){return _.error(t),!1}return!0})),a(this,"validate",(function(e,r){var n=!0;return"FTU"===i.IlmU&&(n=t.getController().getSessionInfo().is_first_session),n&&i.vYeI(e,i.Ubgx)&&i.vYeI(r,i.zTzr)})),a(this,"vYeI",(function(t,e){var n=e.length,i=!0;try{for(var o=function(){var r=e[a];if(!t.hasOwnProperty(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<n;a++){var s=o();if("object"===r(s))return s.v}}catch(t){_.error(t),i=!1}return i}))})),x=window.ApxorLogger,b=o((function e(){var r=this;n(this,e),a(this,"bKXH",0),a(this,"LVVc",0),a(this,"TlfN","SESSION"),a(this,"zTNm",0),a(this,"XVfO",0),a(this,"IHTF",0),a(this,"parse",(function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};try{r.bKXH=e.frequency.count,r.IHTF=r.bKXH,r.LVVc=e.frequency.time_interval,r.TlfN=e.frequency.validity,r.XVfO=e.frequency.ses_lmt,r._dayCount=e.frequency.day_lmt;var n=t.getController().getFromStorage("qe_state"),i=JSON.parse(v(t.getSiteId(),n));if(!l(i)||!l(i[e._id]))return!0;if("SESSION"===r.TlfN){if(r.bKXH=parseInt(r.bKXH)-parseInt(i[e._id].SESSION),r.bKXH<=0)return console.warn("Max count limit reached for session:"+e._id),!1}else{if("OVERALL"!==r.TlfN)return x.info("Invalid config."),!1;if(r.bKXH=parseInt(r.bKXH)-parseInt(i[e._id].OVERALL),r.bKXH<=0)return console.warn("Max count limit reached for overall:"+e._id),!1}}catch(t){return x.error(t),!1}return!0})),a(this,"lZsf",(function(){r.bKXH=r.bKXH-1})),a(this,"getFrequencyCount",(function(){return r.bKXH})),a(this,"xeEy",(function(){"SESSION"===r.TlfN&&(r.bKXH=r.IHTF,x.info("Campaign Limit reset"))})),a(this,"LpVm",(function(e){try{if(r.bKXH<=0)return!1;var n=t.getController().getFromStorage("qe_state"),i=JSON.parse(v(t.getSiteId(),n));if(!l(i)||!l(i[e]))return!0;if(0!==r.XVfO)if(parseInt(r.XVfO)-parseInt(i[e].SESSION)<=0)return!1;if(0!==r._dayCount){q.getInstance();var o=m();if(parseInt(r._dayCount)-parseInt(i[e].DATES[o]||0)<=0)return!1}}catch(t){x.error("Error validating the frequency:"+t)}return!0}))})),O=o((function t(){var e=this;n(this,t),a(this,"ttIP",""),a(this,"IlmU",""),a(this,"parse",(function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};try{var r;e.ttIP=t.meta.name,e.IlmU=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}))})),H=window.ApxorLogger,I=o((function t(){var e=this;n(this,t),a(this,"BEyc",-1),a(this,"FnVv",-1),a(this,"llmB",-1),a(this,"vpNk",-1),a(this,"qoEc",!1),a(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.BEyc=Date.parse(t.validity.start_date),e.FnVv=Date.parse(t.validity.end_date),l(t.time_limits_in_day)&&(e.qoEc=t.time_limits_in_day,e.qoEc&&l(t.time_limits))){var r=(new Date).toISOString().split("T")[0];if(e.llmB=Date.parse(r+"T"+t.time_limits.start_time+".000Z"),e.vpNk=Date.parse(r+"T"+t.time_limits.end_time+".000Z"),isNaN(e.llmB)||isNaN(e.vpNk))return H.error("Not valid times"),!1}}catch(t){return H.error(t),!1}return!0})),a(this,"validate",(function(){var t=Date.now();return t>e.BEyc&&t<e.FnVv&&(!e.qoEc||t>=e.llmB&&t<=e.vpNk)}))})),E=o((function t(){var e=this;n(this,t),a(this,"ttIP",""),a(this,"Hxtl",{}),a(this,"parse",(function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};try{e.ttIP=t.name,e.Hxtl=t.additional_info}catch(t){return!1}return!0}))})),F=o((function t(){var e=this;n(this,t),a(this,"Bieg",0),a(this,"HoKu",0),a(this,"parse",(function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};try{if(e.Bieg=Number(t.lower),e.HoKu=Number(t.upper),isNaN(e.Bieg)||isNaN(e.HoKu))return!1}catch(t){return!1}return!0}))})),w=o((function t(){var e=this;n(this,t),a(this,"BroN",0),a(this,"uZkY",""),a(this,"YJOW",""),a(this,"cHFQ",new E),a(this,"qSGC",new F),a(this,"parse",(function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};try{return e.uZkY=t.event_type,e.YJOW=t.activity,e.cHFQ.parse(t.details)&&e.qSGC.parse(t.time_bounds)}catch(t){return!1}}))})),N=o((function t(){var e=this;n(this,t),a(this,"BroN",0),a(this,"Blda",-1),a(this,"bKXH",0),a(this,"PKZu",""),a(this,"YJOW",""),a(this,"uZkY",""),a(this,"qSGC",new F),a(this,"cHFQ",new E),a(this,"QHAu",new w),a(this,"SkKC","AND"),a(this,"qtsr",!1),a(this,"IlmU",void 0),a(this,"parse",(function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};try{return e.Blda=t.sequence,e.bKXH=t.count_config.count,e.PKZu=t.count_config.operator,e.YJOW=t.activity,e.uZkY=t.event_type,e.SkKC=t.combine_operator,e.IlmU=t.type,e.cHFQ.parse(t.details)&&e.QHAu.parse(t.trigger)&&e.qSGC.parse(t.time_bounds)}catch(t){return Logger.error(t),!1}}))})),A=window.ApxorLogger,C=function(){function e(){var i=this;n(this,e),a(this,"htlg",0),a(this,"aJcG",""),a(this,"xuOm",new N),a(this,"EToX",!1),a(this,"SxIc",!1),a(this,"NGcs",0),a(this,"SkKC","AND"),a(this,"SYkI",-1),a(this,"gKCQ",[]),a(this,"EuKs",{}),a(this,"PKXT",!1),a(this,"initialize",(function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"",n=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]:[];i.aJcG=r,i.NGcs=n,i.gKCQ=a;var s=i.xuOm.parse(e);if(s){if(i.SkKC=i.xuOm.SkKC,i.xuOm.qtsr){var u=i.xuOm.cHFQ.ttIP;"APX_PAGE_OPENED"===u&&(u=i.xuOm.cHFQ.Hxtl.navigation_id,u=isDefined(u)?u:i.xuOm.cHFQ.ttIP),i.SYkI=t.getController().getEventCount(u);var c=i.xuOm.bKXH,l=i.xuOm.PKZu;if(i.SxIc=i.xiQe(i.SYkI-1,c,l,!1),i.EToX=i.SxIc,i.SxIc&&"APX_PAGE_OPENED"===i.xuOm.cHFQ.ttIP)return!0}return o&&0!==n||i.wxCK(),!0}return!1})),a(this,"wxCK",(function(){var t=i.xuOm,e=t.QHAu,r=q.getInstance();"app_start"===e.uZkY?(i.EToX=!0,r.registerForEvent(d(t.uZkY)+"___"+t.cHFQ.ttIP,i.Hbrj)):r.registerForEvent(d(t.uZkY)+"___"+e.cHFQ.ttIP,i.Hbrj)})),a(this,"Pwsv",(function(t,e,r,n){var o,a,s,u=(Date.now()-i.EuKs[e])/1e3;(null===(o=i.xuOm)||void 0===o||null===(a=o.cHFQ)||void 0===a||null===(s=a.Hxtl)||void 0===s?void 0:s.time)/1e3>u&&i._displayCampaign()})),a(this,"oiOg",(function(t,e,r,n){var o,a,s,u,c;i.PKXT=!0;var l=Date.now(),f=null===(o=i.xuOm)||void 0===o||null===(a=o.QHAu)||void 0===a?void 0:a.cHFQ.ttIP,h=(l-i.EuKs[f])/1e3,v=null===(s=i.xuOm)||void 0===s||null===(u=s.cHFQ)||void 0===u||null===(c=u.Hxtl)||void 0===c?void 0:c.time;(v/=1e3)>h&&i._displayCampaign()})),a(this,"Hbrj",(function(t,e,r,n){var o=q.getInstance();if(i.EToX)d(i.xuOm.uZkY)===t&&i.SPfP(r-i.xuOm.QHAu.BroN,i.xuOm.qSGC)&&i.xuOm.cHFQ.ttIP===e&&i.Zevy(i.xuOm.cHFQ.Hxtl,n)&&(i.htlg+=1,i.SxIc=i.xiQe(i.htlg,i.xuOm.bKXH,i.xuOm.PKZu),i.SxIc&&(i.xuOm.BroN=r,o.validate(i.aJcG,i.NGcs)));else if(i.EToX=i.fipO(t,e,r,n),i.EToX){var a=i.xuOm,s=a.QHAu;if(s.BroN=r,"activity_time"===(null==a?void 0:a.uZkY)){var u,c,l,f,h,v,p=null==a||null===(u=a.cHFQ)||void 0===u||null===(c=u.Hxtl)||void 0===c?void 0:c.time;(null==a||null===(l=a.cHFQ)||void 0===l||null===(f=l.Hxtl)||void 0===f?void 0:f.nkpi.length)>0&&(setTimeout((function(){i.PKXT||(i.SxIc=!0,i.SxIc&&(i.htlg+=1,i.SxIc=i.xiQe(i.htlg,i.xuOm.bKXH,i.xuOm.PKZu),i.SxIc&&(i.xuOm.BroN=r,o.validate(i.aJcG,i.NGcs)))),a.cHFQ.Hxtl.nkpi.map((function(t){o.unregisterFromEvent(g(a.cHFQ.Hxtl.et)+"___"+t,i)}))}),p),a.cHFQ.Hxtl.nkpi.map((function(t){o.registerForEvent(g(a.cHFQ.Hxtl.et)+"___"+t,i.oiOg)}))),(null==a||null===(h=a.cHFQ)||void 0===h||null===(v=h.Hxtl)||void 0===v?void 0:v.kpi.length)>0&&(setTimeout((function(){a.cHFQ.Hxtl.kpi.map((function(t){o.unregisterFromEvent(g(a.cHFQ.Hxtl.et)+"___"+t,i)}))}),p),a.cHFQ.Hxtl.kpi.map((function(t){t===a.QHAu.cHFQ.ttIP?(o.unregisterFromEvent(d(s.uZkY)+"___"+s.cHFQ.ttIP,i),o.registerForEvent(g(a.cHFQ.Hxtl.et)+"___"+t,i.Pwsv)):o.registerForEvent(g(a.cHFQ.Hxtl.et)+"___"+t,i.oiOg)})))}else o.unregisterFromEvent(d(s.uZkY)+"___"+s.cHFQ.ttIP,i),o.registerForEvent(d(a.uZkY)+"___"+a.cHFQ.ttIP,i);i.EuKs[e]=Date.now()}})),a(this,"fipO",(function(t,e,r,n){var o=i.xuOm.QHAu;return d(o.uZkY)===t&&o.cHFQ.ttIP===e&&i.SPfP(r,o.qSGC)&&i.Zevy(o.cHFQ.Hxtl,n)})),a(this,"SPfP",(function(t,e){var r=Math.round(t);return r>e.Bieg&&r<e.HoKu})),a(this,"xiQe",(function(t,e,r){var n=!(arguments.length>3&&void 0!==arguments[3])||arguments[3];switch(n&&i.xuOm.qtsr&&(t+=i.SYkI),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}})),a(this,"Zevy",(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 p(t,i,a)}));n=n&&u}else n=n&&p(e[o],t[o],"EQ")};for(var o in t){var a=i();if("object"===r(a))return a.v}}catch(t){A.error(t),n=!1}return n}))}return o(e,[{key:"_displayCampaign",value:function(){var t=q.getInstance();this.SxIc=!0,this.SxIc&&(this.htlg+=1,this.SxIc=this.xiQe(this.htlg,this.xuOm.bKXH,this.xuOm.PKZu),this.SxIc&&(this.xuOm.BroN=time,t.validate(this.aJcG,this.NGcs)))}}]),e}(),P=o((function e(){var r=this;n(this,e),a(this,"KjjG",[]),a(this,"_ret_day",{}),a(this,"KDPD",{}),a(this,"eviS",!1),a(this,"SMAj",!1),a(this,"parse",(function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};try{r.KjjG=t.overall_cfg.events,r._ret_day=t.overall_cfg.ret_day,r.KDPD=t.overall_cfg.session,r.eviS=t.overall_cfg.toggleRetDay,r.KjjG=t.overall_cfg.events,r.SMAj=t.overall_cfg.toggleSession}catch(t){return Logger.error(error),!1}return!0})),a(this,"validate",(function(){var e=parseInt(t.getController().getFromStorage("apx_retained_days")),n=parseInt(t.getController().getFromStorage("apx_retained_session"));if(r.eviS&&!isNaN(e)&&!(e>=r._ret_day.from&&e<=r._ret_day.to))return!1;if(r.SMAj&&!isNaN(n)&&!(n>=r.KDPD.from&&n<=r.KDPD.to))return!1;try{for(var i=t.getController().getFromStorage("_apx_lt_count"),o=t.getSiteId(),a=JSON.parse(v(o,i)),s=0;s<r.KjjG.length;s++){var u=r.KjjG[s].name.replace("'","").replace("’","");if(a.hasOwnProperty(u))return!1}}catch(t){Logger.error("Failed to validate the lt count:"+t)}return!0}))})),T=window.ApxorLogger,K=o((function r(){var i=this;n(this,r),a(this,"eNJE",[]),a(this,"aJcG",""),a(this,"fdyk",new O),a(this,"gLFR",new S),a(this,"TlfN",new I),a(this,"NBKT",new b),a(this,"MBiV",new P),a(this,"QYrI",!1),a(this,"QFWr",[]),a(this,"parse",(function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};try{if(!l(t._id))return T.error("No Id"),!1;if(!l(t.enabled)||!t.enabled)return T.error("Not enabled"),!1;if(!(i.fdyk.parse(t)&&i.TlfN.parse(t)&&i.NBKT.parse(t)&&i.gLFR.parse(t)&&i.MBiV.parse(t)))return!1;if(!l(t.conditions)||!Array.isArray(t.conditions))return T.error("No valid conditions",t.conditions),!1;i.aJcG=t._id,i.QYrI=!!l(t.sequence_enabled)&&t.sequence_enabled,i.QYrI&&t.conditions.sort((function(t,e){return t.sequence<e.sequence}));for(var e=t.conditions,r=e.length,n=0;n<r;n++){i.QFWr=[];var o=e[n];if("didn't"===o.type){var a,u,c={trigger_key:o.trigger.details.name,no_kpi_array:null==o||null===(a=o.details)||void 0===a||null===(u=a.additional_info)||void 0===u?void 0:u.nkpi,condition_id:null==o?void 0:o._id,time_bounds:o.time_bounds.upper};i.QFWr=[].concat(s(i.QFWr),[c])}var f=new C;f.initialize(o,i.aJcG,n,i.QYrI,i.QFWr)&&i.eNJE.push(f)}return i.eNJE.length>0}catch(t){return T.error(t),!1}})),a(this,"mztK",(function(t){if(!(t<0))if(i.QYrI){var e=i.eNJE[t];if(l(e)&&e.SxIc){var r=i.eNJE[t-1];if(l(r)&&!r.SxIc)return;var n=i.eNJE[t+1];l(n)?n.wxCK():i.YdiE()}}else i.YdiE()})),a(this,"YdiE",(function(){var r=t.getController().getUserAttributes(),n=t.getController().getSessionAttributes();if(i.TlfN.validate()&&i.gLFR.validate(r,n)&&i.MBiV.validate()){for(var o=i.eNJE.length,s=o<1,u="",c=0;c<o;c++){var l=i.eNJE[c],f=l.SxIc;if(""===u.trim())s=f;else switch(u){case"AND":s=s&&f;break;case"OR":s=s||f}u=l.SkKC}if(s){if(console.debug("onCondition satisfied"),!i.NBKT.LpVm(i.aJcG))return void console.warn("Maximum limit reached",i.aJcG);console.log("Dispatching event",i.fdyk.IlmU),!0===i.fdyk._only_context&&t.logEvent("apx_context_evaluated",function(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){a(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}({},i.fdyk._attr)),t.getController().dispatchEvent(i.fdyk.IlmU,{name:i.fdyk.IlmU,additional_info:{uuid:i.aJcG,name:i.fdyk.ttIP}})}}})),a(this,"lZsf",(function(){i.NBKT.lZsf()})),a(this,"getFrequencyCount",(function(){return i.NBKT.getFrequencyCount()})),a(this,"HSky",(function(){return i.NBKT.xeEy()}))})),Q=o((function t(){var e=this;n(this,t),a(this,"aXgn",{}),a(this,"parse",(function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{configs:[]};if(l(t)&&l(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 K;a.parse(i)?e.aXgn[o]=a:console.warn("Failed to parse cfg",o)}}})),a(this,"validate",(function(t,r){e.aXgn.hasOwnProperty(t)&&e.aXgn[t].mztK(r)})),a(this,"lZsf",(function(t){e.aXgn[t].lZsf()})),a(this,"getFrequencyCount",(function(t){return e.aXgn[t].getFrequencyCount()})),a(this,"resetFrequencyCounts",(function(){var t=e.aXgn;for(var r in t)t[r].HSky()})),a(this,"nwfh",(function(t){if(Array.isArray(e.aXgn)){var r=e.aXgn[t];if(r)return r.fdyk}return{}}))})),k=window.ApxorLogger,X=o((function e(){var r=this;n(this,e),a(this,"yHdn",{}),a(this,"OAbJ",[]),a(this,"sHPw",!1),a(this,"initialize",(function(){var e=t.getController();e.registerForEvent("APP_EVENT",(function(t){return r.CadS(t,"AE")})),e.registerForEvent("CLIENT_EVENT",(function(t){return r.CadS(t,"CE")}))})),a(this,"YVgY",(function(){for(var t in r.OAbJ)r.IXTy(t.event,t.key,t.type);r.sHPw=!0})),a(this,"rKHV",(function(t,e){var n;"function"==typeof e&&((n=r.yHdn[t]?r.yHdn[t]:[]).push(e),r.yHdn[t]=n,k.debug("Listeners list: ",r.yHdn))})),a(this,"unregisterFromEvent",(function(t,e){if(r.yHdn[t]){for(var n=r.yHdn[t],i=[],o=0;o<n.length;o++){var a=n[o];a!==e&&i.push(a)}r.yHdn[t]=i}})),a(this,"CadS",(function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"AE",n=e+"___"+t.name;r.IXTy(t,n,e)})),a(this,"IXTy",(function(e,n,i){if(r.sHPw){if(k.debug("Notifying listeners for event: "+e+", "+n,r.yHdn),r.yHdn[n])for(var o=r.yHdn[n],a=t.getController().getTime(),s=0;s<o.length;s++){(0,o[s])(i,e.name,a,e.additional_info)}}else r.OAbJ.push({event:e,key:n,type:i})}))})),j=window.ApxorLogger,q=function(){function e(){var r=this;return n(this,e),a(this,"sYTJ",!1),a(this,"XpLf",null),a(this,"jbpI",m()),a(this,"OZlv",new X),a(this,"kfFP",t.getSiteId()),a(this,"ecri",{}),a(this,"initialize",(function(){if(!r.sYTJ){r.sYTJ=!0,r.XpLf=new Q,r.OZlv.initialize();var e=t.getController().getFromStorage("qe_state");e?r.ecri=JSON.parse(v(r.kfFP,e)):t.getController().persistToStorage("qe_state",r.ecri,!0),j.info("QE Initialized..")}})),a(this,"parse",(function(t){r.XUgw()?(r.XpLf.parse(t),r.OZlv.YVgY()):j.warn("Must call init first. Unable to proceed")})),a(this,"validate",(function(t,e){r.XUgw()&&r.XpLf.validate(t,e)})),a(this,"updateCount",(function(e){try{l(r.ecri[e])||r.createObjConfig(e),r.incrementFrequencies(e),t.getController().persistToStorage("qe_state",r.ecri,!0),r.XpLf.lZsf(e)}catch(t){console.log("Could not update the count config:".concat(t))}})),a(this,"resetFrequencyCounts",(function(){r.XpLf.resetFrequencyCounts()})),a(this,"getFrequencyCount",(function(t){return r.XpLf.getFrequencyCount(t)})),a(this,"registerForEvent",(function(t,e){r.OZlv.rKHV(t,e)})),a(this,"unregisterFromEvent",(function(t,e){r.OZlv.unregisterFromEvent(t,e)})),a(this,"fetch",(function(e,r,n,i){t.getController().fetchConfiguration(e,r,n,i)})),a(this,"XUgw",(function(){return r.sYTJ})),a(this,"getCampaignMetaFromQueryEngine",(function(t){return r.XpLf.nwfh(t)})),a(this,"TVAf",(function(){return r.jbpI})),e.instance||(e.instance=this),e.instance}return o(e,[{key:"createObjConfig",value:function(e){try{var r=t.getController().getFromStorage("qe_state");this.ecri=JSON.parse(v(this.kfFP,r)),l(this.ecri[e])||(this.ecri[e]={SESSION:0,OVERALL:0,DATES:{}},this.jbpI&&(this.ecri[e].DATES[this.jbpI]=0),t.getController().persistToStorage("qe_state",this.ecri,!0))}catch(t){j.error("Can not create the frequency count object:"+t)}}},{key:"incrementFrequencies",value:function(e){var r=t.getController().getFromStorage("qe_state");this.ecri=JSON.parse(v(this.kfFP,r));var n=this.ecri[e];n.SESSION=n.SESSION+1,n.OVERALL=n.OVERALL+1;var i=m();i!==this.jbpI&&(this.jbpI=i,n.DATES={},n.DATES[this.jbpI]=0),n.DATES[this.jbpI]=n.DATES[this.jbpI]+1}}],[{key:"getInstance",value:function(){return e.instance||(e.instance=new e),e.instance}}]),e}();a(q,"instance",void 0),window.ceVersion=116;try{void 0===exports&&null===exports||(exports.default=q,module.exports=exports.default)}catch(t){}return q}));
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "apxor-qe",
|
|
3
|
-
"version": "1.1.
|
|
3
|
+
"version": "1.1.6",
|
|
4
4
|
"author": "Uma Sankar Yedida <umasankar.yedida@apxor.com> (https://www.apxor.com)",
|
|
5
5
|
"contributors": [
|
|
6
6
|
{
|
|
@@ -44,15 +44,13 @@
|
|
|
44
44
|
"cypress": "./node_modules/.bin/cypress open"
|
|
45
45
|
},
|
|
46
46
|
"devDependencies": {
|
|
47
|
-
"@babel/core": "^7.
|
|
48
|
-
"@babel/
|
|
49
|
-
"@babel/plugin-proposal-
|
|
50
|
-
"@babel/
|
|
51
|
-
"@babel/preset-
|
|
52
|
-
"babel-eslint": "10.0
|
|
53
|
-
"babel-
|
|
54
|
-
"babel-preset-es2015": "6.24.1",
|
|
55
|
-
"babel-preset-stage-2": "6.24.1",
|
|
47
|
+
"@babel/core": "^7.20.7",
|
|
48
|
+
"@babel/eslint-parser": "^7.19.1",
|
|
49
|
+
"@babel/plugin-proposal-class-properties": "^7.18.6",
|
|
50
|
+
"@babel/plugin-proposal-object-rest-spread": "^7.20.7",
|
|
51
|
+
"@babel/preset-env": "^7.20.2",
|
|
52
|
+
"babel-eslint": "^10.1.0",
|
|
53
|
+
"babel-loader": "^9.1.0",
|
|
56
54
|
"check-node-version": "^3.2.0",
|
|
57
55
|
"chokidar": "^3.5.2",
|
|
58
56
|
"cypress": "^3.2.0",
|
|
@@ -66,7 +64,7 @@
|
|
|
66
64
|
"rollup-plugin-replace": "^2.2.0"
|
|
67
65
|
},
|
|
68
66
|
"dependencies": {
|
|
69
|
-
"apxor": "^1.6
|
|
67
|
+
"apxor": "^1.7.6"
|
|
70
68
|
},
|
|
71
69
|
"files": [
|
|
72
70
|
"dist"
|