Add-ons should be able to be installed on every Clockify workspace, irrespective of environment where the workspace is located.
To ensure that add-ons will work on all environments, you should avoid making use of hardcoded values for API endpoints and UI locations and instead always retrieve environment-specific values from the token claims.
Different environments where a workspace can be located are:
Clockify workspaces can be located in each of the available regions. If a workspace is located on a region, the entirety of the data for that workspace is also located in that region. Each region exposes its own API locations.
A Clockify workspace can also be located on a subdomain. Workspaces that are located on subdomains have custom UI locations. A workspace that is located on a subdomain can also be located on a specific region.
When testing your add-on, you may notice that the environment on which you have installed the add-on is a completely separate one. The development environments use their own separate locations for all API endpoints.
To ensure that add-ons can work independent of the environment where they are installed, we have to retrieve all the environment-related information from the add-on authentication token - which is in fact a JWT.
The following claims can be used to determine the locations where API calls must be made for a specific workspace:
The above claims represent the locations of the backend, reports, locations and screenshots API services.
The add-on token contains other claims which may be used to identify the add-on installation and retrieve other useful information such as the workspace where the add-on is installed, or the user that is currently logged in.
The following claims can be used to retrieve more info related to the add-on installation:
The above claims are available for both installation and user tokens.
Apart from the claims which provide information related to the environment where the add-on is installed, there are also claims which provide information related to the user who is interacting with your add-on.
The following claims can be used to retrieve more info related to the user who is interacting with the add-on UI components:
The above claims are only available for user tokens.