Skip to content

Commit 2d0219c

Browse files
authored
refactor: remove evaluation_context from resolve token and log_assign (#403)
1 parent b218eb7 commit 2d0219c

9 files changed

Lines changed: 4 additions & 36 deletions

File tree

confidence-cloudflare-resolver/src/lib.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -87,12 +87,11 @@ impl Host for H {
8787

8888
fn log_assign(
8989
resolve_id: &str,
90-
evaluation_context: &Struct,
9190
assigned_flags: &[FlagToApply],
9291
client: &Client,
9392
sdk: &Option<Sdk>,
9493
) {
95-
ASSIGN_LOGGER.log_assigns(resolve_id, evaluation_context, assigned_flags, client, sdk);
94+
ASSIGN_LOGGER.log_assigns(resolve_id, assigned_flags, client, sdk);
9695
}
9796
}
9897

confidence-resolver/src/assign_logger.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,6 @@ impl AssignLogger {
3838
pub fn log_assigns(
3939
&self,
4040
resolve_id: &str,
41-
_evaluation_context: &crate::proto::google::Struct,
4241
assigned_flags: &[FlagToApply],
4342
client: &crate::Client,
4443
sdk: &Option<crate::flags_resolver::Sdk>,

confidence-resolver/src/lib.rs

Lines changed: 1 addition & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -274,7 +274,6 @@ pub trait Host {
274274

275275
fn log_assign(
276276
resolve_id: &str,
277-
evaluation_context: &Struct,
278277
assigned_flags: &[FlagToApply],
279278
client: &Client,
280279
sdk: &Option<flags_resolver::Sdk>,
@@ -857,15 +856,14 @@ impl<'a, H: Host> AccountResolver<'a, H> {
857856

858857
H::log_assign(
859858
&resolve_id,
860-
&self.evaluation_context.context,
861859
flags_to_apply.as_slice(),
862860
self.client,
863861
&self.state.sdk,
864862
);
865863
} else {
866864
let mut resolve_token_v1 = flags_resolver::ResolveTokenV1 {
867865
resolve_id: resolve_id.clone(),
868-
evaluation_context: Some(self.evaluation_context.context.clone()),
866+
evaluation_context: Some(Struct::default()),
869867
..Default::default()
870868
};
871869
for assigned_flag in &flags_to_assign {
@@ -934,10 +932,6 @@ impl<'a, H: Host> AccountResolver<'a, H> {
934932
};
935933

936934
let assignments = resolve_token.assignments;
937-
let evaluation_context = resolve_token
938-
.evaluation_context
939-
.as_ref()
940-
.ok_or("missing evaluation context")?;
941935

942936
// ensure that all flags are present before we start sending events
943937
let mut assigned_flags: Vec<FlagToApply> = Vec::with_capacity(request.flags.len());
@@ -960,7 +954,6 @@ impl<'a, H: Host> AccountResolver<'a, H> {
960954

961955
H::log_assign(
962956
&resolve_token.resolve_id,
963-
evaluation_context,
964957
assigned_flags.as_slice(),
965958
self.client,
966959
&self.state.sdk,
@@ -1740,7 +1733,6 @@ mod tests {
17401733

17411734
fn log_assign(
17421735
_resolve_id: &str,
1743-
_evaluation_context: &Struct,
17441736
_assigned_flag: &[FlagToApply],
17451737
_client: &Client,
17461738
_sdk: &Option<Sdk>,
@@ -2140,7 +2132,6 @@ mod tests {
21402132

21412133
fn log_assign(
21422134
resolve_id: &str,
2143-
_evaluation_context: &Struct,
21442135
assigned_flag: &[FlagToApply],
21452136
_client: &Client,
21462137
_sdk: &Option<Sdk>,
@@ -2267,7 +2258,6 @@ mod tests {
22672258
struct AssignLogEntry {
22682259
resolve_id: String,
22692260
flag: String,
2270-
evaluation_context: Struct,
22712261
}
22722262

22732263
struct TestLogger {
@@ -2286,7 +2276,6 @@ mod tests {
22862276

22872277
fn log_assign(
22882278
resolve_id: &str,
2289-
evaluation_context: &Struct,
22902279
assigned_flag: &[FlagToApply],
22912280
_client: &Client,
22922281
_sdk: &Option<Sdk>,
@@ -2299,7 +2288,6 @@ mod tests {
22992288
logs.push(AssignLogEntry {
23002289
resolve_id: resolve_id.to_string(),
23012290
flag: f.assigned_flag.flag.clone(),
2302-
evaluation_context: evaluation_context.clone(),
23032291
});
23042292
});
23052293
}
@@ -2412,19 +2400,6 @@ mod tests {
24122400
log_entry.resolve_id, response.resolve_id,
24132401
"Log should contain the resolve_id from the original resolve"
24142402
);
2415-
2416-
// Verify that the evaluation context used in apply_flags logging matches the original resolve
2417-
// The context should contain the visitor_id that was used during resolve
2418-
let visitor_id_value = log_entry
2419-
.evaluation_context
2420-
.fields
2421-
.get("visitor_id")
2422-
.expect("evaluation_context should contain visitor_id");
2423-
assert_eq!(
2424-
visitor_id_value.kind,
2425-
Some(Kind::StringValue("tutorial_visitor".to_string())),
2426-
"evaluation_context should contain the original visitor_id from resolve"
2427-
);
24282403
}
24292404

24302405
#[test]

confidence-resolver/src/materialization_tests.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,6 @@ impl Host for L {
3030

3131
fn log_assign(
3232
_resolve_id: &str,
33-
_evaluation_context: &Struct,
3433
_assigned_flag: &[FlagToApply],
3534
_client: &Client,
3635
_sdk: &Option<flags_resolver::Sdk>,

confidence-resolver/src/resolve_logger.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -339,7 +339,6 @@ mod tests {
339339

340340
fn log_assign(
341341
_resolve_id: &str,
342-
_evaluation_context: &Struct,
343342
_assigned_flags: &[crate::FlagToApply],
344343
_client: &Client,
345344
_sdk: &Option<crate::flags_resolver::Sdk>,

confidence-resolver/src/resolver_spec_tests.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,6 @@ impl Host for L {
2828

2929
fn log_assign(
3030
_resolve_id: &str,
31-
_evaluation_context: &Struct,
3231
_assigned_flag: &[FlagToApply],
3332
_client: &Client,
3433
_sdk: &Option<flags_resolver::Sdk>,
Binary file not shown.

openfeature-provider/rust/src/host.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,11 +52,10 @@ impl Host for NativeHost {
5252

5353
fn log_assign(
5454
resolve_id: &str,
55-
evaluation_context: &Struct,
5655
assigned_flags: &[FlagToApply],
5756
client: &Client,
5857
sdk: &Option<Sdk>,
5958
) {
60-
ASSIGN_LOGGER.log_assigns(resolve_id, evaluation_context, assigned_flags, client, sdk);
59+
ASSIGN_LOGGER.log_assigns(resolve_id, assigned_flags, client, sdk);
6160
}
6261
}

wasm/rust-guest/src/lib.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -93,12 +93,11 @@ impl Host for WasmHost {
9393

9494
fn log_assign(
9595
resolve_id: &str,
96-
evaluation_context: &Struct,
9796
assigned_flags: &[FlagToApply],
9897
client: &Client,
9998
sdk: &Option<Sdk>,
10099
) {
101-
ASSIGN_LOGGER.log_assigns(resolve_id, evaluation_context, assigned_flags, client, sdk);
100+
ASSIGN_LOGGER.log_assigns(resolve_id, assigned_flags, client, sdk);
102101
}
103102

104103
fn encrypt_resolve_token(token_data: &[u8], _encryption_key: &[u8]) -> Result<Vec<u8>, String> {

0 commit comments

Comments
 (0)