apxor-qe 1.2.1-qa.0 → 1.2.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 +330 -330
- package/dist/apxor.qe.min.js +1 -1
- package/package.json +2 -2
package/dist/apxor.qe.min.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?module.exports=e(require("apxor")):"function"==typeof define&&define.amd?define(["apxor"],e):(t=t||self)["apxor-qe"]=e(t.Apxor)}(this,function(t){"use strict";function e(t,e){var r=Object.keys(t);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(t);e&&(n=n.filter(function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable})),r.push.apply(r,n)}return r}function r(t){for(var r=1;r<arguments.length;r++){var n=null!=arguments[r]?arguments[r]:{};r%2?e(Object(n),!0).forEach(function(e){s(t,e,n[e])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):e(Object(n)).forEach(function(e){Object.defineProperty(t,e,Object.getOwnPropertyDescriptor(n,e))})}return t}function n(t){return(n="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t})(t)}function i(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}function o(t,e){for(var r=0;r<e.length;r++){var n=e[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,f(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=f(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 f(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 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,r){return String.fromCharCode(e^function(t,e){return t.charCodeAt(Math.floor(e%t.length))}(t,r))}).join("")}var g=function(t,e){return v(t,e=function(t){var e,r,n,i,o,a,s=0,u=[];if(!t)return t;t+="";do{e=(a=h.indexOf(t.charAt(s++))<<18|h.indexOf(t.charAt(s++))<<12|(i=h.indexOf(t.charAt(s++)))<<6|(o=h.indexOf(t.charAt(s++))))>>16&255,r=a>>8&255,n=255&a,u.push(e),64!==i&&(u.push(r),64!==o&&u.push(n))}while(s<t.length);return u}(e))},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"},p=function(t){return t.toUpperCase()},y=function(t,e,r){switch(r){case"EQ":return t===e;case"GT":return t>e;case"GTE":return t>=e;case"LT":return t<e;case"LTE":return t<=e;case"NEQ":return t!==e;case"R":return E(e).test(t);default:return!1}},E=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,A=a(function e(){var r=this;i(this,e),s(this,"iFUh","ALL"),s(this,"PZkA",[]),s(this,"BJFI",[]),s(this,"parse",function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};try{if(r.iFUh=t.audience.audience_type,r.PZkA=t.audience.attributes.user,r.BJFI=t.audience.attributes.session,!Array.isArray(r.PZkA)||!Array.isArray(r.BJFI))return _.error("No attributes"),!1}catch(t){return _.error(t),!1}return!0}),s(this,"validate",function(e,n){var i=!0;return"FTU"===r.iFUh&&(i=t.getController().getSessionInfo().is_first_session),i&&r.yYES(e,r.PZkA)&&r.yYES(n,r.BJFI)}),s(this,"yYES",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 y(t,e,n)})});i=i&&u},a=0;a<r;a++){var s=o();if("object"===n(s))return s.v}}catch(t){_.error(t),i=!1}return i})}),S=window.ApxorLogger,b=a(function t(){var e=this;i(this,t),s(this,"EryT",0),s(this,"bBzm",0),s(this,"DTlJ","SESSION"),s(this,"pkwS",0),s(this,"QpXP",0),s(this,"SMdK",0),s(this,"parse",function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};try{e.EryT=t.frequency.count,e.SMdK=e.EryT,e.bBzm=t.frequency.time_interval,e.DTlJ=t.frequency.validity,e.QpXP=t.frequency.ses_lmt,e._dayCount=t.frequency.day_lmt;var r=R.getInstance().getQeState();if(!l(r)||!l(r[t._id]))return!0;if("SESSION"===e.DTlJ){if(e.EryT=parseInt(e.EryT)-parseInt(r[t._id].SESSION),e.EryT<=0)return console.warn("Max count limit reached for session:"+t._id),!1}else{if("OVERALL"!==e.DTlJ)return S.info("Invalid config."),!1;if(e.EryT=parseInt(e.EryT)-parseInt(r[t._id].OVERALL),e.EryT<=0)return console.warn("Max count limit reached for overall:"+t._id),!1}}catch(t){return S.error(t),!1}return!0}),s(this,"CgAS",function(){e.EryT=e.EryT-1}),s(this,"getFrequencyCount",function(){return e.EryT}),s(this,"ihJn",function(){"SESSION"===e.DTlJ&&(e.EryT=e.SMdK,S.info("Campaign Limit reset"))}),s(this,"fmBg",function(t){try{if(e.EryT<=0)return!1;var r=R.getInstance().getQeState();if(!l(r)||!l(r[t]))return!0;if(0!==e.QpXP)if(parseInt(e.QpXP)-parseInt(r[t].SESSION)<=0)return!1;if(0!==e._dayCount){var n,i=m();if(parseInt(e._dayCount)-parseInt((null===(n=r[t])||void 0===n?void 0:n.DATES[i])||0)<=0)return!1}}catch(t){S.error("Error validating the frequency:"+t)}return!0})}),D=a(function t(){var e=this;i(this,t),s(this,"UJen",""),s(this,"iFUh",""),s(this,"parse",function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};try{var r;e.UJen=t.meta.name,e.iFUh=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})}),T=window.ApxorLogger,N=a(function t(){var e=this;i(this,t),s(this,"ABuC",-1),s(this,"NvKk",-1),s(this,"tbvE",-1),s(this,"ImUl",-1),s(this,"BXRW",!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.ABuC=Date.parse(t.validity.start_date),e.NvKk=Date.parse(t.validity.end_date),l(t.time_limits_in_day)&&(e.BXRW=t.time_limits_in_day,e.BXRW&&l(t.time_limits))){var r=(new Date).toISOString().split("T")[0];if(e.tbvE=Date.parse(r+"T"+t.time_limits.start_time+".000Z"),e.ImUl=Date.parse(r+"T"+t.time_limits.end_time+".000Z"),isNaN(e.tbvE)||isNaN(e.ImUl))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.ABuC&&t<e.NvKk&&(!e.BXRW||t>=e.tbvE&&t<=e.ImUl)})}),w=a(function t(){var e=this;i(this,t),s(this,"UJen",""),s(this,"siFg",{}),s(this,"parse",function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};try{e.UJen=t.name,e.siFg=t.additional_info}catch(t){return!1}return!0})}),x=a(function t(){var e=this;i(this,t),s(this,"qpBO",0),s(this,"bNgD",0),s(this,"parse",function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};try{if(e.qpBO=Number(t.lower),e.bNgD=Number(t.upper),isNaN(e.qpBO)||isNaN(e.bNgD))return!1}catch(t){return!1}return!0})}),C=a(function t(){var e=this;i(this,t),s(this,"PJzC",0),s(this,"ZTfT",""),s(this,"VrGK",""),s(this,"AEID",new w),s(this,"siCr",new x),s(this,"parse",function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};try{return e.ZTfT=t.event_type,e.VrGK=t.activity,e.AEID.parse(t.details)&&e.siCr.parse(t.time_bounds)}catch(t){return!1}})}),I=window.ApxorLogger,F=a(function t(){var e=this;i(this,t),s(this,"PJzC",0),s(this,"vOzK",-1),s(this,"EryT",0),s(this,"rxsh",""),s(this,"VrGK",""),s(this,"ZTfT",""),s(this,"siCr",new x),s(this,"AEID",new w),s(this,"CuHY",new C),s(this,"kJkn","AND"),s(this,"NFIW",!1),s(this,"iFUh",void 0),s(this,"parse",function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};try{return e.vOzK=t.sequence,e.EryT=t.count_config.count,e.rxsh=t.count_config.operator,e.VrGK=t.activity,e.ZTfT=t.event_type,e.kJkn=t.combine_operator,e.iFUh=t.type,e.AEID.parse(t.details)&&e.CuHY.parse(t.trigger)&&e.siCr.parse(t.time_bounds)}catch(t){return I.error(t),!1}})}),k=window.ApxorLogger,J=function(){function e(){var r=this;i(this,e),s(this,"xfkt",0),s(this,"kQmq",""),s(this,"xogN",new F),s(this,"MAdD",!1),s(this,"fjVn",!1),s(this,"fDne",0),s(this,"kJkn","AND"),s(this,"RofU",-1),s(this,"aJDv",[]),s(this,"YPme",{}),s(this,"mhrT",!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.kQmq=n,r.fDne=i,r.aJDv=a,r.xogN.parse(e)){if(r.kJkn=r.xogN.kJkn,r.xogN.NFIW){var s=r.xogN.AEID.UJen;"APX_PAGE_OPENED"===s&&(s=r.xogN.AEID.siFg.navigation_id,s=l(s)?s:r.xogN.AEID.UJen),r.RofU=t.getController().getEventCount(s);var u=r.xogN.EryT,c=r.xogN.rxsh;if(r.fjVn=r.FIzB(r.RofU-1,u,c,!1),r.MAdD=r.fjVn,r.fjVn&&"APX_PAGE_OPENED"===r.xogN.AEID.UJen)return!0}return o&&0!==i||r.fggZ(),!0}return!1}),s(this,"fggZ",function(){var t=r.xogN,e=t.CuHY,n=R.getInstance();"app_start"===e.ZTfT?(r.MAdD=!0,n.registerForEvent(d(t.ZTfT)+"___"+t.AEID.UJen,r.XBGa)):n.registerForEvent(d(t.ZTfT)+"___"+e.AEID.UJen,r.XBGa)}),s(this,"CflY",function(t,e,n,i){var o,a,s,u=(Date.now()-r.YPme[e])/1e3;(null===(o=r.xogN)||void 0===o?void 0:null===(a=o.AEID)||void 0===a?void 0:null===(s=a.siFg)||void 0===s?void 0:s.time)/1e3>u&&r._displayCampaign(n)}),s(this,"YiQd",function(t,e,n,i){var o,a,s,u,c;r.mhrT=!0;var f=Date.now(),l=null===(o=r.xogN)||void 0===o?void 0:null===(a=o.CuHY)||void 0===a?void 0:a.AEID.UJen,h=(f-r.YPme[l])/1e3,v=null===(s=r.xogN)||void 0===s?void 0:null===(u=s.AEID)||void 0===u?void 0:null===(c=u.siFg)||void 0===c?void 0:c.time;(v/=1e3)>h&&r._displayCampaign(n)}),s(this,"XBGa",function(t,e,n,i){var o=R.getInstance();if(r.MAdD)d(r.xogN.ZTfT)===t&&r.zDvX(n-r.xogN.CuHY.PJzC,r.xogN.siCr)&&r.xogN.AEID.UJen===e&&r.kzTQ(r.xogN.AEID.siFg,i)&&(r.xfkt+=1,r.fjVn=r.FIzB(r.xfkt,r.xogN.EryT,r.xogN.rxsh),r.fjVn&&(r.xogN.PJzC=n,o.validate(r.kQmq,r.fDne)));else if(r.MAdD=r.yRTw(t,e,n,i),r.MAdD){var a=r.xogN,s=a.CuHY;if(s.PJzC=n,"activity_time"===(null==a?void 0:a.ZTfT)){var u,c,f,l,h,v,g=null==a?void 0:null===(u=a.AEID)||void 0===u?void 0:null===(c=u.siFg)||void 0===c?void 0:c.time;(null==a?void 0:null===(f=a.AEID)||void 0===f?void 0:null===(l=f.siFg)||void 0===l?void 0:l.nkpi.length)>0&&(setTimeout(function(){r.mhrT||(r.fjVn=!0,r.fjVn&&(r.xfkt+=1,r.fjVn=r.FIzB(r.xfkt,r.xogN.EryT,r.xogN.rxsh),r.fjVn&&(r.xogN.PJzC=n,o.validate(r.kQmq,r.fDne)))),a.AEID.siFg.nkpi.map(function(t){o.unregisterFromEvent(p(a.AEID.siFg.et)+"___"+t,r)})},g),a.AEID.siFg.nkpi.map(function(t){o.registerForEvent(p(a.AEID.siFg.et)+"___"+t,r.YiQd)})),(null==a?void 0:null===(h=a.AEID)||void 0===h?void 0:null===(v=h.siFg)||void 0===v?void 0:v.kpi.length)>0&&(setTimeout(function(){a.AEID.siFg.kpi.map(function(t){o.unregisterFromEvent(p(a.AEID.siFg.et)+"___"+t,r)})},g),a.AEID.siFg.kpi.map(function(t){t===a.CuHY.AEID.UJen?(o.unregisterFromEvent(d(s.ZTfT)+"___"+s.AEID.UJen,r),o.registerForEvent(p(a.AEID.siFg.et)+"___"+t,r.CflY)):o.registerForEvent(p(a.AEID.siFg.et)+"___"+t,r.YiQd)}))}else o.unregisterFromEvent(d(s.ZTfT)+"___"+s.AEID.UJen,r),o.registerForEvent(d(a.ZTfT)+"___"+a.AEID.UJen,r);r.YPme[e]=Date.now()}}),s(this,"yRTw",function(t,e,n,i){var o=r.xogN.CuHY;return d(o.ZTfT)===t&&o.AEID.UJen===e&&r.zDvX(n,o.siCr)&&r.kzTQ(o.AEID.siFg,i)}),s(this,"zDvX",function(t,e){var r=Math.ceil(t);return r>e.qpBO&&r<e.bNgD}),s(this,"FIzB",function(t,e,n){switch((!(arguments.length>3&&void 0!==arguments[3])||arguments[3])&&r.xogN.NFIW&&(t+=r.RofU),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,"kzTQ",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 y(t,i,a)});r=r&&u}else r=r&&y(e[o],t[o],"EQ")};for(var o in t){var a=i();if("object"===n(a))return a.v}}catch(t){k.error(t),r=!1}return r})}return a(e,[{key:"_displayCampaign",value:function(t){var e=R.getInstance();this.fjVn=!0,this.fjVn&&(this.xfkt+=1,this.fjVn=this.FIzB(this.xfkt,this.xogN.EryT,this.xogN.rxsh),this.fjVn&&(this.xogN.PJzC=t,e.validate(this.kQmq,this.fDne)))}}]),e}(),q="qe_state",j=window.ApxorLogger,z=a(function e(){var r=this;i(this,e),s(this,"wwqM",[]),s(this,"_ret_day",{}),s(this,"VdHE",{}),s(this,"XLDN",!1),s(this,"wuRU",!1),s(this,"parse",function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};try{r.wwqM=t.overall_cfg.events,r._ret_day=t.overall_cfg.ret_day,r.VdHE=t.overall_cfg.session,r.XLDN=t.overall_cfg.toggleRetDay,r.wwqM=t.overall_cfg.events,r.wuRU=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")),n=parseInt(t.getController().getFromStorage("apx_retained_session"));if(r.XLDN&&!isNaN(e)&&!(e>=r._ret_day.from&&e<=r._ret_day.to))return!1;if(r.wuRU&&!isNaN(n)&&!(n>=r.VdHE.from&&n<=r.VdHE.to))return!1;try{for(var i=t.getController().getFromStorage("_apx_lt_count"),o=t.getSiteId(),a=JSON.parse(g(o,i)),s=0;s<r.wwqM.length;s++){if(a[r.wwqM[s].name.replace("'","").replace("’","")])return!1}}catch(t){j.error("Failed to validate the lt count:"+t)}return!0})}),O=window.ApxorLogger,U=a(function e(){var n=this;i(this,e),s(this,"BWUl",[]),s(this,"kQmq",""),s(this,"RfXY",new D),s(this,"umZx",new A),s(this,"DTlJ",new N),s(this,"sWvb",new b),s(this,"Skej",new z),s(this,"EvKg",!1),s(this,"MjoH",[]),s(this,"parse",function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};try{if(!l(t._id))return O.error("No Id"),!1;if(!l(t.enabled)||!t.enabled)return O.error("Not enabled"),!1;if(!(n.RfXY.parse(t)&&n.DTlJ.parse(t)&&n.sWvb.parse(t)&&n.umZx.parse(t)&&n.Skej.parse(t)))return!1;if(!l(t.conditions)||!Array.isArray(t.conditions))return O.error("No valid conditions",t.conditions),!1;n.kQmq=t._id,n.EvKg=!!l(t.sequence_enabled)&&t.sequence_enabled,n.EvKg&&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.MjoH=[];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.MjoH=[].concat(u(n.MjoH),[c])}var f=new J;f.initialize(o,n.kQmq,i,n.EvKg,n.MjoH)&&n.BWUl.push(f)}return n.BWUl.length>0}catch(t){return O.error(t),!1}}),s(this,"vgMy",function(t){if(!(t<0))if(n.EvKg){var e=n.BWUl[t];if(l(e)&&e.fjVn){var r=n.BWUl[t-1];if(l(r)&&!r.fjVn)return;var i=n.BWUl[t+1];l(i)?i.fggZ():n.bcPN()}}else n.bcPN()}),s(this,"bcPN",function(){var e=t.getController().getUserAttributes(),i=t.getController().getSessionAttributes();if(n.DTlJ.validate()&&n.umZx.validate(e,i)&&n.Skej.validate()){for(var o=n.BWUl.length,a=o<1,s="",u=0;u<o;u++){var c=n.BWUl[u],f=c.fjVn;if(""===s.trim())a=f;else switch(s){case"AND":a=a&&f;break;case"OR":a=a||f}s=c.kJkn}if(a){if(console.debug("onCondition satisfied"),!n.sWvb.fmBg(n.kQmq))return void console.warn("Maximum limit reached",n.kQmq);console.log("Dispatching event",n.RfXY.iFUh),!0===n.RfXY._only_context&&t.logEvent("apx_context_evaluated",r(r({},n.RfXY._attr),{},{message_name:n.RfXY.UJen,id:n.kQmq})),t.getController().dispatchEvent(n.RfXY.iFUh,{name:n.RfXY.iFUh,additional_info:{uuid:n.kQmq,name:n.RfXY.UJen}})}}}),s(this,"CgAS",function(){n.sWvb.CgAS()}),s(this,"getFrequencyCount",function(){return n.sWvb.getFrequencyCount()}),s(this,"EbNj",function(){return n.sWvb.ihJn()})}),P=a(function t(){var e=this;i(this,t),s(this,"zWnJ",{}),s(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 U;a.parse(i)?e.zWnJ[o]=a:console.warn("Failed to parse cfg",o)}}}),s(this,"validate",function(t,r){e.zWnJ[t]&&e.zWnJ[t].vgMy(r)}),s(this,"CgAS",function(t){e.zWnJ[t].CgAS()}),s(this,"getFrequencyCount",function(t){return e.zWnJ[t].getFrequencyCount()}),s(this,"resetFrequencyCounts",function(){var t=e.zWnJ;for(var r in t)t[r].EbNj()}),s(this,"zjhq",function(t){try{if(e.zWnJ){var r=e.zWnJ[t];if(r&&r.RfXY)return r.RfXY}}catch(t){console.log("Error in getting the campaign meta ".concat(t))}return{}})}),M=window.ApxorLogger,Q=a(function e(){var r=this;i(this,e),s(this,"Jzbz",{}),s(this,"ohdM",[]),s(this,"kgpd",!1),s(this,"initialize",function(){var e=t.getController();e.registerForEvent("APP_EVENT",function(t){return r.kkta(t,"AE")}),e.registerForEvent("CLIENT_EVENT",function(t){return r.kkta(t,"CE")})}),s(this,"DWsN",function(){for(var t in r.ohdM)r.LGDG(t.event,t.key,t.type);r.kgpd=!0}),s(this,"MCaN",function(t,e){var n;"function"==typeof e&&((n=r.Jzbz[t]?r.Jzbz[t]:[]).push(e),r.Jzbz[t]=n,M.debug("Listeners list: ",r.Jzbz))}),s(this,"unregisterFromEvent",function(t,e){if(r.Jzbz[t]){for(var n=r.Jzbz[t],i=[],o=0;o<n.length;o++){var a=n[o];a!==e&&i.push(a)}r.Jzbz[t]=i}}),s(this,"kkta",function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"AE",n=e+"___"+t.name;r.LGDG(t,n,e)}),s(this,"LGDG",function(e,n,i){if(r.kgpd){if(M.debug("Notifying listeners for event: "+e+", "+n,r.Jzbz),r.Jzbz[n])for(var o=r.Jzbz[n],a=t.getController().getSDKRunningTimeInSec(),s=0;s<o.length;s++){(0,o[s])(i,e.name,a,e.additional_info)}}else r.ohdM.push({event:e,key:n,type:i})})}),L=window.ApxorLogger,R=function(){function e(){var r=this;return i(this,e),s(this,"WHSu",!1),s(this,"gbMj",null),s(this,"xElT",m()),s(this,"auCK",new Q),s(this,"dhYk",t.getSiteId()),s(this,"qSal",{}),s(this,"getQeState",function(){try{var e=t.getController().getFromStorage(q);return e?JSON.parse(g(r.dhYk,e)):(r.qSal={},r.setQeState())}catch(t){return r.qSal={},r.setQeState()}}),s(this,"setQeState",function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"";try{t.getController().persistToStorage(q,r.qSal,!0)}catch(n){""===e?r.qSal={}:r.qSal[e]={SESSION:0,OVERALL:0,DATES:{}},t.getController().persistToStorage(q,r.qSal,!0)}return r.qSal}),s(this,"initialize",function(){r.WHSu||(r.WHSu=!0,r.gbMj=new P,r.auCK.initialize(),r.qSal=r.getQeState(),L.info("QE Initialized.."))}),s(this,"parse",function(t){r.Kwhz()?(r.gbMj.parse(t),r.auCK.DWsN()):L.warn("Must call init first. Unable to proceed")}),s(this,"validate",function(t,e){r.Kwhz()&&r.gbMj.validate(t,e)}),s(this,"updateCount",function(t){try{l(r.qSal[t])||r.createObjConfig(t),r.incrementFrequencies(t),r.setQeState(t),r.gbMj.CgAS(t)}catch(t){console.log("Could not update the count config:".concat(t))}}),s(this,"resetFrequencyCounts",function(){r.gbMj.resetFrequencyCounts()}),s(this,"getFrequencyCount",function(t){return r.gbMj.getFrequencyCount(t)}),s(this,"registerForEvent",function(t,e){r.auCK.MCaN(t,e)}),s(this,"unregisterFromEvent",function(t,e){r.auCK.unregisterFromEvent(t,e)}),s(this,"fetch",function(e,r,n,i){t.getController().fetchConfiguration(e,r,n,i)}),s(this,"Kwhz",function(){return r.WHSu}),s(this,"getCampaignMetaFromQueryEngine",function(t){return r.gbMj.zjhq(t)}),s(this,"rDKN",function(){return r.xElT}),e.instance||(e.instance=this),e.instance}return a(e,[{key:"createObjConfig",value:function(t){try{this.qSal=this.getQeState(),l(this.qSal[t])||(this.qSal[t]={SESSION:0,OVERALL:0,DATES:{}},this.xElT&&(this.qSal[t].DATES[this.xElT]=0),this.setQeState(t))}catch(t){L.error("Can not create the frequency count object:"+t)}}},{key:"incrementFrequencies",value:function(t){this.qSal=this.getQeState();var e=this.qSal[t];e.SESSION=e.SESSION+1,e.OVERALL=e.OVERALL+1;var r=m();r===this.xElT&&e.DATES&&e.DATES[r]||(this.xElT=r,e.DATES={},e.DATES[this.xElT]=0),e.DATES[this.xElT]=e.DATES[this.xElT]+1}}],[{key:"getInstance",value:function(){return e.instance||(e.instance=new e),e.instance}}]),e}();s(R,"instance",void 0),window.ceVersion=121;try{void 0===exports&&null===exports||(exports.default=R,module.exports=exports.default)}catch(t){}return R});
|
|
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 f=function(t){return void 0!==t&&!function(t){return null===t}(t)},h="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=";function v(t,e){return Array.from(e).map(function(e,r){return String.fromCharCode(e^function(t,e){return t.charCodeAt(Math.floor(e%t.length))}(t,r))}).join("")}var d=function(t,e){return v(t,e=function(t){var e,r,n,i,o,a,s=0,u=[];if(!t)return t;t+="";do{e=(a=h.indexOf(t.charAt(s++))<<18|h.indexOf(t.charAt(s++))<<12|(i=h.indexOf(t.charAt(s++)))<<6|(o=h.indexOf(t.charAt(s++))))>>16&255,r=a>>8&255,n=255&a,u.push(e),64!==i&&(u.push(r),64!==o&&u.push(n))}while(s<t.length);return u}(e))},g=function(t){switch(t){case"app_event":return"AE";case"client_event":return"CE";case"activity_time":case"activity_event":return"AE"}return"Unknown"},p=function(t){return t.toUpperCase()},y=function(t,e,r){switch(r){case"EQ":return t===e;case"GT":return t>e;case"GTE":return t>=e;case"LT":return t<e;case"LTE":return t<=e;case"NEQ":return t!==e;case"R":return S(e).test(t);default:return!1}},S=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,j=a(function e(){var r=this;i(this,e),s(this,"ivYh","ALL"),s(this,"swAi",[]),s(this,"Cgrz",[]),s(this,"parse",function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};try{if(r.ivYh=t.audience.audience_type,r.swAi=t.audience.attributes.user,r.Cgrz=t.audience.attributes.session,!Array.isArray(r.swAi)||!Array.isArray(r.Cgrz))return _.error("No attributes"),!1}catch(t){return _.error(t),!1}return!0}),s(this,"validate",function(e,n){var i=!0;return"FTU"===r.ivYh&&(i=t.getController().getSessionInfo().is_first_session),i&&r.aGEF(e,r.swAi)&&r.aGEF(n,r.Cgrz)}),s(this,"aGEF",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 y(t,e,n)})});i=i&&u},a=0;a<r;a++){var s=o();if("object"===n(s))return s.v}}catch(t){_.error(t),i=!1}return i})}),b=window.ApxorLogger,N=a(function t(){var e=this;i(this,t),s(this,"QbNu",0),s(this,"Ahfz",0),s(this,"LAYA","SESSION"),s(this,"BUyy",0),s(this,"xPGq",0),s(this,"jvRb",0),s(this,"parse",function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};try{e.QbNu=t.frequency.count,e.jvRb=e.QbNu,e.Ahfz=t.frequency.time_interval,e.LAYA=t.frequency.validity,e.xPGq=t.frequency.ses_lmt,e._dayCount=t.frequency.day_lmt;var r=R.getInstance().getQeState();if(!f(r)||!f(r[t._id]))return!0;if("SESSION"===e.LAYA){if(e.QbNu=parseInt(e.QbNu)-parseInt(r[t._id].SESSION),e.QbNu<=0)return console.warn("Max count limit reached for session:"+t._id),!1}else{if("OVERALL"!==e.LAYA)return b.info("Invalid config."),!1;if(e.QbNu=parseInt(e.QbNu)-parseInt(r[t._id].OVERALL),e.QbNu<=0)return console.warn("Max count limit reached for overall:"+t._id),!1}}catch(t){return b.error(t),!1}return!0}),s(this,"cnxa",function(){e.QbNu=e.QbNu-1}),s(this,"getFrequencyCount",function(){return e.QbNu}),s(this,"zibq",function(){"SESSION"===e.LAYA&&(e.QbNu=e.jvRb,b.info("Campaign Limit reset"))}),s(this,"Yfir",function(t){try{if(e.QbNu<=0)return!1;var r=R.getInstance().getQeState();if(!f(r)||!f(r[t]))return!0;if(0!==e.xPGq)if(parseInt(e.xPGq)-parseInt(r[t].SESSION)<=0)return!1;if(0!==e._dayCount){var n,i=m();if(parseInt(e._dayCount)-parseInt((null===(n=r[t])||void 0===n?void 0:n.DATES[i])||0)<=0)return!1}}catch(t){b.error("Error validating the frequency:"+t)}return!0})}),x=a(function t(){var e=this;i(this,t),s(this,"vaGr",""),s(this,"ivYh",""),s(this,"parse",function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};try{var r;e.vaGr=t.meta.name,e.ivYh=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})}),A=window.ApxorLogger,E=a(function t(){var e=this;i(this,t),s(this,"kvkt",-1),s(this,"lgIh",-1),s(this,"CYCz",-1),s(this,"Qhzg",-1),s(this,"qZSX",!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 A.error("Not valid dates"),!1;if(e.kvkt=Date.parse(t.validity.start_date),e.lgIh=Date.parse(t.validity.end_date),f(t.time_limits_in_day)&&(e.qZSX=t.time_limits_in_day,e.qZSX&&f(t.time_limits))){var r=(new Date).toISOString().split("T")[0];if(e.CYCz=Date.parse(r+"T"+t.time_limits.start_time+".000Z"),e.Qhzg=Date.parse(r+"T"+t.time_limits.end_time+".000Z"),isNaN(e.CYCz)||isNaN(e.Qhzg))return A.error("Not valid times"),!1}}catch(t){return A.error(t),!1}return!0}),s(this,"validate",function(){var t=Date.now();return t>e.kvkt&&t<e.lgIh&&(!e.qZSX||t>=e.CYCz&&t<=e.Qhzg)})}),w=a(function t(){var e=this;i(this,t),s(this,"vaGr",""),s(this,"xhRu",{}),s(this,"parse",function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};try{e.vaGr=t.name,e.xhRu=t.additional_info}catch(t){return!1}return!0})}),O=a(function t(){var e=this;i(this,t),s(this,"TNxD",0),s(this,"kxyu",0),s(this,"parse",function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};try{if(e.TNxD=Number(t.lower),e.kxyu=Number(t.upper),isNaN(e.TNxD)||isNaN(e.kxyu))return!1}catch(t){return!1}return!0})}),C=a(function t(){var e=this;i(this,t),s(this,"zXLB",0),s(this,"VlYY",""),s(this,"SiPE",""),s(this,"ScWj",new w),s(this,"eLLb",new O),s(this,"parse",function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};try{return e.VlYY=t.event_type,e.SiPE=t.activity,e.ScWj.parse(t.details)&&e.eLLb.parse(t.time_bounds)}catch(t){return!1}})}),W=window.ApxorLogger,H=a(function t(){var e=this;i(this,t),s(this,"zXLB",0),s(this,"GiHC",-1),s(this,"QbNu",0),s(this,"Gpim",""),s(this,"SiPE",""),s(this,"VlYY",""),s(this,"eLLb",new O),s(this,"ScWj",new w),s(this,"GiPO",new C),s(this,"SIXE","AND"),s(this,"fJlK",!1),s(this,"ivYh",void 0),s(this,"parse",function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};try{return e.GiHC=t.sequence,e.QbNu=t.count_config.count,e.Gpim=t.count_config.operator,e.SiPE=t.activity,e.VlYY=t.event_type,e.SIXE=t.combine_operator,e.ivYh=t.type,e.ScWj.parse(t.details)&&e.GiPO.parse(t.trigger)&&e.eLLb.parse(t.time_bounds)}catch(t){return W.error(t),!1}})}),z=window.ApxorLogger,L=function(){function e(){var r=this;i(this,e),s(this,"WuXg",0),s(this,"VZgC",""),s(this,"jrHz",new H),s(this,"HpgP",!1),s(this,"jNsl",!1),s(this,"pyWB",0),s(this,"SIXE","AND"),s(this,"NQJv",-1),s(this,"lQVv",[]),s(this,"lajT",{}),s(this,"TgUk",!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.VZgC=n,r.pyWB=i,r.lQVv=a,r.jrHz.parse(e)){if(r.SIXE=r.jrHz.SIXE,r.jrHz.fJlK){var s=r.jrHz.ScWj.vaGr;"APX_PAGE_OPENED"===s&&(s=r.jrHz.ScWj.xhRu.navigation_id,s=f(s)?s:r.jrHz.ScWj.vaGr),r.NQJv=t.getController().getEventCount(s);var u=r.jrHz.QbNu,c=r.jrHz.Gpim;if(r.jNsl=r.HeFJ(r.NQJv-1,u,c,!1),r.HpgP=r.jNsl,r.jNsl&&"APX_PAGE_OPENED"===r.jrHz.ScWj.vaGr)return!0}return o&&0!==i||r.jirn(),!0}return!1}),s(this,"jirn",function(){var t=r.jrHz,e=t.GiPO,n=R.getInstance();"app_start"===e.VlYY?(r.HpgP=!0,n.registerForEvent(g(t.VlYY)+"___"+t.ScWj.vaGr,r.yfLP)):n.registerForEvent(g(t.VlYY)+"___"+e.ScWj.vaGr,r.yfLP)}),s(this,"vMTP",function(t,e,n,i){var o,a,s,u=(Date.now()-r.lajT[e])/1e3;(null===(o=r.jrHz)||void 0===o?void 0:null===(a=o.ScWj)||void 0===a?void 0:null===(s=a.xhRu)||void 0===s?void 0:s.time)/1e3>u&&r._displayCampaign(n)}),s(this,"xJxT",function(t,e,n,i){var o,a,s,u,c;r.TgUk=!0;var l=Date.now(),f=null===(o=r.jrHz)||void 0===o?void 0:null===(a=o.GiPO)||void 0===a?void 0:a.ScWj.vaGr,h=(l-r.lajT[f])/1e3,v=null===(s=r.jrHz)||void 0===s?void 0:null===(u=s.ScWj)||void 0===u?void 0:null===(c=u.xhRu)||void 0===c?void 0:c.time;(v/=1e3)>h&&r._displayCampaign(n)}),s(this,"yfLP",function(t,e,n,i){var o=R.getInstance();if(r.HpgP)g(r.jrHz.VlYY)===t&&r.VwBV(n-r.jrHz.GiPO.zXLB,r.jrHz.eLLb)&&r.jrHz.ScWj.vaGr===e&&r.ltAR(r.jrHz.ScWj.xhRu,i)&&(r.WuXg+=1,r.jNsl=r.HeFJ(r.WuXg,r.jrHz.QbNu,r.jrHz.Gpim),r.jNsl&&(r.jrHz.zXLB=n,o.validate(r.VZgC,r.pyWB)));else if(r.HpgP=r.XLRj(t,e,n,i),r.HpgP){var a=r.jrHz,s=a.GiPO;if(s.zXLB=n,"activity_time"===(null==a?void 0:a.VlYY)){var u,c,l,f,h,v,d=null==a?void 0:null===(u=a.ScWj)||void 0===u?void 0:null===(c=u.xhRu)||void 0===c?void 0:c.time;(null==a?void 0:null===(l=a.ScWj)||void 0===l?void 0:null===(f=l.xhRu)||void 0===f?void 0:f.nkpi.length)>0&&(setTimeout(function(){r.TgUk||(r.jNsl=!0,r.jNsl&&(r.WuXg+=1,r.jNsl=r.HeFJ(r.WuXg,r.jrHz.QbNu,r.jrHz.Gpim),r.jNsl&&(r.jrHz.zXLB=n,o.validate(r.VZgC,r.pyWB)))),a.ScWj.xhRu.nkpi.map(function(t){o.unregisterFromEvent(p(a.ScWj.xhRu.et)+"___"+t,r)})},d),a.ScWj.xhRu.nkpi.map(function(t){o.registerForEvent(p(a.ScWj.xhRu.et)+"___"+t,r.xJxT)})),(null==a?void 0:null===(h=a.ScWj)||void 0===h?void 0:null===(v=h.xhRu)||void 0===v?void 0:v.kpi.length)>0&&(setTimeout(function(){a.ScWj.xhRu.kpi.map(function(t){o.unregisterFromEvent(p(a.ScWj.xhRu.et)+"___"+t,r)})},d),a.ScWj.xhRu.kpi.map(function(t){t===a.GiPO.ScWj.vaGr?(o.unregisterFromEvent(g(s.VlYY)+"___"+s.ScWj.vaGr,r),o.registerForEvent(p(a.ScWj.xhRu.et)+"___"+t,r.vMTP)):o.registerForEvent(p(a.ScWj.xhRu.et)+"___"+t,r.xJxT)}))}else o.unregisterFromEvent(g(s.VlYY)+"___"+s.ScWj.vaGr,r),o.registerForEvent(g(a.VlYY)+"___"+a.ScWj.vaGr,r);r.lajT[e]=Date.now()}}),s(this,"XLRj",function(t,e,n,i){var o=r.jrHz.GiPO;return g(o.VlYY)===t&&o.ScWj.vaGr===e&&r.VwBV(n,o.eLLb)&&r.ltAR(o.ScWj.xhRu,i)}),s(this,"VwBV",function(t,e){var r=Math.ceil(t);return r>e.TNxD&&r<e.kxyu}),s(this,"HeFJ",function(t,e,n){switch((!(arguments.length>3&&void 0!==arguments[3])||arguments[3])&&r.jrHz.fJlK&&(t+=r.NQJv),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,"ltAR",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 y(t,i,a)});r=r&&u}else r=r&&y(e[o],t[o],"EQ")};for(var o in t){var a=i();if("object"===n(a))return a.v}}catch(t){z.error(t),r=!1}return r})}return a(e,[{key:"_displayCampaign",value:function(t){var e=R.getInstance();this.jNsl=!0,this.jNsl&&(this.WuXg+=1,this.jNsl=this.HeFJ(this.WuXg,this.jrHz.QbNu,this.jrHz.Gpim),this.jNsl&&(this.jrHz.zXLB=t,e.validate(this.VZgC,this.pyWB)))}}]),e}(),X="qe_state",F=window.ApxorLogger,G=a(function e(){var r=this;i(this,e),s(this,"sZzG",[]),s(this,"_ret_day",{}),s(this,"Xzos",{}),s(this,"oFUv",!1),s(this,"UFdW",!1),s(this,"parse",function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};try{r.sZzG=t.overall_cfg.events,r._ret_day=t.overall_cfg.ret_day,r.Xzos=t.overall_cfg.session,r.oFUv=t.overall_cfg.toggleRetDay,r.sZzG=t.overall_cfg.events,r.UFdW=t.overall_cfg.toggleSession}catch(t){return F.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.oFUv&&!isNaN(e)&&!(e>=r._ret_day.from&&e<=r._ret_day.to))return!1;if(r.UFdW&&!isNaN(n)&&!(n>=r.Xzos.from&&n<=r.Xzos.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.sZzG.length;s++){if(a[r.sZzG[s].name.replace("'","").replace("’","")])return!1}}catch(t){F.error("Failed to validate the lt count:"+t)}return!0})}),I=window.ApxorLogger,Y=a(function e(){var n=this;i(this,e),s(this,"oaNf",[]),s(this,"VZgC",""),s(this,"HSbO",new x),s(this,"ougI",new j),s(this,"LAYA",new E),s(this,"NJhT",new N),s(this,"FIof",new G),s(this,"xPmO",!1),s(this,"GmJY",[]),s(this,"parse",function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};try{if(!f(t._id))return I.error("No Id"),!1;if(!f(t.enabled)||!t.enabled)return I.error("Not enabled"),!1;if(!(n.HSbO.parse(t)&&n.LAYA.parse(t)&&n.NJhT.parse(t)&&n.ougI.parse(t)&&n.FIof.parse(t)))return!1;if(!f(t.conditions)||!Array.isArray(t.conditions))return I.error("No valid conditions",t.conditions),!1;n.VZgC=t._id,n.xPmO=!!f(t.sequence_enabled)&&t.sequence_enabled,n.xPmO&&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.GmJY=[];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.GmJY=[].concat(u(n.GmJY),[c])}var l=new L;l.initialize(o,n.VZgC,i,n.xPmO,n.GmJY)&&n.oaNf.push(l)}return n.oaNf.length>0}catch(t){return I.error(t),!1}}),s(this,"GBBl",function(t){if(!(t<0))if(n.xPmO){var e=n.oaNf[t];if(f(e)&&e.jNsl){var r=n.oaNf[t-1];if(f(r)&&!r.jNsl)return;var i=n.oaNf[t+1];f(i)?i.jirn():n.Bmfx()}}else n.Bmfx()}),s(this,"Bmfx",function(){var e=t.getController().getUserAttributes(),i=t.getController().getSessionAttributes();if(n.LAYA.validate()&&n.ougI.validate(e,i)&&n.FIof.validate()){for(var o=n.oaNf.length,a=o<1,s="",u=0;u<o;u++){var c=n.oaNf[u],l=c.jNsl;if(""===s.trim())a=l;else switch(s){case"AND":a=a&&l;break;case"OR":a=a||l}s=c.SIXE}if(a){if(console.debug("onCondition satisfied"),!n.NJhT.Yfir(n.VZgC))return void console.warn("Maximum limit reached",n.VZgC);console.log("Dispatching event",n.HSbO.ivYh),!0===n.HSbO._only_context&&t.logEvent("apx_context_evaluated",r(r({},n.HSbO._attr),{},{message_name:n.HSbO.vaGr,id:n.VZgC})),t.getController().dispatchEvent(n.HSbO.ivYh,{name:n.HSbO.ivYh,additional_info:{uuid:n.VZgC,name:n.HSbO.vaGr}})}}}),s(this,"cnxa",function(){n.NJhT.cnxa()}),s(this,"getFrequencyCount",function(){return n.NJhT.getFrequencyCount()}),s(this,"NFqM",function(){return n.NJhT.zibq()})}),T=a(function t(){var e=this;i(this,t),s(this,"lljB",{}),s(this,"parse",function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{configs:[]};if(f(t)&&f(t.configs)){var r=t.configs;if(!Array.isArray(r))return;r.sort(function(t,e){var r,n;return(null!==(r=t.prio)&&void 0!==r?r:-1)-(null!==(n=e.prio)&&void 0!==n?n:-1)});for(var n=0;n<r.length;n++){var i=r[n],o=i._id,a=new Y;a.parse(i)?e.lljB[o]=a:console.warn("Failed to parse cfg",o)}}}),s(this,"validate",function(t,r){e.lljB[t]&&e.lljB[t].GBBl(r)}),s(this,"cnxa",function(t){e.lljB[t].cnxa()}),s(this,"getFrequencyCount",function(t){return e.lljB[t].getFrequencyCount()}),s(this,"resetFrequencyCounts",function(){var t=e.lljB;for(var r in t)t[r].NFqM()}),s(this,"YDSO",function(t){try{if(e.lljB){var r=e.lljB[t];if(r&&r.HSbO)return r.HSbO}}catch(t){console.log("Error in getting the campaign meta ".concat(t))}return{}})}),P=window.ApxorLogger,Q=a(function e(){var r=this;i(this,e),s(this,"xUpW",{}),s(this,"dRvR",[]),s(this,"DDNd",!1),s(this,"initialize",function(){var e=t.getController();e.registerForEvent("APP_EVENT",function(t){return r.IsCi(t,"AE")}),e.registerForEvent("CLIENT_EVENT",function(t){return r.IsCi(t,"CE")})}),s(this,"ndnI",function(){for(var t in r.dRvR)r.Fzta(t.event,t.key,t.type);r.DDNd=!0}),s(this,"QOqX",function(t,e){var n;"function"==typeof e&&((n=r.xUpW[t]?r.xUpW[t]:[]).push(e),r.xUpW[t]=n,P.debug("Listeners list: ",r.xUpW))}),s(this,"unregisterFromEvent",function(t,e){if(r.xUpW[t]){for(var n=r.xUpW[t],i=[],o=0;o<n.length;o++){var a=n[o];a!==e&&i.push(a)}r.xUpW[t]=i}}),s(this,"IsCi",function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"AE",n=e+"___"+t.name;r.Fzta(t,n,e)}),s(this,"Fzta",function(e,n,i){if(r.DDNd){if(P.debug("Notifying listeners for event: "+e+", "+n,r.xUpW),r.xUpW[n])for(var o=r.xUpW[n],a=t.getController().getSDKRunningTimeInSec(),s=0;s<o.length;s++){(0,o[s])(i,e.name,a,e.additional_info)}}else r.dRvR.push({event:e,key:n,type:i})})}),k=window.ApxorLogger,R=function(){function e(){var r=this;return i(this,e),s(this,"XRon",!1),s(this,"KSfx",null),s(this,"kkXn",m()),s(this,"fOwS",new Q),s(this,"NhQg",t.getSiteId()),s(this,"WXHd",{}),s(this,"getQeState",function(){try{var e=t.getController().getFromStorage(X);return e?JSON.parse(d(r.NhQg,e)):(r.WXHd={},r.setQeState())}catch(t){return r.WXHd={},r.setQeState()}}),s(this,"setQeState",function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"";try{t.getController().persistToStorage(X,r.WXHd,!0)}catch(n){""===e?r.WXHd={}:r.WXHd[e]={SESSION:0,OVERALL:0,DATES:{}},t.getController().persistToStorage(X,r.WXHd,!0)}return r.WXHd}),s(this,"initialize",function(){r.XRon||(r.XRon=!0,r.KSfx=new T,r.fOwS.initialize(),r.WXHd=r.getQeState(),k.info("QE Initialized.."))}),s(this,"parse",function(t){r.HAyL()?(r.KSfx.parse(t),r.fOwS.ndnI()):k.warn("Must call init first. Unable to proceed")}),s(this,"validate",function(t,e){r.HAyL()&&r.KSfx.validate(t,e)}),s(this,"updateCount",function(t){try{f(r.WXHd[t])||r.createObjConfig(t),r.incrementFrequencies(t),r.setQeState(t),r.KSfx.cnxa(t)}catch(t){console.log("Could not update the count config:".concat(t))}}),s(this,"resetFrequencyCounts",function(){r.KSfx.resetFrequencyCounts()}),s(this,"getFrequencyCount",function(t){return r.KSfx.getFrequencyCount(t)}),s(this,"registerForEvent",function(t,e){r.fOwS.QOqX(t,e)}),s(this,"unregisterFromEvent",function(t,e){r.fOwS.unregisterFromEvent(t,e)}),s(this,"fetch",function(e,r,n,i){t.getController().fetchConfiguration(e,r,n,i)}),s(this,"HAyL",function(){return r.XRon}),s(this,"getCampaignMetaFromQueryEngine",function(t){return r.KSfx.YDSO(t)}),s(this,"mDOI",function(){return r.kkXn}),e.instance||(e.instance=this),e.instance}return a(e,[{key:"createObjConfig",value:function(t){try{this.WXHd=this.getQeState(),f(this.WXHd[t])||(this.WXHd[t]={SESSION:0,OVERALL:0,DATES:{}},this.kkXn&&(this.WXHd[t].DATES[this.kkXn]=0),this.setQeState(t))}catch(t){k.error("Can not create the frequency count object:"+t)}}},{key:"incrementFrequencies",value:function(t){this.WXHd=this.getQeState();var e=this.WXHd[t];e.SESSION=e.SESSION+1,e.OVERALL=e.OVERALL+1;var r=m();r===this.kkXn&&e.DATES&&e.DATES[r]||(this.kkXn=r,e.DATES={},e.DATES[this.kkXn]=0),e.DATES[this.kkXn]=e.DATES[this.kkXn]+1}}],[{key:"getInstance",value:function(){return e.instance||(e.instance=new e),e.instance}}]),e}();s(R,"instance",void 0),window.ceVersion=121;try{void 0===exports&&null===exports||(exports.default=R,module.exports=exports.default)}catch(t){}return R});
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "apxor-qe",
|
|
3
|
-
"version": "1.2.1
|
|
3
|
+
"version": "1.2.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.0.1
|
|
55
|
+
"apxor": "2.0.1"
|
|
56
56
|
},
|
|
57
57
|
"files": [
|
|
58
58
|
"dist"
|