Determine if on "hosted test" or "published"?

Hey, yes that’s possible by checking the url query parameter “state”.
See here https://dev.twitch.tv/docs/extensions/reference/#client-query-parameters