Skip to content

Commit 0f3dfe2

Browse files
committed
Scope dd_debugger source override to URL building only
The previous commit (09376b1) widened `TransportConfiguration.source` to `TransportSource` so the `dd_debugger` override could ride through it. That forced `Configuration` to redeclare `source: SdkSource` to narrow the inherited type back down for consumers like `defaultContext.ts` (where `RumEvent.source` does not accept `dd_debugger`), and it required overload signatures on `computeTransportConfiguration` to preserve that narrowing at the return-type boundary. None of that is actually necessary: nothing reads `source` off a `TransportConfiguration` outside of `validateAndBuildConfiguration` spreading it into `Configuration`. The override only needs to reach the endpoint builders so the `ddsource` URL parameter gets the right value. Keep the override strictly internal to URL building: - `TransportConfiguration.source` is back to `SdkSource`, matching its pre-09376b12b shape. - `computeTransportConfiguration` drops the overload pair and exposes a single signature with optional `sourceOverride`. - The override is plumbed into `ResolvedSourceInitConfiguration` and flows to the endpoint builders, but the returned struct's `source` is always the validated `SdkSource`. - The redundant `source: SdkSource` redeclaration on `Configuration` is removed. Wire behavior is unchanged: URLs still go out with `?ddsource=dd_debugger&...&dd-evp-origin=browser`.
1 parent 0ee8b66 commit 0f3dfe2

2 files changed

Lines changed: 12 additions & 16 deletions

File tree

packages/core/src/domain/configuration/configuration.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -333,7 +333,6 @@ export interface Configuration extends TransportConfiguration {
333333

334334
// internal
335335
sdkVersion: string | undefined
336-
source: SdkSource
337336
variant: string | undefined
338337
}
339338

packages/core/src/domain/configuration/transportConfiguration.ts

Lines changed: 12 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ export interface TransportConfiguration {
1515
datacenter?: string | undefined
1616
replica?: ReplicaConfiguration
1717
site: Site
18-
source: TransportSource
18+
source: SdkSource
1919
}
2020

2121
export interface ReplicaConfiguration {
@@ -33,27 +33,24 @@ type ResolvedSourceInitConfiguration = Omit<InitConfiguration, 'source'> & {
3333
* Compute the transport configuration (endpoint builders, replica, etc.) for an
3434
* SDK init configuration.
3535
*
36-
* When called without `sourceOverride`, the resulting `source` is whatever was
37-
* provided in `initConfiguration.source` (validated to a `SdkSource`, defaulting
38-
* to `browser`).
39-
*
40-
* When called with `sourceOverride`, that value is used instead.
36+
* `sourceOverride` (if provided) is only used to build the `ddsource` URL
37+
* parameter on outgoing requests; it does not appear on the returned
38+
* `TransportConfiguration.source`, which is always the validated `SdkSource`
39+
* derived from `initConfiguration.source`.
4140
*/
42-
export function computeTransportConfiguration(
43-
initConfiguration: InitConfiguration
44-
): TransportConfiguration & { source: SdkSource }
45-
export function computeTransportConfiguration(
46-
initConfiguration: InitConfiguration,
47-
sourceOverride: TransportSource
48-
): TransportConfiguration
4941
export function computeTransportConfiguration(
5042
initConfiguration: InitConfiguration,
5143
sourceOverride?: TransportSource
5244
): TransportConfiguration {
5345
const site = initConfiguration.site || INTAKE_SITE_US1
54-
const source: TransportSource = sourceOverride ?? validateSource(initConfiguration.source)
46+
const source = validateSource(initConfiguration.source)
47+
const transportSource: TransportSource = sourceOverride ?? source
5548

56-
const resolvedConfiguration: ResolvedSourceInitConfiguration = { ...initConfiguration, site, source }
49+
const resolvedConfiguration: ResolvedSourceInitConfiguration = {
50+
...initConfiguration,
51+
site,
52+
source: transportSource,
53+
}
5754
const endpointBuilders = computeEndpointBuilders(resolvedConfiguration)
5855
const replicaConfiguration = computeReplicaConfiguration(resolvedConfiguration)
5956

0 commit comments

Comments
 (0)