@sentry/replay 0.6.1 → 0.6.3

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 (28) hide show
  1. package/CHANGELOG.md +0 -0
  2. package/README.md +8 -2
  3. package/dist/config/types/jest.setup.d.ts +1 -1
  4. package/dist/config/types/src/api/captureReplayEvent.d.ts +1 -1
  5. package/dist/config/types/src/coreHandlers/getBreadcrumbHandler.d.ts +1 -1
  6. package/dist/config/types/src/coreHandlers/getSpanHandler.d.ts +1 -1
  7. package/dist/config/types/src/coreHandlers/handleFetch.d.ts +1 -1
  8. package/dist/config/types/src/coreHandlers/handleHistory.d.ts +1 -1
  9. package/dist/config/types/src/coreHandlers/handleXhr.d.ts +1 -1
  10. package/dist/config/types/src/util/captureInternalException.d.ts +4 -0
  11. package/dist/config/types/src/util/createPayload.d.ts +1 -1
  12. package/dist/config/types/src/util/isSessionExpired.d.ts +1 -1
  13. package/dist/config/types/src/util/logger.d.ts +1 -1
  14. package/dist/config/types/test/mocks/mockRrweb.d.ts +1 -1
  15. package/dist/config/types/test/mocks/mockSdk.d.ts +2 -2
  16. package/dist/index.es.js +14 -4
  17. package/dist/index.js +14 -4
  18. package/dist/index.js.map +1 -1
  19. package/dist/types/src/api/captureReplayEvent.d.ts +1 -1
  20. package/dist/types/src/coreHandlers/getBreadcrumbHandler.d.ts +1 -1
  21. package/dist/types/src/coreHandlers/getSpanHandler.d.ts +1 -1
  22. package/dist/types/src/coreHandlers/handleFetch.d.ts +1 -1
  23. package/dist/types/src/coreHandlers/handleHistory.d.ts +1 -1
  24. package/dist/types/src/coreHandlers/handleXhr.d.ts +1 -1
  25. package/dist/types/src/util/captureInternalException.d.ts +4 -0
  26. package/dist/types/src/util/createPayload.d.ts +1 -1
  27. package/dist/types/src/util/isSessionExpired.d.ts +1 -1
  28. package/package.json +1 -1
package/CHANGELOG.md ADDED
File without changes
package/README.md CHANGED
@@ -4,7 +4,7 @@ Note: Session Replay is currently in alpha.
4
4
 
5
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) (or an equivalent framework SDK e.g. [@sentry/react](https://www.npmjs.com/package/@sentry/react)) installed.
7
+ For the sentry-replay integration to work, you must have the [Sentry browser SDK package](https://www.npmjs.com/package/@sentry/browser) (minimum version `7.x`), or an equivalent framework SDK (e.g. [@sentry/react](https://www.npmjs.com/package/@sentry/react)) installed.
8
8
 
9
9
  ## Installation
10
10
 
@@ -31,7 +31,13 @@ import { Replay } from '@sentry/replay';
31
31
 
32
32
  Sentry.init({
33
33
  dsn: '__DSN__',
34
- integrations: [new Replay()],
34
+ integrations: [
35
+ new Replay({
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
+ })
40
+ ],
35
41
  // ...
36
42
  });
37
43
  ```
@@ -1,5 +1,5 @@
1
1
  /// <reference types="jest" />
2
- import { Session } from '@/session/Session';
2
+ import { Session } from './src/session/Session';
3
3
  declare global {
4
4
  namespace jest {
5
5
  interface Matchers<R> {
@@ -1,4 +1,4 @@
1
- import { InitialState } from '@/types';
1
+ import { InitialState } from '../types';
2
2
  export interface CaptureReplayEventParams {
3
3
  /**
4
4
  * Initial state of the replay
@@ -1,3 +1,3 @@
1
- import { InstrumentationTypeBreadcrumb } from '@/types';
1
+ import { InstrumentationTypeBreadcrumb } from '../types';
2
2
  import { handleScope } from './handleScope';
3
3
  export declare function getBreadcrumbHandler(type: InstrumentationTypeBreadcrumb): typeof handleScope;
@@ -1,4 +1,4 @@
1
- import { InstrumentationTypeSpan } from '@/types';
1
+ import { InstrumentationTypeSpan } from '../types';
2
2
  import { handleFetch } from './handleFetch';
3
3
  import { handleHistory } from './handleHistory';
4
4
  import { handleXhr } from './handleXhr';
@@ -1,4 +1,4 @@
1
- import { ReplayPerformanceEntry } from '@/createPerformanceEntry';
1
+ import { ReplayPerformanceEntry } from '../createPerformanceEntry';
2
2
  interface FetchHandlerData {
3
3
  args: Parameters<typeof fetch>;
4
4
  fetchData: {
@@ -1,4 +1,4 @@
1
- import { ReplayPerformanceEntry } from '@/createPerformanceEntry';
1
+ import { ReplayPerformanceEntry } from '../createPerformanceEntry';
2
2
  interface HistoryHandlerData {
3
3
  from: string;
4
4
  to: string;
@@ -1,4 +1,4 @@
1
- import { ReplayPerformanceEntry } from '@/createPerformanceEntry';
1
+ import { ReplayPerformanceEntry } from '../createPerformanceEntry';
2
2
  declare type XHRSendInput = null | Blob | BufferSource | FormData | URLSearchParams | string;
3
3
  interface SentryWrappedXMLHttpRequest extends XMLHttpRequest {
4
4
  [key: string]: unknown;
@@ -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;
@@ -1,4 +1,4 @@
1
- import { RecordedEvents } from '@/types';
1
+ import { RecordedEvents } from '../types';
2
2
  export declare function createPayload({ events, headers, }: {
3
3
  events: RecordedEvents;
4
4
  headers: Record<string, any>;
@@ -1,4 +1,4 @@
1
- import { Session } from '@/session/Session';
1
+ import { Session } from '../session/Session';
2
2
  /**
3
3
  * Checks to see if session is expired
4
4
  */
@@ -4,8 +4,8 @@ declare const logger: {
4
4
  log: (...args: any[]) => any;
5
5
  disable(): void;
6
6
  enable(): void;
7
- info: (...args: unknown[]) => void;
8
7
  debug: (...args: unknown[]) => void;
8
+ info: (...args: unknown[]) => void;
9
9
  assert: (...args: unknown[]) => void;
10
10
  trace: (...args: unknown[]) => void;
11
11
  };
@@ -1,5 +1,5 @@
1
1
  /// <reference types="jest" />
2
- import { RecordingEvent } from '@/types';
2
+ import { RecordingEvent } from '../../src/types';
3
3
  declare type RecordAdditionalProperties = {
4
4
  takeFullSnapshot: jest.Mock;
5
5
  addCustomEvent: () => void;
@@ -1,6 +1,6 @@
1
1
  import { BrowserOptions } from '@sentry/browser';
2
- import { Replay } from '@';
3
- import { ReplayConfiguration } from '@/types';
2
+ import { Replay } from '../../src';
3
+ import { ReplayConfiguration } from '../../src/types';
4
4
  interface MockSdkParams {
5
5
  replayOptions?: ReplayConfiguration;
6
6
  sentryOptions?: BrowserOptions;
package/dist/index.es.js CHANGED
@@ -123,7 +123,7 @@ function captureReplayEvent(_a) {
123
123
  });
124
124
  }
125
125
  withScope(function (scope) {
126
- scope.setTag('replay_sdk_version', "0.6.1");
126
+ scope.setTag('replay_sdk_version', "0.6.3");
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;
@@ -1657,7 +1667,7 @@ var Replay = /** @class */ (function () {
1657
1667
  return [3 /*break*/, 7];
1658
1668
  case 6:
1659
1669
  err_2 = _d.sent();
1660
- captureException(err_2);
1670
+ captureInternalException(err_2);
1661
1671
  console.error(err_2);
1662
1672
  return [3 /*break*/, 7];
1663
1673
  case 7: return [2 /*return*/];
@@ -1687,7 +1697,7 @@ var Replay = /** @class */ (function () {
1687
1697
  sent_at: new Date().toISOString(),
1688
1698
  sdk: {
1689
1699
  name: 'sentry.javascript.integration.replay',
1690
- version: "0.6.1",
1700
+ version: "0.6.3",
1691
1701
  },
1692
1702
  }, [
1693
1703
  [
@@ -1765,7 +1775,7 @@ var Replay = /** @class */ (function () {
1765
1775
  setContext('Replays', {
1766
1776
  retryCount: this.retryCount,
1767
1777
  });
1768
- captureException(new Error(UNABLE_TO_SEND_REPLAY));
1778
+ captureInternalException(new Error(UNABLE_TO_SEND_REPLAY));
1769
1779
  // If an error happened here, it's likely that uploading the attachment
1770
1780
  // failed, we'll can retry with the same events payload
1771
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.1");
134
+ scope.setTag('replay_sdk_version', "0.6.3");
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;
@@ -1665,7 +1675,7 @@ var Replay = /** @class */ (function () {
1665
1675
  return [3 /*break*/, 7];
1666
1676
  case 6:
1667
1677
  err_2 = _d.sent();
1668
- core.captureException(err_2);
1678
+ captureInternalException(err_2);
1669
1679
  console.error(err_2);
1670
1680
  return [3 /*break*/, 7];
1671
1681
  case 7: return [2 /*return*/];
@@ -1695,7 +1705,7 @@ var Replay = /** @class */ (function () {
1695
1705
  sent_at: new Date().toISOString(),
1696
1706
  sdk: {
1697
1707
  name: 'sentry.javascript.integration.replay',
1698
- version: "0.6.1",
1708
+ version: "0.6.3",
1699
1709
  },
1700
1710
  }, [
1701
1711
  [
@@ -1773,7 +1783,7 @@ var Replay = /** @class */ (function () {
1773
1783
  core.setContext('Replays', {
1774
1784
  retryCount: this.retryCount,
1775
1785
  });
1776
- core.captureException(new Error(UNABLE_TO_SEND_REPLAY));
1786
+ captureInternalException(new Error(UNABLE_TO_SEND_REPLAY));
1777
1787
  // If an error happened here, it's likely that uploading the attachment
1778
1788
  // failed, we'll can retry with the same events payload
1779
1789
  if (this.retryCount >= MAX_RETRY_COUNT) {