@sentry/replay 0.4.9 → 0.5.0
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/dist/config/dist/src/index.d.ts +3 -4
- package/dist/config/dist/src/session/constants.d.ts +2 -2
- package/dist/config/dist/src/types.d.ts +2 -1
- package/dist/dist/index.d.ts +3 -4
- package/dist/dist/session/constants.d.ts +2 -2
- package/dist/dist/types.d.ts +2 -1
- package/dist/dist/util/createPayload.d.ts +5 -0
- package/dist/index.es.js +62 -35
- package/dist/index.js +60 -33
- package/dist/index.js.map +1 -1
- package/package.json +2 -2
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import { Breadcrumb,
|
|
1
|
+
import { Breadcrumb, Event, Integration } from '@sentry/types';
|
|
2
2
|
import { CaptureReplayParams } from './api/captureReplay';
|
|
3
3
|
import { CaptureReplayUpdateParams } from './api/captureReplayUpdate';
|
|
4
4
|
import { Session } from './session/Session';
|
|
5
5
|
import { ReplayPerformanceEntry } from './createPerformanceEntry';
|
|
6
6
|
import { IEventBuffer } from './eventBuffer';
|
|
7
|
-
import type { InstrumentationTypeBreadcrumb, InstrumentationTypeSpan, RecordingConfig, RecordingEvent, ReplayRequest, SentryReplayConfiguration, SentryReplayPluginOptions } from './types';
|
|
7
|
+
import type { InstrumentationTypeBreadcrumb, InstrumentationTypeSpan, RecordedEvents, RecordingConfig, RecordingEvent, ReplayRequest, SentryReplayConfiguration, SentryReplayPluginOptions } from './types';
|
|
8
8
|
/**
|
|
9
9
|
* Returns true to return control to calling function, otherwise continue with normal batching
|
|
10
10
|
*/
|
|
@@ -58,7 +58,6 @@ export declare class SentryReplay implements Integration {
|
|
|
58
58
|
private initialState;
|
|
59
59
|
private context;
|
|
60
60
|
session: Session | undefined;
|
|
61
|
-
static attachmentUrlFromDsn(dsn: DsnComponents, eventId: string): string;
|
|
62
61
|
constructor({ flushMinDelay, flushMaxDelay, initialFlushDelay, stickySession, // TBD: Making this opt-in for now
|
|
63
62
|
useCompression, captureOnlyOnError, replaysSamplingRate, recordingConfig: { maskAllInputs, blockClass, ignoreClass, maskTextClass, ...recordingOptions }, }?: SentryReplayConfiguration);
|
|
64
63
|
/**
|
|
@@ -220,6 +219,6 @@ export declare class SentryReplay implements Integration {
|
|
|
220
219
|
/**
|
|
221
220
|
* Finalize and send the current replay event to Sentry
|
|
222
221
|
*/
|
|
223
|
-
sendReplay(eventId: string, events:
|
|
222
|
+
sendReplay(eventId: string, events: RecordedEvents): Promise<boolean>;
|
|
224
223
|
}
|
|
225
224
|
export {};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
export declare const REPLAY_SESSION_KEY = "sentryReplaySession";
|
|
2
|
-
export declare const
|
|
3
|
-
export declare const
|
|
2
|
+
export declare const REPLAY_EVENT_NAME = "replay_event";
|
|
3
|
+
export declare const RECORDING_EVENT_NAME = "replay_recording";
|
|
4
4
|
export declare const SESSION_IDLE_DURATION = 900000;
|
|
5
5
|
export declare const VISIBILITY_CHANGE_TIMEOUT = 900000;
|
|
@@ -2,9 +2,10 @@ import { record } from 'rrweb';
|
|
|
2
2
|
import type { eventWithTime } from 'rrweb/typings/types';
|
|
3
3
|
export declare type RecordingEvent = eventWithTime;
|
|
4
4
|
export declare type RecordingConfig = Parameters<typeof record>[0];
|
|
5
|
+
export declare type RecordedEvents = Uint8Array | string;
|
|
5
6
|
export interface ReplayRequest {
|
|
6
7
|
endpoint: string;
|
|
7
|
-
events:
|
|
8
|
+
events: RecordedEvents;
|
|
8
9
|
}
|
|
9
10
|
export declare type InstrumentationTypeBreadcrumb = 'dom' | 'scope';
|
|
10
11
|
export declare type InstrumentationTypeSpan = 'fetch' | 'xhr' | 'history';
|
package/dist/dist/index.d.ts
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import { Breadcrumb,
|
|
1
|
+
import { Breadcrumb, Event, Integration } from '@sentry/types';
|
|
2
2
|
import { CaptureReplayParams } from './api/captureReplay';
|
|
3
3
|
import { CaptureReplayUpdateParams } from './api/captureReplayUpdate';
|
|
4
4
|
import { Session } from './session/Session';
|
|
5
5
|
import { ReplayPerformanceEntry } from './createPerformanceEntry';
|
|
6
6
|
import { IEventBuffer } from './eventBuffer';
|
|
7
|
-
import type { InstrumentationTypeBreadcrumb, InstrumentationTypeSpan, RecordingConfig, RecordingEvent, ReplayRequest, SentryReplayConfiguration, SentryReplayPluginOptions } from './types';
|
|
7
|
+
import type { InstrumentationTypeBreadcrumb, InstrumentationTypeSpan, RecordedEvents, RecordingConfig, RecordingEvent, ReplayRequest, SentryReplayConfiguration, SentryReplayPluginOptions } from './types';
|
|
8
8
|
/**
|
|
9
9
|
* Returns true to return control to calling function, otherwise continue with normal batching
|
|
10
10
|
*/
|
|
@@ -58,7 +58,6 @@ export declare class SentryReplay implements Integration {
|
|
|
58
58
|
private initialState;
|
|
59
59
|
private context;
|
|
60
60
|
session: Session | undefined;
|
|
61
|
-
static attachmentUrlFromDsn(dsn: DsnComponents, eventId: string): string;
|
|
62
61
|
constructor({ flushMinDelay, flushMaxDelay, initialFlushDelay, stickySession, // TBD: Making this opt-in for now
|
|
63
62
|
useCompression, captureOnlyOnError, replaysSamplingRate, recordingConfig: { maskAllInputs, blockClass, ignoreClass, maskTextClass, ...recordingOptions }, }?: SentryReplayConfiguration);
|
|
64
63
|
/**
|
|
@@ -220,6 +219,6 @@ export declare class SentryReplay implements Integration {
|
|
|
220
219
|
/**
|
|
221
220
|
* Finalize and send the current replay event to Sentry
|
|
222
221
|
*/
|
|
223
|
-
sendReplay(eventId: string, events:
|
|
222
|
+
sendReplay(eventId: string, events: RecordedEvents): Promise<boolean>;
|
|
224
223
|
}
|
|
225
224
|
export {};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
export declare const REPLAY_SESSION_KEY = "sentryReplaySession";
|
|
2
|
-
export declare const
|
|
3
|
-
export declare const
|
|
2
|
+
export declare const REPLAY_EVENT_NAME = "replay_event";
|
|
3
|
+
export declare const RECORDING_EVENT_NAME = "replay_recording";
|
|
4
4
|
export declare const SESSION_IDLE_DURATION = 900000;
|
|
5
5
|
export declare const VISIBILITY_CHANGE_TIMEOUT = 900000;
|
package/dist/dist/types.d.ts
CHANGED
|
@@ -2,9 +2,10 @@ import { record } from 'rrweb';
|
|
|
2
2
|
import type { eventWithTime } from 'rrweb/typings/types';
|
|
3
3
|
export declare type RecordingEvent = eventWithTime;
|
|
4
4
|
export declare type RecordingConfig = Parameters<typeof record>[0];
|
|
5
|
+
export declare type RecordedEvents = Uint8Array | string;
|
|
5
6
|
export interface ReplayRequest {
|
|
6
7
|
endpoint: string;
|
|
7
|
-
events:
|
|
8
|
+
events: RecordedEvents;
|
|
8
9
|
}
|
|
9
10
|
export declare type InstrumentationTypeBreadcrumb = 'dom' | 'scope';
|
|
10
11
|
export declare type InstrumentationTypeSpan = 'fetch' | 'xhr' | 'history';
|
package/dist/index.es.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { captureEvent, getCurrentHub, captureException, addGlobalEventProcessor } from '@sentry/core';
|
|
2
|
-
import {
|
|
1
|
+
import { captureEvent, getCurrentHub, captureException, addGlobalEventProcessor, getEnvelopeEndpointWithUrlEncodedAuth } from '@sentry/core';
|
|
2
|
+
import { htmlTreeAsString, logger as logger$1, uuid4, addInstrumentationHandler, createEnvelope, serializeEnvelope } from '@sentry/utils';
|
|
3
3
|
import { record, EventType } from 'rrweb';
|
|
4
4
|
|
|
5
5
|
/******************************************************************************
|
|
@@ -89,8 +89,7 @@ function __spreadArray(to, from, pack) {
|
|
|
89
89
|
}
|
|
90
90
|
|
|
91
91
|
var REPLAY_SESSION_KEY = 'sentryReplaySession';
|
|
92
|
-
var
|
|
93
|
-
var REPLAY_EVENT_NAME = 'sentry-replay-event';
|
|
92
|
+
var REPLAY_EVENT_NAME = 'replay_event';
|
|
94
93
|
// The idle limit for a session
|
|
95
94
|
var SESSION_IDLE_DURATION = 900000; // 15 minutes
|
|
96
95
|
// Grace period to keep a session when a user changes tabs or hides window
|
|
@@ -99,29 +98,28 @@ var VISIBILITY_CHANGE_TIMEOUT = SESSION_IDLE_DURATION;
|
|
|
99
98
|
function captureReplay(_a) {
|
|
100
99
|
var session = _a.session, initialState = _a.initialState, errorIds = _a.errorIds, traceIds = _a.traceIds, urls = _a.urls;
|
|
101
100
|
captureEvent({
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
// @ts-expect-error replay event type accepts this
|
|
101
|
+
// @ts-expect-error replay_event is a new event type
|
|
102
|
+
type: REPLAY_EVENT_NAME,
|
|
103
|
+
replay_start_timestamp: initialState.timestamp / 1000,
|
|
106
104
|
error_ids: errorIds,
|
|
107
105
|
trace_ids: traceIds,
|
|
108
106
|
urls: urls,
|
|
107
|
+
replay_id: session.id,
|
|
108
|
+
segment_id: session.segmentId, // TODO: Should this increment?
|
|
109
109
|
}, { event_id: session.id });
|
|
110
110
|
}
|
|
111
111
|
|
|
112
112
|
function captureReplayUpdate(_a) {
|
|
113
113
|
var session = _a.session, timestamp = _a.timestamp, errorIds = _a.errorIds, traceIds = _a.traceIds, urls = _a.urls;
|
|
114
114
|
captureEvent({
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
115
|
+
// @ts-expect-error replay_event is a new event type
|
|
116
|
+
type: REPLAY_EVENT_NAME,
|
|
117
|
+
replay_start_timestamp: timestamp / 1000,
|
|
118
118
|
error_ids: errorIds,
|
|
119
119
|
trace_ids: traceIds,
|
|
120
120
|
urls: urls,
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
segmentId: session.segmentId++,
|
|
124
|
-
},
|
|
121
|
+
replay_id: session.id,
|
|
122
|
+
segment_id: ++session.segmentId,
|
|
125
123
|
});
|
|
126
124
|
}
|
|
127
125
|
|
|
@@ -465,6 +463,26 @@ function getSession(_a) {
|
|
|
465
463
|
return { type: 'new', session: newSession };
|
|
466
464
|
}
|
|
467
465
|
|
|
466
|
+
function createPayload(_a) {
|
|
467
|
+
var events = _a.events, headers = _a.headers;
|
|
468
|
+
var payloadWithSequence;
|
|
469
|
+
// XXX: newline is needed to separate sequence id from events
|
|
470
|
+
var replayHeaders = "".concat(JSON.stringify(headers), "\n");
|
|
471
|
+
if (typeof events === 'string') {
|
|
472
|
+
payloadWithSequence = "".concat(replayHeaders).concat(events);
|
|
473
|
+
}
|
|
474
|
+
else {
|
|
475
|
+
var enc = new TextEncoder();
|
|
476
|
+
// XXX: newline is needed to separate sequence id from events
|
|
477
|
+
var sequence = enc.encode(replayHeaders);
|
|
478
|
+
// Merge the two Uint8Arrays
|
|
479
|
+
payloadWithSequence = new Uint8Array(sequence.length + events.length);
|
|
480
|
+
payloadWithSequence.set(sequence);
|
|
481
|
+
payloadWithSequence.set(events, sequence.length);
|
|
482
|
+
}
|
|
483
|
+
return payloadWithSequence;
|
|
484
|
+
}
|
|
485
|
+
|
|
468
486
|
/**
|
|
469
487
|
* Determine if there is browser support for `navigator.sendBeacon`
|
|
470
488
|
*/
|
|
@@ -799,10 +817,11 @@ var SentryReplay = /** @class */ (function () {
|
|
|
799
817
|
* when an error occurs.
|
|
800
818
|
**/
|
|
801
819
|
this.handleGlobalEvent = function (event) {
|
|
802
|
-
var _a
|
|
820
|
+
var _a;
|
|
803
821
|
// Do not apply replayId to the root event
|
|
804
|
-
if (
|
|
805
|
-
|
|
822
|
+
if (
|
|
823
|
+
// @ts-expect-error new event type
|
|
824
|
+
event.type === REPLAY_EVENT_NAME) {
|
|
806
825
|
// Replays have separate set of breadcrumbs, do not include breadcrumbs
|
|
807
826
|
// from core SDK
|
|
808
827
|
delete event.breadcrumbs;
|
|
@@ -810,7 +829,7 @@ var SentryReplay = /** @class */ (function () {
|
|
|
810
829
|
}
|
|
811
830
|
event.tags = __assign(__assign({}, event.tags), { replayId: _this.session.id });
|
|
812
831
|
if (event.type === 'transaction') {
|
|
813
|
-
_this.context.traceIds.add(String(((
|
|
832
|
+
_this.context.traceIds.add(String(((_a = event.contexts) === null || _a === void 0 ? void 0 : _a.trace.trace_id) || ''));
|
|
814
833
|
return event;
|
|
815
834
|
}
|
|
816
835
|
// XXX: Is it safe to assume that all other events are error events?
|
|
@@ -974,12 +993,6 @@ var SentryReplay = /** @class */ (function () {
|
|
|
974
993
|
this.recordingOptions.checkoutEveryNms = 60000;
|
|
975
994
|
}
|
|
976
995
|
}
|
|
977
|
-
SentryReplay.attachmentUrlFromDsn = function (dsn, eventId) {
|
|
978
|
-
var host = dsn.host, projectId = dsn.projectId, protocol = dsn.protocol, publicKey = dsn.publicKey;
|
|
979
|
-
var port = dsn.port !== '' ? ":".concat(dsn.port) : '';
|
|
980
|
-
var path = dsn.path !== '' ? "/".concat(dsn.path) : '';
|
|
981
|
-
return "".concat(protocol, "://").concat(host).concat(port).concat(path, "/api/").concat(projectId, "/events/").concat(eventId, "/attachments/?sentry_key=").concat(publicKey, "&sentry_version=7&sentry_client=replay");
|
|
982
|
-
};
|
|
983
996
|
/**
|
|
984
997
|
* Because we create a transaction in `setupOnce`, we can potentially create a
|
|
985
998
|
* transaction before some native SDK integrations have run and applied their
|
|
@@ -1408,27 +1421,41 @@ var SentryReplay = /** @class */ (function () {
|
|
|
1408
1421
|
SentryReplay.prototype.sendReplayRequest = function (_a) {
|
|
1409
1422
|
var endpoint = _a.endpoint, events = _a.events;
|
|
1410
1423
|
return __awaiter(this, void 0, void 0, function () {
|
|
1411
|
-
var
|
|
1424
|
+
var payloadWithSequence, envelope;
|
|
1412
1425
|
return __generator(this, function (_b) {
|
|
1413
1426
|
switch (_b.label) {
|
|
1414
1427
|
case 0:
|
|
1415
|
-
|
|
1416
|
-
|
|
1417
|
-
|
|
1428
|
+
payloadWithSequence = createPayload({
|
|
1429
|
+
events: events,
|
|
1430
|
+
headers: {
|
|
1431
|
+
segment_id: this.session.segmentId,
|
|
1432
|
+
},
|
|
1418
1433
|
});
|
|
1419
|
-
|
|
1420
|
-
|
|
1434
|
+
envelope = createEnvelope({
|
|
1435
|
+
event_id: this.session.id,
|
|
1436
|
+
sent_at: new Date().toISOString(),
|
|
1437
|
+
sdk: { name: 'sentry.javascript.integration.replay', version: '1.0.0' },
|
|
1438
|
+
}, [
|
|
1439
|
+
[
|
|
1440
|
+
{
|
|
1441
|
+
// @ts-expect-error setting envelope
|
|
1442
|
+
type: 'replay_recording',
|
|
1443
|
+
length: payloadWithSequence.length,
|
|
1444
|
+
},
|
|
1445
|
+
payloadWithSequence,
|
|
1446
|
+
],
|
|
1447
|
+
]);
|
|
1421
1448
|
// If sendBeacon is supported and payload is smol enough...
|
|
1422
|
-
if (supportsSendBeacon() &&
|
|
1449
|
+
if (supportsSendBeacon() && events.length <= 65536) {
|
|
1423
1450
|
logger.log("uploading attachment via sendBeacon()");
|
|
1424
|
-
window.navigator.sendBeacon(endpoint,
|
|
1451
|
+
window.navigator.sendBeacon(endpoint, serializeEnvelope(envelope));
|
|
1425
1452
|
return [2 /*return*/];
|
|
1426
1453
|
}
|
|
1427
1454
|
// Otherwise use `fetch`, which *WILL* get cancelled on page reloads/unloads
|
|
1428
1455
|
logger.log("uploading attachment via fetch()");
|
|
1429
1456
|
return [4 /*yield*/, fetch(endpoint, {
|
|
1430
1457
|
method: 'POST',
|
|
1431
|
-
body:
|
|
1458
|
+
body: serializeEnvelope(envelope),
|
|
1432
1459
|
})];
|
|
1433
1460
|
case 1:
|
|
1434
1461
|
_b.sent();
|
|
@@ -1456,7 +1483,7 @@ var SentryReplay = /** @class */ (function () {
|
|
|
1456
1483
|
return [2 /*return*/];
|
|
1457
1484
|
}
|
|
1458
1485
|
client = getCurrentHub().getClient();
|
|
1459
|
-
endpoint =
|
|
1486
|
+
endpoint = getEnvelopeEndpointWithUrlEncodedAuth(client.getDsn());
|
|
1460
1487
|
_b.label = 1;
|
|
1461
1488
|
case 1:
|
|
1462
1489
|
_b.trys.push([1, 3, , 8]);
|
package/dist/index.js
CHANGED
|
@@ -93,8 +93,7 @@ function __spreadArray(to, from, pack) {
|
|
|
93
93
|
}
|
|
94
94
|
|
|
95
95
|
var REPLAY_SESSION_KEY = 'sentryReplaySession';
|
|
96
|
-
var
|
|
97
|
-
var REPLAY_EVENT_NAME = 'sentry-replay-event';
|
|
96
|
+
var REPLAY_EVENT_NAME = 'replay_event';
|
|
98
97
|
// The idle limit for a session
|
|
99
98
|
var SESSION_IDLE_DURATION = 900000; // 15 minutes
|
|
100
99
|
// Grace period to keep a session when a user changes tabs or hides window
|
|
@@ -103,29 +102,28 @@ var VISIBILITY_CHANGE_TIMEOUT = SESSION_IDLE_DURATION;
|
|
|
103
102
|
function captureReplay(_a) {
|
|
104
103
|
var session = _a.session, initialState = _a.initialState, errorIds = _a.errorIds, traceIds = _a.traceIds, urls = _a.urls;
|
|
105
104
|
core.captureEvent({
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
// @ts-expect-error replay event type accepts this
|
|
105
|
+
// @ts-expect-error replay_event is a new event type
|
|
106
|
+
type: REPLAY_EVENT_NAME,
|
|
107
|
+
replay_start_timestamp: initialState.timestamp / 1000,
|
|
110
108
|
error_ids: errorIds,
|
|
111
109
|
trace_ids: traceIds,
|
|
112
110
|
urls: urls,
|
|
111
|
+
replay_id: session.id,
|
|
112
|
+
segment_id: session.segmentId, // TODO: Should this increment?
|
|
113
113
|
}, { event_id: session.id });
|
|
114
114
|
}
|
|
115
115
|
|
|
116
116
|
function captureReplayUpdate(_a) {
|
|
117
117
|
var session = _a.session, timestamp = _a.timestamp, errorIds = _a.errorIds, traceIds = _a.traceIds, urls = _a.urls;
|
|
118
118
|
core.captureEvent({
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
119
|
+
// @ts-expect-error replay_event is a new event type
|
|
120
|
+
type: REPLAY_EVENT_NAME,
|
|
121
|
+
replay_start_timestamp: timestamp / 1000,
|
|
122
122
|
error_ids: errorIds,
|
|
123
123
|
trace_ids: traceIds,
|
|
124
124
|
urls: urls,
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
segmentId: session.segmentId++,
|
|
128
|
-
},
|
|
125
|
+
replay_id: session.id,
|
|
126
|
+
segment_id: ++session.segmentId,
|
|
129
127
|
});
|
|
130
128
|
}
|
|
131
129
|
|
|
@@ -469,6 +467,26 @@ function getSession(_a) {
|
|
|
469
467
|
return { type: 'new', session: newSession };
|
|
470
468
|
}
|
|
471
469
|
|
|
470
|
+
function createPayload(_a) {
|
|
471
|
+
var events = _a.events, headers = _a.headers;
|
|
472
|
+
var payloadWithSequence;
|
|
473
|
+
// XXX: newline is needed to separate sequence id from events
|
|
474
|
+
var replayHeaders = "".concat(JSON.stringify(headers), "\n");
|
|
475
|
+
if (typeof events === 'string') {
|
|
476
|
+
payloadWithSequence = "".concat(replayHeaders).concat(events);
|
|
477
|
+
}
|
|
478
|
+
else {
|
|
479
|
+
var enc = new TextEncoder();
|
|
480
|
+
// XXX: newline is needed to separate sequence id from events
|
|
481
|
+
var sequence = enc.encode(replayHeaders);
|
|
482
|
+
// Merge the two Uint8Arrays
|
|
483
|
+
payloadWithSequence = new Uint8Array(sequence.length + events.length);
|
|
484
|
+
payloadWithSequence.set(sequence);
|
|
485
|
+
payloadWithSequence.set(events, sequence.length);
|
|
486
|
+
}
|
|
487
|
+
return payloadWithSequence;
|
|
488
|
+
}
|
|
489
|
+
|
|
472
490
|
/**
|
|
473
491
|
* Determine if there is browser support for `navigator.sendBeacon`
|
|
474
492
|
*/
|
|
@@ -803,10 +821,11 @@ var SentryReplay = /** @class */ (function () {
|
|
|
803
821
|
* when an error occurs.
|
|
804
822
|
**/
|
|
805
823
|
this.handleGlobalEvent = function (event) {
|
|
806
|
-
var _a
|
|
824
|
+
var _a;
|
|
807
825
|
// Do not apply replayId to the root event
|
|
808
|
-
if (
|
|
809
|
-
|
|
826
|
+
if (
|
|
827
|
+
// @ts-expect-error new event type
|
|
828
|
+
event.type === REPLAY_EVENT_NAME) {
|
|
810
829
|
// Replays have separate set of breadcrumbs, do not include breadcrumbs
|
|
811
830
|
// from core SDK
|
|
812
831
|
delete event.breadcrumbs;
|
|
@@ -814,7 +833,7 @@ var SentryReplay = /** @class */ (function () {
|
|
|
814
833
|
}
|
|
815
834
|
event.tags = __assign(__assign({}, event.tags), { replayId: _this.session.id });
|
|
816
835
|
if (event.type === 'transaction') {
|
|
817
|
-
_this.context.traceIds.add(String(((
|
|
836
|
+
_this.context.traceIds.add(String(((_a = event.contexts) === null || _a === void 0 ? void 0 : _a.trace.trace_id) || ''));
|
|
818
837
|
return event;
|
|
819
838
|
}
|
|
820
839
|
// XXX: Is it safe to assume that all other events are error events?
|
|
@@ -978,12 +997,6 @@ var SentryReplay = /** @class */ (function () {
|
|
|
978
997
|
this.recordingOptions.checkoutEveryNms = 60000;
|
|
979
998
|
}
|
|
980
999
|
}
|
|
981
|
-
SentryReplay.attachmentUrlFromDsn = function (dsn, eventId) {
|
|
982
|
-
var host = dsn.host, projectId = dsn.projectId, protocol = dsn.protocol, publicKey = dsn.publicKey;
|
|
983
|
-
var port = dsn.port !== '' ? ":".concat(dsn.port) : '';
|
|
984
|
-
var path = dsn.path !== '' ? "/".concat(dsn.path) : '';
|
|
985
|
-
return "".concat(protocol, "://").concat(host).concat(port).concat(path, "/api/").concat(projectId, "/events/").concat(eventId, "/attachments/?sentry_key=").concat(publicKey, "&sentry_version=7&sentry_client=replay");
|
|
986
|
-
};
|
|
987
1000
|
/**
|
|
988
1001
|
* Because we create a transaction in `setupOnce`, we can potentially create a
|
|
989
1002
|
* transaction before some native SDK integrations have run and applied their
|
|
@@ -1412,27 +1425,41 @@ var SentryReplay = /** @class */ (function () {
|
|
|
1412
1425
|
SentryReplay.prototype.sendReplayRequest = function (_a) {
|
|
1413
1426
|
var endpoint = _a.endpoint, events = _a.events;
|
|
1414
1427
|
return __awaiter(this, void 0, void 0, function () {
|
|
1415
|
-
var
|
|
1428
|
+
var payloadWithSequence, envelope;
|
|
1416
1429
|
return __generator(this, function (_b) {
|
|
1417
1430
|
switch (_b.label) {
|
|
1418
1431
|
case 0:
|
|
1419
|
-
|
|
1420
|
-
|
|
1421
|
-
|
|
1432
|
+
payloadWithSequence = createPayload({
|
|
1433
|
+
events: events,
|
|
1434
|
+
headers: {
|
|
1435
|
+
segment_id: this.session.segmentId,
|
|
1436
|
+
},
|
|
1422
1437
|
});
|
|
1423
|
-
|
|
1424
|
-
|
|
1438
|
+
envelope = utils.createEnvelope({
|
|
1439
|
+
event_id: this.session.id,
|
|
1440
|
+
sent_at: new Date().toISOString(),
|
|
1441
|
+
sdk: { name: 'sentry.javascript.integration.replay', version: '1.0.0' },
|
|
1442
|
+
}, [
|
|
1443
|
+
[
|
|
1444
|
+
{
|
|
1445
|
+
// @ts-expect-error setting envelope
|
|
1446
|
+
type: 'replay_recording',
|
|
1447
|
+
length: payloadWithSequence.length,
|
|
1448
|
+
},
|
|
1449
|
+
payloadWithSequence,
|
|
1450
|
+
],
|
|
1451
|
+
]);
|
|
1425
1452
|
// If sendBeacon is supported and payload is smol enough...
|
|
1426
|
-
if (supportsSendBeacon() &&
|
|
1453
|
+
if (supportsSendBeacon() && events.length <= 65536) {
|
|
1427
1454
|
logger.log("uploading attachment via sendBeacon()");
|
|
1428
|
-
window.navigator.sendBeacon(endpoint,
|
|
1455
|
+
window.navigator.sendBeacon(endpoint, utils.serializeEnvelope(envelope));
|
|
1429
1456
|
return [2 /*return*/];
|
|
1430
1457
|
}
|
|
1431
1458
|
// Otherwise use `fetch`, which *WILL* get cancelled on page reloads/unloads
|
|
1432
1459
|
logger.log("uploading attachment via fetch()");
|
|
1433
1460
|
return [4 /*yield*/, fetch(endpoint, {
|
|
1434
1461
|
method: 'POST',
|
|
1435
|
-
body:
|
|
1462
|
+
body: utils.serializeEnvelope(envelope),
|
|
1436
1463
|
})];
|
|
1437
1464
|
case 1:
|
|
1438
1465
|
_b.sent();
|
|
@@ -1460,7 +1487,7 @@ var SentryReplay = /** @class */ (function () {
|
|
|
1460
1487
|
return [2 /*return*/];
|
|
1461
1488
|
}
|
|
1462
1489
|
client = core.getCurrentHub().getClient();
|
|
1463
|
-
endpoint =
|
|
1490
|
+
endpoint = core.getEnvelopeEndpointWithUrlEncodedAuth(client.getDsn());
|
|
1464
1491
|
_b.label = 1;
|
|
1465
1492
|
case 1:
|
|
1466
1493
|
_b.trys.push([1, 3, , 8]);
|