Custom Adding Actions¶
After initializing RUM, you can use the addAction('<NAME>', '<JSON_OBJECT>') API to add custom Action metric data beyond the standard collection.
Adding an Action¶
Download File for local inclusion
How to Add Custom Actions with the RUM SDK and Avoid Field Conflicts¶
When using window.DATAFLUX_RUM.addAction to add custom data, it's important to avoid conflicts with SDK preset fields. Conflicting fields will cause the data setting to be invalid. Below is an incorrect example and key considerations:
Example Code (Containing Field Conflict)
window.DATAFLUX_RUM.addAction('test action', {
view_url: 'a', // Conflicts with the SDK preset field "view_url", making this field invalid.
b: 'b',
c: 'c',
})
Improved Code and Explanation
Conflicts can be resolved by avoiding names identical to SDK preset fields, opting for custom field names or prefixes instead:
// Recommended custom field naming to avoid conflicts
window.DATAFLUX_RUM.addAction('test action', {
custom_view_url: 'a', // Use a custom field name to avoid conflict with the SDK
b: 'b',
c: 'c',
})
Considerations
- Field Naming Principles: • Avoid using SDK preset fields (such as view_url, view_name, and other common fields). These fields may be used by the SDK for internal logic, causing conflicts. • You can add prefixes (like custom_, user_) to distinguish custom data.
- Impact of Field Conflicts: • If a field name conflicts, the SDK will ignore the custom value for that field. • When required data is not transmitted correctly, checking for field naming conflicts is particularly important.
Below is a reference table of reserved fields:
[
"sdk_name",
"sdk_version",
"app_id",
"env",
"service",
"version",
"source",
"userid",
"user_email",
"user_name",
"session_id",
"session_type",
"session_sampling",
"is_signin",
"os",
"os_version",
"os_version_major",
"browser",
"browser_version",
"browser_version_major",
"screen_size",
"network_type",
"device",
"view_id",
"view_referrer",
"view_url",
"view_host",
"view_path",
"view_name",
"view_path_group",
"view_url_query",
"action_id",
"action_ids",
"view_in_foreground",
"display",
"session_has_replay",
"is_login",
"page_states",
"session_sample_rate",
"session_replay_sample_rate",
"drift",
"action_type",
"action_name",
"duration",
"action_error_count",
"action_resource_count",
"action_frustration_types",
"action_long_task_count",
"action_target",
"action_position"
]