-
Notifications
You must be signed in to change notification settings - Fork 62
feat(launchdarkly-provider): Add new provider #343
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
Merged
Merged
Changes from all commits
Commits
Show all changes
12 commits
Select commit
Hold shift + click to select a range
6fb69de
feat(launchdarkly-provider): Add new provider
Mateoc 7fef5c7
chore(launchdarkly-provider): Add sample on README.md
Mateoc 1778b5c
refactor(launchdarkly-provider): Provider now use @openfeature/web-sd…
Mateoc 08cafef
fix(deps): update dependency @protobuf-ts/grpc-transport to v2.9.0 (#…
renovate[bot] 829b052
chore(launchdarkly-provider): Address pull request comments.
Mateoc 816dbda
chore(launchdarkly-provider): Address pull request review comments, s…
Mateoc 1a84e35
chore(launchdarkly-provider): Address pull request review comments, i…
Mateoc 2b3af42
refactor(launchdarkly-provider): Check for context changes on initial…
Mateoc 4258fbf
chore(launchdarkly-provider): Review linter issues
Mateoc 1d4e808
chore(launchdarkly-provider): Fix dependencies to use main package.js…
Mateoc fb1e896
fixup: deps
toddbaert e0d8e26
Update package.json
toddbaert File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,18 @@ | ||
| { | ||
| "extends": ["../../../.eslintrc.json"], | ||
| "ignorePatterns": ["!**/*"], | ||
| "overrides": [ | ||
| { | ||
| "files": ["*.ts", "*.tsx", "*.js", "*.jsx"], | ||
| "rules": {} | ||
| }, | ||
| { | ||
| "files": ["*.ts", "*.tsx"], | ||
| "rules": {} | ||
| }, | ||
| { | ||
| "files": ["*.js", "*.jsx"], | ||
| "rules": {} | ||
| } | ||
| ] | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,49 @@ | ||
| # launchdarkly-client Provider | ||
|
|
||
|  | ||
|
|
||
toddbaert marked this conversation as resolved.
Show resolved
Hide resolved
toddbaert marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| An unofficial browser provider for LaunchDarkly. | ||
|
|
||
| ## Installation | ||
|
|
||
| ``` | ||
| $ npm install @openfeature/launchdarkly-client-provider | ||
| ``` | ||
|
|
||
| ## Sample initialization | ||
| ``` ts | ||
| // init launchdarkly-js-client-sdk | ||
| const initialContext = { | ||
| anonymous: true, | ||
| }; | ||
| const ldClient = initialize('LDId', initialContext); | ||
| await ldClient.waitForInitialization(); | ||
| const ldOpenFeatureProvider = new LaunchDarklyClientProvider(ldClient); | ||
|
|
||
| //set open feature provider and get client | ||
| OpenFeature.setProvider(ldOpenFeatureProvider); | ||
| const client = OpenFeature.getClient('my-client'); | ||
|
|
||
| //use client | ||
| const boolValue = client.getBooleanValue('boolFlag', false); | ||
| ``` | ||
| ## Update Context | ||
| For context update always use ``OpenFeature.setContext(myNewContext);`` instead of ``ldClient.identify(myNewContext);``, as this will always be handled internally. | ||
toddbaert marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
|
||
| Please note that context changes result in network traffic, so changes should be made sparingly in accordance to relevant user behavior. | ||
| ``` ts | ||
| await OpenFeature.setContext({ targetingKey: 'my-key' }) | ||
| //Laundarkly uses key but this provider tranlates targetingKey to key; | ||
| //So the above is the same as doing | ||
| await OpenFeature.setContext({ key: 'my-key' }); | ||
| ``` | ||
|
|
||
toddbaert marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| Read more about LD contexts [here](https://github.com/launchdarkly/openfeature-node-server#openfeature-specific-considerations) | ||
|
|
||
| ## Building | ||
|
|
||
| Run `nx package providers-launchdarkly-client` to build the library. | ||
|
|
||
| ## Running unit tests | ||
|
|
||
| Run `nx test providers-launchdarkly-client` to execute the unit tests via [Jest](https://jestjs.io). | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,3 @@ | ||
| { | ||
| "presets": [["minify", { "builtIns": false }]] | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,10 @@ | ||
| /* eslint-disable */ | ||
| export default { | ||
| displayName: 'providers-launchdarkly-client', | ||
| preset: '../../../jest.preset.js', | ||
| transform: { | ||
| '^.+\\.[tj]s$': ['ts-jest', { tsconfig: '<rootDir>/tsconfig.spec.json' }], | ||
| }, | ||
| moduleFileExtensions: ['ts', 'js', 'html'], | ||
| coverageDirectory: '../../../coverage/libs/providers/launchdarkly-client', | ||
| }; |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,13 @@ | ||
| { | ||
| "name": "@openfeature/launchdarkly-client-provider", | ||
| "version": "0.0.1", | ||
| "type": "commonjs", | ||
| "scripts": { | ||
| "publish-if-not-exists": "cp $NPM_CONFIG_USERCONFIG .npmrc && if [ \"$(npm show $npm_package_name@$npm_package_version version)\" = \"$(npm run current-version -s)\" ]; then echo 'already published, skipping'; else npm publish --access public; fi", | ||
| "current-version": "echo $npm_package_version" | ||
| }, | ||
| "peerDependencies": { | ||
| "@openfeature/web-sdk": "~0.3.2-experimental", | ||
| "launchdarkly-js-client-sdk": "^3.1.3" | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,76 @@ | ||
| { | ||
| "name": "providers-launchdarkly-client", | ||
| "$schema": "../../../node_modules/nx/schemas/project-schema.json", | ||
| "sourceRoot": "libs/providers/launchdarkly-client/src", | ||
| "projectType": "library", | ||
| "targets": { | ||
| "publish": { | ||
| "executor": "nx:run-commands", | ||
| "options": { | ||
| "command": "npm run publish-if-not-exists", | ||
| "cwd": "dist/libs/providers/launchdarkly-client" | ||
| }, | ||
| "dependsOn": [ | ||
| { | ||
| "projects": "self", | ||
| "target": "package" | ||
| } | ||
| ] | ||
| }, | ||
| "lint": { | ||
| "executor": "@nrwl/linter:eslint", | ||
| "outputs": ["{options.outputFile}"], | ||
| "options": { | ||
| "lintFilePatterns": ["libs/providers/launchdarkly-client/**/*.ts"] | ||
| } | ||
| }, | ||
| "test": { | ||
| "executor": "@nrwl/jest:jest", | ||
| "outputs": ["{workspaceRoot}/coverage/{projectRoot}"], | ||
| "options": { | ||
| "jestConfig": "libs/providers/launchdarkly-client/jest.config.ts", | ||
| "passWithNoTests": true | ||
| }, | ||
| "configurations": { | ||
| "ci": { | ||
| "ci": true, | ||
| "codeCoverage": true | ||
| } | ||
| } | ||
| }, | ||
| "package": { | ||
| "executor": "@nrwl/rollup:rollup", | ||
| "outputs": ["{options.outputPath}"], | ||
| "options": { | ||
| "project": "libs/providers/launchdarkly-client/package.json", | ||
| "outputPath": "dist/libs/providers/launchdarkly-client", | ||
| "entryFile": "libs/providers/launchdarkly-client/src/index.ts", | ||
| "tsConfig": "libs/providers/launchdarkly-client/tsconfig.lib.json", | ||
| "buildableProjectDepsInPackageJsonType": "dependencies", | ||
| "compiler": "tsc", | ||
| "generateExportsField": true, | ||
| "umdName": "launchdarkly-client", | ||
| "external": ["typescript"], | ||
| "format": ["cjs", "esm"], | ||
| "assets": [ | ||
| { | ||
| "glob": "package.json", | ||
| "input": "./assets", | ||
| "output": "./src/" | ||
| }, | ||
| { | ||
| "glob": "LICENSE", | ||
| "input": "./", | ||
| "output": "./" | ||
| }, | ||
| { | ||
| "glob": "README.md", | ||
| "input": "./libs/providers/launchdarkly-client", | ||
| "output": "./" | ||
| } | ||
| ] | ||
| } | ||
| } | ||
| }, | ||
| "tags": [] | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| export * from './lib/launchdarkly-client-provider'; |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.