iamandycohen / UrlRewrite

Sitecore module that allows Content Author's to author inbound and outbound url redirects and rewrites.
MIT License
23 stars 67 forks source link

Deleted redirects cause exceptions when rebuilding reporting db or aggregating interactions #34

Open derekcorreia opened 7 years ago

derekcorreia commented 7 years ago

I'm working with a customer using version 1.8.1.3 of the module. They are unable to rebuild their reporting database because the interactions contain activity with redirects that have been deleted. Instead, they receive this exception:

6708 2017:06:06 11:03:51 ERROR Aggregation Error
Exception: System.Exception
Message: Object reference not set to an instance of an object.
Source: Sitecore.ExperienceAnalytics
   at Sitecore.ExperienceAnalytics.Aggregation.Pipeline.SegmentProcessor.ProcessSegments(AggregationPipelineArgs args, IEnumerable`1 segments)
   at Sitecore.ExperienceAnalytics.Aggregation.Pipeline.SegmentProcessor.OnProcess(AggregationPipelineArgs args)
   at Sitecore.Analytics.Aggregation.Pipeline.AggregationProcessor.Process(AggregationPipelineArgs args)

Nested Exception

Exception: System.NullReferenceException
Message: Object reference not set to an instance of an object.
Source: Hi.UrlRewrite
   at Hi.UrlRewrite.Analytics.ByUrlRewriteRedirect.<ExtractDimensionKeys>d__2.MoveNext() in C:\git\UrlRewrite\Hi.UrlRewrite\Analytics\ByUrlRewriteRedirect.cs:line 27
   at System.Linq.Enumerable.WhereEnumerableIterator`1.MoveNext()
   at Sitecore.ExperienceAnalytics.Aggregation.Dimensions.PageEventDimensionBase.GetDimensionKeys(IVisitAggregationContext context)
   at Sitecore.ExperienceAnalytics.Aggregation.Dimensions.PageEventDimensionBase.<GetData>d__8.MoveNext()
   at System.Linq.Enumerable.WhereEnumerableIterator`1.MoveNext()
   at Sitecore.ExperienceAnalytics.Aggregation.Pipeline.SegmentProcessor.ProcessSegments(AggregationPipelineArgs args, IEnumerable`1 segments)

Steps to reproduce: install fresh 8.1u3 instance install url rewrite 1.8.1.3 deploy marketing definitions smart publish site

in incognito window:

validate interaction logged to analytic db via robomongo Open content editor delete simple external redirect item smart publish site

attach secondary reporting database create new connection string for reporting.secondary rebuild reporting database (/sitecore/admin/rebuildreportingdb.aspx)

Expected Behavior Application does not process redirects for items now missing

Actual Behavior Sitecore halts processing interactions, cannot rebuild analytics db.

We were able to work around this problem by checking for a null item when grabbing the pageEvent from Sitecore. I will submit a pull request shortly with the code we are using to work around the issue; I'm not sure this is how you would want to handle reporting or not, but it allowed us to get Experience Analytics working again.

derekcorreia commented 7 years ago

35 has been submitted. Thanks.