As part of SCHackathon 2018, I created a custom Event (a generic Event, not a Page Event, although I will change it to a Page Event and see if that helps see notes below).
I followed the docs here: https://doc.sitecore.net/developers/xp/xconnect//xconnect-model/events/create-event.html
I was able to attach the event to a Contact's Interactions. (Practically identical code to this post: Single contact showing in Sitecore Experience Profile)
This is confirmed by getting the specific user/contactReference:
// Get all available contact facets in current model
var contactFacets = client.Model.Facets.Where(c => c.Target == EntityType.Contact).Select(x => x.Name);
// Get all available interaction facets in current model
var interactionFacets = client.Model.Facets.Where(c => c.Target == EntityType.Interaction).Select(x => x.Name);
var contactReference = new IdentifiedContactReference(source, identifier);
var contact = client.GetAsync(contactReference, new ContactExpandOptions(contactFacets.ToArray())
{
Interactions = new RelatedInteractionsExpandOptions(interactionFacets.ToArray())
{
// Get all interactions
EndDateTime = DateTime.MaxValue,
StartDateTime = DateTime.MinValue
}
}).Result;
Now, where I am having issues. I am trying to Search all Contacts that have this Event. So, I followed the Search docs here: https://doc.sitecore.net/developers/xp/xconnect//xconnect-client-api/search/index.html and here: https://doc.sitecore.net/developers/xp/getting-started/
I found the simplest search returns 0 records!
var count = client.Contacts.ToEnumerable().Count();
Console.WriteLine("Count: " + count);
Therefore, doing any additional filtering is pointless.
But, what I am really trying to achieve is this:
var queryable = client.Contacts
.Where(c => c.Interactions.Any(x => x.Events.OfType<CustomEvent>().Any()))
While preparing this, I believe it is due to the Event not being a PageEvent and therefore not being a "web" interaction it is causing the contact to not get aggregated. I will updated as I learn more. But any help/insight is greatly appreciated.
Any ideas?