MCPcopy Create free account
hub / github.com/Silentely/eSIM-Tools / shouldShowReportDialog

Function shouldShowReportDialog

tests/modules/sentry-feedback.test.js:88–118  ·  view source on GitHub ↗
(event)

Source from the content-addressed store, hash-verified

86 const COOLDOWN_MS = 60000;
87
88 function shouldShowReportDialog(event) {
89 const empty = { shouldShow: false, fingerprint: '' };
90
91 // 空事件防御
92 if (!event || typeof event !== 'object') return empty;
93
94 // 仅生产环境弹窗
95 if (isDev) return empty;
96
97 // 仅对异常事件弹窗(captureMessage 等不弹)
98 if (!event.exception || !event.exception.values || !event.exception.values.length) {
99 return empty;
100 }
101
102 // 生成错误指纹:取第一个异常的 type + value 组合
103 const firstException = event.exception.values[0];
104 const fingerprint = (firstException.type || '') + ':' + (firstException.value || '');
105
106 // 冷却检查:避免短时间内反复弹窗
107 const now = Date.now();
108 if (now - lastReportDialogTime < COOLDOWN_MS) {
109 return { shouldShow: false, fingerprint };
110 }
111
112 // 同一错误不重复弹窗
113 if (fingerprint === lastReportDialogFingerprint) {
114 return { shouldShow: false, fingerprint };
115 }
116
117 return { shouldShow: true, fingerprint };
118 }
119
120 function reset() {
121 lastReportDialogTime = 0;

Callers 1

Calls

no outgoing calls

Tested by

no test coverage detected