@be-link/cls-logger 1.0.1-beta.18 → 1.0.1-beta.19
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.esm.js +74 -18
- package/dist/index.js +74 -18
- package/dist/index.umd.js +74 -18
- package/dist/mini/errorMonitor.d.ts.map +1 -1
- package/dist/mini.esm.js +49 -18
- package/dist/mini.js +49 -18
- package/dist/types.d.ts +7 -1
- package/dist/types.d.ts.map +1 -1
- package/dist/web/errorMonitor.d.ts.map +1 -1
- package/dist/web.esm.js +25 -0
- package/dist/web.js +25 -0
- package/package.json +1 -1
package/dist/index.esm.js
CHANGED
|
@@ -1433,6 +1433,13 @@ function installRequestMonitor(report, opts = {}) {
|
|
|
1433
1433
|
const DEFAULT_MAX_TEXT$1 = 4000;
|
|
1434
1434
|
const DEFAULT_DEDUPE_WINDOW_MS$1 = 3000;
|
|
1435
1435
|
const DEFAULT_DEDUPE_MAX_KEYS$1 = 200;
|
|
1436
|
+
/** 默认忽略的无意义错误信息 */
|
|
1437
|
+
const DEFAULT_IGNORE_MESSAGES$1 = [
|
|
1438
|
+
'Script error.',
|
|
1439
|
+
'Script error',
|
|
1440
|
+
/^ResizeObserver loop/,
|
|
1441
|
+
'Permission was denied',
|
|
1442
|
+
];
|
|
1436
1443
|
function truncate$3(s, maxLen) {
|
|
1437
1444
|
if (!s)
|
|
1438
1445
|
return s;
|
|
@@ -1445,6 +1452,17 @@ function sampleHit$3(sampleRate) {
|
|
|
1445
1452
|
return false;
|
|
1446
1453
|
return Math.random() < sampleRate;
|
|
1447
1454
|
}
|
|
1455
|
+
/** 检查消息是否应该被忽略 */
|
|
1456
|
+
function shouldIgnoreMessage$1(message, ignorePatterns) {
|
|
1457
|
+
if (!message || ignorePatterns.length === 0)
|
|
1458
|
+
return false;
|
|
1459
|
+
return ignorePatterns.some((pattern) => {
|
|
1460
|
+
if (typeof pattern === 'string') {
|
|
1461
|
+
return message === pattern || message.includes(pattern);
|
|
1462
|
+
}
|
|
1463
|
+
return pattern.test(message);
|
|
1464
|
+
});
|
|
1465
|
+
}
|
|
1448
1466
|
function getPagePath$1() {
|
|
1449
1467
|
try {
|
|
1450
1468
|
if (typeof window === 'undefined')
|
|
@@ -1540,6 +1558,9 @@ function installBrowserErrorMonitor(report, options) {
|
|
|
1540
1558
|
};
|
|
1541
1559
|
if (event && typeof event === 'object' && 'message' in event) {
|
|
1542
1560
|
payload.message = truncate$3(String(event.message ?? ''), options.maxTextLength);
|
|
1561
|
+
// 检查是否应该忽略此错误
|
|
1562
|
+
if (shouldIgnoreMessage$1(String(event.message ?? ''), options.ignoreMessages))
|
|
1563
|
+
return;
|
|
1543
1564
|
payload.filename = truncate$3(String(event.filename ?? ''), 500);
|
|
1544
1565
|
payload.lineno = typeof event.lineno === 'number' ? event.lineno : undefined;
|
|
1545
1566
|
payload.colno = typeof event.colno === 'number' ? event.colno : undefined;
|
|
@@ -1578,6 +1599,9 @@ function installBrowserErrorMonitor(report, options) {
|
|
|
1578
1599
|
return;
|
|
1579
1600
|
const reason = event?.reason;
|
|
1580
1601
|
const e = normalizeErrorLike$1(reason, options.maxTextLength);
|
|
1602
|
+
// 检查是否应该忽略此错误
|
|
1603
|
+
if (shouldIgnoreMessage$1(e.message, options.ignoreMessages))
|
|
1604
|
+
return;
|
|
1581
1605
|
const payload = {
|
|
1582
1606
|
pagePath: getPagePath$1(),
|
|
1583
1607
|
source: 'unhandledrejection',
|
|
@@ -1607,6 +1631,7 @@ function installWebErrorMonitor(report, opts = {}) {
|
|
|
1607
1631
|
maxTextLength: raw.maxTextLength ?? DEFAULT_MAX_TEXT$1,
|
|
1608
1632
|
dedupeWindowMs: raw.dedupeWindowMs ?? DEFAULT_DEDUPE_WINDOW_MS$1,
|
|
1609
1633
|
dedupeMaxKeys: raw.dedupeMaxKeys ?? DEFAULT_DEDUPE_MAX_KEYS$1,
|
|
1634
|
+
ignoreMessages: raw.ignoreMessages ?? DEFAULT_IGNORE_MESSAGES$1,
|
|
1610
1635
|
};
|
|
1611
1636
|
installBrowserErrorMonitor(report, options);
|
|
1612
1637
|
}
|
|
@@ -1614,6 +1639,13 @@ function installWebErrorMonitor(report, opts = {}) {
|
|
|
1614
1639
|
const DEFAULT_MAX_TEXT = 4000;
|
|
1615
1640
|
const DEFAULT_DEDUPE_WINDOW_MS = 3000;
|
|
1616
1641
|
const DEFAULT_DEDUPE_MAX_KEYS = 200;
|
|
1642
|
+
/** 默认忽略的无意义错误信息 */
|
|
1643
|
+
const DEFAULT_IGNORE_MESSAGES = [
|
|
1644
|
+
'Script error.',
|
|
1645
|
+
'Script error',
|
|
1646
|
+
/^ResizeObserver loop/,
|
|
1647
|
+
'Permission was denied',
|
|
1648
|
+
];
|
|
1617
1649
|
function truncate$2(s, maxLen) {
|
|
1618
1650
|
if (!s)
|
|
1619
1651
|
return s;
|
|
@@ -1626,6 +1658,17 @@ function sampleHit$2(sampleRate) {
|
|
|
1626
1658
|
return false;
|
|
1627
1659
|
return Math.random() < sampleRate;
|
|
1628
1660
|
}
|
|
1661
|
+
/** 检查消息是否应该被忽略 */
|
|
1662
|
+
function shouldIgnoreMessage(message, ignorePatterns) {
|
|
1663
|
+
if (!message || ignorePatterns.length === 0)
|
|
1664
|
+
return false;
|
|
1665
|
+
return ignorePatterns.some((pattern) => {
|
|
1666
|
+
if (typeof pattern === 'string') {
|
|
1667
|
+
return message === pattern || message.includes(pattern);
|
|
1668
|
+
}
|
|
1669
|
+
return pattern.test(message);
|
|
1670
|
+
});
|
|
1671
|
+
}
|
|
1629
1672
|
function getMpPagePath() {
|
|
1630
1673
|
try {
|
|
1631
1674
|
const pages = globalThis.getCurrentPages?.();
|
|
@@ -1720,6 +1763,9 @@ function installMiniProgramErrorMonitor(report, options) {
|
|
|
1720
1763
|
if (!sampleHit$2(options.sampleRate))
|
|
1721
1764
|
return;
|
|
1722
1765
|
const e = normalizeErrorLike(msg, options.maxTextLength);
|
|
1766
|
+
// 检查是否应该忽略此错误
|
|
1767
|
+
if (shouldIgnoreMessage(e.message, options.ignoreMessages))
|
|
1768
|
+
return;
|
|
1723
1769
|
const payload = {
|
|
1724
1770
|
pagePath: getMpPagePath(),
|
|
1725
1771
|
source: 'wx.onError',
|
|
@@ -1747,6 +1793,9 @@ function installMiniProgramErrorMonitor(report, options) {
|
|
|
1747
1793
|
if (!sampleHit$2(options.sampleRate))
|
|
1748
1794
|
return;
|
|
1749
1795
|
const e = normalizeErrorLike(res?.reason, options.maxTextLength);
|
|
1796
|
+
// 检查是否应该忽略此错误
|
|
1797
|
+
if (shouldIgnoreMessage(e.message, options.ignoreMessages))
|
|
1798
|
+
return;
|
|
1750
1799
|
const payload = {
|
|
1751
1800
|
pagePath: getMpPagePath(),
|
|
1752
1801
|
source: 'wx.onUnhandledRejection',
|
|
@@ -1778,15 +1827,18 @@ function installMiniProgramErrorMonitor(report, options) {
|
|
|
1778
1827
|
try {
|
|
1779
1828
|
if (sampleHit$2(options.sampleRate)) {
|
|
1780
1829
|
const e = normalizeErrorLike(args?.[0], options.maxTextLength);
|
|
1781
|
-
|
|
1782
|
-
|
|
1783
|
-
|
|
1784
|
-
|
|
1785
|
-
|
|
1786
|
-
|
|
1787
|
-
|
|
1788
|
-
|
|
1789
|
-
|
|
1830
|
+
// 检查是否应该忽略此错误
|
|
1831
|
+
if (!shouldIgnoreMessage(e.message, options.ignoreMessages)) {
|
|
1832
|
+
const payload = {
|
|
1833
|
+
pagePath: getMpPagePath(),
|
|
1834
|
+
source: 'App.onError',
|
|
1835
|
+
message: e.message,
|
|
1836
|
+
errorName: e.name,
|
|
1837
|
+
stack: e.stack,
|
|
1838
|
+
};
|
|
1839
|
+
if (shouldReport(buildErrorKey(options.reportType, payload)))
|
|
1840
|
+
report(options.reportType, payload);
|
|
1841
|
+
}
|
|
1790
1842
|
}
|
|
1791
1843
|
}
|
|
1792
1844
|
catch {
|
|
@@ -1802,15 +1854,18 @@ function installMiniProgramErrorMonitor(report, options) {
|
|
|
1802
1854
|
if (sampleHit$2(options.sampleRate)) {
|
|
1803
1855
|
const reason = args?.[0]?.reason ?? args?.[0];
|
|
1804
1856
|
const e = normalizeErrorLike(reason, options.maxTextLength);
|
|
1805
|
-
|
|
1806
|
-
|
|
1807
|
-
|
|
1808
|
-
|
|
1809
|
-
|
|
1810
|
-
|
|
1811
|
-
|
|
1812
|
-
|
|
1813
|
-
|
|
1857
|
+
// 检查是否应该忽略此错误
|
|
1858
|
+
if (!shouldIgnoreMessage(e.message, options.ignoreMessages)) {
|
|
1859
|
+
const payload = {
|
|
1860
|
+
pagePath: getMpPagePath(),
|
|
1861
|
+
source: 'App.onUnhandledRejection',
|
|
1862
|
+
message: e.message,
|
|
1863
|
+
errorName: e.name,
|
|
1864
|
+
stack: e.stack,
|
|
1865
|
+
};
|
|
1866
|
+
if (shouldReport(buildErrorKey(options.reportType, payload)))
|
|
1867
|
+
report(options.reportType, payload);
|
|
1868
|
+
}
|
|
1814
1869
|
}
|
|
1815
1870
|
}
|
|
1816
1871
|
catch {
|
|
@@ -1841,6 +1896,7 @@ function installMiniErrorMonitor(report, opts = {}) {
|
|
|
1841
1896
|
maxTextLength: raw.maxTextLength ?? DEFAULT_MAX_TEXT,
|
|
1842
1897
|
dedupeWindowMs: raw.dedupeWindowMs ?? DEFAULT_DEDUPE_WINDOW_MS,
|
|
1843
1898
|
dedupeMaxKeys: raw.dedupeMaxKeys ?? DEFAULT_DEDUPE_MAX_KEYS,
|
|
1899
|
+
ignoreMessages: raw.ignoreMessages ?? DEFAULT_IGNORE_MESSAGES,
|
|
1844
1900
|
};
|
|
1845
1901
|
installMiniProgramErrorMonitor(report, options);
|
|
1846
1902
|
}
|
package/dist/index.js
CHANGED
|
@@ -1437,6 +1437,13 @@ function installRequestMonitor(report, opts = {}) {
|
|
|
1437
1437
|
const DEFAULT_MAX_TEXT$1 = 4000;
|
|
1438
1438
|
const DEFAULT_DEDUPE_WINDOW_MS$1 = 3000;
|
|
1439
1439
|
const DEFAULT_DEDUPE_MAX_KEYS$1 = 200;
|
|
1440
|
+
/** 默认忽略的无意义错误信息 */
|
|
1441
|
+
const DEFAULT_IGNORE_MESSAGES$1 = [
|
|
1442
|
+
'Script error.',
|
|
1443
|
+
'Script error',
|
|
1444
|
+
/^ResizeObserver loop/,
|
|
1445
|
+
'Permission was denied',
|
|
1446
|
+
];
|
|
1440
1447
|
function truncate$3(s, maxLen) {
|
|
1441
1448
|
if (!s)
|
|
1442
1449
|
return s;
|
|
@@ -1449,6 +1456,17 @@ function sampleHit$3(sampleRate) {
|
|
|
1449
1456
|
return false;
|
|
1450
1457
|
return Math.random() < sampleRate;
|
|
1451
1458
|
}
|
|
1459
|
+
/** 检查消息是否应该被忽略 */
|
|
1460
|
+
function shouldIgnoreMessage$1(message, ignorePatterns) {
|
|
1461
|
+
if (!message || ignorePatterns.length === 0)
|
|
1462
|
+
return false;
|
|
1463
|
+
return ignorePatterns.some((pattern) => {
|
|
1464
|
+
if (typeof pattern === 'string') {
|
|
1465
|
+
return message === pattern || message.includes(pattern);
|
|
1466
|
+
}
|
|
1467
|
+
return pattern.test(message);
|
|
1468
|
+
});
|
|
1469
|
+
}
|
|
1452
1470
|
function getPagePath$1() {
|
|
1453
1471
|
try {
|
|
1454
1472
|
if (typeof window === 'undefined')
|
|
@@ -1544,6 +1562,9 @@ function installBrowserErrorMonitor(report, options) {
|
|
|
1544
1562
|
};
|
|
1545
1563
|
if (event && typeof event === 'object' && 'message' in event) {
|
|
1546
1564
|
payload.message = truncate$3(String(event.message ?? ''), options.maxTextLength);
|
|
1565
|
+
// 检查是否应该忽略此错误
|
|
1566
|
+
if (shouldIgnoreMessage$1(String(event.message ?? ''), options.ignoreMessages))
|
|
1567
|
+
return;
|
|
1547
1568
|
payload.filename = truncate$3(String(event.filename ?? ''), 500);
|
|
1548
1569
|
payload.lineno = typeof event.lineno === 'number' ? event.lineno : undefined;
|
|
1549
1570
|
payload.colno = typeof event.colno === 'number' ? event.colno : undefined;
|
|
@@ -1582,6 +1603,9 @@ function installBrowserErrorMonitor(report, options) {
|
|
|
1582
1603
|
return;
|
|
1583
1604
|
const reason = event?.reason;
|
|
1584
1605
|
const e = normalizeErrorLike$1(reason, options.maxTextLength);
|
|
1606
|
+
// 检查是否应该忽略此错误
|
|
1607
|
+
if (shouldIgnoreMessage$1(e.message, options.ignoreMessages))
|
|
1608
|
+
return;
|
|
1585
1609
|
const payload = {
|
|
1586
1610
|
pagePath: getPagePath$1(),
|
|
1587
1611
|
source: 'unhandledrejection',
|
|
@@ -1611,6 +1635,7 @@ function installWebErrorMonitor(report, opts = {}) {
|
|
|
1611
1635
|
maxTextLength: raw.maxTextLength ?? DEFAULT_MAX_TEXT$1,
|
|
1612
1636
|
dedupeWindowMs: raw.dedupeWindowMs ?? DEFAULT_DEDUPE_WINDOW_MS$1,
|
|
1613
1637
|
dedupeMaxKeys: raw.dedupeMaxKeys ?? DEFAULT_DEDUPE_MAX_KEYS$1,
|
|
1638
|
+
ignoreMessages: raw.ignoreMessages ?? DEFAULT_IGNORE_MESSAGES$1,
|
|
1614
1639
|
};
|
|
1615
1640
|
installBrowserErrorMonitor(report, options);
|
|
1616
1641
|
}
|
|
@@ -1618,6 +1643,13 @@ function installWebErrorMonitor(report, opts = {}) {
|
|
|
1618
1643
|
const DEFAULT_MAX_TEXT = 4000;
|
|
1619
1644
|
const DEFAULT_DEDUPE_WINDOW_MS = 3000;
|
|
1620
1645
|
const DEFAULT_DEDUPE_MAX_KEYS = 200;
|
|
1646
|
+
/** 默认忽略的无意义错误信息 */
|
|
1647
|
+
const DEFAULT_IGNORE_MESSAGES = [
|
|
1648
|
+
'Script error.',
|
|
1649
|
+
'Script error',
|
|
1650
|
+
/^ResizeObserver loop/,
|
|
1651
|
+
'Permission was denied',
|
|
1652
|
+
];
|
|
1621
1653
|
function truncate$2(s, maxLen) {
|
|
1622
1654
|
if (!s)
|
|
1623
1655
|
return s;
|
|
@@ -1630,6 +1662,17 @@ function sampleHit$2(sampleRate) {
|
|
|
1630
1662
|
return false;
|
|
1631
1663
|
return Math.random() < sampleRate;
|
|
1632
1664
|
}
|
|
1665
|
+
/** 检查消息是否应该被忽略 */
|
|
1666
|
+
function shouldIgnoreMessage(message, ignorePatterns) {
|
|
1667
|
+
if (!message || ignorePatterns.length === 0)
|
|
1668
|
+
return false;
|
|
1669
|
+
return ignorePatterns.some((pattern) => {
|
|
1670
|
+
if (typeof pattern === 'string') {
|
|
1671
|
+
return message === pattern || message.includes(pattern);
|
|
1672
|
+
}
|
|
1673
|
+
return pattern.test(message);
|
|
1674
|
+
});
|
|
1675
|
+
}
|
|
1633
1676
|
function getMpPagePath() {
|
|
1634
1677
|
try {
|
|
1635
1678
|
const pages = globalThis.getCurrentPages?.();
|
|
@@ -1724,6 +1767,9 @@ function installMiniProgramErrorMonitor(report, options) {
|
|
|
1724
1767
|
if (!sampleHit$2(options.sampleRate))
|
|
1725
1768
|
return;
|
|
1726
1769
|
const e = normalizeErrorLike(msg, options.maxTextLength);
|
|
1770
|
+
// 检查是否应该忽略此错误
|
|
1771
|
+
if (shouldIgnoreMessage(e.message, options.ignoreMessages))
|
|
1772
|
+
return;
|
|
1727
1773
|
const payload = {
|
|
1728
1774
|
pagePath: getMpPagePath(),
|
|
1729
1775
|
source: 'wx.onError',
|
|
@@ -1751,6 +1797,9 @@ function installMiniProgramErrorMonitor(report, options) {
|
|
|
1751
1797
|
if (!sampleHit$2(options.sampleRate))
|
|
1752
1798
|
return;
|
|
1753
1799
|
const e = normalizeErrorLike(res?.reason, options.maxTextLength);
|
|
1800
|
+
// 检查是否应该忽略此错误
|
|
1801
|
+
if (shouldIgnoreMessage(e.message, options.ignoreMessages))
|
|
1802
|
+
return;
|
|
1754
1803
|
const payload = {
|
|
1755
1804
|
pagePath: getMpPagePath(),
|
|
1756
1805
|
source: 'wx.onUnhandledRejection',
|
|
@@ -1782,15 +1831,18 @@ function installMiniProgramErrorMonitor(report, options) {
|
|
|
1782
1831
|
try {
|
|
1783
1832
|
if (sampleHit$2(options.sampleRate)) {
|
|
1784
1833
|
const e = normalizeErrorLike(args?.[0], options.maxTextLength);
|
|
1785
|
-
|
|
1786
|
-
|
|
1787
|
-
|
|
1788
|
-
|
|
1789
|
-
|
|
1790
|
-
|
|
1791
|
-
|
|
1792
|
-
|
|
1793
|
-
|
|
1834
|
+
// 检查是否应该忽略此错误
|
|
1835
|
+
if (!shouldIgnoreMessage(e.message, options.ignoreMessages)) {
|
|
1836
|
+
const payload = {
|
|
1837
|
+
pagePath: getMpPagePath(),
|
|
1838
|
+
source: 'App.onError',
|
|
1839
|
+
message: e.message,
|
|
1840
|
+
errorName: e.name,
|
|
1841
|
+
stack: e.stack,
|
|
1842
|
+
};
|
|
1843
|
+
if (shouldReport(buildErrorKey(options.reportType, payload)))
|
|
1844
|
+
report(options.reportType, payload);
|
|
1845
|
+
}
|
|
1794
1846
|
}
|
|
1795
1847
|
}
|
|
1796
1848
|
catch {
|
|
@@ -1806,15 +1858,18 @@ function installMiniProgramErrorMonitor(report, options) {
|
|
|
1806
1858
|
if (sampleHit$2(options.sampleRate)) {
|
|
1807
1859
|
const reason = args?.[0]?.reason ?? args?.[0];
|
|
1808
1860
|
const e = normalizeErrorLike(reason, options.maxTextLength);
|
|
1809
|
-
|
|
1810
|
-
|
|
1811
|
-
|
|
1812
|
-
|
|
1813
|
-
|
|
1814
|
-
|
|
1815
|
-
|
|
1816
|
-
|
|
1817
|
-
|
|
1861
|
+
// 检查是否应该忽略此错误
|
|
1862
|
+
if (!shouldIgnoreMessage(e.message, options.ignoreMessages)) {
|
|
1863
|
+
const payload = {
|
|
1864
|
+
pagePath: getMpPagePath(),
|
|
1865
|
+
source: 'App.onUnhandledRejection',
|
|
1866
|
+
message: e.message,
|
|
1867
|
+
errorName: e.name,
|
|
1868
|
+
stack: e.stack,
|
|
1869
|
+
};
|
|
1870
|
+
if (shouldReport(buildErrorKey(options.reportType, payload)))
|
|
1871
|
+
report(options.reportType, payload);
|
|
1872
|
+
}
|
|
1818
1873
|
}
|
|
1819
1874
|
}
|
|
1820
1875
|
catch {
|
|
@@ -1845,6 +1900,7 @@ function installMiniErrorMonitor(report, opts = {}) {
|
|
|
1845
1900
|
maxTextLength: raw.maxTextLength ?? DEFAULT_MAX_TEXT,
|
|
1846
1901
|
dedupeWindowMs: raw.dedupeWindowMs ?? DEFAULT_DEDUPE_WINDOW_MS,
|
|
1847
1902
|
dedupeMaxKeys: raw.dedupeMaxKeys ?? DEFAULT_DEDUPE_MAX_KEYS,
|
|
1903
|
+
ignoreMessages: raw.ignoreMessages ?? DEFAULT_IGNORE_MESSAGES,
|
|
1848
1904
|
};
|
|
1849
1905
|
installMiniProgramErrorMonitor(report, options);
|
|
1850
1906
|
}
|
package/dist/index.umd.js
CHANGED
|
@@ -1439,6 +1439,13 @@
|
|
|
1439
1439
|
const DEFAULT_MAX_TEXT$1 = 4000;
|
|
1440
1440
|
const DEFAULT_DEDUPE_WINDOW_MS$1 = 3000;
|
|
1441
1441
|
const DEFAULT_DEDUPE_MAX_KEYS$1 = 200;
|
|
1442
|
+
/** 默认忽略的无意义错误信息 */
|
|
1443
|
+
const DEFAULT_IGNORE_MESSAGES$1 = [
|
|
1444
|
+
'Script error.',
|
|
1445
|
+
'Script error',
|
|
1446
|
+
/^ResizeObserver loop/,
|
|
1447
|
+
'Permission was denied',
|
|
1448
|
+
];
|
|
1442
1449
|
function truncate$3(s, maxLen) {
|
|
1443
1450
|
if (!s)
|
|
1444
1451
|
return s;
|
|
@@ -1451,6 +1458,17 @@
|
|
|
1451
1458
|
return false;
|
|
1452
1459
|
return Math.random() < sampleRate;
|
|
1453
1460
|
}
|
|
1461
|
+
/** 检查消息是否应该被忽略 */
|
|
1462
|
+
function shouldIgnoreMessage$1(message, ignorePatterns) {
|
|
1463
|
+
if (!message || ignorePatterns.length === 0)
|
|
1464
|
+
return false;
|
|
1465
|
+
return ignorePatterns.some((pattern) => {
|
|
1466
|
+
if (typeof pattern === 'string') {
|
|
1467
|
+
return message === pattern || message.includes(pattern);
|
|
1468
|
+
}
|
|
1469
|
+
return pattern.test(message);
|
|
1470
|
+
});
|
|
1471
|
+
}
|
|
1454
1472
|
function getPagePath$1() {
|
|
1455
1473
|
try {
|
|
1456
1474
|
if (typeof window === 'undefined')
|
|
@@ -1546,6 +1564,9 @@
|
|
|
1546
1564
|
};
|
|
1547
1565
|
if (event && typeof event === 'object' && 'message' in event) {
|
|
1548
1566
|
payload.message = truncate$3(String(event.message ?? ''), options.maxTextLength);
|
|
1567
|
+
// 检查是否应该忽略此错误
|
|
1568
|
+
if (shouldIgnoreMessage$1(String(event.message ?? ''), options.ignoreMessages))
|
|
1569
|
+
return;
|
|
1549
1570
|
payload.filename = truncate$3(String(event.filename ?? ''), 500);
|
|
1550
1571
|
payload.lineno = typeof event.lineno === 'number' ? event.lineno : undefined;
|
|
1551
1572
|
payload.colno = typeof event.colno === 'number' ? event.colno : undefined;
|
|
@@ -1584,6 +1605,9 @@
|
|
|
1584
1605
|
return;
|
|
1585
1606
|
const reason = event?.reason;
|
|
1586
1607
|
const e = normalizeErrorLike$1(reason, options.maxTextLength);
|
|
1608
|
+
// 检查是否应该忽略此错误
|
|
1609
|
+
if (shouldIgnoreMessage$1(e.message, options.ignoreMessages))
|
|
1610
|
+
return;
|
|
1587
1611
|
const payload = {
|
|
1588
1612
|
pagePath: getPagePath$1(),
|
|
1589
1613
|
source: 'unhandledrejection',
|
|
@@ -1613,6 +1637,7 @@
|
|
|
1613
1637
|
maxTextLength: raw.maxTextLength ?? DEFAULT_MAX_TEXT$1,
|
|
1614
1638
|
dedupeWindowMs: raw.dedupeWindowMs ?? DEFAULT_DEDUPE_WINDOW_MS$1,
|
|
1615
1639
|
dedupeMaxKeys: raw.dedupeMaxKeys ?? DEFAULT_DEDUPE_MAX_KEYS$1,
|
|
1640
|
+
ignoreMessages: raw.ignoreMessages ?? DEFAULT_IGNORE_MESSAGES$1,
|
|
1616
1641
|
};
|
|
1617
1642
|
installBrowserErrorMonitor(report, options);
|
|
1618
1643
|
}
|
|
@@ -1620,6 +1645,13 @@
|
|
|
1620
1645
|
const DEFAULT_MAX_TEXT = 4000;
|
|
1621
1646
|
const DEFAULT_DEDUPE_WINDOW_MS = 3000;
|
|
1622
1647
|
const DEFAULT_DEDUPE_MAX_KEYS = 200;
|
|
1648
|
+
/** 默认忽略的无意义错误信息 */
|
|
1649
|
+
const DEFAULT_IGNORE_MESSAGES = [
|
|
1650
|
+
'Script error.',
|
|
1651
|
+
'Script error',
|
|
1652
|
+
/^ResizeObserver loop/,
|
|
1653
|
+
'Permission was denied',
|
|
1654
|
+
];
|
|
1623
1655
|
function truncate$2(s, maxLen) {
|
|
1624
1656
|
if (!s)
|
|
1625
1657
|
return s;
|
|
@@ -1632,6 +1664,17 @@
|
|
|
1632
1664
|
return false;
|
|
1633
1665
|
return Math.random() < sampleRate;
|
|
1634
1666
|
}
|
|
1667
|
+
/** 检查消息是否应该被忽略 */
|
|
1668
|
+
function shouldIgnoreMessage(message, ignorePatterns) {
|
|
1669
|
+
if (!message || ignorePatterns.length === 0)
|
|
1670
|
+
return false;
|
|
1671
|
+
return ignorePatterns.some((pattern) => {
|
|
1672
|
+
if (typeof pattern === 'string') {
|
|
1673
|
+
return message === pattern || message.includes(pattern);
|
|
1674
|
+
}
|
|
1675
|
+
return pattern.test(message);
|
|
1676
|
+
});
|
|
1677
|
+
}
|
|
1635
1678
|
function getMpPagePath() {
|
|
1636
1679
|
try {
|
|
1637
1680
|
const pages = globalThis.getCurrentPages?.();
|
|
@@ -1726,6 +1769,9 @@
|
|
|
1726
1769
|
if (!sampleHit$2(options.sampleRate))
|
|
1727
1770
|
return;
|
|
1728
1771
|
const e = normalizeErrorLike(msg, options.maxTextLength);
|
|
1772
|
+
// 检查是否应该忽略此错误
|
|
1773
|
+
if (shouldIgnoreMessage(e.message, options.ignoreMessages))
|
|
1774
|
+
return;
|
|
1729
1775
|
const payload = {
|
|
1730
1776
|
pagePath: getMpPagePath(),
|
|
1731
1777
|
source: 'wx.onError',
|
|
@@ -1753,6 +1799,9 @@
|
|
|
1753
1799
|
if (!sampleHit$2(options.sampleRate))
|
|
1754
1800
|
return;
|
|
1755
1801
|
const e = normalizeErrorLike(res?.reason, options.maxTextLength);
|
|
1802
|
+
// 检查是否应该忽略此错误
|
|
1803
|
+
if (shouldIgnoreMessage(e.message, options.ignoreMessages))
|
|
1804
|
+
return;
|
|
1756
1805
|
const payload = {
|
|
1757
1806
|
pagePath: getMpPagePath(),
|
|
1758
1807
|
source: 'wx.onUnhandledRejection',
|
|
@@ -1784,15 +1833,18 @@
|
|
|
1784
1833
|
try {
|
|
1785
1834
|
if (sampleHit$2(options.sampleRate)) {
|
|
1786
1835
|
const e = normalizeErrorLike(args?.[0], options.maxTextLength);
|
|
1787
|
-
|
|
1788
|
-
|
|
1789
|
-
|
|
1790
|
-
|
|
1791
|
-
|
|
1792
|
-
|
|
1793
|
-
|
|
1794
|
-
|
|
1795
|
-
|
|
1836
|
+
// 检查是否应该忽略此错误
|
|
1837
|
+
if (!shouldIgnoreMessage(e.message, options.ignoreMessages)) {
|
|
1838
|
+
const payload = {
|
|
1839
|
+
pagePath: getMpPagePath(),
|
|
1840
|
+
source: 'App.onError',
|
|
1841
|
+
message: e.message,
|
|
1842
|
+
errorName: e.name,
|
|
1843
|
+
stack: e.stack,
|
|
1844
|
+
};
|
|
1845
|
+
if (shouldReport(buildErrorKey(options.reportType, payload)))
|
|
1846
|
+
report(options.reportType, payload);
|
|
1847
|
+
}
|
|
1796
1848
|
}
|
|
1797
1849
|
}
|
|
1798
1850
|
catch {
|
|
@@ -1808,15 +1860,18 @@
|
|
|
1808
1860
|
if (sampleHit$2(options.sampleRate)) {
|
|
1809
1861
|
const reason = args?.[0]?.reason ?? args?.[0];
|
|
1810
1862
|
const e = normalizeErrorLike(reason, options.maxTextLength);
|
|
1811
|
-
|
|
1812
|
-
|
|
1813
|
-
|
|
1814
|
-
|
|
1815
|
-
|
|
1816
|
-
|
|
1817
|
-
|
|
1818
|
-
|
|
1819
|
-
|
|
1863
|
+
// 检查是否应该忽略此错误
|
|
1864
|
+
if (!shouldIgnoreMessage(e.message, options.ignoreMessages)) {
|
|
1865
|
+
const payload = {
|
|
1866
|
+
pagePath: getMpPagePath(),
|
|
1867
|
+
source: 'App.onUnhandledRejection',
|
|
1868
|
+
message: e.message,
|
|
1869
|
+
errorName: e.name,
|
|
1870
|
+
stack: e.stack,
|
|
1871
|
+
};
|
|
1872
|
+
if (shouldReport(buildErrorKey(options.reportType, payload)))
|
|
1873
|
+
report(options.reportType, payload);
|
|
1874
|
+
}
|
|
1820
1875
|
}
|
|
1821
1876
|
}
|
|
1822
1877
|
catch {
|
|
@@ -1847,6 +1902,7 @@
|
|
|
1847
1902
|
maxTextLength: raw.maxTextLength ?? DEFAULT_MAX_TEXT,
|
|
1848
1903
|
dedupeWindowMs: raw.dedupeWindowMs ?? DEFAULT_DEDUPE_WINDOW_MS,
|
|
1849
1904
|
dedupeMaxKeys: raw.dedupeMaxKeys ?? DEFAULT_DEDUPE_MAX_KEYS,
|
|
1905
|
+
ignoreMessages: raw.ignoreMessages ?? DEFAULT_IGNORE_MESSAGES,
|
|
1850
1906
|
};
|
|
1851
1907
|
installMiniProgramErrorMonitor(report, options);
|
|
1852
1908
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"errorMonitor.d.ts","sourceRoot":"","sources":["../../src/mini/errorMonitor.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,mBAAmB,EAAE,UAAU,EAAE,MAAM,UAAU,CAAC;AAGhE,KAAK,QAAQ,GAAG,CAAC,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,UAAU,KAAK,IAAI,CAAC;
|
|
1
|
+
{"version":3,"file":"errorMonitor.d.ts","sourceRoot":"","sources":["../../src/mini/errorMonitor.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,mBAAmB,EAAE,UAAU,EAAE,MAAM,UAAU,CAAC;AAGhE,KAAK,QAAQ,GAAG,CAAC,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,UAAU,KAAK,IAAI,CAAC;AAuPzD,wBAAgB,uBAAuB,CAAC,MAAM,EAAE,QAAQ,EAAE,IAAI,GAAE,OAAO,GAAG,mBAAmB,GAAG,SAAc,GAAG,IAAI,CAiBpH"}
|
package/dist/mini.esm.js
CHANGED
|
@@ -1132,6 +1132,13 @@ function installMiniRequestMonitor(report, opts = {}) {
|
|
|
1132
1132
|
const DEFAULT_MAX_TEXT = 4000;
|
|
1133
1133
|
const DEFAULT_DEDUPE_WINDOW_MS = 3000;
|
|
1134
1134
|
const DEFAULT_DEDUPE_MAX_KEYS = 200;
|
|
1135
|
+
/** 默认忽略的无意义错误信息 */
|
|
1136
|
+
const DEFAULT_IGNORE_MESSAGES = [
|
|
1137
|
+
'Script error.',
|
|
1138
|
+
'Script error',
|
|
1139
|
+
/^ResizeObserver loop/,
|
|
1140
|
+
'Permission was denied',
|
|
1141
|
+
];
|
|
1135
1142
|
function truncate(s, maxLen) {
|
|
1136
1143
|
if (!s)
|
|
1137
1144
|
return s;
|
|
@@ -1144,6 +1151,17 @@ function sampleHit$1(sampleRate) {
|
|
|
1144
1151
|
return false;
|
|
1145
1152
|
return Math.random() < sampleRate;
|
|
1146
1153
|
}
|
|
1154
|
+
/** 检查消息是否应该被忽略 */
|
|
1155
|
+
function shouldIgnoreMessage(message, ignorePatterns) {
|
|
1156
|
+
if (!message || ignorePatterns.length === 0)
|
|
1157
|
+
return false;
|
|
1158
|
+
return ignorePatterns.some((pattern) => {
|
|
1159
|
+
if (typeof pattern === 'string') {
|
|
1160
|
+
return message === pattern || message.includes(pattern);
|
|
1161
|
+
}
|
|
1162
|
+
return pattern.test(message);
|
|
1163
|
+
});
|
|
1164
|
+
}
|
|
1147
1165
|
function getMpPagePath() {
|
|
1148
1166
|
try {
|
|
1149
1167
|
const pages = globalThis.getCurrentPages?.();
|
|
@@ -1238,6 +1256,9 @@ function installMiniProgramErrorMonitor(report, options) {
|
|
|
1238
1256
|
if (!sampleHit$1(options.sampleRate))
|
|
1239
1257
|
return;
|
|
1240
1258
|
const e = normalizeErrorLike(msg, options.maxTextLength);
|
|
1259
|
+
// 检查是否应该忽略此错误
|
|
1260
|
+
if (shouldIgnoreMessage(e.message, options.ignoreMessages))
|
|
1261
|
+
return;
|
|
1241
1262
|
const payload = {
|
|
1242
1263
|
pagePath: getMpPagePath(),
|
|
1243
1264
|
source: 'wx.onError',
|
|
@@ -1265,6 +1286,9 @@ function installMiniProgramErrorMonitor(report, options) {
|
|
|
1265
1286
|
if (!sampleHit$1(options.sampleRate))
|
|
1266
1287
|
return;
|
|
1267
1288
|
const e = normalizeErrorLike(res?.reason, options.maxTextLength);
|
|
1289
|
+
// 检查是否应该忽略此错误
|
|
1290
|
+
if (shouldIgnoreMessage(e.message, options.ignoreMessages))
|
|
1291
|
+
return;
|
|
1268
1292
|
const payload = {
|
|
1269
1293
|
pagePath: getMpPagePath(),
|
|
1270
1294
|
source: 'wx.onUnhandledRejection',
|
|
@@ -1296,15 +1320,18 @@ function installMiniProgramErrorMonitor(report, options) {
|
|
|
1296
1320
|
try {
|
|
1297
1321
|
if (sampleHit$1(options.sampleRate)) {
|
|
1298
1322
|
const e = normalizeErrorLike(args?.[0], options.maxTextLength);
|
|
1299
|
-
|
|
1300
|
-
|
|
1301
|
-
|
|
1302
|
-
|
|
1303
|
-
|
|
1304
|
-
|
|
1305
|
-
|
|
1306
|
-
|
|
1307
|
-
|
|
1323
|
+
// 检查是否应该忽略此错误
|
|
1324
|
+
if (!shouldIgnoreMessage(e.message, options.ignoreMessages)) {
|
|
1325
|
+
const payload = {
|
|
1326
|
+
pagePath: getMpPagePath(),
|
|
1327
|
+
source: 'App.onError',
|
|
1328
|
+
message: e.message,
|
|
1329
|
+
errorName: e.name,
|
|
1330
|
+
stack: e.stack,
|
|
1331
|
+
};
|
|
1332
|
+
if (shouldReport(buildErrorKey(options.reportType, payload)))
|
|
1333
|
+
report(options.reportType, payload);
|
|
1334
|
+
}
|
|
1308
1335
|
}
|
|
1309
1336
|
}
|
|
1310
1337
|
catch {
|
|
@@ -1320,15 +1347,18 @@ function installMiniProgramErrorMonitor(report, options) {
|
|
|
1320
1347
|
if (sampleHit$1(options.sampleRate)) {
|
|
1321
1348
|
const reason = args?.[0]?.reason ?? args?.[0];
|
|
1322
1349
|
const e = normalizeErrorLike(reason, options.maxTextLength);
|
|
1323
|
-
|
|
1324
|
-
|
|
1325
|
-
|
|
1326
|
-
|
|
1327
|
-
|
|
1328
|
-
|
|
1329
|
-
|
|
1330
|
-
|
|
1331
|
-
|
|
1350
|
+
// 检查是否应该忽略此错误
|
|
1351
|
+
if (!shouldIgnoreMessage(e.message, options.ignoreMessages)) {
|
|
1352
|
+
const payload = {
|
|
1353
|
+
pagePath: getMpPagePath(),
|
|
1354
|
+
source: 'App.onUnhandledRejection',
|
|
1355
|
+
message: e.message,
|
|
1356
|
+
errorName: e.name,
|
|
1357
|
+
stack: e.stack,
|
|
1358
|
+
};
|
|
1359
|
+
if (shouldReport(buildErrorKey(options.reportType, payload)))
|
|
1360
|
+
report(options.reportType, payload);
|
|
1361
|
+
}
|
|
1332
1362
|
}
|
|
1333
1363
|
}
|
|
1334
1364
|
catch {
|
|
@@ -1359,6 +1389,7 @@ function installMiniErrorMonitor(report, opts = {}) {
|
|
|
1359
1389
|
maxTextLength: raw.maxTextLength ?? DEFAULT_MAX_TEXT,
|
|
1360
1390
|
dedupeWindowMs: raw.dedupeWindowMs ?? DEFAULT_DEDUPE_WINDOW_MS,
|
|
1361
1391
|
dedupeMaxKeys: raw.dedupeMaxKeys ?? DEFAULT_DEDUPE_MAX_KEYS,
|
|
1392
|
+
ignoreMessages: raw.ignoreMessages ?? DEFAULT_IGNORE_MESSAGES,
|
|
1362
1393
|
};
|
|
1363
1394
|
installMiniProgramErrorMonitor(report, options);
|
|
1364
1395
|
}
|
package/dist/mini.js
CHANGED
|
@@ -1155,6 +1155,13 @@ function installMiniRequestMonitor(report, opts = {}) {
|
|
|
1155
1155
|
const DEFAULT_MAX_TEXT = 4000;
|
|
1156
1156
|
const DEFAULT_DEDUPE_WINDOW_MS = 3000;
|
|
1157
1157
|
const DEFAULT_DEDUPE_MAX_KEYS = 200;
|
|
1158
|
+
/** 默认忽略的无意义错误信息 */
|
|
1159
|
+
const DEFAULT_IGNORE_MESSAGES = [
|
|
1160
|
+
'Script error.',
|
|
1161
|
+
'Script error',
|
|
1162
|
+
/^ResizeObserver loop/,
|
|
1163
|
+
'Permission was denied',
|
|
1164
|
+
];
|
|
1158
1165
|
function truncate(s, maxLen) {
|
|
1159
1166
|
if (!s)
|
|
1160
1167
|
return s;
|
|
@@ -1167,6 +1174,17 @@ function sampleHit$1(sampleRate) {
|
|
|
1167
1174
|
return false;
|
|
1168
1175
|
return Math.random() < sampleRate;
|
|
1169
1176
|
}
|
|
1177
|
+
/** 检查消息是否应该被忽略 */
|
|
1178
|
+
function shouldIgnoreMessage(message, ignorePatterns) {
|
|
1179
|
+
if (!message || ignorePatterns.length === 0)
|
|
1180
|
+
return false;
|
|
1181
|
+
return ignorePatterns.some((pattern) => {
|
|
1182
|
+
if (typeof pattern === 'string') {
|
|
1183
|
+
return message === pattern || message.includes(pattern);
|
|
1184
|
+
}
|
|
1185
|
+
return pattern.test(message);
|
|
1186
|
+
});
|
|
1187
|
+
}
|
|
1170
1188
|
function getMpPagePath() {
|
|
1171
1189
|
try {
|
|
1172
1190
|
const pages = globalThis.getCurrentPages?.();
|
|
@@ -1261,6 +1279,9 @@ function installMiniProgramErrorMonitor(report, options) {
|
|
|
1261
1279
|
if (!sampleHit$1(options.sampleRate))
|
|
1262
1280
|
return;
|
|
1263
1281
|
const e = normalizeErrorLike(msg, options.maxTextLength);
|
|
1282
|
+
// 检查是否应该忽略此错误
|
|
1283
|
+
if (shouldIgnoreMessage(e.message, options.ignoreMessages))
|
|
1284
|
+
return;
|
|
1264
1285
|
const payload = {
|
|
1265
1286
|
pagePath: getMpPagePath(),
|
|
1266
1287
|
source: 'wx.onError',
|
|
@@ -1288,6 +1309,9 @@ function installMiniProgramErrorMonitor(report, options) {
|
|
|
1288
1309
|
if (!sampleHit$1(options.sampleRate))
|
|
1289
1310
|
return;
|
|
1290
1311
|
const e = normalizeErrorLike(res?.reason, options.maxTextLength);
|
|
1312
|
+
// 检查是否应该忽略此错误
|
|
1313
|
+
if (shouldIgnoreMessage(e.message, options.ignoreMessages))
|
|
1314
|
+
return;
|
|
1291
1315
|
const payload = {
|
|
1292
1316
|
pagePath: getMpPagePath(),
|
|
1293
1317
|
source: 'wx.onUnhandledRejection',
|
|
@@ -1319,15 +1343,18 @@ function installMiniProgramErrorMonitor(report, options) {
|
|
|
1319
1343
|
try {
|
|
1320
1344
|
if (sampleHit$1(options.sampleRate)) {
|
|
1321
1345
|
const e = normalizeErrorLike(args?.[0], options.maxTextLength);
|
|
1322
|
-
|
|
1323
|
-
|
|
1324
|
-
|
|
1325
|
-
|
|
1326
|
-
|
|
1327
|
-
|
|
1328
|
-
|
|
1329
|
-
|
|
1330
|
-
|
|
1346
|
+
// 检查是否应该忽略此错误
|
|
1347
|
+
if (!shouldIgnoreMessage(e.message, options.ignoreMessages)) {
|
|
1348
|
+
const payload = {
|
|
1349
|
+
pagePath: getMpPagePath(),
|
|
1350
|
+
source: 'App.onError',
|
|
1351
|
+
message: e.message,
|
|
1352
|
+
errorName: e.name,
|
|
1353
|
+
stack: e.stack,
|
|
1354
|
+
};
|
|
1355
|
+
if (shouldReport(buildErrorKey(options.reportType, payload)))
|
|
1356
|
+
report(options.reportType, payload);
|
|
1357
|
+
}
|
|
1331
1358
|
}
|
|
1332
1359
|
}
|
|
1333
1360
|
catch {
|
|
@@ -1343,15 +1370,18 @@ function installMiniProgramErrorMonitor(report, options) {
|
|
|
1343
1370
|
if (sampleHit$1(options.sampleRate)) {
|
|
1344
1371
|
const reason = args?.[0]?.reason ?? args?.[0];
|
|
1345
1372
|
const e = normalizeErrorLike(reason, options.maxTextLength);
|
|
1346
|
-
|
|
1347
|
-
|
|
1348
|
-
|
|
1349
|
-
|
|
1350
|
-
|
|
1351
|
-
|
|
1352
|
-
|
|
1353
|
-
|
|
1354
|
-
|
|
1373
|
+
// 检查是否应该忽略此错误
|
|
1374
|
+
if (!shouldIgnoreMessage(e.message, options.ignoreMessages)) {
|
|
1375
|
+
const payload = {
|
|
1376
|
+
pagePath: getMpPagePath(),
|
|
1377
|
+
source: 'App.onUnhandledRejection',
|
|
1378
|
+
message: e.message,
|
|
1379
|
+
errorName: e.name,
|
|
1380
|
+
stack: e.stack,
|
|
1381
|
+
};
|
|
1382
|
+
if (shouldReport(buildErrorKey(options.reportType, payload)))
|
|
1383
|
+
report(options.reportType, payload);
|
|
1384
|
+
}
|
|
1355
1385
|
}
|
|
1356
1386
|
}
|
|
1357
1387
|
catch {
|
|
@@ -1382,6 +1412,7 @@ function installMiniErrorMonitor(report, opts = {}) {
|
|
|
1382
1412
|
maxTextLength: raw.maxTextLength ?? DEFAULT_MAX_TEXT,
|
|
1383
1413
|
dedupeWindowMs: raw.dedupeWindowMs ?? DEFAULT_DEDUPE_WINDOW_MS,
|
|
1384
1414
|
dedupeMaxKeys: raw.dedupeMaxKeys ?? DEFAULT_DEDUPE_MAX_KEYS,
|
|
1415
|
+
ignoreMessages: raw.ignoreMessages ?? DEFAULT_IGNORE_MESSAGES,
|
|
1385
1416
|
};
|
|
1386
1417
|
installMiniProgramErrorMonitor(report, options);
|
|
1387
1418
|
}
|
package/dist/types.d.ts
CHANGED
|
@@ -219,7 +219,7 @@ export interface ErrorMonitorOptions {
|
|
|
219
219
|
/**
|
|
220
220
|
* 错误去重窗口(ms)
|
|
221
221
|
* - 目的:避免同一错误在短时间内频繁触发导致重复上报
|
|
222
|
-
* -
|
|
222
|
+
* - 行为:同一"错误签名"在窗口内只会上报一次
|
|
223
223
|
* - 默认:3000
|
|
224
224
|
*/
|
|
225
225
|
dedupeWindowMs?: number;
|
|
@@ -228,6 +228,12 @@ export interface ErrorMonitorOptions {
|
|
|
228
228
|
* - 默认:200
|
|
229
229
|
*/
|
|
230
230
|
dedupeMaxKeys?: number;
|
|
231
|
+
/**
|
|
232
|
+
* 忽略的错误信息(字符串或正则)
|
|
233
|
+
* - 匹配 message 字段,命中则不上报
|
|
234
|
+
* - 默认忽略:['Script error.', 'Script error', 'ResizeObserver loop']
|
|
235
|
+
*/
|
|
236
|
+
ignoreMessages?: Array<string | RegExp>;
|
|
231
237
|
}
|
|
232
238
|
export interface PerformanceMonitorOptions {
|
|
233
239
|
/** 是否开启,默认 true */
|
package/dist/types.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,aAAa,GAAG,MAAM,GAAG,MAAM,GAAG,OAAO,GAAG,IAAI,CAAC;AAC7D,MAAM,MAAM,SAAS,GAAG,aAAa,GAAG,SAAS,EAAE,GAAG;IAAE,CAAC,CAAC,EAAE,MAAM,GAAG,SAAS,CAAA;CAAE,CAAC;AAEjF;;;;;GAKG;AACH,MAAM,MAAM,cAAc,GAAG,aAAa,GAAG,SAAS,GAAG,MAAM,CAAC;AAEhE,sCAAsC;AACtC,MAAM,MAAM,UAAU,GAAG,MAAM,CAAC,MAAM,EAAE,cAAc,CAAC,CAAC;AAExD,MAAM,MAAM,UAAU,GAAG,UAAU,CAAC;AAEpC,MAAM,MAAM,OAAO,GAAG,SAAS,GAAG,aAAa,CAAC;AAEhD,MAAM,WAAW,qBAAqB;IACpC,oDAAoD;IACpD,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,kBAAkB;IAClB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,eAAe;IACf,WAAW,CAAC,EAAE,MAAM,CAAC;CACtB;AAED,MAAM,WAAW,YAAY;IAC3B,8BAA8B;IAC9B,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,wBAAwB;IACxB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB;;;;;OAKG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1
|
+
{"version":3,"file":"errorMonitor.d.ts","sourceRoot":"","sources":["../../src/web/errorMonitor.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,mBAAmB,EAAE,UAAU,EAAE,MAAM,UAAU,CAAC;AAGhE,KAAK,QAAQ,GAAG,CAAC,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,UAAU,KAAK,IAAI,CAAC;AAmMzD,wBAAgB,sBAAsB,CAAC,MAAM,EAAE,QAAQ,EAAE,IAAI,GAAE,OAAO,GAAG,mBAAmB,GAAG,SAAc,GAAG,IAAI,CAiBnH"}
|
package/dist/web.esm.js
CHANGED
|
@@ -1190,6 +1190,13 @@ function installWebRequestMonitor(report, opts = {}) {
|
|
|
1190
1190
|
const DEFAULT_MAX_TEXT = 4000;
|
|
1191
1191
|
const DEFAULT_DEDUPE_WINDOW_MS = 3000;
|
|
1192
1192
|
const DEFAULT_DEDUPE_MAX_KEYS = 200;
|
|
1193
|
+
/** 默认忽略的无意义错误信息 */
|
|
1194
|
+
const DEFAULT_IGNORE_MESSAGES = [
|
|
1195
|
+
'Script error.',
|
|
1196
|
+
'Script error',
|
|
1197
|
+
/^ResizeObserver loop/,
|
|
1198
|
+
'Permission was denied',
|
|
1199
|
+
];
|
|
1193
1200
|
function truncate$2(s, maxLen) {
|
|
1194
1201
|
if (!s)
|
|
1195
1202
|
return s;
|
|
@@ -1202,6 +1209,17 @@ function sampleHit$1(sampleRate) {
|
|
|
1202
1209
|
return false;
|
|
1203
1210
|
return Math.random() < sampleRate;
|
|
1204
1211
|
}
|
|
1212
|
+
/** 检查消息是否应该被忽略 */
|
|
1213
|
+
function shouldIgnoreMessage(message, ignorePatterns) {
|
|
1214
|
+
if (!message || ignorePatterns.length === 0)
|
|
1215
|
+
return false;
|
|
1216
|
+
return ignorePatterns.some((pattern) => {
|
|
1217
|
+
if (typeof pattern === 'string') {
|
|
1218
|
+
return message === pattern || message.includes(pattern);
|
|
1219
|
+
}
|
|
1220
|
+
return pattern.test(message);
|
|
1221
|
+
});
|
|
1222
|
+
}
|
|
1205
1223
|
function getPagePath$1() {
|
|
1206
1224
|
try {
|
|
1207
1225
|
if (typeof window === 'undefined')
|
|
@@ -1297,6 +1315,9 @@ function installBrowserErrorMonitor(report, options) {
|
|
|
1297
1315
|
};
|
|
1298
1316
|
if (event && typeof event === 'object' && 'message' in event) {
|
|
1299
1317
|
payload.message = truncate$2(String(event.message ?? ''), options.maxTextLength);
|
|
1318
|
+
// 检查是否应该忽略此错误
|
|
1319
|
+
if (shouldIgnoreMessage(String(event.message ?? ''), options.ignoreMessages))
|
|
1320
|
+
return;
|
|
1300
1321
|
payload.filename = truncate$2(String(event.filename ?? ''), 500);
|
|
1301
1322
|
payload.lineno = typeof event.lineno === 'number' ? event.lineno : undefined;
|
|
1302
1323
|
payload.colno = typeof event.colno === 'number' ? event.colno : undefined;
|
|
@@ -1335,6 +1356,9 @@ function installBrowserErrorMonitor(report, options) {
|
|
|
1335
1356
|
return;
|
|
1336
1357
|
const reason = event?.reason;
|
|
1337
1358
|
const e = normalizeErrorLike(reason, options.maxTextLength);
|
|
1359
|
+
// 检查是否应该忽略此错误
|
|
1360
|
+
if (shouldIgnoreMessage(e.message, options.ignoreMessages))
|
|
1361
|
+
return;
|
|
1338
1362
|
const payload = {
|
|
1339
1363
|
pagePath: getPagePath$1(),
|
|
1340
1364
|
source: 'unhandledrejection',
|
|
@@ -1364,6 +1388,7 @@ function installWebErrorMonitor(report, opts = {}) {
|
|
|
1364
1388
|
maxTextLength: raw.maxTextLength ?? DEFAULT_MAX_TEXT,
|
|
1365
1389
|
dedupeWindowMs: raw.dedupeWindowMs ?? DEFAULT_DEDUPE_WINDOW_MS,
|
|
1366
1390
|
dedupeMaxKeys: raw.dedupeMaxKeys ?? DEFAULT_DEDUPE_MAX_KEYS,
|
|
1391
|
+
ignoreMessages: raw.ignoreMessages ?? DEFAULT_IGNORE_MESSAGES,
|
|
1367
1392
|
};
|
|
1368
1393
|
installBrowserErrorMonitor(report, options);
|
|
1369
1394
|
}
|
package/dist/web.js
CHANGED
|
@@ -1213,6 +1213,13 @@ function installWebRequestMonitor(report, opts = {}) {
|
|
|
1213
1213
|
const DEFAULT_MAX_TEXT = 4000;
|
|
1214
1214
|
const DEFAULT_DEDUPE_WINDOW_MS = 3000;
|
|
1215
1215
|
const DEFAULT_DEDUPE_MAX_KEYS = 200;
|
|
1216
|
+
/** 默认忽略的无意义错误信息 */
|
|
1217
|
+
const DEFAULT_IGNORE_MESSAGES = [
|
|
1218
|
+
'Script error.',
|
|
1219
|
+
'Script error',
|
|
1220
|
+
/^ResizeObserver loop/,
|
|
1221
|
+
'Permission was denied',
|
|
1222
|
+
];
|
|
1216
1223
|
function truncate$2(s, maxLen) {
|
|
1217
1224
|
if (!s)
|
|
1218
1225
|
return s;
|
|
@@ -1225,6 +1232,17 @@ function sampleHit$1(sampleRate) {
|
|
|
1225
1232
|
return false;
|
|
1226
1233
|
return Math.random() < sampleRate;
|
|
1227
1234
|
}
|
|
1235
|
+
/** 检查消息是否应该被忽略 */
|
|
1236
|
+
function shouldIgnoreMessage(message, ignorePatterns) {
|
|
1237
|
+
if (!message || ignorePatterns.length === 0)
|
|
1238
|
+
return false;
|
|
1239
|
+
return ignorePatterns.some((pattern) => {
|
|
1240
|
+
if (typeof pattern === 'string') {
|
|
1241
|
+
return message === pattern || message.includes(pattern);
|
|
1242
|
+
}
|
|
1243
|
+
return pattern.test(message);
|
|
1244
|
+
});
|
|
1245
|
+
}
|
|
1228
1246
|
function getPagePath$1() {
|
|
1229
1247
|
try {
|
|
1230
1248
|
if (typeof window === 'undefined')
|
|
@@ -1320,6 +1338,9 @@ function installBrowserErrorMonitor(report, options) {
|
|
|
1320
1338
|
};
|
|
1321
1339
|
if (event && typeof event === 'object' && 'message' in event) {
|
|
1322
1340
|
payload.message = truncate$2(String(event.message ?? ''), options.maxTextLength);
|
|
1341
|
+
// 检查是否应该忽略此错误
|
|
1342
|
+
if (shouldIgnoreMessage(String(event.message ?? ''), options.ignoreMessages))
|
|
1343
|
+
return;
|
|
1323
1344
|
payload.filename = truncate$2(String(event.filename ?? ''), 500);
|
|
1324
1345
|
payload.lineno = typeof event.lineno === 'number' ? event.lineno : undefined;
|
|
1325
1346
|
payload.colno = typeof event.colno === 'number' ? event.colno : undefined;
|
|
@@ -1358,6 +1379,9 @@ function installBrowserErrorMonitor(report, options) {
|
|
|
1358
1379
|
return;
|
|
1359
1380
|
const reason = event?.reason;
|
|
1360
1381
|
const e = normalizeErrorLike(reason, options.maxTextLength);
|
|
1382
|
+
// 检查是否应该忽略此错误
|
|
1383
|
+
if (shouldIgnoreMessage(e.message, options.ignoreMessages))
|
|
1384
|
+
return;
|
|
1361
1385
|
const payload = {
|
|
1362
1386
|
pagePath: getPagePath$1(),
|
|
1363
1387
|
source: 'unhandledrejection',
|
|
@@ -1387,6 +1411,7 @@ function installWebErrorMonitor(report, opts = {}) {
|
|
|
1387
1411
|
maxTextLength: raw.maxTextLength ?? DEFAULT_MAX_TEXT,
|
|
1388
1412
|
dedupeWindowMs: raw.dedupeWindowMs ?? DEFAULT_DEDUPE_WINDOW_MS,
|
|
1389
1413
|
dedupeMaxKeys: raw.dedupeMaxKeys ?? DEFAULT_DEDUPE_MAX_KEYS,
|
|
1414
|
+
ignoreMessages: raw.ignoreMessages ?? DEFAULT_IGNORE_MESSAGES,
|
|
1390
1415
|
};
|
|
1391
1416
|
installBrowserErrorMonitor(report, options);
|
|
1392
1417
|
}
|