fix: trace perf of spa page (#33)
* fix: trace perf
* fix: trace spa page
diff --git a/src/monitor.ts b/src/monitor.ts
index f806c2a..c7107de 100644
--- a/src/monitor.ts
+++ b/src/monitor.ts
@@ -17,7 +17,7 @@
import { CustomOptionsType } from './types';
import { JSErrors, PromiseErrors, AjaxErrors, ResourceErrors, VueErrors } from './errors/index';
-import Performance from './performance/index';
+import tracePerf from './performance/index';
import traceSegment from './trace/segment';
const ClientMonitor = {
@@ -37,21 +37,21 @@
...configs,
};
this.errors(this.customOptions);
- if (this.customOptions.autoTracePerf) {
- this.performance();
+ if (!this.customOptions.enableSPA) {
+ this.performance(this.customOptions);
}
traceSegment(this.customOptions);
},
- performance() {
+ performance(configs: any) {
// trace and report perf data and pv to serve when page loaded
if (document.readyState === 'complete') {
- Performance.recordPerf(this.customOptions);
+ tracePerf.recordPerf(configs);
} else {
window.addEventListener(
'load',
() => {
- Performance.recordPerf(this.customOptions);
+ tracePerf.recordPerf(configs);
},
false,
);
@@ -61,7 +61,7 @@
window.addEventListener(
'hashchange',
() => {
- Performance.recordPerf(this.customOptions);
+ tracePerf.recordPerf(configs);
},
false,
);
@@ -90,7 +90,7 @@
...this.customOptions,
...configs,
};
- this.performance();
+ this.performance(this.customOptions);
},
};
diff --git a/src/performance/index.ts b/src/performance/index.ts
index 6823de1..9c5d8ef 100644
--- a/src/performance/index.ts
+++ b/src/performance/index.ts
@@ -51,7 +51,7 @@
new Report('PERF', options.collector).sendByXhr(perfInfo);
// clear perf data
this.clearPerf();
- }, 8000);
+ }, 30000);
}
private clearPerf() {