Thanks JonL, as always, spot on comments.
For anyone interested I followed the solution in this post -
https://community.wappler.io/t/how-to-install-sentry-on-the-back-end-nodejs/31987/19
Specifically creating a new js file in extensions/server_connect/routes/treblle.js containing the treblle code that I previously added to the server.js (in my post above) but wrapping it with “exports.before = function (app) { };” to get:
const { useTreblle } = require("treblle");
exports.before = function (app) {
useTreblle(app, {
apiKey: "_YOUR_API_KEY_",
projectId: "_YOUR_PROJECT_ID_"
});
};
Now since I am not editing the server.js file this should remain in place after updates etc.
Obviously, follow the deployment instructions from treblle.com regarding installing the node package etc.