View Source GrowthBook.Helpers (GrowthBook v0.3.0)
GrowthBook internal helper functions.
A collection of helper functions for use internally inside the GrowthBook
library. You should
not (have to) use any of these functions in your own application. They are documented for
library developers only. Breaking changes in this module will not be considered breaking
changes in the library's public API (or cause a minor/major semver update).
Link to this section Summary
Functions
Given a hash and bucket ranges, assign one of the bucket ranges.
Converts and experiment's coverage and variation weights into a list of bucket ranges.
Returns an list of floats with count
items that are all equal and sum to 1.
Checks if an experiment variation is being forced via a URL query string.
This checks if a userId is within an experiment namespace or not.
Determines if a number n is within the provided range.
Determines if the user is part of a gradual feature rollout.
Link to this section Functions
Specs
choose_variation(float(), [GrowthBook.bucket_range()]) :: integer()
Given a hash and bucket ranges, assign one of the bucket ranges.
Specs
Specs
Specs
get_bucket_ranges(integer(), float(), [float()] | nil) :: [ GrowthBook.bucket_range() ]
Converts and experiment's coverage and variation weights into a list of bucket ranges.
Examples
iex> GrowthBook.Helpers.get_bucket_ranges(2, 1, [0.5, 0.5])
[{0.0, 0.5}, {0.5, 1.0}]
iex> GrowthBook.Helpers.get_bucket_ranges(2, 0.5, [0.4, 0.6])
[{0.0, 0.2}, {0.4, 0.7}]
Specs
Returns an list of floats with count
items that are all equal and sum to 1.
Examples
iex> GrowthBook.Helpers.get_equal_weights(2)
[0.5, 0.5]
Specs
Checks if an experiment variation is being forced via a URL query string.
Examples
iex> GrowthBook.Helpers.get_query_string_override("my-test", "http://localhost/?my-test=1", 2)
1
iex> GrowthBook.Helpers.get_query_string_override("my-test", "not valid", 2)
nil
Specs
in_namespace?(String.t(), GrowthBook.namespace() | nil) :: boolean()
This checks if a userId is within an experiment namespace or not.
Specs
in_range?(number(), GrowthBook.BucketRange.t()) :: boolean()
Determines if a number n is within the provided range.
included_in_rollout?(attributes, seed, hash_attribute, range, coverage, hash_version)
View SourceSpecs
included_in_rollout?( map(), String.t(), String.t(), GrowthBook.BucketRange.t(), number(), integer() ) :: boolean()
Determines if the user is part of a gradual feature rollout.