See also plugins.
You can configure REMS to include extra script files by defining configuration such as:
:extra-scripts {:root "/tmp" :files ["/scripts/foo.js"]}
This means the script will be served from /tmp/scripts/foo.js
on your local filesystem. The browser sees only the /scripts/foo.js
part.
There you can for example initialize your analytics scripts.
If you want to hook code into additional events you can include a script file like the following. REMS will attempt to call hooks for get
, put
and navigate
events, if they exist.
function logIt(e) {
// e.g. call your analytics solution here
console.log(e);
}
window.rems_hooks = {};
window.rems_hooks.get = logIt;
window.rems_hooks.put = logIt;
window.rems_hooks.navigate = logIt;
window.rems_hooks.get
is called when more data is fetched from the API.
window.rems_hooks.put
is called when a command is sent to the API.
window.rems_hooks.navigate
is called whenever the Single-Page App changes page i.e. route.
All callbacks get the request path as first parameter. Both get
and put
callbacks get an additional parameter that is a map containing other request parameters. You can find query parameters and such from there.
At the moment, manipulation of the query is not possible. Neither is accessing the response.