-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathApplicationInsightsModule.cs
43 lines (40 loc) · 2.13 KB
/
ApplicationInsightsModule.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
// <copyright file="ApplicationInsightsModule.cs" company="Engage Software">
// Engage: Application Insights
// Copyright (c) 2004-2016
// by Engage Software ( http://www.engagesoftware.com )
// </copyright>
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED
// TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
// THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF
// CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
// DEALINGS IN THE SOFTWARE.
namespace Engage.Dnn.ApplicationInsights
{
using System.Web;
using System.Web.UI;
using DotNetNuke.Common;
using DotNetNuke.Web.Client.ClientResourceManagement;
/// <summary>Injects Application Insights JS script into all pages</summary>
/// <remarks>based on <see href="http://stackoverflow.com/a/5240313/2688"/></remarks>
public class ApplicationInsightsModule : IHttpModule
{
/// <summary>Initializes a module and prepares it to handle requests.</summary>
/// <param name="application">An <see cref="HttpApplication" /> that provides access to the methods, properties, and events common to all application objects within an ASP.NET application</param>
public void Init(HttpApplication application)
{
Requires.NotNull("application", application);
application.PostMapRequestHandler += (sender, args) =>
{
var page = application.Context.CurrentHandler as Page;
if (page != null)
{
page.InitComplete += (o, eventArgs) => ClientResourceManager.RegisterScript(page, "~/DesktopModules/Engage/ApplicationInsights/ai.js", 0, "DnnPageHeaderProvider");
}
};
}
/// <summary>Disposes of the resources (other than memory) used by the module that implements <see cref="IHttpModule" />.</summary>
public void Dispose()
{
}
}
}