Customize your embed
Changelog and versioning
The version of the styling contract, what a release can change, how long an old name keeps working, and how to pin the plugin.
The names on the Customize your embed pages are one contract with one version number: part names, states, theme fields, layout values, hide keys, text keys and attributes such as sizing-mode. This page tells you what a release can change, how long an old name keeps working, and how to stay on a plugin version you tested.
The version you have
The contract is at version 1.0.0. It first ships in plugin {{PLUGIN_VERSION}}. Read the contract version in your code:
import { EMBED_PARTS_VERSION } from '@databrainhq/plugin/parts';
console.log(EMBED_PARTS_VERSION); // "1.0.0"The number has two parts that matter to you:
- Major (the
1in1.0.0) goes up when a name is renamed or removed. - Minor (the first
0) goes up when a name is added.
A fix that keeps every name does not change the number. Before each release, a check compares every part name, element host, state token and text key with a frozen list. A rename or a removal fails that check until the major number goes up.
What a release can change
| Change | Example | Contract version | What you do |
|---|---|---|---|
| A name is added | A new part, a new state, a new theme field, a new value in a list, a new text key or hide key | Minor, for example 1.1.0 | Nothing. An embed that does not set the new name looks as before. |
| A bug is fixed and every name stays | A part that did not get its state token now gets it | No change | Nothing. |
| A name is deprecated | An old key gets a newer way | No change | Move to the newer way within 12 months. See Deprecation. |
| A name is renamed or removed | A part name changes | Major, for example 2.0.0 | Follow the steps in the changelog entry before you upgrade. |
| Markup or class names inside the embed change | A hashed class name such as .Card_x7f2 changes | Not in the contract | Nothing, if you use parts. CSS and tests on class names can break in any release. |
A value that is not on a list, or a key the embed does not know, is never an error. The embed drops it, keeps the rest, and logs one console warning with the allowed values and a link to the reference page.
Deprecation
When a name gets a newer way:
- The changelog entry and the reference page mark the old name as deprecated and name its replacement.
- The old name keeps working for at least 12 months after that changelog entry.
- While it works, the embed logs one console warning per page load: the old name, its replacement and the link to its page.
- The old name goes away only in a major version. The changelog entry for that version lists it.
Names that have a newer way today
These old names have a newer way, and none of them is deprecated. They keep working with no warning. You can move when it suits you.
| Old name | Newer way | How the two work together |
|---|---|---|
isHideChartSettings, isHideTablePreview, global | hide keys | A thing is hidden when the old flag or the hide key hides it. hide never shows a thing that an old flag hid. |
custom-messages keys empty, noData, error, retry | The text keys | When you set an old key and its new key, the new key wins. |
| CSS and test selectors on class names inside the embed | Parts and states | Class names were never in the contract. Move from internal class names to parts shows each step. |
Pin a plugin version
The styling contract ships in @databrainhq/plugin. Pin the plugin when you want to choose the day you get a new release.
npm
Install an exact version, with no ^ or ~ in front of it:
npm install --save-exact @databrainhq/plugin@<version>Your lock file then keeps that version for every install. To see the versions that each tag points to:
npm view @databrainhq/plugin dist-tags| Tag | What it is | Use it for |
|---|---|---|
latest | The current release. npm install @databrainhq/plugin installs it. | Production. |
next | A preview build of the next release. It changes often. | Trying a fix or a new option before it ships. Not for production. |
Script tag
Put the version in the URL. A URL with no version gets the latest release, which changes when we release:
<script src="https://unpkg.com/@databrainhq/plugin@<version>/dist/webcomponents.umd.js"></script>A pinned URL always serves the same file, so you can also add an integrity hash for it if your security policy asks for one.
Databrain loader
If your embed uses the Databrain loader, keep the API address it already uses. Use your own install’s loader on self-hosted Databrain. If you use a Content Security Policy, allow the API requests and the runtime’s script and network requests. The loader gives the runtime up to 30 seconds to start and shows an error with a retry when the deadline passes.
The loader can send sampled startup, performance and error events to Databrain. These events can include the plugin version, timing and error codes. Company-attributed events use a short-lived identifier. The loader sends no guest token or dashboard rows in these events. On Databrain Cloud, turning off company product analytics disables processing of company-attributed loader analytics. Startup failures before the loader can identify the company may still be counted as unattributed. In the script tag, set data-analytics="off" to stop that loader from sending events.
Loader settings
Upgrade to the hosted script shows how to add the loader. The script tag takes these optional attributes. The ES module entry, import { load } from '@databrainhq/plugin/loader', takes the same settings as load({ host, pin, analytics, offlineCache }).
| Attribute | load() option | What it does |
|---|---|---|
data-api="https://<your API host>" | host | The API for the loader’s manifest and event requests. See the order below for each entry. |
data-dbn-pin="<version>" | pin | Databrain cloud only. Ask for one published release. A pin that Databrain sets for your account wins over it. A version that is not published is ignored. |
data-analytics="off" or data-dbn-analytics="off" | analytics: false | Send no loader events. |
data-dbn-offline="off" | offlineCache: false | Do not use a cached copy of the release list during an outage. |
data-runtime-source="cdn" | allowRuntimeCdn: true | Self-hosted only: allow a compatible plugin file from cdn.usedatabrain.com. |
The order below assumes valid settings. Use an absolute HTTP(S) URL for an override, and remove an unused override to use the default.
- Self-hosted classic script (
loader.js). Thedata-apiattribute, then the script’s own origin. - Self-hosted ES module (
loader.mjs). Thehostoption, thenwindow.dbn.baseUrl, then the module’s own origin. - Cloud script or npm module. The
data-apiattribute orhostoption, thenwindow.dbn.baseUrl, then the embed’sbaseUrlproperty orbase-urlattribute, thenwindow.dbn.proxyAuthUrl, thenhttps://api.usedatabrain.com.
If your self-hosted API and app use different origins, set the loader’s API explicitly. Use one of these entries after the embed has its guest token:
<script src="https://app.example.com/plugin/loader/v1/loader.js"
data-api="https://api.example.com" async></script>const { load } = await import('https://app.example.com/plugin/loader/v1/loader.mjs');
await load({ host: 'https://api.example.com' });Dashboard and metric requests can still use the page’s window.dbn.proxyAuthUrl or window.dbn.baseUrl. Update any stale page setting to the API or proxy you intend to use. Check the destinations of both the loader and embed requests in your browser’s Network panel.
Load the plugin once on a page. If another copy of the plugin already defined <dbn-dashboard>, the loader loads nothing and writes DUPLICATE_PLUGIN to the console.
On self-hosted Databrain, a release that includes the loader serves it from your install: https://<your install>/plugin/loader/v1/loader.js, or loader.mjs for an ES module. The plugin files come from the same image, so the version matches your install. This is the default on self-hosted Databrain, and release pins do not apply. If your ingress routes paths by hand, send /plugin/ to the app container. The loader calls the backend at /api/loader/v1/, with your other /api/ paths.
What the loader shows when it fails
The loader shows a message in the embed, and the error code under it for your developer.
| Code | Message | Why |
|---|---|---|
MANIFEST_FAILED | Dashboard could not load | Check the API manifest response and its integrity values. On self-hosted installs, also check that / is reachable and valid. The loader offers a retry. |
RUNTIME_UNREACHABLE | Dashboard could not load | The plugin file could not be downloaded, or did not load within 30 seconds. It offers a retry. |
RUNTIME_BLOCKED | This page blocks the dashboard | Open the browser console and find the blocked URL and effective Content Security Policy directive. Allow the needed source in the directive that controls that request, such as script-src-elem for a script element or connect-src for a network request. If the console shows no policy violation, check whether the browser can verify the plugin file’s integrity. |
HASH_MISMATCH | Dashboard code failed a safety check | The downloaded file did not match its fingerprint, so it did not run. |
RUNTIME_FAILED | Dashboard could not start | The plugin stopped with an error. |
TOKEN_MISSING | This embed needs an access token | The element has no guest token. |
TOKEN_INVALID | This dashboard session is not valid | The Databrain API refused the guest token, for example because it expired. Make a new one. |
UNAUTHORIZED_ORIGIN | Can’t be shown on this site | The page’s domain is not in Data Apps > Domains. The message names the domain to add. |
Self-hosted Databrain
If you use a plugin older than 0.17.0, update it to use dark mode. The release with this styling contract ({{PLUGIN_VERSION}} or later) adds derived brand colors in dark mode when you select the built-in Brand chart palette.
Use the plugin version that your self-hosted release names. Each release in the self-hosted changelog has a Plugin Version line. If your release has no such line, ask Databrain support which version goes with it. Upgrade the plugin when you upgrade the images, not before.
Where to read what changed
- Product changelog, for Databrain cloud. Each entry names its plugin version.
- Self-hosted changelog, for self-hosted installs.
- The contract history below, for changes to the names on these pages only.
Contract history
| Version | What changed | What you do |
|---|---|---|
1.0.0 | The first frozen contract: 58 parts (including the metric builder and the layout controls) and 5 states, the theme fields with the five layout options, general.fonts, the hide attribute, 14 text keys with languages, sizing-mode and the dbn-height-change event, and the TypeScript types for parts and states. Old attributes and saved themes keep working as before. | If your page uses CSS or test selectors on class names inside the embed, move to parts. |
Next, see every look you can make on Appearance, or start from Theme fields.