ng2-appinsights
Version:
App Insights module for Angular 2.0.x
226 lines • 10.7 kB
JavaScript
;
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
return c > 3 && r && Object.defineProperty(target, key, r), r;
};
var __metadata = (this && this.__metadata) || function (k, v) {
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
};
var __param = (this && this.__param) || function (paramIndex, decorator) {
return function (target, key) { decorator(target, key, paramIndex); }
};
Object.defineProperty(exports, "__esModule", { value: true });
var core_1 = require("@angular/core");
var appinsightslibrary_service_1 = require("../lib/appinsightslibrary.service");
/**
* App Insights Service
*/
var AppInsightsService = (function () {
function AppInsightsService(appInsightsLibraryService) {
this.appInsights = appInsightsLibraryService.getAppInsightsInstance();
}
/**
* Initialize app insights
*
* @param {Config} config
*
* @memberOf AppInsightsService
*/
AppInsightsService.prototype.Init = function (config) {
this.appInsights.downloadAndSetup(config);
};
/**
* Track Page View
*
* @param {string} [name] - The name used to identify the page in the portal.
* Defaults to the document title.
* @param {string} [url] - A relative or absolute URL that identifies the
* page or similar item. Defaults to the window location.
* @param {*} [properties] - Map of string to string: Additional data
* used to filter pages in the portal. Defaults to empty.
* @param {*} [measurements] - Map of string to number: Metrics associated
* with this page, displayed in Metrics Explorer on the portal.
* Defaults to empty.
* @param {number} [duration] - The number of milliseconds it took to load
* this page, displayed in Metrics Explorer on the portal. Defaults to empty.
* If empty, end of page view duration is recorded when browser page load event is called.
*
* @memberOf AppInsightsService
*/
AppInsightsService.prototype.trackPageView = function (name, url, properties, measurements, duration) {
this.appInsights.trackPageView(name, url, properties, measurements, duration);
};
/**
* Track Event
*
* @param {string} name - Identifies the event. Events with the same name are
* counted and can be charted in Metric Explorer.
* @param {*} [properties] - Map of string to string: Additional data used to
* filter events in the portal. Defaults to empty.
* @param {*} [measurements] - Map of string to number: Metrics associated with
* this page, displayed in Metrics Explorer on the portal. Defaults to empty.
*
* @memberOf AppInsightsService
*/
AppInsightsService.prototype.trackEvent = function (name, properties, measurements) {
this.appInsights.trackEvent(name, properties, measurements);
};
;
/**
* Track Metric
*
* @param {string} name - A string that identifies the metric. In the portal,
* you can select metrics for display by name.
* @param {number} average - Either a single measurement, or the average of
* several measurements. Should be >=0 to be correctly displayed.
* @param {number} [sampleCount] - Count of measurements represented by the
* average. Defaults to 1. Should be >=1.
* @param {number} [min] - The smallest measurement in the sample. Defaults
* to the average. Should be >= 0.
* @param {number} [max] - The largest measurement in the sample. Defaults to
* the average. Should be >= 0.
* @param {*} [properties] - Map of string to string: Additional data used to
* filter events in the portal.
*
* @memberOf AppInsightsService
*/
AppInsightsService.prototype.trackMetric = function (name, average, sampleCount, min, max, properties) {
this.appInsights.trackMetric(name, average, sampleCount, min, max, properties);
};
/**
* Track Exception
*
* @param {Error} exception - An Error from a catch clause.
* @param {string} [handledAt] - Defaults to "unhandled".
* @param {*} [properties] - Map of string to string: Additional data used to
* filter exceptions in the portal. Defaults to empty.
* @param {*} [measurements] - Map of string to number: Metrics associated
* with this page, displayed in Metrics Explorer on the portal. Defaults to empty.
* @param {SeverityLevel} [severityLevel] - SeverityLevel
*
* @memberOf AppInsightsService
*/
AppInsightsService.prototype.trackException = function (exception, handledAt, properties, measurements, severityLevel) {
this.appInsights.trackException(exception, handledAt, properties, measurements, severityLevel);
};
/**
* Track Trace
*
* @param {string} message - Diagnostic data. Can be much longer than a name.
* @param {*} [properties] - Map of string to string: Additional data used to
* filter exceptions in the portal. Defaults to empty.
* @param {*} [measurements] - Map of string to number: Metrics associated with this page,
* displayed in Metrics Explorer on the portal. Defaults to empty.
*
* @memberOf AppInsightsService
*/
AppInsightsService.prototype.trackTrace = function (message, properties, measurements) {
this.appInsights.trackTrace(message, properties, measurements);
};
/**
* Track dependency
*
* @param {string} id - Unique id, this is used by the backend o correlate server requests.
* @param {string} method - Represents request verb (GET, POST, etc.)
* @param {string} absoluteUrl - Absolute url used to make the dependency request
* @param {string} pathName - Path part of the absolute url
* @param {number} totalTime - Total request time
* @param {boolean} success - Indicates if the request was sessessful
* @param {number} resultCode - Response code returned by the dependency request
*
* @memberOf AppInsightsService
*/
AppInsightsService.prototype.trackDependency = function (id, method, absoluteUrl, pathName, totalTime, success, resultCode) {
this.appInsights.trackDependency(id, method, absoluteUrl, pathName, totalTime, success, resultCode);
};
/**
* Flush
*
* @description
* Immediately send all queued telemetry. Synchronous.
*
* @memberOf AppInsightsService
*/
AppInsightsService.prototype.flush = function () {
this.appInsights.flush();
};
/**
* Set authenticated user context
*
* @description
* Set the authenticated user id and the account id in this session.
* Use this when you have identified a specific signed-in user.
* Parameters must not contain spaces or ,;=|
*
* @param {string} authenticatedUserId - An id that uniquely identifies a user of your app.
* No spaces, comma, semicolon, equals or vertical bar.
* @param {string} [accountId] - An optional account id, if your app groups users into accounts.
* No spaces, comma, semicolon, equals or vertical bar.
*
* @memberOf AppInsightsService
*/
AppInsightsService.prototype.setAuthenticatedUserContext = function (authenticatedUserId, accountId) {
this.appInsights.setAuthenticatedUserContext(authenticatedUserId, accountId);
};
/**
* Clear authenticated user context
*
* @description
* Clears the authenticated user id and the account id from the user context,
* and clears the associated cookie.
*
* @memberOf AppInsightsService
*/
AppInsightsService.prototype.clearAuthenticatedUserContext = function () {
this.appInsights.clearAuthenticatedUserContext();
};
/**
* Start Track Page
*
* @description
* Starts the timer for tracking a page view. Use this instead of trackPageView
* if you want to control when the page view timer starts and stops, but don't
* want to calculate the duration yourself. This method doesn't send any telemetry.
* Call stopTrackPage to log the end of the page view and send the event.
*
* @param {string} [name] - The name used to identify the page in the portal.
* Defaults to the document title.
*
* @memberOf AppInsightsService
*/
AppInsightsService.prototype.startTrackPage = function (name) {
this.appInsights.startTrackPage(name);
};
/**
* Stop Track Page
*
* @description
* Stops the timer that was started by calling startTrackPage and sends the page view
* telemetry with the specified properties and measurements. The duration of the page
* view will be the time between calling startTrackPage and stopTrackPage.
*
* @param {string} [name] - The name used to identify the page in the portal.
* Defaults to the document title.
* @param {string} [url] - A relative or absolute URL that identifies the page or similar item.
* Defaults to the window location.
* @param {Object} [properties] - Map of string to string: Additional data used
* to filter pages in the portal. Defaults to empty.
* @param {Object} [measurements] - Map of string to number: Metrics associated with this page,
* displayed in Metrics Explorer on the portal. Defaults to empty.
*
* @memberOf AppInsightsService
*/
AppInsightsService.prototype.stopTrackPage = function (name, url, properties, measurements) {
this.appInsights.stopTrackPage(name, url, properties, measurements);
};
return AppInsightsService;
}());
AppInsightsService = __decorate([
core_1.Injectable(),
__param(0, core_1.Inject(appinsightslibrary_service_1.AppInsightsLibraryService)),
__metadata("design:paramtypes", [appinsightslibrary_service_1.AppInsightsLibraryService])
], AppInsightsService);
exports.AppInsightsService = AppInsightsService;
//# sourceMappingURL=appinsights.service.js.map