In plugin development, how do you know which file the user is in?

Hello Figma Community,
When you are developing a Figma plugin have you ever been in a scenario where you needed to know and keep a record of what file the user is in? How did you do it?

You can check the document name or fileKey (if it is a private plugin).