Pre-Published vs. Published vs. Development, for Uplink

Once an App is Published, an Uplink module can tell whether it is servicing a Published version, or a Development version, by examining its Uplink key. It can then adapt its behavior appropriately, e.g., logging more detailed information in the Development case. This is helpful, because the Development version of an app is subject to much more rapid change, and therefore a greater risk of (developer-induced) bugs.

Before the App is Published, however, how can an Uplink module tell that it is essentially working with a Development version of the App (and so should engage in Development-style behaviors)? The key looks just like a Published-version key, so that doesn’t help.

You can check anvil.app.branch (read the docs), which will tell you whether you’re on master (development) or published (published).

(Of course, if you start “unpublished”, and then publish a version of your app while you have an uplink connected, it’s good practice to reconnect your uplink, which will cause it to reconnect to the published branch.)

Aha!

So, if

  1. the Uplink module is connected to branch “master” (development), but
  2. the key does not end in ‘-DEV’,

then it must be operating on an App that is in a pre-production state.

I’ll give it a try. Thank you!