|
Twitch SDK (Internal)
|
#include <experimentapi.h>
Classes | |
| class | CoreApiClient |
Public Types | |
| using | FetchExperimentsCallback = std::function< void(TTV_ErrorCode ec, const std::shared_ptr< ExperimentSet > &result)> |
| enum | State { State::Uninitialized, State::Initializing, State::Initialized, State::ShuttingDown } |
| using | InitializeCallback = std::function< void(TTV_ErrorCode ec)> |
| using | ShutdownCallback = std::function< void(TTV_ErrorCode ec)> |
Public Member Functions | |
| ExperimentAPI () | |
| virtual | ~ExperimentAPI () |
| virtual std::string | GetModuleName () const override |
| virtual TTV_ErrorCode | Initialize (const InitializeCallback &callback) override |
| virtual TTV_ErrorCode | Shutdown (const ShutdownCallback &callback) override |
| virtual TTV_ErrorCode | Update () override |
| TTV_ErrorCode | SetCoreApi (const std::shared_ptr< CoreAPI > &coreApi) |
| TTV_ErrorCode | SetAnalyticsId (const std::string &id) |
| TTV_ErrorCode | FetchExperiments (const FetchExperimentsCallback &callback) |
| TTV_ErrorCode | SetExperiments (const ExperimentSet &experiments) |
| TTV_ErrorCode | DeserializeExperiments (const std::string &json, ExperimentSet &result) |
| TTV_ErrorCode | DetermineBucket (const std::string &experiment, std::string &result) |
| TTV_ErrorCode | SetOverride (const std::string &experimentGuid, const std::string &groupValue) |
| TTV_ErrorCode | GetOverride (const std::string &experimentGuid, std::string &result) |
| TTV_ErrorCode | GetOverrides (std::map< std::string, std::string > &result) |
| TTV_ErrorCode | RemoveOverride (const std::string &experimentGuid) |
| TTV_ErrorCode | ClearOverrides () |
| virtual State | GetState () const override |
Protected Member Functions | |
| virtual bool | CheckShutdown () override |
| virtual void | CompleteShutdown () override |
| void | NotifyStateChange () |
| void | RegisterInitializeCallback (const InitializeCallback &callback) |
| void | RegisterShutdownCallback (const ShutdownCallback &callback) |
| template<typename T > | |
| void | Invoke (std::function< void(std::shared_ptr< T >)> callback) |
| std::shared_ptr< ComponentContainer > | GetComponentContainer () |
Protected Attributes | |
| EventSource< IModuleListener > | mListeners |
| State | mState |
| State | mLastReportedState |
Private Attributes | |
| std::shared_ptr< CoreAPI > | mCoreApi |
| std::shared_ptr< TaskRunner > | mTaskRunner |
| std::shared_ptr< CoreApiClient > | mCoreApiClient |
| ExperimentSet | mExperimentSet |
| std::string | mAnalyticsId |
| std::map< std::string, std::string > | mOverrides |
Provides the client-side mini-experiment functionality.
The following properties must be set before calling Initialize().
The active experiments can be set in this API instance by
Once experiments have been loaded you can ask which bucket a user is in via DetermineBucket().
If debugging your app and want to force certain experiments use SetOverride() and RemoveOverride().
| using ttv::experiment::ExperimentAPI::FetchExperimentsCallback = std::function<void(TTV_ErrorCode ec, const std::shared_ptr<ExperimentSet>& result)> |
|
inherited |
|
inherited |
|
stronginherited |
| ttv::experiment::ExperimentAPI::ExperimentAPI | ( | ) |
|
virtual |
|
overrideprotectedvirtual |
Reimplemented from ttv::ModuleBase.
| TTV_ErrorCode ttv::experiment::ExperimentAPI::ClearOverrides | ( | ) |
Clears all overrides.
|
overrideprotectedvirtual |
Reimplemented from ttv::ModuleBase.
| TTV_ErrorCode ttv::experiment::ExperimentAPI::DeserializeExperiments | ( | const std::string & | json, |
| ExperimentSet & | result | ||
| ) |
Parses the given experiments JSON. This is used to parse previously fetched ExperimentSet::serialized.
| TTV_ErrorCode ttv::experiment::ExperimentAPI::DetermineBucket | ( | const std::string & | experiment, |
| std::string & | result | ||
| ) |
Determines which bucket should be used based on the device id for the given experiment GUID. The data must have previously been fetched via FetchExperiments() which caches it internally.
| TTV_ErrorCode ttv::experiment::ExperimentAPI::FetchExperiments | ( | const FetchExperimentsCallback & | callback | ) |
Requests the current set of experiments from the backend.
|
inlineprotectedinherited |
Returns the common ComponentContainer which hosts all components which live at the module level.
|
overridevirtual |
Returns the name of the module.
Implements ttv::IModule.
| TTV_ErrorCode ttv::experiment::ExperimentAPI::GetOverride | ( | const std::string & | experimentGuid, |
| std::string & | result | ||
| ) |
Determines the value of the group if it is overidden. This will be "" if not overidden.
| TTV_ErrorCode ttv::experiment::ExperimentAPI::GetOverrides | ( | std::map< std::string, std::string > & | result | ) |
Retrieves all groups that have been overridden and their assigned value.
|
overridevirtualinherited |
Returns the current state of the module.
Implements ttv::IModule.
|
overridevirtual |
Initializes the module asynchronously. The module state will be reported in IModuleListener::ModuleStateChanged(). No other calls should be made into the module until the module state is either State::Initialized or State::Uninitialized. You should only expect changes to the module state if this method succeeds.
Reimplemented from ttv::ModuleBase.
|
inlineprotectedinherited |
Invokes the callback for the module listeners.
|
protectedinherited |
|
inlineprotectedinherited |
|
inlineprotectedinherited |
| TTV_ErrorCode ttv::experiment::ExperimentAPI::RemoveOverride | ( | const std::string & | experimentGuid | ) |
Removes an explicit override set using SetOverride().
| TTV_ErrorCode ttv::experiment::ExperimentAPI::SetAnalyticsId | ( | const std::string & | id | ) |
| TTV_ErrorCode ttv::experiment::ExperimentAPI::SetCoreApi | ( | const std::shared_ptr< CoreAPI > & | coreApi | ) |
| TTV_ErrorCode ttv::experiment::ExperimentAPI::SetExperiments | ( | const ExperimentSet & | experiments | ) |
Sets the active experiments.
| TTV_ErrorCode ttv::experiment::ExperimentAPI::SetOverride | ( | const std::string & | experimentGuid, |
| const std::string & | groupValue | ||
| ) |
Sets an explicit group to use for an experiment, typically used for debugging.
|
overridevirtual |
Initiates an asynchronous shutdown of the module. The module state will be reported in IModuleListener::ModuleStateChanged(). No other calls should be made into the module until the module state is either State::Initialized or State::Uninitialized. All modules that depend on this module need to be shutdown first. You should only expect changes to the module state if this method succeeds.
Reimplemented from ttv::ModuleBase.
|
overridevirtual |
Updates the internal state of the module and fires any pending callbacks.
Reimplemented from ttv::ModuleBase.
|
private |
|
private |
|
private |
|
private |
|
protectedinherited |
|
protectedinherited |
The registered listeners. These listeners extend IModuleListener and will be of the type required for the module.
|
private |
|
protectedinherited |
|
private |
1.8.13