You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@skywalking.apache.org by wu...@apache.org on 2022/04/01 06:10:49 UTC
[skywalking-client-js] branch master updated: fix: update metric and events (#78)
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
The following commit(s) were added to refs/heads/master by this push:
new f19ed66 fix: update metric and events (#78)
f19ed66 is described below
commit f19ed66f4fb3c00e8c0437e699673fa5563a7367
Author: Fine0830 <fi...@outlook.com>
AuthorDate: Fri Apr 1 14:10:44 2022 +0800
fix: update metric and events (#78)
---
src/performance/fmp.ts | 2 +-
src/performance/index.ts | 10 +++++-----
src/services/task.ts | 4 ++--
src/trace/segment.ts | 5 ++---
4 files changed, 10 insertions(+), 11 deletions(-)
diff --git a/src/performance/fmp.ts b/src/performance/fmp.ts
index f0002dc..3bd2e00 100644
--- a/src/performance/fmp.ts
+++ b/src/performance/fmp.ts
@@ -145,7 +145,7 @@ class FMPTiming {
time = this.statusCollector[index].time;
} else {
const match = getStyle(item.ele, 'background-image').match(/url\(\"(.*?)\"\)/);
- let url: string;
+ let url: string = '';
if (match && match[1]) {
url = match[1];
}
diff --git a/src/performance/index.ts b/src/performance/index.ts
index 4cb068c..6c637e0 100644
--- a/src/performance/index.ts
+++ b/src/performance/index.ts
@@ -28,14 +28,14 @@ class TracePerf {
public async recordPerf(options: CustomOptionsType) {
let fmp: { fmpTime: number | undefined } = { fmpTime: undefined };
- if (options.autoTracePerf) {
- this.perfConfig.perfDetail = await new pagePerf().getPerfTiming();
- if (options.useFmp) {
- fmp = await new FMP();
- }
+ if (options.autoTracePerf && options.useFmp) {
+ fmp = await new FMP();
}
// auto report pv and perf data
setTimeout(() => {
+ if (options.autoTracePerf) {
+ this.perfConfig.perfDetail = new pagePerf().getPerfTiming();
+ }
const perfDetail = options.autoTracePerf
? {
...this.perfConfig.perfDetail,
diff --git a/src/services/task.ts b/src/services/task.ts
index 2fb29b8..544c9d0 100644
--- a/src/services/task.ts
+++ b/src/services/task.ts
@@ -35,12 +35,12 @@ class TaskQueue {
}
public finallyFireTasks() {
- window.onbeforeunload = () => {
+ window.addEventListener('beforeunload', () => {
if (!this.queues.length) {
return;
}
new Report('ERRORS', this.collector).sendByXhr(this.queues);
- };
+ });
}
}
diff --git a/src/trace/segment.ts b/src/trace/segment.ts
index 836ef7b..1a3d072 100644
--- a/src/trace/segment.ts
+++ b/src/trace/segment.ts
@@ -26,13 +26,12 @@ export default function traceSegment(options: CustomOptionsType) {
// inject interceptor
xhrInterceptor(options, segments);
windowFetch(options, segments);
-
- window.onbeforeunload = function (e: Event) {
+ window.addEventListener('beforeunload', () => {
if (!segments.length) {
return;
}
new Report('SEGMENTS', options.collector).sendByXhr(segments);
- };
+ });
//report per options.traceTimeInterval min
setInterval(() => {
if (!segments.length) {