File tree Expand file tree Collapse file tree
openfeature-node-provider Expand file tree Collapse file tree Original file line number Diff line number Diff line change 11{
22 "name" : " @bucketco/node-sdk" ,
3- "version" : " 1.9.1 " ,
3+ "version" : " 1.9.2 " ,
44 "license" : " MIT" ,
55 "repository" : {
66 "type" : " git" ,
Original file line number Diff line number Diff line change @@ -123,6 +123,7 @@ export class BucketClient {
123123 fallbackFeatures ?: Record < keyof TypedFeatures , RawFeature > ;
124124 featureOverrides : FeatureOverridesFn ;
125125 offline : boolean ;
126+ emitEvaluationEvents : boolean ;
126127 configFile ?: string ;
127128 featuresFetchRetries : number ;
128129 fetchTimeoutMs : number ;
@@ -302,6 +303,7 @@ export class BucketClient {
302303
303304 this . _config = {
304305 offline,
306+ emitEvaluationEvents : config . emitEvaluationEvents ?? true ,
305307 apiBaseUrl : ( config . apiBaseUrl ?? config . host ) || API_BASE_URL ,
306308 headers : {
307309 "Content-Type" : "application/json" ,
@@ -908,6 +910,13 @@ export class BucketClient {
908910 return ;
909911 }
910912
913+ if (
914+ ! this . _config . emitEvaluationEvents &&
915+ ( event . action === "evaluate" || event . action === "evaluate-config" )
916+ ) {
917+ return ;
918+ }
919+
911920 if (
912921 ! this . rateLimiter . isAllowed (
913922 hashObject ( {
Original file line number Diff line number Diff line change @@ -644,6 +644,11 @@ export type ClientOptions = {
644644 */
645645 offline ?: boolean ;
646646
647+ /**
648+ * If set to `false`, no evaluation events will be emitted.
649+ */
650+ emitEvaluationEvents ?: boolean ;
651+
647652 /**
648653 * The path to the config file. If supplied, the config file will be loaded.
649654 * Defaults to `bucket.json` when NODE_ENV is not production. Can also be
Original file line number Diff line number Diff line change @@ -1130,6 +1130,70 @@ describe("BucketClient", () => {
11301130 ) ;
11311131 } ) ;
11321132
1133+ it ( "`track` does not send evaluation events when `emitEvaluationEvents` is `false`" , async ( ) => {
1134+ client = new BucketClient ( {
1135+ ...validOptions ,
1136+ emitEvaluationEvents : false ,
1137+ } ) ;
1138+
1139+ const context = {
1140+ company,
1141+ user,
1142+ other : otherContext ,
1143+ } ;
1144+
1145+ // test that the feature is returned
1146+ await client . initialize ( ) ;
1147+ const feature = client . getFeature (
1148+ {
1149+ ...context ,
1150+ meta : {
1151+ active : true ,
1152+ } ,
1153+ enableTracking : true ,
1154+ } ,
1155+ "feature1" ,
1156+ ) ;
1157+
1158+ await feature . track ( ) ;
1159+ await client . flush ( ) ;
1160+
1161+ expect ( httpClient . post ) . toHaveBeenCalledWith (
1162+ BULK_ENDPOINT ,
1163+ expectedHeaders ,
1164+ [
1165+ {
1166+ attributes : {
1167+ employees : 100 ,
1168+ name : "Acme Inc." ,
1169+ } ,
1170+ companyId : "company123" ,
1171+ context : {
1172+ active : true ,
1173+ } ,
1174+ type : "company" ,
1175+ } ,
1176+ {
1177+ attributes : {
1178+ age : 1 ,
1179+ name : "John" ,
1180+ } ,
1181+ context : {
1182+ active : true ,
1183+ } ,
1184+ type : "user" ,
1185+ userId : "user123" ,
1186+ } ,
1187+ {
1188+ type : "event" ,
1189+ event : "feature1" ,
1190+ userId : user . id ,
1191+ companyId : company . id ,
1192+ } ,
1193+ ] ,
1194+ ) ;
1195+ } ) ;
1196+
11331197 it ( "`isEnabled` sends `check` event" , async ( ) => {
11341198 const context = {
11351199 company,
Original file line number Diff line number Diff line change 11{
22 "name" : " @bucketco/openfeature-node-provider" ,
3- "version" : " 0.4.0 " ,
3+ "version" : " 0.4.1 " ,
44 "license" : " MIT" ,
55 "repository" : {
66 "type" : " git" ,
5050 "vitest" : " ~1.6.0"
5151 },
5252 "dependencies" : {
53- "@bucketco/node-sdk" : " 1.9.1 "
53+ "@bucketco/node-sdk" : " 1.9.2 "
5454 },
5555 "peerDependencies" : {
5656 "@openfeature/server-sdk" : " >=1.16.1"
Original file line number Diff line number Diff line change @@ -786,7 +786,7 @@ __metadata:
786786 languageName: unknown
787787 linkType: soft
788788
789- "@bucketco/node-sdk@npm:1.9.1 , @bucketco/node-sdk@workspace:packages/node-sdk":
789+ "@bucketco/node-sdk@npm:1.9.2 , @bucketco/node-sdk@workspace:packages/node-sdk":
790790 version: 0.0.0-use.local
791791 resolution: "@bucketco/node-sdk@workspace:packages/node-sdk"
792792 dependencies:
@@ -836,7 +836,7 @@ __metadata:
836836 dependencies:
837837 "@babel/core": "npm:~7.24.7"
838838 "@bucketco/eslint-config": "npm:~0.0.2"
839- "@bucketco/node-sdk": "npm:1.9.1 "
839+ "@bucketco/node-sdk": "npm:1.9.2 "
840840 "@bucketco/tsconfig": "npm:~0.0.2"
841841 "@openfeature/core": "npm:^1.5.0"
842842 "@openfeature/server-sdk": "npm:>=1.16.1"
You can’t perform that action at this time.
0 commit comments