Custom Interactions

To understand which features and UI components a subscriber interacted with and how they flow through a user journey, create custom interactions with Apex enums and the IsvPartners.AppAnalytics.logCustomInteraction Apex method.

Required Editions
Available in: both Salesforce Classic and Lightning Experience
Available in: Enterprise, Performance, Unlimited, and Developer Editions
Standard DataSupplemental Data
  • class_name
  • method_name
  • line_number
  • interaction_id_token
api_version

Successful Custom Interactions 

To analyze a custom interaction with your packaged components, look for a log_record_type of CustomInteraction and a custom_entity_type of CustomInteractionLabel. The custom_entity contains a custom interaction label that you created and that was logged.

interaction_id_token is included only if an interaction_id was provided to the associated IsvPartners.AppAnalytics.logCustomInteraction call. interaction_id_token is a hashed, tokenized version of the raw interaction id that was provided.

Note

Unsuccessful Custom Interactions 

When custom_entity_type is equal to CustomInteractionFailure then the custom interaction couldn’t be logged. To determine the reason for the failed logging, review the reason code provided by the custom_entity value.

custom_entityMessage
LABEL_NO_NAMESPACEWe couldn’t log the custom interaction with App Analytics. The interaction label provided to IsvPartners.AppAnalytics.logCustomInteraction must have a namespace.
LABEL_NOT_ENUMWe couldn’t log the custom interaction with App Analytics. The interaction label provided to IsvPartners.AppAnalytics.logCustomInteraction must be an Apex enum.
LABEL_WRONG_NAMESPACEWe couldn’t log the custom interaction with App Analytics. The interaction label provided to IsvPartners.AppAnalytics.logCustomInteraction must have the same namespace as the Apex code that called the method.
OVER_CALL_LIMITIsvPartners.AppAnalytics.logCustomInteraction was called too many times in a single user request. This custom interaction and subsequent ones for this user request weren’t logged with App Analytics.

Example 

Let’s look at an example package usage log record and analyze a successful Apex interaction.

1{
2    "timestamp_derived": "2023-09-20T06:17:39.167Z",
3    "log_record_type": "CustomInteraction",
4    "request_id": "TID:7635077000004b3035",
5    "organization_id": "00Dxx0000006H2l",
6    "organization_name": "MyCustomer Inc.",
7    "organization_status": "Demo",
8    "organization_edition": "Enterprise Edition",
9    "organization_country_code": "IN",
10    "organization_language_locale": "en_US",
11    "organization_time_zone": "Australia/Sydney",
12    "organization_instance": "GS0",
13    "organization_type": "Production",
14    "user_id_token": "005-9BwnBWYO5FMn4cZ1sLw7F3LmTpoe8M77GrZOZHL6xQk=",
15    "user_type": "Standard",
16    "package_id": "033xx0000004FqD",
17    "package_version_id": "04txx0000004Idi",
18    "managed_package_namespace": "Acme",
19    "custom_entity": "MyInteractionLabels.LoginButtonClicked",
20    "custom_entity_type": "CustomInteractionLabel",
21    "session_key": "2l4YtFB/RmsRKVsS",
22    "login_key": "fGV6RgVOH3ZCgl2v",
23    "user_agent": "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/IP_ADDRESS_REMOVED Safari/537.36",
24    "user_country_code": "US",
25    "user_time_zone": "America/Los_Angeles",
26    "class_name": "Acme.MyController",
27    "method_name": "loginButtonCallback",
28    "line_number": 56,
29    "interaction_id_token": "7NDe8HM8ZgPdBL+jiOpTW3/xKTwwL30dyxmKNxtyzi8="
30}

The MyInteractionLabels.LoginButtonClicked custom interaction label was logged as a custom interaction as a result of a user action from subscriber org MyCustomer Inc on 2023-09-20 at 6:17 am. Specifically, the user interaction resulted in logging a custom interaction from line number 56 of the loginButtonCallback method found in the Acme.MyController Apex class. In addition to the InteractionLabels.LoginButtonClicked label, an interaction ID was provided to the log call resulting in an interaction token id value of 7NDe8HM8ZgPdBL+jiOpTW3/xKTwwL30dyxmKNxtyzi8=.

The key data in this analysis are:

QuestionFieldValue
What
  • class_name
  • custom_entity
  • custom_entity_type
  • package_version_id
  • managed_package_namespace
  • class_name
  • method_name
  • line_number
  • interaction_id_token
  • Acme.MyController
  • MyInteractionLabels.LoginButtonClicked
  • CustomInteractionLabel
  • 04txx0000004Idi
  • Acme
  • loginButtonCallback
  • 56
  • 7NDe8HM8ZgPdBL+jiOpTW3/xKTwwL30dyxmKNxtyzi8=
Who
  • organization_id
  • user_id_token
  • 00Dxx0000006H2l
  • 005-9BwnBWYO5FMn4cZ1sLw7F3LmTpoe8M77GrZOZHL6xQk=
Howlog_record_typeCustomInteraction
Whentimestamp_derived2023-09-20T06:17:39.167Z

See Also