Uncanny dodge is clear, but only if you understand the style writing practices of 5e, which many (perfectly understandably) don't pay attention to until it matters. In this case, the wording on the ability is specific - it's when you are hit. That's a different trigger timing to "When you (or a target) is attacked" and it's different again to "When you Take Damage".
Three examples:
Protection Fighting Style's trigger is when a valid target "is attacked"; you must decide when the attack is declared; this means that you decide before the attack is rolled, and thus before you know whether it would be a hit or not.
Uncanny Dodge is triggered when you "are hit"; you decide when an attack hits you; this means that you do not have to use it before the attack is rolled, and so you cannot waste it on an attack that would miss anyway, but you must decide when the hit is confirmed, before the damage is rolled.
Misty Escape (Warlock fey pact feature) is triggered when you "take damage"; you decide to use it once you take damage - after the attack is declared, after it is rolled and the hit confirmed, and after the damage is rolled.
This is not a 'Dm discretion' thing, it's a RAW thing; as always individual Dms can rule otherwise - but by base rules, it's distinct and clear in its timing, and it's before the damage roll that the decision must be made. If the game tells you the damage first, then it is giving you a very prominent concession that makes the ability more powerful than it is meant to be - it removes a lot of the decision cost of whether to use it or not - however, I'm happy to concede that this may not be a bad thing for a video game setting/translation.