Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions packages/core/src/domain/configuration/endpointBuilder.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,10 @@ import type { InitConfiguration } from './configuration'
// replaced at build time
declare const __BUILD_ENV__SDK_VERSION__: string

// Note: 'flagevaluation' is intentionally not wired into TransportConfiguration or computeEndpointBuilders.
// It is used by external SDK packages (e.g. @datadog/openfeature-browser) via the public
// createFlagEvaluationEndpointBuilder function. Adding it here makes the intake path
// (/api/v2/flagevaluation) an explicit part of the contract.
export type TrackType = 'logs' | 'rum' | 'replay' | 'profile' | 'exposures' | 'flagevaluation'
export type ApiType =
| 'fetch'
Expand Down Expand Up @@ -56,6 +60,15 @@ function createEndpointUrlWithParametersBuilder(
return (parameters) => `https://${host}${path}?${parameters}`
}

/**
* Build an EndpointBuilder for the flagevaluation intake track. Intended for use by external SDK
* packages (e.g. @datadog/openfeature-browser) that need to send flag evaluation data to the
* Datadog intake without depending on internal browser-core APIs.
*/
export function createFlagEvaluationEndpointBuilder(initConfiguration: InitConfiguration, extraParameters?: string[]) {
return createEndpointBuilder(initConfiguration, 'flagevaluation', extraParameters)
}

export function buildEndpointHost(
trackType: TrackType,
initConfiguration: InitConfiguration & { usePciIntake?: boolean }
Expand Down
2 changes: 1 addition & 1 deletion packages/core/src/domain/configuration/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,5 @@ export {
serializeConfiguration,
} from './configuration'
export type { EndpointBuilder, TrackType } from './endpointBuilder'
export { createEndpointBuilder, buildEndpointHost } from './endpointBuilder'
export { createEndpointBuilder, buildEndpointHost, createFlagEvaluationEndpointBuilder } from './endpointBuilder'
export { computeTransportConfiguration, isIntakeUrl } from './transportConfiguration'
1 change: 1 addition & 0 deletions packages/core/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ export {
isSampleRate,
buildEndpointHost,
isIntakeUrl,
createFlagEvaluationEndpointBuilder,
} from './domain/configuration'
export * from './domain/intakeSites'
export type { TrackingConsentState } from './domain/trackingConsent'
Expand Down
Loading