Question

Can I use wildcards when adding a snapshot to an event?

  • 4 May 2022
  • 1 reply
  • 42 views

Userlevel 1
Badge +1

I have a custom field where I would like to know what the value was at the time the user clicked into the field. This is what I added to the snapshot:

 

input.text[type="text"][name="ctl00$MainContent$txt_cust_field_name"]#txt_cust_field_name


1 reply

Userlevel 4
Badge +2

Hey @DaniB — The answer is a qualified yes but I’m not sure if you’re referring to the event definition, or the Snapshot. Let me cover both and see if it answers your question. 

Wildcards in events: you can use the wildcard * character to stand in for any portion of the selector when defining an event. This is commonly used for filling in unique parts of a path like /app/env/*/definitions where the wildcard stands in for everyone’s unique Heap environment id. Other use cases are for accommodating libraries that add random and periodically changing text to the end of classes, so you might define a click event on an element with class .profileName-fr56yh as .profileName-*. Snapshots will work with events defined like this. 

Wildcards in Snapshots: If you need to wildcard part of your Snapshot, you can do this, but not in exactly the same way. Returning to the click example above, that won’t work in the Snapshot as it is not a valid JavaScript selector.  (Even if you’re not using the JavaScript option, it is converted to JavaScript under the hood.) Instead, you would take an approach similar to what we describe here on simplified regex and attributes. So a Snapshot to capture the value above would be written as [class^=profileName] (class starts with profileName) or [class*=profileName]  (class contains profileName) depending on where it falls in the class list. The latter is generally the right approach, but it depends on the markup. 

Does that help? 

If you’re having specific issues with capturing the data you want, it might be worth contacting support@heap.io where you can share more detail without risking sharing data that might be inappropriate for this forum. 

Reply