@@ -6,6 +6,7 @@ import "tether-drop/dist/css/drop-theme-arrows.css";
66import "src/basscss.css" ;
77import "./style.css" ;
88import {
9+ Consent ,
910 CoverageStatus ,
1011 FileCoverageReport ,
1112 FileCoverageReportResponse ,
@@ -32,7 +33,7 @@ import {
3233 getConsent ,
3334} from "../common/fetchers" ;
3435import { print } from "src/utils" ;
35- import Sentry from "../../common/sentry" ;
36+ import { initSentry } from "../../common/sentry" ;
3637
3738const globals : {
3839 coverageReport ?: FileCoverageReport ;
@@ -44,9 +45,16 @@ const globals: {
4445 prompt ?: HTMLElement ;
4546} = { } ;
4647
47- init ( ) ;
48+ let Sentry : ReturnType < typeof initSentry > = undefined ;
49+ let consent : Consent = "none" ;
50+
51+ await init ( ) ;
52+
53+ async function init ( ) : Promise < void > {
54+ consent = await getConsent ( ) ;
55+
56+ Sentry = initSentry ( consent ) ;
4857
49- function init ( ) : Promise < void > {
5058 // this event discovered by "reverse-engineering GitHub"
5159 // https://github.com/refined-github/refined-github/blob/main/contributing.md#reverse-engineering-github
5260 // TODO: this event is not fired when navigating using the browser's back and forward buttons
@@ -60,7 +68,8 @@ function init(): Promise<void> {
6068
6169async function main ( ) : Promise < void > {
6270 try {
63- if ( ! ( await getConsent ( ) ) ) {
71+ if ( consent === "none" ) {
72+ // No data consent, do nothing.
6473 return ;
6574 }
6675
@@ -72,7 +81,9 @@ async function main(): Promise<void> {
7281 globals . coverageButton = createCoverageButton ( ) ;
7382 await process ( urlMetadata ) ;
7483 } catch ( e ) {
75- Sentry . captureException ( e ) ;
84+ if ( Sentry ) {
85+ Sentry . captureException ( e ) ;
86+ }
7687 throw e ;
7788 }
7889}
0 commit comments