Skip to content

Commit 4582d56

Browse files
committed
feat(replays): add replay_id to dynamic sampling context
1 parent 766a00b commit 4582d56

File tree

3 files changed

+12
-2
lines changed

3 files changed

+12
-2
lines changed

packages/tracing/src/browser/request.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -160,6 +160,7 @@ export function fetchCallback(
160160
shouldAttachHeaders: (url: string) => boolean,
161161
spans: Record<string, Span>,
162162
): void {
163+
console.log(2);
163164
if (!hasTracingEnabled() || !(handlerData.fetchData && shouldCreateSpan(handlerData.fetchData.url))) {
164165
return;
165166
}
@@ -294,6 +295,7 @@ export function xhrCallback(
294295
shouldAttachHeaders: (url: string) => boolean,
295296
spans: Record<string, Span>,
296297
): void {
298+
console.log(1);
297299
if (
298300
!hasTracingEnabled() ||
299301
(handlerData.xhr && handlerData.xhr.__sentry_own_request__) ||

packages/tracing/src/transaction.ts

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ import type {
1212
TransactionMetadata,
1313
} from '@sentry/types';
1414
import { dropUndefinedKeys, logger } from '@sentry/utils';
15-
15+
import { Replay } from '@sentry/replay';
1616
import { Span as SpanClass, SpanRecorder } from './span';
1717

1818
/** JSDoc */
@@ -236,6 +236,7 @@ export class Transaction extends SpanClass implements TransactionInterface {
236236
* @experimental
237237
*/
238238
public getDynamicSamplingContext(): Readonly<Partial<DynamicSamplingContext>> {
239+
console.log('dsc');
239240
if (this._frozenDynamicSamplingContext) {
240241
return this._frozenDynamicSamplingContext;
241242
}
@@ -256,6 +257,12 @@ export class Transaction extends SpanClass implements TransactionInterface {
256257

257258
const source = this.metadata.source;
258259

260+
const replay = client.getIntegration(Replay);
261+
262+
console.log(replay);
263+
// @ts-ignore
264+
const replayId = replay?._replay.session.id;
265+
259266
// We don't want to have a transaction name in the DSC if the source is "url" because URLs might contain PII
260267
const transaction = source && source !== 'url' ? this.name : undefined;
261268

@@ -267,6 +274,7 @@ export class Transaction extends SpanClass implements TransactionInterface {
267274
public_key,
268275
trace_id: this.traceId,
269276
sample_rate,
277+
replayId,
270278
});
271279

272280
// Uncomment if we want to make DSC immutable

packages/utils/src/instrument.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ function instrument(type: InstrumentHandlerType): void {
4848

4949
switch (type) {
5050
case 'console':
51-
instrumentConsole();
51+
// instrumentConsole();
5252
break;
5353
case 'dom':
5454
instrumentDOM();

0 commit comments

Comments
 (0)