Docs Platform guides
Axelor ERP
A complete example for Axelor 8 behind Apache, with the signed-in user.
This is the setup used for Axelor Open Platform 8.1 running on Tomcat behind Apache. It inserts the script with Apache, and identifies the signed-in Axelor user with a small script served by Apache on the Axelor side.
1. Add the user script to Axelor
Axelor 8 returns the signed-in user from ws/public/app/info (Axelor 6 used ws/app/info, which no longer exists). This script reads it and passes the login to OpL Insights, and checks again when the screen changes, so signing in or out inside Axelor is picked up.
Save it as /home/axelor/www/vs-static/opl-axelor.js, in a folder Apache serves itself:
(function (W) {
'use strict';
var FIELD = 'login'; // Axelor user field sent as the user ID: 'login' or 'name'
var INFO = 'ws/public/app/info';
var last = null, busy = false, at = 0;
function push(cmd) { (W._oplq = W._oplq || []).push(cmd); }
function check() {
if (busy || !W.fetch) { return; }
if (last && Date.now() - at < 60000) { return; } // signed in: re-check at most once a minute
busy = true; at = Date.now();
W.fetch(INFO, { credentials: 'same-origin', headers: { 'Accept': 'application/json' } })
.then(function (r) { return r.ok ? r.json() : null; })
.then(function (j) {
busy = false;
var u = j && j.user && j.user[FIELD] ? String(j.user[FIELD]) : '';
if (u !== last) { last = u; push(u ? ['setUser', u] : ['clearUser']); }
})['catch'](function () { busy = false; });
}
check();
W.addEventListener('hashchange', check);
W.addEventListener('popstate', check);
})(window);
2. Configure the virtual host
The relevant part of the Axelor vhost. The order of the three scripts matters: configuration, then the user script (not async), then OpL Insights.
ProxyPass /vs-static !
ProxyPass / http://127.0.0.1:8080/ upgrade=websocket
ProxyPassReverse / http://127.0.0.1:8080/
AddOutputFilterByType SUBSTITUTE text/html
Substitute "s~</head>~<script>window.OPL_INSIGHTS={m:'https://insights.opl-web.com/',s:129,spa:1,waitForUser:2000};</script><script src='/vs-static/opl-axelor.js?v=1'></script><script async src='https://insights.opl-web.com/plugins/OplReplay/javascripts/opl-insights.js?v=1.5.0'></script></head>~i"
# icon fonts in the recording player (proxied, so LocationMatch)
<LocationMatch "\.(woff2?|ttf|otf|eot)$">
Header always set Access-Control-Allow-Origin "*"
</LocationMatch>
sudo a2enmod substitute headers
sudo apachectl configtest && sudo systemctl reload apache2
3. Check
# the page carries the scripts
curl -sk https://erp.example.com/ | grep -o "OPL_INSIGHTS[^<]*\|opl-axelor.js\|opl-insights.js"
# the user script is served by Apache (200)
curl -s -o /dev/null -w '%{http_code}\n' https://erp.example.com/vs-static/opl-axelor.js
# recordings from this address are accepted ("on":true)
curl -s -H 'Origin: https://erp.example.com' 'https://insights.opl-web.com/plugins/OplReplay/replay.php?c=1&s=129'
Sign in to Axelor and open a few screens. Under Visitors > Recordings, the recording shows your Axelor login in the Customer column, and each Axelor screen appears as its own page in the visits log.
Known Axelor message
On Axelor 8.1.2 the LinkScript form logs React template error: … Expected corresponding JSX closing tag for <br> and its help box stays empty. This is Axelor's own help text, and it happens with or without OpL Insights. With OpL Insights loaded, the browser shows the message against opl-insights.js, because the script passes console messages on so they appear in recordings.