Is it possible for a plug-in to know whether it’s running in the live or development version of an app?
I can’t seem to find such a flag in the plug-in docs, but I hope I’m overlooking something. In the absence of an “official” indicator, has anyone come up with a tip or trick for checking this?
Two things I can think of, but they’re not completely 100% future proof as it’s not an official API and they may change, but you can check if the url contains version-test right after the domain name and also bubble declares this variable upon page load, so you can check it too:
var app = {};
app = {};
app["last_change"] = "4621869430";
app["last_change_as_of"] = 1615228286465;
app["_id"] = "unlimitedbubbling";
app["app_version"] = "test";
// ... a lot more stuff
So if you do console.log(app.app_version) you get this: “test”.
A more stable way is to have a yes/no field in the plugin that you instruct the user to pass the “isn’t not live testing version” () data.
Thanks, @vini_brito. I appreciate you taking the time to reply.
Yeah, that occurred to me, but I dismissed it, since it will break under Bubble plans that offer different versions.
Now that didn’t occur to me. I think that might suit me for now, assuming it says “test” for any app version except the live / production version.
(I understand about the special property, but I’d rather not bother the user about it for this use case. I’m actually doing exactly that in a different plugin though, so great advice!)
While the app_version property will have a different value for different development versions, it will always be “live” for the live version. Thus, one can simply test for “live” to determine if it’s production or development.
A tricky one for you @sudsy and @vini_brito , which seems to me conceptually impossible to implement: how to detect from a plugin Server-side action code that it is running from the “App to test the plugin” ?
This is exactly what I’m doing.
I created a db yes/not field to let my program know which api to use. Just change one entry instead of changing all the backend workflows.