Skip to content

Commit

Permalink
Fix various issues
Browse files Browse the repository at this point in the history
  • Loading branch information
MarkBiesheuvel committed Nov 11, 2024
1 parent 74543e3 commit 4bae73f
Show file tree
Hide file tree
Showing 6 changed files with 11 additions and 12 deletions.
1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
[workspace]
resolver = "2"
members = [
"optimizely",
"examples/*",
Expand Down
2 changes: 1 addition & 1 deletion examples/performance-test/src/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import (
func main() {
logging.SetLogLevel(logging.LogLevelError)

datafile, _ := os.ReadFile("../datafiles/sandbox.json")
datafile, _ := os.ReadFile("../../datafiles/sandbox.json")

optimizelyFactory := &client.OptimizelyFactory{
Datafile: datafile,
Expand Down
2 changes: 1 addition & 1 deletion examples/performance-test/src/main.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
const optimizely = require('@optimizely/optimizely-sdk');
const fs = require('fs');

const datafile = fs.readFileSync('../datafiles/sandbox.json', 'utf8');
const datafile = fs.readFileSync('../../datafiles/sandbox.json', 'utf8');

const client = optimizely.createInstance({
datafile,
Expand Down
2 changes: 1 addition & 1 deletion examples/performance-test/src/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@


def datafile():
with open('../datafiles/sandbox.json', 'r') as file:
with open('../../datafiles/sandbox.json', 'r') as file:
return file.read()


Expand Down
8 changes: 3 additions & 5 deletions examples/performance-test/src/main.rs
Original file line number Diff line number Diff line change
@@ -1,14 +1,12 @@
use optimizely::{decision::DecideOptions, Client};
use std::error::Error;

const FILE_PATH: &str = "../datafiles/sandbox.json";
const FILE_PATH: &str = "../../datafiles/sandbox.json";
const FLAG_KEY: &str = "buy_button";

fn main() -> Result<(), Box<dyn Error>> {
// TODO: set default_decide_options once implemented
let client = Client::from_local_datafile(FILE_PATH)?.initialize();

let flag_key = "buy_button";

// Do not send any decision events during performance testing
let decide_options = DecideOptions {
disable_decision_event: true,
Expand All @@ -18,7 +16,7 @@ fn main() -> Result<(), Box<dyn Error>> {
for i in 0..1_000_000 {
let user_id = format!("user{}", i);
let user_context = client.create_user_context(&user_id);
let _decision = user_context.decide_with_options(flag_key, &decide_options);
let _decision = user_context.decide_with_options(FLAG_KEY, &decide_options);
}

Ok(())
Expand Down
8 changes: 4 additions & 4 deletions examples/results-demo/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ use std::time::{Duration, Instant};
use uuid::Uuid;

// Production SDK key
const SDK_KEY: &str = "K2rKjU83y2YZcZWnvR35A";
const SDK_KEY: &str = "4E5fffEkXpkgULW9AhtCL";

// Flag for which to generate data
const FLAG_KEY: &str = "results_demo";
Expand Down Expand Up @@ -57,9 +57,9 @@ fn main() -> Result<(), Box<dyn Error>> {

// Different conversion rate depending on variation
let conversion_rate = match decision.variation_key() {
"variation_1" => 0.116,
"variation_2" => 0.125,
"variation_3" => 0.117,
"variation_1" => 0.12,
"variation_2" => 0.14,
"variation_3" => 0.11,
_ => 0.0,
};

Expand Down

0 comments on commit 4bae73f

Please sign in to comment.