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

Userlevel 2
Badge +1
  • Known Participant
  • 7 replies

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:



2 replies

Userlevel 5
Badge +3

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 where you can share more detail without risking sharing data that might be inappropriate for this forum. 

I have a specific use case but can’t seem to get it to work.
If I define the snapshot using the pointer tool, it gets defined as:
and works properly.
Now, I’d need to get everything after bold_ “wildcarded” (turn ‘1mbrz_132’ to ‘*’ basically)
How would this look like?
Any ideas are highly appreciated :)