fix: sentry issues (#389)

This commit is contained in:
Razboy20
2024-10-23 14:15:47 -05:00
committed by GitHub
parent d3577358d0
commit 2d0804f90e
4 changed files with 44 additions and 20 deletions

View File

@@ -2,6 +2,7 @@
interface ImportMetaEnv {
readonly VITE_PACKAGE_VERSION: string;
readonly VITE_SENTRY_ENVIRONMENT: string;
readonly VITE_BETA_BUILD?: 'true';
}

View File

@@ -10,7 +10,7 @@
"dev": "vite",
"build": "tsc && vite build",
"build:watch": "NODE_ENV='development' vite build --mode development -w",
"zip": "pnpm build && pnpm gulp zip",
"zip": "PROD=true pnpm build && pnpm gulp zip",
"prettier": "prettier src --check",
"prettier:fix": "prettier src --write",
"lint": "eslint src --ext ts,tsx --report-unused-disable-directives",

View File

@@ -65,8 +65,9 @@ export default function SentryProvider({
integrations,
transport: makeFetchTransport,
stackParser: defaultStackParser,
// debug: true,
debug: import.meta.env.DEV,
release: import.meta.env.VITE_PACKAGE_VERSION,
environment: import.meta.env.VITE_SENTRY_ENVIRONMENT,
};
let client: Client;

View File

@@ -22,6 +22,13 @@ if (isBeta) {
process.env.VITE_BETA_BUILD = 'true';
}
process.env.VITE_PACKAGE_VERSION = packageJson.version;
if (process.env.PROD) {
process.env.VITE_SENTRY_ENVIRONMENT = 'production';
} else if (isBeta) {
process.env.VITE_SENTRY_ENVIRONMENT = 'beta';
} else {
process.env.VITE_SENTRY_ENVIRONMENT = 'development';
}
export const preambleCode = `
import RefreshRuntime from "__BASE__@react-refresh"
@@ -89,10 +96,13 @@ export default defineConfig({
apply: 'serve',
transform(code, id) {
if (id.endsWith('.tsx') || id.endsWith('.ts') || id.endsWith('?url')) {
return code.replace(
return {
code: code.replace(
/(['"])(\/public\/.*?)(['"])/g,
(_, quote1, path, quote2) => `chrome.runtime.getURL(${quote1}${path}${quote2})`
);
),
map: null,
};
}
},
},
@@ -101,10 +111,13 @@ export default defineConfig({
apply: 'build',
transform(code, id) {
if (id.endsWith('.tsx') || id.endsWith('.ts') || id.endsWith('?url')) {
return code.replace(
return {
code: code.replace(
/(['"])(__VITE_ASSET__.*?__)(['"])/g,
(_, quote1, path, quote2) => `chrome.runtime.getURL(${quote1}${path}${quote2})`
);
),
map: null,
};
}
},
},
@@ -114,13 +127,16 @@ export default defineConfig({
enforce: 'post',
transform(code, id) {
if (process.env.NODE_ENV === 'development' && (id.endsWith('.css') || id.endsWith('.scss'))) {
return code.replace(
return {
code: code.replace(
/url\((.*?)\)/g,
(_, path) =>
`url(\\"" + chrome.runtime.getURL(${path
.replaceAll(`\\"`, `"`)
.replace(/public\//, '')}) + "\\")`
);
),
map: null,
};
}
},
},
@@ -133,9 +149,8 @@ export default defineConfig({
/(__VITE_ASSET__.*?__)/g,
(_, path) => `chrome-extension://__MSG_@@extension_id__${path}`
);
return transformedCode;
return { code: transformedCode, map: null };
}
return code;
},
},
renameFile('src/pages/debug/index.html', 'debug.html'),
@@ -143,7 +158,7 @@ export default defineConfig({
renameFile('src/pages/calendar/index.html', 'calendar.html'),
renameFile('src/pages/report/index.html', 'report.html'),
vitePluginRunCommandOnDemand({
afterServerStart: 'pnpm gulp forceDisableUseDynamicUrl',
// afterServerStart: 'pnpm gulp forceDisableUseDynamicUrl',
closeBundle: 'pnpm gulp forceDisableUseDynamicUrl',
}),
],
@@ -206,4 +221,11 @@ export default defineConfig({
provider: 'v8',
},
},
css: {
preprocessorOptions: {
scss: {
api: 'modern-compiler',
},
},
},
});