@sentry/replay 0.6.0 → 0.6.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.
Files changed (70) hide show
  1. package/README.md +60 -27
  2. package/dist/{jest.config.d.ts → config/types/jest.config.d.ts} +0 -0
  3. package/dist/{jest.setup.d.ts → config/types/jest.setup.d.ts} +0 -0
  4. package/dist/{src → config/types/src}/api/captureReplayEvent.d.ts +0 -0
  5. package/dist/{src/coreHandlers/handleFetch.test.d.ts → config/types/src/blockAllMedia.test.d.ts} +0 -0
  6. package/dist/{src → config/types/src}/coreHandlers/getBreadcrumbHandler.d.ts +0 -0
  7. package/dist/{src → config/types/src}/coreHandlers/getSpanHandler.d.ts +0 -0
  8. package/dist/{src → config/types/src}/coreHandlers/handleDom.d.ts +0 -0
  9. package/dist/{src → config/types/src}/coreHandlers/handleFetch.d.ts +0 -0
  10. package/dist/{src/coreHandlers/handleScope-unit.test.d.ts → config/types/src/coreHandlers/handleFetch.test.d.ts} +0 -0
  11. package/dist/{src → config/types/src}/coreHandlers/handleHistory.d.ts +0 -0
  12. package/dist/{src/coreHandlers/handleScope.test.d.ts → config/types/src/coreHandlers/handleScope-unit.test.d.ts} +0 -0
  13. package/dist/{src → config/types/src}/coreHandlers/handleScope.d.ts +0 -0
  14. package/dist/{src/createPerformanceEntry.test.d.ts → config/types/src/coreHandlers/handleScope.test.d.ts} +0 -0
  15. package/dist/{src → config/types/src}/coreHandlers/handleXhr.d.ts +0 -0
  16. package/dist/{src → config/types/src}/createPerformanceEntry.d.ts +0 -0
  17. package/dist/{src/flush.test.d.ts → config/types/src/createPerformanceEntry.test.d.ts} +0 -0
  18. package/dist/{src → config/types/src}/eventBuffer.d.ts +0 -0
  19. package/dist/{src → config/types/src}/eventBuffer.test.d.ts +0 -0
  20. package/dist/{src → config/types/src}/flags.d.ts +0 -0
  21. package/dist/{src/index-captureOnlyOnError.test.d.ts → config/types/src/flush.test.d.ts} +0 -0
  22. package/dist/{src/index-noSticky.test.d.ts → config/types/src/index-captureOnlyOnError.test.d.ts} +0 -0
  23. package/dist/{src/index-sampling.test.d.ts → config/types/src/index-noSticky.test.d.ts} +0 -0
  24. package/dist/{src/index.test.d.ts → config/types/src/index-sampling.test.d.ts} +0 -0
  25. package/dist/{src → config/types/src}/index.d.ts +3 -3
  26. package/dist/{src/session/Session.test.d.ts → config/types/src/index.test.d.ts} +0 -0
  27. package/dist/{src → config/types/src}/session/Session.d.ts +0 -0
  28. package/dist/{src/session/createSession.test.d.ts → config/types/src/session/Session.test.d.ts} +0 -0
  29. package/dist/{src → config/types/src}/session/constants.d.ts +0 -0
  30. package/dist/{src → config/types/src}/session/createSession.d.ts +0 -0
  31. package/dist/{src/session/deleteSession.test.d.ts → config/types/src/session/createSession.test.d.ts} +0 -0
  32. package/dist/{src → config/types/src}/session/deleteSession.d.ts +0 -0
  33. package/dist/{src/session/fetchSession.test.d.ts → config/types/src/session/deleteSession.test.d.ts} +0 -0
  34. package/dist/{src → config/types/src}/session/fetchSession.d.ts +0 -0
  35. package/dist/{src/session/getSession.test.d.ts → config/types/src/session/fetchSession.test.d.ts} +0 -0
  36. package/dist/{src → config/types/src}/session/getSession.d.ts +0 -0
  37. package/dist/{src/session/saveSession.test.d.ts → config/types/src/session/getSession.test.d.ts} +0 -0
  38. package/dist/{src → config/types/src}/session/index.d.ts +0 -0
  39. package/dist/{src → config/types/src}/session/saveSession.d.ts +0 -0
  40. package/dist/{src/stop.test.d.ts → config/types/src/session/saveSession.test.d.ts} +0 -0
  41. package/dist/{src/util/dedupePerformanceEntries.test.d.ts → config/types/src/stop.test.d.ts} +0 -0
  42. package/dist/{src → config/types/src}/types.d.ts +6 -7
  43. package/dist/{src → config/types/src}/util/addInternalBreadcrumb.d.ts +0 -0
  44. package/dist/config/types/src/util/captureInternalException.d.ts +4 -0
  45. package/dist/{src → config/types/src}/util/createBreadcrumb.d.ts +0 -0
  46. package/dist/{src → config/types/src}/util/createPayload.d.ts +0 -0
  47. package/dist/{src → config/types/src}/util/dedupePerformanceEntries.d.ts +0 -0
  48. package/dist/{src/util/isExpired.test.d.ts → config/types/src/util/dedupePerformanceEntries.test.d.ts} +0 -0
  49. package/dist/{src → config/types/src}/util/isExpired.d.ts +0 -0
  50. package/dist/{src/util/isSampled.test.d.ts → config/types/src/util/isExpired.test.d.ts} +0 -0
  51. package/dist/{src → config/types/src}/util/isIngestHost.d.ts +0 -0
  52. package/dist/{src → config/types/src}/util/isInternal.d.ts +0 -0
  53. package/dist/{src → config/types/src}/util/isSampled.d.ts +0 -0
  54. package/dist/{src/util/isSessionExpired.test.d.ts → config/types/src/util/isSampled.test.d.ts} +0 -0
  55. package/dist/{src → config/types/src}/util/isSessionExpired.d.ts +0 -0
  56. package/dist/config/types/src/util/isSessionExpired.test.d.ts +1 -0
  57. package/dist/{src → config/types/src}/util/logger.d.ts +0 -0
  58. package/dist/{test → config/types/test}/fixtures/performanceEntry/lcp.d.ts +0 -0
  59. package/dist/{test → config/types/test}/fixtures/performanceEntry/navigation.d.ts +0 -0
  60. package/dist/{test → config/types/test}/fixtures/performanceEntry/resource.d.ts +0 -0
  61. package/dist/{test → config/types/test}/index.d.ts +0 -0
  62. package/dist/{test → config/types/test}/mocks/mockRrweb.d.ts +0 -0
  63. package/dist/{test → config/types/test}/mocks/mockSdk.d.ts +0 -0
  64. package/dist/index.es.js +32 -10
  65. package/dist/index.js +31 -9
  66. package/dist/index.js.map +1 -1
  67. package/dist/types/src/index.d.ts +3 -3
  68. package/dist/types/src/types.d.ts +6 -7
  69. package/dist/types/src/util/captureInternalException.d.ts +4 -0
  70. package/package.json +5 -5
package/README.md CHANGED
@@ -1,15 +1,13 @@
1
1
  # sentry-replay
2
2
 
3
- This integration is a WIP.
3
+ Note: Session Replay is currently in alpha.
4
4
 
5
- ## Pre-Requisites
5
+ ## Pre-requisites
6
6
 
7
- For the sentry-replay integration to work, you must have the [Sentry browser SDK package](https://www.npmjs.com/package/@sentry/browser) installed.
7
+ For the sentry-replay integration to work, you must have the [Sentry browser SDK package](https://www.npmjs.com/package/@sentry/browser) (or an equivalent framework SDK e.g. [@sentry/react](https://www.npmjs.com/package/@sentry/react)) installed.
8
8
 
9
9
  ## Installation
10
10
 
11
- To install the stable version:
12
-
13
11
  with npm:
14
12
 
15
13
  ```shell
@@ -24,8 +22,8 @@ yarn add @sentry/browser @sentry/replay
24
22
 
25
23
  ## Setup
26
24
 
27
- To set up the integration add the following to your Sentry initialization. Several options are supported and passable via the integration constructor.
28
- See the rrweb documentation for advice on configuring these values.
25
+ To set up the integration, add the following to your Sentry initialization. Several options are supported and passable via the integration constructor.
26
+ See the [configuration section](#configuration) below for more details.
29
27
 
30
28
  ```javascript
31
29
  import * as Sentry from '@sentry/browser';
@@ -35,17 +33,16 @@ Sentry.init({
35
33
  dsn: '__DSN__',
36
34
  integrations: [
37
35
  new Replay({
38
- maskAllText: true, // Will mask all text strings
39
- recordingConfig: {
40
- maskAllInputs: false, // Default is true
41
- },
42
- }),
36
+ // This sets the sample rate to be 10%. You may want this to be 100% while
37
+ // in development and sample at a lower rate in production
38
+ replaysSamplingRate: 0.1,
39
+ })
43
40
  ],
44
41
  // ...
45
42
  });
46
43
  ```
47
44
 
48
- ### Stop Recording
45
+ ### Start and Stop Recording
49
46
 
50
47
  Replay recording only starts automatically when it is included in the `integrations` key when calling `Sentry.init`. Otherwise you can initialize the plugin and manually call the `start()` method on the integration instance. To stop recording you can call the `stop()`.
51
48
 
@@ -59,17 +56,53 @@ replay.stop(); // Stop recording
59
56
 
60
57
  ## Configuration
61
58
 
62
- | key | type | default | description |
63
- | ------------------------------- | --------- | ----------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
64
- | `flushMinDelay` | `number` | `5000` | The minimum time to wait (in ms) before sending the recording payload. The payload is sent if `flushMinDelay` ms have elapsed between two events. |
65
- | `flushMaxDelay` | `number` | `15000` | The maximum time to wait (in ms) when sending the recording payload. The payload is sent if events occur at an interval less than `flushMinDelay` and `flushMaxDelay` ms have elapsed since the last time a payload was sent. |
66
- | `initialFlushDelay` | `number` | `5000` | The amount of time to wait (in ms) before sending the initial recording payload. This helps drop recordings where users visit and close the page quickly. |
67
- | `maskAllText` | `boolean` | `false` | Mask _all_ text strings with `*`. |
68
- | `replaysSamplingRate` | `number` | `1.0` | The rate at which to sample replays. (1.0 will collect all replays, 0 will collect no replays). |
69
- | `stickySession` | `boolean` | `true` | Keep track of the user across page loads. Note a single user using multiple tabs will result in multiple sessions. Closing a tab will result in the session being closed as well. |
70
- | `useCompression` | `boolean` | `true` | Uses `WebWorkers` (if available) to compress the recording payload before uploading to Sentry. |
71
- | `captureOnlyOnError` | `boolean` | `false` | Only capture the recording when an error happens. |
72
- | `recordingConfig.maskAllInputs` | `boolean` | `true` | Mask all `<input>` elements |
73
- | `recordingConfig.blockClass` | `string` | `'sentry-block'` | Redact all elements with the class name `sentry-block` |
74
- | `recordingConfig.ignoreClass` | `string` | `'sentry-ignore'` | Ignores all elements with the class name `sentry-ignore` |
75
- | `recordingConfig.maskTextClass` | `string` | `'sentry-mask'` | Mask all elements with the class name `sentry-ignore` |
59
+ ### General Configuration
60
+
61
+ | key | type | default | description |
62
+ | ------------------- | ------- | ------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
63
+ | captureOnlyOnError | boolean | `false` | Only capture the recording when an error happens. The recording is currently limited to up to the last 60 seconds before the error occurs and only records up to the error. |
64
+ | initialFlushDelay | number | `5000` | The amount of time to wait (in ms) before sending the initial recording payload. This helps drop recordings where users visit and close the page quickly. |
65
+ | replaysSamplingRate | number | `1.0` | The rate at which to sample replays. (1.0 will collect all replays, 0 will collect no replays). |
66
+ | stickySession | boolean | `true` | Keep track of the user across page loads. Note a single user using multiple tabs will result in multiple sessions. Closing a tab will result in the session being closed as well. |
67
+
68
+ ### Privacy Configuration
69
+
70
+ | key | type | default | description |
71
+ | ---------------- | ------------------------ | ----------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
72
+ | maskAllText | boolean | `true` | Mask _all_ text content. Will pass text content through `maskTextFn` before sending to server. |
73
+ | blockAllMedia | boolean | `true` | Block _all_ media elements (`img, svg, video, object, picture, embed, map, audio`)
74
+ | maskTextFn | (text: string) => string | `(text) => '*'.repeat(text.length)` | Function to customize how text content is masked before sending to server. By default, masks text with `*`. |
75
+ | maskAllInputs | boolean | `true` | Mask values of `<input>` elements. Passes input values through `maskInputFn` before sending to server. |
76
+ | maskInputOptions | Record<string, boolean> | `{ password: true }` | Customize which inputs `type` to mask. <br /> Available `<input>` types: `color, date, datetime-local, email, month, number, range, search, tel, text, time, url, week, textarea, select, password`. |
77
+ | maskInputFn | (text: string) => string | `(text) => '*'.repeat(text.length)` | Function to customize how form input values are masked before sending to server. By default, masks values with `*`. |
78
+ | blockClass | string \| RegExp | `'sentry-block'` | Redact all elements that match the class name. See [privacy](#blocking) section for an example. |
79
+ | blockSelector | string | `'[data-sentry-block]'` | Redact all elements that match the DOM selector. See [privacy](#blocking) section for an example. |
80
+ | ignoreClass | string \| RegExp | `'sentry-ignore'` | Ignores all events on the matching input field. See [privacy](#ignoring) section for an example. |
81
+ | maskTextClass | string \| RegExp | `'sentry-mask'` | Mask all elements that match the class name. See [privacy](#masking) section for an example. |
82
+
83
+ ### Optimization Configuration
84
+
85
+ | key | type | default | description |
86
+ | ---------------- | ----------------------- | ------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
87
+ | collectFonts | boolean | `false` | Should collect fonts used on the website |
88
+ | inlineImages | boolean | `false` | Should inline `<image>` content |
89
+ | inlineStylesheet | boolean | `true` | Should inline stylesheets used in the recording |
90
+ | recordCanvas | boolean | `false` | Should record `<canvas>` elements |
91
+ | slimDOMOptions | Record<string, boolean> | `{}` | Remove unnecessary parts of the DOM <br /> Available keys: `script, comment, headFavicon, headWhitespace, headMetaDescKeywords, headMetaSocial, headMetaRobots, headMetaHttpEquiv, headMetaAuthorship, headMetaVerification` |
92
+
93
+ ## Privacy
94
+ There are several ways to deal with PII. By default, the integration will mask all text content with `*` and block all media elements (`img, svg, video, object, picture, embed, map, audio`). This can be disabled by setting `maskAllText` to `false`. It is also possible to add the following CSS classes to specific DOM elements to prevent recording its contents: `sentry-block`, `sentry-ignore`, and `sentry-mask`. The following sections will show examples of how content is handled by the differing methods.
95
+
96
+ ### Masking
97
+ Masking replaces the text content with something else. The default masking behavior is to replace each character with a `*`. In this example the relevant html code is: `<table class="sentry-mask">...</table>`.
98
+ ![Masking example](https://user-images.githubusercontent.com/79684/193118192-dee1d3d8-5813-47e8-b532-f9ee1c8714b3.png)
99
+
100
+ ### Blocking
101
+ Blocking replaces the element with a placeholder that has the same dimensions. The recording will show an empty space where the content was. In this example the relevant html code is: `<table data-sentry-block>...</table>`.
102
+ ![Blocking example](https://user-images.githubusercontent.com/79684/193118084-51a589fc-2160-476a-a8dc-b681eddb136c.png)
103
+
104
+ ### Ignoring
105
+ Ignoring only applies to form inputs. Events will be ignored on the input element so that the replay does not show what occurs inside of the input. In the below example, notice how the results in the table below the input changes, but no text is visible in the input.
106
+
107
+ https://user-images.githubusercontent.com/79684/192815134-a6451c3f-d3cb-455f-a699-7c3fe04d0a2e.mov
108
+
File without changes
File without changes
@@ -3,7 +3,7 @@ import { CaptureReplayEventParams } from './api/captureReplayEvent';
3
3
  import { Session } from './session/Session';
4
4
  import { ReplayPerformanceEntry } from './createPerformanceEntry';
5
5
  import { IEventBuffer } from './eventBuffer';
6
- import type { AllPerformanceEntry, InstrumentationTypeBreadcrumb, InstrumentationTypeSpan, RecordedEvents, RecordingConfig, RecordingEvent, ReplayConfiguration, ReplayPluginOptions, ReplayRequest } from './types';
6
+ import type { AllPerformanceEntry, InstrumentationTypeBreadcrumb, InstrumentationTypeSpan, RecordedEvents, RecordingEvent, RecordingOptions, ReplayConfiguration, ReplayPluginOptions, ReplayRequest } from './types';
7
7
  /**
8
8
  * Returns true to return control to calling function, otherwise continue with normal batching
9
9
  */
@@ -25,7 +25,7 @@ export declare class Replay implements Integration {
25
25
  /**
26
26
  * Options to pass to `rrweb.record()`
27
27
  */
28
- readonly recordingOptions: RecordingConfig;
28
+ readonly recordingOptions: RecordingOptions;
29
29
  readonly options: ReplayPluginOptions;
30
30
  private performanceObserver;
31
31
  private retryCount;
@@ -56,7 +56,7 @@ export declare class Replay implements Integration {
56
56
  private initialState;
57
57
  private context;
58
58
  session: Session | undefined;
59
- constructor({ flushMinDelay, flushMaxDelay, initialFlushDelay, stickySession, useCompression, captureOnlyOnError, replaysSamplingRate, maskAllText, recordingConfig: { maskAllInputs, blockClass, ignoreClass, maskTextClass, ...recordingOptions }, }?: ReplayConfiguration);
59
+ constructor({ flushMinDelay, flushMaxDelay, initialFlushDelay, stickySession, useCompression, captureOnlyOnError, replaysSamplingRate, maskAllText, maskAllInputs, blockAllMedia, blockClass, ignoreClass, maskTextClass, blockSelector, ...recordingOptions }?: ReplayConfiguration);
60
60
  /**
61
61
  * Because we create a transaction in `setupOnce`, we can potentially create a
62
62
  * transaction before some native SDK integrations have run and applied their
@@ -1,7 +1,6 @@
1
- import { record } from 'rrweb';
2
- import type { eventWithTime } from 'rrweb/typings/types';
1
+ import type { eventWithTime, recordOptions } from 'rrweb/typings/types';
3
2
  export declare type RecordingEvent = eventWithTime;
4
- export declare type RecordingConfig = Parameters<typeof record>[0];
3
+ export declare type RecordingOptions = recordOptions<eventWithTime>;
5
4
  export declare type RecordedEvents = Uint8Array | string;
6
5
  export declare type AllPerformanceEntry = PerformancePaintTiming | PerformanceResourceTiming | PerformanceNavigationTiming;
7
6
  export interface ReplayRequest {
@@ -68,12 +67,12 @@ export interface ReplayPluginOptions {
68
67
  * Mask all text in recordings. All text will be replaced with asterisks by default.
69
68
  */
70
69
  maskAllText?: boolean;
71
- }
72
- export interface ReplayConfiguration extends ReplayPluginOptions {
73
70
  /**
74
- * Options for `rrweb.record()`
71
+ * Block all media (e.g. images, svg, video) in recordings.
75
72
  */
76
- recordingConfig?: RecordingConfig;
73
+ blockAllMedia?: boolean;
74
+ }
75
+ export interface ReplayConfiguration extends ReplayPluginOptions, RecordingOptions {
77
76
  }
78
77
  /**
79
78
  * Some initial state captured before creating a root replay event
@@ -0,0 +1,4 @@
1
+ /**
2
+ * Captures exceptions to Sentry only when it occurs on sentry.io
3
+ */
4
+ export declare function captureInternalException(err: Error): void;
File without changes
File without changes
package/dist/index.es.js CHANGED
@@ -1,5 +1,5 @@
1
1
  import { addBreadcrumb, withScope, captureEvent, getCurrentHub, captureException, addGlobalEventProcessor, setContext, getEnvelopeEndpointWithUrlEncodedAuth } from '@sentry/core';
2
- import { htmlTreeAsString, logger as logger$1, uuid4, addInstrumentationHandler, createEnvelope, serializeEnvelope } from '@sentry/utils';
2
+ import { htmlTreeAsString, logger as logger$1, uuid4, browserPerformanceTimeOrigin, addInstrumentationHandler, createEnvelope, serializeEnvelope } from '@sentry/utils';
3
3
  import debounce from 'lodash.debounce';
4
4
  import { record, EventType } from 'rrweb';
5
5
 
@@ -123,7 +123,7 @@ function captureReplayEvent(_a) {
123
123
  });
124
124
  }
125
125
  withScope(function (scope) {
126
- scope.setTag('replay_sdk_version', "0.6.0");
126
+ scope.setTag('replay_sdk_version', "0.6.2");
127
127
  captureEvent(__assign(__assign({
128
128
  // @ts-expect-error replay_event is a new event type
129
129
  type: REPLAY_EVENT_NAME }, (includeReplayStartTimestamp
@@ -499,6 +499,16 @@ function getSession(_a) {
499
499
  return { type: 'new', session: newSession };
500
500
  }
501
501
 
502
+ /**
503
+ * Captures exceptions to Sentry only when it occurs on sentry.io
504
+ */
505
+ function captureInternalException(err) {
506
+ if (!isInternal()) {
507
+ return;
508
+ }
509
+ captureException(err);
510
+ }
511
+
502
512
  function createPayload(_a) {
503
513
  var events = _a.events, headers = _a.headers;
504
514
  var payloadWithSequence;
@@ -609,7 +619,10 @@ function createPerformanceEntry(entry) {
609
619
  return ENTRY_TYPES[entry.entryType](entry);
610
620
  }
611
621
  function getAbsoluteTime(time) {
612
- return (window.performance.timeOrigin + time) / 1000;
622
+ // browserPerformanceTimeOrigin can be undefined if `performance` or
623
+ // `performance.now` doesn't exist, but this is already checked by this integration
624
+ return (((browserPerformanceTimeOrigin || window.performance.timeOrigin) + time) /
625
+ 1000);
613
626
  }
614
627
  function createPaintEntry(entry) {
615
628
  var duration = entry.duration, entryType = entry.entryType, name = entry.name, startTime = entry.startTime;
@@ -678,8 +691,8 @@ function createLargestContentfulPaint(entry) {
678
691
  }
679
692
  function createMemoryEntry(memoryEntry) {
680
693
  var jsHeapSizeLimit = memoryEntry.jsHeapSizeLimit, totalJSHeapSize = memoryEntry.totalJSHeapSize, usedJSHeapSize = memoryEntry.usedJSHeapSize;
681
- // we can't use getAbsoluteTime because it adds the event time to
682
- // window.performance.timeOrigin, so we get right now instead.
694
+ // we don't want to use `getAbsoluteTime` because it adds the event time to the
695
+ // time origin, so we get the current timestamp instead
683
696
  var time = new Date().getTime() / 1000;
684
697
  return {
685
698
  type: 'memory',
@@ -889,11 +902,12 @@ var EventBufferCompressionWorker = /** @class */ (function () {
889
902
  var BASE_RETRY_INTERVAL = 5000;
890
903
  var MAX_RETRY_COUNT = 3;
891
904
  var UNABLE_TO_SEND_REPLAY = 'Unable to send Replay';
905
+ var MEDIA_SELECTORS = 'img,image,svg,path,rect,area,video,object,picture,embed,map,audio';
892
906
  var Replay = /** @class */ (function () {
893
907
  function Replay(_a) {
894
908
  if (_a === void 0) { _a = {}; }
895
909
  var _this = this;
896
- var _b = _a.flushMinDelay, flushMinDelay = _b === void 0 ? 5000 : _b, _c = _a.flushMaxDelay, flushMaxDelay = _c === void 0 ? 15000 : _c, _d = _a.initialFlushDelay, initialFlushDelay = _d === void 0 ? 5000 : _d, _e = _a.stickySession, stickySession = _e === void 0 ? true : _e, _f = _a.useCompression, useCompression = _f === void 0 ? true : _f, _g = _a.captureOnlyOnError, captureOnlyOnError = _g === void 0 ? false : _g, _h = _a.replaysSamplingRate, replaysSamplingRate = _h === void 0 ? 1.0 : _h, _j = _a.maskAllText, maskAllText = _j === void 0 ? false : _j, _k = _a.recordingConfig, _l = _k === void 0 ? {} : _k, _m = _l.maskAllInputs, maskAllInputs = _m === void 0 ? true : _m, _o = _l.blockClass, blockClass = _o === void 0 ? 'sentry-block' : _o, _p = _l.ignoreClass, ignoreClass = _p === void 0 ? 'sentry-ignore' : _p, _q = _l.maskTextClass, maskTextClass = _q === void 0 ? 'sentry-mask' : _q, recordingOptions = __rest(_l, ["maskAllInputs", "blockClass", "ignoreClass", "maskTextClass"]);
910
+ var _b = _a.flushMinDelay, flushMinDelay = _b === void 0 ? 5000 : _b, _c = _a.flushMaxDelay, flushMaxDelay = _c === void 0 ? 15000 : _c, _d = _a.initialFlushDelay, initialFlushDelay = _d === void 0 ? 5000 : _d, _e = _a.stickySession, stickySession = _e === void 0 ? true : _e, _f = _a.useCompression, useCompression = _f === void 0 ? true : _f, _g = _a.captureOnlyOnError, captureOnlyOnError = _g === void 0 ? false : _g, _h = _a.replaysSamplingRate, replaysSamplingRate = _h === void 0 ? 1.0 : _h, _j = _a.maskAllText, maskAllText = _j === void 0 ? true : _j, _k = _a.maskAllInputs, maskAllInputs = _k === void 0 ? true : _k, _l = _a.blockAllMedia, blockAllMedia = _l === void 0 ? true : _l, _m = _a.blockClass, blockClass = _m === void 0 ? 'sentry-block' : _m, _o = _a.ignoreClass, ignoreClass = _o === void 0 ? 'sentry-ignore' : _o, _p = _a.maskTextClass, maskTextClass = _p === void 0 ? 'sentry-mask' : _p, _q = _a.blockSelector, blockSelector = _q === void 0 ? '[data-sentry-block]' : _q, recordingOptions = __rest(_a, ["flushMinDelay", "flushMaxDelay", "initialFlushDelay", "stickySession", "useCompression", "captureOnlyOnError", "replaysSamplingRate", "maskAllText", "maskAllInputs", "blockAllMedia", "blockClass", "ignoreClass", "maskTextClass", "blockSelector"]);
897
911
  /**
898
912
  * @inheritDoc
899
913
  */
@@ -1175,7 +1189,7 @@ var Replay = /** @class */ (function () {
1175
1189
  }
1176
1190
  });
1177
1191
  }); };
1178
- this.recordingOptions = __assign({ maskAllInputs: maskAllInputs, blockClass: blockClass, ignoreClass: ignoreClass, maskTextClass: maskTextClass }, recordingOptions);
1192
+ this.recordingOptions = __assign({ maskAllInputs: maskAllInputs, blockClass: blockClass, ignoreClass: ignoreClass, maskTextClass: maskTextClass, blockSelector: blockSelector }, recordingOptions);
1179
1193
  this.options = {
1180
1194
  flushMinDelay: flushMinDelay,
1181
1195
  flushMaxDelay: flushMaxDelay,
@@ -1185,6 +1199,7 @@ var Replay = /** @class */ (function () {
1185
1199
  replaysSamplingRate: replaysSamplingRate,
1186
1200
  useCompression: useCompression,
1187
1201
  maskAllText: maskAllText,
1202
+ blockAllMedia: blockAllMedia,
1188
1203
  };
1189
1204
  // Modify rrweb options to checkoutEveryNthSecond if this is defined, as we don't know when an error occurs, so we want to try to minimize the number of events captured.
1190
1205
  if (this.options.captureOnlyOnError) {
@@ -1197,6 +1212,13 @@ var Replay = /** @class */ (function () {
1197
1212
  // content masked.
1198
1213
  this.recordingOptions.maskTextSelector = '*';
1199
1214
  }
1215
+ if (this.options.blockAllMedia) {
1216
+ // `blockAllMedia` is a more user friendly option to configure blocking
1217
+ // embedded media elements
1218
+ this.recordingOptions.blockSelector = !this.recordingOptions.blockSelector
1219
+ ? MEDIA_SELECTORS
1220
+ : "".concat(this.recordingOptions.blockSelector, ",").concat(MEDIA_SELECTORS);
1221
+ }
1200
1222
  this.debouncedFlush = debounce(function () { return _this.flush(); }, this.options.flushMinDelay, {
1201
1223
  maxWait: this.options.flushMaxDelay,
1202
1224
  });
@@ -1645,7 +1667,7 @@ var Replay = /** @class */ (function () {
1645
1667
  return [3 /*break*/, 7];
1646
1668
  case 6:
1647
1669
  err_2 = _d.sent();
1648
- captureException(err_2);
1670
+ captureInternalException(err_2);
1649
1671
  console.error(err_2);
1650
1672
  return [3 /*break*/, 7];
1651
1673
  case 7: return [2 /*return*/];
@@ -1675,7 +1697,7 @@ var Replay = /** @class */ (function () {
1675
1697
  sent_at: new Date().toISOString(),
1676
1698
  sdk: {
1677
1699
  name: 'sentry.javascript.integration.replay',
1678
- version: "0.6.0",
1700
+ version: "0.6.2",
1679
1701
  },
1680
1702
  }, [
1681
1703
  [
@@ -1753,7 +1775,7 @@ var Replay = /** @class */ (function () {
1753
1775
  setContext('Replays', {
1754
1776
  retryCount: this.retryCount,
1755
1777
  });
1756
- captureException(new Error(UNABLE_TO_SEND_REPLAY));
1778
+ captureInternalException(new Error(UNABLE_TO_SEND_REPLAY));
1757
1779
  // If an error happened here, it's likely that uploading the attachment
1758
1780
  // failed, we'll can retry with the same events payload
1759
1781
  if (this.retryCount >= MAX_RETRY_COUNT) {
package/dist/index.js CHANGED
@@ -131,7 +131,7 @@ function captureReplayEvent(_a) {
131
131
  });
132
132
  }
133
133
  core.withScope(function (scope) {
134
- scope.setTag('replay_sdk_version', "0.6.0");
134
+ scope.setTag('replay_sdk_version', "0.6.2");
135
135
  core.captureEvent(__assign(__assign({
136
136
  // @ts-expect-error replay_event is a new event type
137
137
  type: REPLAY_EVENT_NAME }, (includeReplayStartTimestamp
@@ -507,6 +507,16 @@ function getSession(_a) {
507
507
  return { type: 'new', session: newSession };
508
508
  }
509
509
 
510
+ /**
511
+ * Captures exceptions to Sentry only when it occurs on sentry.io
512
+ */
513
+ function captureInternalException(err) {
514
+ if (!isInternal()) {
515
+ return;
516
+ }
517
+ core.captureException(err);
518
+ }
519
+
510
520
  function createPayload(_a) {
511
521
  var events = _a.events, headers = _a.headers;
512
522
  var payloadWithSequence;
@@ -617,7 +627,10 @@ function createPerformanceEntry(entry) {
617
627
  return ENTRY_TYPES[entry.entryType](entry);
618
628
  }
619
629
  function getAbsoluteTime(time) {
620
- return (window.performance.timeOrigin + time) / 1000;
630
+ // browserPerformanceTimeOrigin can be undefined if `performance` or
631
+ // `performance.now` doesn't exist, but this is already checked by this integration
632
+ return (((utils.browserPerformanceTimeOrigin || window.performance.timeOrigin) + time) /
633
+ 1000);
621
634
  }
622
635
  function createPaintEntry(entry) {
623
636
  var duration = entry.duration, entryType = entry.entryType, name = entry.name, startTime = entry.startTime;
@@ -686,8 +699,8 @@ function createLargestContentfulPaint(entry) {
686
699
  }
687
700
  function createMemoryEntry(memoryEntry) {
688
701
  var jsHeapSizeLimit = memoryEntry.jsHeapSizeLimit, totalJSHeapSize = memoryEntry.totalJSHeapSize, usedJSHeapSize = memoryEntry.usedJSHeapSize;
689
- // we can't use getAbsoluteTime because it adds the event time to
690
- // window.performance.timeOrigin, so we get right now instead.
702
+ // we don't want to use `getAbsoluteTime` because it adds the event time to the
703
+ // time origin, so we get the current timestamp instead
691
704
  var time = new Date().getTime() / 1000;
692
705
  return {
693
706
  type: 'memory',
@@ -897,11 +910,12 @@ var EventBufferCompressionWorker = /** @class */ (function () {
897
910
  var BASE_RETRY_INTERVAL = 5000;
898
911
  var MAX_RETRY_COUNT = 3;
899
912
  var UNABLE_TO_SEND_REPLAY = 'Unable to send Replay';
913
+ var MEDIA_SELECTORS = 'img,image,svg,path,rect,area,video,object,picture,embed,map,audio';
900
914
  var Replay = /** @class */ (function () {
901
915
  function Replay(_a) {
902
916
  if (_a === void 0) { _a = {}; }
903
917
  var _this = this;
904
- var _b = _a.flushMinDelay, flushMinDelay = _b === void 0 ? 5000 : _b, _c = _a.flushMaxDelay, flushMaxDelay = _c === void 0 ? 15000 : _c, _d = _a.initialFlushDelay, initialFlushDelay = _d === void 0 ? 5000 : _d, _e = _a.stickySession, stickySession = _e === void 0 ? true : _e, _f = _a.useCompression, useCompression = _f === void 0 ? true : _f, _g = _a.captureOnlyOnError, captureOnlyOnError = _g === void 0 ? false : _g, _h = _a.replaysSamplingRate, replaysSamplingRate = _h === void 0 ? 1.0 : _h, _j = _a.maskAllText, maskAllText = _j === void 0 ? false : _j, _k = _a.recordingConfig, _l = _k === void 0 ? {} : _k, _m = _l.maskAllInputs, maskAllInputs = _m === void 0 ? true : _m, _o = _l.blockClass, blockClass = _o === void 0 ? 'sentry-block' : _o, _p = _l.ignoreClass, ignoreClass = _p === void 0 ? 'sentry-ignore' : _p, _q = _l.maskTextClass, maskTextClass = _q === void 0 ? 'sentry-mask' : _q, recordingOptions = __rest(_l, ["maskAllInputs", "blockClass", "ignoreClass", "maskTextClass"]);
918
+ var _b = _a.flushMinDelay, flushMinDelay = _b === void 0 ? 5000 : _b, _c = _a.flushMaxDelay, flushMaxDelay = _c === void 0 ? 15000 : _c, _d = _a.initialFlushDelay, initialFlushDelay = _d === void 0 ? 5000 : _d, _e = _a.stickySession, stickySession = _e === void 0 ? true : _e, _f = _a.useCompression, useCompression = _f === void 0 ? true : _f, _g = _a.captureOnlyOnError, captureOnlyOnError = _g === void 0 ? false : _g, _h = _a.replaysSamplingRate, replaysSamplingRate = _h === void 0 ? 1.0 : _h, _j = _a.maskAllText, maskAllText = _j === void 0 ? true : _j, _k = _a.maskAllInputs, maskAllInputs = _k === void 0 ? true : _k, _l = _a.blockAllMedia, blockAllMedia = _l === void 0 ? true : _l, _m = _a.blockClass, blockClass = _m === void 0 ? 'sentry-block' : _m, _o = _a.ignoreClass, ignoreClass = _o === void 0 ? 'sentry-ignore' : _o, _p = _a.maskTextClass, maskTextClass = _p === void 0 ? 'sentry-mask' : _p, _q = _a.blockSelector, blockSelector = _q === void 0 ? '[data-sentry-block]' : _q, recordingOptions = __rest(_a, ["flushMinDelay", "flushMaxDelay", "initialFlushDelay", "stickySession", "useCompression", "captureOnlyOnError", "replaysSamplingRate", "maskAllText", "maskAllInputs", "blockAllMedia", "blockClass", "ignoreClass", "maskTextClass", "blockSelector"]);
905
919
  /**
906
920
  * @inheritDoc
907
921
  */
@@ -1183,7 +1197,7 @@ var Replay = /** @class */ (function () {
1183
1197
  }
1184
1198
  });
1185
1199
  }); };
1186
- this.recordingOptions = __assign({ maskAllInputs: maskAllInputs, blockClass: blockClass, ignoreClass: ignoreClass, maskTextClass: maskTextClass }, recordingOptions);
1200
+ this.recordingOptions = __assign({ maskAllInputs: maskAllInputs, blockClass: blockClass, ignoreClass: ignoreClass, maskTextClass: maskTextClass, blockSelector: blockSelector }, recordingOptions);
1187
1201
  this.options = {
1188
1202
  flushMinDelay: flushMinDelay,
1189
1203
  flushMaxDelay: flushMaxDelay,
@@ -1193,6 +1207,7 @@ var Replay = /** @class */ (function () {
1193
1207
  replaysSamplingRate: replaysSamplingRate,
1194
1208
  useCompression: useCompression,
1195
1209
  maskAllText: maskAllText,
1210
+ blockAllMedia: blockAllMedia,
1196
1211
  };
1197
1212
  // Modify rrweb options to checkoutEveryNthSecond if this is defined, as we don't know when an error occurs, so we want to try to minimize the number of events captured.
1198
1213
  if (this.options.captureOnlyOnError) {
@@ -1205,6 +1220,13 @@ var Replay = /** @class */ (function () {
1205
1220
  // content masked.
1206
1221
  this.recordingOptions.maskTextSelector = '*';
1207
1222
  }
1223
+ if (this.options.blockAllMedia) {
1224
+ // `blockAllMedia` is a more user friendly option to configure blocking
1225
+ // embedded media elements
1226
+ this.recordingOptions.blockSelector = !this.recordingOptions.blockSelector
1227
+ ? MEDIA_SELECTORS
1228
+ : "".concat(this.recordingOptions.blockSelector, ",").concat(MEDIA_SELECTORS);
1229
+ }
1208
1230
  this.debouncedFlush = debounce__default["default"](function () { return _this.flush(); }, this.options.flushMinDelay, {
1209
1231
  maxWait: this.options.flushMaxDelay,
1210
1232
  });
@@ -1653,7 +1675,7 @@ var Replay = /** @class */ (function () {
1653
1675
  return [3 /*break*/, 7];
1654
1676
  case 6:
1655
1677
  err_2 = _d.sent();
1656
- core.captureException(err_2);
1678
+ captureInternalException(err_2);
1657
1679
  console.error(err_2);
1658
1680
  return [3 /*break*/, 7];
1659
1681
  case 7: return [2 /*return*/];
@@ -1683,7 +1705,7 @@ var Replay = /** @class */ (function () {
1683
1705
  sent_at: new Date().toISOString(),
1684
1706
  sdk: {
1685
1707
  name: 'sentry.javascript.integration.replay',
1686
- version: "0.6.0",
1708
+ version: "0.6.2",
1687
1709
  },
1688
1710
  }, [
1689
1711
  [
@@ -1761,7 +1783,7 @@ var Replay = /** @class */ (function () {
1761
1783
  core.setContext('Replays', {
1762
1784
  retryCount: this.retryCount,
1763
1785
  });
1764
- core.captureException(new Error(UNABLE_TO_SEND_REPLAY));
1786
+ captureInternalException(new Error(UNABLE_TO_SEND_REPLAY));
1765
1787
  // If an error happened here, it's likely that uploading the attachment
1766
1788
  // failed, we'll can retry with the same events payload
1767
1789
  if (this.retryCount >= MAX_RETRY_COUNT) {