2

I'm unable to receive interaction events by the specific definition id

    using (var client = SitecoreXConnectClientConfiguration.GetClient())
    {
        try
        {
            var events = new List<VotePoll>();

            // VotePoll.VotePollId is "{5D824DC3-52A8-4FBD-A6F4-4782E98C44EA}"
            IAsyncQueryable<Interaction> queryable = client.Interactions
                .Where(x => x.Events.Any(y => y.DefinitionId == VotePoll.VotePollId));

            var enumerable = queryable.GetBatchEnumeratorSync(20);

            while (enumerable.MoveNext())
            {
                var interactionBatchPageEvent = enumerable.Current;

                foreach (var interaction in interactionBatchPageEvent)
                {
                    var matchingEvents = interaction.Events.OfType<VotePoll>()
                        .Where(x => x.DefinitionId == VotePoll.VotePollId).ToList();

                    events.AddRange(matchingEvents);
                }
            }

            return events;
        }
        catch (Exception e)
        {
            throw;
        }
    }

Even though I see that these events were successfully registered enter image description here Does anyone have any ideas on how to resolve the issue?

Here is some more information: The VotePoll event

public class VotePoll : Sitecore.XConnect.Event
{
    public VotePoll(DateTime timestamp)
        : base(VotePollId, timestamp)
    {
    }

    public static Guid VotePollId = Guid.Parse("{5D824DC3-52A8-4FBD-A6F4-4782E98C44EA}");

    public string InteractiveElementId { get; set; }

    public string InteractiveElementAnswerId { get; set; }

    public Guid VisitorId { get; set; }
}

was registered in a custom xDb model

private static XdbModel BuildModel()
{
    var builder = new XdbModelBuilder("InteractiveElementTrackingModel", new XdbModelVersion(1, 0));
    builder.ReferenceModel(Sitecore.XConnect.Collection.Model.CollectionModel.Model);
    builder.DefineFacet<Contact, InteractiveElementTrackingModelFacet>(InteractiveElementTrackingModelFacet.DefaultFacetKey);
    builder.DefineEventType<VotePoll>(false);

    return builder.BuildModel();
}

and deployed to xConnect. The serialized model looks in this way:

{
  "Name": "InteractiveElementTrackingModel",
  "Version": "1.0",
  "References": [
    {
      "Name": "XConnect",
      "Version": "1.0"
    },
    {
      "Name": "Sitecore.XConnect.Collection.Model",
      "Version": "9.0"
    }
  ],
  "Types": {
    "XX.Foundation.CustomInteractiveElementTrackingModel.Models.CustomFacets.InteractiveElementTrackingModelFacet": {
      "Type": "Facet",
      "BaseType": "Sitecore.XConnect.Facet",
      "ClrType": "XX.Foundation.CustomInteractiveElementTrackingModel.Models.CustomFacets.InteractiveElementTrackingModelFacet, XX.Foundation.CustomInteractiveElementTrackingModel, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null",
      "Properties": {
        "InteractiveElementId": {
          "Type": "String"
        },
        "InteractiveElementAnswerId": {
          "Type": "String"
        },
        "QuestionTitle": {
          "Type": "String"
        },
        "AnswerTitle": {
          "Type": "String"
        }
      }
    },
    "XX.Foundation.CustomInteractiveElementTrackingModel.Models.CustomEvents.VotePoll": {
      "Type": "Event",
      "BaseType": "Sitecore.XConnect.Event",
      "ClrType": "XX.Foundation.CustomInteractiveElementTrackingModel.Models.CustomEvents.VotePoll, XX.Foundation.CustomInteractiveElementTrackingModel, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null",
      "Properties": {
        "InteractiveElementId": {
          "Type": "String"
        },
        "InteractiveElementAnswerId": {
          "Type": "String"
        },
        "VisitorId": {
          "Type": "Guid"
        }
      }
    }
  },
  "Facets": [
    {
      "Target": "Contact",
      "Name": "InteractiveElementTrackingModelFacet",
      "Type": "XX.Foundation.CustomInteractiveElementTrackingModel.Models.CustomFacets.InteractiveElementTrackingModelFacet"
    }
  ]
}

The event was registered by tracker

        var eventData = new Sitecore.Analytics.Data.PageEventData(pageEventDefinition.Alias, pageEventDefinition.Id);

        if (data != null)
        {
            eventData.Data = data;
        }

        if (dataKey != null)
        {
            eventData.DataKey = dataKey;
        }

        if (text != null)
        {
            eventData.Text = text;
        }

        if (customValues != null)
        {
            foreach (var customValue in customValues)
            {
                eventData.CustomValues.Add(customValue);
            }
        }

        Tracker.Current.CurrentPage.Register(eventData);

and all the custom properties were transformed in the appropriate pipeline

protected override Event CreateEvent(PageEventData pageEventData)
{
    var votePoll = new VotePoll(pageEventData.DateTime)
                       {
                           InteractiveElementId = (string)pageEventData.CustomValues["InteractiveElementId"],
                           InteractiveElementAnswerId =
                               (string)pageEventData.CustomValues["InteractiveElementAnswerId"],
                           VisitorId = (Guid)pageEventData.CustomValues["VisitorId"]
                       };

    return votePoll;
}

Also when I query Interactions from Shard databases in SqlServer I receive more than 20 Interactions with properly filled VotePoll events. e.g.:

  {
    "@odata.type": "#XX.Foundation.CustomInteractiveElementTrackingModel.Models.CustomEvents.VotePoll",
    "CustomValues": [],
    "Data": "5d824dc3-52a8-4fbd-a6f4-4782e98c44ea",
    "DataKey": "interactiveelementid",
    "DefinitionId": "5d824dc3-52a8-4fbd-a6f4-4782e98c44ea",
    "Id": "efcf3f7b-a899-40e9-9010-21ab7a376bbb",
    "ParentEventId": "56d77129-ba1d-4919-ba64-419c20fecfb6",
    "Text": "Voted by Interactive element",
    "Timestamp": "2019-12-06T13:50:34.4696273Z",
    "InteractiveElementId": "c2a7a5d1-3425-49cd-a1d9-5282cbc79a19",
    "InteractiveElementAnswerId": "e2d77b17-13fc-4fc7-8c0c-26d68fda50fb",
    "VisitorId": "e70535fd-7ee5-4c2a-ac37-fb760009784d"
  }

but nothing is returned via xConnect API

2
  • How did you defined VotePoll class? Can you please update question with this information? Commented Dec 9, 2019 at 17:04
  • @PeterProcházka, I've updated the question with more info. Now it looks much more detailed but less readable. Commented Dec 9, 2019 at 17:42

1 Answer 1

3

It was resolved by enabling indexing for anonymous contacts in sc.Xdb.Collection.IndexerSettings.xml:

  <IndexerSettings>
    <Type>Sitecore.Xdb.Collection.Indexing.IndexerSettings, Sitecore.Xdb.Collection</Type>
    <LifeTime>Singleton</LifeTime>
    <Options>
        <!-- Indexer will split change set on chunks to improve memory consumption. Setting this option to 0, a negative value or removing the element completely, results in no splitting.-->
      <SplitRecordsThreshold>25000</SplitRecordsThreshold>
      <IndexPIISensitiveData>false</IndexPIISensitiveData>
      <IndexAnonymousContactData>true</IndexAnonymousContactData>
    </Options>
  </IndexerSettings>

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.