Hey,
I’m wondering if there exists a good practice for defining global variables in Studio projects?
I’d like to define some strings in the root symbol of the project and access these in subsymbols living quite deep inside other subsymbols. Currently trying to implement a definition script where I could set Zapalytics strings and then apply these in subsymbols that need to log events.
In the root I have a script ‘globals’ with:
export namespace analytics {
export const someString = "test";
}
And in a script inside a subsymbol:
var a = root__sym__globals.analytics;
console.log(a.someString); // will later become Z.stats.logEvent()
The Studio editor seems to think this is ok as it doesn’t tell me about errors and the autocomplete finds root__sym_globals.analytics. However, as I try to publish the zap, the compiler throws me an error about not finding it. I assume my way is too much of a hack and not the intended way of doing this…
Anyone know how I could accomplish what I’m trying to do? I’d be happy with something hacky and working for now as I’d love to implement this in my project right away. This could be later polished to become a useful tool (zapalyticsManager) for any Studio project.