@amplitude/session-replay-browser 1.50.4 → 1.51.1

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.
Files changed (103) hide show
  1. package/README.md +15 -0
  2. package/lib/cjs/config/joined-config.d.ts.map +1 -1
  3. package/lib/cjs/config/joined-config.js +6 -25
  4. package/lib/cjs/config/joined-config.js.map +1 -1
  5. package/lib/cjs/config/types.d.ts +2 -25
  6. package/lib/cjs/config/types.d.ts.map +1 -1
  7. package/lib/cjs/config/types.js +0 -2
  8. package/lib/cjs/config/types.js.map +1 -1
  9. package/lib/cjs/events/base-events-store.d.ts +8 -5
  10. package/lib/cjs/events/base-events-store.d.ts.map +1 -1
  11. package/lib/cjs/events/base-events-store.js +51 -55
  12. package/lib/cjs/events/base-events-store.js.map +1 -1
  13. package/lib/cjs/events/event-compressor.d.ts.map +1 -1
  14. package/lib/cjs/events/event-compressor.js +4 -2
  15. package/lib/cjs/events/event-compressor.js.map +1 -1
  16. package/lib/cjs/events/events-idb-store.d.ts.map +1 -1
  17. package/lib/cjs/events/events-idb-store.js +23 -8
  18. package/lib/cjs/events/events-idb-store.js.map +1 -1
  19. package/lib/cjs/events/events-manager.d.ts.map +1 -1
  20. package/lib/cjs/events/events-manager.js +18 -6
  21. package/lib/cjs/events/events-manager.js.map +1 -1
  22. package/lib/cjs/helpers.d.ts +1 -16
  23. package/lib/cjs/helpers.d.ts.map +1 -1
  24. package/lib/cjs/helpers.js +8 -166
  25. package/lib/cjs/helpers.js.map +1 -1
  26. package/lib/cjs/observers.d.ts.map +1 -1
  27. package/lib/cjs/observers.js +2 -22
  28. package/lib/cjs/observers.js.map +1 -1
  29. package/lib/cjs/session-replay.d.ts.map +1 -1
  30. package/lib/cjs/session-replay.js +6 -35
  31. package/lib/cjs/session-replay.js.map +1 -1
  32. package/lib/cjs/track-destination.d.ts.map +1 -1
  33. package/lib/cjs/track-destination.js +6 -5
  34. package/lib/cjs/track-destination.js.map +1 -1
  35. package/lib/cjs/utils/utf8-byte-length.d.ts +17 -0
  36. package/lib/cjs/utils/utf8-byte-length.d.ts.map +1 -0
  37. package/lib/cjs/utils/utf8-byte-length.js +104 -0
  38. package/lib/cjs/utils/utf8-byte-length.js.map +1 -0
  39. package/lib/cjs/version.d.ts +1 -1
  40. package/lib/cjs/version.js +1 -1
  41. package/lib/cjs/version.js.map +1 -1
  42. package/lib/cjs/worker/index.js +1 -1
  43. package/lib/esm/config/joined-config.d.ts.map +1 -1
  44. package/lib/esm/config/joined-config.js +6 -25
  45. package/lib/esm/config/joined-config.js.map +1 -1
  46. package/lib/esm/config/types.d.ts +2 -25
  47. package/lib/esm/config/types.d.ts.map +1 -1
  48. package/lib/esm/config/types.js +1 -1
  49. package/lib/esm/config/types.js.map +1 -1
  50. package/lib/esm/events/base-events-store.d.ts +8 -5
  51. package/lib/esm/events/base-events-store.d.ts.map +1 -1
  52. package/lib/esm/events/base-events-store.js +51 -55
  53. package/lib/esm/events/base-events-store.js.map +1 -1
  54. package/lib/esm/events/event-compressor.d.ts.map +1 -1
  55. package/lib/esm/events/event-compressor.js +4 -2
  56. package/lib/esm/events/event-compressor.js.map +1 -1
  57. package/lib/esm/events/events-idb-store.d.ts.map +1 -1
  58. package/lib/esm/events/events-idb-store.js +23 -8
  59. package/lib/esm/events/events-idb-store.js.map +1 -1
  60. package/lib/esm/events/events-manager.d.ts.map +1 -1
  61. package/lib/esm/events/events-manager.js +18 -6
  62. package/lib/esm/events/events-manager.js.map +1 -1
  63. package/lib/esm/helpers.d.ts +1 -16
  64. package/lib/esm/helpers.d.ts.map +1 -1
  65. package/lib/esm/helpers.js +7 -161
  66. package/lib/esm/helpers.js.map +1 -1
  67. package/lib/esm/observers.d.ts.map +1 -1
  68. package/lib/esm/observers.js +2 -22
  69. package/lib/esm/observers.js.map +1 -1
  70. package/lib/esm/session-replay.d.ts.map +1 -1
  71. package/lib/esm/session-replay.js +8 -37
  72. package/lib/esm/session-replay.js.map +1 -1
  73. package/lib/esm/track-destination.d.ts.map +1 -1
  74. package/lib/esm/track-destination.js +6 -5
  75. package/lib/esm/track-destination.js.map +1 -1
  76. package/lib/esm/utils/utf8-byte-length.d.ts +17 -0
  77. package/lib/esm/utils/utf8-byte-length.d.ts.map +1 -0
  78. package/lib/esm/utils/utf8-byte-length.js +97 -0
  79. package/lib/esm/utils/utf8-byte-length.js.map +1 -0
  80. package/lib/esm/version.d.ts +1 -1
  81. package/lib/esm/version.js +1 -1
  82. package/lib/esm/version.js.map +1 -1
  83. package/lib/esm/worker/index.js +1 -1
  84. package/lib/scripts/index-min.js +1 -1
  85. package/lib/scripts/index-min.js.gz +0 -0
  86. package/lib/scripts/index-min.js.map +1 -1
  87. package/lib/scripts/observers-min.js +1 -1
  88. package/lib/scripts/observers-min.js.gz +0 -0
  89. package/lib/scripts/observers-min.js.map +1 -1
  90. package/lib/scripts/session-replay-browser-min.js +1 -1
  91. package/lib/scripts/session-replay-browser-min.js.gz +0 -0
  92. package/lib/scripts/session-replay-browser-min.js.map +1 -1
  93. package/lib/scripts/worker-min.js +1 -1
  94. package/lib/scripts/worker-min.js.gz +0 -0
  95. package/package.json +3 -2
  96. package/lib/cjs/utils/get-input-type.d.ts +0 -9
  97. package/lib/cjs/utils/get-input-type.d.ts.map +0 -1
  98. package/lib/cjs/utils/get-input-type.js +0 -25
  99. package/lib/cjs/utils/get-input-type.js.map +0 -1
  100. package/lib/esm/utils/get-input-type.d.ts +0 -9
  101. package/lib/esm/utils/get-input-type.d.ts.map +0 -1
  102. package/lib/esm/utils/get-input-type.js +0 -20
  103. package/lib/esm/utils/get-input-type.js.map +0 -1
@@ -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{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};
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,h,y,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())h=v.value,d.set(h,p),p+=h.length}catch(e){y={error:e}}finally{try{v&&!v.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 l(e){for(var t=e.length,r=0;r<t&&!(e.charCodeAt(r)>127);r++);if(r===t)return t;for(var n=r;r<t;r++){var s=e.charCodeAt(r);if(s<=127)n++;else if(s<=2047)n+=2;else if(s>=55296&&s<=56319){var o=r+1<t?e.charCodeAt(r+1):NaN;o>=56320&&o<=57343?(n+=4,r++):n+=3}else n+=3}return n}var d=0,p=new Map,f=function(e,t){return fetch(e,t)},v=function(e,t){var r="".concat(++d);return new Promise(function(n,s){var o=t.signal,a=function(){p.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}),p.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 h(e,t,o){var d,p,f,v,h,y,b,g;return n(this,void 0,void 0,function(){var n,m,w,S,T,E,k,R,C,x,A,I,M,O,U;return s(this,function(s){switch(s.label){case 0:n=null!==(d=t.sendTimeoutMs)&&void 0!==d?d: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 w=s.sent(),[3,4];case 3:w=null,s.label=4;case 4:m=w,S="".concat(null!==(f=null===(p=t.version)||void 0===p?void 0:p.type)&&void 0!==f?f:"standalone","/").concat(null!==(h=null===(v=t.version)||void 0===v?void 0:v.version)&&void 0!==h?h:t.sdkVersion),T=new URLSearchParams({device_id:t.deviceId,session_id:"".concat(t.sessionId),type:t.eventType}),E="".concat((P=t.serverZone,_=t.trackServerUrl,_||("STAGING"===P?"https://api-sr.stag2.amplitude.com/sessions/v2/track":"EU"===P?"https://api-sr.eu.amplitude.com/sessions/v2/track":"https://api-sr.amplitude.com/sessions/v2/track")),"?").concat(T.toString()),k=r({"Content-Type":"application/json",Accept:"*/*",Authorization:"Bearer ".concat(t.apiKey),"X-Client-Version":t.sdkVersion,"X-Client-Library":S,"X-Client-Url":t.currentUrl.substring(0,1e3),"X-Client-Sample-Rate":"".concat(t.sampleRate),"X-Sampling-Hash-Alg":"xxhash32"},m?{"Content-Encoding":"gzip"}:{}),R=m?m.byteLength:l(e),C=new AbortController,x=n>0?setTimeout(function(){C.abort()},n):void 0,A=void 0,s.label=5;case 5:return s.trys.push([5,,7,8]),[4,o(E,{method:"POST",headers:k,body:null!=m?m:e,keepalive:R<=65536,signal:C.signal})];case 6:return A=s.sent(),[3,8];case 7:return x&&clearTimeout(x),[7];case 8:if(null===A)return[2,{shouldRetry:!1,success:!1,message:"Unexpected error occurred"}];if(A.status>=200&&A.status<300)return I=Math.round(function(e){for(var t=0,r=0;r<e.length;r++)t+=l(e[r]);return t}(t.events)/1024),M=null!==(g=null===(b=null===(y=A.headers)||void 0===y?void 0:y.get)||void 0===b?void 0:b.call(y,i))&&void 0!==g?g: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:M}];if(413!==A.status)return[3,13];O="",s.label=9;case 9:return s.trys.push([9,11,,12]),[4,A.text()];case 10:return O=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(O)}];case 13:return A.status>=500||408===A.status||429===A.status||499===A.status?[2,{shouldRetry:!0,success:!1,message:"HTTP ".concat(A.status)}]:[2,{shouldRetry:!1,success:!1,message:u}];case 14:return(U=s.sent())&&"object"==typeof U&&"AbortError"===U.name?[2,{shouldRetry:!0,success:!1,message:"Session replay worker request timed out after ".concat(n,"ms")}]:[2,{shouldRetry:!1,success:!1,message:String(U)}];case 15:return[2]}var 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,h(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=p.get(t.requestId))&&(p.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?v:f)]);case 1:s.sent(),s.label=2;case 2:return[2]}})})};var b=onmessage;return e.trackDestinationOnMessage=b,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.50.4",
3
+ "version": "1.51.1",
4
4
  "description": "",
5
5
  "author": "Amplitude Inc",
6
6
  "homepage": "https://github.com/amplitude/Amplitude-TypeScript",
@@ -25,8 +25,9 @@
25
25
  "@amplitude/rrweb-types": "2.0.0-alpha.40",
26
26
  "idb": "8.0.0",
27
27
  "tslib": "^2.4.1",
28
- "@amplitude/analytics-core": "2.58.1",
28
+ "@amplitude/analytics-core": "2.60.0",
29
29
  "@amplitude/analytics-types": "2.11.1",
30
+ "@amplitude/session-replay-dom-privacy": "0.2.0",
30
31
  "@amplitude/targeting": "0.3.10"
31
32
  },
32
33
  "devDependencies": {
@@ -1,9 +0,0 @@
1
- export declare function toLowerCase<T extends string>(str: T): Lowercase<T>;
2
- /**
3
- * Get the type of an input element.
4
- * This takes care of the case where a password input is changed to a text input.
5
- * In this case, we continue to consider this of type password, in order to avoid leaking sensitive data
6
- * where passwords should be masked.
7
- */
8
- export declare function getInputType(element: HTMLElement): Lowercase<string> | null;
9
- //# sourceMappingURL=get-input-type.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"get-input-type.d.ts","sourceRoot":"","sources":["../../../src/utils/get-input-type.ts"],"names":[],"mappings":"AAAA,wBAAgB,WAAW,CAAC,CAAC,SAAS,MAAM,EAAE,GAAG,EAAE,CAAC,GAAG,SAAS,CAAC,CAAC,CAAC,CAElE;AAED;;;;;GAKG;AACH,wBAAgB,YAAY,CAAC,OAAO,EAAE,WAAW,GAAG,SAAS,CAAC,MAAM,CAAC,GAAG,IAAI,CAU3E"}
@@ -1,25 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.getInputType = exports.toLowerCase = void 0;
4
- function toLowerCase(str) {
5
- return str.toLowerCase();
6
- }
7
- exports.toLowerCase = toLowerCase;
8
- /**
9
- * Get the type of an input element.
10
- * This takes care of the case where a password input is changed to a text input.
11
- * In this case, we continue to consider this of type password, in order to avoid leaking sensitive data
12
- * where passwords should be masked.
13
- */
14
- function getInputType(element) {
15
- // when omitting the type of input element(e.g. <input />), the type is treated as text
16
- var type = element.type;
17
- return element.hasAttribute('data-rr-is-password')
18
- ? 'password'
19
- : type
20
- ? // eslint-disable-next-line @typescript-eslint/no-unnecessary-type-assertion
21
- toLowerCase(type)
22
- : null;
23
- }
24
- exports.getInputType = getInputType;
25
- //# sourceMappingURL=get-input-type.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"get-input-type.js","sourceRoot":"","sources":["../../../src/utils/get-input-type.ts"],"names":[],"mappings":";;;AAAA,SAAgB,WAAW,CAAmB,GAAM;IAClD,OAAO,GAAG,CAAC,WAAW,EAA6B,CAAC;AACtD,CAAC;AAFD,kCAEC;AAED;;;;;GAKG;AACH,SAAgB,YAAY,CAAC,OAAoB;IAC/C,uFAAuF;IACvF,IAAM,IAAI,GAAI,OAA4B,CAAC,IAAI,CAAC;IAEhD,OAAO,OAAO,CAAC,YAAY,CAAC,qBAAqB,CAAC;QAChD,CAAC,CAAC,UAAU;QACZ,CAAC,CAAC,IAAI;YACN,CAAC,CAAC,4EAA4E;gBAC5E,WAAW,CAAC,IAAI,CAAC;YACnB,CAAC,CAAC,IAAI,CAAC;AACX,CAAC;AAVD,oCAUC","sourcesContent":["export function toLowerCase<T extends string>(str: T): Lowercase<T> {\n return str.toLowerCase() as unknown as Lowercase<T>;\n}\n\n/**\n * Get the type of an input element.\n * This takes care of the case where a password input is changed to a text input.\n * In this case, we continue to consider this of type password, in order to avoid leaking sensitive data\n * where passwords should be masked.\n */\nexport function getInputType(element: HTMLElement): Lowercase<string> | null {\n // when omitting the type of input element(e.g. <input />), the type is treated as text\n const type = (element as HTMLInputElement).type;\n\n return element.hasAttribute('data-rr-is-password')\n ? 'password'\n : type\n ? // eslint-disable-next-line @typescript-eslint/no-unnecessary-type-assertion\n toLowerCase(type)\n : null;\n}\n"]}
@@ -1,9 +0,0 @@
1
- export declare function toLowerCase<T extends string>(str: T): Lowercase<T>;
2
- /**
3
- * Get the type of an input element.
4
- * This takes care of the case where a password input is changed to a text input.
5
- * In this case, we continue to consider this of type password, in order to avoid leaking sensitive data
6
- * where passwords should be masked.
7
- */
8
- export declare function getInputType(element: HTMLElement): Lowercase<string> | null;
9
- //# sourceMappingURL=get-input-type.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"get-input-type.d.ts","sourceRoot":"","sources":["../../../src/utils/get-input-type.ts"],"names":[],"mappings":"AAAA,wBAAgB,WAAW,CAAC,CAAC,SAAS,MAAM,EAAE,GAAG,EAAE,CAAC,GAAG,SAAS,CAAC,CAAC,CAAC,CAElE;AAED;;;;;GAKG;AACH,wBAAgB,YAAY,CAAC,OAAO,EAAE,WAAW,GAAG,SAAS,CAAC,MAAM,CAAC,GAAG,IAAI,CAU3E"}
@@ -1,20 +0,0 @@
1
- export function toLowerCase(str) {
2
- return str.toLowerCase();
3
- }
4
- /**
5
- * Get the type of an input element.
6
- * This takes care of the case where a password input is changed to a text input.
7
- * In this case, we continue to consider this of type password, in order to avoid leaking sensitive data
8
- * where passwords should be masked.
9
- */
10
- export function getInputType(element) {
11
- // when omitting the type of input element(e.g. <input />), the type is treated as text
12
- var type = element.type;
13
- return element.hasAttribute('data-rr-is-password')
14
- ? 'password'
15
- : type
16
- ? // eslint-disable-next-line @typescript-eslint/no-unnecessary-type-assertion
17
- toLowerCase(type)
18
- : null;
19
- }
20
- //# sourceMappingURL=get-input-type.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"get-input-type.js","sourceRoot":"","sources":["../../../src/utils/get-input-type.ts"],"names":[],"mappings":"AAAA,MAAM,UAAU,WAAW,CAAmB,GAAM;IAClD,OAAO,GAAG,CAAC,WAAW,EAA6B,CAAC;AACtD,CAAC;AAED;;;;;GAKG;AACH,MAAM,UAAU,YAAY,CAAC,OAAoB;IAC/C,uFAAuF;IACvF,IAAM,IAAI,GAAI,OAA4B,CAAC,IAAI,CAAC;IAEhD,OAAO,OAAO,CAAC,YAAY,CAAC,qBAAqB,CAAC;QAChD,CAAC,CAAC,UAAU;QACZ,CAAC,CAAC,IAAI;YACN,CAAC,CAAC,4EAA4E;gBAC5E,WAAW,CAAC,IAAI,CAAC;YACnB,CAAC,CAAC,IAAI,CAAC;AACX,CAAC","sourcesContent":["export function toLowerCase<T extends string>(str: T): Lowercase<T> {\n return str.toLowerCase() as unknown as Lowercase<T>;\n}\n\n/**\n * Get the type of an input element.\n * This takes care of the case where a password input is changed to a text input.\n * In this case, we continue to consider this of type password, in order to avoid leaking sensitive data\n * where passwords should be masked.\n */\nexport function getInputType(element: HTMLElement): Lowercase<string> | null {\n // when omitting the type of input element(e.g. <input />), the type is treated as text\n const type = (element as HTMLInputElement).type;\n\n return element.hasAttribute('data-rr-is-password')\n ? 'password'\n : type\n ? // eslint-disable-next-line @typescript-eslint/no-unnecessary-type-assertion\n toLowerCase(type)\n : null;\n}\n"]}