Close

BLOGS

Azure Application Insights(AI) and capturing Dynamics 365 client side telemetry

What is Application Insights?

Application Insights is an extensible Application Performance Management (APM) service for web developers on multiple platforms. Use it to monitor your live web application. It allow you to monitor the end user performance of an application. It will automatically detect performance anomalies. It includes powerful analytics tools to help you diagnose issues and to understand what users actually do with your app. It's designed to help you continuously improve performance and usability. It works for apps on a wide variety of platforms including .NET, Node.js and J2EE, hosted on-premises or in the cloud. It integrates with your DevOps process, and has connection points to a variety of development tools. It can monitor and analyze telemetry from mobile apps by integrating with Visual Studio App Center.

In the past, performance monitoring was more about monitoring servers and their performance. It’s very easy to track the CRM form client-side performance using Application Insights. The Application Insight is not expensive, the basic plan is free and 1 GB of data is included every month.

What does Application Insights monitor?
  1. Request rates, response times, and failure rates 
  2. Dependency rates, response times, and failure rates 
  3. Exceptions
  4. AJAX calls from web pages
  5. User and session counts.
  6. Performance counters from your Windows or Linux server machines
  7. Host diagnostics from Docker or Azure.
  8. Diagnostic trace logs from your app
  9. Custom events and metrics that you write yourself in the client or server code, to track business events


Follow the below steps to configure the Application Insights for Dynamics 365,

  1. Create an Application Insights in the Azure portal.
  2. Open the Application Insights and Click on the Getting started under the Configure menu and then click on the Monitor and Diagnose Client Side Application.

  1. In the Client application monitoring and diagnosis form, copy the instrumentation key and paste it in a notepad file.

  1. Log in to Dynamics 365 and create a web resource for Application Insights and add the below-mentioned scripts. Update your Application Insights Instrumentation key in the highlighted area on the script.
if (ApplicationInsights === "undefined") {
 var ApplicationInsights = {};
}

ApplicationInsights = {
 trackApplicationInsight: function (entityName, properties) {
 var appInsights = window.appInsights || function (config) { function i(config) { t[config] = function () { var i = arguments; t.queue.push(function () { t[config].apply(t, i) }) } } var t = { config: config }, u = document, e = window, o = "script", s = "AuthenticatedUserContext", h = "start", c = "stop", l = "Track", a = l + "Event", v = l + "Page", y = u.createElement(o), r, f; y.src = config.url || "https://az416426.vo.msecnd.net/scripts/a/ai.0.js"; u.getElementsByTagName(o)[0].parentNode.appendChild(y); try { t.cookie = u.cookie } catch (p) { } for (t.queue = [], t.version = "1.0", r = ["Event", "Exception", "Metric", "PageView", "Trace", "Dependency"]; r.length;) i("track" + r.pop()); return i("set" + s), i("clear" + s), i(h + a), i(c + a), i(h + v), i(c + v), i("flush"), config.disableExceptionTracking || (r = "onerror", i("_" + r), f = e[r], e[r] = function (config, i, u, e, o) { var s = f && f(config, i, u, e, o); return s !== !0 && t["_" + r](config, i, u, e, o), s }), t }(
 {
 instrumentationKey: "XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX"
 });
 window.appInsights = appInsights;

appInsights.trackPageView(entityName, Xrm.Page.context.getClientUrl(), properties);
 }
}
  1. For whichever entity the performance telemetry needs to be captured add the below JavaScript code to the entity JavaScript web resource.
function accountOnLoad()
{
 var operationType = '';
 if (Xrm.Page.ui.getFormType() == 1) { operationType = 'Create'; } else { operationType = 'Update'; }

var properties = { User: Xrm.Page.context.getUserName(), ObjectId: Xrm.Page.data.entity.getId(), OperationType: operationType, TriggerEvent: 'Form Load' };
 ApplicationInsights.trackApplicationInsight('Account', properties);
}

function accountOnSave()
{
 var operationType = '';
 if (Xrm.Page.ui.getFormType() == 1) { operationType = 'Create'; } else { operationType = 'Update'; }

var properties = { User: Xrm.Page.context.getUserName(), ObjectId: Xrm.Page.data.entity.getId(), OperationType: operationType, TriggerEvent: 'Form Save' };
 ApplicationInsights.trackApplicationInsight('Account', properties);
}
  1. Add the created Application Insights web resource to the Entity Form Properties and add the JavaScript function to the form on-load and on-save event, so that the complete performance metrics will be captured by the Application Insights for these.

 

  1. You can add as much as details you want to capture by adding to the properties. These properties information will be captured as custom data in the Application Insights.
var properties = { User: Xrm.Page.context.getUserName(), ObjectId: Xrm.Page.data.entity.getId(), OperationType: operationType, TriggerEvent: 'Form Save' };  
ApplicationInsights.trackApplicationInsight('Account', properties);

  1. Now the client side performance telemetry will be captured on the on-load and on-save of the entity form. This function can be added to any events like button click, business process stage change, etc to capture the client side performance and exceptions
  1. Application Insights has lots of out of the box dashboards, charts and live metrices stream to monitor the metrices easily.

 

Print
Posted: Sep 22, 2018,
Comments: 0,
Author: Urish Arora
Rate this article:
5.0

Urish AroraUrish Arora

Other posts by Urish Arora

, Contact author

Please login or register to post comments.

Name:
Email:
Subject:
Message:
x

SEARCH

Categories

Subscribe to our blog

«August 2019»
MonTueWedThuFriSatSun
2930311234
567891011
12131415161718
19202122232425
2627282930311
2345678

  • Featured Posts
  • Recent Posts
  • Recent Comments
Dynamics365Authority is a community platform for Professionals and Students to contribute or share their knowledge and skills on Microsoft Dynamics 365 Technologies. Our primary goal is to invite professionals on Dynamics 365 technology across the world to contribute & share their knowledge and skills through their blogs so that we can help other developers.
Stay updated with Dynamics 365 technology. Improve skills and knowledge from our blogs, articles and code snippets. Learn it. Follow professionals and learn from them.
Unified Service Desk Book(Online Edition) 

FOLLOW US

Stay connected with us on our social media channels for latest articles, blogs posts etc.  We will keep updating regularly on our social media platform and web platform.

FACEBOOK

Follow us on Facebook

 

TWITTER

View all our tweets

 

DYNAMICS365AUTH

Join us now

 

BLOGS

View our blogs

 

 

Latest Blog

Posted: Jun 20, 2019

Overview - Appendix (Unified Service Desk)

This blog is about Appendix

Read more
Posted: Jun 20, 2019

Overview - Troubleshoot and Debug (Unified Service Desk)

This blog is about Troubleshoot and Debug in Unified Service Desk

Read more
Posted: Jun 20, 2019

Overview - Performance (Unified Service Desk)

This blog is about the Performance in Unified Service Desk

Read more
RSS

ADDITIONAL RESOURCES

Dynamics 365 Authority.com - Search the library for "Dynamics 365"

  What's New in Dynamics 365

  Dynamics 365 Documentation

  

  Sign-up for 30 days trial

 

 

Recent comments

Ashish:

Nice blog. Very helpful to get all references to white papers at one place.

Previous Next

About Us

Here comes the Dynamics 365 Authority - Great technical blog posts are hidden gems. They are hard to find simply because not enough of us write them in the first place. Yet technical blogging is one of the best things we can do not only for ourselves, but also as members of the wider community of developers.

Dynamics 365 Authority leverages this platform to help developers and users to move from traditional paper-based process to modern digital business process. Dynamics365Authority.com helps your business grow, evolve and transform.

Dynamics365Authority.com is your Digital Transformation Partner

Recent Posts

Overview - Appendix (Unified Service Desk)

This blog is about Appendix
  • 148
  • Article rating: 5.0

Overview - Troubleshoot and Debug (Unified Service Desk)

This blog is about Troubleshoot and Debug in Unified Service Desk
  • 177
  • Article rating: 5.0
RSS

Get in touch

Follow Us

 

Tag cloud: Dynamics365Authority.com with Urish Arora; Dynamics365Authority.com; Sales; Leading community site on MS Dynamics 365; Dynamics 365 Authority; Service;Top CRM Blogs; Urish Arora - Australia's leading expert on Digital Transformation;  Digital Transformation; Field Service;Top Articles on MS Dynamics CRM Relationship Insights; Office 365 Security Compliance; Project Service; Microsoft Dynamics 365 for Sales; Relevance Search; Goal Metrics; Activities and Case; Sales Literature;Knowledge Management;

Terms Of UsePrivacy StatementCopyright 2019 by Dynamics365Authority
Back To Top