Amplitude Experiment implementation for Flutter. This is a non official package provided by ProductMinds.
Features
fetch
: Fetch experiments assigned to user. You can use some properties as below:
variant
: Fetch assigned variant for each experiment. You can use some properties as below:
clear
: Clear all SDK cache
exposure
(works only with initializeWithAmplitude or by providing a custom exposureTrackingProvider): Track exposure for assigned variant in assigned experiment
Getting started
In order to start using this package you must have properly defined an Amplitude Account and Project as well Amplitude Experiment. When you have already setted your experiment, you should create a deployment
and this api key is the artifact that this SDK uses.
The init functions
initialize
: This function is going to return an ExperimentClient instance that you should use to start instrumentation. Look at this:
Experiment.initialize({ required String apiKey, ExperimentConfig? experimentConfig });
initializeWithAmplitude
: This function is going to return the same ExperimentClient instance configs but will try to link an Amplitude Analytic as exposure tracker.
NOTE: This will work only if you've already installed and setup an analytics plugin
Experiment.initializeWithAmplitude({ required String apiKey, ExperimentConfig? experimentConfig });
Config Object
class ExperimentConfig {
final bool? debug;
final String? instanceName;
final ExperimentVariant? fallbackVariant;
final ExperimentVariantSource? source;
final int? fetchTimeoutMillis;
final bool? retryFetchOnFailure;
final bool? automaticExposureTracking;
final ExperimentExposureTrackingProvider? exposureTrackingProvider;
ExperimentConfig(
{this.debug = false,
this.instanceName = 'default-instance',
this.fallbackVariant,
this.source,
this.fetchTimeoutMillis,
this.retryFetchOnFailure,
this.automaticExposureTracking = false,
this.exposureTrackingProvider});
};
Usage
To fetch
experiments for user:
Experiment.fetch({ String? userId, String? deviceId, Map<String, dynamic>? userProperties });
To get variant
for specific experiment:
Experiment.variant(String flagKey);
To get all variants
and experiments
that this user is assigned to:
Experiment.all();
To clear
all cache data:
Experiment.clear();
To track exposure
event:
Experiment.exposure(String flagKey);
NOTE: works only with initializeWithAmplitude or by providing a custom exposureTrackingProvider
Additional information
This package is basically an wrappper to Experiment Evaluation API maintened by Product Minds team. If you have any problem with this license or usage, please mail to antonny.santos@productminds.io.