Predominant Activity Time Enricher


The Predominant Activity Time enricher for SAP Hybris Profile listens for system events related to user session start time.

When the system sends these events, the Predominant Activity Time enricher adds a new subdocument to the user's profile document. Based on the defined rules, the enricher not only computes and adds the current activity classifier to the relevant session, but also maintains a long-term activity affinity stored in the profiles/insights subdocument.


The following schema triggers the Predominant Activity Time enricher:

Triggering schemaSample payload of a context eventEvent outcome in the profile document
/context/commerce/SessionStartedExampleSample profile

The enricher writes to the following subsections of a customer profile:

  • profiles/observations/web
  • profiles/insights/affinities

Data Consumption

Add information to the customer profile

The enricher calculates the customer-side time, in hours and minutes with minutes accuracy, based on the values of the source/event/h and source/event/m properties of the received SessionStarted event. The system then stores the following data:

  • Long-term activity classifier affinities in the insights/affinities/predominantActivityTime section. The system uses a defined dictionary to compute this value.

  • Session data in the profiles/observations/web/{sessionId} section, where {sessionId} is a session identifier that the system saves with the predominantActivityTime subsection that contains current activity classification, computed according to the defined rules.

Activity Classifier

You can set up the computing rules for the activity classifier in the Configuration Explorer. To do so, create a variable with the name activity_time_classification and set its value according to your need. By default, the enricher uses the following rule set:

  "morning": {
    "startAt": "05:00:00",
    "endAt": "10:00:00"
  "noon": {
    "startAt": "10:00:00",
    "endAt": "14:00:00"
  "afternoon": {
    "startAt": "14:00:00",
    "endAt": "19:00:00"
  "evening": {
    "startAt": "19:00:00",
    "endAt": "23:00:00"
  "night": {
    "startAt": "23:00:00",
    "endAt": "05:00:00",
    "transition": true

The property transition informs you whether a date change occurs during the period specified by the startAt and endAt parameters, which are formatted as valid JavaScript objects. If the date changes, set the value of this parameter to true. If the date does not change, do not set this parameter.

To determine a user's predominant activity time, you must define time ranges that cover all 24 hours of a day. It means that the end time of one range is the start time of the next one. However, the startAt parameter is exclusive, and the endAt is inclusive. Therefore, the Predominant Activity Time enricher with the default setting classifies an event retrieved at 10:00:00 into the morning range.

Corner cases

You might encounter some corner cases regarding the configuration of time ranges. First, the system takes the configuration defined in the Configuration Explorer. If the activity_time_classification variable is not configured or the JSON file with the value is invalid, then the system uses the default configuration. However, the tenant can prepare a JSON file that contains invalid information. This can happen when:

  • time range configurations in the subsequent subsections overlap. In this case, the system reports the first matching time range. For example, when a retrieved event fits in more than one time range, the first range that comes in the document defined in the Configuration Explorer applies. The system does not reorder the properties while storing, getting, or processing the activity_time_classification variable.

  • time range configurations contain gaps. In this case, the system sends no reports and logs information about its inability to calculate a valid range.

  • time range configurations are syntactically or semantically wrong. In this case, the system stops the flow and adds logging information.

  • Send feedback

    If you find any information that is unclear or incorrect, please let us know so that we can improve the Dev Portal content.

  • Get Help

    Use our private help channel. Receive updates over email and contact our specialists directly.

  • hybris Experts

    If you need more information about this topic, visit hybris Experts to post your own question and interact with our community and experts.