6

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.

3
  • It could be possible the pipeline is getting aborted before this processor.
    – Ashita
    Commented Mar 23, 2017 at 15:28
  • Thats not the case, since none of the above pipelines have abort statement. Also, the next processor ConversionsProcessor is recreating the data.
    – user1234
    Commented Mar 23, 2017 at 15:30
  • Are you missing a constructor? I'm guessing you also made sure that the ShowConfig.aspx is showing your processor.
    – Marco
    Commented Feb 20, 2018 at 18:21

1 Answer 1

2

It may be a bit late for an answer but I have been having this type of issue recently.

To be able to fix the issue, I have proceed as follows

  1. Check log if there are any errors. If data are not being entered, this may be because there is an error such as Exception when storing an aggregation result into reporting database. Item will be postponed and retried later. Most of the time, it will already tell you what SQL error has occurred. For my case, it was that the string I was passing is too long and will be truncated.

  2. Execute a SQL Profiler on the Sitecore Analytics table and check for the INSERT statement. To get the INSERT statement, you can perform a search on the keyword "Fact_PageEvents".

  3. Once you have the SQL Statement, check for the values being passed in the INSERT and try to run it manually and this will output the error.

If you are testing locally, add a breakpoint to see if it is hit. This allows you to know whether the aggregation is being triggered or not.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.