Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Server side evaluation #24

Closed
wants to merge 13 commits into from
Closed

Conversation

bryce-fitzsimons
Copy link
Member

  • open new eval endpoint for server side evaluation on the proxy

    • requires attributes passed through query string
    • will defer tracking calls, pushing the info to trackExperiments in the sdk payload
  • alters the caching behavior slightly within the proxy

    • SWR still works
    • no read-through caching because we need to capture and mutate (scrub) all results from the API
  • alters the SSE (streaming) behavior

    • changes the payload to {update: true} instead of revealing the entire payload.
    • SDK to interpret this message and re-fetch the evaluated results

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

instead of using this middleware, we call a new generalized fetcher services.features.fetchFeatures() and let it run in the background

if (feature.rules) {
// track any removely evaluated experiments
for (const rule of feature.rules) {
if (rule.tracks) {
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  1. Do we need this? Included for compatibility.
  2. Do we care that track.experiment and track.result will probably not be scrubbed?

const result = gb.evalFeature(key);
if (result.on) {
// reduced feature definition
evaluatedFeatures[key] = { defaultValue: true };
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this the correct minimal format for an evaluated feature flag?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

defaultValue: result.value

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If result.source === "experiment":

{
  defaultValue: result.value,
  rules: [
    {  
      force: result.value, 
      tracks: [
        {
          experiment: result.experiment,
          result: result
        }
     ]
   }
  ]
}

Otherwise:

{ defaultValue: result.value }

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

make sure the SDK doesn't actually push the track payload for this case (deferred tracking)

const result = gb.run(experiment);
if (result.inExperiment) {
// reduced experiment definition
const evaluatedExperiment = {
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What do we think of this scrubbed format for an evaluated experiment?

evaluatedExperiments.push(evaluatedExperiment);

// track experiment
trackExperiments.push({ experiment: evaluatedExperiment, result });
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  1. Any issues tracking the evaluated (scrubbed) experiment instead of the original (unscrubbed)? Trying to avoid leaking extra data in the SDK payload.
  2. Similar question for result: is this too much info?

}
}

trackExperiments = gb.getTrackedExperiments();
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

relies on new SDK functionality, exportable _trackedExperimentQueue

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we must deploy the new SDK changes before this works for general users

if (result.on) {
// reduced feature definition
evaluatedFeatures[key] = { defaultValue: true };
}
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if it was an exp, don't want to track, but rather store in track object for later FE eval + tracking

),
weights: Array.from(
{ length: experiment.variations.length },
(_, i) => (i === result.variationId ? 1 : 0)
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

likely don't need this

}
}

trackExperiments = gb.getTrackedExperiments();
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

dont' need this one, let the tracking happen on the FE instead

...payload,
features: evaluatedFeatures,
experiments: evaluatedExperiments,
trackExperiments: [
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  • don't need this field during ssEval (proxy eval)
  • but we will need this for BE->FE deferred tracking

@bryce-fitzsimons bryce-fitzsimons marked this pull request as ready for review July 20, 2023 20:25
@bryce-fitzsimons
Copy link
Member Author

See: #33

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants