@sentry/replay 8.0.0-alpha.1 → 8.0.0-alpha.2

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/esm/index.js CHANGED
@@ -1,6 +1,6 @@
1
1
  import { _nullishCoalesce, _optionalChain } from '@sentry/utils';
2
2
  import { addBreadcrumb, getClient, isSentryRequestUrl, addEventProcessor, prepareEvent, getIsolationScope, getCurrentScope, setContext, captureException, spanToJSON, SEMANTIC_ATTRIBUTE_SENTRY_SOURCE } from '@sentry/core';
3
- import { GLOBAL_OBJ, normalize, fill, htmlTreeAsString, browserPerformanceTimeOrigin, logger, uuid4, dropUndefinedKeys, stringMatchesSomePattern, SENTRY_XHR_DATA_KEY, addClickKeypressInstrumentationHandler, addHistoryInstrumentationHandler, createEnvelope, createEventEnvelopeHeaders, getSdkMetadataForEnvelopeHeader, updateRateLimits, isRateLimited, consoleSandbox, isBrowser } from '@sentry/utils';
3
+ import { GLOBAL_OBJ, normalize, fill, htmlTreeAsString, browserPerformanceTimeOrigin, logger, uuid4, dropUndefinedKeys, stringMatchesSomePattern, SENTRY_XHR_DATA_KEY, addClickKeypressInstrumentationHandler, addHistoryInstrumentationHandler, createEnvelope, createEventEnvelopeHeaders, getSdkMetadataForEnvelopeHeader, resolvedSyncPromise, updateRateLimits, isRateLimited, consoleSandbox, isBrowser } from '@sentry/utils';
4
4
  import { addPerformanceInstrumentationHandler, addLcpInstrumentationHandler } from '@sentry-internal/tracing';
5
5
 
6
6
  // exporting a separate copy of `WINDOW` rather than exporting the one from `@sentry/browser`
@@ -5708,10 +5708,6 @@ function isFeedbackEvent(event) {
5708
5708
  * Returns a listener to be added to `client.on('afterSendErrorEvent, listener)`.
5709
5709
  */
5710
5710
  function handleAfterSendEvent(replay) {
5711
- // Custom transports may still be returning `Promise<void>`, which means we cannot expect the status code to be available there
5712
- // TODO (v8): remove this check as it will no longer be necessary
5713
- const enforceStatusCode = isBaseTransportSend();
5714
-
5715
5711
  return (event, sendResponse) => {
5716
5712
  if (!replay.isEnabled() || (!isErrorEvent(event) && !isTransactionEvent(event))) {
5717
5713
  return;
@@ -5722,7 +5718,7 @@ function handleAfterSendEvent(replay) {
5722
5718
  // We only want to do stuff on successful error sending, otherwise you get error replays without errors attached
5723
5719
  // If not using the base transport, we allow `undefined` response (as a custom transport may not implement this correctly yet)
5724
5720
  // If we do use the base transport, we skip if we encountered an non-OK status code
5725
- if (enforceStatusCode && (!statusCode || statusCode < 200 || statusCode >= 300)) {
5721
+ if (!statusCode || statusCode < 200 || statusCode >= 300) {
5726
5722
  return;
5727
5723
  }
5728
5724
 
@@ -5778,22 +5774,6 @@ function handleErrorEvent(replay, event) {
5778
5774
  });
5779
5775
  }
5780
5776
 
5781
- function isBaseTransportSend() {
5782
- const client = getClient();
5783
- if (!client) {
5784
- return false;
5785
- }
5786
-
5787
- const transport = client.getTransport();
5788
- if (!transport) {
5789
- return false;
5790
- }
5791
-
5792
- return (
5793
- (transport.send ).__sentry__baseTransport__ || false
5794
- );
5795
- }
5796
-
5797
5777
  /**
5798
5778
  * Returns a listener to be added to `client.on('afterSendErrorEvent, listener)`.
5799
5779
  */
@@ -7460,7 +7440,7 @@ async function sendReplayRequest({
7460
7440
  const dsn = client && client.getDsn();
7461
7441
 
7462
7442
  if (!client || !transport || !dsn || !session.sampled) {
7463
- return;
7443
+ return resolvedSyncPromise({});
7464
7444
  }
7465
7445
 
7466
7446
  const baseEvent = {
@@ -7481,7 +7461,7 @@ async function sendReplayRequest({
7481
7461
  // Taken from baseclient's `_processEvent` method, where this is handled for errors/transactions
7482
7462
  client.recordDroppedEvent('event_processor', 'replay', baseEvent);
7483
7463
  logInfo('An event processor returned `null`, will not send event.');
7484
- return;
7464
+ return resolvedSyncPromise({});
7485
7465
  }
7486
7466
 
7487
7467
  /*
@@ -7543,11 +7523,6 @@ async function sendReplayRequest({
7543
7523
  throw error;
7544
7524
  }
7545
7525
 
7546
- // TODO (v8): we can remove this guard once transport.send's type signature doesn't include void anymore
7547
- if (!response) {
7548
- return response;
7549
- }
7550
-
7551
7526
  // If the status code is invalid, we want to immediately stop & not retry
7552
7527
  if (typeof response.statusCode === 'number' && (response.statusCode < 200 || response.statusCode >= 300)) {
7553
7528
  throw new TransportStatusCodeError(response.statusCode);