Access tracked variables in VanillaJS?

Add import { on } from "@ember/modifier"; and this should work.
It’s a good idea to look at the Discourse source code. It’s a good place to learn with existing code.