@amplitude/session-replay-browser 1.47.0-sr-trc-debug-log.4 → 1.47.0
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/README.md +203 -0
- package/lib/cjs/beacon-transport.d.ts +2 -0
- package/lib/cjs/beacon-transport.d.ts.map +1 -1
- package/lib/cjs/beacon-transport.js +39 -1
- package/lib/cjs/beacon-transport.js.map +1 -1
- package/lib/cjs/config/joined-config.d.ts +1 -6
- package/lib/cjs/config/joined-config.d.ts.map +1 -1
- package/lib/cjs/config/joined-config.js +23 -64
- package/lib/cjs/config/joined-config.js.map +1 -1
- package/lib/cjs/config/local-config.d.ts +4 -6
- package/lib/cjs/config/local-config.d.ts.map +1 -1
- package/lib/cjs/config/local-config.js +3 -19
- package/lib/cjs/config/local-config.js.map +1 -1
- package/lib/cjs/config/types.d.ts +74 -19
- package/lib/cjs/config/types.d.ts.map +1 -1
- package/lib/cjs/config/types.js.map +1 -1
- package/lib/cjs/index.d.ts +1 -0
- package/lib/cjs/index.d.ts.map +1 -1
- package/lib/cjs/index.js.map +1 -1
- package/lib/cjs/plugins/url-tracking-plugin.d.ts +0 -13
- package/lib/cjs/plugins/url-tracking-plugin.d.ts.map +1 -1
- package/lib/cjs/plugins/url-tracking-plugin.js +2 -6
- package/lib/cjs/plugins/url-tracking-plugin.js.map +1 -1
- package/lib/cjs/session-replay.d.ts +0 -33
- package/lib/cjs/session-replay.d.ts.map +1 -1
- package/lib/cjs/session-replay.js +40 -339
- package/lib/cjs/session-replay.js.map +1 -1
- package/lib/cjs/targeting/targeting-manager.d.ts +1 -4
- package/lib/cjs/targeting/targeting-manager.d.ts.map +1 -1
- package/lib/cjs/targeting/targeting-manager.js +10 -56
- package/lib/cjs/targeting/targeting-manager.js.map +1 -1
- package/lib/cjs/track-destination.d.ts +5 -1
- package/lib/cjs/track-destination.d.ts.map +1 -1
- package/lib/cjs/track-destination.js +212 -55
- package/lib/cjs/track-destination.js.map +1 -1
- package/lib/cjs/version.d.ts +1 -1
- package/lib/cjs/version.d.ts.map +1 -1
- package/lib/cjs/version.js +1 -1
- package/lib/cjs/version.js.map +1 -1
- package/lib/cjs/worker/index.js +1 -1
- package/lib/esm/beacon-transport.d.ts +2 -0
- package/lib/esm/beacon-transport.d.ts.map +1 -1
- package/lib/esm/beacon-transport.js +39 -1
- package/lib/esm/beacon-transport.js.map +1 -1
- package/lib/esm/config/joined-config.d.ts +1 -6
- package/lib/esm/config/joined-config.d.ts.map +1 -1
- package/lib/esm/config/joined-config.js +23 -64
- package/lib/esm/config/joined-config.js.map +1 -1
- package/lib/esm/config/local-config.d.ts +4 -6
- package/lib/esm/config/local-config.d.ts.map +1 -1
- package/lib/esm/config/local-config.js +4 -20
- package/lib/esm/config/local-config.js.map +1 -1
- package/lib/esm/config/types.d.ts +74 -19
- package/lib/esm/config/types.d.ts.map +1 -1
- package/lib/esm/config/types.js.map +1 -1
- package/lib/esm/index.d.ts +1 -0
- package/lib/esm/index.d.ts.map +1 -1
- package/lib/esm/index.js.map +1 -1
- package/lib/esm/plugins/url-tracking-plugin.d.ts +0 -13
- package/lib/esm/plugins/url-tracking-plugin.d.ts.map +1 -1
- package/lib/esm/plugins/url-tracking-plugin.js +2 -6
- package/lib/esm/plugins/url-tracking-plugin.js.map +1 -1
- package/lib/esm/session-replay.d.ts +0 -33
- package/lib/esm/session-replay.d.ts.map +1 -1
- package/lib/esm/session-replay.js +40 -339
- package/lib/esm/session-replay.js.map +1 -1
- package/lib/esm/targeting/targeting-manager.d.ts +1 -4
- package/lib/esm/targeting/targeting-manager.d.ts.map +1 -1
- package/lib/esm/targeting/targeting-manager.js +10 -56
- package/lib/esm/targeting/targeting-manager.js.map +1 -1
- package/lib/esm/track-destination.d.ts +5 -1
- package/lib/esm/track-destination.d.ts.map +1 -1
- package/lib/esm/track-destination.js +212 -55
- package/lib/esm/track-destination.js.map +1 -1
- package/lib/esm/version.d.ts +1 -1
- package/lib/esm/version.d.ts.map +1 -1
- package/lib/esm/version.js +1 -1
- package/lib/esm/version.js.map +1 -1
- package/lib/esm/worker/index.js +1 -1
- package/lib/scripts/index-min.js +1 -1
- package/lib/scripts/index-min.js.gz +0 -0
- package/lib/scripts/index-min.js.map +1 -1
- package/lib/scripts/observers-min.js +1 -1
- package/lib/scripts/observers-min.js.gz +0 -0
- package/lib/scripts/session-replay-browser-min.js +1 -1
- package/lib/scripts/session-replay-browser-min.js.gz +0 -0
- package/lib/scripts/session-replay-browser-min.js.map +1 -1
- package/lib/scripts/targeting-min.js +1 -1
- package/lib/scripts/targeting-min.js.gz +0 -0
- package/lib/scripts/worker-min.js +1 -1
- package/lib/scripts/worker-min.js.gz +0 -0
- package/package.json +4 -4
- package/lib/cjs/diagnostics.d.ts +0 -50
- package/lib/cjs/diagnostics.d.ts.map +0 -1
- package/lib/cjs/diagnostics.js +0 -67
- package/lib/cjs/diagnostics.js.map +0 -1
- package/lib/esm/diagnostics.d.ts +0 -50
- package/lib/esm/diagnostics.d.ts.map +0 -1
- package/lib/esm/diagnostics.js +0 -64
- package/lib/esm/diagnostics.js.map +0 -1
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
var e=function(t,r){return e=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&(e[r]=t[r])},e(t,r)};function t(t,r){if("function"!=typeof r&&null!==r)throw new TypeError("Class extends value "+String(r)+" is not a constructor or null");function n(){this.constructor=t}e(t,r),t.prototype=null===r?Object.create(r):(n.prototype=r.prototype,new n)}var r=function(){return r=Object.assign||function(e){for(var t,r=1,n=arguments.length;r<n;r++)for(var o in t=arguments[r])Object.prototype.hasOwnProperty.call(t,o)&&(e[o]=t[o]);return e},r.apply(this,arguments)};function n(e,t){var r={};for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&t.indexOf(n)<0&&(r[n]=e[n]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var o=0;for(n=Object.getOwnPropertySymbols(e);o<n.length;o++)t.indexOf(n[o])<0&&Object.prototype.propertyIsEnumerable.call(e,n[o])&&(r[n[o]]=e[n[o]])}return r}function o(e,t,r,n){return new(r||(r=Promise))(function(o,a){function i(e){try{c(n.next(e))}catch(e){a(e)}}function s(e){try{c(n.throw(e))}catch(e){a(e)}}function c(e){var t;e.done?o(e.value):(t=e.value,t instanceof r?t:new r(function(e){e(t)})).then(i,s)}c((n=n.apply(e,t||[])).next())})}function a(e,t){var r,n,o,a={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]},i=Object.create(("function"==typeof Iterator?Iterator:Object).prototype);return i.next=s(0),i.throw=s(1),i.return=s(2),"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function s(s){return function(c){return function(s){if(r)throw new TypeError("Generator is already executing.");for(;i&&(i=0,s[0]&&(a=0)),a;)try{if(r=1,n&&(o=2&s[0]?n.return:s[0]?n.throw||((o=n.return)&&o.call(n),0):n.next)&&!(o=o.call(n,s[1])).done)return o;switch(n=0,o&&(s=[2&s[0],o.value]),s[0]){case 0:case 1:o=s;break;case 4:return a.label++,{value:s[1],done:!1};case 5:a.label++,n=s[1],s=[0];continue;case 7:s=a.ops.pop(),a.trys.pop();continue;default:if(!(o=a.trys,(o=o.length>0&&o[o.length-1])||6!==s[0]&&2!==s[0])){a=0;continue}if(3===s[0]&&(!o||s[1]>o[0]&&s[1]<o[3])){a.label=s[1];break}if(6===s[0]&&a.label<o[1]){a.label=o[1],o=s;break}if(o&&a.label<o[2]){a.label=o[2],a.ops.push(s);break}o[2]&&a.ops.pop(),a.trys.pop();continue}s=t.call(e,a)}catch(e){s=[6,e],n=0}finally{r=o=0}if(5&s[0])throw s[1];return{value:s[0]?s[1]:void 0,done:!0}}([s,c])}}}function i(e){var t="function"==typeof Symbol&&Symbol.iterator,r=t&&e[t],n=0;if(r)return r.call(e);if(e&&"number"==typeof e.length)return{next:function(){return e&&n>=e.length&&(e=void 0),{value:e&&e[n++],done:!e}}};throw new TypeError(t?"Object is not iterable.":"Symbol.iterator is not defined.")}function s(e,t){var r="function"==typeof Symbol&&e[Symbol.iterator];if(!r)return e;var n,o,a=r.call(e),i=[];try{for(;(void 0===t||t-- >0)&&!(n=a.next()).done;)i.push(n.value)}catch(e){o={error:e}}finally{try{n&&!n.done&&(r=a.return)&&r.call(a)}finally{if(o)throw o.error}}return i}function c(e,t,r){if(r||2===arguments.length)for(var n,o=0,a=t.length;o<a;o++)!n&&o in t||(n||(n=Array.prototype.slice.call(t,0,o)),n[o]=t[o]);return e.concat(n||Array.prototype.slice.call(t))}"function"==typeof SuppressedError&&SuppressedError;const u=(e,t)=>t.some(t=>e instanceof t);let l,f;const p=new WeakMap,h=new WeakMap,v=new WeakMap;let y={get(e,t,r){if(e instanceof IDBTransaction){if("done"===t)return p.get(e);if("store"===t)return r.objectStoreNames[1]?void 0:r.objectStore(r.objectStoreNames[0])}return b(e[t])},set:(e,t,r)=>(e[t]=r,!0),has:(e,t)=>e instanceof IDBTransaction&&("done"===t||"store"===t)||t in e};function d(e){y=e(y)}function m(e){return(f||(f=[IDBCursor.prototype.advance,IDBCursor.prototype.continue,IDBCursor.prototype.continuePrimaryKey])).includes(e)?function(...t){return e.apply(w(this),t),b(this.request)}:function(...t){return b(e.apply(w(this),t))}}function g(e){return"function"==typeof e?m(e):(e instanceof IDBTransaction&&function(e){if(p.has(e))return;const t=new Promise((t,r)=>{const n=()=>{e.removeEventListener("complete",o),e.removeEventListener("error",a),e.removeEventListener("abort",a)},o=()=>{t(),n()},a=()=>{r(e.error||new DOMException("AbortError","AbortError")),n()};e.addEventListener("complete",o),e.addEventListener("error",a),e.addEventListener("abort",a)});p.set(e,t)}(e),u(e,l||(l=[IDBDatabase,IDBObjectStore,IDBIndex,IDBCursor,IDBTransaction]))?new Proxy(e,y):e)}function b(e){if(e instanceof IDBRequest)return function(e){const t=new Promise((t,r)=>{const n=()=>{e.removeEventListener("success",o),e.removeEventListener("error",a)},o=()=>{t(b(e.result)),n()},a=()=>{r(e.error),n()};e.addEventListener("success",o),e.addEventListener("error",a)});return v.set(t,e),t}(e);if(h.has(e))return h.get(e);const t=g(e);return t!==e&&(h.set(e,t),v.set(t,e)),t}const w=e=>v.get(e);function S(e,t,{blocked:r,upgrade:n,blocking:o,terminated:a}={}){const i=indexedDB.open(e,t),s=b(i);return n&&i.addEventListener("upgradeneeded",e=>{n(b(i.result),e.oldVersion,e.newVersion,b(i.transaction),e)}),r&&i.addEventListener("blocked",e=>r(e.oldVersion,e.newVersion,e)),s.then(e=>{a&&e.addEventListener("close",()=>a()),o&&e.addEventListener("versionchange",e=>o(e.oldVersion,e.newVersion,e))}).catch(()=>{}),s}const x=["get","getKey","getAll","getAllKeys","count"],I=["put","add","delete","clear"],O=new Map;function E(e,t){if(!(e instanceof IDBDatabase)||t in e||"string"!=typeof t)return;if(O.get(t))return O.get(t);const r=t.replace(/FromIndex$/,""),n=t!==r,o=I.includes(r);if(!(r in(n?IDBIndex:IDBObjectStore).prototype)||!o&&!x.includes(r))return;const a=async function(e,...t){const a=this.transaction(e,o?"readwrite":"readonly");let i=a.store;return n&&(i=i.index(t.shift())),(await Promise.all([i[r](...t),o&&a.done]))[0]};return O.set(t,a),a}d(e=>({...e,get:(t,r,n)=>E(t,r)||e.get(t,r,n),has:(t,r)=>!!E(t,r)||e.has(t,r)}));const C=["continue","continuePrimaryKey","advance"],j={},T=new WeakMap,A=new WeakMap,D={get(e,t){if(!C.includes(t))return e[t];let r=j[t];return r||(r=j[t]=function(...e){T.set(this,A.get(this)[t](...e))}),r}};async function*B(...e){let t=this;if(t instanceof IDBCursor||(t=await t.openCursor(...e)),!t)return;const r=new Proxy(t,D);for(A.set(r,t),v.set(r,w(t));t;)yield r,t=await(T.get(r)||t.continue()),T.delete(r)}function _(e,t){return t===Symbol.asyncIterator&&u(e,[IDBIndex,IDBObjectStore,IDBCursor])||"iterate"===t&&u(e,[IDBIndex,IDBObjectStore])}d(e=>({...e,get:(t,r,n)=>_(t,r)?B:e.get(t,r,n),has:(t,r)=>_(t,r)||e.has(t,r)}));var P=function(e,t){return P=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&(e[r]=t[r])},P(e,t)};var k=function(){return k=Object.assign||function(e){for(var t,r=1,n=arguments.length;r<n;r++)for(var o in t=arguments[r])Object.prototype.hasOwnProperty.call(t,o)&&(e[o]=t[o]);return e},k.apply(this,arguments)};function L(e){var t="function"==typeof Symbol&&Symbol.iterator,r=t&&e[t],n=0;if(r)return r.call(e);if(e&&"number"==typeof e.length)return{next:function(){return e&&n>=e.length&&(e=void 0),{value:e&&e[n++],done:!e}}};throw new TypeError(t?"Object is not iterable.":"Symbol.iterator is not defined.")}"function"==typeof SuppressedError&&SuppressedError;var M="is",N="is not",R="contains",F="does not contain",q="less",K="less or equal",U="greater",V="greater or equal",W="version less",z="version less or equal",H="version greater",J="version greater or equal",G="set is",$="set is not",Q="set contains",X="set does not contain",Y="set contains any",Z="set does not contain any",ee="regex match",te="regex does not match",re=-862048943,ne=461845907,oe=function(e,t){void 0===t&&(t=0);for(var r=function(e){for(var t=[],r=0,n=0;n<e.length;n++){var o=e.charCodeAt(n);o<128?t[r++]=o:o<2048?(t[r++]=o>>6|192,t[r++]=63&o|128):55296==(64512&o)&&n+1<e.length&&56320==(64512&e.charCodeAt(n+1))?(o=65536+((1023&o)<<10)+(1023&e.charCodeAt(++n)),t[r++]=o>>18|240,t[r++]=o>>12&63|128,t[r++]=o>>6&63|128,t[r++]=63&o|128):(t[r++]=o>>12|224,t[r++]=o>>6&63|128,t[r++]=63&o|128)}return Uint8Array.from(t)}(e),n=r.length,o=n>>2,a=t,i=0;i<o;i++){var s=ce(r,i<<2);a=ae(s,a)}var c=o<<2,u=0;switch(n-c){case 3:u^=r[c+2]<<16,u^=r[c+1]<<8,u^=r[c],u=Math.imul(u,re),u=se(u,15),a^=u=Math.imul(u,ne);break;case 2:u^=r[c+1]<<8,u^=r[c],u=Math.imul(u,re),u=se(u,15),a^=u=Math.imul(u,ne);break;case 1:u^=r[c],u=Math.imul(u,re),u=se(u,15),a^=u=Math.imul(u,ne)}return ie(a^=n)>>>0},ae=function(e,t){var r=e,n=t;return r=Math.imul(r,re),r=se(r,15),r=Math.imul(r,ne),n=se(n^=r,13),(n=Math.imul(n,5))+-430675100|0},ie=function(e){var t=e;return t^=t>>>16,t=Math.imul(t,-2048144789),t^=t>>>13,t=Math.imul(t,-1028477387),t^=t>>>16},se=function(e,t,r){return void 0===r&&(r=32),t>r&&(t%=r),(e<<t|(e&4294967295<<r-t>>>0)>>>0>>>r-t>>>0)>>>0},ce=function(e,t){void 0===t&&(t=0);var r=e[t]<<24|e[t+1]<<16|e[t+2]<<8|e[t+3];return ue(r)},ue=function(e){return(-16777216&e)>>>24|(16711680&e)>>>8|(65280&e)<<8|(255&e)<<24},le=function(e,t){var r,n;if(t&&0!==t.length){try{for(var o=L(t),a=o.next();!a.done;a=o.next()){var i=a.value;if(!i||!e||"object"!=typeof e)return;e=e[i]}}catch(e){r={error:e}}finally{try{a&&!a.done&&(n=o.return)&&n.call(o)}finally{if(r)throw r.error}}return e||void 0}},fe="^".concat("(\\d+)\\.(\\d+)","(\\.").concat("(\\d+)").concat("(-(([-\\w]+\\.?)*))?",")?$"),pe=function(){function e(e,t,r,n){void 0===n&&(n=void 0),this.major=e,this.minor=t,this.patch=r,this.preRelease=n}return e.parse=function(t){if(t){var r=new RegExp(fe).exec(t);if(r){var n=Number(r[1]),o=Number(r[2]);if(!isNaN(n)&&!isNaN(o))return new e(n,o,Number(r[4])||0,r[5]||void 0)}}},e.prototype.compareTo=function(e){return this.major>e.major?1:this.major<e.major?-1:this.minor>e.minor?1:this.minor<e.minor?-1:this.patch>e.patch?1:this.patch<e.patch||this.preRelease&&!e.preRelease?-1:!this.preRelease&&e.preRelease?1:this.preRelease&&e.preRelease?this.preRelease>e.preRelease?1:this.preRelease<e.preRelease?-1:0:0},e}(),he=function(){function e(){}return e.prototype.evaluate=function(e,t){var r,n,o={},a={context:e,result:o};try{for(var i=L(t),s=i.next();!s.done;s=i.next()){var c=s.value,u=this.evaluateFlag(a,c);u&&(o[c.key]=u)}}catch(e){r={error:e}}finally{try{s&&!s.done&&(n=i.return)&&n.call(i)}finally{if(r)throw r.error}}return o},e.prototype.evaluateFlag=function(e,t){var r,n,o;try{for(var a=L(t.segments),i=a.next();!i.done;i=a.next()){var s=i.value;if(o=this.evaluateSegment(e,t,s)){var c=k(k(k({},t.metadata),s.metadata),o.metadata);o=k(k({},o),{metadata:c});break}}}catch(e){r={error:e}}finally{try{i&&!i.done&&(n=a.return)&&n.call(a)}finally{if(r)throw r.error}}return o},e.prototype.evaluateSegment=function(e,t,r){var n,o,a,i;if(!r.conditions)return void 0!==(u=this.bucket(e,r))?t.variants[u]:void 0;try{for(var s=L(r.conditions),c=s.next();!c.done;c=s.next()){var u,l=c.value,f=!0;try{for(var p=(a=void 0,L(l)),h=p.next();!h.done;h=p.next()){var v=h.value;if(!(f=this.matchCondition(e,v)))break}}catch(e){a={error:e}}finally{try{h&&!h.done&&(i=p.return)&&i.call(p)}finally{if(a)throw a.error}}if(f)return void 0!==(u=this.bucket(e,r))?t.variants[u]:void 0}}catch(e){n={error:e}}finally{try{c&&!c.done&&(o=s.return)&&o.call(s)}finally{if(n)throw n.error}}},e.prototype.matchCondition=function(e,t){var r=le(e,t.selector);if(r){if(this.isSetOperator(t.op)){var n=this.coerceStringArray(r);return!!n&&this.matchSet(n,t.op,t.values)}var o=this.coerceString(r);return void 0!==o&&this.matchString(o,t.op,t.values)}return this.matchNull(t.op,t.values)},e.prototype.getHash=function(e){return oe(e)},e.prototype.bucket=function(e,t){var r,n,o,a;if(!t.bucket)return t.variant;var i=this.coerceString(le(e,t.bucket.selector));if(!i||0===i.length)return t.variant;var s="".concat(t.bucket.salt,"/").concat(i),c=this.getHash(s),u=c%100,l=Math.floor(c/100);try{for(var f=L(t.bucket.allocations),p=f.next();!p.done;p=f.next()){var h=p.value,v=h.range[0],y=h.range[1];if(u>=v&&u<y)try{for(var d=(o=void 0,L(h.distributions)),m=d.next();!m.done;m=d.next()){var g=m.value,b=g.range[0],w=g.range[1];if(l>=b&&l<w)return g.variant}}catch(e){o={error:e}}finally{try{m&&!m.done&&(a=d.return)&&a.call(d)}finally{if(o)throw o.error}}}}catch(e){r={error:e}}finally{try{p&&!p.done&&(n=f.return)&&n.call(f)}finally{if(r)throw r.error}}return t.variant},e.prototype.matchNull=function(e,t){var r=this.containsNone(t);switch(e){case M:case R:case q:case K:case U:case V:case W:case z:case H:case J:case G:case Q:case Y:return r;case N:case F:case X:case Z:return!r;default:return!1}},e.prototype.matchSet=function(e,t,r){switch(t){case G:return this.setEquals(e,r);case $:return!this.setEquals(e,r);case Q:return this.matchesSetContainsAll(e,r);case X:return!this.matchesSetContainsAll(e,r);case Y:return this.matchesSetContainsAny(e,r);case Z:return!this.matchesSetContainsAny(e,r);default:return!1}},e.prototype.matchString=function(e,t,r){var n=this;switch(t){case M:return this.matchesIs(e,r);case N:return!this.matchesIs(e,r);case R:return this.matchesContains(e,r);case F:return!this.matchesContains(e,r);case q:case K:case U:case V:return this.matchesComparable(e,t,r,function(e){return n.parseNumber(e)},this.comparator);case W:case z:case H:case J:return this.matchesComparable(e,t,r,function(e){return pe.parse(e)},this.versionComparator);case ee:return this.matchesRegex(e,r);case te:return!this.matchesRegex(e,r);default:return!1}},e.prototype.matchesIs=function(e,t){if(this.containsBooleans(t)){var r=e.toLowerCase();if("true"===r||"false"===r)return t.some(function(e){return e.toLowerCase()===r})}return t.some(function(t){return e===t})},e.prototype.matchesContains=function(e,t){var r,n;try{for(var o=L(t),a=o.next();!a.done;a=o.next()){var i=a.value;if(e.toLowerCase().includes(i.toLowerCase()))return!0}}catch(e){r={error:e}}finally{try{a&&!a.done&&(n=o.return)&&n.call(o)}finally{if(r)throw r.error}}return!1},e.prototype.matchesComparable=function(e,t,r,n,o){var a=this,i=n(e),s=r.map(function(e){return n(e)}).filter(function(e){return void 0!==e});return void 0===i||0===s.length?r.some(function(r){return a.comparator(e,t,r)}):s.some(function(e){return o(i,t,e)})},e.prototype.comparator=function(e,t,r){switch(t){case q:case W:return e<r;case K:case z:return e<=r;case U:case H:return e>r;case V:case J:return e>=r;default:return!1}},e.prototype.versionComparator=function(e,t,r){var n=e.compareTo(r);switch(t){case q:case W:return n<0;case K:case z:return n<=0;case U:case H:return n>0;case V:case J:return n>=0;default:return!1}},e.prototype.matchesRegex=function(e,t){return t.some(function(t){return Boolean(new RegExp(t).exec(e))})},e.prototype.containsNone=function(e){return e.some(function(e){return"(none)"===e})},e.prototype.containsBooleans=function(e){return e.some(function(e){switch(e.toLowerCase()){case"true":case"false":return!0;default:return!1}})},e.prototype.parseNumber=function(e){var t;return null!==(t=Number(e))&&void 0!==t?t:void 0},e.prototype.coerceString=function(e){if(e)return"object"==typeof e?JSON.stringify(e):String(e)},e.prototype.coerceStringArray=function(e){var t=this;if(Array.isArray(e))return e.map(function(e){return t.coerceString(e)}).filter(Boolean);var r=String(e);try{var n=JSON.parse(r);return Array.isArray(n)?e.map(function(e){return t.coerceString(e)}).filter(Boolean):void 0}catch(e){return}},e.prototype.isSetOperator=function(e){switch(e){case G:case $:case Q:case X:case Y:case Z:return!0;default:return!1}},e.prototype.setEquals=function(e,t){var r=new Set(e),n=new Set(t);return r.size===n.size&&function(e,t,r){if(r||2===arguments.length)for(var n,o=0,a=t.length;o<a;o++)!n&&o in t||(n||(n=Array.prototype.slice.call(t,0,o)),n[o]=t[o]);return e.concat(n||Array.prototype.slice.call(t))}([],function(e,t){var r="function"==typeof Symbol&&e[Symbol.iterator];if(!r)return e;var n,o,a=r.call(e),i=[];try{for(;(void 0===t||t-- >0)&&!(n=a.next()).done;)i.push(n.value)}catch(e){o={error:e}}finally{try{n&&!n.done&&(r=a.return)&&r.call(a)}finally{if(o)throw o.error}}return i}(n),!1).every(function(e){return r.has(e)})},e.prototype.matchesSetContainsAll=function(e,t){var r,n;if(e.length<t.length)return!1;try{for(var o=L(t),a=o.next();!a.done;a=o.next()){var i=a.value;if(!this.matchesIs(i,e))return!1}}catch(e){r={error:e}}finally{try{a&&!a.done&&(n=o.return)&&n.call(o)}finally{if(r)throw r.error}}return!0},e.prototype.matchesSetContainsAny=function(e,t){var r,n;try{for(var o=L(t),a=o.next();!a.done;a=o.next()){var i=a.value;if(this.matchesIs(i,e))return!0}}catch(e){r={error:e}}finally{try{a&&!a.done&&(n=o.return)&&n.call(o)}finally{if(r)throw r.error}}return!1},e}();"function"==typeof TextDecoder&&new TextDecoder,"function"==typeof TextEncoder&&new TextEncoder;const ve=Array.prototype.slice.call("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=");(()=>{let e={};ve.forEach((t,r)=>e[t]=r)})(),String.fromCharCode.bind(String),"function"==typeof Uint8Array.from&&Uint8Array.from.bind(Uint8Array),function(e){function t(r,n){var o=e.call(this,n)||this;return o.statusCode=r,Object.setPrototypeOf(o,t.prototype),o}(function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Class extends value "+String(t)+" is not a constructor or null");function r(){this.constructor=e}P(e,t),e.prototype=null===t?Object.create(t):(r.prototype=t.prototype,new r)})(t,e)}(Error);var ye=new function(){var e=this;this.dbs={},this.createStore=function(t){return o(e,void 0,void 0,function(){return a(this,function(e){switch(e.label){case 0:return[4,S(t,1,{upgrade:function(e){e.objectStoreNames.contains("eventTypesForSession")||e.createObjectStore("eventTypesForSession",{keyPath:"sessionId"})}})];case 1:return[2,e.sent()]}})})},this.openOrCreateDB=function(t){return o(e,void 0,void 0,function(){var e,r;return a(this,function(n){switch(n.label){case 0:return this.dbs&&this.dbs[t]?[2,this.dbs[t]]:(e="".concat(t.substring(0,10),"_amp_targeting"),[4,this.createStore(e)]);case 1:return r=n.sent(),this.dbs[t]=r,[2,r]}})})},this.updateEventListForSession=function(t){var n=t.sessionId,i=t.eventType,s=t.eventTime,c=t.loggerProvider,u=t.tx;return o(e,void 0,void 0,function(){var e,t,o,l,f,p,h,v,y;return a(this,function(a){switch(a.label){case 0:return a.trys.push([0,3,,4]),e=String(n),[4,u.store.get(e)];case 1:return t=a.sent(),o=t?t.eventTypes:{},l=o[i]||{},f=r(r({},o),((v={})[i]=r(r({},l),((y={})[s]={event_type:i},y)),v)),p={sessionId:e,eventTypes:f,lastUpdated:Date.now()},[4,u.store.put(p)];case 2:return a.sent(),[2,f];case 3:return h=a.sent(),c.warn("Failed to store events for targeting ".concat(n,": ").concat(h)),[3,4];case 4:return[2,void 0]}})})},this.deleteOldSessionEventTypes=function(t){var r=t.currentSessionId,n=t.loggerProvider,i=t.tx;return o(e,void 0,void 0,function(){var e,t,o,s,c,u;return a(this,function(a){switch(a.label){case 0:return a.trys.push([0,6,,7]),e=String(r),[4,i.store.getAll()];case 1:t=a.sent(),o=0,a.label=2;case 2:return o<t.length?(s=t[o],c=Date.now()-s.lastUpdated,s.sessionId!==e&&c>1728e5?[4,i.store.delete(s.sessionId)]:[3,4]):[3,5];case 3:a.sent(),a.label=4;case 4:return o++,[3,2];case 5:return[3,7];case 6:return u=a.sent(),n.warn("Failed to clear old session event types for targeting: ".concat(u)),[3,7];case 7:return[2]}})})},this.storeEventTypeForSession=function(t){var r=t.loggerProvider,n=t.sessionId,i=t.eventType,s=t.eventTime,c=t.apiKey;return o(e,void 0,void 0,function(){var e,t,o,u;return a(this,function(a){switch(a.label){case 0:return a.trys.push([0,5,,6]),[4,this.openOrCreateDB(c)];case 1:return e=a.sent(),(t=e.transaction("eventTypesForSession","readwrite"))?[4,this.updateEventListForSession({sessionId:n,tx:t,loggerProvider:r,eventType:i,eventTime:s})]:[2];case 2:return o=a.sent(),[4,this.deleteOldSessionEventTypes({currentSessionId:n,tx:t,loggerProvider:r})];case 3:return a.sent(),[4,t.done];case 4:return a.sent(),[2,o];case 5:return u=a.sent(),r.warn("Failed to store events for targeting ".concat(n,": ").concat(u)),[3,6];case 6:return[2,void 0]}})})}},de=function(){var e=this;this.evaluateTargeting=function(t){var n=t.apiKey,i=t.loggerProvider,s=t.event,c=t.sessionId,u=t.userProperties,l=t.deviceId,f=t.page,p=t.flag;return o(e,void 0,void 0,function(){var e,t,o,h;return a(this,function(a){switch(a.label){case 0:return s&&s.time?[4,ye.storeEventTypeForSession({loggerProvider:i,apiKey:n,sessionId:c,eventType:s.event_type,eventTime:s.time})]:[3,2];case 1:return t=a.sent(),[3,3];case 2:t=void 0,a.label=3;case 3:return o=(e=t)&&new Set(Object.keys(e)),h={session_id:c,event:s,event_types:o&&Array.from(o),user:r(r({},u),{device_id:l,user_properties:u}),page:f},[2,this.evaluationEngine.evaluate(h,[p])]}})})},this.evaluationEngine=new he},me=function(){var e=new de;return{evaluateTargeting:e.evaluateTargeting.bind(e)}}().evaluateTargeting,ge=Object.freeze({__proto__:null,evaluateTargeting:me});export{c as _,s as a,o as b,a as c,r as d,i as e,t as f,n as g,ge as i,S as o};
|
|
1
|
+
var e=function(t,r){return e=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&(e[r]=t[r])},e(t,r)};function t(t,r){if("function"!=typeof r&&null!==r)throw new TypeError("Class extends value "+String(r)+" is not a constructor or null");function n(){this.constructor=t}e(t,r),t.prototype=null===r?Object.create(r):(n.prototype=r.prototype,new n)}var r=function(){return r=Object.assign||function(e){for(var t,r=1,n=arguments.length;r<n;r++)for(var o in t=arguments[r])Object.prototype.hasOwnProperty.call(t,o)&&(e[o]=t[o]);return e},r.apply(this,arguments)};function n(e,t){var r={};for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&t.indexOf(n)<0&&(r[n]=e[n]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var o=0;for(n=Object.getOwnPropertySymbols(e);o<n.length;o++)t.indexOf(n[o])<0&&Object.prototype.propertyIsEnumerable.call(e,n[o])&&(r[n[o]]=e[n[o]])}return r}function o(e,t,r,n){return new(r||(r=Promise))(function(o,a){function i(e){try{c(n.next(e))}catch(e){a(e)}}function s(e){try{c(n.throw(e))}catch(e){a(e)}}function c(e){var t;e.done?o(e.value):(t=e.value,t instanceof r?t:new r(function(e){e(t)})).then(i,s)}c((n=n.apply(e,t||[])).next())})}function a(e,t){var r,n,o,a={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]},i=Object.create(("function"==typeof Iterator?Iterator:Object).prototype);return i.next=s(0),i.throw=s(1),i.return=s(2),"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function s(s){return function(c){return function(s){if(r)throw new TypeError("Generator is already executing.");for(;i&&(i=0,s[0]&&(a=0)),a;)try{if(r=1,n&&(o=2&s[0]?n.return:s[0]?n.throw||((o=n.return)&&o.call(n),0):n.next)&&!(o=o.call(n,s[1])).done)return o;switch(n=0,o&&(s=[2&s[0],o.value]),s[0]){case 0:case 1:o=s;break;case 4:return a.label++,{value:s[1],done:!1};case 5:a.label++,n=s[1],s=[0];continue;case 7:s=a.ops.pop(),a.trys.pop();continue;default:if(!(o=a.trys,(o=o.length>0&&o[o.length-1])||6!==s[0]&&2!==s[0])){a=0;continue}if(3===s[0]&&(!o||s[1]>o[0]&&s[1]<o[3])){a.label=s[1];break}if(6===s[0]&&a.label<o[1]){a.label=o[1],o=s;break}if(o&&a.label<o[2]){a.label=o[2],a.ops.push(s);break}o[2]&&a.ops.pop(),a.trys.pop();continue}s=t.call(e,a)}catch(e){s=[6,e],n=0}finally{r=o=0}if(5&s[0])throw s[1];return{value:s[0]?s[1]:void 0,done:!0}}([s,c])}}}function i(e){var t="function"==typeof Symbol&&Symbol.iterator,r=t&&e[t],n=0;if(r)return r.call(e);if(e&&"number"==typeof e.length)return{next:function(){return e&&n>=e.length&&(e=void 0),{value:e&&e[n++],done:!e}}};throw new TypeError(t?"Object is not iterable.":"Symbol.iterator is not defined.")}function s(e,t){var r="function"==typeof Symbol&&e[Symbol.iterator];if(!r)return e;var n,o,a=r.call(e),i=[];try{for(;(void 0===t||t-- >0)&&!(n=a.next()).done;)i.push(n.value)}catch(e){o={error:e}}finally{try{n&&!n.done&&(r=a.return)&&r.call(a)}finally{if(o)throw o.error}}return i}function c(e,t,r){if(r||2===arguments.length)for(var n,o=0,a=t.length;o<a;o++)!n&&o in t||(n||(n=Array.prototype.slice.call(t,0,o)),n[o]=t[o]);return e.concat(n||Array.prototype.slice.call(t))}"function"==typeof SuppressedError&&SuppressedError;const u=(e,t)=>t.some(t=>e instanceof t);let l,f;const p=new WeakMap,h=new WeakMap,v=new WeakMap;let y={get(e,t,r){if(e instanceof IDBTransaction){if("done"===t)return p.get(e);if("store"===t)return r.objectStoreNames[1]?void 0:r.objectStore(r.objectStoreNames[0])}return b(e[t])},set:(e,t,r)=>(e[t]=r,!0),has:(e,t)=>e instanceof IDBTransaction&&("done"===t||"store"===t)||t in e};function d(e){y=e(y)}function m(e){return(f||(f=[IDBCursor.prototype.advance,IDBCursor.prototype.continue,IDBCursor.prototype.continuePrimaryKey])).includes(e)?function(...t){return e.apply(w(this),t),b(this.request)}:function(...t){return b(e.apply(w(this),t))}}function g(e){return"function"==typeof e?m(e):(e instanceof IDBTransaction&&function(e){if(p.has(e))return;const t=new Promise((t,r)=>{const n=()=>{e.removeEventListener("complete",o),e.removeEventListener("error",a),e.removeEventListener("abort",a)},o=()=>{t(),n()},a=()=>{r(e.error||new DOMException("AbortError","AbortError")),n()};e.addEventListener("complete",o),e.addEventListener("error",a),e.addEventListener("abort",a)});p.set(e,t)}(e),u(e,l||(l=[IDBDatabase,IDBObjectStore,IDBIndex,IDBCursor,IDBTransaction]))?new Proxy(e,y):e)}function b(e){if(e instanceof IDBRequest)return function(e){const t=new Promise((t,r)=>{const n=()=>{e.removeEventListener("success",o),e.removeEventListener("error",a)},o=()=>{t(b(e.result)),n()},a=()=>{r(e.error),n()};e.addEventListener("success",o),e.addEventListener("error",a)});return v.set(t,e),t}(e);if(h.has(e))return h.get(e);const t=g(e);return t!==e&&(h.set(e,t),v.set(t,e)),t}const w=e=>v.get(e);function S(e,t,{blocked:r,upgrade:n,blocking:o,terminated:a}={}){const i=indexedDB.open(e,t),s=b(i);return n&&i.addEventListener("upgradeneeded",e=>{n(b(i.result),e.oldVersion,e.newVersion,b(i.transaction),e)}),r&&i.addEventListener("blocked",e=>r(e.oldVersion,e.newVersion,e)),s.then(e=>{a&&e.addEventListener("close",()=>a()),o&&e.addEventListener("versionchange",e=>o(e.oldVersion,e.newVersion,e))}).catch(()=>{}),s}const x=["get","getKey","getAll","getAllKeys","count"],I=["put","add","delete","clear"],O=new Map;function E(e,t){if(!(e instanceof IDBDatabase)||t in e||"string"!=typeof t)return;if(O.get(t))return O.get(t);const r=t.replace(/FromIndex$/,""),n=t!==r,o=I.includes(r);if(!(r in(n?IDBIndex:IDBObjectStore).prototype)||!o&&!x.includes(r))return;const a=async function(e,...t){const a=this.transaction(e,o?"readwrite":"readonly");let i=a.store;return n&&(i=i.index(t.shift())),(await Promise.all([i[r](...t),o&&a.done]))[0]};return O.set(t,a),a}d(e=>({...e,get:(t,r,n)=>E(t,r)||e.get(t,r,n),has:(t,r)=>!!E(t,r)||e.has(t,r)}));const C=["continue","continuePrimaryKey","advance"],j={},T=new WeakMap,A=new WeakMap,D={get(e,t){if(!C.includes(t))return e[t];let r=j[t];return r||(r=j[t]=function(...e){T.set(this,A.get(this)[t](...e))}),r}};async function*B(...e){let t=this;if(t instanceof IDBCursor||(t=await t.openCursor(...e)),!t)return;const r=new Proxy(t,D);for(A.set(r,t),v.set(r,w(t));t;)yield r,t=await(T.get(r)||t.continue()),T.delete(r)}function _(e,t){return t===Symbol.asyncIterator&&u(e,[IDBIndex,IDBObjectStore,IDBCursor])||"iterate"===t&&u(e,[IDBIndex,IDBObjectStore])}d(e=>({...e,get:(t,r,n)=>_(t,r)?B:e.get(t,r,n),has:(t,r)=>_(t,r)||e.has(t,r)}));var P=function(e,t){return P=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&(e[r]=t[r])},P(e,t)};var k=function(){return k=Object.assign||function(e){for(var t,r=1,n=arguments.length;r<n;r++)for(var o in t=arguments[r])Object.prototype.hasOwnProperty.call(t,o)&&(e[o]=t[o]);return e},k.apply(this,arguments)};function L(e){var t="function"==typeof Symbol&&Symbol.iterator,r=t&&e[t],n=0;if(r)return r.call(e);if(e&&"number"==typeof e.length)return{next:function(){return e&&n>=e.length&&(e=void 0),{value:e&&e[n++],done:!e}}};throw new TypeError(t?"Object is not iterable.":"Symbol.iterator is not defined.")}"function"==typeof SuppressedError&&SuppressedError;var M="is",N="is not",R="contains",F="does not contain",q="less",K="less or equal",U="greater",V="greater or equal",W="version less",z="version less or equal",H="version greater",J="version greater or equal",G="set is",$="set is not",Q="set contains",X="set does not contain",Y="set contains any",Z="set does not contain any",ee="regex match",te="regex does not match",re=-862048943,ne=461845907,oe=function(e,t){void 0===t&&(t=0);for(var r=function(e){for(var t=[],r=0,n=0;n<e.length;n++){var o=e.charCodeAt(n);o<128?t[r++]=o:o<2048?(t[r++]=o>>6|192,t[r++]=63&o|128):55296==(64512&o)&&n+1<e.length&&56320==(64512&e.charCodeAt(n+1))?(o=65536+((1023&o)<<10)+(1023&e.charCodeAt(++n)),t[r++]=o>>18|240,t[r++]=o>>12&63|128,t[r++]=o>>6&63|128,t[r++]=63&o|128):(t[r++]=o>>12|224,t[r++]=o>>6&63|128,t[r++]=63&o|128)}return Uint8Array.from(t)}(e),n=r.length,o=n>>2,a=t,i=0;i<o;i++){var s=ce(r,i<<2);a=ae(s,a)}var c=o<<2,u=0;switch(n-c){case 3:u^=r[c+2]<<16,u^=r[c+1]<<8,u^=r[c],u=Math.imul(u,re),u=se(u,15),a^=u=Math.imul(u,ne);break;case 2:u^=r[c+1]<<8,u^=r[c],u=Math.imul(u,re),u=se(u,15),a^=u=Math.imul(u,ne);break;case 1:u^=r[c],u=Math.imul(u,re),u=se(u,15),a^=u=Math.imul(u,ne)}return ie(a^=n)>>>0},ae=function(e,t){var r=e,n=t;return r=Math.imul(r,re),r=se(r,15),r=Math.imul(r,ne),n=se(n^=r,13),(n=Math.imul(n,5))+-430675100|0},ie=function(e){var t=e;return t^=t>>>16,t=Math.imul(t,-2048144789),t^=t>>>13,t=Math.imul(t,-1028477387),t^=t>>>16},se=function(e,t,r){return void 0===r&&(r=32),t>r&&(t%=r),(e<<t|(e&4294967295<<r-t>>>0)>>>0>>>r-t>>>0)>>>0},ce=function(e,t){void 0===t&&(t=0);var r=e[t]<<24|e[t+1]<<16|e[t+2]<<8|e[t+3];return ue(r)},ue=function(e){return(-16777216&e)>>>24|(16711680&e)>>>8|(65280&e)<<8|(255&e)<<24},le=function(e,t){var r,n;if(t&&0!==t.length){try{for(var o=L(t),a=o.next();!a.done;a=o.next()){var i=a.value;if(!i||!e||"object"!=typeof e)return;e=e[i]}}catch(e){r={error:e}}finally{try{a&&!a.done&&(n=o.return)&&n.call(o)}finally{if(r)throw r.error}}return e||void 0}},fe="^".concat("(\\d+)\\.(\\d+)","(\\.").concat("(\\d+)").concat("(-(([-\\w]+\\.?)*))?",")?$"),pe=function(){function e(e,t,r,n){void 0===n&&(n=void 0),this.major=e,this.minor=t,this.patch=r,this.preRelease=n}return e.parse=function(t){if(t){var r=new RegExp(fe).exec(t);if(r){var n=Number(r[1]),o=Number(r[2]);if(!isNaN(n)&&!isNaN(o))return new e(n,o,Number(r[4])||0,r[5]||void 0)}}},e.prototype.compareTo=function(e){return this.major>e.major?1:this.major<e.major?-1:this.minor>e.minor?1:this.minor<e.minor?-1:this.patch>e.patch?1:this.patch<e.patch||this.preRelease&&!e.preRelease?-1:!this.preRelease&&e.preRelease?1:this.preRelease&&e.preRelease?this.preRelease>e.preRelease?1:this.preRelease<e.preRelease?-1:0:0},e}(),he=function(){function e(){}return e.prototype.evaluate=function(e,t){var r,n,o={},a={context:e,result:o};try{for(var i=L(t),s=i.next();!s.done;s=i.next()){var c=s.value,u=this.evaluateFlag(a,c);u&&(o[c.key]=u)}}catch(e){r={error:e}}finally{try{s&&!s.done&&(n=i.return)&&n.call(i)}finally{if(r)throw r.error}}return o},e.prototype.evaluateFlag=function(e,t){var r,n,o;try{for(var a=L(t.segments),i=a.next();!i.done;i=a.next()){var s=i.value;if(o=this.evaluateSegment(e,t,s)){var c=k(k(k({},t.metadata),s.metadata),o.metadata);o=k(k({},o),{metadata:c});break}}}catch(e){r={error:e}}finally{try{i&&!i.done&&(n=a.return)&&n.call(a)}finally{if(r)throw r.error}}return o},e.prototype.evaluateSegment=function(e,t,r){var n,o,a,i;if(!r.conditions)return void 0!==(u=this.bucket(e,r))?t.variants[u]:void 0;try{for(var s=L(r.conditions),c=s.next();!c.done;c=s.next()){var u,l=c.value,f=!0;try{for(var p=(a=void 0,L(l)),h=p.next();!h.done;h=p.next()){var v=h.value;if(!(f=this.matchCondition(e,v)))break}}catch(e){a={error:e}}finally{try{h&&!h.done&&(i=p.return)&&i.call(p)}finally{if(a)throw a.error}}if(f)return void 0!==(u=this.bucket(e,r))?t.variants[u]:void 0}}catch(e){n={error:e}}finally{try{c&&!c.done&&(o=s.return)&&o.call(s)}finally{if(n)throw n.error}}},e.prototype.matchCondition=function(e,t){var r=le(e,t.selector);if(r){if(this.isSetOperator(t.op)){var n=this.coerceStringArray(r);return!!n&&this.matchSet(n,t.op,t.values)}var o=this.coerceString(r);return void 0!==o&&this.matchString(o,t.op,t.values)}return this.matchNull(t.op,t.values)},e.prototype.getHash=function(e){return oe(e)},e.prototype.bucket=function(e,t){var r,n,o,a;if(!t.bucket)return t.variant;var i=this.coerceString(le(e,t.bucket.selector));if(!i||0===i.length)return t.variant;var s="".concat(t.bucket.salt,"/").concat(i),c=this.getHash(s),u=c%100,l=Math.floor(c/100);try{for(var f=L(t.bucket.allocations),p=f.next();!p.done;p=f.next()){var h=p.value,v=h.range[0],y=h.range[1];if(u>=v&&u<y)try{for(var d=(o=void 0,L(h.distributions)),m=d.next();!m.done;m=d.next()){var g=m.value,b=g.range[0],w=g.range[1];if(l>=b&&l<w)return g.variant}}catch(e){o={error:e}}finally{try{m&&!m.done&&(a=d.return)&&a.call(d)}finally{if(o)throw o.error}}}}catch(e){r={error:e}}finally{try{p&&!p.done&&(n=f.return)&&n.call(f)}finally{if(r)throw r.error}}return t.variant},e.prototype.matchNull=function(e,t){var r=this.containsNone(t);switch(e){case M:case R:case q:case K:case U:case V:case W:case z:case H:case J:case G:case Q:case Y:return r;case N:case F:case X:case Z:return!r;default:return!1}},e.prototype.matchSet=function(e,t,r){switch(t){case G:return this.setEquals(e,r);case $:return!this.setEquals(e,r);case Q:return this.matchesSetContainsAll(e,r);case X:return!this.matchesSetContainsAll(e,r);case Y:return this.matchesSetContainsAny(e,r);case Z:return!this.matchesSetContainsAny(e,r);default:return!1}},e.prototype.matchString=function(e,t,r){var n=this;switch(t){case M:return this.matchesIs(e,r);case N:return!this.matchesIs(e,r);case R:return this.matchesContains(e,r);case F:return!this.matchesContains(e,r);case q:case K:case U:case V:return this.matchesComparable(e,t,r,function(e){return n.parseNumber(e)},this.comparator);case W:case z:case H:case J:return this.matchesComparable(e,t,r,function(e){return pe.parse(e)},this.versionComparator);case ee:return this.matchesRegex(e,r);case te:return!this.matchesRegex(e,r);default:return!1}},e.prototype.matchesIs=function(e,t){if(this.containsBooleans(t)){var r=e.toLowerCase();if("true"===r||"false"===r)return t.some(function(e){return e.toLowerCase()===r})}return t.some(function(t){return e===t})},e.prototype.matchesContains=function(e,t){var r,n;try{for(var o=L(t),a=o.next();!a.done;a=o.next()){var i=a.value;if(e.toLowerCase().includes(i.toLowerCase()))return!0}}catch(e){r={error:e}}finally{try{a&&!a.done&&(n=o.return)&&n.call(o)}finally{if(r)throw r.error}}return!1},e.prototype.matchesComparable=function(e,t,r,n,o){var a=this,i=n(e),s=r.map(function(e){return n(e)}).filter(function(e){return void 0!==e});return void 0===i||0===s.length?r.some(function(r){return a.comparator(e,t,r)}):s.some(function(e){return o(i,t,e)})},e.prototype.comparator=function(e,t,r){switch(t){case q:case W:return e<r;case K:case z:return e<=r;case U:case H:return e>r;case V:case J:return e>=r;default:return!1}},e.prototype.versionComparator=function(e,t,r){var n=e.compareTo(r);switch(t){case q:case W:return n<0;case K:case z:return n<=0;case U:case H:return n>0;case V:case J:return n>=0;default:return!1}},e.prototype.matchesRegex=function(e,t){return t.some(function(t){return Boolean(new RegExp(t).exec(e))})},e.prototype.containsNone=function(e){return e.some(function(e){return"(none)"===e})},e.prototype.containsBooleans=function(e){return e.some(function(e){switch(e.toLowerCase()){case"true":case"false":return!0;default:return!1}})},e.prototype.parseNumber=function(e){var t;return null!==(t=Number(e))&&void 0!==t?t:void 0},e.prototype.coerceString=function(e){if(e)return"object"==typeof e?JSON.stringify(e):String(e)},e.prototype.coerceStringArray=function(e){var t=this;if(Array.isArray(e))return e.map(function(e){return t.coerceString(e)}).filter(Boolean);var r=String(e);try{var n=JSON.parse(r);return Array.isArray(n)?e.map(function(e){return t.coerceString(e)}).filter(Boolean):void 0}catch(e){return}},e.prototype.isSetOperator=function(e){switch(e){case G:case $:case Q:case X:case Y:case Z:return!0;default:return!1}},e.prototype.setEquals=function(e,t){var r=new Set(e),n=new Set(t);return r.size===n.size&&function(e,t,r){if(r||2===arguments.length)for(var n,o=0,a=t.length;o<a;o++)!n&&o in t||(n||(n=Array.prototype.slice.call(t,0,o)),n[o]=t[o]);return e.concat(n||Array.prototype.slice.call(t))}([],function(e,t){var r="function"==typeof Symbol&&e[Symbol.iterator];if(!r)return e;var n,o,a=r.call(e),i=[];try{for(;(void 0===t||t-- >0)&&!(n=a.next()).done;)i.push(n.value)}catch(e){o={error:e}}finally{try{n&&!n.done&&(r=a.return)&&r.call(a)}finally{if(o)throw o.error}}return i}(n),!1).every(function(e){return r.has(e)})},e.prototype.matchesSetContainsAll=function(e,t){var r,n;if(e.length<t.length)return!1;try{for(var o=L(t),a=o.next();!a.done;a=o.next()){var i=a.value;if(!this.matchesIs(i,e))return!1}}catch(e){r={error:e}}finally{try{a&&!a.done&&(n=o.return)&&n.call(o)}finally{if(r)throw r.error}}return!0},e.prototype.matchesSetContainsAny=function(e,t){var r,n;try{for(var o=L(t),a=o.next();!a.done;a=o.next()){var i=a.value;if(this.matchesIs(i,e))return!0}}catch(e){r={error:e}}finally{try{a&&!a.done&&(n=o.return)&&n.call(o)}finally{if(r)throw r.error}}return!1},e}();"function"==typeof TextDecoder&&new TextDecoder,"function"==typeof TextEncoder&&new TextEncoder;const ve=Array.prototype.slice.call("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=");(()=>{let e={};ve.forEach((t,r)=>e[t]=r)})(),String.fromCharCode.bind(String),"function"==typeof Uint8Array.from&&Uint8Array.from.bind(Uint8Array),function(e){function t(r,n){var o=e.call(this,n)||this;return o.statusCode=r,Object.setPrototypeOf(o,t.prototype),o}(function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Class extends value "+String(t)+" is not a constructor or null");function r(){this.constructor=e}P(e,t),e.prototype=null===t?Object.create(t):(r.prototype=t.prototype,new r)})(t,e)}(Error);var ye=new function(){var e=this;this.dbs={},this.createStore=function(t){return o(e,void 0,void 0,function(){return a(this,function(e){switch(e.label){case 0:return[4,S(t,1,{upgrade:function(e){e.objectStoreNames.contains("eventTypesForSession")||e.createObjectStore("eventTypesForSession",{keyPath:"sessionId"})}})];case 1:return[2,e.sent()]}})})},this.openOrCreateDB=function(t){return o(e,void 0,void 0,function(){var e,r;return a(this,function(n){switch(n.label){case 0:return this.dbs&&this.dbs[t]?[2,this.dbs[t]]:(e="".concat(t.substring(0,10),"_amp_targeting"),[4,this.createStore(e)]);case 1:return r=n.sent(),this.dbs[t]=r,[2,r]}})})},this.updateEventListForSession=function(t){var n=t.sessionId,i=t.eventType,s=t.eventTime,c=t.loggerProvider,u=t.tx;return o(e,void 0,void 0,function(){var e,t,o,l,f,p,h,v,y;return a(this,function(a){switch(a.label){case 0:return a.trys.push([0,3,,4]),e=String(n),[4,u.store.get(e)];case 1:return t=a.sent(),o=t?t.eventTypes:{},l=o[i]||{},f=r(r({},o),((v={})[i]=r(r({},l),((y={})[s]={event_type:i},y)),v)),p={sessionId:e,eventTypes:f,lastUpdated:Date.now()},[4,u.store.put(p)];case 2:return a.sent(),[2,f];case 3:return h=a.sent(),c.warn("Failed to store events for targeting ".concat(n,": ").concat(h)),[3,4];case 4:return[2,void 0]}})})},this.deleteOldSessionEventTypes=function(t){var r=t.currentSessionId,n=t.loggerProvider,i=t.tx;return o(e,void 0,void 0,function(){var e,t,o,s,c,u;return a(this,function(a){switch(a.label){case 0:return a.trys.push([0,6,,7]),e=String(r),[4,i.store.getAll()];case 1:t=a.sent(),o=0,a.label=2;case 2:return o<t.length?(s=t[o],c=Date.now()-s.lastUpdated,s.sessionId!==e&&c>1728e5?[4,i.store.delete(s.sessionId)]:[3,4]):[3,5];case 3:a.sent(),a.label=4;case 4:return o++,[3,2];case 5:return[3,7];case 6:return u=a.sent(),n.warn("Failed to clear old session event types for targeting: ".concat(u)),[3,7];case 7:return[2]}})})},this.storeEventTypeForSession=function(t){var r=t.loggerProvider,n=t.sessionId,i=t.eventType,s=t.eventTime,c=t.apiKey;return o(e,void 0,void 0,function(){var e,t,o,u;return a(this,function(a){switch(a.label){case 0:return a.trys.push([0,5,,6]),[4,this.openOrCreateDB(c)];case 1:return e=a.sent(),(t=e.transaction("eventTypesForSession","readwrite"))?[4,this.updateEventListForSession({sessionId:n,tx:t,loggerProvider:r,eventType:i,eventTime:s})]:[2];case 2:return o=a.sent(),[4,this.deleteOldSessionEventTypes({currentSessionId:n,tx:t,loggerProvider:r})];case 3:return a.sent(),[4,t.done];case 4:return a.sent(),[2,o];case 5:return u=a.sent(),r.warn("Failed to store events for targeting ".concat(n,": ").concat(u)),[3,6];case 6:return[2,void 0]}})})}},de=function(){var e=this;this.evaluateTargeting=function(t){var n=t.apiKey,i=t.loggerProvider,s=t.event,c=t.sessionId,u=t.userProperties,l=t.deviceId,f=t.page,p=t.flag;return o(e,void 0,void 0,function(){var e,t,o,h;return a(this,function(a){switch(a.label){case 0:return s&&s.time?[4,ye.storeEventTypeForSession({loggerProvider:i,apiKey:n,sessionId:c,eventType:s.event_type,eventTime:s.time})]:[3,2];case 1:return t=a.sent(),[3,3];case 2:t=void 0,a.label=3;case 3:return o=(e=t)&&new Set(Object.keys(e)),h={session_id:c,event:s,event_types:o&&Array.from(o),user:r(r({},u),{device_id:l,user_properties:u}),page:f},[2,this.evaluationEngine.evaluate(h,[p])]}})})},this.evaluationEngine=new he},me=function(){var e=new de;return{evaluateTargeting:e.evaluateTargeting.bind(e)}}().evaluateTargeting,ge=Object.freeze({__proto__:null,evaluateTargeting:me});export{c as _,s as a,t as b,o as c,a as d,r as e,i as f,n as g,ge as i,S as o};
|
|
2
2
|
//# sourceMappingURL=targeting-min.js.map
|
|
Binary file
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
const e='var WebWorker=function(e){"use strict";onmessage=function(e){var s="string"==typeof e.data?JSON.parse(e.data):e.data,t=s.event,a=s.sessionId,n=t.type,r=t.timestamp,i=t.delay,o=t.data,d=null!=i?JSON.stringify({type:n,timestamp:r,delay:i,data:o}):JSON.stringify({type:n,timestamp:r,data:o});postMessage({compressedEvent:d,sessionId:a})};var s=onmessage;return e.compressionOnMessage=s,Object.defineProperty(e,"__esModule",{value:!0}),e}({});\n',t='var WebWorker=function(e){"use strict";var t,r=function(){return r=Object.assign||function(e){for(var t,r=1,n=arguments.length;r<n;r++)for(var s in t=arguments[r])Object.prototype.hasOwnProperty.call(t,s)&&(e[s]=t[s]);return e},r.apply(this,arguments)};function n(e,t,r,n){return new(r||(r=Promise))(function(s,o){function a(e){try{
|
|
1
|
+
const e='var WebWorker=function(e){"use strict";onmessage=function(e){var s="string"==typeof e.data?JSON.parse(e.data):e.data,t=s.event,a=s.sessionId,n=t.type,r=t.timestamp,i=t.delay,o=t.data,d=null!=i?JSON.stringify({type:n,timestamp:r,delay:i,data:o}):JSON.stringify({type:n,timestamp:r,data:o});postMessage({compressedEvent:d,sessionId:a})};var s=onmessage;return e.compressionOnMessage=s,Object.defineProperty(e,"__esModule",{value:!0}),e}({});\n',t='var WebWorker=function(e){"use strict";var t,r=function(){return r=Object.assign||function(e){for(var t,r=1,n=arguments.length;r<n;r++)for(var s in t=arguments[r])Object.prototype.hasOwnProperty.call(t,s)&&(e[s]=t[s]);return e},r.apply(this,arguments)};function n(e,t,r,n){return new(r||(r=Promise))(function(s,o){function a(e){try{u(n.next(e))}catch(e){o(e)}}function i(e){try{u(n.throw(e))}catch(e){o(e)}}function u(e){var t;e.done?s(e.value):(t=e.value,t instanceof r?t:new r(function(e){e(t)})).then(a,i)}u((n=n.apply(e,t||[])).next())})}function s(e,t){var r,n,s,o={label:0,sent:function(){if(1&s[0])throw s[1];return s[1]},trys:[],ops:[]},a=Object.create(("function"==typeof Iterator?Iterator:Object).prototype);return a.next=i(0),a.throw=i(1),a.return=i(2),"function"==typeof Symbol&&(a[Symbol.iterator]=function(){return this}),a;function i(i){return function(u){return function(i){if(r)throw new TypeError("Generator is already executing.");for(;a&&(a=0,i[0]&&(o=0)),o;)try{if(r=1,n&&(s=2&i[0]?n.return:i[0]?n.throw||((s=n.return)&&s.call(n),0):n.next)&&!(s=s.call(n,i[1])).done)return s;switch(n=0,s&&(i=[2&i[0],s.value]),i[0]){case 0:case 1:s=i;break;case 4:return o.label++,{value:i[1],done:!1};case 5:o.label++,n=i[1],i=[0];continue;case 7:i=o.ops.pop(),o.trys.pop();continue;default:if(!(s=o.trys,(s=s.length>0&&s[s.length-1])||6!==i[0]&&2!==i[0])){o=0;continue}if(3===i[0]&&(!s||i[1]>s[0]&&i[1]<s[3])){o.label=i[1];break}if(6===i[0]&&o.label<s[1]){o.label=s[1],s=i;break}if(s&&o.label<s[2]){o.label=s[2],o.ops.push(i);break}s[2]&&o.ops.pop(),o.trys.pop();continue}i=t.call(e,o)}catch(e){i=[6,e],n=0}finally{r=s=0}if(5&i[0])throw i[1];return{value:i[0]?i[1]:void 0,done:!0}}([i,u])}}}"function"==typeof SuppressedError&&SuppressedError,function(e){e.US="US",e.EU="EU",e.STAGING="STAGING"}(t||(t={})),t.US;var o,a=/payload.*exceed/i,i="X-Session-Replay-Event-Skipped";!function(e){e.GET_SR_PROPS="get-sr-props",e.DEBUG_INFO="debug-info",e.FETCH_REQUEST="fetch-request",e.METADATA="metadata",e.TARGETING_DECISION="targeting-decision",e.REPLAY_GATE_DECISION="replay-gate-decision"}(o||(o={}));var u="Network error occurred, event batch rejected";function c(e,t){return n(this,void 0,void 0,function(){var r,o,a,i,u,c,l,d,p,f,v,y,h,b,g=this;return s(this,function(m){switch(m.label){case 0:return m.trys.push([0,4,,5]),r=t.CompressionStream,o=new r("gzip"),a=o.writable.getWriter(),i=o.readable.getReader(),u=[],c=n(g,void 0,void 0,function(){var e,t,r;return s(this,function(n){switch(n.label){case 0:return[4,i.read()];case 1:if(e=n.sent(),t=e.done,r=e.value,t)return[3,3];u.push(r),n.label=2;case 2:return[3,0];case 3:return[2]}})}),[4,a.write((new TextEncoder).encode(e))];case 1:return m.sent(),[4,a.close()];case 2:return m.sent(),[4,c];case 3:m.sent(),l=u.reduce(function(e,t){return e+t.length},0),d=new Uint8Array(l),p=0;try{for(f=function(e){var t="function"==typeof Symbol&&Symbol.iterator,r=t&&e[t],n=0;if(r)return r.call(e);if(e&&"number"==typeof e.length)return{next:function(){return e&&n>=e.length&&(e=void 0),{value:e&&e[n++],done:!e}}};throw new TypeError(t?"Object is not iterable.":"Symbol.iterator is not defined.")}(u),v=f.next();!v.done;v=f.next())y=v.value,d.set(y,p),p+=y.length}catch(e){h={error:e}}finally{try{v&&!v.done&&(b=f.return)&&b.call(f)}finally{if(h)throw h.error}}return[2,d];case 4:return m.sent(),[2,null];case 5:return[2]}})})}var l=0,d=new Map,p=function(e,t){return fetch(e,t)},f=function(e,t){var r="".concat(++l);return new Promise(function(n,s){var o=t.signal,a=function(){d.delete(r);var e=new Error("Delegated session replay fetch aborted by send timeout");e.name="AbortError",s(e)};o.addEventListener("abort",a,{once:!0}),d.set(r,function(e){o.removeEventListener("abort",a),e.error?s(new Error(e.body)):n({status:e.status,headers:{get:function(t){return t===i?e.skipHeader:null}},text:function(){return Promise.resolve(e.body)}})}),postMessage({type:"fetch-request",requestId:r,url:e,method:"POST",headers:t.headers,body:t.body,keepalive:t.keepalive})})};function v(e,t,o){var l,d,p,f,v,y,h,b;return n(this,void 0,void 0,function(){var n,g,m,w,S,T,E,k,R,x,C,I,A,M,O;return s(this,function(s){switch(s.label){case 0:n=null!==(l=t.sendTimeoutMs)&&void 0!==l?l:1e4,s.label=1;case 1:return s.trys.push([1,14,,15]),!1!==t.enableTransportCompression&&"CompressionStream"in self?[4,c(e,self)]:[3,3];case 2:return m=s.sent(),[3,4];case 3:m=null,s.label=4;case 4:g=m,w="".concat(null!==(p=null===(d=t.version)||void 0===d?void 0:d.type)&&void 0!==p?p:"standalone","/").concat(null!==(v=null===(f=t.version)||void 0===f?void 0:f.version)&&void 0!==v?v:t.sdkVersion),S=new URLSearchParams({device_id:t.deviceId,session_id:"".concat(t.sessionId),type:t.eventType}),T="".concat((U=t.serverZone,P=t.trackServerUrl,P||("STAGING"===U?"https://api-sr.stag2.amplitude.com/sessions/v2/track":"EU"===U?"https://api-sr.eu.amplitude.com/sessions/v2/track":"https://api-sr.amplitude.com/sessions/v2/track")),"?").concat(S.toString()),E=r({"Content-Type":"application/json",Accept:"*/*",Authorization:"Bearer ".concat(t.apiKey),"X-Client-Version":t.sdkVersion,"X-Client-Library":w,"X-Client-Url":t.currentUrl.substring(0,1e3),"X-Client-Sample-Rate":"".concat(t.sampleRate),"X-Sampling-Hash-Alg":"xxhash32"},g?{"Content-Encoding":"gzip"}:{}),k=g?g.byteLength:new Blob([e]).size,R=new AbortController,x=n>0?setTimeout(function(){R.abort()},n):void 0,C=void 0,s.label=5;case 5:return s.trys.push([5,,7,8]),[4,o(T,{method:"POST",headers:E,body:null!=g?g:e,keepalive:k<=65536,signal:R.signal})];case 6:return C=s.sent(),[3,8];case 7:return x&&clearTimeout(x),[7];case 8:if(null===C)return[2,{shouldRetry:!1,success:!1,message:"Unexpected error occurred"}];if(C.status>=200&&C.status<300)return I=Math.round(new Blob(t.events).size/1024),A=null!==(b=null===(h=null===(y=C.headers)||void 0===y?void 0:y.get)||void 0===h?void 0:h.call(y,i))&&void 0!==b?b:null,[2,{shouldRetry:!1,success:!0,message:"Session replay event batch tracked successfully for session id ".concat(t.sessionId,", size of events: ").concat(I," KB"),skipCode:A}];if(413!==C.status)return[3,13];M="",s.label=9;case 9:return s.trys.push([9,11,,12]),[4,C.text()];case 10:return M=s.sent(),[3,12];case 11:return s.sent(),[3,12];case 12:return[2,{shouldRetry:!1,success:!1,message:u,payloadTooLarge:!0,isWaf:a.test(M)}];case 13:return C.status>=500||408===C.status||429===C.status||499===C.status?[2,{shouldRetry:!0,success:!1,message:"HTTP ".concat(C.status)}]:[2,{shouldRetry:!1,success:!1,message:u}];case 14:return(O=s.sent())&&"object"==typeof O&&"AbortError"===O.name?[2,{shouldRetry:!0,success:!1,message:"Session replay worker request timed out after ".concat(n,"ms")}]:[2,{shouldRetry:!1,success:!1,message:String(O)}];case 15:return[2]}var U,P})})}function y(e,t,r,o,a){var i;return n(this,void 0,void 0,function(){var n,u,c;return s(this,function(s){switch(s.label){case 0:n=1,s.label=1;case 1:return[4,v(t,r,a)];case 2:return(u=s.sent()).success?(postMessage({type:"log",id:e,message:u.message}),postMessage({type:"complete",id:e,skipCode:null!==(i=u.skipCode)&&void 0!==i?i:null}),[2]):u.payloadTooLarge&&o?(postMessage({type:"payload_too_large",id:e,isWaf:!0===u.isWaf}),[2]):o&&u.shouldRetry&&n<r.flushMaxRetries?[4,new Promise(function(e){return setTimeout(e,Math.random()*n*1e3)})]:[3,4];case 3:return s.sent(),n++,[3,5];case 4:return c=n>=r.flushMaxRetries?"Session replay event batch rejected due to exceeded retry count":u.message,postMessage({type:"warn",id:e,message:c}),postMessage({type:"complete",id:e}),[2];case 5:return[3,1];case 6:return[2]}})})}onmessage=function(e){return n(void 0,void 0,void 0,function(){var t,r,n,o,a,i,u,c;return s(this,function(s){switch(s.label){case 0:return"fetch-response"===(t=e.data).type?((r=d.get(t.requestId))&&(d.delete(t.requestId),r(t)),[2]):"send"!==t.type?[3,2]:(n=t.id,o=t.payload,a=t.context,i=t.useRetry,u=t.useCustomTransport,c=JSON.stringify(o),[4,y(n,c,a,i,u?f:p)]);case 1:s.sent(),s.label=2;case 2:return[2]}})})};var h=onmessage;return e.trackDestinationOnMessage=h,Object.defineProperty(e,"__esModule",{value:!0}),e}({});\n';export{e as compressionScript,t as trackDestinationScript};
|
|
2
2
|
//# sourceMappingURL=worker-min.js.map
|
|
Binary file
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@amplitude/session-replay-browser",
|
|
3
|
-
"version": "1.47.0
|
|
3
|
+
"version": "1.47.0",
|
|
4
4
|
"description": "",
|
|
5
5
|
"author": "Amplitude Inc",
|
|
6
6
|
"homepage": "https://github.com/amplitude/Amplitude-TypeScript",
|
|
@@ -29,10 +29,10 @@
|
|
|
29
29
|
"@rollup/plugin-replace": "^6.0.1",
|
|
30
30
|
"idb": "8.0.0",
|
|
31
31
|
"tslib": "^2.4.1",
|
|
32
|
+
"@amplitude/analytics-core": "2.52.0",
|
|
32
33
|
"@amplitude/analytics-types": "2.11.1",
|
|
33
|
-
"@amplitude/
|
|
34
|
-
"@amplitude/
|
|
35
|
-
"@amplitude/analytics-client-common": "2.4.50"
|
|
34
|
+
"@amplitude/analytics-client-common": "2.4.52",
|
|
35
|
+
"@amplitude/targeting": "0.3.2"
|
|
36
36
|
},
|
|
37
37
|
"devDependencies": {
|
|
38
38
|
"@aws-sdk/client-s3": "^3.229.0",
|
package/lib/cjs/diagnostics.d.ts
DELETED
|
@@ -1,50 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Centralized names for Session Replay diagnostics shipped via the analytics DiagnosticsClient.
|
|
3
|
-
*
|
|
4
|
-
* Every name shares SR_DIAGNOSTIC_PREFIX so they group together in DataDog as
|
|
5
|
-
* `sdk.diagnostics.sr.trc.*`. The diagnostics pipeline prepends `sdk.diagnostics.` and appends
|
|
6
|
-
* `.count` to counters / `.{min,max,avg,count}` to histograms; events are forwarded to DataDog
|
|
7
|
-
* Logs keyed by `event_name`. Keep ALL SR diagnostic names here so the prefix stays unified —
|
|
8
|
-
* changing the namespace is then a one-line edit.
|
|
9
|
-
*/
|
|
10
|
-
export declare const SR_DIAGNOSTIC_PREFIX = "sr.trc";
|
|
11
|
-
export declare const SrDiagnostic: {
|
|
12
|
-
readonly init: "sr.trc.init";
|
|
13
|
-
readonly sessionChanged: "sr.trc.session.changed";
|
|
14
|
-
readonly configSource: (source: string) => string;
|
|
15
|
-
readonly configHasTargeting: "sr.trc.config.has_targeting";
|
|
16
|
-
readonly configNoTargeting: "sr.trc.config.no_targeting";
|
|
17
|
-
readonly configFetchFailed: "sr.trc.config.fetch_failed";
|
|
18
|
-
readonly configReceived: "sr.trc.config.received";
|
|
19
|
-
readonly targetingTrigger: "sr.trc.targeting.trigger";
|
|
20
|
-
readonly evalTrigger: (trigger: string) => string;
|
|
21
|
-
readonly evalNoConfig: "sr.trc.eval.no_config";
|
|
22
|
-
readonly evalMissingPrereq: "sr.trc.eval.missing_prereq";
|
|
23
|
-
readonly evalMatch: "sr.trc.eval.match";
|
|
24
|
-
readonly evalNoMatch: "sr.trc.eval.no_match";
|
|
25
|
-
readonly evalError: "sr.trc.eval.error";
|
|
26
|
-
readonly evalStaleDiscarded: "sr.trc.eval.stale_discarded";
|
|
27
|
-
readonly evalSkippedAlreadyMatched: "sr.trc.eval.skipped_already_matched";
|
|
28
|
-
readonly evalDurationMs: "sr.trc.eval.duration_ms";
|
|
29
|
-
readonly evalEvent: "sr.trc.eval";
|
|
30
|
-
readonly evalResult: "sr.trc.eval.result";
|
|
31
|
-
readonly recordStarted: "sr.trc.record.started";
|
|
32
|
-
readonly recordNoRecordFn: "sr.trc.record.no_record_fn";
|
|
33
|
-
readonly sendSuppressedMinDuration: "sr.trc.send.suppressed_min_duration";
|
|
34
|
-
readonly gateNoIdentifiers: "sr.trc.gate.no_identifiers";
|
|
35
|
-
readonly gateCaptureDisabled: "sr.trc.gate.capture_disabled";
|
|
36
|
-
readonly gateOptOut: "sr.trc.gate.optout";
|
|
37
|
-
readonly gateTrcMatch: "sr.trc.gate.trc_match";
|
|
38
|
-
readonly gateTrcNoMatch: "sr.trc.gate.trc_no_match";
|
|
39
|
-
readonly gateSampleIn: "sr.trc.gate.sample_in";
|
|
40
|
-
readonly gateSampleOut: "sr.trc.gate.sample_out";
|
|
41
|
-
readonly decision: "sr.trc.decision";
|
|
42
|
-
readonly urlChange: "sr.trc.url_change";
|
|
43
|
-
readonly urlChangeEvent: "sr.trc.url_change";
|
|
44
|
-
readonly urlListenerSetup: "sr.trc.url_listener.setup";
|
|
45
|
-
readonly urlListenerAttached: "sr.trc.url_listener.attached";
|
|
46
|
-
readonly urlListenerSkipped: "sr.trc.url_listener.skipped";
|
|
47
|
-
readonly urlPollTick: "sr.trc.url_poll.tick";
|
|
48
|
-
readonly urlPollFirstTick: "sr.trc.url_poll.first_tick";
|
|
49
|
-
};
|
|
50
|
-
//# sourceMappingURL=diagnostics.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"diagnostics.d.ts","sourceRoot":"","sources":["../../src/diagnostics.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AACH,eAAO,MAAM,oBAAoB,WAAW,CAAC;AAI7C,eAAO,MAAM,YAAY;;;oCAUA,MAAM;;;;;;oCAUN,MAAM;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAsCrB,CAAC"}
|
package/lib/cjs/diagnostics.js
DELETED
|
@@ -1,67 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.SrDiagnostic = exports.SR_DIAGNOSTIC_PREFIX = void 0;
|
|
4
|
-
/**
|
|
5
|
-
* Centralized names for Session Replay diagnostics shipped via the analytics DiagnosticsClient.
|
|
6
|
-
*
|
|
7
|
-
* Every name shares SR_DIAGNOSTIC_PREFIX so they group together in DataDog as
|
|
8
|
-
* `sdk.diagnostics.sr.trc.*`. The diagnostics pipeline prepends `sdk.diagnostics.` and appends
|
|
9
|
-
* `.count` to counters / `.{min,max,avg,count}` to histograms; events are forwarded to DataDog
|
|
10
|
-
* Logs keyed by `event_name`. Keep ALL SR diagnostic names here so the prefix stays unified —
|
|
11
|
-
* changing the namespace is then a one-line edit.
|
|
12
|
-
*/
|
|
13
|
-
exports.SR_DIAGNOSTIC_PREFIX = 'sr.trc';
|
|
14
|
-
var p = exports.SR_DIAGNOSTIC_PREFIX;
|
|
15
|
-
exports.SrDiagnostic = {
|
|
16
|
-
// ── Init (Q1: did init even happen?) ─────────────────────────────────────
|
|
17
|
-
init: "".concat(p, ".init"),
|
|
18
|
-
// ── Session lifecycle ────────────────────────────────────────────────────
|
|
19
|
-
// SR session id changed (timeout / explicit setSessionId / custom session id). New tabs and
|
|
20
|
-
// page refreshes do NOT change the session id, so this is distinct from a fresh init.
|
|
21
|
-
sessionChanged: "".concat(p, ".session.changed"),
|
|
22
|
-
// ── Remote config fetch (joined-config) ──────────────────────────────────
|
|
23
|
-
configSource: function (source) { return "".concat(p, ".config.source.").concat(source); },
|
|
24
|
-
configHasTargeting: "".concat(p, ".config.has_targeting"),
|
|
25
|
-
configNoTargeting: "".concat(p, ".config.no_targeting"),
|
|
26
|
-
configFetchFailed: "".concat(p, ".config.fetch_failed"),
|
|
27
|
-
configReceived: "".concat(p, ".config.received"),
|
|
28
|
-
targetingTrigger: "".concat(p, ".targeting.trigger"),
|
|
29
|
-
// ── Targeting evaluation (evaluateTargetingAndCapture) ────────────────────
|
|
30
|
-
// Q2 (did eval run?), Q3 (working/failed?), Q4 (missing value?), Q5 (all params).
|
|
31
|
-
evalTrigger: function (trigger) { return "".concat(p, ".eval.").concat(trigger); },
|
|
32
|
-
evalNoConfig: "".concat(p, ".eval.no_config"),
|
|
33
|
-
evalMissingPrereq: "".concat(p, ".eval.missing_prereq"),
|
|
34
|
-
evalMatch: "".concat(p, ".eval.match"),
|
|
35
|
-
evalNoMatch: "".concat(p, ".eval.no_match"),
|
|
36
|
-
evalError: "".concat(p, ".eval.error"),
|
|
37
|
-
evalStaleDiscarded: "".concat(p, ".eval.stale_discarded"),
|
|
38
|
-
evalSkippedAlreadyMatched: "".concat(p, ".eval.skipped_already_matched"),
|
|
39
|
-
evalDurationMs: "".concat(p, ".eval.duration_ms"),
|
|
40
|
-
evalEvent: "".concat(p, ".eval"),
|
|
41
|
-
evalResult: "".concat(p, ".eval.result"),
|
|
42
|
-
// ── Recording execution (getShouldRecord said yes — did rrweb actually start?) ──
|
|
43
|
-
recordStarted: "".concat(p, ".record.started"),
|
|
44
|
-
recordNoRecordFn: "".concat(p, ".record.no_record_fn"),
|
|
45
|
-
sendSuppressedMinDuration: "".concat(p, ".send.suppressed_min_duration"),
|
|
46
|
-
// ── Record / no-record gate (getShouldRecord) ────────────────────────────
|
|
47
|
-
gateNoIdentifiers: "".concat(p, ".gate.no_identifiers"),
|
|
48
|
-
gateCaptureDisabled: "".concat(p, ".gate.capture_disabled"),
|
|
49
|
-
gateOptOut: "".concat(p, ".gate.optout"),
|
|
50
|
-
gateTrcMatch: "".concat(p, ".gate.trc_match"),
|
|
51
|
-
gateTrcNoMatch: "".concat(p, ".gate.trc_no_match"),
|
|
52
|
-
gateSampleIn: "".concat(p, ".gate.sample_in"),
|
|
53
|
-
gateSampleOut: "".concat(p, ".gate.sample_out"),
|
|
54
|
-
decision: "".concat(p, ".decision"),
|
|
55
|
-
// ── SPA URL change (setupUrlChangeListener) ──────────────────────────────
|
|
56
|
-
urlChange: "".concat(p, ".url_change"),
|
|
57
|
-
urlChangeEvent: "".concat(p, ".url_change"),
|
|
58
|
-
// Was the URL-change listener even wired up? (covers "the SDK never saw any navigation"
|
|
59
|
-
// because the listener was never attached — e.g. no targeting config, or no global scope.)
|
|
60
|
-
urlListenerSetup: "".concat(p, ".url_listener.setup"),
|
|
61
|
-
urlListenerAttached: "".concat(p, ".url_listener.attached"),
|
|
62
|
-
urlListenerSkipped: "".concat(p, ".url_listener.skipped"),
|
|
63
|
-
// Proof the polling loop actually FIRES (not just that it was scheduled by url_listener.attached).
|
|
64
|
-
urlPollTick: "".concat(p, ".url_poll.tick"),
|
|
65
|
-
urlPollFirstTick: "".concat(p, ".url_poll.first_tick"), // event: once per session on the first tick (carries href)
|
|
66
|
-
};
|
|
67
|
-
//# sourceMappingURL=diagnostics.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"diagnostics.js","sourceRoot":"","sources":["../../src/diagnostics.ts"],"names":[],"mappings":";;;AAAA;;;;;;;;GAQG;AACU,QAAA,oBAAoB,GAAG,QAAQ,CAAC;AAE7C,IAAM,CAAC,GAAG,4BAAoB,CAAC;AAElB,QAAA,YAAY,GAAG;IAC1B,4EAA4E;IAC5E,IAAI,EAAE,UAAG,CAAC,UAAO;IAEjB,4EAA4E;IAC5E,4FAA4F;IAC5F,sFAAsF;IACtF,cAAc,EAAE,UAAG,CAAC,qBAAkB;IAEtC,4EAA4E;IAC5E,YAAY,EAAE,UAAC,MAAc,IAAK,OAAA,UAAG,CAAC,4BAAkB,MAAM,CAAE,EAA9B,CAA8B;IAChE,kBAAkB,EAAE,UAAG,CAAC,0BAAuB;IAC/C,iBAAiB,EAAE,UAAG,CAAC,yBAAsB;IAC7C,iBAAiB,EAAE,UAAG,CAAC,yBAAsB;IAC7C,cAAc,EAAE,UAAG,CAAC,qBAAkB;IAEtC,gBAAgB,EAAE,UAAG,CAAC,uBAAoB;IAE1C,6EAA6E;IAC7E,kFAAkF;IAClF,WAAW,EAAE,UAAC,OAAe,IAAK,OAAA,UAAG,CAAC,mBAAS,OAAO,CAAE,EAAtB,CAAsB;IACxD,YAAY,EAAE,UAAG,CAAC,oBAAiB;IACnC,iBAAiB,EAAE,UAAG,CAAC,yBAAsB;IAC7C,SAAS,EAAE,UAAG,CAAC,gBAAa;IAC5B,WAAW,EAAE,UAAG,CAAC,mBAAgB;IACjC,SAAS,EAAE,UAAG,CAAC,gBAAa;IAC5B,kBAAkB,EAAE,UAAG,CAAC,0BAAuB;IAC/C,yBAAyB,EAAE,UAAG,CAAC,kCAA+B;IAC9D,cAAc,EAAE,UAAG,CAAC,sBAAmB;IACvC,SAAS,EAAE,UAAG,CAAC,UAAO;IACtB,UAAU,EAAE,UAAG,CAAC,iBAAc;IAE9B,mFAAmF;IACnF,aAAa,EAAE,UAAG,CAAC,oBAAiB;IACpC,gBAAgB,EAAE,UAAG,CAAC,yBAAsB;IAC5C,yBAAyB,EAAE,UAAG,CAAC,kCAA+B;IAE9D,4EAA4E;IAC5E,iBAAiB,EAAE,UAAG,CAAC,yBAAsB;IAC7C,mBAAmB,EAAE,UAAG,CAAC,2BAAwB;IACjD,UAAU,EAAE,UAAG,CAAC,iBAAc;IAC9B,YAAY,EAAE,UAAG,CAAC,oBAAiB;IACnC,cAAc,EAAE,UAAG,CAAC,uBAAoB;IACxC,YAAY,EAAE,UAAG,CAAC,oBAAiB;IACnC,aAAa,EAAE,UAAG,CAAC,qBAAkB;IACrC,QAAQ,EAAE,UAAG,CAAC,cAAW;IAEzB,4EAA4E;IAC5E,SAAS,EAAE,UAAG,CAAC,gBAAa;IAC5B,cAAc,EAAE,UAAG,CAAC,gBAAa;IACjC,wFAAwF;IACxF,2FAA2F;IAC3F,gBAAgB,EAAE,UAAG,CAAC,wBAAqB;IAC3C,mBAAmB,EAAE,UAAG,CAAC,2BAAwB;IACjD,kBAAkB,EAAE,UAAG,CAAC,0BAAuB;IAC/C,mGAAmG;IACnG,WAAW,EAAE,UAAG,CAAC,mBAAgB;IACjC,gBAAgB,EAAE,UAAG,CAAC,yBAAsB,EAAE,2DAA2D;CACjG,CAAC","sourcesContent":["/**\n * Centralized names for Session Replay diagnostics shipped via the analytics DiagnosticsClient.\n *\n * Every name shares SR_DIAGNOSTIC_PREFIX so they group together in DataDog as\n * `sdk.diagnostics.sr.trc.*`. The diagnostics pipeline prepends `sdk.diagnostics.` and appends\n * `.count` to counters / `.{min,max,avg,count}` to histograms; events are forwarded to DataDog\n * Logs keyed by `event_name`. Keep ALL SR diagnostic names here so the prefix stays unified —\n * changing the namespace is then a one-line edit.\n */\nexport const SR_DIAGNOSTIC_PREFIX = 'sr.trc';\n\nconst p = SR_DIAGNOSTIC_PREFIX;\n\nexport const SrDiagnostic = {\n // ── Init (Q1: did init even happen?) ─────────────────────────────────────\n init: `${p}.init`, // counter + event(with props): fires once per init()\n\n // ── Session lifecycle ────────────────────────────────────────────────────\n // SR session id changed (timeout / explicit setSessionId / custom session id). New tabs and\n // page refreshes do NOT change the session id, so this is distinct from a fresh init.\n sessionChanged: `${p}.session.changed`, // event (with from/to)\n\n // ── Remote config fetch (joined-config) ──────────────────────────────────\n configSource: (source: string) => `${p}.config.source.${source}`,\n configHasTargeting: `${p}.config.has_targeting`,\n configNoTargeting: `${p}.config.no_targeting`,\n configFetchFailed: `${p}.config.fetch_failed`,\n configReceived: `${p}.config.received`, // event (with props)\n\n targetingTrigger: `${p}.targeting.trigger`, // event: targeting evaluation triggered\n\n // ── Targeting evaluation (evaluateTargetingAndCapture) ────────────────────\n // Q2 (did eval run?), Q3 (working/failed?), Q4 (missing value?), Q5 (all params).\n evalTrigger: (trigger: string) => `${p}.eval.${trigger}`, // init | urlchange | event\n evalNoConfig: `${p}.eval.no_config`,\n evalMissingPrereq: `${p}.eval.missing_prereq`, // Q4: sessionId/config/deviceId missing\n evalMatch: `${p}.eval.match`,\n evalNoMatch: `${p}.eval.no_match`,\n evalError: `${p}.eval.error`, // Q3: targeting engine threw\n evalStaleDiscarded: `${p}.eval.stale_discarded`,\n evalSkippedAlreadyMatched: `${p}.eval.skipped_already_matched`,\n evalDurationMs: `${p}.eval.duration_ms`, // histogram\n evalEvent: `${p}.eval`, // event (with ALL eval params — Q5)\n evalResult: `${p}.eval.result`, // event: raw engine verdict (variantKey) — why match/no-match\n\n // ── Recording execution (getShouldRecord said yes — did rrweb actually start?) ──\n recordStarted: `${p}.record.started`, // event: capture began (carries the srId the replay uploads under)\n recordNoRecordFn: `${p}.record.no_record_fn`, // counter + event: rrweb import returned nothing\n sendSuppressedMinDuration: `${p}.send.suppressed_min_duration`, // counter: events held back by min_session_duration\n\n // ── Record / no-record gate (getShouldRecord) ────────────────────────────\n gateNoIdentifiers: `${p}.gate.no_identifiers`, // Q4: no config/sessionId at gate time\n gateCaptureDisabled: `${p}.gate.capture_disabled`,\n gateOptOut: `${p}.gate.optout`,\n gateTrcMatch: `${p}.gate.trc_match`,\n gateTrcNoMatch: `${p}.gate.trc_no_match`,\n gateSampleIn: `${p}.gate.sample_in`,\n gateSampleOut: `${p}.gate.sample_out`,\n decision: `${p}.decision`, // event (with props)\n\n // ── SPA URL change (setupUrlChangeListener) ──────────────────────────────\n urlChange: `${p}.url_change`,\n urlChangeEvent: `${p}.url_change`, // event (with props); same name, logs vs metric\n // Was the URL-change listener even wired up? (covers \"the SDK never saw any navigation\"\n // because the listener was never attached — e.g. no targeting config, or no global scope.)\n urlListenerSetup: `${p}.url_listener.setup`, // event: the needsUrlTracking decision + its inputs\n urlListenerAttached: `${p}.url_listener.attached`, // event: subscribeToUrlChanges succeeded (with polling opts)\n urlListenerSkipped: `${p}.url_listener.skipped`, // counter + event: listener NOT attached (with reason)\n // Proof the polling loop actually FIRES (not just that it was scheduled by url_listener.attached).\n urlPollTick: `${p}.url_poll.tick`, // counter: incremented every poll tick (aggregated metric, cheap)\n urlPollFirstTick: `${p}.url_poll.first_tick`, // event: once per session on the first tick (carries href)\n} as const;\n"]}
|
package/lib/esm/diagnostics.d.ts
DELETED
|
@@ -1,50 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Centralized names for Session Replay diagnostics shipped via the analytics DiagnosticsClient.
|
|
3
|
-
*
|
|
4
|
-
* Every name shares SR_DIAGNOSTIC_PREFIX so they group together in DataDog as
|
|
5
|
-
* `sdk.diagnostics.sr.trc.*`. The diagnostics pipeline prepends `sdk.diagnostics.` and appends
|
|
6
|
-
* `.count` to counters / `.{min,max,avg,count}` to histograms; events are forwarded to DataDog
|
|
7
|
-
* Logs keyed by `event_name`. Keep ALL SR diagnostic names here so the prefix stays unified —
|
|
8
|
-
* changing the namespace is then a one-line edit.
|
|
9
|
-
*/
|
|
10
|
-
export declare const SR_DIAGNOSTIC_PREFIX = "sr.trc";
|
|
11
|
-
export declare const SrDiagnostic: {
|
|
12
|
-
readonly init: "sr.trc.init";
|
|
13
|
-
readonly sessionChanged: "sr.trc.session.changed";
|
|
14
|
-
readonly configSource: (source: string) => string;
|
|
15
|
-
readonly configHasTargeting: "sr.trc.config.has_targeting";
|
|
16
|
-
readonly configNoTargeting: "sr.trc.config.no_targeting";
|
|
17
|
-
readonly configFetchFailed: "sr.trc.config.fetch_failed";
|
|
18
|
-
readonly configReceived: "sr.trc.config.received";
|
|
19
|
-
readonly targetingTrigger: "sr.trc.targeting.trigger";
|
|
20
|
-
readonly evalTrigger: (trigger: string) => string;
|
|
21
|
-
readonly evalNoConfig: "sr.trc.eval.no_config";
|
|
22
|
-
readonly evalMissingPrereq: "sr.trc.eval.missing_prereq";
|
|
23
|
-
readonly evalMatch: "sr.trc.eval.match";
|
|
24
|
-
readonly evalNoMatch: "sr.trc.eval.no_match";
|
|
25
|
-
readonly evalError: "sr.trc.eval.error";
|
|
26
|
-
readonly evalStaleDiscarded: "sr.trc.eval.stale_discarded";
|
|
27
|
-
readonly evalSkippedAlreadyMatched: "sr.trc.eval.skipped_already_matched";
|
|
28
|
-
readonly evalDurationMs: "sr.trc.eval.duration_ms";
|
|
29
|
-
readonly evalEvent: "sr.trc.eval";
|
|
30
|
-
readonly evalResult: "sr.trc.eval.result";
|
|
31
|
-
readonly recordStarted: "sr.trc.record.started";
|
|
32
|
-
readonly recordNoRecordFn: "sr.trc.record.no_record_fn";
|
|
33
|
-
readonly sendSuppressedMinDuration: "sr.trc.send.suppressed_min_duration";
|
|
34
|
-
readonly gateNoIdentifiers: "sr.trc.gate.no_identifiers";
|
|
35
|
-
readonly gateCaptureDisabled: "sr.trc.gate.capture_disabled";
|
|
36
|
-
readonly gateOptOut: "sr.trc.gate.optout";
|
|
37
|
-
readonly gateTrcMatch: "sr.trc.gate.trc_match";
|
|
38
|
-
readonly gateTrcNoMatch: "sr.trc.gate.trc_no_match";
|
|
39
|
-
readonly gateSampleIn: "sr.trc.gate.sample_in";
|
|
40
|
-
readonly gateSampleOut: "sr.trc.gate.sample_out";
|
|
41
|
-
readonly decision: "sr.trc.decision";
|
|
42
|
-
readonly urlChange: "sr.trc.url_change";
|
|
43
|
-
readonly urlChangeEvent: "sr.trc.url_change";
|
|
44
|
-
readonly urlListenerSetup: "sr.trc.url_listener.setup";
|
|
45
|
-
readonly urlListenerAttached: "sr.trc.url_listener.attached";
|
|
46
|
-
readonly urlListenerSkipped: "sr.trc.url_listener.skipped";
|
|
47
|
-
readonly urlPollTick: "sr.trc.url_poll.tick";
|
|
48
|
-
readonly urlPollFirstTick: "sr.trc.url_poll.first_tick";
|
|
49
|
-
};
|
|
50
|
-
//# sourceMappingURL=diagnostics.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"diagnostics.d.ts","sourceRoot":"","sources":["../../src/diagnostics.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AACH,eAAO,MAAM,oBAAoB,WAAW,CAAC;AAI7C,eAAO,MAAM,YAAY;;;oCAUA,MAAM;;;;;;oCAUN,MAAM;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAsCrB,CAAC"}
|
package/lib/esm/diagnostics.js
DELETED
|
@@ -1,64 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Centralized names for Session Replay diagnostics shipped via the analytics DiagnosticsClient.
|
|
3
|
-
*
|
|
4
|
-
* Every name shares SR_DIAGNOSTIC_PREFIX so they group together in DataDog as
|
|
5
|
-
* `sdk.diagnostics.sr.trc.*`. The diagnostics pipeline prepends `sdk.diagnostics.` and appends
|
|
6
|
-
* `.count` to counters / `.{min,max,avg,count}` to histograms; events are forwarded to DataDog
|
|
7
|
-
* Logs keyed by `event_name`. Keep ALL SR diagnostic names here so the prefix stays unified —
|
|
8
|
-
* changing the namespace is then a one-line edit.
|
|
9
|
-
*/
|
|
10
|
-
export var SR_DIAGNOSTIC_PREFIX = 'sr.trc';
|
|
11
|
-
var p = SR_DIAGNOSTIC_PREFIX;
|
|
12
|
-
export var SrDiagnostic = {
|
|
13
|
-
// ── Init (Q1: did init even happen?) ─────────────────────────────────────
|
|
14
|
-
init: "".concat(p, ".init"),
|
|
15
|
-
// ── Session lifecycle ────────────────────────────────────────────────────
|
|
16
|
-
// SR session id changed (timeout / explicit setSessionId / custom session id). New tabs and
|
|
17
|
-
// page refreshes do NOT change the session id, so this is distinct from a fresh init.
|
|
18
|
-
sessionChanged: "".concat(p, ".session.changed"),
|
|
19
|
-
// ── Remote config fetch (joined-config) ──────────────────────────────────
|
|
20
|
-
configSource: function (source) { return "".concat(p, ".config.source.").concat(source); },
|
|
21
|
-
configHasTargeting: "".concat(p, ".config.has_targeting"),
|
|
22
|
-
configNoTargeting: "".concat(p, ".config.no_targeting"),
|
|
23
|
-
configFetchFailed: "".concat(p, ".config.fetch_failed"),
|
|
24
|
-
configReceived: "".concat(p, ".config.received"),
|
|
25
|
-
targetingTrigger: "".concat(p, ".targeting.trigger"),
|
|
26
|
-
// ── Targeting evaluation (evaluateTargetingAndCapture) ────────────────────
|
|
27
|
-
// Q2 (did eval run?), Q3 (working/failed?), Q4 (missing value?), Q5 (all params).
|
|
28
|
-
evalTrigger: function (trigger) { return "".concat(p, ".eval.").concat(trigger); },
|
|
29
|
-
evalNoConfig: "".concat(p, ".eval.no_config"),
|
|
30
|
-
evalMissingPrereq: "".concat(p, ".eval.missing_prereq"),
|
|
31
|
-
evalMatch: "".concat(p, ".eval.match"),
|
|
32
|
-
evalNoMatch: "".concat(p, ".eval.no_match"),
|
|
33
|
-
evalError: "".concat(p, ".eval.error"),
|
|
34
|
-
evalStaleDiscarded: "".concat(p, ".eval.stale_discarded"),
|
|
35
|
-
evalSkippedAlreadyMatched: "".concat(p, ".eval.skipped_already_matched"),
|
|
36
|
-
evalDurationMs: "".concat(p, ".eval.duration_ms"),
|
|
37
|
-
evalEvent: "".concat(p, ".eval"),
|
|
38
|
-
evalResult: "".concat(p, ".eval.result"),
|
|
39
|
-
// ── Recording execution (getShouldRecord said yes — did rrweb actually start?) ──
|
|
40
|
-
recordStarted: "".concat(p, ".record.started"),
|
|
41
|
-
recordNoRecordFn: "".concat(p, ".record.no_record_fn"),
|
|
42
|
-
sendSuppressedMinDuration: "".concat(p, ".send.suppressed_min_duration"),
|
|
43
|
-
// ── Record / no-record gate (getShouldRecord) ────────────────────────────
|
|
44
|
-
gateNoIdentifiers: "".concat(p, ".gate.no_identifiers"),
|
|
45
|
-
gateCaptureDisabled: "".concat(p, ".gate.capture_disabled"),
|
|
46
|
-
gateOptOut: "".concat(p, ".gate.optout"),
|
|
47
|
-
gateTrcMatch: "".concat(p, ".gate.trc_match"),
|
|
48
|
-
gateTrcNoMatch: "".concat(p, ".gate.trc_no_match"),
|
|
49
|
-
gateSampleIn: "".concat(p, ".gate.sample_in"),
|
|
50
|
-
gateSampleOut: "".concat(p, ".gate.sample_out"),
|
|
51
|
-
decision: "".concat(p, ".decision"),
|
|
52
|
-
// ── SPA URL change (setupUrlChangeListener) ──────────────────────────────
|
|
53
|
-
urlChange: "".concat(p, ".url_change"),
|
|
54
|
-
urlChangeEvent: "".concat(p, ".url_change"),
|
|
55
|
-
// Was the URL-change listener even wired up? (covers "the SDK never saw any navigation"
|
|
56
|
-
// because the listener was never attached — e.g. no targeting config, or no global scope.)
|
|
57
|
-
urlListenerSetup: "".concat(p, ".url_listener.setup"),
|
|
58
|
-
urlListenerAttached: "".concat(p, ".url_listener.attached"),
|
|
59
|
-
urlListenerSkipped: "".concat(p, ".url_listener.skipped"),
|
|
60
|
-
// Proof the polling loop actually FIRES (not just that it was scheduled by url_listener.attached).
|
|
61
|
-
urlPollTick: "".concat(p, ".url_poll.tick"),
|
|
62
|
-
urlPollFirstTick: "".concat(p, ".url_poll.first_tick"), // event: once per session on the first tick (carries href)
|
|
63
|
-
};
|
|
64
|
-
//# sourceMappingURL=diagnostics.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"diagnostics.js","sourceRoot":"","sources":["../../src/diagnostics.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AACH,MAAM,CAAC,IAAM,oBAAoB,GAAG,QAAQ,CAAC;AAE7C,IAAM,CAAC,GAAG,oBAAoB,CAAC;AAE/B,MAAM,CAAC,IAAM,YAAY,GAAG;IAC1B,4EAA4E;IAC5E,IAAI,EAAE,UAAG,CAAC,UAAO;IAEjB,4EAA4E;IAC5E,4FAA4F;IAC5F,sFAAsF;IACtF,cAAc,EAAE,UAAG,CAAC,qBAAkB;IAEtC,4EAA4E;IAC5E,YAAY,EAAE,UAAC,MAAc,IAAK,OAAA,UAAG,CAAC,4BAAkB,MAAM,CAAE,EAA9B,CAA8B;IAChE,kBAAkB,EAAE,UAAG,CAAC,0BAAuB;IAC/C,iBAAiB,EAAE,UAAG,CAAC,yBAAsB;IAC7C,iBAAiB,EAAE,UAAG,CAAC,yBAAsB;IAC7C,cAAc,EAAE,UAAG,CAAC,qBAAkB;IAEtC,gBAAgB,EAAE,UAAG,CAAC,uBAAoB;IAE1C,6EAA6E;IAC7E,kFAAkF;IAClF,WAAW,EAAE,UAAC,OAAe,IAAK,OAAA,UAAG,CAAC,mBAAS,OAAO,CAAE,EAAtB,CAAsB;IACxD,YAAY,EAAE,UAAG,CAAC,oBAAiB;IACnC,iBAAiB,EAAE,UAAG,CAAC,yBAAsB;IAC7C,SAAS,EAAE,UAAG,CAAC,gBAAa;IAC5B,WAAW,EAAE,UAAG,CAAC,mBAAgB;IACjC,SAAS,EAAE,UAAG,CAAC,gBAAa;IAC5B,kBAAkB,EAAE,UAAG,CAAC,0BAAuB;IAC/C,yBAAyB,EAAE,UAAG,CAAC,kCAA+B;IAC9D,cAAc,EAAE,UAAG,CAAC,sBAAmB;IACvC,SAAS,EAAE,UAAG,CAAC,UAAO;IACtB,UAAU,EAAE,UAAG,CAAC,iBAAc;IAE9B,mFAAmF;IACnF,aAAa,EAAE,UAAG,CAAC,oBAAiB;IACpC,gBAAgB,EAAE,UAAG,CAAC,yBAAsB;IAC5C,yBAAyB,EAAE,UAAG,CAAC,kCAA+B;IAE9D,4EAA4E;IAC5E,iBAAiB,EAAE,UAAG,CAAC,yBAAsB;IAC7C,mBAAmB,EAAE,UAAG,CAAC,2BAAwB;IACjD,UAAU,EAAE,UAAG,CAAC,iBAAc;IAC9B,YAAY,EAAE,UAAG,CAAC,oBAAiB;IACnC,cAAc,EAAE,UAAG,CAAC,uBAAoB;IACxC,YAAY,EAAE,UAAG,CAAC,oBAAiB;IACnC,aAAa,EAAE,UAAG,CAAC,qBAAkB;IACrC,QAAQ,EAAE,UAAG,CAAC,cAAW;IAEzB,4EAA4E;IAC5E,SAAS,EAAE,UAAG,CAAC,gBAAa;IAC5B,cAAc,EAAE,UAAG,CAAC,gBAAa;IACjC,wFAAwF;IACxF,2FAA2F;IAC3F,gBAAgB,EAAE,UAAG,CAAC,wBAAqB;IAC3C,mBAAmB,EAAE,UAAG,CAAC,2BAAwB;IACjD,kBAAkB,EAAE,UAAG,CAAC,0BAAuB;IAC/C,mGAAmG;IACnG,WAAW,EAAE,UAAG,CAAC,mBAAgB;IACjC,gBAAgB,EAAE,UAAG,CAAC,yBAAsB,EAAE,2DAA2D;CACjG,CAAC","sourcesContent":["/**\n * Centralized names for Session Replay diagnostics shipped via the analytics DiagnosticsClient.\n *\n * Every name shares SR_DIAGNOSTIC_PREFIX so they group together in DataDog as\n * `sdk.diagnostics.sr.trc.*`. The diagnostics pipeline prepends `sdk.diagnostics.` and appends\n * `.count` to counters / `.{min,max,avg,count}` to histograms; events are forwarded to DataDog\n * Logs keyed by `event_name`. Keep ALL SR diagnostic names here so the prefix stays unified —\n * changing the namespace is then a one-line edit.\n */\nexport const SR_DIAGNOSTIC_PREFIX = 'sr.trc';\n\nconst p = SR_DIAGNOSTIC_PREFIX;\n\nexport const SrDiagnostic = {\n // ── Init (Q1: did init even happen?) ─────────────────────────────────────\n init: `${p}.init`, // counter + event(with props): fires once per init()\n\n // ── Session lifecycle ────────────────────────────────────────────────────\n // SR session id changed (timeout / explicit setSessionId / custom session id). New tabs and\n // page refreshes do NOT change the session id, so this is distinct from a fresh init.\n sessionChanged: `${p}.session.changed`, // event (with from/to)\n\n // ── Remote config fetch (joined-config) ──────────────────────────────────\n configSource: (source: string) => `${p}.config.source.${source}`,\n configHasTargeting: `${p}.config.has_targeting`,\n configNoTargeting: `${p}.config.no_targeting`,\n configFetchFailed: `${p}.config.fetch_failed`,\n configReceived: `${p}.config.received`, // event (with props)\n\n targetingTrigger: `${p}.targeting.trigger`, // event: targeting evaluation triggered\n\n // ── Targeting evaluation (evaluateTargetingAndCapture) ────────────────────\n // Q2 (did eval run?), Q3 (working/failed?), Q4 (missing value?), Q5 (all params).\n evalTrigger: (trigger: string) => `${p}.eval.${trigger}`, // init | urlchange | event\n evalNoConfig: `${p}.eval.no_config`,\n evalMissingPrereq: `${p}.eval.missing_prereq`, // Q4: sessionId/config/deviceId missing\n evalMatch: `${p}.eval.match`,\n evalNoMatch: `${p}.eval.no_match`,\n evalError: `${p}.eval.error`, // Q3: targeting engine threw\n evalStaleDiscarded: `${p}.eval.stale_discarded`,\n evalSkippedAlreadyMatched: `${p}.eval.skipped_already_matched`,\n evalDurationMs: `${p}.eval.duration_ms`, // histogram\n evalEvent: `${p}.eval`, // event (with ALL eval params — Q5)\n evalResult: `${p}.eval.result`, // event: raw engine verdict (variantKey) — why match/no-match\n\n // ── Recording execution (getShouldRecord said yes — did rrweb actually start?) ──\n recordStarted: `${p}.record.started`, // event: capture began (carries the srId the replay uploads under)\n recordNoRecordFn: `${p}.record.no_record_fn`, // counter + event: rrweb import returned nothing\n sendSuppressedMinDuration: `${p}.send.suppressed_min_duration`, // counter: events held back by min_session_duration\n\n // ── Record / no-record gate (getShouldRecord) ────────────────────────────\n gateNoIdentifiers: `${p}.gate.no_identifiers`, // Q4: no config/sessionId at gate time\n gateCaptureDisabled: `${p}.gate.capture_disabled`,\n gateOptOut: `${p}.gate.optout`,\n gateTrcMatch: `${p}.gate.trc_match`,\n gateTrcNoMatch: `${p}.gate.trc_no_match`,\n gateSampleIn: `${p}.gate.sample_in`,\n gateSampleOut: `${p}.gate.sample_out`,\n decision: `${p}.decision`, // event (with props)\n\n // ── SPA URL change (setupUrlChangeListener) ──────────────────────────────\n urlChange: `${p}.url_change`,\n urlChangeEvent: `${p}.url_change`, // event (with props); same name, logs vs metric\n // Was the URL-change listener even wired up? (covers \"the SDK never saw any navigation\"\n // because the listener was never attached — e.g. no targeting config, or no global scope.)\n urlListenerSetup: `${p}.url_listener.setup`, // event: the needsUrlTracking decision + its inputs\n urlListenerAttached: `${p}.url_listener.attached`, // event: subscribeToUrlChanges succeeded (with polling opts)\n urlListenerSkipped: `${p}.url_listener.skipped`, // counter + event: listener NOT attached (with reason)\n // Proof the polling loop actually FIRES (not just that it was scheduled by url_listener.attached).\n urlPollTick: `${p}.url_poll.tick`, // counter: incremented every poll tick (aggregated metric, cheap)\n urlPollFirstTick: `${p}.url_poll.first_tick`, // event: once per session on the first tick (carries href)\n} as const;\n"]}
|