File tree Expand file tree Collapse file tree 6 files changed +82
-13
lines changed
openfeature-node-provider Expand file tree Collapse file tree 6 files changed +82
-13
lines changed Original file line number Diff line number Diff line change 11{
22 "name" : " @bucketco/node-sdk" ,
3- "version" : " 1.9.0 " ,
3+ "version" : " 1.9.1 " ,
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 5050 "vitest" : " ~1.6.0"
5151 },
5252 "dependencies" : {
53- "@bucketco/node-sdk" : " 1.8.4 "
53+ "@bucketco/node-sdk" : " 1.9.1 "
5454 },
5555 "peerDependencies" : {
5656 "@openfeature/server-sdk" : " >=1.16.1"
Original file line number Diff line number Diff line change @@ -795,16 +795,7 @@ __metadata:
795795 languageName: unknown
796796 linkType: soft
797797
798- "@bucketco/node-sdk@npm:1.8.4":
799- version: 1.8.4
800- resolution: "@bucketco/node-sdk@npm:1.8.4"
801- dependencies:
802- "@bucketco/flag-evaluation": "npm:0.1.4"
803- checksum: 10c0/f5270915b61526f69f7dbd37b41edf0f130a4a008730f20baf00bbbf49c0a2e3e190a56d35a9451d5645e6da4d874f5d0d555f378596440cccb10306c4362003
804- languageName: node
805- linkType: hard
806-
807- "@bucketco/node-sdk@workspace:packages/node-sdk":
798+ "@bucketco/node-sdk@npm:1.9.1, @bucketco/node-sdk@workspace:packages/node-sdk":
808799 version: 0.0.0-use.local
809800 resolution: "@bucketco/node-sdk@workspace:packages/node-sdk"
810801 dependencies:
@@ -854,7 +845,7 @@ __metadata:
854845 dependencies:
855846 "@babel/core": "npm:~7.24.7"
856847 "@bucketco/eslint-config": "npm:~0.0.2"
857- "@bucketco/node-sdk": "npm:1.8.4 "
848+ "@bucketco/node-sdk": "npm:1.9.1 "
858849 "@bucketco/tsconfig": "npm:~0.0.2"
859850 "@openfeature/core": "npm:^1.5.0"
860851 "@openfeature/server-sdk": "npm:>=1.16.1"
You can’t perform that action at this time.
0 commit comments