<commit_before>﻿# aurelia-appInsights

This plugin allows you to add page [Application Insights](http://azure.microsoft.com/en-us/documentation/articles/app-insights-web-track-usage-custom-events-metrics/) tracking and tracing for your [Aurelia](http://www.aurelia.io/) applications.

> The solution was developed using Visual Studio 2015 and [TypeScript](http://www.typescriptlang.org/). If you're using TypeScript, you can inlcude the .ts files. If not, then just include the .js files to add the plugin.

## Installing the Plugin

1. Include Application Insights. You can do this in your main page (where you specify ```aurelia-app``` or ```aurelia-main```). Copy the JavaScript Application Insights snippet from the Azure portal and paste it into the ```<head>``` of the page:
```javascript
<script>
    var appInsights = window.appInsights || function (config) {
        function s(config) { t[config] = function () { var i = arguments; t.queue.push(function () { t[config].apply(t, i) }) } } var t = { config: config }, r = document, f = window, e = "script", o = r.createElement(e), i, u; for (o.src = config.url || "//az416426.vo.msecnd.net/scripts/a/ai.0.js", r.getElementsByTagName(e)[0].parentNode.appendChild(o), t.cookie = r.cookie, t.queue = [], i = ["Event", "Exception", "Metric", "PageView", "Trace"]; i.length;) s("track" + i.pop()); return config.disableExceptionTracking || (i = "onerror", s("_" + i), u = f[i], f[i] = function (config, r, f, e, o) { var s = u && u(config, r, f, e, o); return s !== !0 && t["_" + i](config, r, f, e, o), s }), t
    }({
        instrumentationKey: "your-ai-key"
    });

    window.appInsights = appInsights;
</script>
```
2. Include the src\resources folder in your project (make sure you have the aurelia-appInsights.js (or ts) files). The plugin assumes that you are manually inserting the AI script using the snippet from the Portal.
3. Include the plugin in main.js using ```.plugin("./resources/aurelia-appInsights")```. You can set 'global properties' if you want to.
```typescript
import auf = require("aurelia-framework");
import aul = require("aurelia-logging-console");
import aai = require("resources/aurelia-appInsights");

auf.LogManager.addAppender(new aul.ConsoleAppender());
auf.LogManager.setLevel(auf.LogManager.levels.debug);
<commit_msg>Adding lang to md file<commit_after>﻿# aurelia-appInsights

This plugin allows you to add page [Application Insights](http://azure.microsoft.com/en-us/documentation/articles/app-insights-web-track-usage-custom-events-metrics/) tracking and tracing for your [Aurelia](http://www.aurelia.io/) applications.

> The solution was developed using Visual Studio 2015 and [TypeScript](http://www.typescriptlang.org/). If you're using TypeScript, you can inlcude the .ts files. If not, then just include the .js files to add the plugin.

## Installing the Plugin

1. Include Application Insights. You can do this in your main page (where you specify ```aurelia-app``` or ```aurelia-main```). Copy the JavaScript Application Insights snippet from the Azure portal and paste it into the ```<head>``` of the page:
```html
<script>
    var appInsights = window.appInsights || function (config) {
        function s(config) { t[config] = function () { var i = arguments; t.queue.push(function () { t[config].apply(t, i) }) } } var t = { config: config }, r = document, f = window, e = "script", o = r.createElement(e), i, u; for (o.src = config.url || "//az416426.vo.msecnd.net/scripts/a/ai.0.js", r.getElementsByTagName(e)[0].parentNode.appendChild(o), t.cookie = r.cookie, t.queue = [], i = ["Event", "Exception", "Metric", "PageView", "Trace"]; i.length;) s("track" + i.pop()); return config.disableExceptionTracking || (i = "onerror", s("_" + i), u = f[i], f[i] = function (config, r, f, e, o) { var s = u && u(config, r, f, e, o); return s !== !0 && t["_" + i](config, r, f, e, o), s }), t
    }({
        instrumentationKey: "your-ai-key"
    });

    window.appInsights = appInsights;
</script>
```
2. Include the src\resources folder in your project (make sure you have the aurelia-appInsights.js (or ts) files). The plugin assumes that you are manually inserting the AI script using the snippet from the Portal.
3. Include the plugin in main.js using ```.plugin("./resources/aurelia-appInsights")```. You can set 'global properties' if you want to.
```typescript
import auf = require("aurelia-framework");
import aul = require("aurelia-logging-console");
import aai = require("resources/aurelia-appInsights");

auf.LogManager.addAppender(new aul.ConsoleAppender());
auf.LogManager.setLevel(auf.LogManager.levels.debug);

{'fraction_non_alphanumeric': 0.15863410417116922, 'fraction_numerical': 0.006915928247244435, 'mean_word_length': 4.425556858147714, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 11, 'https://': 0, 'lorem ipsum': 0, 'www.': 4, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1611838', 'n_tokens_mistral': 1492, 'n_tokens_neox': 1446, 'n_words': 486}