We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 6ffdce0 commit 5a8c6b3Copy full SHA for 5a8c6b3
7 files changed
packages/core/src/types-hoist/replay.ts
@@ -9,6 +9,7 @@ export interface ReplayEvent extends Event {
9
replay_start_timestamp?: number;
10
error_ids: string[];
11
trace_ids: string[];
12
+ // Data expected is [timestamp (seconds), trace id]
13
traces_by_timestamp: [number, string][];
14
replay_id: string;
15
segment_id: number;
packages/replay-internal/src/replay.ts
@@ -1140,7 +1140,16 @@ export class ReplayContainer implements ReplayContainerInterface {
1140
if (this._context.traceIds.length === 0) {
1141
const currentTraceId = getCurrentScope().getPropagationContext().traceId;
1142
if (currentTraceId) {
1143
- this._context.traceIds.push([-1, currentTraceId]);
+ // Previously, in order to associate a replay with a trace, sdk waits
1144
+ // until after a `type: transaction` event is sent successfully. it's
1145
+ // possible that the replay integration is loaded after this event is
1146
+ // sent and never gets associated with any trace. in this case, use the
1147
+ // trace from current scope and propagation context. We associate the
1148
+ // current trace w/ the earliest timestamp in event buffer.
1149
+ //
1150
+ // This is in seconds to be consistent with how we normally collect
1151
+ // trace ids from the SDK hook event
1152
+ this._context.traceIds.push([this._context.initialTimestamp / 1000, currentTraceId]);
1153
}
1154
1155
const _context = {
packages/replay-internal/src/util/sendReplayRequest.ts
@@ -44,9 +44,7 @@ export async function sendReplayRequest({
44
timestamp: timestamp / 1000,
45
error_ids: errorIds,
46
trace_ids: uniqueTraceIds,
47
- traces_by_timestamp: traceIds
48
- .filter(([_ts, traceId]) => uniqueTraceIds.includes(traceId))
49
- .map(([ts, traceId]) => [ts, traceId]),
+ traces_by_timestamp: traceIds.map(([ts, traceId]) => [ts, traceId]),
50
urls,
51
replay_id: replayId,
52
segment_id,
packages/replay-internal/test/integration/coreHandlers/handleAfterSendEvent.test.ts
@@ -53,7 +53,7 @@ describe('Integration | coreHandlers | handleAfterSendEvent', () => {
53
handler(error4, { statusCode: undefined });
54
55
expect(Array.from(replay.getContext().errorIds)).toEqual(['err2']);
56
- expect(Array.from(replay.getContext().traceIds)).toEqual([[-1, expect.any(String)]]);
+ expect(Array.from(replay.getContext().traceIds)).toEqual([[expect.any(Number), expect.any(String)]]);
57
});
58
59
it('records traceIds from sent transaction events', async () => {
@@ -122,7 +122,7 @@ describe('Integration | coreHandlers | handleAfterSendEvent', () => {
122
.fill(undefined)
123
.map((_, i) => `err-${i}`),
124
);
125
- expect(replay.getContext().traceIds).toEqual([[-1, expect.any(String)]]);
+ expect(replay.getContext().traceIds).toEqual([[expect.any(Number), expect.any(String)]]);
126
127
128
it('limits traceIds to max. 100', async () => {
packages/replay-internal/test/integration/errorSampleRate.test.ts
@@ -723,7 +723,7 @@ describe('Integration | errorSampleRate', () => {
723
timestamp: (BASE_TIMESTAMP + DEFAULT_FLUSH_MIN_DELAY + DEFAULT_FLUSH_MIN_DELAY) / 1000,
724
error_ids: [expect.any(String)],
725
trace_ids: [expect.any(String)],
726
- traces_by_timestamp: [[-1, expect.any(String)]],
+ traces_by_timestamp: [[expect.any(Number), expect.any(String)]],
727
urls: ['http://localhost:3000/'],
728
replay_id: expect.any(String),
729
}),
@@ -932,7 +932,7 @@ describe('Integration | errorSampleRate', () => {
932
replay_start_timestamp: (BASE_TIMESTAMP + stepDuration * steps) / 1000,
933
934
935
936
937
938
packages/replay-internal/test/integration/sendReplayEvent.test.ts
@@ -341,7 +341,7 @@ describe('Integration | sendReplayEvent', () => {
341
// timestamp is set on first try, after 5s flush
342
timestamp: (BASE_TIMESTAMP + 5000) / 1000,
343
344
345
346
347
recordingPayloadHeader: { segment_id: 0 },
packages/replay-internal/test/integration/session.test.ts
@@ -252,7 +252,7 @@ describe('Integration | session', () => {
252
initialTimestamp: newTimestamp - DEFAULT_FLUSH_MIN_DELAY,
253
urls: [],
254
errorIds: new Set(),
255
- traceIds: [[-1, expect.any(String)]],
+ traceIds: [[expect.any(Number), expect.any(String)]],
256
257
258
0 commit comments