Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@asymmetrik/ngx-instrumentation

Package Overview
Dependencies
Maintainers
6
Versions
7
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@asymmetrik/ngx-instrumentation - npm Package Compare versions

Comparing version 0.0.2 to 0.0.3

2

dist/instrumentation/instrumentation.module.js

@@ -1,2 +0,2 @@

import { ModuleWithProviders, NgModule } from '@angular/core';
import { NgModule } from '@angular/core';
import { CommonModule } from '@angular/common';

@@ -3,0 +3,0 @@ import { InstrumentRouterDirective } from './integrations/instrument-router.directive';

@@ -9,4 +9,11 @@ import { ErrorHandler } from '@angular/core';

private instrumentationService;
/**
* Determines whether or not handled errors are logged to the client
* console in addition to being passed to the instrumentation service
*
* @type {boolean}
*/
logErrorsToConsole: boolean;
constructor(instrumentationService: InstrumentationService);
handleError(error: Error): void;
}

@@ -1,2 +0,2 @@

import { ErrorHandler, Injectable } from '@angular/core';
import { Injectable } from '@angular/core';
import { InstrumentationService } from '../instrumentation.service';

@@ -11,5 +11,17 @@ /**

this.instrumentationService = instrumentationService;
/**
* Determines whether or not handled errors are logged to the client
* console in addition to being passed to the instrumentation service
*
* @type {boolean}
*/
this.logErrorsToConsole = true;
}
InstrumentErrorHandler.prototype.handleError = function (error) {
if (null != error) {
// Log errors to console
if (this.logErrorsToConsole) {
// tslint:disable-next-line:no-console
console.error(error);
}
// Call the instrumentation service to handle the error event

@@ -16,0 +28,0 @@ this.instrumentationService.handleEvent({

@@ -1,1 +0,1 @@

[{"__symbolic":"module","version":4,"metadata":{"InstrumentErrorHandler":{"__symbolic":"class","decorators":[{"__symbolic":"call","expression":{"__symbolic":"reference","module":"@angular/core","name":"Injectable","line":8,"character":1}}],"members":{"__ctor__":[{"__symbolic":"constructor","parameters":[{"__symbolic":"reference","module":"../instrumentation.service","name":"InstrumentationService","line":11,"character":45}]}],"handleError":[{"__symbolic":"method"}]}}}}]
[{"__symbolic":"module","version":4,"metadata":{"InstrumentErrorHandler":{"__symbolic":"class","decorators":[{"__symbolic":"call","expression":{"__symbolic":"reference","module":"@angular/core","name":"Injectable","line":8,"character":1}}],"members":{"__ctor__":[{"__symbolic":"constructor","parameters":[{"__symbolic":"reference","module":"../instrumentation.service","name":"InstrumentationService","line":19,"character":45}]}],"handleError":[{"__symbolic":"method"}]}}}}]

@@ -14,3 +14,2 @@ import { HttpEvent, HttpHandler, HttpInterceptor, HttpParams, HttpRequest } from '@angular/common/http';

constructor(instrumentationService: InstrumentationService);
setIncludeParams(v: boolean): void;
intercept(req: HttpRequest<any>, next: HttpHandler): Observable<HttpEvent<any>>;

@@ -17,0 +16,0 @@ /**

import { Injectable } from '@angular/core';
import { HttpEvent, HttpHandler, HttpInterceptor, HttpParams, HttpRequest, HttpResponse } from '@angular/common/http';
import { Observable } from 'rxjs';
import { HttpResponse } from '@angular/common/http';
import 'rxjs/add/operator/do';

@@ -17,5 +16,2 @@ import { InstrumentationService } from '../instrumentation.service';

}
InstrumentHttpInterceptor.prototype.setIncludeParams = function (v) {
this.includeParams = v;
};
InstrumentHttpInterceptor.prototype.intercept = function (req, next) {

@@ -22,0 +18,0 @@ var _this = this;

@@ -1,1 +0,1 @@

[{"__symbolic":"module","version":4,"metadata":{"InstrumentHttpInterceptor":{"__symbolic":"class","decorators":[{"__symbolic":"call","expression":{"__symbolic":"reference","module":"@angular/core","name":"Injectable","line":13,"character":1}}],"members":{"__ctor__":[{"__symbolic":"constructor","parameters":[{"__symbolic":"reference","module":"../instrumentation.service","name":"InstrumentationService","line":18,"character":45}]}],"setIncludeParams":[{"__symbolic":"method"}],"intercept":[{"__symbolic":"method"}],"extractParams":[{"__symbolic":"method"}]}}}}]
[{"__symbolic":"module","version":4,"metadata":{"InstrumentHttpInterceptor":{"__symbolic":"class","decorators":[{"__symbolic":"call","expression":{"__symbolic":"reference","module":"@angular/core","name":"Injectable","line":13,"character":1}}],"members":{"__ctor__":[{"__symbolic":"constructor","parameters":[{"__symbolic":"reference","module":"../instrumentation.service","name":"InstrumentationService","line":18,"character":45}]}],"intercept":[{"__symbolic":"method"}],"extractParams":[{"__symbolic":"method"}]}}}}]

@@ -1,4 +0,3 @@

import { Directive, OnDestroy, OnInit } from '@angular/core';
import { ActivatedRouteSnapshot, Event, NavigationCancel, NavigationEnd, NavigationError, Router } from '@angular/router';
import { Subscription } from 'rxjs';
import { Directive } from '@angular/core';
import { NavigationCancel, NavigationEnd, NavigationError, Router } from '@angular/router';
import 'rxjs/add/operator/filter';

@@ -68,3 +67,6 @@ import 'rxjs/add/operator/pairwise';

url: event.url,
error: event.error
error: {
message: (null != event.error) ? event.error.message : '',
stack: (null != event.error) ? event.error.stack : ''
}
};

@@ -84,7 +86,13 @@ };

var _this = this;
if (max === void 0) { max = 0; }
if (max === void 0) { max = 20; }
var toReturn = {};
// Get the child snapshots
if (null != snapshot.children) {
toReturn.children = snapshot.children.map(function (c) { return _this.extractActivatedRouteSnapshot(c, max++); });
// Only keep going if we haven't exceeded the max levels
if (max > 0) {
toReturn.children = snapshot.children.map(function (c) { return _this.extractActivatedRouteSnapshot(c, max--); });
}
else {
toReturn.children = [];
}
}

@@ -91,0 +99,0 @@ // Get the component name (if it exists)

@@ -17,10 +17,9 @@ import { InstrumentationService } from './instrumentation.service';

private httpBackend;
private url;
sessionId: string;
constructor(httpBackend: HttpBackend, url?: string);
/**
* The URL of the server endpoint to which to POST events
* @param {string} url
* Determines the URL of the server instrumentation service endpoint
* @type {string}
*/
setUrl(url: string): void;
url: string;
sessionId: string;
constructor(httpBackend: HttpBackend);
/**

@@ -27,0 +26,0 @@ * Handle instrumentation events.

@@ -1,4 +0,3 @@

import { InstrumentationService } from './instrumentation.service';
import { Guid } from './guid';
import { HttpBackend, HttpRequest } from '@angular/common/http';
import { HttpRequest } from '@angular/common/http';
/**

@@ -29,7 +28,10 @@ * Basic server logging for instrumentation service. Passes events as HTTP POST to

ServerInstrumentationService = /** @class */ (function () {
function ServerInstrumentationService(httpBackend, url) {
if (url === void 0) { url = '/api/metrics'; }
function ServerInstrumentationService(httpBackend) {
// Nothing here
this.httpBackend = httpBackend;
this.url = url;
/**
* Determines the URL of the server instrumentation service endpoint
* @type {string}
*/
this.url = '/api/metrics';
// simple uuid that represents the current browser tab/session

@@ -39,17 +41,2 @@ this.sessionId = Guid.guid();

/**
* The URL of the server endpoint to which to POST events
* @param {string} url
*/
/**
* The URL of the server endpoint to which to POST events
* @param {string} url
*/
ServerInstrumentationService.prototype.setUrl = /**
* The URL of the server endpoint to which to POST events
* @param {string} url
*/
function (url) {
this.url = url;
};
/**
* Handle instrumentation events.

@@ -56,0 +43,0 @@ * @param event The event to handle

@@ -1,1 +0,1 @@

[{"__symbolic":"module","version":4,"metadata":{"ServerInstrumentationService":{"__symbolic":"class","members":{"__ctor__":[{"__symbolic":"constructor","parameters":[{"__symbolic":"reference","module":"@angular/common/http","name":"HttpBackend","line":21,"character":34},{"__symbolic":"reference","name":"string"}]}],"setUrl":[{"__symbolic":"method"}],"handleEvent":[{"__symbolic":"method"}]}}}}]
[{"__symbolic":"module","version":4,"metadata":{"ServerInstrumentationService":{"__symbolic":"class","members":{"__ctor__":[{"__symbolic":"constructor","parameters":[{"__symbolic":"reference","module":"@angular/common/http","name":"HttpBackend","line":27,"character":34}]}],"handleEvent":[{"__symbolic":"method"}]}}}}]

@@ -6,3 +6,3 @@ {

"description": "Angular.io components and services for instrumenting errors, performance, and user actions",
"version": "0.0.2",
"version": "0.0.3",
"author": "Asymmetrik, Ltd.",

@@ -9,0 +9,0 @@ "copyright": "Copyright Asymmetrik, Ltd. 2007-2017 - All Rights Reserved.",

@@ -101,3 +101,6 @@ # @asymmetrik/ngx-instrumentation

export function serverInstrumentationServiceFactory(httpBackend: HttpBackend) {
return new ServerInstrumentationService(httpBackend, '/api/metrics');
const svc = new ServerInstrumentationService(httpBackend);
svc.url = '/api/metrics';
return svc;
}

@@ -153,3 +156,30 @@

*Note:* The global error handler will handle all Angular zone errors.
To help with development (and to ensure that errors aren't ignored), the plugin still logs errors to the client error console.
To disable this and hide all Angular errors from the client, you can configure the ```InstrumentErrorHandler``` using ```useFactory``` as follows:
```js
import { ErrorHandler, NgModule } from '@angular/core';
import { InstrumentationModule, InstrumentErrorHandler, InstrumentationService } from '@asymmetrik/ngx-instrumentation';
@NgModule({
...
providers: [
...
{ provide: ErrorHandler, useFactory: errorHandlerFactory, deps: [ InstrumentationService ] },
...
],
...
})
export class AppModule { }
export function errorHandlerFactory(instrumentationService: InstrumentationService) {
const handler = new InstrumentErrorHandler(instrumentationService);
handler.logErrorsToConsole = true;
return handler;
}
```
### HTTP Interceptor

@@ -156,0 +186,0 @@ This integration captures all HTTP calls made in the application.

@@ -42,3 +42,3 @@ import { BrowserModule } from '@angular/platform-browser';

{ provide: InstrumentationService, useFactory: serverInstrumentationServiceFactory, deps: [ HttpBackend ] },
{ provide: ErrorHandler, useClass: InstrumentErrorHandler },
{ provide: ErrorHandler, useFactory: errorHandlerFactory, deps: [ InstrumentationService ] },
{ provide: HTTP_INTERCEPTORS, useClass: InstrumentHttpInterceptor, multi: true }

@@ -49,4 +49,14 @@ ]

function serverInstrumentationServiceFactory(httpBackend: HttpBackend) {
return new ServerInstrumentationService(httpBackend, '/api/metrics');
export function serverInstrumentationServiceFactory(httpBackend: HttpBackend) {
const svc = new ServerInstrumentationService(httpBackend);
svc.url = '/api/metrics';
return svc;
}
export function errorHandlerFactory(instrumentationService: InstrumentationService) {
const handler = new InstrumentErrorHandler(instrumentationService);
handler.logErrorsToConsole = true;
return handler;
}

@@ -12,2 +12,10 @@ import { ErrorHandler, Injectable } from '@angular/core';

/**
* Determines whether or not handled errors are logged to the client
* console in addition to being passed to the instrumentation service
*
* @type {boolean}
*/
public logErrorsToConsole: boolean = true;
constructor(private instrumentationService: InstrumentationService) {

@@ -21,2 +29,9 @@ // Nothing here

// Log errors to console
if (this.logErrorsToConsole) {
// tslint:disable-next-line:no-console
console.error(error);
}
// Call the instrumentation service to handle the error event

@@ -23,0 +38,0 @@ this.instrumentationService.handleEvent({

@@ -17,3 +17,3 @@ import { Injectable } from '@angular/core';

includeParams: boolean = false;
public includeParams: boolean = false;

@@ -24,6 +24,2 @@ constructor(private instrumentationService: InstrumentationService) {

setIncludeParams(v: boolean) {
this.includeParams = v;
}
intercept(req: HttpRequest<any>, next: HttpHandler): Observable<HttpEvent<any>> {

@@ -30,0 +26,0 @@

@@ -101,3 +101,6 @@ import { Directive, OnDestroy, OnInit } from '@angular/core';

url: event.url,
error: event.error
error: {
message: (null != event.error) ? event.error.message : '',
stack: (null != event.error) ? event.error.stack : ''
}
};

@@ -121,3 +124,3 @@

protected extractActivatedRouteSnapshot(snapshot: ActivatedRouteSnapshot, max: number = 0) {
protected extractActivatedRouteSnapshot(snapshot: ActivatedRouteSnapshot, max: number = 20) {

@@ -128,3 +131,11 @@ const toReturn: any = {};

if (null != snapshot.children) {
toReturn.children = snapshot.children.map((c) => this.extractActivatedRouteSnapshot(c, max++));
// Only keep going if we haven't exceeded the max levels
if (max > 0) {
toReturn.children = snapshot.children.map((c) => this.extractActivatedRouteSnapshot(c, max--));
}
else {
toReturn.children = [];
}
}

@@ -131,0 +142,0 @@

@@ -19,6 +19,12 @@ import { InstrumentationService } from './instrumentation.service';

/**
* Determines the URL of the server instrumentation service endpoint
* @type {string}
*/
public url: string = '/api/metrics';
// simple uuid that represents the current browser tab/session
sessionId = Guid.guid();
constructor(private httpBackend: HttpBackend, private url: string = '/api/metrics') {
constructor(private httpBackend: HttpBackend) {
// Nothing here

@@ -28,10 +34,2 @@ }

/**
* The URL of the server endpoint to which to POST events
* @param {string} url
*/
setUrl(url: string) {
this.url = url;
}
/**
* Handle instrumentation events.

@@ -38,0 +36,0 @@ * @param event The event to handle

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc