-
-
Save islaytitans/c346c11576403bcd155ecfee041b5ab3 to your computer and use it in GitHub Desktop.
Gets goals from the Sitecore xDB
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class GetGoals : ReportProcessorBase | |
{ | |
private readonly QueryBuilder goalsQueryBuilder = new QueryBuilder() | |
{ | |
collectionName = "Interactions", | |
QueryParms = | |
{ | |
{ | |
"ContactId", "@contactId" | |
}, | |
{ | |
"Pages.PageEvents.0", "{$exists:1}" | |
} | |
}, | |
Fields = | |
{ | |
"_id", | |
"ContactId", | |
"Pages_PageEvents_PageEventDefinitionId", | |
"Pages_PageEvents_DateTime", | |
"Pages_PageEvents_Data", | |
"Pages_Url_Path", | |
"Pages_Url_QueryString", | |
"Pages_PageEvents_Value", | |
"Pages_Item__id" | |
} | |
}; | |
public override void Process(ReportProcessorArgs args) | |
{ | |
DataTable goalsData = this.GetGoalsData(args.ReportParameters.ContactId); | |
args.QueryResult = goalsData; | |
} | |
private DataTable GetGoalsData(Guid contactId) | |
{ | |
ReportDataProvider reportDataProvider = this.GetReportDataProvider(); | |
Assert.IsNotNull((object)reportDataProvider, "provider should not be null"); | |
return reportDataProvider.GetData("collection", new ReportDataQuery(this.goalsQueryBuilder.Build()) | |
{ | |
Parameters = | |
{ | |
{ | |
"@contactId", (object) contactId | |
} | |
} | |
}, new CachingPolicy() | |
{ | |
NoCache = true | |
}).GetDataTable(); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment