Skip to content

Conversation

@kinyoklion
Copy link
Member

For review after the addition of the releaser config.

Adds basic logging support, and logs in a few places.

@shortcut-integration
Copy link

This pull request has been linked to Shortcut Story #170667: Add logging to the node OpenFeature provider..

@@ -0,0 +1,67 @@
import { LDLogger } from 'launchdarkly-node-server-sdk';
Copy link
Member Author

Choose a reason for hiding this comment

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

This is mostly a duplicate of the js-server-sdk. Possibly that could be exported in that version, so we wouldn't duplicate it.

The OpenFeature sdk also has basically the same code in it. Also not exported.

Choose a reason for hiding this comment

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

I'd rather not export it in the SDK module, because it's an implementation detail that we'd rather not have to maintain without breaking changes for application use. Exporting it from a common package would be a different matter, since that stuff can be versioned separately and is explicitly for our own consumption.

addCustom(convertedContext, key, value as boolean[]);
} else if (value.every((val) => typeof val === 'number')) {
addCustom(convertedContext, key, value as string[]);
} else {
Copy link
Member Author

Choose a reason for hiding this comment

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

This conversion is a bit more strict, because it matched the actual .d.ts. Hopefully we don't have this long though, as U2C does support these types.

Choose a reason for hiding this comment

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

Hmm... I don't think it was ever correct to say that a custom attribute that's an array must have every element be the same type. I mean, the LD data model and evaluation algorithm had no such restriction. I think that may have been a misunderstanding based on the fact that some older SDK versions (I'm thinking of Java) had custom attribute setters for "array of booleans", etc. because we thought those would be common use cases.

Copy link
Member Author

Choose a reason for hiding this comment

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

I will adjust this a bit.

Choose a reason for hiding this comment

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

That is— an LD user whose JSON representation is {"key": "a", "custom": {"b": [1, "yes", true]}} is a valid user, and every implementation of the LD evaluation engine, as far as I know, will let you evaluate a clause like {"attribute": "b", "op": "in", "values": [2, "yes"]} against that user. Mixing types doesn't hurt anything, it just means that any operators that can't be applied to the type of one of the elements will be a non-match for that element. In my example, it would be a match because there is at least one element value in the user attribute ("yes") that is a match for one of the values in the clause.

Copy link
Member Author

Choose a reason for hiding this comment

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

When I had put the check in earlier I had put it in wrong for whatever reason. Now it complies correctly. Which is that it is an array of that type union. Not arrays of each type. Removed the mixed type test as well. It does only allow the types in the .d.ts still. Which is still probably more restrictive than it really has been.

@kinyoklion kinyoklion marked this pull request as ready for review September 26, 2022 21:13
Base automatically changed from rlamb/sc-169460/add-releaser-config to main September 26, 2022 22:26
@kinyoklion kinyoklion merged commit 8e82dac into main Sep 26, 2022
@kinyoklion kinyoklion deleted the rlamb/sc-170667/add-logging-support branch September 26, 2022 22:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants