コード例 #1
0
        public void HandleAddToCartCTATags(WesofHtmlTag[] Tags, ref ServerResponse sRep)
        {
            //Check if the clients currently assigned MVT's are addtocart tests
            Variation[] relevantTestAssignments = MVTHistory.MatchLiveMVTWithTestType(sRep.Cookie.ModifiedMVTAssignments, TestTypesEnum.ADDTOCARTBUTTON);
            if (relevantTestAssignments != null)
            {
                //Todo, the client is already assigned to live AddToCartButton test(s)
                for (int i = 0; i < relevantTestAssignments.Length; i++)
                {
                    relevantTestAssignments[i].ApplyModification(ref Tags, ref sRep);
                }

                return;
            }


            //Check if there is already a live mvt that experiments with the add to cart.
            int assignToMVTId = MVTHistory.GetSuitableLiveMVTforNewGUIDAssignment(TestTypesEnum.ADDTOCARTBUTTON);
            int assignToVariation;

            if (assignToMVTId == -1)
            {
                //No suitable live MVT found. Generate a new one.
                assignToMVTId = CreateNewAddToCartMVT();
            }

            //Check if a test is available
            if (assignToMVTId > -1)
            {
                assignToVariation = AssignGuidToMVT(assignToMVTId, sRep.Cookie.Wesof_GUID, ref sRep);
                if (assignToVariation > -1)
                {
                    Variation v = MVTHistory.GetVariant(assignToMVTId, assignToVariation);
                    if (v != null)
                    {
                        v.ApplyModification(ref Tags, ref sRep);
                    }
                    else
                    {
                        if (Configuration.IsDebugModeOn)
                        {
                            _CLI.Out("Error. Expected variation object, returned null.", true, false);
                        }
                    }
                }
            }
            else
            {
                //Check if all the possible variations tested
                if (AddToCartButton.IsAllVariationTested())
                {
                    //Let's apply the winning variant.
                    AddToCartButton.ApplyChangesBasedOnLatestWinner(ref Tags, ref sRep);
                }
            }

            _CLI.RefreshStatDashboard();
        }
コード例 #2
0
        public void AddTestVariant(ref VariationType testVariant)
        {
            int       vid     = variants.Count;
            Variation variant = new Variation(vid, false);

            variant.SetVariationType(testVariant);

            variants.Add(variant);
        }
コード例 #3
0
        public MultiVariateTest(int mvtid, TestTypesEnum tType)
        {
            id                 = mvtid;
            testType           = tType;
            isActive           = true;
            LaunchDateTime     = DateTime.UtcNow;
            ResultType         = TestResultType.Live;
            AssignedGuidsTotal = 0;

            Variation control = control = new Variation(0, true);

            if (tType == TestTypesEnum.ADDTOCARTBUTTON)
            {
                control.SetVariationType(AddToCartButton.GetCurrentWinnderControl());
            }


            variants.Add(control);
        }
コード例 #4
0
        internal static void IncrementConversionOnGuid(string guid)
        {
            for (int i = 0; i < _History.Count; i++)
            {
                if (_History[i].IsActive)
                {
                    Variation v = _History[i].GetVariantWithGuid(guid);
                    if (v != null)
                    {
                        bool previousConversionState = v.ConvertGuid(guid);

                        if (previousConversionState == false)
                        {
                            UpdateTestAnalysis(_History[i]);
                        }
                    }
                }
            }

            _CLI.RefreshStatDashboard();
        }
コード例 #5
0
        public static Variation[] MatchLiveMVTWithTestType(string[] mvtlist, TestTypesEnum testType)
        {
            if (mvtlist == null)
            {
                return(null);
            }

            List <Variation> result = new List <Variation>();

            foreach (string s in mvtlist)
            {
                string[] tmp  = s.Split(new char[] { '.' }, StringSplitOptions.RemoveEmptyEntries);
                int      iMvt = int.Parse(tmp[0]);
                int      iVar = int.Parse(tmp[1]);

                int index = IndexById(iMvt);

                //check if this is a valid mvt id
                if (index == -1)
                {
                    if (Configuration.IsDebugModeOn)
                    {
                        _CLI.Out("Cannot find the MVT id sent by the client.", true, false);
                    }
                    continue;
                }

                //Check if the assigned mvt is relevant
                if (_History[index].IsActive == false)
                {
                    if (Configuration.IsDebugModeOn)
                    {
                        _CLI.Out("Error. The MVT sent by the client is not active, but has not been removed during the cleaning.", true, false);
                    }
                    continue;
                }

                //Check if the type is appropriate
                if (_History[index].TestType == testType)
                {
                    //Get the containing variant
                    Variation v = _History[index].GetVariant(iVar);

                    if (v == null)
                    {
                        if (Configuration.IsDebugModeOn)
                        {
                            _CLI.Out("Error. Found mvt, but could not get variation index.", true, false);
                        }
                        continue;
                    }
                    else
                    {
                        result.Add(v);
                    }
                }
            }

            if (result.Count == 0)
            {
                return(null);
            }
            else
            {
                return(result.ToArray());
            }
        }