Skip to content

Commit 19c5afc

Browse files
committed
rename function, delete optional chaining
1 parent 3b51968 commit 19c5afc

File tree

4 files changed

+13
-13
lines changed

4 files changed

+13
-13
lines changed

packages/core/src/tracing/dynamicSamplingContext.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ import {
1010
import type { DynamicSamplingContext } from '../types-hoist/envelope';
1111
import type { Span } from '../types-hoist/span';
1212
import { baggageHeaderToDynamicSamplingContext, dynamicSamplingContextToSentryBaggageHeader } from '../utils/baggage';
13-
import { deriveOrgIdFromClient } from '../utils/dsn';
13+
import { extractOrgIdFromClient } from '../utils/dsn';
1414
import { hasSpansEnabled } from '../utils/hasSpansEnabled';
1515
import { addNonEnumerableProperty } from '../utils/object';
1616
import { getRootSpan, spanIsSampled, spanToJSON } from '../utils/spanUtils';
@@ -51,7 +51,7 @@ export function getDynamicSamplingContextFromClient(trace_id: string, client: Cl
5151
release: options.release,
5252
public_key,
5353
trace_id,
54-
org_id: deriveOrgIdFromClient(client),
54+
org_id: extractOrgIdFromClient(client),
5555
};
5656

5757
client.emit('createDsc', dsc);

packages/core/src/utils/dsn.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -135,14 +135,14 @@ export function extractOrgIdFromDsnHost(host: string): string | undefined {
135135
*
136136
* The organization ID is extracted from the DSN. If the client options include a `orgId`, this will always take precedence.
137137
*/
138-
export function deriveOrgIdFromClient(client: Client): string | undefined {
138+
export function extractOrgIdFromClient(client: Client): string | undefined {
139139
const options = client.getOptions();
140140

141141
const { host } = client.getDsn() || {};
142142

143143
let org_id: string | undefined;
144144

145-
if (options?.orgId) {
145+
if (options.orgId) {
146146
org_id = String(options.orgId);
147147
} else if (host) {
148148
org_id = extractOrgIdFromDsnHost(host);

packages/core/src/utils/tracing.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import type { PropagationContext } from '../types-hoist/tracing';
44
import type { TraceparentData } from '../types-hoist/transaction';
55
import { debug } from '../utils/debug-logger';
66
import { baggageHeaderToDynamicSamplingContext } from './baggage';
7-
import { deriveOrgIdFromClient } from './dsn';
7+
import { extractOrgIdFromClient } from './dsn';
88
import { parseSampleRate } from './parseSampleRate';
99
import { generateSpanId, generateTraceId } from './propagationContext';
1010

@@ -136,7 +136,7 @@ function getSampleRandFromTraceparentAndDsc(
136136
* See https://develop.sentry.dev/sdk/telemetry/traces/#stricttracecontinuation
137137
*/
138138
export function shouldContinueTrace(client: Client, baggageOrgId?: string): boolean {
139-
const clientOrgId = deriveOrgIdFromClient(client);
139+
const clientOrgId = extractOrgIdFromClient(client);
140140

141141
// Case: baggage orgID and Client orgID don't match - always start new trace
142142
if (baggageOrgId && clientOrgId && baggageOrgId !== clientOrgId) {
@@ -146,7 +146,7 @@ export function shouldContinueTrace(client: Client, baggageOrgId?: string): bool
146146
return false;
147147
}
148148

149-
const strictTraceContinuation = client.getOptions()?.strictTraceContinuation || false; // default for `strictTraceContinuation` is `false`
149+
const strictTraceContinuation = client.getOptions().strictTraceContinuation || false; // default for `strictTraceContinuation` is `false`
150150

151151
if (strictTraceContinuation) {
152152
// With strict continuation enabled, don't continue trace if:

packages/core/test/lib/utils/dsn.test.ts

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { beforeEach, describe, expect, it, test, vi } from 'vitest';
22
import { DEBUG_BUILD } from '../../../src/debug-build';
33
import { debug } from '../../../src/utils/debug-logger';
4-
import { deriveOrgIdFromClient, dsnToString, extractOrgIdFromDsnHost, makeDsn } from '../../../src/utils/dsn';
4+
import { dsnToString, extractOrgIdFromClient, extractOrgIdFromDsnHost, makeDsn } from '../../../src/utils/dsn';
55
import { getDefaultTestClientOptions, TestClient } from '../../mocks/client';
66

77
function testIf(condition: boolean) {
@@ -249,7 +249,7 @@ describe('extractOrgIdFromDsnHost', () => {
249249
});
250250
});
251251

252-
describe('deriveOrgIdFromClient', () => {
252+
describe('extractOrgIdFromClient', () => {
253253
let client: TestClient;
254254

255255
beforeEach(() => {
@@ -264,7 +264,7 @@ describe('deriveOrgIdFromClient', () => {
264264
}),
265265
);
266266

267-
const result = deriveOrgIdFromClient(client);
267+
const result = extractOrgIdFromClient(client);
268268
expect(result).toBe('00222111');
269269
});
270270

@@ -276,7 +276,7 @@ describe('deriveOrgIdFromClient', () => {
276276
}),
277277
);
278278

279-
const result = deriveOrgIdFromClient(client);
279+
const result = extractOrgIdFromClient(client);
280280
expect(result).toBe('12345');
281281
});
282282

@@ -287,14 +287,14 @@ describe('deriveOrgIdFromClient', () => {
287287
}),
288288
);
289289

290-
const result = deriveOrgIdFromClient(client);
290+
const result = extractOrgIdFromClient(client);
291291
expect(result).toBe('012300');
292292
});
293293

294294
test('returns undefined when neither options.orgId nor DSN host are available', () => {
295295
client = new TestClient(getDefaultTestClientOptions({}));
296296

297-
const result = deriveOrgIdFromClient(client);
297+
const result = extractOrgIdFromClient(client);
298298
expect(result).toBeUndefined();
299299
});
300300
});

0 commit comments

Comments
 (0)