Skip to main content

Session properties

Session properties

Session properties are another way to annotate a session. The difference between session properties and user personas is that the former are for items relating to the session or the device and not necessarily to the user. However, you are free to use both mechanisms interchangeably.

Property scopes

The PropertyScope parameter controls how long a property is retained:

ScopeDescription
PropertyScope.USER_SESSIONProperty is attached to the current session only and is cleared when that session ends.
PropertyScope.PROCESSProperty persists for the lifetime of the process, surviving session boundaries, but is cleared when the process exits.
PropertyScope.PERMANENTProperty persists across all sessions and process restarts until explicitly removed.

Setting properties

Here is an example of setting a session property scoped to the current session:

Embrace.addUserSessionProperty("launch type", "normal", PropertyScope.USER_SESSION)

To retain a property across all sessions:

Embrace.addUserSessionProperty("launch type", "normal", PropertyScope.PERMANENT)

To remove a property that has been previously set:

Embrace.removeUserSessionProperty("launch type")
Limits on Properties
  • Property keys have a limit of 128 characters.
  • Property values have a limit of 256 characters.
  • You can have up to 100 session properties.

In the above, the "launch type" property is set with a value of "normal". This is to indicate normal launches by the user. When the app is launched via a push notification tap, you can set the value "push". This can help to understand issues that are hurting push notification adoption rates. For example, you could prioritize fixing the issues that affect customers that use push notifications, since they generally provide higher lifetime value.