Skip to content
Open
Show file tree
Hide file tree
Changes from 1 commit
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
3 changes: 3 additions & 0 deletions packages/flagging/src/openfeature/provider.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,11 @@ describe('DatadogProvider', () => {

beforeEach(() => {
provider = new DatadogProvider({
apiKey: 'xxx',
applicationKey: 'xxx',
applicationId: 'xxx',
clientToken: 'xxx',
env: 'test',
baseUrl: 'http://localhost:8000',
})
mockLogger = {
Expand Down
28 changes: 21 additions & 7 deletions packages/flagging/src/openfeature/provider.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import type {
Provider,
EvaluationContext,
JsonValue,
Logger,
Paradigm,
Provider,
ProviderMetadata,
ResolutionDetails,
} from '@openfeature/web-sdk'
Expand All @@ -15,14 +15,29 @@ import { evaluate } from '../evaluation'

export type DatadogProviderOptions = {
/**
* The RUM application ID.
* The API key for Datadog. Required for authenticating your application with Datadog.
*/
apiKey: string
/**
* The application key for Datadog. Required for authenticating your application with Datadog.
*/
applicationKey: string

/**
* The application key for Datadog. Required for initializing the Datadog RUM client.
*/
applicationId: string

/**
* The client token for Datadog. Required for authenticating your application with Datadog.
* The client token for Datadog. Required for initializing the Datadog RUM client.
*/
clientToken: string

/**
* The environment for Datadog.
*/
env: string

baseUrl?: string

initialConfiguration?: Configuration
Expand Down Expand Up @@ -111,13 +126,12 @@ export class DatadogProvider implements Provider {
async function fetchConfiguration(options: DatadogProviderOptions, context: EvaluationContext): Promise<Configuration> {
const baseUrl = options.baseUrl || 'https://dd.datad0g.com'

const parameters = [`application_id=${options.applicationId}`, `client_token=${options.clientToken}`]

const response = await fetch(`${baseUrl}/api/unstable/precompute-assignments?${parameters.join('&')}`, {
const response = await fetch(`${baseUrl}/api/unstable/precompute-assignments`, {
method: 'POST',
headers: {
'Content-Type': 'application/json',
'DD-API-KEY': options.clientToken,
'dd-api-key': options.apiKey,
'dd-application-key': options.applicationKey,
},
body: JSON.stringify({
context,
Expand Down