important-zebra-55422
01/07/2024, 9:36 PMon_experiment_viewed
def on_experiment_viewed(experiment, result):
aws_firehose.track(attributes["id"], "Experiment Viewed", {
'experimentId': experiment.key,
'variationId': result.key
"timestamp": now()
})
# Create a GrowthBook instance
gb = GrowthBook(
attributes = attributes,
on_experiment_viewed = on_experiment_viewed,
api_host = "<https://cdn.growthbook.io>",
client_key = "<some_key>"
)
gb.load_features()
feature_name = "banner-color"
# Simple on/off feature gating
if gb.is_on(feature_name):
print("My feature is on!")
else:
print("My feature is off")
If I run the above code in a script, it'll call our aws firehose each time the script is run, passing the same data(expect for a different timestamp
)? We'll have to deduplicate it in our data warehouse I believe. Is my understanding correct? If so, is there a way of capturing the first time an user was assigned to a variant only? So if I run the script multiple times, it won't trigger on_experiment_viewed
. Or any other way you recommend. Maybe, what I want is not a good idea. If so, do let me know.fresh-football-47124
fresh-football-47124
fresh-football-47124
important-zebra-55422
01/10/2024, 3:24 PM