Dynatrace allows you to identify users across sessions and devices, manage session lifecycle, and attach properties that apply to all events in a session.
Use identifyUser() to tag the current session with a user identifier. This enables you to track individual users across different sessions, browsers, and devices.
import { Dynatrace } from '@dynatrace/react-native-plugin';// After user logs inDynatrace.identifyUser("user@example.com");// Or use an internal user IDDynatrace.identifyUser("user-12345");
To remove the user tag (for example, on logout), pass null or an empty string:
import { Dynatrace } from '@dynatrace/react-native-plugin';function logout() {// Clear user identificationDynatrace.identifyUser(null);}
identifyUser() for every new session.When the user closes the app or when privacy settings change, sessions are not automatically re-tagged. You must call identifyUser() again after the new session starts.
Session properties are key-value pairs that apply to all events in the current session. Use them to add context that characterizes the user's session.
Before you can send event or session properties from your application, you must first define them in the Dynatrace web UI. Any properties that are not pre-configured will be discarded.
To define a new property:
Experience Vitals, select the frontend for which you want to add the property.cart.total_value).string, boolean, or number.Dynatrace automatically prefixes your field name with event_properties. or session_properties. based on the property type you selected. For example, a field name of cart.total_value will become event_properties.cart.total_value.
Session properties apply to all events within the current session. Use sendSessionPropertyEvent() to set properties using the SessionPropertyEventData class that should be available across the entire user session.
import { Dynatrace, SessionPropertyEventData } from '@dynatrace/react-native-plugin';// Set session-wide propertiesDynatrace.sendSessionPropertyEvent(new SessionPropertyEventData().addSessionProperty("session_properties.user_tier", "premium").addSessionProperty("session_properties.app_version", "2.1.0").addSessionProperty("session_properties.feature_flag_enabled", true));
Allowed properties:
session_properties.*.Property limits:
Field naming rules:
session_properties. prefix).Session property behavior:
Valid examples:
session_properties.user_tiersession_properties.app_versionsession_properties.feature_flag_enabledSession properties require server-side configuration in Dynatrace. Properties that are not configured will be dropped during ingest.
You can send session properties multiple times during a session. However, if you send the same property multiple times, session aggregation will keep only one value (first or last, depending on configuration).
import { Dynatrace, SessionPropertyEventData } from '@dynatrace/react-native-plugin';// Initial propertiesDynatrace.sendSessionPropertyEvent(new SessionPropertyEventData().addSessionProperty("session_properties.cart_value", 0));// Update after user adds itemsDynatrace.sendSessionPropertyEvent(new SessionPropertyEventData().addSessionProperty("session_properties.cart_value", 149.99));
Use endSession() to manually close the current session and start a new one. All open actions are closed and sent to the server.
import { Dynatrace } from '@dynatrace/react-native-plugin';function logout() {// Clear user identificationDynatrace.identifyUser(null);// End the current sessionDynatrace.endSession();}
identifyUser() API again.