Client Customisation APIļ
Warning
The functionality detailed in this page needs more attention, both in terms of testing and code development. We expect there to be some bugs and possible API changes. If you rely on this functionality, we recommend you pin your installation of Auspice to a specific version. Please get in touch with us if you are using these customisations so that we can work with you!
This page details the available options and format of the customisations available at (client) build time. They are contained in a JSON file supplied to Auspice via
auspice build --extend <JSON>
Note
The hot-reloading development functionality does not work for code which is included via this client customisation mechanism. Thus, while you can run auspice develop --extend <JSON> it will not update as you may expect!
Available Customisationsļ
The following are definable as top-level keys of the JSON file. A useful reference may be the customisation JSON file used by nextstrain.org.
sidebarThemeallows modifications to the aesthetics of the sidebar. See below.navbarComponenta (relative) path to a JS file exporting a React component to be rendered as the nav bar. See below.splashComponenta (relative) path to a JS file exporting a React component to be rendered as the splash page. See below.browserTitleThe browser title for the page. Defaults to āauspiceā if not defined.finePrintString of Markdown to add to the āfine printā at the bottom of pages.plausibleDataDomainplausible.io analytics (see below)serverAddressSpecify the address / prefix which the auspice client uses for API requests.mapTilesSpecify the address (and other information) for the tiles used to render the map.enableDatasetEditorSet totrueto turn on the ability to edit datasets and colors in the app.
Note
Please remember to make any modifications, including customisations described here, publicly available. See the previous page for more details.
Componentsļ
One way to extend Auspice is by replacing React components with your own custom components. These custom components will receive props defined here, which can be used to update the rendering of the component using the normal react lifecycle methods. Right now this is only available for the splash page and nav-bar components, whose interfaces are defined here.
Each component must be the default export of a javascript file which is specified in the (client) config JSON passed to Auspice at build time (auspice build or auspice develop).
Splash componentļ
Define a custom splash page for Auspice. Please note that this is extremely expirimental and the interface is expected to change.
Build config:
{
"splashComponent": "<relative path to javascript file>"
}
Where the javascript file contains a default export of a React component.
React Props available:
Prop |
Type |
Description |
|---|---|---|
|
Bool |
|
|
Object |
available datasets and narratives |
|
Object |
Browser width & height |
|
function |
access to reduxās dispatch mechanism |
|
function |
to do |
|
function |
to do |
Specifying the API server addressļ
By default, the client makes API requests (as detailed here) to ā/charon/getAvailableā, ā/charon/getDatasetā etc. This is using the default server address of ā/charonā. This can be changed by specifying serverAddress in the customisation JSON.
Note
If you specify a serverAddress on a different origin (protocol + domain + port) than Auspice, the server will need to send CORS headers to permit the requests from Auspice.
Custom Map tilesļ
Note
Auspice v3 introduced a breaking change to this interface. This page reflects the v3 API. Navigate to Auspice v2 docs for the raster-tile URL approach.
Backgroundļ
Auspice uses Leaflet with MapLibre GL JS to render the map using vector tiles. By default, Auspice uses its own map-styles.json, a stylesheet originally based on OpenMapTilesā positron theme.
The renderer is provider-agnostic: it simply renders whatever MapLibre style you give it, any provider that serves a MapLibre-compatible style (e.g. MapTiler, Stadia Maps, or a self-hosted style) should work.
If you wish to use Mapbox styles then you will need to transform the stylesheet as MapLibre doesnāt understand the proprietary mapbox:// protocol.
We have a helper script transform-mapbox-style-json.js which will rewrite those references to their https://api.mapbox.com/... equivalents (and template the token as <ACCESS_TOKEN>); see the mapbox example customisation for an example of this.
Note
As tiles are fetched, Auspice rewrites any http:// requests to https://. This guards against mixed-content and CORS failures.
Customisation structureļ
{
"mapTiles": {
"style": "A MapLibre style JSON (inlined)",
"accessToken": "(optional) access token for the tile provider",
"attribution": "HTML-formatted attribution string to be displayed in the bottom-right-hand corner of the map",
"mapboxWordmark": "(optional) should the Mapbox logo be displayed in the bottom-left of the map? (boolean)"
}
}
If mapTiles is provided it fully replaces the default; specify every field you need (there is no merging with our defaults).
styleEither a URL string that resolves to a MapLibre style document, or the style document inline as a JSON object. The document declares everything the map needs ā sources (tiles), sprites, fonts (glyphs), and layers ā so in most cases this is the only thing you need to provide.
accessTokenOptional, and only relevant if your provider requires a key. Rather than embedding the key directly in the style, place the string
<ACCESS_TOKEN>wherever the key value is required and supply the key here; it is substituted in at runtime. Because the placeholder is the value only, the surrounding query parameter comes from your providerās own URLs (?access_token=<ACCESS_TOKEN>for Mapbox,?key=<ACCESS_TOKEN>for MapTiler, etc.), so the same mechanism works across providers. Providers that donāt need a key can omit this field entirely.
Examplesļ
Examples of map customisations are available in the Auspice repo:
Tracking Analyticsļ
Auspice has in-built support for Plausible Analytics. To enable this you will need to provide the plausibleDataDomain in your extensions. The analytics are not included when running Auspice in development mode.