cwj_monitoring 0.0.25 → 0.0.26
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.cjs +41 -15
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +41 -15
- package/dist/index.js.map +1 -1
- package/dist/index.min.js +1 -1
- package/dist/index.min.js.map +1 -1
- package/dist/index.umd.js +41 -15
- package/dist/index.umd.js.map +1 -1
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -105,6 +105,13 @@ function throttle(fn, delay) {
|
|
|
105
105
|
}
|
|
106
106
|
};
|
|
107
107
|
}
|
|
108
|
+
const isIgnoredScriptSource = (sourceURL) => {
|
|
109
|
+
if (!sourceURL || typeof sourceURL !== "string")
|
|
110
|
+
return false;
|
|
111
|
+
if (/node_modules/.test(sourceURL))
|
|
112
|
+
return true;
|
|
113
|
+
return false;
|
|
114
|
+
};
|
|
108
115
|
|
|
109
116
|
const MAX_CACHE_LEN = 5;
|
|
110
117
|
const MAX_WAITING_TIME = 3e4;
|
|
@@ -663,21 +670,40 @@ const PerformancePlugin = (options = {}) => {
|
|
|
663
670
|
}
|
|
664
671
|
const threshold = options.loafThreshold ?? DEFAULT_LOAF_THRESHOLD;
|
|
665
672
|
if (entry.duration > threshold) {
|
|
666
|
-
|
|
667
|
-
|
|
668
|
-
|
|
669
|
-
|
|
670
|
-
|
|
671
|
-
|
|
672
|
-
|
|
673
|
-
|
|
674
|
-
|
|
675
|
-
|
|
676
|
-
|
|
677
|
-
|
|
678
|
-
|
|
679
|
-
|
|
680
|
-
}
|
|
673
|
+
const scripts = Array.isArray(entry.scripts) ? entry.scripts : [];
|
|
674
|
+
let isUserTriggered = false;
|
|
675
|
+
let allIgnored = true;
|
|
676
|
+
for (let i = 0; i < scripts.length; i++) {
|
|
677
|
+
const s = scripts[i];
|
|
678
|
+
if (!s)
|
|
679
|
+
continue;
|
|
680
|
+
if (!isUserTriggered && s.invokerType === "user-callback")
|
|
681
|
+
isUserTriggered = true;
|
|
682
|
+
if (allIgnored && !isIgnoredScriptSource(s.sourceURL)) {
|
|
683
|
+
allIgnored = false;
|
|
684
|
+
}
|
|
685
|
+
if (isUserTriggered && !allIgnored)
|
|
686
|
+
break;
|
|
687
|
+
}
|
|
688
|
+
if (isUserTriggered && !allIgnored) {
|
|
689
|
+
context?.emit(EMIT_TYPE.PERFORMANCE_LOAF, {
|
|
690
|
+
duration: entry.duration,
|
|
691
|
+
startTime: entry.startTime,
|
|
692
|
+
renderStart: entry.renderStart,
|
|
693
|
+
styleAndLayoutStart: entry.styleAndLayoutStart,
|
|
694
|
+
hadRecentInput: entry.hadRecentInput,
|
|
695
|
+
scripts: entry.scripts.map((s) => ({
|
|
696
|
+
duration: s.duration,
|
|
697
|
+
invoker: s.invoker,
|
|
698
|
+
invokerType: s.invokerType,
|
|
699
|
+
sourceURL: s.sourceURL,
|
|
700
|
+
functionName: s.functionName,
|
|
701
|
+
sourceFunctionName: s.sourceFunctionName,
|
|
702
|
+
sourceCharPosition: s.sourceCharPosition,
|
|
703
|
+
startTime: s.startTime
|
|
704
|
+
}))
|
|
705
|
+
});
|
|
706
|
+
}
|
|
681
707
|
}
|
|
682
708
|
}
|
|
683
709
|
};
|