azureazure-log-analyticsazure-static-website-hosting

How can I log trace information from an Azure Static Website?


I have a JavaScript website deployed into an Azure Storage Account (Static Website) and I would like to log debug information (somewhere). For example, when a user logs in, I would like to track them around the site and print user input/responses.

Think of a Console.log("User exited shopping basket"), except instead of "Console." I want something more permanent in Azure. I have been looking at App Insights but to me this is more suited to tracking page loads and 404 errors etc; not the granularity that I need. Is there anyway I can call ApplicationInsights.log("User exited shopping basket") from JavaScript to use that existing framework?

Or alternatively, how does one log debug/trace information from a Static Website?


Solution

  • App Insights will provide what you're after.

    Check out this getting started page for use within JS. Once you have everything set up, you can leverage the custom events and metrics APIs to collect the type of event data you showed.

    The Readme on the SDK repo also has some good tactical examples of how to use AI in your web site.