예제 #1
0
        /// <summary>
        /// Gets list of rollout experiments
        /// </summary>
        /// <param name="featureId">Feature ID</param>
        /// <param name="experiments">Experiments</param>
        /// <param name="projectConfig">Project Config</param>
        /// <returns>List | List of Optimizely rollout experiments.</returns>
        private List <OptimizelyExperiment> GetDeliveryRules(string featureId, IEnumerable <Experiment> experiments,
                                                             ProjectConfig projectConfig)
        {
            if (experiments == null)
            {
                return(new List <OptimizelyExperiment>());
            }

            var featureVariableIdMap = GetVariableIdMap(projectConfig);

            var deliveryRules = new List <OptimizelyExperiment>();

            foreach (var experiment in experiments)
            {
                var optimizelyExperiment = new OptimizelyExperiment(
                    id: experiment.Id,
                    key: experiment.Key,
                    audiences: GetExperimentAudiences(experiment, projectConfig),
                    variationsMap: GetVariationsMap(experiment.Variations, featureVariableIdMap, featureId)
                    );
                deliveryRules.Add(optimizelyExperiment);
            }

            return(deliveryRules);
        }
예제 #2
0
        /// <summary>
        /// Gets Map of all experiments except rollouts
        /// </summary>
        /// <param name="projectConfig">The project config</param>
        /// <returns>Dictionary | Dictionary of experiment key and value as experiment object</returns>
        private IDictionary <string, OptimizelyExperiment> GetExperimentsMap(ProjectConfig projectConfig)
        {
            var experimentsMap       = new Dictionary <string, OptimizelyExperiment>();
            var featureVariableIdMap = GetVariableIdMap(projectConfig);
            var experiments          = projectConfig?.Experiments?.ToList();

            experiments = projectConfig?.Groups?.SelectMany(g => g.Experiments).Concat(experiments)?.ToList();

            foreach (Experiment experiment in experiments)
            {
                var variationsMap = new Dictionary <string, OptimizelyVariation>();
                foreach (Variation variation in experiment.Variations)
                {
                    var variablesMap = MergeFeatureVariables(projectConfig,
                                                             featureVariableIdMap,
                                                             experiment.Id,
                                                             variation);

                    var optimizelyVariation = new OptimizelyVariation(variation.Id,
                                                                      variation.Key,
                                                                      variation.FeatureEnabled,
                                                                      variablesMap);

                    variationsMap.Add(variation.Key, optimizelyVariation);
                }
                var optimizelyExperiment = new OptimizelyExperiment(experiment.Id,
                                                                    experiment.Key,
                                                                    variationsMap);

                experimentsMap.Add(experiment.Key, optimizelyExperiment);
            }

            return(experimentsMap);
        }
예제 #3
0
        /// <summary>
        /// Gets Map of all experiments except rollouts
        /// </summary>
        /// <param name="projectConfig">The project config</param>
        /// <returns>Dictionary | Dictionary of experiment key and value as experiment object</returns>
        private IDictionary <string, OptimizelyExperiment> GetExperimentsMapById(ProjectConfig projectConfig)
        {
            var experimentsMap       = new Dictionary <string, OptimizelyExperiment>();
            var featureVariableIdMap = GetVariableIdMap(projectConfig);
            var experiments          = projectConfig?.Experiments?.ToList();

            experiments = projectConfig?.Groups?.SelectMany(g => g.Experiments).Concat(experiments)?.ToList();

            foreach (Experiment experiment in experiments)
            {
                var featureId            = projectConfig.GetExperimentFeatureList(experiment.Id)?.FirstOrDefault();
                var variationsMap        = GetVariationsMap(experiment.Variations, featureVariableIdMap, featureId);
                var experimentAudience   = GetExperimentAudiences(experiment, projectConfig);
                var optimizelyExperiment = new OptimizelyExperiment(experiment.Id,
                                                                    experiment.Key,
                                                                    experimentAudience,
                                                                    variationsMap);

                experimentsMap.Add(experiment.Id, optimizelyExperiment);
            }

            return(experimentsMap);
        }