0

I am facing issue in identifying the events and facets that needs to be passed to the below methods: UpdateAssetsDimension UpdateSiteNamesDimension UpdateLanguagesDimension

Please find the below updated source code on upgrading Sitecore Analytics from 8.2 to 9.3:

public class CentralDownloadsProcessor : InteractionAggregationPipelineProcessor
{
    private Guid CentralDownloadEventDefinitionId = Common.Constants.PageEvents.CentralDownload.Guid;

    protected override void OnProcess(InteractionAggregationPipelineArgs args)
    {
        try
        {
            Database masterDb = Database.GetDatabase(Common.Constants.Databases.Master);
            Assert.ArgumentNotNull(args, "args");
            VisitData visit = VisitDataMapper.GetVisitData(args);
            
            var facetdownloads = args.Context.Results.GetFact<CentralDownloads>();
            List<Hash128> list = new List<Hash128>();

            if (visit.SiteName == "central" || visit.SiteName == "authoring")
            {
                int subwayPersonId = 0;
                if (visit.CustomValues.ContainsKey("subwaypersonid"))
                {
                    subwayPersonId = (int)visit.CustomValues["subwaypersonid"];
                    Log.Info($"CentralDownloadProcessor: Subwaypersonid = {subwayPersonId}", this);
                }

                if (visit.Pages != null && 0 < visit.Pages.Count)
                {
                    Log.Info($"CentralDownloadProcessor: visit.Pages.Count = {visit.Pages.Count}", this);
                    CentralDownloads downloads = null;
                    foreach (PageData current in visit.Pages)
                    {
                        if (current.PageEvents != null && 0 < current.PageEvents.Count)
                        {
                            foreach (PageEventData current2 in current.PageEvents)
                            {
                                bool flag = this.IsDownload(current2.PageEventDefinitionId);
                                if (flag)
                                {
                                   // Guid accountId = InteractionAggregationPipelineProcessor.UpdateAccountDimension(args);
                                    Hash128 hash = InteractionAggregationPipelineProcessor.UpdateAssetsDimension( ?, args.Context.Results);
                                    Hash32 siteNameId = InteractionAggregationPipelineProcessor.UpdateSiteNamesDimension(?, args.Context.Results);
                                    Hash32 deviceNameId = UpdateDeviceNamesDimension(args.Context.Interaction, args.Context.Results);
                                    Hash32 languageId = InteractionAggregationPipelineProcessor.UpdateLanguagesDimension(?, args.Context.Results);

                                    Guid itemId = Guid.Empty;
                                    var jsonModel = GetDownloadJsonModel(current2);
                                    itemId = jsonModel.itemid == null ? Guid.Empty : new Guid(jsonModel.itemid);
                                    subwayPersonId = jsonModel.subwaypersonid != null
                                        ? int.Parse(jsonModel.subwaypersonid)
                                        : GetBackupInt(current2);
                                    Item downloadItem = masterDb.GetItem(new ID(itemId));

                                    if (!downloadItem.IsDerived(ISubway_Document_AttributesConstants.TemplateId) || !downloadItem.Paths.ContentPath.Contains("/media library/Document Repo/"))
                                    {
                                        if (jsonModel.source == null)
                                            continue;
                                    }

                                    CentralDownloadsKey downloadsKey = new CentralDownloadsKey();
                                    downloadsKey.Date = args.DateTimeStrategy.Translate(visit.StartDateTime);
                                    downloadsKey.TrafficType = visit.TrafficType;
                                    downloadsKey.CampaignId = new Guid?(visit.CampaignId ?? Guid.Empty);
                                    downloadsKey.SiteNameId = siteNameId;
                                    downloadsKey.DeviceNameId = deviceNameId;
                                    downloadsKey.LanguageId = languageId;
                                   //downloadsKey.AccountId = accountId;
                                    downloadsKey.AssetId = hash;
                                    downloadsKey.Source = jsonModel.source == null ? "Document" : jsonModel.source;
                                    //downloadsKey.ItemId = current2.ItemId;
                                    downloadsKey.ItemId = itemId;
                                    downloadsKey.ContactId = args.Context.Contact.Id.Value;
                                    downloadsKey.SubwayPersonId = subwayPersonId;

                                    Log.Info($"CentralDownloadProcessor: ItemId = {itemId}", this);

                                    CentralDownloadsValue downloadsValue = new CentralDownloadsValue();
                                    bool flag2 = list.Contains(hash);
                                    if (flag2)
                                    {
                                        downloadsValue.Visits = 0L;
                                        downloadsValue.Value = 0L;
                                        downloadsValue.Count = 1L;
                                    }
                                    else
                                    {
                                        downloadsValue.Visits = 1L;
                                        downloadsValue.Value = (long)visit.Value;
                                        downloadsValue.Count = 1L;
                                        list.Add(hash);
                                    }

                                    if (downloads == null)
                                    {
                                        downloads = args.Context.Results.GetFact<CentralDownloads>();
                                    }

                                    downloads.Emit(downloadsKey, downloadsValue);

                                    Log.Info($"CentralDownloadProcessor: Downloads emitted", this);
                                }
                            }
                        }
                    }
                }
            }
        }
        catch (Exception ex)
        {

            Log.Error(
                $"CentralDownloadProcessor: Error while aggregating Central Downloads: {ex}", this);
        }
        Log.Info("CentralDownloadProcessor: Done process of aggregating Central Downloads", this);
    }
1
  • Can you make sure you have deployed your custom facet models and JSON on the XConnect website? – Mahendra Shekhawat May 3 at 6:29

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.