@sentry/replay 0.6.0 → 0.6.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 (68) hide show
  1. package/README.md +57 -30
  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/{src → config/types/src}/util/createBreadcrumb.d.ts +0 -0
  45. package/dist/{src → config/types/src}/util/createPayload.d.ts +0 -0
  46. package/dist/{src → config/types/src}/util/dedupePerformanceEntries.d.ts +0 -0
  47. package/dist/{src/util/isExpired.test.d.ts → config/types/src/util/dedupePerformanceEntries.test.d.ts} +0 -0
  48. package/dist/{src → config/types/src}/util/isExpired.d.ts +0 -0
  49. package/dist/{src/util/isSampled.test.d.ts → config/types/src/util/isExpired.test.d.ts} +0 -0
  50. package/dist/{src → config/types/src}/util/isIngestHost.d.ts +0 -0
  51. package/dist/{src → config/types/src}/util/isInternal.d.ts +0 -0
  52. package/dist/{src → config/types/src}/util/isSampled.d.ts +0 -0
  53. package/dist/{src/util/isSessionExpired.test.d.ts → config/types/src/util/isSampled.test.d.ts} +0 -0
  54. package/dist/{src → config/types/src}/util/isSessionExpired.d.ts +0 -0
  55. package/dist/config/types/src/util/isSessionExpired.test.d.ts +1 -0
  56. package/dist/{src → config/types/src}/util/logger.d.ts +0 -0
  57. package/dist/{test → config/types/test}/fixtures/performanceEntry/lcp.d.ts +0 -0
  58. package/dist/{test → config/types/test}/fixtures/performanceEntry/navigation.d.ts +0 -0
  59. package/dist/{test → config/types/test}/fixtures/performanceEntry/resource.d.ts +0 -0
  60. package/dist/{test → config/types/test}/index.d.ts +0 -0
  61. package/dist/{test → config/types/test}/mocks/mockRrweb.d.ts +0 -0
  62. package/dist/{test → config/types/test}/mocks/mockSdk.d.ts +0 -0
  63. package/dist/index.es.js +20 -8
  64. package/dist/index.js +19 -7
  65. package/dist/index.js.map +1 -1
  66. package/dist/types/src/index.d.ts +3 -3
  67. package/dist/types/src/types.d.ts +6 -7
  68. 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';
@@ -33,19 +31,12 @@ import { Replay } from '@sentry/replay';
33
31
 
34
32
  Sentry.init({
35
33
  dsn: '__DSN__',
36
- integrations: [
37
- new Replay({
38
- maskAllText: true, // Will mask all text strings
39
- recordingConfig: {
40
- maskAllInputs: false, // Default is true
41
- },
42
- }),
43
- ],
34
+ integrations: [new Replay()],
44
35
  // ...
45
36
  });
46
37
  ```
47
38
 
48
- ### Stop Recording
39
+ ### Start and Stop Recording
49
40
 
50
41
  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
42
 
@@ -59,17 +50,53 @@ replay.stop(); // Stop recording
59
50
 
60
51
  ## Configuration
61
52
 
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` |
53
+ ### General Configuration
54
+
55
+ | key | type | default | description |
56
+ | ------------------- | ------- | ------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
57
+ | 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. |
58
+ | 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. |
59
+ | replaysSamplingRate | number | `1.0` | The rate at which to sample replays. (1.0 will collect all replays, 0 will collect no replays). |
60
+ | 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. |
61
+
62
+ ### Privacy Configuration
63
+
64
+ | key | type | default | description |
65
+ | ---------------- | ------------------------ | ----------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
66
+ | maskAllText | boolean | `true` | Mask _all_ text content. Will pass text content through `maskTextFn` before sending to server. |
67
+ | blockAllMedia | boolean | `true` | Block _all_ media elements (`img, svg, video, object, picture, embed, map, audio`)
68
+ | 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 `*`. |
69
+ | maskAllInputs | boolean | `true` | Mask values of `<input>` elements. Passes input values through `maskInputFn` before sending to server. |
70
+ | 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`. |
71
+ | 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 `*`. |
72
+ | blockClass | string \| RegExp | `'sentry-block'` | Redact all elements that match the class name. See [privacy](#blocking) section for an example. |
73
+ | blockSelector | string | `'[data-sentry-block]'` | Redact all elements that match the DOM selector. See [privacy](#blocking) section for an example. |
74
+ | ignoreClass | string \| RegExp | `'sentry-ignore'` | Ignores all events on the matching input field. See [privacy](#ignoring) section for an example. |
75
+ | maskTextClass | string \| RegExp | `'sentry-mask'` | Mask all elements that match the class name. See [privacy](#masking) section for an example. |
76
+
77
+ ### Optimization Configuration
78
+
79
+ | key | type | default | description |
80
+ | ---------------- | ----------------------- | ------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
81
+ | collectFonts | boolean | `false` | Should collect fonts used on the website |
82
+ | inlineImages | boolean | `false` | Should inline `<image>` content |
83
+ | inlineStylesheet | boolean | `true` | Should inline stylesheets used in the recording |
84
+ | recordCanvas | boolean | `false` | Should record `<canvas>` elements |
85
+ | slimDOMOptions | Record<string, boolean> | `{}` | Remove unnecessary parts of the DOM <br /> Available keys: `script, comment, headFavicon, headWhitespace, headMetaDescKeywords, headMetaSocial, headMetaRobots, headMetaHttpEquiv, headMetaAuthorship, headMetaVerification` |
86
+
87
+ ## Privacy
88
+ 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.
89
+
90
+ ### Masking
91
+ 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>`.
92
+ ![Masking example](https://user-images.githubusercontent.com/79684/193118192-dee1d3d8-5813-47e8-b532-f9ee1c8714b3.png)
93
+
94
+ ### Blocking
95
+ 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>`.
96
+ ![Blocking example](https://user-images.githubusercontent.com/79684/193118084-51a589fc-2160-476a-a8dc-b681eddb136c.png)
97
+
98
+ ### Ignoring
99
+ 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.
100
+
101
+ https://user-images.githubusercontent.com/79684/192815134-a6451c3f-d3cb-455f-a699-7c3fe04d0a2e.mov
102
+
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
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.1");
127
127
  captureEvent(__assign(__assign({
128
128
  // @ts-expect-error replay_event is a new event type
129
129
  type: REPLAY_EVENT_NAME }, (includeReplayStartTimestamp
@@ -609,7 +609,10 @@ function createPerformanceEntry(entry) {
609
609
  return ENTRY_TYPES[entry.entryType](entry);
610
610
  }
611
611
  function getAbsoluteTime(time) {
612
- return (window.performance.timeOrigin + time) / 1000;
612
+ // browserPerformanceTimeOrigin can be undefined if `performance` or
613
+ // `performance.now` doesn't exist, but this is already checked by this integration
614
+ return (((browserPerformanceTimeOrigin || window.performance.timeOrigin) + time) /
615
+ 1000);
613
616
  }
614
617
  function createPaintEntry(entry) {
615
618
  var duration = entry.duration, entryType = entry.entryType, name = entry.name, startTime = entry.startTime;
@@ -678,8 +681,8 @@ function createLargestContentfulPaint(entry) {
678
681
  }
679
682
  function createMemoryEntry(memoryEntry) {
680
683
  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.
684
+ // we don't want to use `getAbsoluteTime` because it adds the event time to the
685
+ // time origin, so we get the current timestamp instead
683
686
  var time = new Date().getTime() / 1000;
684
687
  return {
685
688
  type: 'memory',
@@ -889,11 +892,12 @@ var EventBufferCompressionWorker = /** @class */ (function () {
889
892
  var BASE_RETRY_INTERVAL = 5000;
890
893
  var MAX_RETRY_COUNT = 3;
891
894
  var UNABLE_TO_SEND_REPLAY = 'Unable to send Replay';
895
+ var MEDIA_SELECTORS = 'img,image,svg,path,rect,area,video,object,picture,embed,map,audio';
892
896
  var Replay = /** @class */ (function () {
893
897
  function Replay(_a) {
894
898
  if (_a === void 0) { _a = {}; }
895
899
  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"]);
900
+ 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
901
  /**
898
902
  * @inheritDoc
899
903
  */
@@ -1175,7 +1179,7 @@ var Replay = /** @class */ (function () {
1175
1179
  }
1176
1180
  });
1177
1181
  }); };
1178
- this.recordingOptions = __assign({ maskAllInputs: maskAllInputs, blockClass: blockClass, ignoreClass: ignoreClass, maskTextClass: maskTextClass }, recordingOptions);
1182
+ this.recordingOptions = __assign({ maskAllInputs: maskAllInputs, blockClass: blockClass, ignoreClass: ignoreClass, maskTextClass: maskTextClass, blockSelector: blockSelector }, recordingOptions);
1179
1183
  this.options = {
1180
1184
  flushMinDelay: flushMinDelay,
1181
1185
  flushMaxDelay: flushMaxDelay,
@@ -1185,6 +1189,7 @@ var Replay = /** @class */ (function () {
1185
1189
  replaysSamplingRate: replaysSamplingRate,
1186
1190
  useCompression: useCompression,
1187
1191
  maskAllText: maskAllText,
1192
+ blockAllMedia: blockAllMedia,
1188
1193
  };
1189
1194
  // 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
1195
  if (this.options.captureOnlyOnError) {
@@ -1197,6 +1202,13 @@ var Replay = /** @class */ (function () {
1197
1202
  // content masked.
1198
1203
  this.recordingOptions.maskTextSelector = '*';
1199
1204
  }
1205
+ if (this.options.blockAllMedia) {
1206
+ // `blockAllMedia` is a more user friendly option to configure blocking
1207
+ // embedded media elements
1208
+ this.recordingOptions.blockSelector = !this.recordingOptions.blockSelector
1209
+ ? MEDIA_SELECTORS
1210
+ : "".concat(this.recordingOptions.blockSelector, ",").concat(MEDIA_SELECTORS);
1211
+ }
1200
1212
  this.debouncedFlush = debounce(function () { return _this.flush(); }, this.options.flushMinDelay, {
1201
1213
  maxWait: this.options.flushMaxDelay,
1202
1214
  });
@@ -1675,7 +1687,7 @@ var Replay = /** @class */ (function () {
1675
1687
  sent_at: new Date().toISOString(),
1676
1688
  sdk: {
1677
1689
  name: 'sentry.javascript.integration.replay',
1678
- version: "0.6.0",
1690
+ version: "0.6.1",
1679
1691
  },
1680
1692
  }, [
1681
1693
  [
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.1");
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
@@ -617,7 +617,10 @@ function createPerformanceEntry(entry) {
617
617
  return ENTRY_TYPES[entry.entryType](entry);
618
618
  }
619
619
  function getAbsoluteTime(time) {
620
- return (window.performance.timeOrigin + time) / 1000;
620
+ // browserPerformanceTimeOrigin can be undefined if `performance` or
621
+ // `performance.now` doesn't exist, but this is already checked by this integration
622
+ return (((utils.browserPerformanceTimeOrigin || window.performance.timeOrigin) + time) /
623
+ 1000);
621
624
  }
622
625
  function createPaintEntry(entry) {
623
626
  var duration = entry.duration, entryType = entry.entryType, name = entry.name, startTime = entry.startTime;
@@ -686,8 +689,8 @@ function createLargestContentfulPaint(entry) {
686
689
  }
687
690
  function createMemoryEntry(memoryEntry) {
688
691
  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.
692
+ // we don't want to use `getAbsoluteTime` because it adds the event time to the
693
+ // time origin, so we get the current timestamp instead
691
694
  var time = new Date().getTime() / 1000;
692
695
  return {
693
696
  type: 'memory',
@@ -897,11 +900,12 @@ var EventBufferCompressionWorker = /** @class */ (function () {
897
900
  var BASE_RETRY_INTERVAL = 5000;
898
901
  var MAX_RETRY_COUNT = 3;
899
902
  var UNABLE_TO_SEND_REPLAY = 'Unable to send Replay';
903
+ var MEDIA_SELECTORS = 'img,image,svg,path,rect,area,video,object,picture,embed,map,audio';
900
904
  var Replay = /** @class */ (function () {
901
905
  function Replay(_a) {
902
906
  if (_a === void 0) { _a = {}; }
903
907
  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"]);
908
+ 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
909
  /**
906
910
  * @inheritDoc
907
911
  */
@@ -1183,7 +1187,7 @@ var Replay = /** @class */ (function () {
1183
1187
  }
1184
1188
  });
1185
1189
  }); };
1186
- this.recordingOptions = __assign({ maskAllInputs: maskAllInputs, blockClass: blockClass, ignoreClass: ignoreClass, maskTextClass: maskTextClass }, recordingOptions);
1190
+ this.recordingOptions = __assign({ maskAllInputs: maskAllInputs, blockClass: blockClass, ignoreClass: ignoreClass, maskTextClass: maskTextClass, blockSelector: blockSelector }, recordingOptions);
1187
1191
  this.options = {
1188
1192
  flushMinDelay: flushMinDelay,
1189
1193
  flushMaxDelay: flushMaxDelay,
@@ -1193,6 +1197,7 @@ var Replay = /** @class */ (function () {
1193
1197
  replaysSamplingRate: replaysSamplingRate,
1194
1198
  useCompression: useCompression,
1195
1199
  maskAllText: maskAllText,
1200
+ blockAllMedia: blockAllMedia,
1196
1201
  };
1197
1202
  // 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
1203
  if (this.options.captureOnlyOnError) {
@@ -1205,6 +1210,13 @@ var Replay = /** @class */ (function () {
1205
1210
  // content masked.
1206
1211
  this.recordingOptions.maskTextSelector = '*';
1207
1212
  }
1213
+ if (this.options.blockAllMedia) {
1214
+ // `blockAllMedia` is a more user friendly option to configure blocking
1215
+ // embedded media elements
1216
+ this.recordingOptions.blockSelector = !this.recordingOptions.blockSelector
1217
+ ? MEDIA_SELECTORS
1218
+ : "".concat(this.recordingOptions.blockSelector, ",").concat(MEDIA_SELECTORS);
1219
+ }
1208
1220
  this.debouncedFlush = debounce__default["default"](function () { return _this.flush(); }, this.options.flushMinDelay, {
1209
1221
  maxWait: this.options.flushMaxDelay,
1210
1222
  });
@@ -1683,7 +1695,7 @@ var Replay = /** @class */ (function () {
1683
1695
  sent_at: new Date().toISOString(),
1684
1696
  sdk: {
1685
1697
  name: 'sentry.javascript.integration.replay',
1686
- version: "0.6.0",
1698
+ version: "0.6.1",
1687
1699
  },
1688
1700
  }, [
1689
1701
  [