We have created a custom, PageEventsProcessor
in Aggregation interaction Pipeline
. I have added a lot of logs in that processor. That processor does not seem to be called. And there is no data in my custom Fact_PageEvents
table. All other data seems to have rebuild on QA environment.
public class PageEventsProcessor : AggregationProcessor
{
protected string AnalyticsPageEventDefinitionsCacheName = "AnalyticsPageEventDefinitions";
protected override void OnProcess(AggregationPipelineArgs args)
{
Logger.Debug("PageEventsProcessor - OnProcess: Started");
Assert.ArgumentNotNull(args, "args");
var abc = args.GetFact<PageEvents>();
if (abc == null)
{
Logger.Debug("PageEventsProcessor - OnProcess:PageEvents fact not found");
return;
}
Logger.Debug("PageEventsProcessor - OnProcess:PageEvents fact found");
var visit = args.Context.Visit;
var list = new List<Guid>();
if ((visit.Pages != null) && (0 < visit.Pages.Count))
{
PageEvents fact = null;
var analyticsPageEventDefinitions = GetAnalyticsPageEvents();
if (analyticsPageEventDefinitions == null || !analyticsPageEventDefinitions.Any())
{
Logger.Error($"PageEventsProcessor - OnProcess: No pageeventdefinitions found in analytics system.");
return;
}
foreach (var pageData in visit.Pages)
{
if (pageData.PageEvents == null || !pageData.PageEvents.Any())
{
continue;
}
var validPageEvents = pageData.PageEvents.Where(x => analyticsPageEventDefinitions.
Any( y => y.ID.ToString().Equals(x.PageEventDefinitionId.ToString())))
.ToList();
if (!validPageEvents.Any())
{
Logger.Error($"PageEventsProcessor - OnProcess: No Valid PageEvents found for {pageData.Item.Id}.");
continue;
}
Logger.Debug($"PageEventsProcessor - OnProcess: Valid PageEvents found for {pageData.Item.Id}.");
foreach (var pageEvent in validPageEvents)
{
if (pageEvent == null || pageEvent.PageEventDefinitionId == Guid.Empty)
continue;
var pageEventDefinitionItem = (PageEventItem)analyticsPageEventDefinitions.FirstOrDefault(
x => x.ID.ToString().Equals(pageEvent.PageEventDefinitionId.ToString()));
if (pageEventDefinitionItem == null)
{
continue;
}
Logger.Debug($"PageEventsProcessor - OnProcess: PageEvent is {pageEventDefinitionItem.ID.ToString()}.");
long num;
var guid = AggregationProcessor.UpdateAccountDimension(args);
var hash = AggregationProcessor.UpdateSiteNamesDimension(args);
var hash2 = AggregationProcessor.UpdateDeviceNamesDimension(args);
var hash3 = AggregationProcessor.UpdateLanguagesDimension(args);
long.TryParse(pageEventDefinitionItem.Points, out num);
var key = new PageEventsKey
{
Date = args.DateTimeStrategy.Translate(visit.StartDateTime),
TrafficType = visit.TrafficType,
ContactId = visit.ContactId
};
Guid? campaignId = visit.CampaignId;
key.CampaignId = new Guid?(campaignId.HasValue ? campaignId.GetValueOrDefault() : Guid.Empty);
key.SiteNameId = hash;
key.DeviceNameId = hash2;
key.LanguageId = hash3;
key.AccountId = guid;
key.PageEventDefinitionId = pageEvent.PageEventDefinitionId;
key.ItemId = pageEvent.ItemId;
key.PageEventPoints = num;
var value2 = new PageEventsValue();
var flag = !list.Contains(pageEvent.PageEventDefinitionId);
value2.Count = 1L;
if (flag)
{
value2.Visits = 1L;
value2.Value = visit.Value;
list.Add(pageEvent.PageEventDefinitionId);
}
else
{
value2.Visits = 0L;
}
if (fact == null)
{
fact = args.GetFact<PageEvents>();
}
fact.Emit(key, value2);
}
}
}
}
protected List<Item> GetAnalyticsPageEvents()
{
ICache cache = CacheFactory.GetCache();
//check cache
List<Item> cachedObject = cache.RetrieveFromCache<List<Item>>(AnalyticsPageEventDefinitionsCacheName);
if (cachedObject != null && cachedObject.Any())
{
return cachedObject;
}
var pageEventsFolder = ItemReference.Sitecore_System_Settings_Analytics_PageEvents.InnerItem;
var TemplateId = PageEventItem.TemplateID;
Logger.Debug($"PageEventsProcessor - GetAnalyticsPageEvents:Itemreference value {ItemReference.System_Analytics_PageEvent_Template.Guid}");
Logger.Debug($"PageEventsProcessor - GetAnalyticsPageEvents:PageEvents TemplateId {TemplateId}");
var analyticsPageEventDefinitions = new List<Item>();
if (!pageEventsFolder.IsNull())
{
analyticsPageEventDefinitions.AddRange(pageEventsFolder.Axes.GetDescendants()
.Where(x => x.TemplateID.ToString().Equals(ItemReference.System_Analytics_PageEvent_Template.Guid)));
cache.AddToCache(analyticsPageEventDefinitions, AnalyticsPageEventDefinitionsCacheName);
}
return analyticsPageEventDefinitions;
}
}
There are no errors in the log file. I am calling this processor
<group groupName="analytics.aggregation">
<pipelines>
<interactions>
<processor type="XYZ.Library.CustomSitecore.Analytics.Aggregation.Pipeline.PageEventsProcessor, XYZ.Library"
patch:after="processor[@type='Sitecore.Analytics.Aggregation.Pipeline.ConversionsProcessor, Sitecore.Analytics.Aggregation']"/>
</interactions>
</pipelines>
</group>
Any thoughts, what might have gone wrong, will be helpful. The rebuildReporting
process completes, but no data in Fact_PageEvents
.