OpL Insights

Docs Platform guides

Apps behind Apache

Add OpL Insights to an app you can't change, by inserting the script in Apache.

For an application whose templates you can't or don't want to edit (an ERP, a vendor portal, an older system), Apache can insert the script into every HTML page on the way out with mod_substitute.

Insert the script

Add this inside the app's <VirtualHost> and replace 129 with your site ID:

AddOutputFilterByType SUBSTITUTE text/html
Substitute "s~</head>~<script>window.OPL_INSIGHTS={m:'https://insights.opl-web.com/',s:129,spa:1};</script><script async src='https://insights.opl-web.com/plugins/OplReplay/javascripts/opl-insights.js'></script></head>~i"

Most modern apps are single-page apps, so spa:1 is included; remove it for a classic multi-page app.

Turn the modules on and reload Apache:

sudo a2enmod substitute headers
sudo apachectl configtest && sudo systemctl reload apache2

Check the script is inserted

curl -sk https://app.example.com/ | grep -o "OPL_INSIGHTS[^<]*\|opl-insights.js"

If nothing is printed and the app sits behind a proxy that compresses its pages, Apache can't edit the compressed HTML. Ask the back end for uncompressed pages:

RequestHeader unset Accept-Encoding

Identify users

Apache doesn't know who is signed in. Add a small script on the app's side that finds out and passes it on with setUser, and load it before opl-insights.js. Serve it from a folder Apache serves itself, not through the proxy. The Axelor guide is a complete example.

Fonts

Recordings are replayed on the OpL Insights server, which loads the app's fonts. For a proxied app use LocationMatch, because FilesMatch doesn't apply to proxied addresses:

<LocationMatch "\.(woff2?|ttf|otf|eot)$">
    Header always set Access-Control-Allow-Origin "*"
</LocationMatch>