Skip to content

Commit ef2869f

Browse files
authored
feat: Add wrapper information to the LaunchDarkly client-side provider. (#1368)
Signed-off-by: Ryan Lamb <[email protected]>
1 parent 9a7ef4f commit ef2869f

File tree

3 files changed

+37
-5
lines changed

3 files changed

+37
-5
lines changed

libs/providers/launchdarkly-client/src/lib/launchdarkly-client-provider.spec.ts

Lines changed: 24 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,12 @@ describe('LaunchDarklyClientProvider', () => {
6868

6969
const provider = new LaunchDarklyClientProvider(envKey, { logger, ...ldOptionsMock });
7070

71-
expect(provider['ldOptions']).toStrictEqual({ ...ldOptionsMock, logger });
71+
expect(provider['ldOptions']).toStrictEqual({
72+
...ldOptionsMock,
73+
logger,
74+
wrapperName: 'open-feature-community-js-client',
75+
wrapperVersion: expect.any(String),
76+
});
7277
});
7378
});
7479

@@ -81,7 +86,15 @@ describe('LaunchDarklyClientProvider', () => {
8186
await provider.initialize();
8287
expect(initialize).toHaveBeenCalledTimes(1);
8388
/* when not set in open feauture LD sdk initialize should be called with the anonymous context*/
84-
expect(initialize).toHaveBeenCalledWith(envKey, { anonymous: true }, { logger });
89+
expect(initialize).toHaveBeenCalledWith(
90+
envKey,
91+
{ anonymous: true },
92+
{
93+
logger,
94+
wrapperName: 'open-feature-community-js-client',
95+
wrapperVersion: expect.any(String),
96+
},
97+
);
8598
expect(ldClientMock.waitForInitialization).toHaveBeenCalledWith(undefined);
8699
});
87100

@@ -90,7 +103,15 @@ describe('LaunchDarklyClientProvider', () => {
90103
await provider.initialize();
91104
expect(initialize).toHaveBeenCalledTimes(1);
92105
/* when not set in open feauture LD sdk initialize should be called with the anonymous context*/
93-
expect(initialize).toHaveBeenCalledWith(envKey, { anonymous: true }, { logger });
106+
expect(initialize).toHaveBeenCalledWith(
107+
envKey,
108+
{ anonymous: true },
109+
{
110+
logger,
111+
wrapperName: 'open-feature-community-js-client',
112+
wrapperVersion: expect.any(String),
113+
},
114+
);
94115
expect(ldClientMock.waitForInitialization).toHaveBeenCalledTimes(1);
95116
expect(ldClientMock.waitForInitialization).toHaveBeenCalledWith(5);
96117
});

libs/providers/launchdarkly-client/src/lib/launchdarkly-client-provider.ts

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,9 @@ import type { LaunchDarklyProviderOptions } from './launchdarkly-provider-option
2525
import translateContext from './translate-context';
2626
import translateResult from './translate-result';
2727

28+
const WRAPPER_NAME = 'open-feature-community-js-client';
29+
const WRAPPER_VERSION = '0.3.2'; // {{ x-release-please-version }}
30+
2831
/**
2932
* Create a ResolutionDetails for an evaluation that produced a type different
3033
* from the expected type.
@@ -75,7 +78,12 @@ export class LaunchDarklyClientProvider implements Provider {
7578
this.logger = basicLogger({ level: 'info' });
7679
}
7780
this.initializationTimeout = initializationTimeout;
78-
this.ldOptions = { ...ldOptions, logger: this.logger };
81+
this.ldOptions = {
82+
...ldOptions,
83+
logger: this.logger,
84+
wrapperName: WRAPPER_NAME,
85+
wrapperVersion: WRAPPER_VERSION,
86+
};
7987
}
8088

8189
private get client(): LDClient {

release-please-config.json

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,10 @@
6363
"prerelease": false,
6464
"bump-minor-pre-major": true,
6565
"bump-patch-for-minor-pre-major": true,
66-
"versioning": "default"
66+
"versioning": "default",
67+
"extra-files": [
68+
"src/lib/launchdarkly-client-provider.ts"
69+
]
6770
},
6871
"libs/providers/go-feature-flag-web": {
6972
"release-type": "node",

0 commit comments

Comments
 (0)