Class ExperimentTracker
java.lang.Object
growthbook.sdk.java.multiusermode.ExperimentTracker
A thread-safe LRU cache deduplicating experiment-exposure events by
hashAttribute + hashValue + experimentKey + variationId (the same
key composition as the JavaScript and Python SDKs).
Sizing matters: the multi-user client shares ONE tracker across all users, so the bound must comfortably exceed the number of concurrently active unique exposures — an undersized LRU evicts and re-fires exposures under load. Past the bound, an evicted exposure may legitimately fire again.
-
Constructor Summary
ConstructorsConstructorDescriptionEvaluator-local tracker with the legacy 30-entry bound (single-user scope).ExperimentTracker(int maxSize) -
Method Summary
Modifier and TypeMethodDescriptionvoidbooleanisExperimentTracked(String experimentId) markIfFirst(String experimentId) Atomically claims an exposure for delivery: marks it tracked and reports whether this caller was the first to do so.voidtrackExperiment(String experimentId) voidUn-marks an exposure whose delivery failed, so it is retried on the next evaluation instead of being silently lost.
-
Constructor Details
-
ExperimentTracker
public ExperimentTracker()Evaluator-local tracker with the legacy 30-entry bound (single-user scope). -
ExperimentTracker
public ExperimentTracker(int maxSize) - Parameters:
maxSize- maximum tracked exposures before least-recently-used eviction; must be at least 1- Throws:
IllegalArgumentException- ifmaxSizeis less than 1
-
-
Method Details
-
trackExperiment
-
isExperimentTracked
-
markIfFirst
Atomically claims an exposure for delivery: marks it tracked and reports whether this caller was the first to do so. Concurrent first evaluations of the same key on a shared tracker see exactly one claim, so the exposure is dispatched once rather than racing a separate check-then-mark.- Parameters:
experimentId- the dedup key to claim- Returns:
- this caller's claim, to hand to
untrack(java.lang.String, java.lang.Object)if delivery fails, ornullif the key was already tracked
-
untrack
Un-marks an exposure whose delivery failed, so it is retried on the next evaluation instead of being silently lost. Only the mark made byclaimis removed: if the key was evicted and claimed again while the failed delivery was still running, the newer mark stays.- Parameters:
experimentId- the dedup key to un-markclaim- the valuemarkIfFirst(java.lang.String)returned for this delivery
-
clearTrackedExperiments
public void clearTrackedExperiments()
-