Get target selector for entity which was last interacted with?

I'm trying to use an advancement to detect a player interacting with an entity, so I can trigger a function which affects that entity's data, via the data command. To do this, I need the entity's UUID, or maybe a target selector which can select the last-interacted-with entity. How can I do this? Is there a a way to get additional information from the trigger?

    "criteria": {
        "sole_criterion": {
            "trigger": "minecraft:player_interacted_with_entity",
            "conditions": {
                "item": {
                    "items": [ "minecraft:potion" ],
                    "potion": "minecraft:thick"
                },
                "entity": {
                    "type": "minecraft:villager"
                }
            }
        }
    }```
Continue to help post