Conversation
There was a problem hiding this comment.
It seems you are using https://splitio.jfrog.io registry for installing dependencies (probably you are using your credentials for the webconsole). So, consider removing the package-lock.json file, running npm install again without any credentials, and submit the change.
This way, package-lock will use the public NPM registry, and if the project is made public, anyone might run npm install on their side.
There was a problem hiding this comment.
Makes sense, but sorry I am new to JS, how can I run npm install without credentials?
There was a problem hiding this comment.
I think the following steps should work:
- Open your
~/.npmrcfile and comment (# ...) or remove your credentials there.
The file should look something like:
init-author-name=Your Name
# registry=https://splitio.jfrog.io/artifactory/api/npm/npm-all-virtual/
# //splitio.jfrog.io/artifactory/api/npm/npm-all-virtual/:_auth = XXX
# always-auth = true
- Delete the package-lock.file.
- Run
npm installagain. - Revert changes in 1st step.
| metadata = { | ||
| name: "split", | ||
| }; | ||
| private initialized: Promise<void>; |
There was a problem hiding this comment.
initialized promise should be used somewhere. Maybe inside the onContextChange method part of the Provider interface?
(Definitively not inside the resolve<Boolean|String|...>Evaluation methods, because unlike the server-side OpenFeature Provider, they are synchronous).
That promise should somehow be used to wait for the provider to be ready and support:
await OpenFeature.setProviderAndWait(new OpenFeatureSplitProvider({splitClient}));
as explained here: https://www.npmjs.com/package/@openfeature/web-sdk#awaitable
There was a problem hiding this comment.
im actually having trouble figure out where this would be used, or if it is even necessary? I am kind of thinking it might not be, but not confident. How do you think it should be used in the onContextChange method?
There was a problem hiding this comment.
Yes, I guess it's not mandatory to use, because users can evaluate anyway (e.g., const boolValue = client.getBooleanValue('boolFlag', false);), and if the client is not ready, the method call will retrieve the provided default value.
But it's nice to have if users can use the await OpenFeature.setProviderAndWait(...); method to start evaluating once the Split client is ready.
Anyway, I also don't know how the promise can be used for that, in which part of the provider should be used :/
| import type SplitIO from "@splitsoftware/splitio/types/splitio"; | ||
|
|
||
| export interface SplitProviderOptions { | ||
| splitClient: SplitIO.IClient; |
There was a problem hiding this comment.
For the Web use splitClient: SplitIO.IBrowserClient;
This changes the interface compared to server-side (Node.js SDK), because the getTreatment methods doesn't require a traffic type key as first argument.
In client-side (JS Browser SDK), the key is provided in the SDK configuration, or when calling the factory.client(key) method.
There was a problem hiding this comment.
For the OpenFeature spec we need to be able to implement evaluations with a provided key, it seems like using the IBrowserClient would not allow us to do that right?
There was a problem hiding this comment.
Not like Node.js (server-side API, IClient).
In the Web (client-side API, IBrowserClient), you can use the SDK factory instance to retrieve clients for different keys than the default one provided in the config:
const newClient: SplitIO.IBrowserClient = splitFactory.client('new-targeting-key');That's why I suggest in the README to pass the factory instance to the provider, rather than the default Split client: #2
const splitFactory = SplitFactory({
core: {
authorizationKey,
key: targetingKey
}
});
const provider = new OpenFeatureSplitProvider({splitFactory});
Update README to follow OpenFeature Web SDK API
|
branch migrated to |
No description provided.