open-feature / js-sdk-contrib Goto Github PK
View Code? Open in Web Editor NEWOpenFeature Providers and Hooks for JavaScript
Home Page: https://openfeature.dev
License: Apache License 2.0
OpenFeature Providers and Hooks for JavaScript
Home Page: https://openfeature.dev
License: Apache License 2.0
I want to add a hook which performs validation using Zod.
Hook
interfaceKeep in mind the CONTRIBUTING guidelines: https://github.com/open-feature/js-sdk-contrib/blob/main/CONTRIBUTING.md
We need to build an experimental flagd-web provider. This should work in accordance with the proposed spec enhancements for client side. It should feature:
An implementation is already partially complete here.
The config cat provider doesn't implement status: https://github.com/open-feature/js-sdk-contrib/blob/main/libs/providers/config-cat/src/lib/config-cat-provider.ts
In order for it to stay functional after this is released, it needs to be updated to set its status
field (it should start with it NOT_READY
and update it to READY
once it's handler is attached.
Flagd sends empty values in flag response payloads when the value is equivalent to the zero-value of the associated go type. We should test that this works as expected and still returns an equivalent zero-value (ie: false
, 0
).
DoD:
Currently the flagd provider doesn't default to unlimited retries, and doesn't throw immediately if it can't start.
See: https://github.com/open-feature/flagd/blob/main/docs/other_resources/creating_providers.md#environment-variables and https://github.com/open-feature/flagd/blob/main/docs/other_resources/creating_providers.md#provider-lifecycle-initialization-and-shutdown
Definition of done:
The Go-Feature-Flag provider doesn't implement status: https://github.com/open-feature/js-sdk-contrib/blob/main/libs/providers/go-feature-flag/src/lib/go-feature-flag-provider.ts
In order for it to stay functional after this is released, it needs to be updated to set its status
field (it should start with it NOT_READY
and update it to READY
once its bgScheduler
interval is started.
Before we try to resolve flag values, we should see if the provider is READY. If not, we should throw the not-ready error. With the current implementation, we'd attempt a gRPC call and then get a "general error".
Please also add the appropriate tests.
Objects returned by flagd are not deserialized as expected:
http:
{
"key": "val"
}
grpc
{
"fields": {
"key": {
"kind": {
"oneofKind": "stringValue",
"stringValue": "val"
}
}
}
}
An upcoming change to the OpenFeature node SDK will remove the context transformer. The Go Feature Flag provider currently uses the context transforming and will be affected by this change. You can see an example of how the provider could look in this PR.
We should support the ability to add custom attributes to traces, as we do with metrics.
We should allow users to supply a function that maps flag metadata
to custom span attributes.
I want to add a provider which stores feature flags in {my-system}. This would be valuable because...
Provider
interfaceKeep in mind the CONTRIBUTING guidelines: https://github.com/open-feature/js-sdk-contrib/blob/main/CONTRIBUTING.md
I want to add an OpenFeature provider for ConfigCat.
This would be valuable because we are using that system in our projects and would like to be able to interface it with OpenFeature.
I would like to implement it and contribute the provider to this repo.
Provider
interfaceKeep in mind the CONTRIBUTING guidelines: https://github.com/open-feature/js-sdk-contrib/blob/main/CONTRIBUTING.md
We probably want to fire a configuration_changed
event on reconnect, in case any events have been missed. To keep things from being too chatty, we can do this only if we're currently in a reconnecting state, so that we don't get a redundant event with the initial ready.
We need to support the creation of web-components. This involves:
The flagd-web provider doesn't implement status: https://github.com/open-feature/js-sdk-contrib/blob/main/libs/providers/go-feature-flag/src/lib/go-feature-flag-provider.ts
In order for it to stay functional after this is released, it needs to be updated to set its status
field (it should start with it NOT_READY
and update it to READY
once its connected.
The OTel hook should include the span attributes when starting the span. This is useful because OTel is able use this information for sampling purposes.
Quickly describe what a hook is and how it can be used. It should also contain a section on how to add a new hook.
I want to add a provider which stores feature flags in LaunchDarkly via client-side JavaScript. This would be valuable because...
Provider
interfaceKeep in mind the CONTRIBUTING guidelines: https://github.com/open-feature/js-sdk-contrib/blob/main/CONTRIBUTING.md
Once the js-sdk has events
and init/shutdown
support, we need to update the flagd-provider to emit events and do proper init/shutdown. We already have a stream implemented for cache-busing, so this should be pretty simple.
Definition of done:
initialize
functionclose/shutdown
functionBlocked by:
I want to add a hook which captures OTel metrics, similar to https://github.com/open-feature/go-sdk-contrib/blob/main/hooks/open-telemetry/pkg/metrics.go
Hook
interfaceAs we have seen in #428 we can introduce breaking changes for some version of NodeJS without noticing it in the CI.
We should be able to build/test in a matrix of versions, at least 16
and the latest version.
The Jest configuration has changed slightly. The repo should be updated accordingly. The OTel hook has already been updated. This approach should be done for the rest of the project (include the NX template).
Originally posted by @toddbaert in #179 (comment)
The flagd provider should start an OTel span that will be passed to flagd to get cross-service tracing for evaluation.
As described in the documentation, hooks are a mechanism that allow for the addition of arbitrary behavior at well-defined points of the flag evaluation life-cycle. Use cases include validation of the resolved flag value, modifying or adding data to the evaluation context, logging, telemetry, and tracking.
This repository has built in tooling for adding hooks. If you have a creative idea for a hook, we welcome your contribution! To add a hook:
Add hook
template found here.We should make our options consistent, including the env vars. I think we want:
| Option name | Environment variable name | Type | Default |
| ----------- | ------------------------- | ------- | --------- |
| host | FLAGD_HOST | string | localhost |
| port | FLAGD_PORT | number | 8013 |
| tls | FLAGD_TLS | boolean | false |
| socketPath | FLAGD_SOCKET_PATH | string | - |
| certPath | FLAGD_SERVER_CERT_PATH | string | - |
We have all of these except FLAGD_SERVER_CERT_PATH
.
The build process current adds external dependencies as peer dependencies. This is likely what we want but we'll need to make it clear what additional packages must be installed.
I want to add an OpenFeature provider for Backstage. This would be valuable because...
Provider
interfaceKeep in mind the CONTRIBUTING guidelines: https://github.com/open-feature/js-sdk-contrib/blob/main/CONTRIBUTING.md
Add a provider generator that makes it easy to start a new provider.
Requirements;
esm
and cjs
package@thomaspoignant just a heads up that the most recent change to the the JS go-feature-flag-provider
here used a feature (structuredClone()
) that is only available in NodeJS 17 and above. This change will break builds for anyone who has the default value from npm install
in their package.json
(which is "@openfeature/go-feature-flag-provider": "^0.5.8"
) and using a NodeJS version either 16 or below.
This should probably be considered a breaking change if not a in the NodeJS world.
For anyone who uses this and finds their build is randomly failing, you can just remove the ^
from the version in package.json
to pin the version so it works for older NodeJS versions.
"@openfeature/go-feature-flag-provider": "^0.5.8"
-> "@openfeature/go-feature-flag-provider": "0.5.8"
Now that OTel 2529 is merged, we should update the (or create a new) Open Telemetry hook.
Basically, this would entail creating a hook which:
after
stage: gets the current span and adds an appropriately named event (feature_flag
), with the attributes (feature_flag.key
, feature_flag.provider_name
, and feature_flag.variant
)error
stage, records the exceptionIn pseudocode, this looks something like:
class OTelHook implements Hook {
after(context, details) {
var currentTrace = trace.getActiveSpan();
currentTrace.addEvent("feature_flag", { "feature_flag.key": details.key, /* other props */ } );
}
error(err) {
var currentTrace = trace.getActiveSpan();
currentTrace.recordException(err);
}
}
Note: For the this repo, we may want to deprecate the old hook.
Trying to import FlagdProvider in Typescript with ESM causes the following error:
node_modules/@openfeature/flagd-provider/src/index.d.ts:1:15 - error TS2834: Relative import paths need explicit file extensions in EcmaScript imports when '--moduleResolution' is 'node16' or 'nodenext'. Consider adding an extension to the import path.
1 export * from './lib/flagd-provider';
~~~~~~~~~~~~~~~~~~~~~~
src/main.ts:2:10 - error TS2305: Module '"@openfeature/flagd-provider"' has no exported member 'FlagdProvider'.
2 import { FlagdProvider } from '@openfeature/flagd-provider';
~~~~~~~~~~~~~
Found 2 errors in 2 files.
Errors Files
1 node_modules/@openfeature/flagd-provider/src/index.d.ts:1
1 src/main.ts:2
When I switch my project to CommonJS the problem is resolved.
I'm not sure if this is a bug or if I'm doing something wrong here.
import { FlagdProvider } from '@openfeature/flagd-provider';
.I also created a simple example repo. Running npm run build
shows the error.
As described in the documentation, providers are responsible for performing flag evaluation. They provide an abstraction between the underlying flag management system and the OpenFeature SDK.
A flag management system could be a vendor solution, a custom feature flag system, or a thin wrapper around some other service, such as a cloud storage solution or an RDBMS.
This repository has built in tooling for adding providers. If you have a creative idea for a provider, we welcome your contribution! To add a provider:
Add provider
template found here.Implement the changes to support the new features of spec 0.6.0.
Initialization is not needed by ConfigCat.
Implement flagd caching.
Example in go: https://github.com/open-feature/go-sdk-contrib/blob/main/providers/flagd/pkg/provider.go
To prepare for the client/server change, the following must be updated:
o Update the generator to support client, server, or both.
o Update badges for existing artifacts.
Fossa has identified license issues with this repo. The only requirement I can see is a requirement to include licenses.
It seems like we may be able to automate this using: https://www.npmjs.com/package/npm-license-crawler. We should do this within each module.
This issue lists Renovate updates and detected dependencies. Read the Dependency Dashboard docs to learn more.
These updates are currently rate-limited. Click on a checkbox below to force their creation now.
These updates have all been created already. Click a checkbox below to force a retry/rebase of any.
@swc/core
, @swc/helpers
)@typescript-eslint/eslint-plugin
, @typescript-eslint/parser
, eslint
, eslint-config-prettier
)These are blocked by an existing closed PR and will not be recreated unless you click a checkbox below.
libs/providers/flagd/docker-compose.yaml
ghcr.io/open-feature/flagd-testbed v0.5.6
ghcr.io/open-feature/flagd-testbed-unstable v0.5.6
ghcr.io/open-feature/sync-testbed v0.5.6
ghcr.io/open-feature/sync-testbed-unstable v0.5.6
.github/workflows/ci.yml
actions/checkout v4
actions/setup-node v4
actions/checkout v4
actions/setup-node v4
.github/workflows/component-owners.yml
dyladan/component-owners a0a1a67d6955b6efe190e9646e0ba536f882414a
.github/workflows/lint-pr.yml
amannn/action-semantic-pull-request v5
marocchino/sticky-pull-request-comment v2
marocchino/sticky-pull-request-comment v2
.github/workflows/release-please.yml
google-github-actions/release-please-action v3
actions/checkout v4
bufbuild/buf-setup-action v1.32.0
actions/setup-node v4
libs/hooks/open-telemetry/package.json
@openfeature/server-sdk ^1.13.0
@opentelemetry/api >=1.3.0
libs/providers/config-cat/package.json
@openfeature/server-sdk ^1.13.0
configcat-js-ssr >=7.1.2
libs/providers/env-var/package.json
@openfeature/server-sdk ^1.13.0
libs/providers/flagd-web/package.json
@openfeature/web-sdk ^1.0.0
libs/providers/flagd/package.json
@grpc/grpc-js ~1.8.0 || ~1.9.0 || ~1.10.0
@openfeature/server-sdk ^1.13.0
libs/providers/flagsmith-client/package.json
tslib ^2.3.0
@openfeature/web-sdk ^1.0.0
flagsmith 4.0.0
libs/providers/flipt-web/package.json
@flipt-io/flipt-client-browser ^0.0.17
tslib ^2.3.0
undici ^6.13.0
@openfeature/web-sdk ^1.0.0
libs/providers/flipt/package.json
tslib ^2.3.0
@openfeature/server-sdk ^1.13.0
@flipt-io/flipt ^1.0.0
libs/providers/go-feature-flag-web/package.json
@openfeature/web-sdk ^1.0.0
libs/providers/go-feature-flag/package.json
@openfeature/server-sdk ^1.15.0
libs/providers/growthbook-client/package.json
tslib ^2.3.0
@growthbook/growthbook ^1.0.0
@openfeature/web-sdk ^1.0.0
libs/providers/launchdarkly-client/package.json
@openfeature/web-sdk ^1.0.0
launchdarkly-js-client-sdk >=3.1.3
libs/providers/multi-provider-web/package.json
tslib ^2.3.0
@openfeature/web-sdk ^1.2.1
libs/providers/multi-provider/package.json
tslib ^2.3.0
@openfeature/server-sdk ^1.6.0
libs/providers/ofrep-web/package.json
tslib ^2.3.0
@openfeature/web-sdk >=0.4.0
libs/providers/ofrep/package.json
tslib ^2.3.0
@openfeature/server-sdk ^1.6.0
libs/shared/flagd-core/package.json
ajv ^8.12.0
tslib ^2.3.0
@openfeature/core >=0.0.16
libs/shared/ofrep-core/package.json
package.json
@bufbuild/protobuf ^1.2.0
@connectrpc/connect ^1.4.0
@connectrpc/connect-web ^1.4.0
@flipt-io/flipt ^1.0.0
@flipt-io/flipt-client-browser ^0.0.17
@growthbook/growthbook ^1.0.0
@grpc/grpc-js ^1.9.13
@opentelemetry/api ^1.3.0
@protobuf-ts/grpc-transport ^2.9.0
@protobuf-ts/runtime-rpc ^2.9.0
@swc/helpers 0.5.11
ajv ^8.12.0
axios 1.6.8
configcat-js-ssr ^8.3.0
copy-anything ^3.0.5
flagsmith ^4.0.0
imurmurhash ^0.1.4
json-logic-engine 1.3.4
launchdarkly-js-client-sdk ^3.1.3
lodash.isempty ^4.4.0
lodash.isequal ^4.5.0
lru-cache ^10.0.0
object-hash ^3.0.0
tslib 2.6.2
@openfeature/core ^1.1.0
@openfeature/server-sdk ^1.13.2
@openfeature/web-sdk ^1.1.0
@opentelemetry/sdk-metrics ^1.15.0
@swc-node/register ~1.10.0
@swc/cli ~0.4.0
@swc/core 1.6.13
@types/assert ^1.5.6
@types/events ^3.0.0
@types/imurmurhash ^0.1.3
@types/jest 29.5.12
@types/lodash.isempty ^4.4.7
@types/lodash.isequal ^4.5.6
@types/node 20.14.10
@types/object-hash ^3.0.0
@types/semver ^7.5.4
@typescript-eslint/eslint-plugin 5.62.0
@typescript-eslint/parser 5.62.0
assert ^2.0.0
axios-mock-adapter 1.22.0
babel-preset-minify 0.5.2
@bufbuild/buf ^1.34.0
eslint 8.57.0
eslint-config-prettier 8.10.0
eslint-plugin-prettier ^5.0.1
fetch-mock-jest ^1.5.1
jest ^29.4.1
jest-cucumber ^4.4.0
jest-environment-jsdom ^29.4.1
jest-fetch-mock ^3.0.3
jest-websocket-mock ^2.4.0
jsonc-eslint-parser ^2.1.0
msw ^2.2.3
prettier ^3.0.3
testcontainers 10.10.3
ts-jest 29.2.2
ts-node 10.9.2
typescript 5.5.3
undici ^5.0.0
tools/workspace-plugin/package.json
.nvmrc
node 20
Hello everybody, don't really know if this is the correct process but we want to get launch darkly working for our frontend use case.
There is a provider but there are couple of issues:
@openfeature/js-sdk
for types, prefered in this case should be @openfeature/web-sdk
I opened a PR #418 that handles this issues, it has been tested in one of our frontend applications, the motivation for this change is basically to get the ball rolling and use the provider.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.