This is an automated email from the ASF dual-hosted git repository. wusheng pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/skywalking-client-js.git
commit 24c04a79912682b5bc4a2a576ac41c28a0e391b2 Author: Qiuxia Fan <[email protected]> AuthorDate: Wed Feb 12 17:41:20 2020 +0800 feat: add js error pv --- src/errors/js.ts | 1 - src/monitor.ts | 8 ++++++-- src/services/base.ts | 7 +++++++ src/services/types.d.ts | 1 + src/types.d.ts | 2 ++ 5 files changed, 16 insertions(+), 3 deletions(-) diff --git a/src/errors/js.ts b/src/errors/js.ts index e6b81f8..4b1d237 100644 --- a/src/errors/js.ts +++ b/src/errors/js.ts @@ -17,7 +17,6 @@ import Base from '../services/base'; import { GradeTypeEnum, ErrorsCategory } from '../services/constant'; - class JSErrors extends Base { public handleErrors(options: {reportUrl: string; serviceName: string}) { window.onerror = (message, url, line, col, error) => { diff --git a/src/monitor.ts b/src/monitor.ts index bf0d567..7b903ba 100644 --- a/src/monitor.ts +++ b/src/monitor.ts @@ -60,8 +60,12 @@ const ClientMonitor = { } }, - tracePerfDetail(options: any) { - Performance.recordPerf(options); + tracePerfDetail(options: CustomPerfOptionsType) { + const customPerfOptions = { + ...this.customPerfOptions, + ...options, + }; + Performance.recordPerf(customPerfOptions); }, }; diff --git a/src/services/base.ts b/src/services/base.ts index d7f3cea..521a28e 100644 --- a/src/services/base.ts +++ b/src/services/base.ts @@ -18,6 +18,7 @@ import Task from './task'; import { ErrorsCategory, GradeTypeEnum } from './constant'; import { errorInfoFeilds } from './types'; +let jsErrorPv = false; export default class Base { public reportUrl: string; @@ -31,9 +32,15 @@ export default class Base { col: 0, errorInfo: '', message: '', + jsErrorPv: false, }; public traceInfo() { + // mark js error pv + if (!jsErrorPv && this.logInfo.category === ErrorsCategory.JS_ERROR) { + jsErrorPv = true; + this.logInfo.jsErrorPv = true; + } this.handleRecordError(); setTimeout(() => { Task.fireTasks(); diff --git a/src/services/types.d.ts b/src/services/types.d.ts index f1ae5a6..a0bdad9 100644 --- a/src/services/types.d.ts +++ b/src/services/types.d.ts @@ -40,4 +40,5 @@ export interface errorInfoFeilds { line?: number; col?: number; errorInfo?: any; + jsErrorPv?: boolean; } diff --git a/src/types.d.ts b/src/types.d.ts index 61dc7c8..3b858a2 100644 --- a/src/types.d.ts +++ b/src/types.d.ts @@ -29,4 +29,6 @@ export type CustomPerfOptionsType = { pageId: string; reportUrl: string; serviceName: string; + serviceId: string; + versionId: string; } \ No newline at end of file
