Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion packages/node-sdk/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@bucketco/node-sdk",
"version": "1.9.2",
"version": "1.9.3",
"license": "MIT",
"repository": {
"type": "git",
Expand Down
29 changes: 18 additions & 11 deletions packages/node-sdk/src/client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -666,14 +666,17 @@ export class BucketClient {
const features = this._getFeatures(options);
const feature = features[key];

return this._wrapRawFeature(options, {
key,
isEnabled: feature?.isEnabled ?? false,
targetingVersion: feature?.targetingVersion,
config: feature?.config,
ruleEvaluationResults: feature?.ruleEvaluationResults,
missingContextFields: feature?.missingContextFields,
});
return this._wrapRawFeature(
{ ...options, enableChecks: true },
{
key,
isEnabled: feature?.isEnabled ?? false,
targetingVersion: feature?.targetingVersion,
config: feature?.config,
ruleEvaluationResults: feature?.ruleEvaluationResults,
missingContextFields: feature?.missingContextFields,
},
);
}

/**
Expand Down Expand Up @@ -1199,7 +1202,11 @@ export class BucketClient {
}

private _wrapRawFeature<TKey extends keyof TypedFeatures>(
{ enableTracking, ...context }: { enableTracking: boolean } & Context,
{
enableTracking,
enableChecks = false,
...context
}: { enableTracking: boolean; enableChecks?: boolean } & Context,
{ config, ...feature }: RawFeature,
): TypedFeatures[TKey] {
// eslint-disable-next-line @typescript-eslint/no-this-alias
Expand All @@ -1211,7 +1218,7 @@ export class BucketClient {

return {
get isEnabled() {
if (enableTracking) {
if (enableTracking && enableChecks) {
void client
.sendFeatureEvent({
action: "check",
Expand All @@ -1232,7 +1239,7 @@ export class BucketClient {
return feature.isEnabled;
},
get config() {
if (enableTracking) {
if (enableTracking && enableChecks) {
void client
.sendFeatureEvent({
action: "check-config",
Expand Down
37 changes: 5 additions & 32 deletions packages/node-sdk/test/client.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1646,7 +1646,7 @@ describe("BucketClient", () => {
expect(events).toStrictEqual([]);
});

it("`isEnabled` sends `check` event", async () => {
it("`isEnabled` does not send `check` event", async () => {
const context = {
company,
user,
Expand All @@ -1665,21 +1665,10 @@ describe("BucketClient", () => {
.flatMap((call) => call[2])
.filter((e) => e.action === "check");

expect(checkEvents).toStrictEqual([
{
type: "feature-flag-event",
action: "check",
key: "feature1",
targetingVersion: 1,
evalResult: true,
evalContext: context,
evalRuleResults: [true],
evalMissingFields: [],
},
]);
expect(checkEvents).toStrictEqual([]);
});

it("`config` sends `check` event", async () => {
it("`config` does not send `check` event", async () => {
const context = {
company,
user,
Expand All @@ -1690,7 +1679,7 @@ describe("BucketClient", () => {
await client.initialize();
const feature = client.getFeatures(context);

// trigger `check` event
// attempt to trigger `check` event
expect(feature.feature1.config).toBeDefined();

await client.flush();
Expand All @@ -1699,23 +1688,7 @@ describe("BucketClient", () => {
.flatMap((call) => call[2])
.filter((e) => e.action === "check-config");

expect(checkEvents).toStrictEqual([
{
type: "feature-flag-event",
action: "check-config",
key: "feature1",
evalResult: {
key: "config-1",
payload: {
something: "else",
},
},
targetingVersion: 1,
evalContext: context,
evalRuleResults: [true],
evalMissingFields: [],
},
]);
expect(checkEvents).toStrictEqual([]);
});

it("sends company/user events", async () => {
Expand Down
4 changes: 2 additions & 2 deletions packages/openfeature-node-provider/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@bucketco/openfeature-node-provider",
"version": "0.4.1",
"version": "0.4.2",
"license": "MIT",
"repository": {
"type": "git",
Expand Down Expand Up @@ -50,7 +50,7 @@
"vitest": "~1.6.0"
},
"dependencies": {
"@bucketco/node-sdk": "1.9.2"
"@bucketco/node-sdk": "1.9.3"
},
"peerDependencies": {
"@openfeature/server-sdk": ">=1.16.1"
Expand Down
4 changes: 2 additions & 2 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -786,7 +786,7 @@ __metadata:
languageName: unknown
linkType: soft

"@bucketco/node-sdk@npm:1.9.2, @bucketco/node-sdk@workspace:packages/node-sdk":
"@bucketco/node-sdk@npm:1.9.3, @bucketco/node-sdk@workspace:packages/node-sdk":
version: 0.0.0-use.local
resolution: "@bucketco/node-sdk@workspace:packages/node-sdk"
dependencies:
Expand Down Expand Up @@ -836,7 +836,7 @@ __metadata:
dependencies:
"@babel/core": "npm:~7.24.7"
"@bucketco/eslint-config": "npm:~0.0.2"
"@bucketco/node-sdk": "npm:1.9.2"
"@bucketco/node-sdk": "npm:1.9.3"
"@bucketco/tsconfig": "npm:~0.0.2"
"@openfeature/core": "npm:^1.5.0"
"@openfeature/server-sdk": "npm:>=1.16.1"
Expand Down