From b6b35f96981b2e4088248def328df2f59023ca7f Mon Sep 17 00:00:00 2001 From: dominikjasek Date: Wed, 17 Jul 2024 20:10:27 +0200 Subject: [PATCH 1/6] v1.0.1-canary.0 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 0e250c9..5c28db2 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@customink/signalerjs", - "version": "1.0.0", + "version": "1.0.1-canary.0", "description": "JavaScript A/B testing feature flag library", "main": "dist/signalerjs.min.js", "scripts": { From 6b403d664a39ec2d9f082b2d774cccc3faa7237f Mon Sep 17 00:00:00 2001 From: dominikjasek Date: Wed, 17 Jul 2024 20:39:29 +0200 Subject: [PATCH 2/6] v1.0.1-canary.1 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 5c28db2..9b9c20b 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@customink/signalerjs", - "version": "1.0.1-canary.0", + "version": "1.0.1-canary.1", "description": "JavaScript A/B testing feature flag library", "main": "dist/signalerjs.min.js", "scripts": { From 9f6da0002a4f4d2a829d8cc0c8b85a52f5d44f12 Mon Sep 17 00:00:00 2001 From: dominikjasek Date: Wed, 17 Jul 2024 20:49:07 +0200 Subject: [PATCH 3/6] v1.0.1-canary.2 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 9b9c20b..8cade84 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@customink/signalerjs", - "version": "1.0.1-canary.1", + "version": "1.0.1-canary.2", "description": "JavaScript A/B testing feature flag library", "main": "dist/signalerjs.min.js", "scripts": { From 1b4cd0a4d3809d4ef419270d202f75941eab3e70 Mon Sep 17 00:00:00 2001 From: dominikjasek Date: Wed, 17 Jul 2024 20:58:06 +0200 Subject: [PATCH 4/6] v1.0.1-canary.3 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 8cade84..2385c84 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@customink/signalerjs", - "version": "1.0.1-canary.2", + "version": "1.0.1-canary.3", "description": "JavaScript A/B testing feature flag library", "main": "dist/signalerjs.min.js", "scripts": { From a8299b43e54db10786398cf1bb10cbebcd238c6e Mon Sep 17 00:00:00 2001 From: dominikjasek Date: Wed, 17 Jul 2024 21:13:03 +0200 Subject: [PATCH 5/6] merge config from constructor with default config --- dist/signalerjs.min.js | 2 +- package.json | 2 +- src/index.js | 4 ++-- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/dist/signalerjs.min.js b/dist/signalerjs.min.js index aabec3f..345cbf0 100644 --- a/dist/signalerjs.min.js +++ b/dist/signalerjs.min.js @@ -1 +1 @@ -!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t():"function"==typeof define&&define.amd?define([],t):"object"==typeof exports?exports.signalerjs=t():e.signalerjs=t()}(self,(function(){return function(){var e={560:function(e,t,n){var r;!function(o){"use strict";function u(e,t){var n=(65535&e)+(65535&t);return(e>>16)+(t>>16)+(n>>16)<<16|65535&n}function c(e,t,n,r,o,c){return u((i=u(u(t,e),u(r,c)))<<(a=o)|i>>>32-a,n);var i,a}function i(e,t,n,r,o,u,i){return c(t&n|~t&r,e,t,o,u,i)}function a(e,t,n,r,o,u,i){return c(t&r|n&~r,e,t,o,u,i)}function f(e,t,n,r,o,u,i){return c(t^n^r,e,t,o,u,i)}function s(e,t,n,r,o,u,i){return c(n^(t|~r),e,t,o,u,i)}function l(e,t){var n,r,o,c,l;e[t>>5]|=128<>>9<<4)]=t;var d=1732584193,p=-271733879,g=-1732584194,h=271733878;for(n=0;n>5]>>>t%32&255);return n}function p(e){var t,n=[];for(n[(e.length>>2)-1]=void 0,t=0;t>5]|=(255&e.charCodeAt(t/8))<>>4&15)+r.charAt(15&t);return o}function h(e){return unescape(encodeURIComponent(e))}function v(e){return function(e){return d(l(p(e),8*e.length))}(h(e))}function m(e,t){return function(e,t){var n,r,o=p(e),u=[],c=[];for(u[15]=c[15]=void 0,o.length>16&&(o=l(o,8*e.length)),n=0;n<16;n+=1)u[n]=909522486^o[n],c[n]=1549556828^o[n];return r=l(u.concat(p(t)),512+8*t.length),d(l(c.concat(r),640))}(h(e),h(t))}function y(e,t,n){return t?n?m(t,e):g(m(t,e)):n?v(e):g(v(e))}void 0===(r=function(){return y}.call(t,n,t,e))||(e.exports=r)}()},360:function(e,t,n){var r;!function(o,u){"use strict";var c=function(e){if("object"!=typeof e.document)throw new Error("Cookies.js requires a `window` with a `document` object");var t=function(e,n,r){return 1===arguments.length?t.get(e):t.set(e,n,r)};return t._document=e.document,t._cacheKeyPrefix="cookey.",t._maxExpireDate=new Date("Fri, 31 Dec 9999 23:59:59 UTC"),t.defaults={path:"/",secure:!1},t.get=function(e){t._cachedDocumentCookie!==t._document.cookie&&t._renewCache();var n=t._cache[t._cacheKeyPrefix+e];return n===u?u:decodeURIComponent(n)},t.set=function(e,n,r){return(r=t._getExtendedOptions(r)).expires=t._getExpiresDate(n===u?-1:r.expires),t._document.cookie=t._generateCookieString(e,n,r),t},t.expire=function(e,n){return t.set(e,u,n)},t._getExtendedOptions=function(e){return{path:e&&e.path||t.defaults.path,domain:e&&e.domain||t.defaults.domain,expires:e&&e.expires||t.defaults.expires,secure:e&&e.secure!==u?e.secure:t.defaults.secure}},t._isValidDate=function(e){return"[object Date]"===Object.prototype.toString.call(e)&&!isNaN(e.getTime())},t._getExpiresDate=function(e,n){if(n=n||new Date,"number"==typeof e?e=e===1/0?t._maxExpireDate:new Date(n.getTime()+1e3*e):"string"==typeof e&&(e=new Date(e)),e&&!t._isValidDate(e))throw new Error("`expires` parameter cannot be converted to a valid Date instance");return e},t._generateCookieString=function(e,t,n){var r=(e=(e=e.replace(/[^#$&+\^`|]/g,encodeURIComponent)).replace(/\(/g,"%28").replace(/\)/g,"%29"))+"="+(t=(t+"").replace(/[^!#$&-+\--:<-\[\]-~]/g,encodeURIComponent));return r+=(n=n||{}).path?";path="+n.path:"",r+=n.domain?";domain="+n.domain:"",(r+=n.expires?";expires="+n.expires.toUTCString():"")+(n.secure?";secure":"")},t._getCacheFromString=function(e){for(var n={},r=e?e.split("; "):[],o=0;o=t?(u=!0,e):void 0}))[0]||null},e.exports=t.default}])}},t={};function n(r){var o=t[r];if(void 0!==o)return o.exports;var u=t[r]={exports:{}};return e[r].call(u.exports,u,u.exports,n),u.exports}n.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return n.d(t,{a:t}),t},n.d=function(e,t){for(var r in t)n.o(t,r)&&!n.o(e,r)&&Object.defineProperty(e,r,{enumerable:!0,get:t[r]})},n.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},n.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})};var r={};return function(){"use strict";function e(t){return e="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},e(t)}n.r(r),n.d(r,{default:function(){return v}});var t=n(560),o=n.n(t),u=n(360),c=n.n(u),i=n(789),a=n.n(i);function f(e){var t=Date.now();return new Date(t+864e5*e).toUTCString()}var s,l,d={path:"/",domain:(s=window.location.hostname,l=s.split("."),l.length>2?".".concat(l.slice(1).join(".")):".".concat(s)),expires:f(30)},p=function(e){var t={};return e.map((function(e){t[e]=g(e)})),t},g=function(e){var t=c().get(o()(e));return t?(c().set("feature_".concat(e),t),c().expire(o()(e))):t=c().get("feature_".concat(e)),t},h=function(t){switch(e(t)){case"string":return{expires:t};case"number":return{expires:f(t)};default:return{}}};function v(t){var n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},r=n.transformCookieOptions||function(e){return e};c().defaults=n.cookieDefaults||d;var o=function(){return"string"===e(t)?window.fetch("".concat(t,".json")).then((function(e){return e.json()})).then((function(e){return p(Object.keys(e))})):new Promise((function(e){return e(p(Object.keys(t)))}))},u=function(e){var n=g(e);if(n)return n;var r=t[e],o=a()(r.flags),u=h(r.expires);return f(e,o,u),o},i=function(e){return window.fetch("".concat(t,"/").concat(e,".json")).then((function(e){return e.json()})).then((function(t){var n=h(t.expires);return f(e,t.flag,n),t.flag}))},f=function(e,t){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};c().set("feature_".concat(e),t,r(n))};return{featureFlags:o,featureFlag:u,featureFlagFromServer:i,setFeatureFlag:f}}}(),r}()})); \ No newline at end of file +!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t():"function"==typeof define&&define.amd?define([],t):"object"==typeof exports?exports.signalerjs=t():e.signalerjs=t()}(self,(function(){return function(){var e={560:function(e,t,n){var r;!function(o){"use strict";function u(e,t){var n=(65535&e)+(65535&t);return(e>>16)+(t>>16)+(n>>16)<<16|65535&n}function c(e,t,n,r,o,c){return u((i=u(u(t,e),u(r,c)))<<(a=o)|i>>>32-a,n);var i,a}function i(e,t,n,r,o,u,i){return c(t&n|~t&r,e,t,o,u,i)}function a(e,t,n,r,o,u,i){return c(t&r|n&~r,e,t,o,u,i)}function f(e,t,n,r,o,u,i){return c(t^n^r,e,t,o,u,i)}function s(e,t,n,r,o,u,i){return c(n^(t|~r),e,t,o,u,i)}function l(e,t){var n,r,o,c,l;e[t>>5]|=128<>>9<<4)]=t;var p=1732584193,d=-271733879,g=-1732584194,y=271733878;for(n=0;n>5]>>>t%32&255);return n}function d(e){var t,n=[];for(n[(e.length>>2)-1]=void 0,t=0;t>5]|=(255&e.charCodeAt(t/8))<>>4&15)+r.charAt(15&t);return o}function y(e){return unescape(encodeURIComponent(e))}function h(e){return function(e){return p(l(d(e),8*e.length))}(y(e))}function v(e,t){return function(e,t){var n,r,o=d(e),u=[],c=[];for(u[15]=c[15]=void 0,o.length>16&&(o=l(o,8*e.length)),n=0;n<16;n+=1)u[n]=909522486^o[n],c[n]=1549556828^o[n];return r=l(u.concat(d(t)),512+8*t.length),p(l(c.concat(r),640))}(y(e),y(t))}function m(e,t,n){return t?n?v(t,e):g(v(t,e)):n?h(e):g(h(e))}void 0===(r=function(){return m}.call(t,n,t,e))||(e.exports=r)}()},360:function(e,t,n){var r;!function(o,u){"use strict";var c=function(e){if("object"!=typeof e.document)throw new Error("Cookies.js requires a `window` with a `document` object");var t=function(e,n,r){return 1===arguments.length?t.get(e):t.set(e,n,r)};return t._document=e.document,t._cacheKeyPrefix="cookey.",t._maxExpireDate=new Date("Fri, 31 Dec 9999 23:59:59 UTC"),t.defaults={path:"/",secure:!1},t.get=function(e){t._cachedDocumentCookie!==t._document.cookie&&t._renewCache();var n=t._cache[t._cacheKeyPrefix+e];return n===u?u:decodeURIComponent(n)},t.set=function(e,n,r){return(r=t._getExtendedOptions(r)).expires=t._getExpiresDate(n===u?-1:r.expires),t._document.cookie=t._generateCookieString(e,n,r),t},t.expire=function(e,n){return t.set(e,u,n)},t._getExtendedOptions=function(e){return{path:e&&e.path||t.defaults.path,domain:e&&e.domain||t.defaults.domain,expires:e&&e.expires||t.defaults.expires,secure:e&&e.secure!==u?e.secure:t.defaults.secure}},t._isValidDate=function(e){return"[object Date]"===Object.prototype.toString.call(e)&&!isNaN(e.getTime())},t._getExpiresDate=function(e,n){if(n=n||new Date,"number"==typeof e?e=e===1/0?t._maxExpireDate:new Date(n.getTime()+1e3*e):"string"==typeof e&&(e=new Date(e)),e&&!t._isValidDate(e))throw new Error("`expires` parameter cannot be converted to a valid Date instance");return e},t._generateCookieString=function(e,t,n){var r=(e=(e=e.replace(/[^#$&+\^`|]/g,encodeURIComponent)).replace(/\(/g,"%28").replace(/\)/g,"%29"))+"="+(t=(t+"").replace(/[^!#$&-+\--:<-\[\]-~]/g,encodeURIComponent));return r+=(n=n||{}).path?";path="+n.path:"",r+=n.domain?";domain="+n.domain:"",(r+=n.expires?";expires="+n.expires.toUTCString():"")+(n.secure?";secure":"")},t._getCacheFromString=function(e){for(var n={},r=e?e.split("; "):[],o=0;o=t?(u=!0,e):void 0}))[0]||null},e.exports=t.default}])}},t={};function n(r){var o=t[r];if(void 0!==o)return o.exports;var u=t[r]={exports:{}};return e[r].call(u.exports,u,u.exports,n),u.exports}n.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return n.d(t,{a:t}),t},n.d=function(e,t){for(var r in t)n.o(t,r)&&!n.o(e,r)&&Object.defineProperty(e,r,{enumerable:!0,get:t[r]})},n.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},n.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})};var r={};return function(){"use strict";function e(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function t(e){return t="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},t(e)}n.r(r),n.d(r,{default:function(){return b}});var o=n(560),u=n.n(o),c=n(360),i=n.n(c),a=n(789),f=n.n(a);function s(e){var t=Date.now();return new Date(t+864e5*e).toUTCString()}function l(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),n.push.apply(n,r)}return n}function p(t){for(var n=1;n2?".".concat(g.slice(1).join(".")):".".concat(d)),expires:s(30)},h=function(e){var t={};return e.map((function(e){t[e]=v(e)})),t},v=function(e){var t=i().get(u()(e));return t?(i().set("feature_".concat(e),t),i().expire(u()(e))):t=i().get("feature_".concat(e)),t},m=function(e){switch(t(e)){case"string":return{expires:e};case"number":return{expires:s(e)};default:return{}}};function b(e){var n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},r=n.transformCookieOptions||function(e){return e};i().defaults=p(p({},y),n.cookieDefaults);var o=function(){return"string"===t(e)?window.fetch("".concat(e,".json")).then((function(e){return e.json()})).then((function(e){return h(Object.keys(e))})):new Promise((function(t){return t(h(Object.keys(e)))}))},u=function(t){var n=v(t);if(n)return n;var r=e[t],o=f()(r.flags),u=m(r.expires);return a(t,o,u),o},c=function(t){return window.fetch("".concat(e,"/").concat(t,".json")).then((function(e){return e.json()})).then((function(e){var n=m(e.expires);return a(t,e.flag,n),e.flag}))},a=function(e,t){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};i().set("feature_".concat(e),t,r(n))};return{featureFlags:o,featureFlag:u,featureFlagFromServer:c,setFeatureFlag:a}}}(),r}()})); \ No newline at end of file diff --git a/package.json b/package.json index 2385c84..77d448b 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@customink/signalerjs", - "version": "1.0.1-canary.3", + "version": "1.1.0", "description": "JavaScript A/B testing feature flag library", "main": "dist/signalerjs.min.js", "scripts": { diff --git a/src/index.js b/src/index.js index acc61fc..91788fb 100644 --- a/src/index.js +++ b/src/index.js @@ -41,7 +41,7 @@ const cookieOptionsFromExpires = expires => { export default function Signaler(urlOrFeatures, config = {}) { const transformCookieOptions = config.transformCookieOptions || (data => data); - Cookies.defaults = config.cookieDefaults || cookieDefaults; + Cookies.defaults = {...cookieDefaults, ...config.cookieDefaults}; const featureFlags = () => { switch (typeof urlOrFeatures) { @@ -61,7 +61,7 @@ export default function Signaler(urlOrFeatures, config = {}) { const cookieValue = featureFlagFromCookie(featureName); if(cookieValue) { return cookieValue; - } else { + } else { const feature = urlOrFeatures[featureName]; const flag = sample(feature.flags); const cookieOpts = cookieOptionsFromExpires(feature.expires); From 37d0cc36a6b0a3658dc0c668da5f1536bc2e0a16 Mon Sep 17 00:00:00 2001 From: dominikjasek Date: Wed, 17 Jul 2024 21:14:17 +0200 Subject: [PATCH 6/6] changelog --- CHANGELOG.md | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 64ac84d..0ce1495 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,6 +7,13 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## [Unreleased] + +## [1.1.0] - 2024-07-18 + +### Changed + +- Merge cookieDefaults from constructor with default cookie values + ## [1.0.0] - 2022-02-09 ### Changed