Coder Social home page Coder Social logo

harry671003 / ng2-appinsights Goto Github PK

View Code? Open in Web Editor NEW
8.0 3.0 3.0 31 KB

App Insights module for Angular 2.0.x

License: MIT License

TypeScript 79.62% JavaScript 12.98% HTML 6.57% CSS 0.83%
angular2 application-insights appinsights ng2-appinsights

ng2-appinsights's Introduction

ng2-appinsights

Installation

npm install ng2-appinsights --save

Usage

Initialization

Inside your app module import AppInsightsModule

import { NgModule } from '@angular/core';
import { BrowserModule } from '@angular/platform-browser';
import { AppInsightsModule } from 'ng2-appinsights';

import { AppComponent } from './app.component';

@NgModule({
    imports : [
        BrowserModule,
        AppInsightsModule,
    ],
    declarations : [AppComponent],
    bootstrap : [AppComponent]
})
export class AppModule {
}

Inside your app component initialize the AppInsightsService

import { Component } from '@angular/core';
import { AppInsightsService } from 'ng2-appinsights';

@Component({
    selector: 'app',
    templateUrl: './app.component.html'
})
export class AppComponent {
    constructor(private appinsightsService: AppInsightsService) {
        this.appinsightsService.Init({
            instrumentationKey: '<INSTRUMENTATION_KEY>'
        });
    }
}

Configurations

To configure the service pass a configuration object in the Init method

this.appinsightsService.Init({
    instrumentationKey: '<INSTRUMENTATION_KEY>', // Required field
    enableDebug: false,
    maxAjaxCallsPerView: 50,
    disableTelemetry: true
});

The complete list of configuration options are

instrumentationKey;

The key of your Application Insights resource in Azure

endpointUrl: string;

The Application Insights server

accountId: string;

User Account Id

sessionRenewalMs: number;

A session is logged if the user is inactive for this time in milliseconds. Default 30 mins.

sessionExpirationMs: number;

A session is logged if it has continued for this time in milliseconds. Default 24h.

maxBatchSizeInBytes: number;

Default 100k

maxBatchInterval: number;

Default 15s

enableDebug: boolean;

If true, data is sent immediately and not batched.

disableTelemetry: boolean;

If true, telemetry data is not collected or sent. Default false.

verboseLogging: boolean;

Default false

samplingPercentage: boolean;

Controls what percentage of events will be sent Default 100.

diagnosticLogInterval: number;

Default 10s

disableExceptionTracking: boolean;

If true, exceptions are not monitored.

disableAjaxTracking: boolean;

If true, ajax calls are not monitored.

overridePageViewDuration: boolean;

If true, default behavior of trackPageView is changed to record end of page view duration interval when trackPageView is called. If false and no custom duration is provided to trackPageView, the page view performance is calculated using the navigation timing API.

maxAjaxCallsPerView: number;

Default 500 - controls how many ajax calls will be monitored per page view. Set to -1 to monitor all ajax calls on the page.

isCookieUseDisabled: boolean;

If true, the SDK will not store or read any data from cookies. Default: false

cookieDomain: string;

Custom cookie domain. This is helpful if you want to share Application Insights cookies across subdomains.

disableFlushOnBeforeUnload: boolean;

Default false. If true, flush method will not be called when onBeforeUnload event triggers.

enableSessionStorageBuffer: boolean;

If true, the buffer with all unsent telemetry is stored in a session storage. The buffer is resotered on page load. The feature is enable by default starting with v0.23.0.

isRetryDisabled: boolean;

Is retry handler disabled. Default false. If enabled, retry on 206 (partial success), 408 (timeout), 429 (too many requests), 500 (internal server error) and 503 (service unavailable).

url: string;

The url from where the JS SDK will be downloaded. Default 'https://az416426.vo.msecnd.net/scripts/a/ai.0.js'

isStorageUseDisabled: boolean;

If true, the SDK will not store or read any data from local and session storage. Default: false

API Reference

Check Microsoft Application Insights API Reference for API reference

Check e2e/app/app.component.ts for examples

ng2-appinsights's People

Contributors

harry671003 avatar jordan112 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

ng2-appinsights's Issues

EXCEPTION: this.appInsights.downloadAndSetup is not a function

I'm using the latest version of this package with Angular 2.2.4. Running with webpack and ASP.NET Core as seen here.

I don't have any trouble until I run the project and get the following error:

TypeError: this.appInsights.downloadAndSetup is not a function

and

Unhandled Promise rejection: this.appInsights.downloadAndSetup is not a function ; Zone: < root > ; Task: Promise.then ; Value: TypeError: this.appInsights.downloadAndSetup is not a function

image

this.appInsights.downloadAndSetup is not a function

Ive followed the installation steps.

Imported into my app.module. Brought the service into my component

But when I call :
this.appInsightsService.Init({
instrumentationKey: 'XXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX',
verboseLogging: true
});

I get this error: this.appInsights.downloadAndSetup is not a function

appInsights string name is not changeable

We want to customize our appInsights object and assign it to another variable on window object instead of hard coded "appInsights" in

export class AppInsightsLibraryService {
.....
    private _appInsightsName: string = 'appInsights';
.....

When we change the string to something else then whole the service stops working. Is there a way?

not working, old sdk ?

looks like the package needs to be updated , the azure portal is not getting the live stream data.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.