protected override List <DimensionData> GenerateDimensionData(IVisitAggregationContext context, SegmentMetricsValue metrics, OrderModel orderModel) { List <DimensionData> dimensionDataList = new List <DimensionData>(); if (orderModel.Event.Order != null & orderModel.Event.Order.CartLines != null && orderModel.Event.Order.CartLines.Any()) { foreach (var cartLine in orderModel.Event.Order.CartLines) { if (orderModel.Event.CustomValues.ContainsKey($"PersonalizationId|{cartLine.ExternalCartLineId}")) { var personalizationId = orderModel.Event.CustomValues[$"PersonalizationId|{cartLine.ExternalCartLineId}"]; if (!string.IsNullOrEmpty(personalizationId)) { SegmentMetricsValue segmentMetricsValue = metrics.Clone(); segmentMetricsValue.Count = 1; DimensionData dimensionData = new DimensionData() { DimensionKey = personalizationId, MetricsValue = segmentMetricsValue }; dimensionDataList.Add(dimensionData); } } } } return(dimensionDataList); }
public override IEnumerable <DimensionData> GetData(IVisitAggregationContext context) { SegmentMetricsValue metrics = this.CalculateCommonMetrics(context, 0); ConcurrentDictionary <string, int> keyCount = this.GetDimensionKeys(context); foreach (string index in (IEnumerable <string>)keyCount.Keys) { int count = keyCount[index]; SegmentMetricsValue metricsValue = metrics.Clone(); metricsValue.Count = count; yield return(new DimensionData() { DimensionKey = index, MetricsValue = metricsValue }); } }
public override IEnumerable <DimensionData> GetData(IVisitAggregationContext context) { List <DimensionData> dimensionDataList = new List <DimensionData>(); DateTime startTime = this.LogStartProcessingDimension(); Interaction xconnectInteraction = this.ToXConnectInteraction(context.Visit); SegmentMetricsValue metrics = this.CalculateCommonMetrics(context, 0); if (metrics == null) { this.LogEndProcessingDimension(startTime, 0); } else { Guid eventDefinitionId = this.GetPageEventDefinitionId(); int numberOfEntries = 0; foreach (var @event in xconnectInteraction.Events) { if (@event.DefinitionId == eventDefinitionId && @event.CustomValues.ContainsKey("PersonalizationId") && !string.IsNullOrEmpty(@event.CustomValues["PersonalizationId"])) { var personalizationId = @event.CustomValues["PersonalizationId"]; if (!dimensionDataList.Any(dimensionData => dimensionData.DimensionKey.Equals(personalizationId, StringComparison.OrdinalIgnoreCase))) { SegmentMetricsValue segmentMetricsValue = metrics.Clone(); segmentMetricsValue.PageViews = xconnectInteraction.Events.Count(e => e.DefinitionId == eventDefinitionId && e.CustomValues.ContainsKey("PersonalizationId") && e.CustomValues["PersonalizationId"].Equals(personalizationId, StringComparison.OrdinalIgnoreCase)); dimensionDataList.Add(new DimensionData() { DimensionKey = personalizationId, MetricsValue = segmentMetricsValue }); ++numberOfEntries; } } } this.LogEndProcessingDimension(startTime, numberOfEntries); } return(dimensionDataList); }