Skip to content
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

feat: New data kinds for edge SDKs. #260

Merged
merged 1 commit into from
Aug 28, 2023

Conversation

kinyoklion
Copy link
Member

Add new data kind support as well as a couple error handling changes.

@@ -44,7 +44,7 @@
"eslint-plugin-prettier": "^5.0.0",
"prettier": "^3.0.0",
"typedoc": "0.23.26",
"typescript": "^5.1.6"
Copy link
Member Author

Choose a reason for hiding this comment

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

The package.json changes will come from main once I merge main in, but I want things in a good state before I attempt to do that.

default:
throw new Error(`Unsupported DataKind: ${namespace}`);
callback(null);
Copy link
Member Author

Choose a reason for hiding this comment

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

If we don't know what it is, then we should just return null I think. (Or empty objects in the all cases.) Versus throwing an exception and then returning null.

If I had not noticed this, then it would have ran, but the edge SDKs would likely have slowed down quite a bit attempting to access fields that didn't exist.

@@ -59,8 +59,14 @@ export class EdgeFeatureStore implements LDFeatureStore {
case 'segments':
callback(item.segments[dataKey]);
break;
case 'configurationOverrides':
Copy link
Member Author

Choose a reason for hiding this comment

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

These two new types are used for event sampling, it will be nice to support that in edge SDKs as well.

@kinyoklion kinyoklion marked this pull request as ready for review August 28, 2023 22:05
Comment on lines +63 to +66
callback(item.configurationOverrides?.[dataKey] ?? null);
break;
case 'metrics':
callback(item.metrics?.[dataKey] ?? null);
Copy link
Contributor

Choose a reason for hiding this comment

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

Is there a difference between passing null and undefined? Usually there's no difference:

Suggested change
callback(item.configurationOverrides?.[dataKey] ?? null);
break;
case 'metrics':
callback(item.metrics?.[dataKey] ?? null);
callback(item.configurationOverrides?.[dataKey]);
break;
case 'metrics':
callback(item.metrics?.[dataKey]);

Copy link
Member Author

Choose a reason for hiding this comment

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

So, functionally not a lot in this specific case. Here though the LDFeatureStore is still compatible with the one we had before, and the typing had LDFeatureStoreItem | null. So it just has 'null' here to keep typescript compiling. Without it it simply would not compile.

At some point we may change that typing. I have to release 9.0 for migrations, so it would possibly be a good time.

Not in this situation, but in regards to truthiness, it can be very important. Thankfully ?. and ?? have reduced it.

If 0/"" is valid, but null/undefined are not, then you often would end up with checks that check for both.

@kinyoklion kinyoklion merged commit ee62381 into feat/node-migrations Aug 28, 2023
13 checks passed
@kinyoklion kinyoklion deleted the rlamb/edge-new-data-kinds branch August 28, 2023 22:46
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.

2 participants