@customerio/cdp-analytics-browser 0.3.7 → 0.3.9
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/cjs/core/analytics/index.js.map +1 -1
- package/dist/cjs/core/buffer/index.js +12 -0
- package/dist/cjs/core/buffer/index.js.map +1 -1
- package/dist/cjs/generated/version.js +1 -1
- package/dist/cjs/plugins/in-app-plugin/inbox_messages.js +144 -0
- package/dist/cjs/plugins/in-app-plugin/inbox_messages.js.map +1 -0
- package/dist/cjs/plugins/in-app-plugin/index.js +25 -0
- package/dist/cjs/plugins/in-app-plugin/index.js.map +1 -1
- package/dist/pkg/core/analytics/index.js.map +1 -1
- package/dist/pkg/core/buffer/index.js +12 -0
- package/dist/pkg/core/buffer/index.js.map +1 -1
- package/dist/pkg/generated/version.js +1 -1
- package/dist/pkg/plugins/in-app-plugin/inbox_messages.js +140 -0
- package/dist/pkg/plugins/in-app-plugin/inbox_messages.js.map +1 -0
- package/dist/pkg/plugins/in-app-plugin/index.js +25 -0
- package/dist/pkg/plugins/in-app-plugin/index.js.map +1 -1
- package/dist/types/core/analytics/index.d.ts +1 -0
- package/dist/types/core/analytics/index.d.ts.map +1 -1
- package/dist/types/core/analytics/interfaces.d.ts +8 -0
- package/dist/types/core/analytics/interfaces.d.ts.map +1 -1
- package/dist/types/core/buffer/index.d.ts +2 -1
- package/dist/types/core/buffer/index.d.ts.map +1 -1
- package/dist/types/generated/version.d.ts +1 -1
- package/dist/types/plugins/in-app-plugin/inbox_messages.d.ts +62 -0
- package/dist/types/plugins/in-app-plugin/inbox_messages.d.ts.map +1 -0
- package/dist/types/plugins/in-app-plugin/index.d.ts +2 -0
- package/dist/types/plugins/in-app-plugin/index.d.ts.map +1 -1
- package/dist/umd/{799.js → 407.js} +1 -1
- package/dist/umd/407.js.gz +0 -0
- package/dist/umd/852.js +1 -0
- package/dist/umd/852.js.gz +0 -0
- package/dist/umd/ajs-destination.js +1 -1
- package/dist/umd/ajs-destination.js.gz +0 -0
- package/dist/umd/auto-track.js +1 -1
- package/dist/umd/auto-track.js.gz +0 -0
- package/dist/umd/inAppPlugin.js +1 -1
- package/dist/umd/inAppPlugin.js.gz +0 -0
- package/dist/umd/index.js +1 -1
- package/dist/umd/index.js.gz +0 -0
- package/dist/umd/legacyVideos.js +1 -1
- package/dist/umd/legacyVideos.js.gz +0 -0
- package/dist/umd/queryString.js +1 -1
- package/dist/umd/queryString.js.gz +0 -0
- package/dist/umd/remoteMiddleware.js +1 -1
- package/dist/umd/remoteMiddleware.js.gz +0 -0
- package/dist/umd/schemaFilter.js +1 -1
- package/dist/umd/schemaFilter.js.gz +0 -0
- package/dist/umd/standalone.js +1 -1
- package/dist/umd/standalone.js.gz +0 -0
- package/dist/umd/tsub-middleware.js +1 -1
- package/dist/umd/tsub-middleware.js.gz +0 -0
- package/package.json +4 -4
- package/src/core/analytics/index.ts +1 -0
- package/src/core/analytics/interfaces.ts +8 -0
- package/src/core/buffer/index.ts +6 -0
- package/src/generated/version.ts +1 -1
- package/src/plugins/in-app-plugin/inbox_messages.ts +163 -0
- package/src/plugins/in-app-plugin/index.ts +31 -0
- package/dist/umd/646.js +0 -1
- package/dist/umd/646.js.gz +0 -0
- package/dist/umd/799.js.gz +0 -0
|
@@ -1 +1 @@
|
|
|
1
|
-
(self.webpackChunk_customerio_cdp_analytics_browser=self.webpackChunk_customerio_cdp_analytics_browser||[]).push([[604],{669:function(t,r,n){"use strict";n.r(r),n.d(r,{tsubMiddleware:function(){return o}});var e=n(2248),o=function(t){return function(r){var n=r.payload,o=r.integration,i=r.next;new e.Store(t).getRulesByDestinationName(o).forEach((function(t){for(var r=t.matchers,o=t.transformers,u=0;u<r.length;u++)if(e.matches(n.obj,r[u])&&(n.obj=e.transform(n.obj,o[u]),null===n.obj))return i(null)})),i(n)}}},2248:function(t){"use strict";self,t.exports=function(){var t={2870:function(t,r,n){var e=this&&this.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(r,"__esModule",{value:!0}),r.Store=r.matches=r.transform=void 0;var o=n(4303);Object.defineProperty(r,"transform",{enumerable:!0,get:function(){return e(o).default}});var i=n(2370);Object.defineProperty(r,"matches",{enumerable:!0,get:function(){return e(i).default}});var u=n(1444);Object.defineProperty(r,"Store",{enumerable:!0,get:function(){return e(u).default}})},2370:function(t,r,n){var e=this&&this.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(r,"__esModule",{value:!0});var o=e(n(7843));function i(t,r){if(!Array.isArray(t))return!0===u(t,r);var n,e,o,s,p=t[0];switch(p){case"!":return!i(t[1],r);case"or":for(var l=1;l<t.length;l++)if(i(t[l],r))return!0;return!1;case"and":for(l=1;l<t.length;l++)if(!i(t[l],r))return!1;return!0;case"=":case"!=":return function(t,r,n,e){switch(a(t)&&(t=i(t,e)),a(r)&&(r=i(r,e)),"object"==typeof t&&"object"==typeof r&&(t=JSON.stringify(t),r=JSON.stringify(r)),n){case"=":return t===r;case"!=":return t!==r;default:throw new Error("Invalid operator in compareItems: ".concat(n))}}(u(t[1],r),u(t[2],r),p,r);case"<=":case"<":case">":case">=":return function(t,r,n,e){if(a(t)&&(t=i(t,e)),a(r)&&(r=i(r,e)),"number"!=typeof t||"number"!=typeof r)return!1;switch(n){case"<=":return t<=r;case">=":return t>=r;case"<":return t<r;case">":return t>r;default:throw new Error("Invalid operator in compareNumbers: ".concat(n))}}(u(t[1],r),u(t[2],r),p,r);case"in":return function(t,r,n){return void 0!==r.find((function(r){return u(r,n)===t}))}(u(t[1],r),u(t[2],r),r);case"contains":return o=u(t[1],r),s=u(t[2],r),"string"==typeof o&&"string"==typeof s&&-1!==o.indexOf(s);case"match":return n=u(t[1],r),e=u(t[2],r),"string"==typeof n&&"string"==typeof e&&function(t,r){var n,e;t:for(;t.length>0;){var o,i;if(o=(n=c(t)).star,i=n.chunk,t=n.pattern,o&&""===i)return!0;var u=f(i,r),a=u.t,s=u.ok,p=u.err;if(p)return!1;if(!s||!(0===a.length||t.length>0)){if(o)for(var l=0;l<r.length;l++){if(a=(e=f(i,r.slice(l+1))).t,s=e.ok,p=e.err,s){if(0===t.length&&a.length>0)continue;r=a;continue t}if(p)return!1}return!1}r=a}return 0===r.length}(e,n);case"lowercase":var v=u(t[1],r);return"string"!=typeof v?null:v.toLowerCase();case"typeof":return typeof u(t[1],r);case"length":return function(t){return null===t?0:Array.isArray(t)||"string"==typeof t?t.length:NaN}(u(t[1],r));default:throw new Error("FQL IR could not evaluate for token: ".concat(p))}}function u(t,r){return Array.isArray(t)?t:"object"==typeof t?t.value:(0,o.default)(r,t)}function a(t){return!!Array.isArray(t)&&(("lowercase"===t[0]||"length"===t[0]||"typeof"===t[0])&&2===t.length||("contains"===t[0]||"match"===t[0])&&3===t.length)}function c(t){for(var r={star:!1,chunk:"",pattern:""};t.length>0&&"*"===t[0];)t=t.slice(1),r.star=!0;var n,e=!1;t:for(n=0;n<t.length;n++)switch(t[n]){case"\\":n+1<t.length&&n++;break;case"[":e=!0;break;case"]":e=!1;break;case"*":if(!e)break t}return r.chunk=t.slice(0,n),r.pattern=t.slice(n),r}function f(t,r){for(var n,e,o={t:"",ok:!1,err:!1};t.length>0;){if(0===r.length)return o;switch(t[0]){case"[":var i=r[0];r=r.slice(1);var u=!0;(t=t.slice(1)).length>0&&"^"===t[0]&&(u=!1,t=t.slice(1));for(var a=!1,c=0;;){if(t.length>0&&"]"===t[0]&&c>0){t=t.slice(1);break}var f,p="";if(f=(n=s(t)).char,t=n.newChunk,n.err)return o;if(p=f,"-"===t[0]&&(p=(e=s(t.slice(1))).char,t=e.newChunk,e.err))return o;f<=i&&i<=p&&(a=!0),c++}if(a!==u)return o;break;case"?":r=r.slice(1),t=t.slice(1);break;case"\\":if(0===(t=t.slice(1)).length)return o.err=!0,o;default:if(t[0]!==r[0])return o;r=r.slice(1),t=t.slice(1)}}return o.t=r,o.ok=!0,o.err=!1,o}function s(t){var r={char:"",newChunk:"",err:!1};return 0===t.length||"-"===t[0]||"]"===t[0]||"\\"===t[0]&&0===(t=t.slice(1)).length?(r.err=!0,r):(r.char=t[0],r.newChunk=t.slice(1),0===r.newChunk.length&&(r.err=!0),r)}r.default=function(t,r){if(!r)throw new Error("No matcher supplied!");switch(r.type){case"all":return!0;case"fql":return function(t,r){if(!t)return!1;try{t=JSON.parse(t)}catch(r){throw new Error('Failed to JSON.parse FQL intermediate representation "'.concat(t,'": ').concat(r))}var n=i(t,r);return"boolean"==typeof n&&n}(r.ir,t);default:throw new Error("Matcher of type ".concat(r.type," unsupported."))}}},1444:function(t,r){Object.defineProperty(r,"__esModule",{value:!0});var n=function(){function t(t){this.rules=[],this.rules=t||[]}return t.prototype.getRulesByDestinationName=function(t){for(var r=[],n=0,e=this.rules;n<e.length;n++){var o=e[n];o.destinationName!==t&&void 0!==o.destinationName||r.push(o)}return r},t}();r.default=n},4303:function(t,r,n){var e=this&&this.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(r,"__esModule",{value:!0});var o=e(n(2263)),i=e(n(7843)),u=e(n(5500)),a=n(2341),c=n(4966);function f(t,r){p(t,r.drop,(function(t,r){r.forEach((function(r){return delete t[r]}))}))}function s(t,r){p(t,r.allow,(function(t,r){Object.keys(t).forEach((function(n){r.includes(n)||delete t[n]}))}))}function p(t,r,n){Object.entries(r).forEach((function(r){var e=r[0],o=r[1],u=function(t){"object"==typeof t&&null!==t&&n(t,o)},a=""===e?t:(0,i.default)(t,e);Array.isArray(a)?a.forEach(u):u(a)}))}function l(t,r){var n=JSON.parse(JSON.stringify(t));for(var e in r.map)if(r.map.hasOwnProperty(e)){var o=r.map[e],u=e.split("."),f=void 0;if(u.length>1?(u.pop(),f=(0,i.default)(n,u.join("."))):f=t,"object"==typeof f){if(o.copy){var s=(0,i.default)(n,o.copy);void 0!==s&&(0,a.dset)(t,e,s)}else if(o.move){var p=(0,i.default)(n,o.move);void 0!==p&&(0,a.dset)(t,e,p),(0,c.unset)(t,o.move)}else o.hasOwnProperty("set")&&(0,a.dset)(t,e,o.set);if(o.to_string){var l=(0,i.default)(t,e);if("string"==typeof l||"object"==typeof l&&null!==l)continue;void 0!==l?(0,a.dset)(t,e,JSON.stringify(l)):(0,a.dset)(t,e,"undefined")}}}}function v(t,r){return!(r.sample.percent<=0)&&(r.sample.percent>=1||(r.sample.path?function(t,r){var n=(0,i.default)(t,r.sample.path),e=(0,o.default)(JSON.stringify(n)),a=-64,c=[];y(e.slice(0,8),c);for(var f=0,s=0;s<64&&1!==c[s];s++)f++;if(0!==f){var p=[];y(e.slice(9,16),p),a-=f,c.splice(0,f),p.splice(64-f),c=c.concat(p)}return c[63]=0===c[63]?1:0,(0,u.default)(parseInt(c.join(""),2),a)<r.sample.percent}(t,r):(n=r.sample.percent,Math.random()<=n)));var n}function y(t,r){for(var n=0;n<8;n++)for(var e=t[n],o=128;o>=1;o/=2)e-o>=0?(e-=o,r.push(1)):r.push(0)}r.default=function(t,r){for(var n=t,e=0,o=r;e<o.length;e++){var i=o[e];switch(i.type){case"drop":return null;case"drop_properties":f(n,i.config);break;case"allow_properties":s(n,i.config);break;case"sample_event":if(v(n,i.config))break;return null;case"map_properties":l(n,i.config);break;case"hash_properties":break;default:throw new Error('Transformer of type "'.concat(i.type,'" is unsupported.'))}}return n}},4966:function(t,r,n){var e=this&&this.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(r,"__esModule",{value:!0}),r.unset=void 0;var o=e(n(7843));r.unset=function(t,r){if((0,o.default)(t,r)){for(var n=r.split("."),e=n.pop();n.length&&"\\"===n[n.length-1].slice(-1);)e=n.pop().slice(0,-1)+"."+e;for(;n.length;)t=t[r=n.shift()];return delete t[e]}return!0}},3304:function(t){var r="function"==typeof Float64Array?Float64Array:void 0;t.exports=r},7382:function(t,r,n){var e,o=n(5569),i=n(3304),u=n(8482);e=o()?i:u,t.exports=e},8482:function(t){t.exports=function(){throw new Error("not implemented")}},6322:function(t,r,n){var e,o=n(2508),i=n(5679),u=n(882);e=o()?i:u,t.exports=e},882:function(t){t.exports=function(){throw new Error("not implemented")}},5679:function(t){var r="function"==typeof Uint16Array?Uint16Array:void 0;t.exports=r},4773:function(t,r,n){var e,o=n(9773),i=n(3004),u=n(3078);e=o()?i:u,t.exports=e},3078:function(t){t.exports=function(){throw new Error("not implemented")}},3004:function(t){var r="function"==typeof Uint32Array?Uint32Array:void 0;t.exports=r},7980:function(t,r,n){var e,o=n(8114),i=n(6737),u=n(3357);e=o()?i:u,t.exports=e},3357:function(t){t.exports=function(){throw new Error("not implemented")}},6737:function(t){var r="function"==typeof Uint8Array?Uint8Array:void 0;t.exports=r},2684:function(t){var r="function"==typeof Float64Array?Float64Array:null;t.exports=r},5569:function(t,r,n){var e=n(3876);t.exports=e},3876:function(t,r,n){var e=n(1448),o=n(2684);t.exports=function(){var t,r;if("function"!=typeof o)return!1;try{r=new o([1,3.14,-3.14,NaN]),t=e(r)&&1===r[0]&&3.14===r[1]&&-3.14===r[2]&&r[3]!=r[3]}catch(r){t=!1}return t}},9048:function(t,r,n){var e=n(3763);t.exports=e},3763:function(t){var r=Object.prototype.hasOwnProperty;t.exports=function(t,n){return null!=t&&r.call(t,n)}},7009:function(t,r,n){var e=n(6784);t.exports=e},6784:function(t){t.exports=function(){return"function"==typeof Symbol&&"symbol"==typeof Symbol("foo")}},3123:function(t,r,n){var e=n(8481);t.exports=e},8481:function(t,r,n){var e=n(7009)();t.exports=function(){return e&&"symbol"==typeof Symbol.toStringTag}},2508:function(t,r,n){var e=n(3403);t.exports=e},3403:function(t,r,n){var e=n(768),o=n(9668),i=n(187);t.exports=function(){var t,r;if("function"!=typeof i)return!1;try{r=new i(r=[1,3.14,-3.14,o+1,o+2]),t=e(r)&&1===r[0]&&3===r[1]&&r[2]===o-2&&0===r[3]&&1===r[4]}catch(r){t=!1}return t}},187:function(t){var r="function"==typeof Uint16Array?Uint16Array:null;t.exports=r},9773:function(t,r,n){var e=n(2822);t.exports=e},2822:function(t,r,n){var e=n(2744),o=n(3899),i=n(746);t.exports=function(){var t,r;if("function"!=typeof i)return!1;try{r=new i(r=[1,3.14,-3.14,o+1,o+2]),t=e(r)&&1===r[0]&&3===r[1]&&r[2]===o-2&&0===r[3]&&1===r[4]}catch(r){t=!1}return t}},746:function(t){var r="function"==typeof Uint32Array?Uint32Array:null;t.exports=r},8114:function(t,r,n){var e=n(8066);t.exports=e},8066:function(t,r,n){var e=n(8279),o=n(3443),i=n(2731);t.exports=function(){var t,r;if("function"!=typeof i)return!1;try{r=new i(r=[1,3.14,-3.14,o+1,o+2]),t=e(r)&&1===r[0]&&3===r[1]&&r[2]===o-2&&0===r[3]&&1===r[4]}catch(r){t=!1}return t}},2731:function(t){var r="function"==typeof Uint8Array?Uint8Array:null;t.exports=r},1448:function(t,r,n){var e=n(1453);t.exports=e},1453:function(t,r,n){var e=n(6208),o="function"==typeof Float64Array;t.exports=function(t){return o&&t instanceof Float64Array||"[object Float64Array]"===e(t)}},9331:function(t,r,n){var e=n(7980),o={uint16:n(6322),uint8:e};t.exports=o},5902:function(t,r,n){var e=n(4106);t.exports=e},4106:function(t,r,n){var e,o,i=n(9331);(o=new i.uint16(1))[0]=4660,e=52===new i.uint8(o.buffer)[0],t.exports=e},768:function(t,r,n){var e=n(3823);t.exports=e},3823:function(t,r,n){var e=n(6208),o="function"==typeof Uint16Array;t.exports=function(t){return o&&t instanceof Uint16Array||"[object Uint16Array]"===e(t)}},2744:function(t,r,n){var e=n(2326);t.exports=e},2326:function(t,r,n){var e=n(6208),o="function"==typeof Uint32Array;t.exports=function(t){return o&&t instanceof Uint32Array||"[object Uint32Array]"===e(t)}},8279:function(t,r,n){var e=n(208);t.exports=e},208:function(t,r,n){var e=n(6208),o="function"==typeof Uint8Array;t.exports=function(t){return o&&t instanceof Uint8Array||"[object Uint8Array]"===e(t)}},6315:function(t){t.exports=1023},1686:function(t){t.exports=2147483647},3105:function(t){t.exports=2146435072},3449:function(t){t.exports=2147483648},6988:function(t){t.exports=-1023},9777:function(t){t.exports=1023},3690:function(t){t.exports=-1074},2918:function(t,r,n){var e=n(4772).NEGATIVE_INFINITY;t.exports=e},4165:function(t){var r=Number.POSITIVE_INFINITY;t.exports=r},6488:function(t){t.exports=22250738585072014e-324},9668:function(t){t.exports=65535},3899:function(t){t.exports=4294967295},3443:function(t){t.exports=255},7011:function(t,r,n){var e=n(812);t.exports=e},812:function(t,r,n){var e=n(4165),o=n(2918);t.exports=function(t){return t===e||t===o}},1883:function(t,r,n){var e=n(1797);t.exports=e},1797:function(t){t.exports=function(t){return t!=t}},513:function(t,r,n){var e=n(5760);t.exports=e},5760:function(t){t.exports=function(t){return Math.abs(t)}},5848:function(t,r,n){var e=n(677);t.exports=e},677:function(t,r,n){var e=n(3449),o=n(1686),i=n(7838),u=n(1921),a=n(2490),c=[0,0];t.exports=function(t,r){var n,f;return i.assign(t,c,1,0),n=c[0],n&=o,f=u(r),a(n|=f&=e,c[1])}},5500:function(t,r,n){var e=n(8397);t.exports=e},8397:function(t,r,n){var e=n(4165),o=n(2918),i=n(6315),u=n(9777),a=n(6988),c=n(3690),f=n(1883),s=n(7011),p=n(5848),l=n(4948),v=n(8478),y=n(7838),d=n(2490),h=[0,0],x=[0,0];t.exports=function(t,r){var n,b;return 0===t||f(t)||s(t)?t:(l(h,t),r+=h[1],(r+=v(t=h[0]))<c?p(0,t):r>u?t<0?o:e:(r<=a?(r+=52,b=2220446049250313e-31):b=1,y(x,t),n=x[0],n&=2148532223,b*d(n|=r+i<<20,x[1])))}},4772:function(t,r,n){var e=n(7548);t.exports=e},7548:function(t){t.exports=Number},8478:function(t,r,n){var e=n(4500);t.exports=e},4500:function(t,r,n){var e=n(1921),o=n(3105),i=n(6315);t.exports=function(t){var r=e(t);return(r=(r&o)>>>20)-i|0}},2490:function(t,r,n){var e=n(9639);t.exports=e},4445:function(t,r,n){var e,o,i;!0===n(5902)?(o=1,i=0):(o=0,i=1),e={HIGH:o,LOW:i},t.exports=e},9639:function(t,r,n){var e=n(4773),o=n(7382),i=n(4445),u=new o(1),a=new e(u.buffer),c=i.HIGH,f=i.LOW;t.exports=function(t,r){return a[c]=t,a[f]=r,u[0]}},5646:function(t,r,n){var e;e=!0===n(5902)?1:0,t.exports=e},1921:function(t,r,n){var e=n(6285);t.exports=e},6285:function(t,r,n){var e=n(4773),o=n(7382),i=n(5646),u=new o(1),a=new e(u.buffer);t.exports=function(t){return u[0]=t,a[i]}},9024:function(t,r,n){var e=n(6488),o=n(7011),i=n(1883),u=n(513);t.exports=function(t,r,n,a){return i(t)||o(t)?(r[a]=t,r[a+n]=0,r):0!==t&&u(t)<e?(r[a]=4503599627370496*t,r[a+n]=-52,r):(r[a]=t,r[a+n]=0,r)}},4948:function(t,r,n){var e=n(7576),o=n(9422);e(o,"assign",n(9024)),t.exports=o},9422:function(t,r,n){var e=n(9024);t.exports=function(t){return e(t,[0,0],1,0)}},7838:function(t,r,n){var e=n(4010);t.exports=e},5782:function(t,r,n){var e,o,i;!0===n(5902)?(o=1,i=0):(o=0,i=1),e={HIGH:o,LOW:i},t.exports=e},4010:function(t,r,n){var e=n(4903);t.exports=function(t,r){return 1===arguments.length?e([0,0],t):e(t,r)}},4903:function(t,r,n){var e=n(4773),o=n(7382),i=n(5782),u=new o(1),a=new e(u.buffer),c=i.HIGH,f=i.LOW;t.exports=function(t,r){return u[0]=r,t[0]=a[c],t[1]=a[f],t}},7576:function(t,r,n){var e=n(7063);t.exports=e},7063:function(t,r,n){var e=n(6691);t.exports=function(t,r,n){e(t,r,{configurable:!1,enumerable:!1,writable:!1,value:n})}},2073:function(t){var r=Object.defineProperty;t.exports=r},1680:function(t){var r="function"==typeof Object.defineProperty?Object.defineProperty:null;t.exports=r},1471:function(t,r,n){var e=n(1680);t.exports=function(){try{return e({},"x",{}),!0}catch(t){return!1}}},6691:function(t,r,n){var e,o=n(1471),i=n(2073),u=n(1309);e=o()?i:u,t.exports=e},1309:function(t){var r=Object.prototype,n=r.toString,e=r.__defineGetter__,o=r.__defineSetter__,i=r.__lookupGetter__,u=r.__lookupSetter__;t.exports=function(t,a,c){var f,s,p,l;if("object"!=typeof t||null===t||"[object Array]"===n.call(t))throw new TypeError("invalid argument. First argument must be an object. Value: `"+t+"`.");if("object"!=typeof c||null===c||"[object Array]"===n.call(c))throw new TypeError("invalid argument. Property descriptor must be an object. Value: `"+c+"`.");if((s="value"in c)&&(i.call(t,a)||u.call(t,a)?(f=t.__proto__,t.__proto__=r,delete t[a],t[a]=c.value,t.__proto__=f):t[a]=c.value),p="get"in c,l="set"in c,s&&(p||l))throw new Error("invalid argument. Cannot specify one or more accessors and a value or writable attribute in the property descriptor.");return p&&e&&e.call(t,a,c.get),l&&o&&o.call(t,a,c.set),t}},6208:function(t,r,n){var e,o=n(3123),i=n(7407),u=n(4210);e=o()?u:i,t.exports=e},7407:function(t,r,n){var e=n(173);t.exports=function(t){return e.call(t)}},4210:function(t,r,n){var e=n(9048),o=n(1403),i=n(173);t.exports=function(t){var r,n,u;if(null==t)return i.call(t);n=t[o],r=e(t,o);try{t[o]=void 0}catch(r){return i.call(t)}return u=i.call(t),r?t[o]=n:delete t[o],u}},173:function(t){var r=Object.prototype.toString;t.exports=r},1403:function(t){var r="function"==typeof Symbol?Symbol.toStringTag:"";t.exports=r},7843:function(t){t.exports=function(t,r,n,e,o){for(r=r.split?r.split("."):r,e=0;e<r.length;e++)t=t?t[r[e]]:o;return t===o?n:t}},2341:function(t,r){r.dset=function(t,r,n){r.split&&(r=r.split("."));for(var e,o,i=0,u=r.length,a=t;i<u&&"__proto__"!==(o=r[i++])&&"constructor"!==o&&"prototype"!==o;)a=a[o]=i===u?n:typeof(e=a[o])==typeof r?e:0*r[i]!=0||~(""+r[i]).indexOf(".")?{}:[]}},2263:function(t,r,n){n.r(r),n.d(r,{default:function(){return i}});for(var e=[],o=0;o<64;)e[o]=0|4294967296*Math.sin(++o%Math.PI);function i(t){var r,n,i,u=[r=1732584193,n=4023233417,~r,~n],a=[],c=unescape(encodeURI(t))+"",f=c.length;for(t=--f/4+2|15,a[--t]=8*f;~f;)a[f>>2]|=c.charCodeAt(f)<<8*f--;for(o=c=0;o<t;o+=16){for(f=u;c<64;f=[i=f[3],r+((i=f[0]+[r&n|~r&i,i&r|~i&n,r^n^i,n^(r|~i)][f=c>>4]+e[c]+~~a[o|15&[c,5*c+1,3*c+5,7*c][f]])<<(f=[7,12,17,22,5,9,14,20,4,11,16,23,6,10,15,21][4*f+c++%4])|i>>>-f),r,n])r=0|f[1],n=f[2];for(c=4;c;)u[--c]+=f[c]}for(t="";c<32;)t+=(u[c>>3]>>4*(1^c++)&15).toString(16);return t}}},r={};function n(e){var o=r[e];if(void 0!==o)return o.exports;var i=r[e]={exports:{}};return t[e].call(i.exports,i,i.exports,n),i.exports}return n.d=function(t,r){for(var e in r)n.o(r,e)&&!n.o(t,e)&&Object.defineProperty(t,e,{enumerable:!0,get:r[e]})},n.o=function(t,r){return Object.prototype.hasOwnProperty.call(t,r)},n.r=function(t){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})},n(2870)}()}}]);
|
|
1
|
+
"use strict";(self.webpackChunk_customerio_cdp_analytics_browser=self.webpackChunk_customerio_cdp_analytics_browser||[]).push([[10],{31:function(t,r,n){n.d(r,{tsubMiddleware:function(){return o}});var e=n(4052),o=function(t){return function(r){var n=r.payload,o=r.integration,i=r.next;new e.Store(t).getRulesByDestinationName(o).forEach((function(t){for(var r=t.matchers,o=t.transformers,u=0;u<r.length;u++)if(e.matches(n.obj,r[u])&&(n.obj=e.transform(n.obj,o[u]),null===n.obj))return i(null)})),i(n)}}},4052:function(t){self,t.exports=function(){var t={2870:function(t,r,n){var e=this&&this.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(r,"__esModule",{value:!0}),r.Store=r.matches=r.transform=void 0;var o=n(4303);Object.defineProperty(r,"transform",{enumerable:!0,get:function(){return e(o).default}});var i=n(2370);Object.defineProperty(r,"matches",{enumerable:!0,get:function(){return e(i).default}});var u=n(1444);Object.defineProperty(r,"Store",{enumerable:!0,get:function(){return e(u).default}})},2370:function(t,r,n){var e=this&&this.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(r,"__esModule",{value:!0});var o=e(n(7843));function i(t,r){if(!Array.isArray(t))return!0===u(t,r);var n,e,o,s,p=t[0];switch(p){case"!":return!i(t[1],r);case"or":for(var l=1;l<t.length;l++)if(i(t[l],r))return!0;return!1;case"and":for(l=1;l<t.length;l++)if(!i(t[l],r))return!1;return!0;case"=":case"!=":return function(t,r,n,e){switch(a(t)&&(t=i(t,e)),a(r)&&(r=i(r,e)),"object"==typeof t&&"object"==typeof r&&(t=JSON.stringify(t),r=JSON.stringify(r)),n){case"=":return t===r;case"!=":return t!==r;default:throw new Error("Invalid operator in compareItems: ".concat(n))}}(u(t[1],r),u(t[2],r),p,r);case"<=":case"<":case">":case">=":return function(t,r,n,e){if(a(t)&&(t=i(t,e)),a(r)&&(r=i(r,e)),"number"!=typeof t||"number"!=typeof r)return!1;switch(n){case"<=":return t<=r;case">=":return t>=r;case"<":return t<r;case">":return t>r;default:throw new Error("Invalid operator in compareNumbers: ".concat(n))}}(u(t[1],r),u(t[2],r),p,r);case"in":return function(t,r,n){return void 0!==r.find((function(r){return u(r,n)===t}))}(u(t[1],r),u(t[2],r),r);case"contains":return o=u(t[1],r),s=u(t[2],r),"string"==typeof o&&"string"==typeof s&&-1!==o.indexOf(s);case"match":return n=u(t[1],r),e=u(t[2],r),"string"==typeof n&&"string"==typeof e&&function(t,r){var n,e;t:for(;t.length>0;){var o,i;if(o=(n=c(t)).star,i=n.chunk,t=n.pattern,o&&""===i)return!0;var u=f(i,r),a=u.t,s=u.ok,p=u.err;if(p)return!1;if(!s||!(0===a.length||t.length>0)){if(o)for(var l=0;l<r.length;l++){if(a=(e=f(i,r.slice(l+1))).t,s=e.ok,p=e.err,s){if(0===t.length&&a.length>0)continue;r=a;continue t}if(p)return!1}return!1}r=a}return 0===r.length}(e,n);case"lowercase":var v=u(t[1],r);return"string"!=typeof v?null:v.toLowerCase();case"typeof":return typeof u(t[1],r);case"length":return function(t){return null===t?0:Array.isArray(t)||"string"==typeof t?t.length:NaN}(u(t[1],r));default:throw new Error("FQL IR could not evaluate for token: ".concat(p))}}function u(t,r){return Array.isArray(t)?t:"object"==typeof t?t.value:(0,o.default)(r,t)}function a(t){return!!Array.isArray(t)&&(("lowercase"===t[0]||"length"===t[0]||"typeof"===t[0])&&2===t.length||("contains"===t[0]||"match"===t[0])&&3===t.length)}function c(t){for(var r={star:!1,chunk:"",pattern:""};t.length>0&&"*"===t[0];)t=t.slice(1),r.star=!0;var n,e=!1;t:for(n=0;n<t.length;n++)switch(t[n]){case"\\":n+1<t.length&&n++;break;case"[":e=!0;break;case"]":e=!1;break;case"*":if(!e)break t}return r.chunk=t.slice(0,n),r.pattern=t.slice(n),r}function f(t,r){for(var n,e,o={t:"",ok:!1,err:!1};t.length>0;){if(0===r.length)return o;switch(t[0]){case"[":var i=r[0];r=r.slice(1);var u=!0;(t=t.slice(1)).length>0&&"^"===t[0]&&(u=!1,t=t.slice(1));for(var a=!1,c=0;;){if(t.length>0&&"]"===t[0]&&c>0){t=t.slice(1);break}var f,p="";if(f=(n=s(t)).char,t=n.newChunk,n.err)return o;if(p=f,"-"===t[0]&&(p=(e=s(t.slice(1))).char,t=e.newChunk,e.err))return o;f<=i&&i<=p&&(a=!0),c++}if(a!==u)return o;break;case"?":r=r.slice(1),t=t.slice(1);break;case"\\":if(0===(t=t.slice(1)).length)return o.err=!0,o;default:if(t[0]!==r[0])return o;r=r.slice(1),t=t.slice(1)}}return o.t=r,o.ok=!0,o.err=!1,o}function s(t){var r={char:"",newChunk:"",err:!1};return 0===t.length||"-"===t[0]||"]"===t[0]||"\\"===t[0]&&0===(t=t.slice(1)).length?(r.err=!0,r):(r.char=t[0],r.newChunk=t.slice(1),0===r.newChunk.length&&(r.err=!0),r)}r.default=function(t,r){if(!r)throw new Error("No matcher supplied!");switch(r.type){case"all":return!0;case"fql":return function(t,r){if(!t)return!1;try{t=JSON.parse(t)}catch(r){throw new Error('Failed to JSON.parse FQL intermediate representation "'.concat(t,'": ').concat(r))}var n=i(t,r);return"boolean"==typeof n&&n}(r.ir,t);default:throw new Error("Matcher of type ".concat(r.type," unsupported."))}}},1444:function(t,r){Object.defineProperty(r,"__esModule",{value:!0});var n=function(){function t(t){this.rules=[],this.rules=t||[]}return t.prototype.getRulesByDestinationName=function(t){for(var r=[],n=0,e=this.rules;n<e.length;n++){var o=e[n];o.destinationName!==t&&void 0!==o.destinationName||r.push(o)}return r},t}();r.default=n},4303:function(t,r,n){var e=this&&this.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(r,"__esModule",{value:!0});var o=e(n(2263)),i=e(n(7843)),u=e(n(5500)),a=n(2341),c=n(4966);function f(t,r){p(t,r.drop,(function(t,r){r.forEach((function(r){return delete t[r]}))}))}function s(t,r){p(t,r.allow,(function(t,r){Object.keys(t).forEach((function(n){r.includes(n)||delete t[n]}))}))}function p(t,r,n){Object.entries(r).forEach((function(r){var e=r[0],o=r[1],u=function(t){"object"==typeof t&&null!==t&&n(t,o)},a=""===e?t:(0,i.default)(t,e);Array.isArray(a)?a.forEach(u):u(a)}))}function l(t,r){var n=JSON.parse(JSON.stringify(t));for(var e in r.map)if(r.map.hasOwnProperty(e)){var o=r.map[e],u=e.split("."),f=void 0;if(u.length>1?(u.pop(),f=(0,i.default)(n,u.join("."))):f=t,"object"==typeof f){if(o.copy){var s=(0,i.default)(n,o.copy);void 0!==s&&(0,a.dset)(t,e,s)}else if(o.move){var p=(0,i.default)(n,o.move);void 0!==p&&(0,a.dset)(t,e,p),(0,c.unset)(t,o.move)}else o.hasOwnProperty("set")&&(0,a.dset)(t,e,o.set);if(o.to_string){var l=(0,i.default)(t,e);if("string"==typeof l||"object"==typeof l&&null!==l)continue;void 0!==l?(0,a.dset)(t,e,JSON.stringify(l)):(0,a.dset)(t,e,"undefined")}}}}function v(t,r){return!(r.sample.percent<=0)&&(r.sample.percent>=1||(r.sample.path?function(t,r){var n=(0,i.default)(t,r.sample.path),e=(0,o.default)(JSON.stringify(n)),a=-64,c=[];y(e.slice(0,8),c);for(var f=0,s=0;s<64&&1!==c[s];s++)f++;if(0!==f){var p=[];y(e.slice(9,16),p),a-=f,c.splice(0,f),p.splice(64-f),c=c.concat(p)}return c[63]=0===c[63]?1:0,(0,u.default)(parseInt(c.join(""),2),a)<r.sample.percent}(t,r):(n=r.sample.percent,Math.random()<=n)));var n}function y(t,r){for(var n=0;n<8;n++)for(var e=t[n],o=128;o>=1;o/=2)e-o>=0?(e-=o,r.push(1)):r.push(0)}r.default=function(t,r){for(var n=t,e=0,o=r;e<o.length;e++){var i=o[e];switch(i.type){case"drop":return null;case"drop_properties":f(n,i.config);break;case"allow_properties":s(n,i.config);break;case"sample_event":if(v(n,i.config))break;return null;case"map_properties":l(n,i.config);break;case"hash_properties":break;default:throw new Error('Transformer of type "'.concat(i.type,'" is unsupported.'))}}return n}},4966:function(t,r,n){var e=this&&this.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(r,"__esModule",{value:!0}),r.unset=void 0;var o=e(n(7843));r.unset=function(t,r){if((0,o.default)(t,r)){for(var n=r.split("."),e=n.pop();n.length&&"\\"===n[n.length-1].slice(-1);)e=n.pop().slice(0,-1)+"."+e;for(;n.length;)t=t[r=n.shift()];return delete t[e]}return!0}},3304:function(t){var r="function"==typeof Float64Array?Float64Array:void 0;t.exports=r},7382:function(t,r,n){var e,o=n(5569),i=n(3304),u=n(8482);e=o()?i:u,t.exports=e},8482:function(t){t.exports=function(){throw new Error("not implemented")}},6322:function(t,r,n){var e,o=n(2508),i=n(5679),u=n(882);e=o()?i:u,t.exports=e},882:function(t){t.exports=function(){throw new Error("not implemented")}},5679:function(t){var r="function"==typeof Uint16Array?Uint16Array:void 0;t.exports=r},4773:function(t,r,n){var e,o=n(9773),i=n(3004),u=n(3078);e=o()?i:u,t.exports=e},3078:function(t){t.exports=function(){throw new Error("not implemented")}},3004:function(t){var r="function"==typeof Uint32Array?Uint32Array:void 0;t.exports=r},7980:function(t,r,n){var e,o=n(8114),i=n(6737),u=n(3357);e=o()?i:u,t.exports=e},3357:function(t){t.exports=function(){throw new Error("not implemented")}},6737:function(t){var r="function"==typeof Uint8Array?Uint8Array:void 0;t.exports=r},2684:function(t){var r="function"==typeof Float64Array?Float64Array:null;t.exports=r},5569:function(t,r,n){var e=n(3876);t.exports=e},3876:function(t,r,n){var e=n(1448),o=n(2684);t.exports=function(){var t,r;if("function"!=typeof o)return!1;try{r=new o([1,3.14,-3.14,NaN]),t=e(r)&&1===r[0]&&3.14===r[1]&&-3.14===r[2]&&r[3]!=r[3]}catch(r){t=!1}return t}},9048:function(t,r,n){var e=n(3763);t.exports=e},3763:function(t){var r=Object.prototype.hasOwnProperty;t.exports=function(t,n){return null!=t&&r.call(t,n)}},7009:function(t,r,n){var e=n(6784);t.exports=e},6784:function(t){t.exports=function(){return"function"==typeof Symbol&&"symbol"==typeof Symbol("foo")}},3123:function(t,r,n){var e=n(8481);t.exports=e},8481:function(t,r,n){var e=n(7009)();t.exports=function(){return e&&"symbol"==typeof Symbol.toStringTag}},2508:function(t,r,n){var e=n(3403);t.exports=e},3403:function(t,r,n){var e=n(768),o=n(9668),i=n(187);t.exports=function(){var t,r;if("function"!=typeof i)return!1;try{r=new i(r=[1,3.14,-3.14,o+1,o+2]),t=e(r)&&1===r[0]&&3===r[1]&&r[2]===o-2&&0===r[3]&&1===r[4]}catch(r){t=!1}return t}},187:function(t){var r="function"==typeof Uint16Array?Uint16Array:null;t.exports=r},9773:function(t,r,n){var e=n(2822);t.exports=e},2822:function(t,r,n){var e=n(2744),o=n(3899),i=n(746);t.exports=function(){var t,r;if("function"!=typeof i)return!1;try{r=new i(r=[1,3.14,-3.14,o+1,o+2]),t=e(r)&&1===r[0]&&3===r[1]&&r[2]===o-2&&0===r[3]&&1===r[4]}catch(r){t=!1}return t}},746:function(t){var r="function"==typeof Uint32Array?Uint32Array:null;t.exports=r},8114:function(t,r,n){var e=n(8066);t.exports=e},8066:function(t,r,n){var e=n(8279),o=n(3443),i=n(2731);t.exports=function(){var t,r;if("function"!=typeof i)return!1;try{r=new i(r=[1,3.14,-3.14,o+1,o+2]),t=e(r)&&1===r[0]&&3===r[1]&&r[2]===o-2&&0===r[3]&&1===r[4]}catch(r){t=!1}return t}},2731:function(t){var r="function"==typeof Uint8Array?Uint8Array:null;t.exports=r},1448:function(t,r,n){var e=n(1453);t.exports=e},1453:function(t,r,n){var e=n(6208),o="function"==typeof Float64Array;t.exports=function(t){return o&&t instanceof Float64Array||"[object Float64Array]"===e(t)}},9331:function(t,r,n){var e=n(7980),o={uint16:n(6322),uint8:e};t.exports=o},5902:function(t,r,n){var e=n(4106);t.exports=e},4106:function(t,r,n){var e,o,i=n(9331);(o=new i.uint16(1))[0]=4660,e=52===new i.uint8(o.buffer)[0],t.exports=e},768:function(t,r,n){var e=n(3823);t.exports=e},3823:function(t,r,n){var e=n(6208),o="function"==typeof Uint16Array;t.exports=function(t){return o&&t instanceof Uint16Array||"[object Uint16Array]"===e(t)}},2744:function(t,r,n){var e=n(2326);t.exports=e},2326:function(t,r,n){var e=n(6208),o="function"==typeof Uint32Array;t.exports=function(t){return o&&t instanceof Uint32Array||"[object Uint32Array]"===e(t)}},8279:function(t,r,n){var e=n(208);t.exports=e},208:function(t,r,n){var e=n(6208),o="function"==typeof Uint8Array;t.exports=function(t){return o&&t instanceof Uint8Array||"[object Uint8Array]"===e(t)}},6315:function(t){t.exports=1023},1686:function(t){t.exports=2147483647},3105:function(t){t.exports=2146435072},3449:function(t){t.exports=2147483648},6988:function(t){t.exports=-1023},9777:function(t){t.exports=1023},3690:function(t){t.exports=-1074},2918:function(t,r,n){var e=n(4772).NEGATIVE_INFINITY;t.exports=e},4165:function(t){var r=Number.POSITIVE_INFINITY;t.exports=r},6488:function(t){t.exports=22250738585072014e-324},9668:function(t){t.exports=65535},3899:function(t){t.exports=4294967295},3443:function(t){t.exports=255},7011:function(t,r,n){var e=n(812);t.exports=e},812:function(t,r,n){var e=n(4165),o=n(2918);t.exports=function(t){return t===e||t===o}},1883:function(t,r,n){var e=n(1797);t.exports=e},1797:function(t){t.exports=function(t){return t!=t}},513:function(t,r,n){var e=n(5760);t.exports=e},5760:function(t){t.exports=function(t){return Math.abs(t)}},5848:function(t,r,n){var e=n(677);t.exports=e},677:function(t,r,n){var e=n(3449),o=n(1686),i=n(7838),u=n(1921),a=n(2490),c=[0,0];t.exports=function(t,r){var n,f;return i.assign(t,c,1,0),n=c[0],n&=o,f=u(r),a(n|=f&=e,c[1])}},5500:function(t,r,n){var e=n(8397);t.exports=e},8397:function(t,r,n){var e=n(4165),o=n(2918),i=n(6315),u=n(9777),a=n(6988),c=n(3690),f=n(1883),s=n(7011),p=n(5848),l=n(4948),v=n(8478),y=n(7838),d=n(2490),h=[0,0],x=[0,0];t.exports=function(t,r){var n,b;return 0===t||f(t)||s(t)?t:(l(h,t),r+=h[1],(r+=v(t=h[0]))<c?p(0,t):r>u?t<0?o:e:(r<=a?(r+=52,b=2220446049250313e-31):b=1,y(x,t),n=x[0],n&=2148532223,b*d(n|=r+i<<20,x[1])))}},4772:function(t,r,n){var e=n(7548);t.exports=e},7548:function(t){t.exports=Number},8478:function(t,r,n){var e=n(4500);t.exports=e},4500:function(t,r,n){var e=n(1921),o=n(3105),i=n(6315);t.exports=function(t){var r=e(t);return(r=(r&o)>>>20)-i|0}},2490:function(t,r,n){var e=n(9639);t.exports=e},4445:function(t,r,n){var e,o,i;!0===n(5902)?(o=1,i=0):(o=0,i=1),e={HIGH:o,LOW:i},t.exports=e},9639:function(t,r,n){var e=n(4773),o=n(7382),i=n(4445),u=new o(1),a=new e(u.buffer),c=i.HIGH,f=i.LOW;t.exports=function(t,r){return a[c]=t,a[f]=r,u[0]}},5646:function(t,r,n){var e;e=!0===n(5902)?1:0,t.exports=e},1921:function(t,r,n){var e=n(6285);t.exports=e},6285:function(t,r,n){var e=n(4773),o=n(7382),i=n(5646),u=new o(1),a=new e(u.buffer);t.exports=function(t){return u[0]=t,a[i]}},9024:function(t,r,n){var e=n(6488),o=n(7011),i=n(1883),u=n(513);t.exports=function(t,r,n,a){return i(t)||o(t)?(r[a]=t,r[a+n]=0,r):0!==t&&u(t)<e?(r[a]=4503599627370496*t,r[a+n]=-52,r):(r[a]=t,r[a+n]=0,r)}},4948:function(t,r,n){var e=n(7576),o=n(9422);e(o,"assign",n(9024)),t.exports=o},9422:function(t,r,n){var e=n(9024);t.exports=function(t){return e(t,[0,0],1,0)}},7838:function(t,r,n){var e=n(4010);t.exports=e},5782:function(t,r,n){var e,o,i;!0===n(5902)?(o=1,i=0):(o=0,i=1),e={HIGH:o,LOW:i},t.exports=e},4010:function(t,r,n){var e=n(4903);t.exports=function(t,r){return 1===arguments.length?e([0,0],t):e(t,r)}},4903:function(t,r,n){var e=n(4773),o=n(7382),i=n(5782),u=new o(1),a=new e(u.buffer),c=i.HIGH,f=i.LOW;t.exports=function(t,r){return u[0]=r,t[0]=a[c],t[1]=a[f],t}},7576:function(t,r,n){var e=n(7063);t.exports=e},7063:function(t,r,n){var e=n(6691);t.exports=function(t,r,n){e(t,r,{configurable:!1,enumerable:!1,writable:!1,value:n})}},2073:function(t){var r=Object.defineProperty;t.exports=r},1680:function(t){var r="function"==typeof Object.defineProperty?Object.defineProperty:null;t.exports=r},1471:function(t,r,n){var e=n(1680);t.exports=function(){try{return e({},"x",{}),!0}catch(t){return!1}}},6691:function(t,r,n){var e,o=n(1471),i=n(2073),u=n(1309);e=o()?i:u,t.exports=e},1309:function(t){var r=Object.prototype,n=r.toString,e=r.__defineGetter__,o=r.__defineSetter__,i=r.__lookupGetter__,u=r.__lookupSetter__;t.exports=function(t,a,c){var f,s,p,l;if("object"!=typeof t||null===t||"[object Array]"===n.call(t))throw new TypeError("invalid argument. First argument must be an object. Value: `"+t+"`.");if("object"!=typeof c||null===c||"[object Array]"===n.call(c))throw new TypeError("invalid argument. Property descriptor must be an object. Value: `"+c+"`.");if((s="value"in c)&&(i.call(t,a)||u.call(t,a)?(f=t.__proto__,t.__proto__=r,delete t[a],t[a]=c.value,t.__proto__=f):t[a]=c.value),p="get"in c,l="set"in c,s&&(p||l))throw new Error("invalid argument. Cannot specify one or more accessors and a value or writable attribute in the property descriptor.");return p&&e&&e.call(t,a,c.get),l&&o&&o.call(t,a,c.set),t}},6208:function(t,r,n){var e,o=n(3123),i=n(7407),u=n(4210);e=o()?u:i,t.exports=e},7407:function(t,r,n){var e=n(173);t.exports=function(t){return e.call(t)}},4210:function(t,r,n){var e=n(9048),o=n(1403),i=n(173);t.exports=function(t){var r,n,u;if(null==t)return i.call(t);n=t[o],r=e(t,o);try{t[o]=void 0}catch(r){return i.call(t)}return u=i.call(t),r?t[o]=n:delete t[o],u}},173:function(t){var r=Object.prototype.toString;t.exports=r},1403:function(t){var r="function"==typeof Symbol?Symbol.toStringTag:"";t.exports=r},7843:function(t){t.exports=function(t,r,n,e,o){for(r=r.split?r.split("."):r,e=0;e<r.length;e++)t=t?t[r[e]]:o;return t===o?n:t}},2341:function(t,r){r.dset=function(t,r,n){r.split&&(r=r.split("."));for(var e,o,i=0,u=r.length,a=t;i<u&&"__proto__"!==(o=r[i++])&&"constructor"!==o&&"prototype"!==o;)a=a[o]=i===u?n:typeof(e=a[o])==typeof r?e:0*r[i]!=0||~(""+r[i]).indexOf(".")?{}:[]}},2263:function(t,r,n){n.r(r),n.d(r,{default:function(){return i}});for(var e=[],o=0;o<64;)e[o]=0|4294967296*Math.sin(++o%Math.PI);function i(t){var r,n,i,u=[r=1732584193,n=4023233417,~r,~n],a=[],c=unescape(encodeURI(t))+"",f=c.length;for(t=--f/4+2|15,a[--t]=8*f;~f;)a[f>>2]|=c.charCodeAt(f)<<8*f--;for(o=c=0;o<t;o+=16){for(f=u;c<64;f=[i=f[3],r+((i=f[0]+[r&n|~r&i,i&r|~i&n,r^n^i,n^(r|~i)][f=c>>4]+e[c]+~~a[o|15&[c,5*c+1,3*c+5,7*c][f]])<<(f=[7,12,17,22,5,9,14,20,4,11,16,23,6,10,15,21][4*f+c++%4])|i>>>-f),r,n])r=0|f[1],n=f[2];for(c=4;c;)u[--c]+=f[c]}for(t="";c<32;)t+=(u[c>>3]>>4*(1^c++)&15).toString(16);return t}}},r={};function n(e){var o=r[e];if(void 0!==o)return o.exports;var i=r[e]={exports:{}};return t[e].call(i.exports,i,i.exports,n),i.exports}return n.d=function(t,r){for(var e in r)n.o(r,e)&&!n.o(t,e)&&Object.defineProperty(t,e,{enumerable:!0,get:r[e]})},n.o=function(t,r){return Object.prototype.hasOwnProperty.call(t,r)},n.r=function(t){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})},n(2870)}()}}]);
|
|
Binary file
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@customerio/cdp-analytics-browser",
|
|
3
|
-
"version": "0.3.
|
|
3
|
+
"version": "0.3.9",
|
|
4
4
|
"repository": {
|
|
5
5
|
"type": "git",
|
|
6
6
|
"url": "https://github.com/customerio/cdp-analytics-js",
|
|
@@ -48,11 +48,11 @@
|
|
|
48
48
|
}
|
|
49
49
|
],
|
|
50
50
|
"dependencies": {
|
|
51
|
-
"@customerio/cdp-analytics-core": "0.3.
|
|
51
|
+
"@customerio/cdp-analytics-core": "0.3.9",
|
|
52
52
|
"@lukeed/uuid": "^2.0.0",
|
|
53
53
|
"@segment/analytics.js-video-plugins": "^0.2.1",
|
|
54
54
|
"@segment/facade": "^3.4.9",
|
|
55
|
-
"customerio-gist-web": "3.
|
|
55
|
+
"customerio-gist-web": "3.18.0",
|
|
56
56
|
"dset": "^3.1.2",
|
|
57
57
|
"js-cookie": "3.0.1",
|
|
58
58
|
"node-fetch": "^2.6.7",
|
|
@@ -97,7 +97,7 @@
|
|
|
97
97
|
"terser-webpack-plugin": "^5.1.4",
|
|
98
98
|
"ts-loader": "^9.1.1",
|
|
99
99
|
"ts-node": "^10.8.0",
|
|
100
|
-
"webpack": "^5.
|
|
100
|
+
"webpack": "^5.95.0",
|
|
101
101
|
"webpack-bundle-analyzer": "^4.4.2",
|
|
102
102
|
"webpack-cli": "^4.8.0"
|
|
103
103
|
},
|
|
@@ -12,6 +12,7 @@ import type { Context } from '../context'
|
|
|
12
12
|
import type { CustomerioEvent } from '../events'
|
|
13
13
|
import type { Group, User } from '../user'
|
|
14
14
|
import type { LegacyIntegration } from '../../plugins/ajs-destination/types'
|
|
15
|
+
import type { InboxAPI } from '../../plugins/in-app-plugin'
|
|
15
16
|
import { CoreAnalytics } from '@customerio/cdp-analytics-core'
|
|
16
17
|
|
|
17
18
|
// we can define a contract because:
|
|
@@ -88,6 +89,13 @@ export interface AnalyticsCore extends CoreAnalytics {
|
|
|
88
89
|
deregister(...plugins: string[]): Promise<Context>
|
|
89
90
|
user(): User
|
|
90
91
|
readonly VERSION: string
|
|
92
|
+
/**
|
|
93
|
+
* Access inbox functionality provided by the Customer.io In-App Plugin.
|
|
94
|
+
* Only available when the In-App Plugin is loaded.
|
|
95
|
+
* @param topics - Optional topics to filter inbox messages
|
|
96
|
+
* @returns InboxAPI interface for managing inbox messages
|
|
97
|
+
*/
|
|
98
|
+
inbox?(...topics: string[]): InboxAPI
|
|
91
99
|
}
|
|
92
100
|
|
|
93
101
|
/**
|
package/src/core/buffer/index.ts
CHANGED
|
@@ -241,6 +241,12 @@ export class AnalyticsBuffered
|
|
|
241
241
|
register = this._createMethod('register')
|
|
242
242
|
deregister = this._createMethod('deregister')
|
|
243
243
|
user = this._createMethod('user')
|
|
244
|
+
inbox(...topics: string[]): import('../../plugins/in-app-plugin').InboxAPI {
|
|
245
|
+
if (this.instance?.inbox) {
|
|
246
|
+
return this.instance.inbox(...topics)
|
|
247
|
+
}
|
|
248
|
+
throw new Error('Customer.io In-App Plugin is not loaded yet. Ensure the plugin is initialized before calling inbox().')
|
|
249
|
+
}
|
|
244
250
|
readonly VERSION = version
|
|
245
251
|
|
|
246
252
|
private _createMethod<T extends PreInitMethodName>(methodName: T) {
|
package/src/generated/version.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
// This file is generated.
|
|
2
|
-
export const version = '0.3.
|
|
2
|
+
export const version = '0.3.9'
|
|
@@ -0,0 +1,163 @@
|
|
|
1
|
+
export interface GistInboxMessage {
|
|
2
|
+
messageType: string
|
|
3
|
+
expiry: string
|
|
4
|
+
priority: number
|
|
5
|
+
topics?: string[]
|
|
6
|
+
properties: { [key: string]: any }
|
|
7
|
+
queueId: string
|
|
8
|
+
userToken: string
|
|
9
|
+
deliveryId: string
|
|
10
|
+
sentAt: string
|
|
11
|
+
opened: boolean
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
export interface InboxMessage {
|
|
15
|
+
// Unique identifier for this messeage
|
|
16
|
+
readonly messageId: string
|
|
17
|
+
|
|
18
|
+
// If the message has been marked opened
|
|
19
|
+
readonly opened: boolean
|
|
20
|
+
|
|
21
|
+
// The properties payload of the message
|
|
22
|
+
readonly properties: { [key: string]: any }
|
|
23
|
+
|
|
24
|
+
// When the message was sent
|
|
25
|
+
readonly sentAt: string
|
|
26
|
+
|
|
27
|
+
/**
|
|
28
|
+
* Marks this message as opened
|
|
29
|
+
* @returns Promise that resolves when the message is marked as opened
|
|
30
|
+
*/
|
|
31
|
+
markOpened(): Promise<void>
|
|
32
|
+
|
|
33
|
+
/**
|
|
34
|
+
* Marks this message as unopened
|
|
35
|
+
* @returns Promise that resolves when the message is marked as unopened
|
|
36
|
+
*/
|
|
37
|
+
markUnopened(): Promise<void>
|
|
38
|
+
|
|
39
|
+
/**
|
|
40
|
+
* Marks this message as deleted
|
|
41
|
+
* @returns Promise that resolves when the message is deleted
|
|
42
|
+
*/
|
|
43
|
+
markDeleted(): Promise<void>
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
export interface InboxAPI {
|
|
47
|
+
/**
|
|
48
|
+
* Returns the total number of messages
|
|
49
|
+
* @returns Promise that resolves to the total count of messages
|
|
50
|
+
*/
|
|
51
|
+
total(): Promise<number>
|
|
52
|
+
|
|
53
|
+
/**
|
|
54
|
+
* Returns the count of unopened messages
|
|
55
|
+
* @returns Promise that resolves to the count of unopened messages
|
|
56
|
+
*/
|
|
57
|
+
totalUnopened(): Promise<number>
|
|
58
|
+
|
|
59
|
+
/**
|
|
60
|
+
* Returns all inbox messages
|
|
61
|
+
* @returns Promise that resolves to an array of inbox messages
|
|
62
|
+
*/
|
|
63
|
+
messages(): Promise<InboxMessage[]>
|
|
64
|
+
|
|
65
|
+
/**
|
|
66
|
+
* Subscribe to inbox message updates
|
|
67
|
+
* @param callback - Function called with array of InboxMessage objects when the message list changes.
|
|
68
|
+
* @returns Unsubscribe function to remove the listener
|
|
69
|
+
*/
|
|
70
|
+
onUpdates(callback: (messages: InboxMessage[]) => void): () => void
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
function createInboxMessage(
|
|
74
|
+
gist: any,
|
|
75
|
+
gistMessage: GistInboxMessage
|
|
76
|
+
): InboxMessage {
|
|
77
|
+
return {
|
|
78
|
+
sentAt: gistMessage.sentAt,
|
|
79
|
+
messageId: gistMessage.queueId,
|
|
80
|
+
opened: gistMessage?.opened === true,
|
|
81
|
+
properties: gistMessage.properties,
|
|
82
|
+
markOpened: async () => {
|
|
83
|
+
await gist.updateInboxMessageOpenState(gistMessage.queueId, true)
|
|
84
|
+
},
|
|
85
|
+
markUnopened: async () => {
|
|
86
|
+
await gist.updateInboxMessageOpenState(gistMessage.queueId, false)
|
|
87
|
+
},
|
|
88
|
+
markDeleted: async () => {
|
|
89
|
+
await gist.removeInboxMessage(gistMessage.queueId)
|
|
90
|
+
},
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
async function getFilteredMessages(
|
|
95
|
+
gist: any,
|
|
96
|
+
topics: string[],
|
|
97
|
+
messages: GistInboxMessage[] | null
|
|
98
|
+
): Promise<GistInboxMessage[]> {
|
|
99
|
+
let allMessages = messages
|
|
100
|
+
if (!allMessages || !Array.isArray(allMessages)) {
|
|
101
|
+
allMessages = (await gist.getInboxMessages()) as GistInboxMessage[]
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
if (!allMessages || !Array.isArray(allMessages)) {
|
|
105
|
+
return []
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
if (topics.length === 0) {
|
|
109
|
+
return allMessages
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
return allMessages.filter((message) => {
|
|
113
|
+
const messageTopics = message.topics
|
|
114
|
+
if (!messageTopics || messageTopics.length === 0) {
|
|
115
|
+
return false
|
|
116
|
+
}
|
|
117
|
+
return messageTopics.some((messageTopic) => topics.includes(messageTopic))
|
|
118
|
+
})
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
export function createInboxAPI(gist: any, topics: string[]): InboxAPI {
|
|
122
|
+
return {
|
|
123
|
+
total: async () => {
|
|
124
|
+
const messages = await getFilteredMessages(gist, topics, null)
|
|
125
|
+
return messages.length
|
|
126
|
+
},
|
|
127
|
+
totalUnopened: async () => {
|
|
128
|
+
const messages = await getFilteredMessages(gist, topics, null)
|
|
129
|
+
return messages.filter((message) => {
|
|
130
|
+
return message?.opened !== true
|
|
131
|
+
}).length
|
|
132
|
+
},
|
|
133
|
+
messages: async (): Promise<InboxMessage[]> => {
|
|
134
|
+
const messages = await getFilteredMessages(gist, topics, null)
|
|
135
|
+
return messages.map((msg) => createInboxMessage(gist, msg))
|
|
136
|
+
},
|
|
137
|
+
onUpdates: (callback: (messages: InboxMessage[]) => void): (() => void) => {
|
|
138
|
+
const handler = async (gistMessages: GistInboxMessage[]) => {
|
|
139
|
+
try {
|
|
140
|
+
const filteredMessages = await getFilteredMessages(
|
|
141
|
+
gist,
|
|
142
|
+
topics,
|
|
143
|
+
gistMessages
|
|
144
|
+
)
|
|
145
|
+
const inboxMessages = filteredMessages.map((msg) =>
|
|
146
|
+
createInboxMessage(gist, msg)
|
|
147
|
+
)
|
|
148
|
+
|
|
149
|
+
callback(inboxMessages)
|
|
150
|
+
} catch (error) {
|
|
151
|
+
console.error('Error processing inbox updates:', error)
|
|
152
|
+
}
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
gist.events.on('messageInboxUpdated', handler)
|
|
156
|
+
|
|
157
|
+
// Return unsubscribe function
|
|
158
|
+
return () => {
|
|
159
|
+
gist.events.off('messageInboxUpdated', handler)
|
|
160
|
+
}
|
|
161
|
+
},
|
|
162
|
+
}
|
|
163
|
+
}
|
|
@@ -11,8 +11,11 @@ import {
|
|
|
11
11
|
ContentType,
|
|
12
12
|
} from './events'
|
|
13
13
|
import Gist from 'customerio-gist-web'
|
|
14
|
+
import type { InboxAPI, InboxMessage, GistInboxMessage } from './inbox_messages'
|
|
15
|
+
import { createInboxAPI } from './inbox_messages'
|
|
14
16
|
|
|
15
17
|
export { InAppEvents }
|
|
18
|
+
export type { InboxAPI, InboxMessage }
|
|
16
19
|
|
|
17
20
|
export type InAppPluginSettings = {
|
|
18
21
|
siteId: string | undefined
|
|
@@ -96,6 +99,12 @@ export function InAppPlugin(settings: InAppPluginSettings): Plugin {
|
|
|
96
99
|
}
|
|
97
100
|
})
|
|
98
101
|
|
|
102
|
+
Gist.events.on('inboxMessageAction', (params: any) => {
|
|
103
|
+
if (params?.message && params?.action !== '') {
|
|
104
|
+
_handleInboxMessageAction(_analytics, params.message, params.action)
|
|
105
|
+
}
|
|
106
|
+
})
|
|
107
|
+
|
|
99
108
|
Gist.events.on('messageAction', (params: any) => {
|
|
100
109
|
const deliveryId: string = params?.message?.properties?.gist?.campaignId
|
|
101
110
|
if (settings.events) {
|
|
@@ -214,6 +223,14 @@ export function InAppPlugin(settings: InAppPluginSettings): Plugin {
|
|
|
214
223
|
|
|
215
224
|
await syncUserToken(ctx)
|
|
216
225
|
attachListeners()
|
|
226
|
+
;(instance as any).inbox = (...topics: string[]): InboxAPI => {
|
|
227
|
+
if (!_pluginLoaded) {
|
|
228
|
+
throw new Error(
|
|
229
|
+
'Customer.io In-App Plugin is not loaded yet. Ensure the plugin is initialized before calling inbox().'
|
|
230
|
+
)
|
|
231
|
+
}
|
|
232
|
+
return createInboxAPI(Gist, topics)
|
|
233
|
+
}
|
|
217
234
|
|
|
218
235
|
_pluginLoaded = true
|
|
219
236
|
|
|
@@ -236,6 +253,20 @@ export function InAppPlugin(settings: InAppPluginSettings): Plugin {
|
|
|
236
253
|
return customerio
|
|
237
254
|
}
|
|
238
255
|
|
|
256
|
+
function _handleInboxMessageAction(
|
|
257
|
+
analyticsInstance: Analytics,
|
|
258
|
+
message: GistInboxMessage,
|
|
259
|
+
action: string
|
|
260
|
+
) {
|
|
261
|
+
const deliveryId = message?.deliveryId
|
|
262
|
+
if (action === 'opened' && typeof deliveryId !== 'undefined' && deliveryId !== '') {
|
|
263
|
+
void analyticsInstance.track(JourneysEvents.Metric, {
|
|
264
|
+
deliveryId: message.deliveryId,
|
|
265
|
+
metric: JourneysEvents.Opened,
|
|
266
|
+
})
|
|
267
|
+
}
|
|
268
|
+
}
|
|
269
|
+
|
|
239
270
|
function _error(msg: string) {
|
|
240
271
|
console.error(`[Customer.io In-App Plugin] ${msg}`)
|
|
241
272
|
}
|
package/dist/umd/646.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
(self.webpackChunk_customerio_cdp_analytics_browser=self.webpackChunk_customerio_cdp_analytics_browser||[]).push([[646],{1369:function(e,t,n){"use strict";n.d(t,{Z:function(){return We}});class s{on(e,t){var n=this[e];n?n.push(t):this[e]=[t]}dispatch(e,t){var n=this[e];n&&n.forEach((e=>e(t)))}}function i(e){We.config&&We.config.logging&&console.log(`Gist: ${e}`)}var a,o=new Uint8Array(16);function r(){if(!a&&!(a="undefined"!=typeof crypto&&crypto.getRandomValues&&crypto.getRandomValues.bind(crypto)||"undefined"!=typeof msCrypto&&"function"==typeof msCrypto.getRandomValues&&msCrypto.getRandomValues.bind(msCrypto)))throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");return a(o)}var c=/^(?:[0-9a-f]{8}-[0-9a-f]{4}-[1-5][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}|00000000-0000-0000-0000-000000000000)$/i;for(var u=function(e){return"string"==typeof e&&c.test(e)},d=[],g=0;g<256;++g)d.push((g+256).toString(16).substr(1));var l=function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0,n=(d[e[t+0]]+d[e[t+1]]+d[e[t+2]]+d[e[t+3]]+"-"+d[e[t+4]]+d[e[t+5]]+"-"+d[e[t+6]]+d[e[t+7]]+"-"+d[e[t+8]]+d[e[t+9]]+"-"+d[e[t+10]]+d[e[t+11]]+d[e[t+12]]+d[e[t+13]]+d[e[t+14]]+d[e[t+15]]).toLowerCase();if(!u(n))throw TypeError("Stringified UUID is invalid");return n};var m=function(e,t,n){var s=(e=e||{}).random||(e.rng||r)();if(s[6]=15&s[6]|64,s[8]=63&s[8]|128,t){n=n||0;for(var i=0;i<16;++i)t[n+i]=s[i];return t}return l(s)};const f="gist.web.isPersistingSession";function h(e,t,n=null){var s=n;s||(s=new Date).setDate(s.getDate()+365);const i={value:t,expiry:s};y().setItem(e,JSON.stringify(i))}function p(e){const t=y().getItem(e);if(!t)return null;const n=JSON.parse(t),s=new Date,i=new Date(n.expiry),a=e.startsWith("gist.web.message.broadcasts")&&!e.endsWith("shouldShow")&&!e.endsWith("numberOfTimesShown")||e.startsWith("gist.web.message.user")&&!e.endsWith("seen"),o=new Date(s.getTime()+366e4);return a&&i.getTime()>o.getTime()||s.getTime()>i.getTime()?(w(e),null):n.value}function w(e){y().removeItem(e)}function v(){const e=sessionStorage.getItem(f);return null===e?(sessionStorage.setItem(f,"true"),!0):"true"===e}function y(){return v()?localStorage:sessionStorage}const b="gist.web.userQueueUseSSE",S="gist.web.activeSSEConnection";let I,E=30;const $={RENDERER_HOST:"https://code.gist.build",ENGINE_API_ENDPOINT:{prod:"https://engine.api.gist.build",dev:"https://engine.api.dev.gist.build",local:"http://engine.api.local.gist.build:82"},GIST_QUEUE_API_ENDPOINT:{prod:"https://consumer.cloud.gist.build",dev:"https://consumer.cloud.dev.gist.build",local:"http://api.local.gist.build:86"},GIST_QUEUE_REALTIME_API_ENDPOINT:{prod:"https://realtime.cloud.gist.build",dev:"https://realtime.cloud.dev.gist.build",local:"http://api.local.gist.build:3000"},GIST_VIEW_ENDPOINT:{prod:"https://renderer.gist.build/3.0",dev:"https://renderer.gist.build/3.0",local:"http://app.local.gist.build:8080/web"},getSdkId:function(){return I||(I=m()),I},useSSE:function(){return p(b)??!1},setUseSSEFlag:function(e){h(b,e,new Date((new Date).getTime()+6e4)),i(`Set user uses SSE to "${e}"`)},removeActiveSSEConnection:function(){w(S)},setActiveSSEConnection:function(){h(S,$.getSdkId(),new Date((new Date).getTime()+$.getSSEHeartbeat()))},hasActiveSSEConnection:function(){return p(S)??!1},isSSEConnectionManagedBySDK:function(){return p(S)===$.getSdkId()},getSSEHeartbeat:function(){return 1e3*(E+5)},setSSEHeartbeat:function(e){e&&e>0&&(E=e)}};function x(){const e=$.GIST_QUEUE_API_ENDPOINT[We.config.env],t={"X-CIO-Site-Id":We.config.siteId,"X-CIO-Client-Platform":"web"},n=O();async function s(n,s={}){const i=e+n,a=new AbortController,o=setTimeout((()=>a.abort()),5e3);try{const e=await fetch(i,{method:s.method||"GET",headers:{...t,...s.headers||{}},body:s.method&&"GET"!==s.method.toUpperCase()?s.body:void 0,signal:a.signal});clearTimeout(o);const n=e.headers.get("content-type")?.includes("application/json"),r=n?await e.json():await e.text(),c=Object.fromEntries(e.headers.entries());if(e.status<200||e.status>=400)throw{response:{status:e.status,data:r,headers:c}};return{status:e.status,headers:c,data:r}}catch(e){throw clearTimeout(o),e.response||(e.response={status:0,data:e.message||"Unknown error"}),e}}return null!=n&&(t["X-Gist-Encoded-User-Token"]=n),s.post=(e,t={},n={})=>s(e,{method:"POST",body:JSON.stringify(t),headers:{"Content-Type":"application/json",...n.headers||{}}}),s}const T="gist.web.userLocale";var D=600,k=!1;const C="gist.web.userQueueNextPullCheck",M="gist.web.sessionId";async function R(){var e;try{if(!k){k=!0;var t={"X-Gist-User-Anonymous":N(),"Content-Language":null!==p(T)?p(T):navigator.language};e=await x().post(`/api/v3/users?sessionId=${q()}`,{},{headers:t})}}catch(t){t.response?e=t.response:i(`Error getting user queue: ${t}`)}finally{k=!1,function(e){if(e&&e.headers){var t=e.headers["x-gist-queue-polling-interval"];t&&t>0&&(D=t)}var n=new Date((new Date).getTime()+1e3*D);h(C,D,n)}(e),function(e){const t="true"===e?.headers?.["x-cio-use-sse"]?.toLowerCase();$.setUseSSEFlag(t)}(e)}return e}function q(){var e=p(M);return e||(e=m()),h(M,e,new Date((new Date).getTime()+18e5)),e}const L="gist.web.userToken",P="gist.web.usingGuestUserToken",A="gist.web.guestUserToken";function N(){return null!==p(P)}function U(){return p(L)}function _(){if(null===U()){var e=p(A);null==e&&(e=m(),h(A,e),i(`Set guest user token "${e}" with expiry date set to 1 year from today`)),h(L,e),h(P,!0),i(`Using anonymous session with token: "${e}"`)}}async function W(){var e=U();return null===e?null:await async function(e){const t=(new TextEncoder).encode(e),n=await crypto.subtle.digest("SHA-256",t),s=Array.from(new Uint8Array(n));return s.map((e=>e.toString(16).padStart(2,"0"))).join("")}(e)}function O(){var e=U();return null===e?null:btoa(e)}function H(e){const t={isEmbedded:!1,elementId:"",hasRouteRule:!1,routeRule:"",position:"",hasPosition:!1,shouldScale:!1,campaignId:null,messageWidth:414,overlayColor:"#00000033",persistent:!1,exitClick:!1,hasCustomWidth:!1},n=e?.properties?.gist;return n?{isEmbedded:!!n.elementId,elementId:n.elementId||"",hasRouteRule:!!n.routeRuleWeb,routeRule:n.routeRuleWeb||"",position:n.position||"",hasPosition:!!n.position,shouldScale:!!n.scale,campaignId:n.campaignId??null,messageWidth:n.messageWidth>0?n.messageWidth:t.messageWidth,hasCustomWidth:n.messageWidth>0,overlayColor:n.overlayColor||t.overlayColor,persistent:!!n.persistent,exitClick:!!n.exitClick}:t}var G=["x-gist-top","x-gist-floating-top","x-gist-bottom","x-gist-floating-bottom","x-gist-floating-bottom-left","x-gist-floating-bottom-right","x-gist-floating-top-left","x-gist-floating-top-right"];const V=["x-gist-top","x-gist-bottom","x-gist-floating-top","x-gist-floating-bottom"];function z(e,t,n,s){var a=Y(e);if(a){var o=K(n.instanceId);a.classList.add(o);var r=H(n),c=r.messageWidth+"px";V.includes(e)&&!r.hasCustomWidth&&(c="100%"),G.includes(e)&&(a.style.width=c),j(e)||(a.style.height="0px"),a.innerHTML=function(e,t,n){return function(e,t,n){var s=800;return t.messageWidth>s&&(s=t.messageWidth),`\n <div id="gist-embed">\n <style>\n #x-gist-floating-top, #x-gist-floating-top-left, #x-gist-floating-top-right {\n position: fixed;\n top: 0px;\n z-index: 1000000;\n }\n #x-gist-floating-bottom, #x-gist-floating-bottom-left, #x-gist-floating-bottom-right {\n position: fixed;\n bottom: 0px;\n z-index: 1000000;\n }\n #x-gist-bottom, #x-gist-top, #x-gist-floating-top, #x-gist-floating-bottom {\n left: 50%;\n transform: translate(-50%, 0%);\n }\n #x-gist-floating-top-right, #x-gist-floating-bottom-right {\n right: 0px;\n }\n #gist-embed {\n position: relative;\n height: 100%;\n width: 100%;\n }\n #gist-embed-container {\n position: relative;\n height: 100%;\n width: 100%;\n }\n #gist-embed-container .gist-frame {\n height: 100%;\n width: 100%;\n border: none;\n }\n #x-gist-top.${e},\n #x-gist-bottom.${e},\n #x-gist-floating-top.${e},\n #x-gist-floating-bottom.${e},\n #x-gist-floating-top-left.${e},\n #x-gist-floating-top-right.${e},\n #x-gist-floating-bottom-left.${e},\n #x-gist-floating-bottom-right.${e} {\n transition: height 0.1s ease-in-out;\n }\n @media (max-width: ${s}px) {\n #x-gist-top.${e},\n #x-gist-bottom.${e},\n #x-gist-floating-top.${e},\n #x-gist-floating-bottom.${e},\n #x-gist-floating-top-left.${e},\n #x-gist-floating-top-right.${e},\n #x-gist-floating-bottom-left.${e},\n #x-gist-floating-bottom-right.${e} {\n width: 100% !important;\n }\n }\n </style>\n <div id="gist-embed-container">\n <iframe id="${e}" class="gist-frame" src="${n}"></iframe>\n </div>\n </div>`}(K(t.instanceId),n,e)}(t,n,r),B(o,s)}else i(`Message could not be embedded, elementId ${e} not found.`)}function j(e){var t=Y(e);if(t)return t.style&&t.style.height&&"0px"!=t.style.height}function F(e,t,n){document.body.insertAdjacentHTML("afterbegin",function(e,t){var n=H(t);return function(e,t,n){var s=600;return t.messageWidth>s&&(s=t.messageWidth),`\n <div id="gist-embed-message">\n <style>\n #gist-overlay.gist-background {\n position: fixed;\n z-index: 9999999998;\n left: 0;\n top: 0;\n width: 100%;\n height: 100%;\n background-color: ${t.overlayColor};\n visibility: hidden;\n }\n #gist-overlay.gist-background.gist-visible {\n visibility: visible;\n }\n .gist-message {\n width: ${t.messageWidth}px;\n position: absolute;\n border: none;\n opacity: 0;\n transition: opacity 0.3s ease-in-out, height 0.1s ease-in-out;\n z-index: 9999999999;\n left: 50%;\n transform: translateX(-50%);\n }\n .gist-message.gist-visible {\n opacity: 1;\n pointer-events: auto;\n }\n .gist-message.gist-center {\n transform: translate(-50%, -50%);\n top: 50%;\n }\n .gist-message.gist-bottom {\n bottom: 0;\n }\n .gist-message.gist-top {\n top: 0;\n }\n @media (max-width: ${s}px) {\n .gist-message {\n width: 100%;\n }\n }\n </style>\n <div id="gist-overlay" class="gist-background">\n <iframe id="${e}" class="gist-message" src="${n}"></iframe>\n </div>\n </div>`}(K(t.instanceId),n,e)}(e,t)),B(K(t.instanceId),n)}function B(e,t){const n=document.getElementById(e);n&&(n.onload=function(){!function(e,t){const n=document.getElementById(e);n&&n.contentWindow&&n.contentWindow.postMessage({options:t},"*")}(e,t)})}function Q(e){var t=H(e),n=document.querySelector("#gist-overlay");if(n){n.classList.add("gist-visible");var s=document.querySelector(".gist-message");e.position?s.classList.add("gist-"+e.position):s.classList.add("gist-center"),setTimeout(Z,100),t.exitClick&&setTimeout((()=>function(e){var t=document.querySelector("#gist-overlay");t&&t.addEventListener("click",(function(){We.dismissMessage(e)}))}(e.instanceId)),1e3)}else X()}async function J(){var e,t=document.querySelector(".gist-message");t&&(t.classList.remove("gist-visible"),await(e=300,new Promise((t=>setTimeout(t,e))))),X()}function X(){var e=document.querySelector("#gist-embed-message");e&&e.parentNode.removeChild(e)}function K(e){return`gist-${e}`}function Z(){var e=document.querySelector(".gist-message");e&&e.classList.add("gist-visible")}function Y(e){try{var t=document.querySelector(`#${e}`);return t||null}catch{return null}}const ee="gist.web.customAttributes";let te=new Map;function ne(){const e=Array.from(te.entries()),t=new Date;t.setDate(t.getDate()+30),h(ee,e,t),i(`Saved ${te.size} custom attributes to storage with TTL of 30 days`)}!function(){const e=p(ee);if(e)try{te=new Map(e)}catch{te=new Map}else te=new Map}();async function se(e){const t=await oe();if(!t)return;const n=new Date;n.setMinutes(n.getMinutes()+60);h(t,e.filter(ae),n)}async function ie(e,t){return p(e).find((e=>e.queueId===t))}function ae(e){return e.properties&&e.properties.gist&&e.properties.gist.broadcast}async function oe(){const e=await W();return e?`gist.web.message.broadcasts.${e}`:null}function re(e,t){return`${e}.${t}.numberOfTimesShown`}function ce(e,t){return`${e}.${t}.shouldShow`}async function ue(e){const t=await ge();if(!t)return;const n=e.filter((e=>!(e.properties&&e.properties.gist&&e.properties.gist.broadcast))),s=new Date;s.setMinutes(s.getMinutes()+60),h(t,n,s)}async function de(){const e=await ge();if(!e)return[];const t=p(e)??[],n=await async function(){const e=await le();return e?p(e)??[]:[]}();return t.filter((e=>!n.includes(e.queueId)))}async function ge(){const e=await W();return e?`gist.web.message.user.${e}`:null}async function le(){const e=await W();return e?`gist.web.message.user.${e}.seen`:null}async function me(e){const t=await W();return t?`gist.web.message.user.${t}.message.${e}.loading`:null}async function fe(e){if(We.isDocumentVisible){if(We.overlayInstanceId)return i(`Message ${We.overlayInstanceId} already showing.`),null;var t=H(e);return e.instanceId=m(),e.overlay=!0,e.firstLoad=!0,e.shouldResizeHeight=!0,e.shouldScale=t.shouldScale,e.renderStartTime=(new Date).getTime(),We.overlayInstanceId=e.instanceId,We.currentMessages.push(e),be(e)}return i("Document hidden, not showing message now."),null}async function he(e,t){return We.isDocumentVisible?(e.instanceId=m(),e.overlay=!1,e.firstLoad=!0,e.shouldScale=!1,e.elementId=t,e.shouldResizeHeight=!j(t),e.renderStartTime=(new Date).getTime(),We.currentMessages.push(e),be(e,t)):(i("Document hidden, not showing message now."),null)}async function pe(e){e?(We.messageDismissed(e),e.overlay?await ye(!0,e):ve(e)):i(`Message with instance id: ${e.instanceId} not found`)}async function we(e){var t=H(e);e?t.persistent&&(i("Persistent message dismissed, logging view"),await De(e),await Se(e)):i(`Message with instance id: ${e.instanceId} not found`)}function ve(e){var t,n;Ee(e.instanceId),t=e.elementId,(n=Y(t))&&(n.classList.remove("gist-visible"),n.style.removeProperty("height"),n.innerHTML="")}async function ye(e,t){e?await J():X(),0==We.currentMessages.length&&(window.removeEventListener("message",Te),window.removeEventListener("touchstart",xe)),Ee(t.instanceId),We.overlayInstanceId=null}function be(e,t=null){if(t&&function(e){var t=Y(e);return!(!t||!t.classList.contains("gist-visible"))}(t))return i(`Message ${e.messageId} already showing in element ${t}.`),null;var n={endpoint:$.ENGINE_API_ENDPOINT[We.config.env],siteId:We.config.siteId,dataCenter:We.config.dataCenter,messageId:e.messageId,instanceId:e.instanceId,livePreview:!1,properties:e.properties,customAttributes:Object.fromEntries(new Map(te))},s=`${$.GIST_VIEW_ENDPOINT[We.config.env]}/index.html`;return window.addEventListener("message",Te),window.addEventListener("touchstart",xe),t?(G.includes(t)&&function(e){const t=document.createElement("div");t.id=e,"x-gist-top"===e?document.body.insertBefore(t,document.body.firstChild):document.body.insertAdjacentElement("beforeend",t);i("Top & bottom elements injected into page")}(t),z(t,s,e,n)):F(s,e,n),e}async function Se(e){i(`Message shown, logging view for: ${e.messageId}`);var t={};null!=e.queueId?(await De(e),t=await async function(e){try{return await x().post(`/api/v1/logs/queue/${e}`)}catch(e){return e.response}}(e.queueId)):t=await async function(e){try{return await x().post(`/api/v1/logs/message/${e}`)}catch(e){return e.response}}(e.messageId),200===t.status?i("Message view logged"):i(`Problem logging message: ${t.status}`)}function Ie(e){return We.currentMessages.find((t=>t.instanceId===e))}function Ee(e){We.currentMessages=We.currentMessages.filter((t=>t.instanceId!==e))}function $e(e,t){Ee(e),We.currentMessages.push(t)}function xe(){}async function Te(e){if(e.data.gist&&e.origin===$.RENDERER_HOST){var t=e.data.gist.instanceId,n=Ie(t);if(!n)return;var s=H(n);switch(e.data.gist.method){case"routeLoaded":var a=.001*((new Date).getTime()-n.renderStartTime);i(`Engine render for message: ${n.messageId} timer elapsed in ${a.toFixed(3)} seconds`),async function(e){const t=await me(e);if(!t)return!1;w(t)}(n.queueId),n.currentRoute=e.data.gist.parameters.route,n.firstLoad&&(n.overlay?Q(n):(g=n.elementId,(l=Y(g))&&l.classList.add("gist-visible")),We.messageShown(n),s.persistent?i("Persistent message shown, skipping logging view"):await Se(n),n.firstLoad=!1),$e(t,n);break;case"tap":var o=e.data.gist.parameters.action,r=e.data.gist.parameters.name;if(We.messageAction(n,o,r),e.data.gist.parameters.system&&!s.persistent){await pe(n);break}try{var c=new URL(o);if(c&&"gist:"===c.protocol)switch(c.href.replace("gist://","").split("?")[0]){case"close":await pe(n),await we(n),await ke(n),await Le();break;case"showMessage":var u=c.searchParams.get("messageId"),d=c.searchParams.get("properties");u&&(d&&(d=JSON.parse(atob(d))),await We.showMessage({messageId:u,properties:d}));break;case"loadPage":(c=c.href.substring(c.href.indexOf("?url=")+5))&&(c.startsWith("mailto:")||c.startsWith("https://")||c.startsWith("http://")||c.startsWith("/")?window.location.href=c:window.location.href=window.location+c)}}catch{}break;case"routeChanged":n.currentRoute=e.data.gist.parameters.route,n.renderStartTime=(new Date).getTime(),$e(t,n),i(`Route changed to: ${n.currentRoute}`);break;case"sizeChanged":i(`Size Changed Width: ${e.data.gist.parameters.width} - Height: ${e.data.gist.parameters.height}`),n.elementId&&!n.shouldResizeHeight||function(e,t){var n=Y(e.elementId?e.elementId:K(e.instanceId));if(n){var s=n.style;if(t.height>0)if(t.height>window.innerHeight){var i=1-(t.height/window.innerHeight-1);e.shouldScale&&i>=.4?(s.height=`${t.height}px`,s.transform=`translateX(-50%) translateY(-50%) scale(${i})`):s.height=`${window.innerHeight}px`}else s.height=`${t.height}px`}}(n,e.data.gist.parameters);break;case"titleChanged":i(`Overlay title changed to: ${e.data.gist.parameters.title}`),function(e,t){var n=Y(K(e));n&&(n.title=t)}(t,e.data.gist.parameters.title);break;case"eventDispatched":We.events.dispatch("eventDispatched",{name:e.data.gist.parameters.name,payload:e.data.gist.parameters.payload});break;case"error":case"routeError":We.messageError(n),We.overlayInstanceId?ye(!1,n):ve(n)}}var g,l}async function De(e){i(`Logging user message view locally for: ${e.queueId}`),ae(e)?await async function(e){i(`Marking broadcast ${e} as seen.`);const t=await oe();if(!t)return;const n=await ie(t,e);if(!n)return;const{broadcast:s}=n.properties.gist,a=re(t,e),o=ce(t,e);let r=p(a)||0;if(h(a,r+1),1===s.frequency.count)h(o,!1),i(`Marked broadcast ${e} as seen.`);else{let t=new Date;t.setSeconds(t.getSeconds()+s.frequency.delay),h(o,!1,t),i(`Marked broadcast ${e} as seen, broadcast was seen ${r+1} times, next show date is ${t}.`)}}(e.queueId):await async function(e){const t=await le();if(!t)return;const n=p(t)??[];n.push(e),h(t,n)}(e.queueId)}async function ke(e){ae(e)&&(i(`Logging broadcast dismissed locally for: ${e.queueId}`),await async function(e){i(`Marking broadcast ${e} as dismissed.`);const t=await oe();if(!t)return;const n=await ie(t,e);if(!n)return;const{broadcast:s}=n.properties.gist;if(!0===s.frequency.ignoreDismiss)return void i(`Broadcast ${e} is set to ignore dismiss.`);h(ce(t,e),!1),i(`Marked broadcast ${e} as dismissed and will not show again.`)}(e.queueId))}var Ce=(e,t)=>e().then((e=>new Promise((t=>setTimeout(t,e))))(t).then((()=>Ce(e,t)))),Me=!1;let Re=null;async function qe(){Me?await Le():U()?(i("Queue watcher started"),Me=!0,Ce((()=>new Promise((()=>async function(){if($.hasActiveSSEConnection())return!$.isSSEConnectionManagedBySDK()&&Re&&(i("Not the main instance, closing our SSE connection."),Ne()),void await Le();Re&&(i("SSE connection not active, closing it."),Ne());if($.useSSE()&&!N())return void await async function(){Ne();const e=(t=O(),null===t?(i("No user token available for SSE endpoint."),null):$.GIST_QUEUE_REALTIME_API_ENDPOINT[We.config.env]+`/api/v3/sse?userToken=${t}&siteId=${We.config.siteId}&sessionId=${q()}`);var t;if(null===e)return i("SSE endpoint not available, falling back to polling."),void await Ae();i(`Starting SSE queue listener on ${e}`),Re=new EventSource(e),$.setActiveSSEConnection(),Re.addEventListener("connected",(async e=>{try{i("SSE connection received:"),$.setUseSSEFlag(!0);var t=JSON.parse(e.data);t.heartbeat&&($.setSSEHeartbeat(t.heartbeat),i(`SSE heartbeat set to ${t.heartbeat} seconds`)),$.setActiveSSEConnection()}catch(e){i(`Failed to parse SSE settings: ${e}`)}w(C),await Ae()})),Re.addEventListener("messages",(async e=>{try{var t=JSON.parse(e.data);i("SSE message received:"),await ue(t),await se(t),await Le()}catch(e){i("Failed to parse SSE message"),Ne()}})),Re.addEventListener("error",(async e=>{i("SSE error received:"),Ne()})),Re.addEventListener("heartbeat",(async e=>{i("SSE heartbeat received:"),$.setActiveSSEConnection(),$.setUseSSEFlag(!0)}))}();await Ae()}()))),1e3)):i("User token not setup, queue not started.")}async function Le(){var e=await async function(){const e=await oe();return e?(p(e)??[]).filter((t=>{const{broadcast:n}=t.properties.gist,s=p(ce(e,t.queueId))??!0,i=p(re(e,t.queueId))||0,a=0===n.frequency.count;return s&&(a||i<n.frequency.count)})):[]}(),t=await de(),n=e.concat(t);i(`Messages in local queue: ${n.length}`);var s=n.sort(((e,t)=>e.priority-t.priority));for(const e of s)await Pe(e)}async function Pe(e){var t=H(e);if(t.hasRouteRule){var n=We.currentRoute;null==n&&(n=new URL(window.location.href).pathname);var s=t.routeRule;if(i(`Verifying route ${n} against rule: ${s}`),!new RegExp(s).test(n))return i(`Route ${n} does not match rule.`),!1}if(t.hasPosition&&(e.position=t.position),t.persistent||function(e){if(!ae(e))return!1;const{broadcast:t}=e.properties.gist;return 0===t.frequency.delay&&0===t.frequency.count}(e)||!await async function(e){const t=await me(e);return!!t&&null!==p(t)}(e.queueId)){var a=!1;return(a=t.isEmbedded?await he(e,t.elementId):await fe(e))&&async function(e){const t=await me(e);if(!t)return!1;h(t,!0,new Date(Date.now()+5e3))}(e.queueId),a}return i(`Not showing message with queueId ${e.queueId} because its already loading.`),!1}async function Ae(){if(U())if(We.isDocumentVisible)if(null===p(C)){var e=await R(),t=[];e?(200===e.status||204===e.status?(i("200 response, updating local store."),ue(t=e.data),se(t)):304===e.status&&i("304 response, using local store."),await Le()):i("There was an error while checking message queue.")}else i("Next queue pull scheduled for later.");else i("Document not visible, skipping queue check.");else i("User token reset, skipping queue check.")}function Ne(e=!1){e&&$.removeActiveSSEConnection(),(e||$.isSSEConnectionManagedBySDK())&&$.setUseSSEFlag(!1),Re&&(i("Stopping SSE queue listener..."),Re.close(),Re=null)}const Ue="cioPreviewId";function _e(){const e=new URLSearchParams(window.location.search).get(Ue);var t;return e&&(t=!1,sessionStorage.setItem(f,t),We.setUserToken(e),i(`Preview mode enabled with user token: ${e}`)),!v()}var We=class{static async setup(e){this.events=new s,this.config={useAnonymousSession:void 0!==e.useAnonymousSession&&e.useAnonymousSession,siteId:e.siteId,dataCenter:e.dataCenter,env:void 0===e.env?"prod":e.env,logging:void 0!==e.logging&&e.logging,experiments:void 0!==e.experiments&&e.experiments},this.currentMessages=[],this.overlayInstanceId=null,this.currentRoute=null,this.isDocumentVisible=!0,this.config.isPreviewSession=_e(),i(`Setup complete on ${this.config.env} environment.`),!this.config.isPreviewSession&&this.config.useAnonymousSession&&_(),await qe(),document.addEventListener("visibilitychange",(async()=>{"hidden"===document.visibilityState?this.isDocumentVisible=!1:(this.isDocumentVisible=!0,await Le())}),!1)}static async setCurrentRoute(e){this.currentRoute=e,i(`Current route set to: ${e}`),await Le()}static async setUserToken(e,t){this.config.isPreviewSession||(!function(e,t){void 0===t&&(t=new Date).setDate(t.getDate()+30),h(L,e,t),N()&&(w(C),w(P)),i(`Set user token "${e}" with expiry date set to ${t}`)}(e,t),Ne(!0),await qe())}static setUserLocale(e){var t;h(T,t=e),i(`Set user locate to "${t}"`)}static setCustomAttribute(e,t){return function(e,t){return e&&"string"==typeof e?(te.set(e,t),ne(),i(`Set custom attribute "${e}" to "${t}"`),!0):(i(`Invalid key for custom attribute: ${e}`),!1)}(e,t)}static clearCustomAttributes(){te.clear(),w(ee),i("Cleared all custom attributes")}static removeCustomAttribute(e){return function(e){if(!e||"string"!=typeof e)return i(`Invalid key for custom attribute: ${e}`),!1;const t=te.has(e);return te.delete(e),te.size>0?ne():w(ee),i(`Removed custom attribute "${e}"`),t}(e)}static async clearUserToken(){this.config.isPreviewSession||(w(L),i("Cleared user token"),this.config.useAnonymousSession&&_(),Ne(!0),await qe())}static async dismissMessage(e){var t=Ie(e);await pe(t),await we(t),await ke(t),await Le()}static async embedMessage(e,t){var n=await he(e,t);return n?n.instanceId:null}static async showMessage(e){var t=await fe(e);return t?t.instanceId:null}static messageShown(e){i(`Message shown: ${e.messageId}`),this.events.dispatch("messageShown",e)}static messageDismissed(e){null!==e&&(i(`Message dismissed: ${e.messageId}`),this.events.dispatch("messageDismissed",e))}static messageError(e){i(`Message error: ${e.messageId}`),this.events.dispatch("messageError",e)}static messageAction(e,t,n){i(`Message action: ${e.currentRoute}, ${t} with name ${n} on ${e.instanceId}`),this.events.dispatch("messageAction",{message:e,action:t,name:n})}}},6646:function(e,t,n){const s=n(1369).Z;e.exports=s}}]);
|
package/dist/umd/646.js.gz
DELETED
|
Binary file
|
package/dist/umd/799.js.gz
DELETED
|
Binary file
|