azure-application-insightsghost-blogghost

Adding Application Insights to Ghost


I'm trying to add Application Insights to my Ghost blog running in Azure. I have read the generic documentation about adding App Insights to a Node.js application, so I know how to do that.

What I have zero idea about is where exactly should I do that for Ghost? I've seen a lot of examples and tutorials out there, but they are all for older versions and I can't use any for the version that I have set up (1.21.3). No matter where I tried to initialize App Insights, I either got some kind of error or just no data appeared in App Insights.

Can someone point me into the right direction? First step would be to know for sure where to put initialization code. Once I'm sure that the code is at the right place, I might have better chances tracking down the specific error.


Solution

  • Turns out I was overthinking this. The solution is to put the initialization code right at the top of the root index.js.

    var appInsights = require('applicationinsights');
    appInsights.setup('your_ikey').start();