@guardian/ab-core
Advanced tools
Comparing version 1.0.0-next.0 to 1.0.1-next.0
@@ -1,2 +0,2 @@ | ||
function e(){return(e=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e}).apply(this,arguments)}var t=function(){},n=function(e,t){return t({abTestRegister:e})},r=function(e,t){var n={variantName:e.id,complete:t};return e.campaignCode&&(n.campaignCodes=[e.campaignCode]),n},i=function(e){return e.variants.every(function(e){return"function"==typeof e.impression})},s=function(e,i,s){return function(a){var o=a.variantToRun,u=(e?o.success:o.impression)||t;try{u(function(e,t,i,s){var a,o=((a={})[e.id]=r(t,i),a);return function(){return n(o,s)}}(a,o,e,s))}catch(e){i(e,{},!1)}}};exports.AB=function(){function t(t){var a=t.serverSideTests,o=t.errorReporter,u=t.ophanRecord,c=function(t){var n=t.mvtMaxValue,r=void 0===n?1e6:n,i=t.mvtId,s=t.pageIsSensitive,a=t.abTestSwitches,o=t.forcedTestVariant,u=t.forcedTestException,c=t.arrayOfTestObjects,f=void 0===c?[]:c,l=function(t){var n,c,f=function(e){var t=r*e.audienceOffset,n=t+r*e.audience;return console.log(e.variants),console.log(i),i&&i>t&&i<=n?e.variants[i%e.variants.length]:null}(t),l=o&&o.testId===t.id&&o.variant||f;return u!==t.id&&function(e){var t,n=(t=e.expiry,(new Date).valueOf()>new Date(t).setHours(23,59,59,59)),r=!!e.showForSensitive,i=a["ab"+e.id]&&!!a["ab"+e.id],o=!e.canRun||e.canRun();return(!s||r)&&i&&!n&&o}(t)&&l&&(c="notintest"!==(n=l).id,n.canRun?n.canRun()&&c:c)?e({},t,{variantToRun:l}):null},v=function(e){return e.reduce(function(e,t){var n=l(t);return n?[].concat(e,[n]):e},[])};return{allRunnableTests:v,runnableTest:l,firstRunnableTest:function(e){return e.map(function(e){return l(e)}).find(function(e){return null!==e})||null},isUserInVariant:function(e,t){return v(f).some(function(n){return n.id===e&&n.variantToRun.id===t})}}}({mvtMaxValue:t.mvtMaxValue,mvtId:t.mvtId,pageIsSensitive:t.pageIsSensitive,abTestSwitches:t.abTestSwitches,forcedTestVariant:t.forcedTestVariant,forcedTestException:t.forcedTestException,arrayOfTestObjects:t.arrayOfTestObjects}),f=function(e){var t=e.serverSideTests,a=void 0===t?{}:t,o=e.errorReporter,u=void 0===o?function(){}:o,c=e.ophanRecord,f=void 0===c?function(){}:c;return{registerCompleteEvents:function(e){return e.forEach(s(!0,u,f))},registerImpressionEvents:function(e){console.log("registering impression events"),console.log(e),console.log("registering for",e.filter(i)),e.filter(i).forEach(s(!1,u,f))},trackABTests:function(e){return n(function(e,t,n){try{var s={},a=Object.keys(n).filter(function(e){return!!n[e]});return e.filter(function(e){return!i(e)}).forEach(function(e){s[e.id]=r(e.variantToRun,!1)}),a.forEach(function(e){s["ab"+e]=r({id:"inTest",test:function(){}},!1)}),s}catch(e){return t(e,{},!1),{}}}(e,u,a),f)}}}({serverSideTests:a,errorReporter:o,ophanRecord:u});this._allRunnableTests=c.allRunnableTests,this._firstRunnableTest=c.firstRunnableTest,this._runnableTest=c.runnableTest,this._isUserInVariant=c.isUserInVariant,this._registerCompleteEvents=f.registerCompleteEvents,this._registerImpressionEvents=f.registerImpressionEvents,this._trackABTests=f.trackABTests}var a;return(a=[{key:"allRunnableTests",get:function(){return this._allRunnableTests}},{key:"firstRunnableTest",get:function(){return this._firstRunnableTest}},{key:"runnableTest",get:function(){return this._runnableTest}},{key:"isUserInVariant",get:function(){return this._isUserInVariant}},{key:"registerCompleteEvents",get:function(){return this._registerCompleteEvents}},{key:"registerImpressionEvents",get:function(){return this._registerImpressionEvents}},{key:"trackABTests",get:function(){return this._trackABTests}}])&&function(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}(t.prototype,a),t}(); | ||
function e(){return(e=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e}).apply(this,arguments)}var t=function(){},n=function(e,t){return t({abTestRegister:e})},r=function(e,t){var n={variantName:e.id,complete:t};return e.campaignCode&&(n.campaignCodes=[e.campaignCode]),n},i=function(e){return e.variants.every(function(e){return"function"==typeof e.impression})},s=function(e,i,s){return function(a){var u=a.variantToRun,o=(e?u.success:u.impression)||t;try{o(function(e,t,i,s){var a,u=((a={})[e.id]=r(t,i),a);return function(){return n(u,s)}}(a,u,e,s))}catch(e){i(e,{},!1)}}};exports.AB=function(){function t(t){var a=t.serverSideTests,u=t.errorReporter,o=t.ophanRecord,c=function(t){var n=t.mvtMaxValue,r=void 0===n?1e6:n,i=t.mvtId,s=t.pageIsSensitive,a=t.abTestSwitches,u=t.forcedTestVariant,o=t.forcedTestException,c=t.arrayOfTestObjects,f=void 0===c?[]:c,v=function(t){var n,c,f=function(e){var t=r*e.audienceOffset;return i&&i>t&&i<=t+r*e.audience?e.variants[i%e.variants.length]:null}(t),v=u&&u.testId===t.id&&u.variant||f;return o!==t.id&&function(e){var t,n=(t=e.expiry,(new Date).valueOf()>new Date(t).setHours(23,59,59,59)),r=!!e.showForSensitive,i=a["ab"+e.id]&&!!a["ab"+e.id],u=!e.canRun||e.canRun();return(!s||r)&&i&&!n&&u}(t)&&v&&(c="notintest"!==(n=v).id,n.canRun?n.canRun()&&c:c)?e({},t,{variantToRun:v}):null},l=function(e){return e.reduce(function(e,t){var n=v(t);return n?[].concat(e,[n]):e},[])};return{allRunnableTests:l,runnableTest:v,firstRunnableTest:function(e){return e.map(function(e){return v(e)}).find(function(e){return null!==e})||null},isUserInVariant:function(e,t){return l(f).some(function(n){return n.id===e&&n.variantToRun.id===t})}}}({mvtMaxValue:t.mvtMaxValue,mvtId:t.mvtId,pageIsSensitive:t.pageIsSensitive,abTestSwitches:t.abTestSwitches,forcedTestVariant:t.forcedTestVariant,forcedTestException:t.forcedTestException,arrayOfTestObjects:t.arrayOfTestObjects}),f=function(e){var t=e.serverSideTests,a=void 0===t?{}:t,u=e.errorReporter,o=void 0===u?function(){}:u,c=e.ophanRecord,f=void 0===c?function(){}:c;return{registerCompleteEvents:function(e){return e.forEach(s(!0,o,f))},registerImpressionEvents:function(e){e.filter(i).forEach(s(!1,o,f))},trackABTests:function(e){return n(function(e,t,n){try{var s={},a=Object.keys(n).filter(function(e){return!!n[e]});return e.filter(function(e){return!i(e)}).forEach(function(e){s[e.id]=r(e.variantToRun,!1)}),a.forEach(function(e){s["ab"+e]=r({id:"inTest",test:function(){}},!1)}),s}catch(e){return t(e,{},!1),{}}}(e,o,a),f)}}}({serverSideTests:a,errorReporter:u,ophanRecord:o});this._allRunnableTests=c.allRunnableTests,this._firstRunnableTest=c.firstRunnableTest,this._runnableTest=c.runnableTest,this._isUserInVariant=c.isUserInVariant,this._registerCompleteEvents=f.registerCompleteEvents,this._registerImpressionEvents=f.registerImpressionEvents,this._trackABTests=f.trackABTests}var a;return(a=[{key:"allRunnableTests",get:function(){return this._allRunnableTests}},{key:"firstRunnableTest",get:function(){return this._firstRunnableTest}},{key:"runnableTest",get:function(){return this._runnableTest}},{key:"isUserInVariant",get:function(){return this._isUserInVariant}},{key:"registerCompleteEvents",get:function(){return this._registerCompleteEvents}},{key:"registerImpressionEvents",get:function(){return this._registerImpressionEvents}},{key:"trackABTests",get:function(){return this._trackABTests}}])&&function(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}(t.prototype,a),t}(); | ||
//# sourceMappingURL=index.js.map |
@@ -1,2 +0,2 @@ | ||
function e(){return(e=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e}).apply(this,arguments)}var t=function(){},n=function(e,t){return t({abTestRegister:e})},r=function(e,t){var n={variantName:e.id,complete:t};return e.campaignCode&&(n.campaignCodes=[e.campaignCode]),n},i=function(e){return e.variants.every(function(e){return"function"==typeof e.impression})},s=function(e,i,s){return function(a){var o=a.variantToRun,u=(e?o.success:o.impression)||t;try{u(function(e,t,i,s){var a,o=((a={})[e.id]=r(t,i),a);return function(){return n(o,s)}}(a,o,e,s))}catch(e){i(e,{},!1)}}},a=function(){function t(t){var a=t.serverSideTests,o=t.errorReporter,u=t.ophanRecord,c=function(t){var n=t.mvtMaxValue,r=void 0===n?1e6:n,i=t.mvtId,s=t.pageIsSensitive,a=t.abTestSwitches,o=t.forcedTestVariant,u=t.forcedTestException,c=t.arrayOfTestObjects,f=void 0===c?[]:c,l=function(t){var n,c,f=function(e){var t=r*e.audienceOffset,n=t+r*e.audience;return console.log(e.variants),console.log(i),i&&i>t&&i<=n?e.variants[i%e.variants.length]:null}(t),l=o&&o.testId===t.id&&o.variant||f;return u!==t.id&&function(e){var t,n=(t=e.expiry,(new Date).valueOf()>new Date(t).setHours(23,59,59,59)),r=!!e.showForSensitive,i=a["ab"+e.id]&&!!a["ab"+e.id],o=!e.canRun||e.canRun();return(!s||r)&&i&&!n&&o}(t)&&l&&(c="notintest"!==(n=l).id,n.canRun?n.canRun()&&c:c)?e({},t,{variantToRun:l}):null},v=function(e){return e.reduce(function(e,t){var n=l(t);return n?[].concat(e,[n]):e},[])};return{allRunnableTests:v,runnableTest:l,firstRunnableTest:function(e){return e.map(function(e){return l(e)}).find(function(e){return null!==e})||null},isUserInVariant:function(e,t){return v(f).some(function(n){return n.id===e&&n.variantToRun.id===t})}}}({mvtMaxValue:t.mvtMaxValue,mvtId:t.mvtId,pageIsSensitive:t.pageIsSensitive,abTestSwitches:t.abTestSwitches,forcedTestVariant:t.forcedTestVariant,forcedTestException:t.forcedTestException,arrayOfTestObjects:t.arrayOfTestObjects}),f=function(e){var t=e.serverSideTests,a=void 0===t?{}:t,o=e.errorReporter,u=void 0===o?function(){}:o,c=e.ophanRecord,f=void 0===c?function(){}:c;return{registerCompleteEvents:function(e){return e.forEach(s(!0,u,f))},registerImpressionEvents:function(e){console.log("registering impression events"),console.log(e),console.log("registering for",e.filter(i)),e.filter(i).forEach(s(!1,u,f))},trackABTests:function(e){return n(function(e,t,n){try{var s={},a=Object.keys(n).filter(function(e){return!!n[e]});return e.filter(function(e){return!i(e)}).forEach(function(e){s[e.id]=r(e.variantToRun,!1)}),a.forEach(function(e){s["ab"+e]=r({id:"inTest",test:function(){}},!1)}),s}catch(e){return t(e,{},!1),{}}}(e,u,a),f)}}}({serverSideTests:a,errorReporter:o,ophanRecord:u});this._allRunnableTests=c.allRunnableTests,this._firstRunnableTest=c.firstRunnableTest,this._runnableTest=c.runnableTest,this._isUserInVariant=c.isUserInVariant,this._registerCompleteEvents=f.registerCompleteEvents,this._registerImpressionEvents=f.registerImpressionEvents,this._trackABTests=f.trackABTests}var a;return(a=[{key:"allRunnableTests",get:function(){return this._allRunnableTests}},{key:"firstRunnableTest",get:function(){return this._firstRunnableTest}},{key:"runnableTest",get:function(){return this._runnableTest}},{key:"isUserInVariant",get:function(){return this._isUserInVariant}},{key:"registerCompleteEvents",get:function(){return this._registerCompleteEvents}},{key:"registerImpressionEvents",get:function(){return this._registerImpressionEvents}},{key:"trackABTests",get:function(){return this._trackABTests}}])&&function(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}(t.prototype,a),t}();export{a as AB}; | ||
function e(){return(e=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e}).apply(this,arguments)}var t=function(){},n=function(e,t){return t({abTestRegister:e})},r=function(e,t){var n={variantName:e.id,complete:t};return e.campaignCode&&(n.campaignCodes=[e.campaignCode]),n},i=function(e){return e.variants.every(function(e){return"function"==typeof e.impression})},s=function(e,i,s){return function(a){var u=a.variantToRun,o=(e?u.success:u.impression)||t;try{o(function(e,t,i,s){var a,u=((a={})[e.id]=r(t,i),a);return function(){return n(u,s)}}(a,u,e,s))}catch(e){i(e,{},!1)}}},a=function(){function t(t){var a=t.serverSideTests,u=t.errorReporter,o=t.ophanRecord,c=function(t){var n=t.mvtMaxValue,r=void 0===n?1e6:n,i=t.mvtId,s=t.pageIsSensitive,a=t.abTestSwitches,u=t.forcedTestVariant,o=t.forcedTestException,c=t.arrayOfTestObjects,f=void 0===c?[]:c,v=function(t){var n,c,f=function(e){var t=r*e.audienceOffset;return i&&i>t&&i<=t+r*e.audience?e.variants[i%e.variants.length]:null}(t),v=u&&u.testId===t.id&&u.variant||f;return o!==t.id&&function(e){var t,n=(t=e.expiry,(new Date).valueOf()>new Date(t).setHours(23,59,59,59)),r=!!e.showForSensitive,i=a["ab"+e.id]&&!!a["ab"+e.id],u=!e.canRun||e.canRun();return(!s||r)&&i&&!n&&u}(t)&&v&&(c="notintest"!==(n=v).id,n.canRun?n.canRun()&&c:c)?e({},t,{variantToRun:v}):null},l=function(e){return e.reduce(function(e,t){var n=v(t);return n?[].concat(e,[n]):e},[])};return{allRunnableTests:l,runnableTest:v,firstRunnableTest:function(e){return e.map(function(e){return v(e)}).find(function(e){return null!==e})||null},isUserInVariant:function(e,t){return l(f).some(function(n){return n.id===e&&n.variantToRun.id===t})}}}({mvtMaxValue:t.mvtMaxValue,mvtId:t.mvtId,pageIsSensitive:t.pageIsSensitive,abTestSwitches:t.abTestSwitches,forcedTestVariant:t.forcedTestVariant,forcedTestException:t.forcedTestException,arrayOfTestObjects:t.arrayOfTestObjects}),f=function(e){var t=e.serverSideTests,a=void 0===t?{}:t,u=e.errorReporter,o=void 0===u?function(){}:u,c=e.ophanRecord,f=void 0===c?function(){}:c;return{registerCompleteEvents:function(e){return e.forEach(s(!0,o,f))},registerImpressionEvents:function(e){e.filter(i).forEach(s(!1,o,f))},trackABTests:function(e){return n(function(e,t,n){try{var s={},a=Object.keys(n).filter(function(e){return!!n[e]});return e.filter(function(e){return!i(e)}).forEach(function(e){s[e.id]=r(e.variantToRun,!1)}),a.forEach(function(e){s["ab"+e]=r({id:"inTest",test:function(){}},!1)}),s}catch(e){return t(e,{},!1),{}}}(e,o,a),f)}}}({serverSideTests:a,errorReporter:u,ophanRecord:o});this._allRunnableTests=c.allRunnableTests,this._firstRunnableTest=c.firstRunnableTest,this._runnableTest=c.runnableTest,this._isUserInVariant=c.isUserInVariant,this._registerCompleteEvents=f.registerCompleteEvents,this._registerImpressionEvents=f.registerImpressionEvents,this._trackABTests=f.trackABTests}var a;return(a=[{key:"allRunnableTests",get:function(){return this._allRunnableTests}},{key:"firstRunnableTest",get:function(){return this._firstRunnableTest}},{key:"runnableTest",get:function(){return this._runnableTest}},{key:"isUserInVariant",get:function(){return this._isUserInVariant}},{key:"registerCompleteEvents",get:function(){return this._registerCompleteEvents}},{key:"registerImpressionEvents",get:function(){return this._registerImpressionEvents}},{key:"trackABTests",get:function(){return this._trackABTests}}])&&function(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}(t.prototype,a),t}();export{a as AB}; | ||
//# sourceMappingURL=index.modern.js.map |
@@ -1,2 +0,2 @@ | ||
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports):"function"==typeof define&&define.amd?define(["exports"],t):t((e=e||self).abCore={})}(this,function(e){function t(){return(t=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e}).apply(this,arguments)}var n=function(){},r=function(e,t){return t({abTestRegister:e})},i=function(e,t){var n={variantName:e.id,complete:t};return e.campaignCode&&(n.campaignCodes=[e.campaignCode]),n},s=function(e){return e.variants.every(function(e){return"function"==typeof e.impression})},o=function(e,t,s){return function(o){var a=o.variantToRun,u=(e?a.success:a.impression)||n;try{u(function(e,t,n,s){var o,a=((o={})[e.id]=i(t,n),o);return function(){return r(a,s)}}(o,a,e,s))}catch(e){t(e,{},!1)}}};e.AB=function(){function e(e){var n=e.serverSideTests,a=e.errorReporter,u=e.ophanRecord,c=function(e){var n=e.mvtMaxValue,r=void 0===n?1e6:n,i=e.mvtId,s=e.pageIsSensitive,o=e.abTestSwitches,a=e.forcedTestVariant,u=e.forcedTestException,c=e.arrayOfTestObjects,f=void 0===c?[]:c,l=function(e){var n,c,f=function(e){var t=r*e.audienceOffset,n=t+r*e.audience;return console.log(e.variants),console.log(i),i&&i>t&&i<=n?e.variants[i%e.variants.length]:null}(e),l=a&&a.testId===e.id&&a.variant||f;return u!==e.id&&function(e){var t,n=(t=e.expiry,(new Date).valueOf()>new Date(t).setHours(23,59,59,59)),r=!!e.showForSensitive,i=o["ab"+e.id]&&!!o["ab"+e.id],a=!e.canRun||e.canRun();return(!s||r)&&i&&!n&&a}(e)&&l&&(c="notintest"!==(n=l).id,n.canRun?n.canRun()&&c:c)?t({},e,{variantToRun:l}):null},v=function(e){return e.reduce(function(e,t){var n=l(t);return n?[].concat(e,[n]):e},[])};return{allRunnableTests:v,runnableTest:l,firstRunnableTest:function(e){return e.map(function(e){return l(e)}).find(function(e){return null!==e})||null},isUserInVariant:function(e,t){return v(f).some(function(n){return n.id===e&&n.variantToRun.id===t})}}}({mvtMaxValue:e.mvtMaxValue,mvtId:e.mvtId,pageIsSensitive:e.pageIsSensitive,abTestSwitches:e.abTestSwitches,forcedTestVariant:e.forcedTestVariant,forcedTestException:e.forcedTestException,arrayOfTestObjects:e.arrayOfTestObjects}),f=function(e){var t=e.serverSideTests,n=void 0===t?{}:t,a=e.errorReporter,u=void 0===a?function(){}:a,c=e.ophanRecord,f=void 0===c?function(){}:c;return{registerCompleteEvents:function(e){return e.forEach(o(!0,u,f))},registerImpressionEvents:function(e){console.log("registering impression events"),console.log(e),console.log("registering for",e.filter(s)),e.filter(s).forEach(o(!1,u,f))},trackABTests:function(e){return r(function(e,t,n){try{var r={},o=Object.keys(n).filter(function(e){return!!n[e]});return e.filter(function(e){return!s(e)}).forEach(function(e){r[e.id]=i(e.variantToRun,!1)}),o.forEach(function(e){r["ab"+e]=i({id:"inTest",test:function(){}},!1)}),r}catch(e){return t(e,{},!1),{}}}(e,u,n),f)}}}({serverSideTests:n,errorReporter:a,ophanRecord:u});this._allRunnableTests=c.allRunnableTests,this._firstRunnableTest=c.firstRunnableTest,this._runnableTest=c.runnableTest,this._isUserInVariant=c.isUserInVariant,this._registerCompleteEvents=f.registerCompleteEvents,this._registerImpressionEvents=f.registerImpressionEvents,this._trackABTests=f.trackABTests}var n;return(n=[{key:"allRunnableTests",get:function(){return this._allRunnableTests}},{key:"firstRunnableTest",get:function(){return this._firstRunnableTest}},{key:"runnableTest",get:function(){return this._runnableTest}},{key:"isUserInVariant",get:function(){return this._isUserInVariant}},{key:"registerCompleteEvents",get:function(){return this._registerCompleteEvents}},{key:"registerImpressionEvents",get:function(){return this._registerImpressionEvents}},{key:"trackABTests",get:function(){return this._trackABTests}}])&&function(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}(e.prototype,n),e}()}); | ||
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports):"function"==typeof define&&define.amd?define(["exports"],t):t((e=e||self).abCore={})}(this,function(e){function t(){return(t=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e}).apply(this,arguments)}var n=function(){},r=function(e,t){return t({abTestRegister:e})},i=function(e,t){var n={variantName:e.id,complete:t};return e.campaignCode&&(n.campaignCodes=[e.campaignCode]),n},s=function(e){return e.variants.every(function(e){return"function"==typeof e.impression})},a=function(e,t,s){return function(a){var u=a.variantToRun,o=(e?u.success:u.impression)||n;try{o(function(e,t,n,s){var a,u=((a={})[e.id]=i(t,n),a);return function(){return r(u,s)}}(a,u,e,s))}catch(e){t(e,{},!1)}}};e.AB=function(){function e(e){var n=e.serverSideTests,u=e.errorReporter,o=e.ophanRecord,c=function(e){var n=e.mvtMaxValue,r=void 0===n?1e6:n,i=e.mvtId,s=e.pageIsSensitive,a=e.abTestSwitches,u=e.forcedTestVariant,o=e.forcedTestException,c=e.arrayOfTestObjects,f=void 0===c?[]:c,l=function(e){var n,c,f=function(e){var t=r*e.audienceOffset;return i&&i>t&&i<=t+r*e.audience?e.variants[i%e.variants.length]:null}(e),l=u&&u.testId===e.id&&u.variant||f;return o!==e.id&&function(e){var t,n=(t=e.expiry,(new Date).valueOf()>new Date(t).setHours(23,59,59,59)),r=!!e.showForSensitive,i=a["ab"+e.id]&&!!a["ab"+e.id],u=!e.canRun||e.canRun();return(!s||r)&&i&&!n&&u}(e)&&l&&(c="notintest"!==(n=l).id,n.canRun?n.canRun()&&c:c)?t({},e,{variantToRun:l}):null},v=function(e){return e.reduce(function(e,t){var n=l(t);return n?[].concat(e,[n]):e},[])};return{allRunnableTests:v,runnableTest:l,firstRunnableTest:function(e){return e.map(function(e){return l(e)}).find(function(e){return null!==e})||null},isUserInVariant:function(e,t){return v(f).some(function(n){return n.id===e&&n.variantToRun.id===t})}}}({mvtMaxValue:e.mvtMaxValue,mvtId:e.mvtId,pageIsSensitive:e.pageIsSensitive,abTestSwitches:e.abTestSwitches,forcedTestVariant:e.forcedTestVariant,forcedTestException:e.forcedTestException,arrayOfTestObjects:e.arrayOfTestObjects}),f=function(e){var t=e.serverSideTests,n=void 0===t?{}:t,u=e.errorReporter,o=void 0===u?function(){}:u,c=e.ophanRecord,f=void 0===c?function(){}:c;return{registerCompleteEvents:function(e){return e.forEach(a(!0,o,f))},registerImpressionEvents:function(e){e.filter(s).forEach(a(!1,o,f))},trackABTests:function(e){return r(function(e,t,n){try{var r={},a=Object.keys(n).filter(function(e){return!!n[e]});return e.filter(function(e){return!s(e)}).forEach(function(e){r[e.id]=i(e.variantToRun,!1)}),a.forEach(function(e){r["ab"+e]=i({id:"inTest",test:function(){}},!1)}),r}catch(e){return t(e,{},!1),{}}}(e,o,n),f)}}}({serverSideTests:n,errorReporter:u,ophanRecord:o});this._allRunnableTests=c.allRunnableTests,this._firstRunnableTest=c.firstRunnableTest,this._runnableTest=c.runnableTest,this._isUserInVariant=c.isUserInVariant,this._registerCompleteEvents=f.registerCompleteEvents,this._registerImpressionEvents=f.registerImpressionEvents,this._trackABTests=f.trackABTests}var n;return(n=[{key:"allRunnableTests",get:function(){return this._allRunnableTests}},{key:"firstRunnableTest",get:function(){return this._firstRunnableTest}},{key:"runnableTest",get:function(){return this._runnableTest}},{key:"isUserInVariant",get:function(){return this._isUserInVariant}},{key:"registerCompleteEvents",get:function(){return this._registerCompleteEvents}},{key:"registerImpressionEvents",get:function(){return this._registerImpressionEvents}},{key:"trackABTests",get:function(){return this._trackABTests}}])&&function(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}(e.prototype,n),e}()}); | ||
//# sourceMappingURL=index.umd.js.map |
{ | ||
"version": "1.0.0-next.0", | ||
"version": "1.0.1-next.0", | ||
"name": "@guardian/ab-core", | ||
@@ -77,3 +77,3 @@ "author": "The Guardian", | ||
}, | ||
"gitHead": "af948fb107cc97c8aa17b17a0f32dee99984d1ee" | ||
"gitHead": "b452c40e2e3fde0ec5f6486ce14db1a6af138ab9" | ||
} |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
83240
203