I had a method which worked fine in 8.0 but now is throwing an error in 8.2 Update 2.
The method is:
public bool AddPageEvent(Guid DefinitionId, Guid PageEventItemId, string PageEventName, string PageEventData, string PageEventText) {
try
{
Assert.IsNotNull(Tracker.Current, "Tracker.Current");
Assert.IsNotNull(Tracker.Current.Session, "Tracker.Current.Session");
var interaction = Tracker.Current.Session.Interaction;
Assert.IsNotNull(interaction, "Tracker.Current.Session.Interaction");
Assert.IsNotNull(interaction.CurrentPage, "Tracker.Current.Session.Interaction.CurrentPage");
var pageEventData = new PageEventData(PageEventName, DefinitionId)
{
ItemId = PageEventItemId,
Data = PageEventData,
Text = PageEventText
};
interaction.CurrentPage.Register(pageEventData);
}
catch (Exception ex)
{
Log.Error("MySite.Analytics.PageEvents.AddPageEvent", ex, this);
return false;
}
return true;
}
The following error is being thrown on the first Assert.IsNotNull
:
Exception: System.InvalidOperationException Message: Tracker.Current Source: MySite.Analytics at MySite.Analytics.PageEvents.AddPageEvent(Guid DefinitionId, Guid PageEventItemId, String PageEventName, String PageEventData, String PageEventText) in C:\SRC\Main\Sitecore\MySite.Analytics\PageEvents.cs:line 27
Any ideas why this would throw this error in 8.2?
Analytics.Enabled
setting should be false, and theXdb.Enabled
setting should be true, correct?