Skip to content

✨ [FFL-24] add openfeature dependency and datadog provider #3554

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Conversation

leoromanovsky
Copy link
Contributor

@leoromanovsky leoromanovsky commented May 22, 2025

Motivation

Changes

🚧 Adds an open feature provider

This will be the basis for datadog flagging customers interacting with the API. It's methods are not yet implemented.

πŸ› Fix a bug in the license check file

The output was being reported as:

Package.json dependencies and LICENSE-3rdparty.csv mismatch
 In package.json but not in LICENSE-3rdparty.csv:
 []
 In LICENSE-3rdparty.csv but not in package.json:
 []

Script exited with error: Error: Dependencies mismatch
    at /Users/leo.romanovsky/src/browser-sdk/scripts/check-licenses.js:33:11
    at process.processTicksAndRejections (node:internal/process/task_queues:105:5)

This should indicate no error but CI was failing.

βœ”οΈ I validated that the script is working by removing entries for open feature from the license file and verifying that the check works:

 Package.json dependencies and LICENSE-3rdparty.csv mismatch
 In package.json but not in LICENSE-3rdparty.csv:
 [ '@openfeature/core', '@openfeature/web-sdk' ]

Script exited with error: Error: Dependencies mismatch
    at /Users/leo.romanovsky/src/browser-sdk/scripts/check-licenses.js:40:9
    at process.processTicksAndRejections (node:internal/process/task_queues:105:5)

Test instructions

  • Added units tests to verify provider correctness (all functions return false)
Screenshot 2025-05-22 at 2 05 52β€―PM

Checklist

  • Tested locally
  • Tested on staging
  • Added unit tests for this change.
  • Added e2e/integration tests for this change.

@codecov-commenter
Copy link

codecov-commenter commented May 22, 2025

Codecov Report

Attention: Patch coverage is 82.03125% with 23 lines in your changes missing coverage. Please review.

Project coverage is 92.19%. Comparing base (5cf79a7) to head (71afc70).
Report is 1 commits behind head on main.

Files with missing lines Patch % Lines
...g/src/configuration-wire/configurationWireTypes.ts 38.88% 11 Missing ⚠️
packages/flagging/src/precomputeClient.ts 83.33% 10 Missing ⚠️
packages/flagging/src/openfeature/provider.ts 94.44% 1 Missing ⚠️
packages/flagging/test/helpers.ts 83.33% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #3554      +/-   ##
==========================================
- Coverage   92.34%   92.19%   -0.15%     
==========================================
  Files         319      326       +7     
  Lines        8109     8237     +128     
  Branches     1833     1860      +27     
==========================================
+ Hits         7488     7594     +106     
- Misses        621      643      +22     

β˜” View full report in Codecov by Sentry.
πŸ“’ Have feedback on the report? Share it here.

πŸš€ New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • πŸ“¦ JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@leoromanovsky leoromanovsky force-pushed the leo.romanovsky/flagging-sdk-long-running-openfeature-2 branch 2 times, most recently from 0121d00 to fa988b8 Compare May 22, 2025 20:56
@leoromanovsky leoromanovsky marked this pull request as ready for review May 22, 2025 21:05
@leoromanovsky leoromanovsky requested review from a team as code owners May 22, 2025 21:05
@leoromanovsky leoromanovsky requested review from aarsilv and a team May 22, 2025 21:05
@leoromanovsky leoromanovsky changed the title feat: add openfeature dependency and datadog provider (FFL-24) ✨ [FFL-24] add openfeature dependency and datadog provider May 23, 2025
Copy link

@aarsilv aarsilv left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So cool to see this starting to be fleshed out! Nice work working through the OpenFeature spec to build out the stubs.

@@ -1,3 +1,27 @@
# Flagging SDK

This package supports flagging and experimentation by performing evaluation in the browser.

## Initialize
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

❀️

Love the quickstart examples!

Comment on lines 18 to 20
"@openfeature/core": "1.8.0",
"@openfeature/web-sdk": "1.5.0"
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

πŸ‘€

import { StandardResolutionReasons, type EvaluationContext, type Logger } from '@openfeature/core'
import { createDatadogProvider } from './provider'

describe('DatadogProvider', () => {
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

πŸ™Œ


describe('resolveBooleanEvaluation', () => {
it('should return default value with DEFAULT reason', () => {
const result = provider.resolveBooleanEvaluation('test-flag', true, mockContext, mockLogger)
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Interesting they want logger as a fourth argument (package docs). It seems it (and context) can be set at the provider level. Is this just for extra flexibility?

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@aarsilv I don't see a way to set logger on provider level (in provider API). For context, I guess that helps with context switches and it helps for providers in dynamic-context paradigm.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What's even funnier about logger is that OF discourages any logging in resolve methods

import { StandardResolutionReasons } from '@openfeature/core'
import type { Provider } from '@openfeature/web-sdk'

export function createDatadogProvider(): Provider {
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

πŸ“ˆ


async function initializeOpenFeature() {
const datadogFlaggingProvider = createDatadogProvider()
await OpenFeature.setContext(subject)
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

presumably after this is where we could also call setLogger() (package docs)

return (
<div>
<h1>Home</h1>
<h2>Flagging Evaluation</h2>
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

πŸ™Œ

}
printLog('Dependencies check done.')
throw new Error('Dependencies mismatch')
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the cleanup and fixing here! πŸ”§ 🧹

@leoromanovsky leoromanovsky force-pushed the leo.romanovsky/flagging-sdk-long-running-scaffold-1 branch from c32ec4e to d7c9863 Compare May 23, 2025 17:04
Base automatically changed from leo.romanovsky/flagging-sdk-long-running-scaffold-1 to main May 23, 2025 17:53
@leoromanovsky leoromanovsky force-pushed the leo.romanovsky/flagging-sdk-long-running-openfeature-2 branch from 4a6d5e5 to 02ef932 Compare May 23, 2025 20:33
@DataDog DataDog deleted a comment from dd-devflow bot May 23, 2025
@DataDog DataDog deleted a comment from dd-devflow bot May 23, 2025
@leoromanovsky leoromanovsky force-pushed the leo.romanovsky/flagging-sdk-long-running-openfeature-2 branch 2 times, most recently from 862769f to 3078f1b Compare May 27, 2025 21:40
@leoromanovsky leoromanovsky force-pushed the leo.romanovsky/flagging-sdk-long-running-openfeature-2 branch from 3078f1b to 044fd8c Compare May 27, 2025 22:57
@@ -18,13 +18,18 @@
"@datadog/browser-core": "6.8.0"
},
"peerDependencies": {
"@datadog/browser-rum": "6.8.0"
"@datadog/browser-rum": "6.8.0",
"@openfeature/web-sdk": "1.5.0"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

question: is this a peer dependency the customer will need to install to use the flagging package?

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes. Our provider is a plugin for OpenFeature SDK

@leoromanovsky
Copy link
Contributor Author

closing to work on #3571

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants