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.
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.
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.
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. :)
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!
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: