feat: expose js sdk identity on client metadata#1376
feat: expose js sdk identity on client metadata#1376jonathannorris wants to merge 3 commits intomainfrom
Conversation
Expose stable sdk and framework identity through client metadata so providers and hooks can distinguish web/server usage and framework wrappers without custom vendor shims. Signed-off-by: Jonathan Norris <jonathan.norris@dynatrace.com>
There was a problem hiding this comment.
Code Review
This pull request introduces framework-specific metadata (Angular, Nest, and React) and SDK family identification ('web' or 'server') into OpenFeature clients. This is achieved by wrapping clients in a Proxy that intercepts metadata access. The changes include new utility functions for each framework, updates to the respective SDK providers/services to apply these wrappers, and expanded unit tests to verify metadata propagation. Review feedback highlights potential performance improvements in the Angular SDK, specifically regarding redundant client initialization in the directive and the need for caching proxied client instances in the service to avoid overhead during frequent flag evaluations.
| this.disposeClient(this._client); | ||
| } | ||
| this._client = OpenFeature.getClient(this._featureFlagDomain); | ||
| this._client = withAngularFrameworkMetadata(OpenFeature.getClient(this._featureFlagDomain)); |
There was a problem hiding this comment.
The initClient method is called both from the featureFlagDomain setter and from ngOnInit. When the domain is provided via an input binding, the setter will trigger initClient before ngOnInit runs, causing the client to be initialized twice and the first one to be immediately disposed. While not a functional bug, it is redundant.
| options?: AngularFlagEvaluationOptions, | ||
| ): Observable<EvaluationDetails<T>> { | ||
| const client = domain ? OpenFeature.getClient(domain) : OpenFeature.getClient(); | ||
| const client = withAngularFrameworkMetadata(domain ? OpenFeature.getClient(domain) : OpenFeature.getClient()); |
There was a problem hiding this comment.
Creating a new Proxy wrapper on every call to getFlagDetails (which occurs for every flag evaluation via the service) introduces unnecessary overhead. Since OpenFeature.getClient() returns a singleton for a given domain, consider caching the proxied client instances within the service to improve efficiency.
Move the framework metadata proxy into shared client utilities so the React, Angular, and Nest SDKs reuse one implementation. Signed-off-by: Jonathan Norris <jonathan.norris@dynatrace.com>
|
Hum... should Right now this PR uses I think it probably makes sense to decide whether this field is meant to represent JS package family ( |
Define a minimal core client interface for metadata so shared framework wrappers can depend on an explicit contract instead of a broad object type. Signed-off-by: Jonathan Norris <jonathan.norris@dynatrace.com>
Reusing makes sense to me. I think they are essentially representing the same thing? The server package sets its |
Summary
ClientMetadatawith JS-specific identity fields:sdkandframeworksdkin the basewebandserverclientsclient.metadataand in hookclientMetadataMotivation
Relates to #1375.
Today providers and hooks can access
clientMetadata, but the JS SDKs do not expose enough identity to tell whether a call came fromwebvsserver, or fromreact,angular, ornest.Usage
Notes
Proxywrapper so framework metadata is visible both viaclient.metadataand from evaluations that readthis.metadataRelated Issues