Visitor groups not availables due to Episerver search error

Vote:
 

Hi. The visitor groups are not available to personalize content in CMS and we see an error related to Visitor Groups and Episerver.Find.Commerce. It seems to happen in internal Episerver classes.

Did someone have a similar issue? Any direction will help. Thanks

Visitor groups not available:

Log stream:

#326675
Aug 07, 2024 20:53
Vote:
 

The error may happens if you are using UserProfileCriterion but you do not use Asp.net identity for authentication. This criterion is for Asp.net identity by default.

#326721
Aug 08, 2024 11:46
David Ortiz - Aug 22, 2024 14:26
I updated the cause of the issue. Thanks Binh for your help.
Vote:
 

Update: The error is related to a content delivery api configuration we applied to enabled Edit mode for Content types served by Content Delivery Api to a Head system hosted externally in React (simulating what Optimizely now built as Visual Builder in  SaaS). 

services.Configure<ExternalApplicationOptions>(options => options.OptimizeForDelivery = true)

Removing this line , the personalization start to work again.  

#327868
Aug 22, 2024 14:25
Vote:
 

Update: The error is related to a content delivery api configuration we applied to enabled Edit mode for Content types served by Content Delivery Api to a Head system hosted externally in React (simulating what Optimizely now built as Visual Builder in  SaaS). 

services.Configure<ExternalApplicationOptions>(options => options.OptimizeForDelivery = true)

Removing this line , the personalization start to work again.  

#327869
Aug 22, 2024 14:25
Vote:
 

Hi David,

Yes. When you turn on OptimizelyForDelivery then Personalize in context menu is not displayed. But I do not think this flag relates to visitor group error in your log stream. :)

#327916
Aug 23, 2024 4:11
Vote:
 

So I just wanted to comment that we also had the same issue. During a search using Search & Navigation we had FilterForVisitor() enabled. This triggered the response to personlize the content, and we found usages of the UserProfileCriteria.

We also do use federated login, so the following code inside the UserProfileCriterion was returning null, since we could not find the User in the UIUserProvider since it was a federated user:

_securityConfiguration.UiUserProvider.GetUserAsync(text).GetAwaiter().GetResult()

The whole methods in UserProfileCriteria for reference ():

public override bool IsMatch(IPrincipal principal, HttpContext httpContext)
{
	string text = httpContext?.User?.Identity?.Name;
	if (!string.IsNullOrEmpty(text))
	{
		string text2 = GetPropValue(_securityConfiguration.UiUserProvider.GetUserAsync(text).GetAwaiter().GetResult(), base.Model.ProfileKey)?.ToString();
		if (!string.IsNullOrEmpty(text2))
		{
			return StringMatchHelper.IsMatch(text2, base.Model.ProfileValue, base.Model.MatchType);
		}
		return false;
	}
	return false;
}

private static object GetPropValue(object src, string propName)
{
	if (propName == null)
	{
		return null;
	}
	return src.GetType().GetProperty(propName)?.GetValue(src, null);
}

Anyway, instead of trying to solve this, we hid this and other uncompatible AudienceCriterias from the editors, and deleted all usages of the UserProfile-audience.

    public class FilterAudienceCriterions(IVisitorGroupCriterionRepository instance) : IVisitorGroupCriterionRepository
    {
        private readonly IVisitorGroupCriterionRepository _instance = instance;
        private readonly string[] AudienceCriterionsToFilter = ["UserProfileCriterion", "IPRangeCriterion", "ReferrerCriterion", "SearchWordReferrerCriterion"];

        public IEnumerable<VisitorGroupCriterion> List()
        {
            // Get the list of criteria from the default implementation
            var initialCriteriaList = _instance.List();
            return initialCriteriaList.Where(criterion => !AudienceCriterionsToFilter.Any(x => criterion.TypeName.Contains(x)));
        }
    }

Replaced the default repo in Startup.cs:

services.Intercept<IVisitorGroupCriterionRepository>((a, b) => new FilterAudienceCriterions(b));

Hope this helps someone else in the same situation!

#328242
Aug 28, 2024 13:32
* You are NOT allowed to include any hyperlinks in the post because your account hasn't associated to your company. User profile should be updated.