@amplitude/segment-session-replay-plugin 0.0.20 → 0.0.22

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.
@@ -1,2 +1,2 @@
1
- var 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,n=function(){return n=Object.assign||function(e){for(var t,n=1,r=arguments.length;n<r;n++)for(var s in t=arguments[n])Object.prototype.hasOwnProperty.call(t,s)&&(e[s]=t[s]);return e},n.apply(this,arguments)};function r(e,t,n,r){return new(n||(n=Promise))(function(s,o){function a(e){try{c(r.next(e))}catch(e){o(e)}}function i(e){try{c(r.throw(e))}catch(e){o(e)}}function c(e){var t;e.done?s(e.value):(t=e.value,t instanceof n?t:new n(function(e){e(t)})).then(a,i)}c((r=r.apply(e,t||[])).next())})}function s(e,t){var n,r,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(c){return function(i){if(n)throw new TypeError("Generator is already executing.");for(;a&&(a=0,i[0]&&(o=0)),o;)try{if(n=1,r&&(s=2&i[0]?r.return:i[0]?r.throw||((s=r.return)&&s.call(r),0):r.next)&&!(s=s.call(r,i[1])).done)return s;switch(r=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++,r=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],r=0}finally{n=s=0}if(5&i[0])throw i[1];return{value:i[0]?i[1]:void 0,done:!0}}([i,c])}}}"function"==typeof SuppressedError&&SuppressedError,function(e){e.US="US",e.EU="EU",e.STAGING="STAGING"}(t||(t={})),t.US;var o;!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"}(o||(o={}));function a(e,t){return r(this,void 0,void 0,function(){var n,o,a,i,c,u,l,d,p,f,h,v,y,b,g=this;return s(this,function(m){switch(m.label){case 0:return m.trys.push([0,4,,5]),n=t.CompressionStream,o=new n("gzip"),a=o.writable.getWriter(),i=o.readable.getReader(),c=[],u=r(g,void 0,void 0,function(){var e,t,n;return s(this,function(r){switch(r.label){case 0:return[4,i.read()];case 1:if(e=r.sent(),t=e.done,n=e.value,t)return[3,3];c.push(n),r.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,u];case 3:m.sent(),l=c.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,n=t&&e[t],r=0;if(n)return n.call(e);if(e&&"number"==typeof e.length)return{next:function(){return e&&r>=e.length&&(e=void 0),{value:e&&e[r++],done:!e}}};throw new TypeError(t?"Object is not iterable.":"Symbol.iterator is not defined.")}(c),h=f.next();!h.done;h=f.next())v=h.value,d.set(v,p),p+=v.length}catch(e){y={error:e}}finally{try{h&&!h.done&&(b=f.return)&&b.call(f)}finally{if(y)throw y.error}}return[2,d];case 4:return m.sent(),[2,null];case 5:return[2]}})})}function i(e,t){var o,i,c,u;return r(this,void 0,void 0,function(){var r,l,d,p,f,h,v,y,b,g;return s(this,function(s){switch(s.label){case 0:return s.trys.push([0,5,,6]),"CompressionStream"in self?[4,a(e,self)]:[3,2];case 1:return l=s.sent(),[3,3];case 2:l=null,s.label=3;case 3:return r=l,d="".concat(null!==(i=null===(o=t.version)||void 0===o?void 0:o.type)&&void 0!==i?i:"standalone","/").concat(null!==(u=null===(c=t.version)||void 0===c?void 0:c.version)&&void 0!==u?u:t.sdkVersion),p=new URLSearchParams({device_id:t.deviceId,session_id:"".concat(t.sessionId),type:t.eventType}),f="".concat((m=t.serverZone,w=t.trackServerUrl,w||("STAGING"===m?"https://api-sr.stag2.amplitude.com/sessions/v2/track":"EU"===m?"https://api-sr.eu.amplitude.com/sessions/v2/track":"https://api-sr.amplitude.com/sessions/v2/track")),"?").concat(p.toString()),h=n({"Content-Type":"application/json",Accept:"*/*",Authorization:"Bearer ".concat(t.apiKey),"X-Client-Version":t.sdkVersion,"X-Client-Library":d,"X-Client-Url":t.currentUrl.substring(0,1e3),"X-Client-Sample-Rate":"".concat(t.sampleRate),"X-Sampling-Hash-Alg":"xxhash32"},r?{"Content-Encoding":"gzip"}:{}),v=r?r.byteLength:new Blob([e]).size,[4,fetch(f,{method:"POST",headers:h,body:null!=r?r:e,keepalive:v<=65536})];case 4:return null===(y=s.sent())?[2,{shouldRetry:!1,success:!1,message:"Unexpected error occurred"}]:y.status>=200&&y.status<300?(b=Math.round(new Blob(t.events).size/1024),[2,{shouldRetry:!1,success:!0,message:"Session replay event batch tracked successfully for session id ".concat(t.sessionId,", size of events: ").concat(b," KB")}]):y.status>=500||408===y.status||429===y.status||499===y.status?[2,{shouldRetry:!0,success:!1,message:"HTTP ".concat(y.status)}]:[2,{shouldRetry:!1,success:!1,message:"Network error occurred, event batch rejected"}];case 5:return g=s.sent(),[2,{shouldRetry:!1,success:!1,message:String(g)}];case 6:return[2]}var m,w})})}function c(e,t,n,o){return r(this,void 0,void 0,function(){var r,a,c;return s(this,function(s){switch(s.label){case 0:r=1,s.label=1;case 1:return[4,i(t,n)];case 2:return(a=s.sent()).success?(postMessage({type:"log",id:e,message:a.message}),postMessage({type:"complete",id:e}),[2]):o&&a.shouldRetry&&r<n.flushMaxRetries?[4,new Promise(function(e){return setTimeout(e,Math.random()*r*1e3)})]:[3,4];case 3:return s.sent(),r++,[3,5];case 4:return c=r>=n.flushMaxRetries?"Session replay event batch rejected due to exceeded retry count":a.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 r(void 0,void 0,void 0,function(){var t,n,r,o,a,i,u;return s(this,function(s){switch(s.label){case 0:return t=e.data,n=t.type,r=t.id,o=t.payload,a=t.context,i=t.useRetry,"send"!==n?[3,2]:(u=JSON.stringify(o),[4,c(r,u,a,i)]);case 1:s.sent(),s.label=2;case 2:return[2]}})})};var u=onmessage;return e.trackDestinationOnMessage=u,Object.defineProperty(e,"__esModule",{value:!0}),e}({});\n';export{e as compressionScript,t as trackDestinationScript};
1
+ var 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,a){function o(e){try{c(n.next(e))}catch(e){a(e)}}function i(e){try{c(n.throw(e))}catch(e){a(e)}}function c(e){var t;e.done?s(e.value):(t=e.value,t instanceof r?t:new r(function(e){e(t)})).then(o,i)}c((n=n.apply(e,t||[])).next())})}function s(e,t){var r,n,s,a={label:0,sent:function(){if(1&s[0])throw s[1];return s[1]},trys:[],ops:[]},o=Object.create(("function"==typeof Iterator?Iterator:Object).prototype);return o.next=i(0),o.throw=i(1),o.return=i(2),"function"==typeof Symbol&&(o[Symbol.iterator]=function(){return this}),o;function i(i){return function(c){return function(i){if(r)throw new TypeError("Generator is already executing.");for(;o&&(o=0,i[0]&&(a=0)),a;)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 a.label++,{value:i[1],done:!1};case 5:a.label++,n=i[1],i=[0];continue;case 7:i=a.ops.pop(),a.trys.pop();continue;default:if(!(s=a.trys,(s=s.length>0&&s[s.length-1])||6!==i[0]&&2!==i[0])){a=0;continue}if(3===i[0]&&(!s||i[1]>s[0]&&i[1]<s[3])){a.label=i[1];break}if(6===i[0]&&a.label<s[1]){a.label=s[1],s=i;break}if(s&&a.label<s[2]){a.label=s[2],a.ops.push(i);break}s[2]&&a.ops.pop(),a.trys.pop();continue}i=t.call(e,a)}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,c])}}}"function"==typeof SuppressedError&&SuppressedError,function(e){e.US="US",e.EU="EU",e.STAGING="STAGING"}(t||(t={})),t.US;var a,o=/payload.*exceed/i;!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"}(a||(a={}));var i="Network error occurred, event batch rejected";function c(e,t){return n(this,void 0,void 0,function(){var r,a,o,i,c,u,l,d,p,f,h,v,y,g,b=this;return s(this,function(m){switch(m.label){case 0:return m.trys.push([0,4,,5]),r=t.CompressionStream,a=new r("gzip"),o=a.writable.getWriter(),i=a.readable.getReader(),c=[],u=n(b,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];c.push(r),n.label=2;case 2:return[3,0];case 3:return[2]}})}),[4,o.write((new TextEncoder).encode(e))];case 1:return m.sent(),[4,o.close()];case 2:return m.sent(),[4,u];case 3:m.sent(),l=c.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.")}(c),h=f.next();!h.done;h=f.next())v=h.value,d.set(v,p),p+=v.length}catch(e){y={error:e}}finally{try{h&&!h.done&&(g=f.return)&&g.call(f)}finally{if(y)throw y.error}}return[2,d];case 4:return m.sent(),[2,null];case 5:return[2]}})})}function u(e,t){var a,u,l,d,p,f,h;return n(this,void 0,void 0,function(){var n,v,y,g,b,m,S,w,T,k,R,x;return s(this,function(s){switch(s.label){case 0:return s.trys.push([0,10,,11]),"CompressionStream"in self?[4,c(e,self)]:[3,2];case 1:return v=s.sent(),[3,3];case 2:v=null,s.label=3;case 3:return n=v,y="".concat(null!==(u=null===(a=t.version)||void 0===a?void 0:a.type)&&void 0!==u?u:"standalone","/").concat(null!==(d=null===(l=t.version)||void 0===l?void 0:l.version)&&void 0!==d?d:t.sdkVersion),g=new URLSearchParams({device_id:t.deviceId,session_id:"".concat(t.sessionId),type:t.eventType}),b="".concat((E=t.serverZone,U=t.trackServerUrl,U||("STAGING"===E?"https://api-sr.stag2.amplitude.com/sessions/v2/track":"EU"===E?"https://api-sr.eu.amplitude.com/sessions/v2/track":"https://api-sr.amplitude.com/sessions/v2/track")),"?").concat(g.toString()),m=r({"Content-Type":"application/json",Accept:"*/*",Authorization:"Bearer ".concat(t.apiKey),"X-Client-Version":t.sdkVersion,"X-Client-Library":y,"X-Client-Url":t.currentUrl.substring(0,1e3),"X-Client-Sample-Rate":"".concat(t.sampleRate),"X-Sampling-Hash-Alg":"xxhash32"},n?{"Content-Encoding":"gzip"}:{}),S=n?n.byteLength:new Blob([e]).size,[4,fetch(b,{method:"POST",headers:m,body:null!=n?n:e,keepalive:S<=65536})];case 4:if(null===(w=s.sent()))return[2,{shouldRetry:!1,success:!1,message:"Unexpected error occurred"}];if(w.status>=200&&w.status<300)return T=Math.round(new Blob(t.events).size/1024),k=null!==(h=null===(f=null===(p=w.headers)||void 0===p?void 0:p.get)||void 0===f?void 0:f.call(p,"X-Session-Replay-Event-Skipped"))&&void 0!==h?h:null,[2,{shouldRetry:!1,success:!0,message:"Session replay event batch tracked successfully for session id ".concat(t.sessionId,", size of events: ").concat(T," KB"),skipCode:k}];if(413!==w.status)return[3,9];R="",s.label=5;case 5:return s.trys.push([5,7,,8]),[4,w.text()];case 6:return R=s.sent(),[3,8];case 7:return s.sent(),[3,8];case 8:return[2,{shouldRetry:!1,success:!1,message:i,payloadTooLarge:!0,isWaf:o.test(R)}];case 9:return w.status>=500||408===w.status||429===w.status||499===w.status?[2,{shouldRetry:!0,success:!1,message:"HTTP ".concat(w.status)}]:[2,{shouldRetry:!1,success:!1,message:i}];case 10:return x=s.sent(),[2,{shouldRetry:!1,success:!1,message:String(x)}];case 11:return[2]}var E,U})})}function l(e,t,r,a){var o;return n(this,void 0,void 0,function(){var n,i,c;return s(this,function(s){switch(s.label){case 0:n=1,s.label=1;case 1:return[4,u(t,r)];case 2:return(i=s.sent()).success?(postMessage({type:"log",id:e,message:i.message}),postMessage({type:"complete",id:e,skipCode:null!==(o=i.skipCode)&&void 0!==o?o:null}),[2]):i.payloadTooLarge&&a?(postMessage({type:"payload_too_large",id:e,isWaf:!0===i.isWaf}),[2]):a&&i.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":i.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,a,o,i,c;return s(this,function(s){switch(s.label){case 0:return t=e.data,r=t.type,n=t.id,a=t.payload,o=t.context,i=t.useRetry,"send"!==r?[3,2]:(c=JSON.stringify(a),[4,l(n,c,o,i)]);case 1:s.sent(),s.label=2;case 2:return[2]}})})};var d=onmessage;return e.trackDestinationOnMessage=d,Object.defineProperty(e,"__esModule",{value:!0}),e}({});\n';export{e as compressionScript,t as trackDestinationScript};
2
2
  //# sourceMappingURL=index-min2.js.map
Binary file
@@ -1 +1 @@
1
- {"version":3,"file":"index-min2.js","sources":["../../../session-replay-browser/lib/esm/worker/index.js"],"sourcesContent":["var compressionScript = \"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\";\nvar trackDestinationScript = \"var WebWorker=function(e){\\\"use strict\\\";var t,n=function(){return n=Object.assign||function(e){for(var t,n=1,r=arguments.length;n<r;n++)for(var s in t=arguments[n])Object.prototype.hasOwnProperty.call(t,s)&&(e[s]=t[s]);return e},n.apply(this,arguments)};function r(e,t,n,r){return new(n||(n=Promise))(function(s,o){function a(e){try{c(r.next(e))}catch(e){o(e)}}function i(e){try{c(r.throw(e))}catch(e){o(e)}}function c(e){var t;e.done?s(e.value):(t=e.value,t instanceof n?t:new n(function(e){e(t)})).then(a,i)}c((r=r.apply(e,t||[])).next())})}function s(e,t){var n,r,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(c){return function(i){if(n)throw new TypeError(\\\"Generator is already executing.\\\");for(;a&&(a=0,i[0]&&(o=0)),o;)try{if(n=1,r&&(s=2&i[0]?r.return:i[0]?r.throw||((s=r.return)&&s.call(r),0):r.next)&&!(s=s.call(r,i[1])).done)return s;switch(r=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++,r=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],r=0}finally{n=s=0}if(5&i[0])throw i[1];return{value:i[0]?i[1]:void 0,done:!0}}([i,c])}}}\\\"function\\\"==typeof SuppressedError&&SuppressedError,function(e){e.US=\\\"US\\\",e.EU=\\\"EU\\\",e.STAGING=\\\"STAGING\\\"}(t||(t={})),t.US;var o;!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\\\"}(o||(o={}));function a(e,t){return r(this,void 0,void 0,function(){var n,o,a,i,c,u,l,d,p,f,h,v,y,b,g=this;return s(this,function(m){switch(m.label){case 0:return m.trys.push([0,4,,5]),n=t.CompressionStream,o=new n(\\\"gzip\\\"),a=o.writable.getWriter(),i=o.readable.getReader(),c=[],u=r(g,void 0,void 0,function(){var e,t,n;return s(this,function(r){switch(r.label){case 0:return[4,i.read()];case 1:if(e=r.sent(),t=e.done,n=e.value,t)return[3,3];c.push(n),r.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,u];case 3:m.sent(),l=c.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,n=t&&e[t],r=0;if(n)return n.call(e);if(e&&\\\"number\\\"==typeof e.length)return{next:function(){return e&&r>=e.length&&(e=void 0),{value:e&&e[r++],done:!e}}};throw new TypeError(t?\\\"Object is not iterable.\\\":\\\"Symbol.iterator is not defined.\\\")}(c),h=f.next();!h.done;h=f.next())v=h.value,d.set(v,p),p+=v.length}catch(e){y={error:e}}finally{try{h&&!h.done&&(b=f.return)&&b.call(f)}finally{if(y)throw y.error}}return[2,d];case 4:return m.sent(),[2,null];case 5:return[2]}})})}function i(e,t){var o,i,c,u;return r(this,void 0,void 0,function(){var r,l,d,p,f,h,v,y,b,g;return s(this,function(s){switch(s.label){case 0:return s.trys.push([0,5,,6]),\\\"CompressionStream\\\"in self?[4,a(e,self)]:[3,2];case 1:return l=s.sent(),[3,3];case 2:l=null,s.label=3;case 3:return r=l,d=\\\"\\\".concat(null!==(i=null===(o=t.version)||void 0===o?void 0:o.type)&&void 0!==i?i:\\\"standalone\\\",\\\"/\\\").concat(null!==(u=null===(c=t.version)||void 0===c?void 0:c.version)&&void 0!==u?u:t.sdkVersion),p=new URLSearchParams({device_id:t.deviceId,session_id:\\\"\\\".concat(t.sessionId),type:t.eventType}),f=\\\"\\\".concat((m=t.serverZone,w=t.trackServerUrl,w||(\\\"STAGING\\\"===m?\\\"https://api-sr.stag2.amplitude.com/sessions/v2/track\\\":\\\"EU\\\"===m?\\\"https://api-sr.eu.amplitude.com/sessions/v2/track\\\":\\\"https://api-sr.amplitude.com/sessions/v2/track\\\")),\\\"?\\\").concat(p.toString()),h=n({\\\"Content-Type\\\":\\\"application/json\\\",Accept:\\\"*/*\\\",Authorization:\\\"Bearer \\\".concat(t.apiKey),\\\"X-Client-Version\\\":t.sdkVersion,\\\"X-Client-Library\\\":d,\\\"X-Client-Url\\\":t.currentUrl.substring(0,1e3),\\\"X-Client-Sample-Rate\\\":\\\"\\\".concat(t.sampleRate),\\\"X-Sampling-Hash-Alg\\\":\\\"xxhash32\\\"},r?{\\\"Content-Encoding\\\":\\\"gzip\\\"}:{}),v=r?r.byteLength:new Blob([e]).size,[4,fetch(f,{method:\\\"POST\\\",headers:h,body:null!=r?r:e,keepalive:v<=65536})];case 4:return null===(y=s.sent())?[2,{shouldRetry:!1,success:!1,message:\\\"Unexpected error occurred\\\"}]:y.status>=200&&y.status<300?(b=Math.round(new Blob(t.events).size/1024),[2,{shouldRetry:!1,success:!0,message:\\\"Session replay event batch tracked successfully for session id \\\".concat(t.sessionId,\\\", size of events: \\\").concat(b,\\\" KB\\\")}]):y.status>=500||408===y.status||429===y.status||499===y.status?[2,{shouldRetry:!0,success:!1,message:\\\"HTTP \\\".concat(y.status)}]:[2,{shouldRetry:!1,success:!1,message:\\\"Network error occurred, event batch rejected\\\"}];case 5:return g=s.sent(),[2,{shouldRetry:!1,success:!1,message:String(g)}];case 6:return[2]}var m,w})})}function c(e,t,n,o){return r(this,void 0,void 0,function(){var r,a,c;return s(this,function(s){switch(s.label){case 0:r=1,s.label=1;case 1:return[4,i(t,n)];case 2:return(a=s.sent()).success?(postMessage({type:\\\"log\\\",id:e,message:a.message}),postMessage({type:\\\"complete\\\",id:e}),[2]):o&&a.shouldRetry&&r<n.flushMaxRetries?[4,new Promise(function(e){return setTimeout(e,Math.random()*r*1e3)})]:[3,4];case 3:return s.sent(),r++,[3,5];case 4:return c=r>=n.flushMaxRetries?\\\"Session replay event batch rejected due to exceeded retry count\\\":a.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 r(void 0,void 0,void 0,function(){var t,n,r,o,a,i,u;return s(this,function(s){switch(s.label){case 0:return t=e.data,n=t.type,r=t.id,o=t.payload,a=t.context,i=t.useRetry,\\\"send\\\"!==n?[3,2]:(u=JSON.stringify(o),[4,c(r,u,a,i)]);case 1:s.sent(),s.label=2;case 2:return[2]}})})};var u=onmessage;return e.trackDestinationOnMessage=u,Object.defineProperty(e,\\\"__esModule\\\",{value:!0}),e}({});\\n\";\n\nexport { compressionScript, trackDestinationScript };\n"],"names":["compressionScript","trackDestinationScript"],"mappings":"AAAG,IAACA,EAAoB,4bACpBC,EAAyB"}
1
+ {"version":3,"file":"index-min2.js","sources":["../../../session-replay-browser/lib/esm/worker/index.js"],"sourcesContent":["var compressionScript = \"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\";\nvar trackDestinationScript = \"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,a){function o(e){try{c(n.next(e))}catch(e){a(e)}}function i(e){try{c(n.throw(e))}catch(e){a(e)}}function c(e){var t;e.done?s(e.value):(t=e.value,t instanceof r?t:new r(function(e){e(t)})).then(o,i)}c((n=n.apply(e,t||[])).next())})}function s(e,t){var r,n,s,a={label:0,sent:function(){if(1&s[0])throw s[1];return s[1]},trys:[],ops:[]},o=Object.create((\\\"function\\\"==typeof Iterator?Iterator:Object).prototype);return o.next=i(0),o.throw=i(1),o.return=i(2),\\\"function\\\"==typeof Symbol&&(o[Symbol.iterator]=function(){return this}),o;function i(i){return function(c){return function(i){if(r)throw new TypeError(\\\"Generator is already executing.\\\");for(;o&&(o=0,i[0]&&(a=0)),a;)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 a.label++,{value:i[1],done:!1};case 5:a.label++,n=i[1],i=[0];continue;case 7:i=a.ops.pop(),a.trys.pop();continue;default:if(!(s=a.trys,(s=s.length>0&&s[s.length-1])||6!==i[0]&&2!==i[0])){a=0;continue}if(3===i[0]&&(!s||i[1]>s[0]&&i[1]<s[3])){a.label=i[1];break}if(6===i[0]&&a.label<s[1]){a.label=s[1],s=i;break}if(s&&a.label<s[2]){a.label=s[2],a.ops.push(i);break}s[2]&&a.ops.pop(),a.trys.pop();continue}i=t.call(e,a)}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,c])}}}\\\"function\\\"==typeof SuppressedError&&SuppressedError,function(e){e.US=\\\"US\\\",e.EU=\\\"EU\\\",e.STAGING=\\\"STAGING\\\"}(t||(t={})),t.US;var a,o=/payload.*exceed/i;!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\\\"}(a||(a={}));var i=\\\"Network error occurred, event batch rejected\\\";function c(e,t){return n(this,void 0,void 0,function(){var r,a,o,i,c,u,l,d,p,f,h,v,y,g,b=this;return s(this,function(m){switch(m.label){case 0:return m.trys.push([0,4,,5]),r=t.CompressionStream,a=new r(\\\"gzip\\\"),o=a.writable.getWriter(),i=a.readable.getReader(),c=[],u=n(b,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];c.push(r),n.label=2;case 2:return[3,0];case 3:return[2]}})}),[4,o.write((new TextEncoder).encode(e))];case 1:return m.sent(),[4,o.close()];case 2:return m.sent(),[4,u];case 3:m.sent(),l=c.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.\\\")}(c),h=f.next();!h.done;h=f.next())v=h.value,d.set(v,p),p+=v.length}catch(e){y={error:e}}finally{try{h&&!h.done&&(g=f.return)&&g.call(f)}finally{if(y)throw y.error}}return[2,d];case 4:return m.sent(),[2,null];case 5:return[2]}})})}function u(e,t){var a,u,l,d,p,f,h;return n(this,void 0,void 0,function(){var n,v,y,g,b,m,S,w,T,k,R,x;return s(this,function(s){switch(s.label){case 0:return s.trys.push([0,10,,11]),\\\"CompressionStream\\\"in self?[4,c(e,self)]:[3,2];case 1:return v=s.sent(),[3,3];case 2:v=null,s.label=3;case 3:return n=v,y=\\\"\\\".concat(null!==(u=null===(a=t.version)||void 0===a?void 0:a.type)&&void 0!==u?u:\\\"standalone\\\",\\\"/\\\").concat(null!==(d=null===(l=t.version)||void 0===l?void 0:l.version)&&void 0!==d?d:t.sdkVersion),g=new URLSearchParams({device_id:t.deviceId,session_id:\\\"\\\".concat(t.sessionId),type:t.eventType}),b=\\\"\\\".concat((E=t.serverZone,U=t.trackServerUrl,U||(\\\"STAGING\\\"===E?\\\"https://api-sr.stag2.amplitude.com/sessions/v2/track\\\":\\\"EU\\\"===E?\\\"https://api-sr.eu.amplitude.com/sessions/v2/track\\\":\\\"https://api-sr.amplitude.com/sessions/v2/track\\\")),\\\"?\\\").concat(g.toString()),m=r({\\\"Content-Type\\\":\\\"application/json\\\",Accept:\\\"*/*\\\",Authorization:\\\"Bearer \\\".concat(t.apiKey),\\\"X-Client-Version\\\":t.sdkVersion,\\\"X-Client-Library\\\":y,\\\"X-Client-Url\\\":t.currentUrl.substring(0,1e3),\\\"X-Client-Sample-Rate\\\":\\\"\\\".concat(t.sampleRate),\\\"X-Sampling-Hash-Alg\\\":\\\"xxhash32\\\"},n?{\\\"Content-Encoding\\\":\\\"gzip\\\"}:{}),S=n?n.byteLength:new Blob([e]).size,[4,fetch(b,{method:\\\"POST\\\",headers:m,body:null!=n?n:e,keepalive:S<=65536})];case 4:if(null===(w=s.sent()))return[2,{shouldRetry:!1,success:!1,message:\\\"Unexpected error occurred\\\"}];if(w.status>=200&&w.status<300)return T=Math.round(new Blob(t.events).size/1024),k=null!==(h=null===(f=null===(p=w.headers)||void 0===p?void 0:p.get)||void 0===f?void 0:f.call(p,\\\"X-Session-Replay-Event-Skipped\\\"))&&void 0!==h?h:null,[2,{shouldRetry:!1,success:!0,message:\\\"Session replay event batch tracked successfully for session id \\\".concat(t.sessionId,\\\", size of events: \\\").concat(T,\\\" KB\\\"),skipCode:k}];if(413!==w.status)return[3,9];R=\\\"\\\",s.label=5;case 5:return s.trys.push([5,7,,8]),[4,w.text()];case 6:return R=s.sent(),[3,8];case 7:return s.sent(),[3,8];case 8:return[2,{shouldRetry:!1,success:!1,message:i,payloadTooLarge:!0,isWaf:o.test(R)}];case 9:return w.status>=500||408===w.status||429===w.status||499===w.status?[2,{shouldRetry:!0,success:!1,message:\\\"HTTP \\\".concat(w.status)}]:[2,{shouldRetry:!1,success:!1,message:i}];case 10:return x=s.sent(),[2,{shouldRetry:!1,success:!1,message:String(x)}];case 11:return[2]}var E,U})})}function l(e,t,r,a){var o;return n(this,void 0,void 0,function(){var n,i,c;return s(this,function(s){switch(s.label){case 0:n=1,s.label=1;case 1:return[4,u(t,r)];case 2:return(i=s.sent()).success?(postMessage({type:\\\"log\\\",id:e,message:i.message}),postMessage({type:\\\"complete\\\",id:e,skipCode:null!==(o=i.skipCode)&&void 0!==o?o:null}),[2]):i.payloadTooLarge&&a?(postMessage({type:\\\"payload_too_large\\\",id:e,isWaf:!0===i.isWaf}),[2]):a&&i.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\\\":i.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,a,o,i,c;return s(this,function(s){switch(s.label){case 0:return t=e.data,r=t.type,n=t.id,a=t.payload,o=t.context,i=t.useRetry,\\\"send\\\"!==r?[3,2]:(c=JSON.stringify(a),[4,l(n,c,o,i)]);case 1:s.sent(),s.label=2;case 2:return[2]}})})};var d=onmessage;return e.trackDestinationOnMessage=d,Object.defineProperty(e,\\\"__esModule\\\",{value:!0}),e}({});\\n\";\n\nexport { compressionScript, trackDestinationScript };\n"],"names":["compressionScript","trackDestinationScript"],"mappings":"AAAG,IAACA,EAAoB,4bACpBC,EAAyB"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@amplitude/segment-session-replay-plugin",
3
- "version": "0.0.20",
3
+ "version": "0.0.22",
4
4
  "description": "Plugin for Segment's analytics.js library to support Amplitude's Session Replay.",
5
5
  "keywords": [
6
6
  "amplitude",
@@ -30,7 +30,7 @@
30
30
  "dependencies": {
31
31
  "@segment/analytics-next": "^1.81.0",
32
32
  "js-cookie": "^3.0.5",
33
- "@amplitude/session-replay-browser": "1.42.0"
33
+ "@amplitude/session-replay-browser": "1.42.2"
34
34
  },
35
35
  "devDependencies": {
36
36
  "@aws-sdk/client-s3": "^3.229.0",