|
340 | 340 | this.maxScrollDepth = Math.max(this.maxScrollDepth, scrollPercent); |
341 | 341 | } |
342 | 342 |
|
343 | | - async send(event) { |
| 343 | + send(event) { |
344 | 344 | const eventData = |
345 | 345 | event.type === 'track' && event.payload ? event.payload : event; |
346 | 346 |
|
347 | 347 | if ( |
348 | 348 | this.options.disabled || |
| 349 | + !this.options.clientId || |
349 | 350 | (this.options.filter && !this.options.filter(eventData)) |
350 | 351 | ) { |
351 | 352 | return Promise.resolve(); |
|
419 | 420 | this.send(originalEvent); |
420 | 421 | } |
421 | 422 | } else { |
| 423 | + // |
422 | 424 | } |
423 | 425 |
|
424 | 426 | return null; |
425 | 427 | } |
426 | 428 | } |
427 | 429 |
|
428 | | - async sendBatchBeacon(events) { |
429 | | - if (this.isServer() || !navigator.sendBeacon) { |
| 430 | + sendBatchBeacon(events) { |
| 431 | + if (this.isServer() || !navigator.sendBeacon || !this.options.clientId) { |
430 | 432 | return null; |
431 | 433 | } |
432 | 434 |
|
|
445 | 447 | if (success) { |
446 | 448 | return { success: true }; |
447 | 449 | } |
448 | | - } catch (_e) {} |
| 450 | + } catch (_e) { |
| 451 | + // |
| 452 | + } |
449 | 453 |
|
450 | 454 | return null; |
451 | 455 | } |
|
525 | 529 | return this.send(payload); |
526 | 530 | } |
527 | 531 |
|
528 | | - async sendBeacon(event) { |
| 532 | + sendBeacon(event) { |
529 | 533 | if (this.isServer()) { |
530 | 534 | return null; |
531 | 535 | } |
|
536 | 540 |
|
537 | 541 | if ( |
538 | 542 | this.options.disabled || |
| 543 | + !this.options.clientId || |
539 | 544 | (this.options.filter && !this.options.filter(eventData)) |
540 | 545 | ) { |
541 | 546 | return null; |
|
565 | 570 | if (success) { |
566 | 571 | return { success: true }; |
567 | 572 | } |
568 | | - } catch (_e) {} |
| 573 | + } catch (_e) { |
| 574 | + // |
| 575 | + } |
569 | 576 | } |
570 | 577 |
|
571 | 578 | return null; |
|
720 | 727 | if (linkUrl.origin === window.location.origin) { |
721 | 728 | this.isInternalNavigation = true; |
722 | 729 | } |
723 | | - } catch (_err) {} |
| 730 | + } catch (_err) { |
| 731 | + // |
| 732 | + } |
724 | 733 | } |
725 | 734 | }); |
726 | 735 |
|
|
873 | 882 | observer.observe({ type, buffered: true }); |
874 | 883 | this.webVitalObservers.push(observer); |
875 | 884 | } |
876 | | - } catch (_e) {} |
| 885 | + } catch (_e) { |
| 886 | + // |
| 887 | + } |
877 | 888 | }; |
878 | 889 |
|
879 | 890 | observe('paint', (entries) => { |
|
933 | 944 | }); |
934 | 945 |
|
935 | 946 | this.webVitalsReportTimeoutId = setTimeout(report, 10_000); |
936 | | - } catch (_e) {} |
| 947 | + } catch (_e) { |
| 948 | + // |
| 949 | + } |
937 | 950 | } |
938 | 951 |
|
939 | 952 | getConnectionInfo() { |
|
1086 | 1099 | if (beaconResult) { |
1087 | 1100 | return beaconResult; |
1088 | 1101 | } |
1089 | | - } catch (_e) {} |
| 1102 | + } catch (_e) { |
| 1103 | + // |
| 1104 | + } |
1090 | 1105 |
|
1091 | 1106 | return this.send(errorEvent); |
1092 | 1107 | } |
|
1125 | 1140 | if (beaconResult) { |
1126 | 1141 | return beaconResult; |
1127 | 1142 | } |
1128 | | - } catch (_e) {} |
| 1143 | + } catch (_e) { |
| 1144 | + // |
| 1145 | + } |
1129 | 1146 |
|
1130 | 1147 | return this.send(webVitalsEvent); |
1131 | 1148 | } |
|
1189 | 1206 | r.getAttribute('alt'), |
1190 | 1207 | }); |
1191 | 1208 | } |
1192 | | - } catch (_e) {} |
| 1209 | + } catch (_e) { |
| 1210 | + // |
| 1211 | + } |
1193 | 1212 | } |
1194 | 1213 | } |
1195 | 1214 | }); |
|
1349 | 1368 | document.currentScript || |
1350 | 1369 | (() => { |
1351 | 1370 | const scripts = document.getElementsByTagName('script'); |
1352 | | - // biome-ignore lint/style/useAt: not supported in all target browsers |
1353 | | - return scripts[scripts.length - 1]; |
| 1371 | + return scripts.at(-1); |
1354 | 1372 | })(); |
1355 | 1373 |
|
1356 | 1374 | function getConfig() { |
|
1397 | 1415 | urlParams[key] = value; |
1398 | 1416 | } |
1399 | 1417 | }); |
1400 | | - } catch (_e) {} |
| 1418 | + } catch (_e) { |
| 1419 | + // |
| 1420 | + } |
1401 | 1421 |
|
1402 | 1422 | const config = { |
1403 | 1423 | ...globalConfig, |
|
0 commit comments