fix: sentry issues (#389)
This commit is contained in:
1
@types/vite-env.d.ts
vendored
1
@types/vite-env.d.ts
vendored
@@ -2,6 +2,7 @@
|
|||||||
|
|
||||||
interface ImportMetaEnv {
|
interface ImportMetaEnv {
|
||||||
readonly VITE_PACKAGE_VERSION: string;
|
readonly VITE_PACKAGE_VERSION: string;
|
||||||
|
readonly VITE_SENTRY_ENVIRONMENT: string;
|
||||||
readonly VITE_BETA_BUILD?: 'true';
|
readonly VITE_BETA_BUILD?: 'true';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -10,7 +10,7 @@
|
|||||||
"dev": "vite",
|
"dev": "vite",
|
||||||
"build": "tsc && vite build",
|
"build": "tsc && vite build",
|
||||||
"build:watch": "NODE_ENV='development' vite build --mode development -w",
|
"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": "prettier src --check",
|
||||||
"prettier:fix": "prettier src --write",
|
"prettier:fix": "prettier src --write",
|
||||||
"lint": "eslint src --ext ts,tsx --report-unused-disable-directives",
|
"lint": "eslint src --ext ts,tsx --report-unused-disable-directives",
|
||||||
|
|||||||
@@ -65,8 +65,9 @@ export default function SentryProvider({
|
|||||||
integrations,
|
integrations,
|
||||||
transport: makeFetchTransport,
|
transport: makeFetchTransport,
|
||||||
stackParser: defaultStackParser,
|
stackParser: defaultStackParser,
|
||||||
// debug: true,
|
debug: import.meta.env.DEV,
|
||||||
release: import.meta.env.VITE_PACKAGE_VERSION,
|
release: import.meta.env.VITE_PACKAGE_VERSION,
|
||||||
|
environment: import.meta.env.VITE_SENTRY_ENVIRONMENT,
|
||||||
};
|
};
|
||||||
|
|
||||||
let client: Client;
|
let client: Client;
|
||||||
|
|||||||
@@ -22,6 +22,13 @@ if (isBeta) {
|
|||||||
process.env.VITE_BETA_BUILD = 'true';
|
process.env.VITE_BETA_BUILD = 'true';
|
||||||
}
|
}
|
||||||
process.env.VITE_PACKAGE_VERSION = packageJson.version;
|
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 = `
|
export const preambleCode = `
|
||||||
import RefreshRuntime from "__BASE__@react-refresh"
|
import RefreshRuntime from "__BASE__@react-refresh"
|
||||||
@@ -89,10 +96,13 @@ export default defineConfig({
|
|||||||
apply: 'serve',
|
apply: 'serve',
|
||||||
transform(code, id) {
|
transform(code, id) {
|
||||||
if (id.endsWith('.tsx') || id.endsWith('.ts') || id.endsWith('?url')) {
|
if (id.endsWith('.tsx') || id.endsWith('.ts') || id.endsWith('?url')) {
|
||||||
return code.replace(
|
return {
|
||||||
/(['"])(\/public\/.*?)(['"])/g,
|
code: code.replace(
|
||||||
(_, quote1, path, quote2) => `chrome.runtime.getURL(${quote1}${path}${quote2})`
|
/(['"])(\/public\/.*?)(['"])/g,
|
||||||
);
|
(_, quote1, path, quote2) => `chrome.runtime.getURL(${quote1}${path}${quote2})`
|
||||||
|
),
|
||||||
|
map: null,
|
||||||
|
};
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
@@ -101,10 +111,13 @@ export default defineConfig({
|
|||||||
apply: 'build',
|
apply: 'build',
|
||||||
transform(code, id) {
|
transform(code, id) {
|
||||||
if (id.endsWith('.tsx') || id.endsWith('.ts') || id.endsWith('?url')) {
|
if (id.endsWith('.tsx') || id.endsWith('.ts') || id.endsWith('?url')) {
|
||||||
return code.replace(
|
return {
|
||||||
/(['"])(__VITE_ASSET__.*?__)(['"])/g,
|
code: code.replace(
|
||||||
(_, quote1, path, quote2) => `chrome.runtime.getURL(${quote1}${path}${quote2})`
|
/(['"])(__VITE_ASSET__.*?__)(['"])/g,
|
||||||
);
|
(_, quote1, path, quote2) => `chrome.runtime.getURL(${quote1}${path}${quote2})`
|
||||||
|
),
|
||||||
|
map: null,
|
||||||
|
};
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
@@ -114,13 +127,16 @@ export default defineConfig({
|
|||||||
enforce: 'post',
|
enforce: 'post',
|
||||||
transform(code, id) {
|
transform(code, id) {
|
||||||
if (process.env.NODE_ENV === 'development' && (id.endsWith('.css') || id.endsWith('.scss'))) {
|
if (process.env.NODE_ENV === 'development' && (id.endsWith('.css') || id.endsWith('.scss'))) {
|
||||||
return code.replace(
|
return {
|
||||||
/url\((.*?)\)/g,
|
code: code.replace(
|
||||||
(_, path) =>
|
/url\((.*?)\)/g,
|
||||||
`url(\\"" + chrome.runtime.getURL(${path
|
(_, path) =>
|
||||||
.replaceAll(`\\"`, `"`)
|
`url(\\"" + chrome.runtime.getURL(${path
|
||||||
.replace(/public\//, '')}) + "\\")`
|
.replaceAll(`\\"`, `"`)
|
||||||
);
|
.replace(/public\//, '')}) + "\\")`
|
||||||
|
),
|
||||||
|
map: null,
|
||||||
|
};
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
@@ -133,9 +149,8 @@ export default defineConfig({
|
|||||||
/(__VITE_ASSET__.*?__)/g,
|
/(__VITE_ASSET__.*?__)/g,
|
||||||
(_, path) => `chrome-extension://__MSG_@@extension_id__${path}`
|
(_, path) => `chrome-extension://__MSG_@@extension_id__${path}`
|
||||||
);
|
);
|
||||||
return transformedCode;
|
return { code: transformedCode, map: null };
|
||||||
}
|
}
|
||||||
return code;
|
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
renameFile('src/pages/debug/index.html', 'debug.html'),
|
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/calendar/index.html', 'calendar.html'),
|
||||||
renameFile('src/pages/report/index.html', 'report.html'),
|
renameFile('src/pages/report/index.html', 'report.html'),
|
||||||
vitePluginRunCommandOnDemand({
|
vitePluginRunCommandOnDemand({
|
||||||
afterServerStart: 'pnpm gulp forceDisableUseDynamicUrl',
|
// afterServerStart: 'pnpm gulp forceDisableUseDynamicUrl',
|
||||||
closeBundle: 'pnpm gulp forceDisableUseDynamicUrl',
|
closeBundle: 'pnpm gulp forceDisableUseDynamicUrl',
|
||||||
}),
|
}),
|
||||||
],
|
],
|
||||||
@@ -206,4 +221,11 @@ export default defineConfig({
|
|||||||
provider: 'v8',
|
provider: 'v8',
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
css: {
|
||||||
|
preprocessorOptions: {
|
||||||
|
scss: {
|
||||||
|
api: 'modern-compiler',
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
});
|
});
|
||||||
|
|||||||
Reference in New Issue
Block a user