Profiles
Profiles in Superblocks make it easy to manage and customize credentials and variables for different development environments, like Production, Staging, or Development, as well as different regions within those environments, like us-east vs us-west.
- Use Development configurations in Superblocks Edit modes, Staging data sources to review and test changes, and Production once Applications, Workflows, and Scheduled Jobs are deployed.
- Add multiple Production Instances (ex:
us-east
,us-west
,eu-west
, etc) to your Application’s deployed mode. Let users switch between Profiles to fetch region specific data.
Manage organization profiles
Your Superblocks account comes with two built in profiles, Staging and Production.
Admins can create new profiles to represent the stages in your company’s software development lifecycle. To add a profile:
- Navigate to the Profiles page under Organization Settings
- Click Add Profile
- Provide a unique name for your profile and optional description
- Click Create
Each profile has a unique alphanumeric key associated with it. Use the key when referencing the profile directly. The key can’t be changed once you’ve created the profile to prevent references from breaking.
Once you’ve created a new profile, you can start:
- Configuring integration credentials
- Using profiles in Applications, Workflows, and Scheduled Jobs
- Deploying On-Premise Agents to multiple environments
Configuring integration credentials
In Superblocks, integrations can have many configurations to help connect to different database instances or API servers. Each configuration can then be linked to one or more profiles. Configurations define the set of credentials used when an API, Workflow, or Scheduled Job executes against a profile (e.g., when executing a Workflow against staging).
To update the configuration associated with a profile:
- Navigate to Integrations and search for your integration or create a new one
- Upon creation, the integration has only a Default configuration that applies to all profiles. Click the ➕ icon to "Add new configuration" and select the profile(s) that will be used for this configuration
- Fill out the configuration form with values specific to the selected profiles
- Click Test Connection to check that Superblocks can connect to the data source
- Once you’ve successfully connected, Create or Save changes to your integration's configurations
Using profiles
With your integrations configured to connect to databases and APIs in different environments, you can now start building Apps, Workflows, and Scheduled Jobs to leverage these different configurations.
Add profiles to Edit, Preview, or Deployed modes
Profiles can be added or removed from the Edit, Preview, or Deployed mode of your Apps, Workflows, and Scheduled Jobs from the Profile Settings menu. Access the menu from the Settings icon on the lower left corner of any App, Workflow, or Scheduled Job then click Profiles.
To make additional profiles available in each mode:
- Click the ➕ icon next to the profiles for the desired mode
- Choose the profile to add to the mode
To remove a profile, click the trash can icon.
Since Scheduled Jobs cannot be invoked by end-users, you only need to choose which profile to use in Edit and Deployed modes. The Edit mode Profile will be used when running the job interactively while the Deployed mode Profile will be used when the job runs on its schedule.
Change the default profile
When multiple profiles are available in Edit, Preview, or Deployed mode, you can set a default profile for the mode. This is the profile that will be used to execute APIs when the Application first loads, or when Workflows are called without a profile specified.
To change the default profile, select the radio button next to the profile you want to use by default when APIs run:
Change the current profile from the Application UI
When multiple profiles are available in an Application, you can let users change the current profile using the Set Profile action.
Use this action to change the selected profile:
- When a user selects a new profile from a Dropdown
- When changing between Tabs in your application
- Before running a particular API that is triggered on a Button click
For example, let's say we're building an Application that shows orders made by European, US, and Japanese customers. There are separate Orders
databases in each region that we'll query to get customer orders to show to our Support Agents.
To support this, we’ve created separate profiles for our Europe, United States, and Japan regions. To let our Support agents change between regional data centers, we’ve added a Dropdown to the Application listing all the available profiles.
Since only Staging is available in Edit and Preview modes, the dropdown will only show Staging in these modes. When the Application is deployed though, the three Production profiles, Europe, Japan, and United States will be shown to users.
When the user selects their desired region from the dropdown, that profile is activated and the getOrders API is re-run, fetching data from that region’s databases.
If you would like to replicate this feature in your application, we have created a guide here as a starting point.
Reference profiles in code
Profiles can be referenced in code using {{Global.profiles}}
. The profiles object has the following attributes available:
Attribute | Description |
---|---|
{{Global.profiles.available}} | Returns the full list of profiles defined in Profile Settings for the current mode of your App, Workflow, or Scheduled Job. Ex: When viewing your deployed Application, this will only list the profiles set up for the Deployed mode. |
{{Global.profiles.default}} | Returns the default profile for the current mode of your App, Workflow, or Scheduled Job. |
{{Global.profiles.selected}} | Gives you the currently selected profile that will be used when executing APIs. This value will change when calling the Set Profile action. |
Use cases
Change profile with a URL query parameter
It's possible to control the selected profile with a query parameter in the Application URL (e.g, https://app.superblocks.com/applications/<APP_ID>?env=production
). For example, using a query parameter named env
, this can be implemented with the following:
- Add a backend API with a single JavaScript step that evaluates the query parameter.
if (Global.URL.queryParams.env) {
return Global.profiles.available.filter(item => item.key == Global.URL.queryParams.env)[0].id;
} else {
return Global.profiles.selected.id
}
- Configure the API to always run on page load.
- Configure the API response onSuccess handler to Set Profile to the Profile returned by the API, and run any APIs that depend on the Profile.
- Set dependent APIs to never run on page load.
Restrict profiles based on user group
If certain users should only have access to a subset of environments, users can restrict which profiles are available in their UI. Example if using a Dropdown:
Dropdown options code
{{Global.profiles.available.filter(item => {
if (Global.mode == 'EDIT' || Global.user.groups.map(item => item.name).includes("Engineering")) {
return true;
} else if (item.displayName.startsWith('Prod')) {
return true;
}
})}}