Skip to content

Commit 592e41e

Browse files
committed
fixup: default tracking details
Signed-off-by: Todd Baert <[email protected]>
1 parent fcf0bea commit 592e41e

File tree

4 files changed

+26
-2
lines changed

4 files changed

+26
-2
lines changed

Diff for: packages/server/src/client/internal/open-feature-client.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -226,7 +226,7 @@ export class OpenFeatureClient implements Client {
226226
return this.evaluate<T>(flagKey, this._provider.resolveObjectEvaluation, defaultValue, 'object', context, options);
227227
}
228228

229-
track(occurrenceKey: string, context: EvaluationContext, occurrenceDetails: TrackingEventDetails): void {
229+
track(occurrenceKey: string, context: EvaluationContext, occurrenceDetails: TrackingEventDetails = {}): void {
230230
try {
231231
this.shortCircuitIfNotReady();
232232

Diff for: packages/server/test/client.spec.ts

+12
Original file line numberDiff line numberDiff line change
@@ -859,6 +859,18 @@ describe('OpenFeatureClient', () => {
859859
}).not.toThrow();
860860
});
861861

862+
it('provide empty tracking details to provider if not supplied in call', async () => {
863+
await OpenFeature.setProviderAndWait({ ...MOCK_PROVIDER });
864+
const client = OpenFeature.getClient();
865+
client.track(eventName);
866+
867+
expect(MOCK_PROVIDER.track).toHaveBeenCalledWith(
868+
eventName,
869+
expect.any(Object),
870+
expect.any(Object),
871+
);
872+
});
873+
862874
it('should call provider with correct context', async () => {
863875
await OpenFeature.setProviderAndWait({ ...MOCK_PROVIDER });
864876
OpenFeature.setContext({ [globalContextKey]: globalContextValue });

Diff for: packages/web/src/client/internal/open-feature-client.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -183,7 +183,7 @@ export class OpenFeatureClient implements Client {
183183
return this.evaluate<T>(flagKey, this._provider.resolveObjectEvaluation, defaultValue, 'object', options);
184184
}
185185

186-
track(occurrenceKey: string, occurrenceDetails: TrackingEventDetails): void {
186+
track(occurrenceKey: string, occurrenceDetails: TrackingEventDetails = {}): void {
187187
try {
188188
this.shortCircuitIfNotReady();
189189

Diff for: packages/web/test/client.spec.ts

+12
Original file line numberDiff line numberDiff line change
@@ -655,6 +655,18 @@ describe('OpenFeatureClient', () => {
655655
}).not.toThrow();
656656
});
657657

658+
it('provide empty tracking details to provider if not supplied in call', async () => {
659+
await OpenFeature.setProviderAndWait({ ...MOCK_PROVIDER });
660+
const client = OpenFeature.getClient();
661+
client.track(eventName);
662+
663+
expect(MOCK_PROVIDER.track).toHaveBeenCalledWith(
664+
eventName,
665+
expect.any(Object),
666+
expect.any(Object),
667+
);
668+
});
669+
658670
it('should no-op and not throw if provider throws', async () => {
659671
await OpenFeature.setProviderAndWait({
660672
...MOCK_PROVIDER,

0 commit comments

Comments
 (0)