mirror of
https://github.com/toeverything/AFFiNE.git
synced 2024-11-27 15:06:12 +03:00
fix: SHOULD_REPORT_TRACE condition (#4273)
Co-authored-by: X1a0t <405028157@qq.com>
This commit is contained in:
parent
a25a31c105
commit
892cae5599
@ -349,10 +349,12 @@ export const createConfiguration: (
|
||||
'process.env': JSON.stringify({}),
|
||||
'process.env.COVERAGE': JSON.stringify(!!buildFlags.coverage),
|
||||
'process.env.NODE_ENV': JSON.stringify(buildFlags.mode),
|
||||
'process.env.SHOULD_REPORT_TRACE': `${Boolean(
|
||||
process.env.SHOULD_REPORT_TRACE
|
||||
)}`,
|
||||
'process.env.TRACE_REPORT_ENDPOINT': `"${process.env.TRACE_REPORT_ENDPOINT}"`,
|
||||
'process.env.SHOULD_REPORT_TRACE': JSON.stringify(
|
||||
Boolean(process.env.SHOULD_REPORT_TRACE === 'true')
|
||||
),
|
||||
'process.env.TRACE_REPORT_ENDPOINT': JSON.stringify(
|
||||
process.env.TRACE_REPORT_ENDPOINT
|
||||
),
|
||||
runtimeConfig: JSON.stringify(runtimeConfig),
|
||||
}),
|
||||
new CopyPlugin({
|
||||
|
@ -24,7 +24,7 @@ export default defineConfig({
|
||||
'process.env': {},
|
||||
'process.env.COVERAGE': JSON.stringify(!!process.env.COVERAGE),
|
||||
'process.env.SHOULD_REPORT_TRACE': `${Boolean(
|
||||
process.env.SHOULD_REPORT_TRACE
|
||||
process.env.SHOULD_REPORT_TRACE === 'true'
|
||||
)}`,
|
||||
'process.env.TRACE_REPORT_ENDPOINT': `"${process.env.TRACE_REPORT_ENDPOINT}"`,
|
||||
runtimeConfig: getRuntimeConfig({
|
||||
|
@ -47,7 +47,7 @@ export default {
|
||||
'process.env': {},
|
||||
'process.env.COVERAGE': JSON.stringify(!!process.env.COVERAGE),
|
||||
'process.env.SHOULD_REPORT_TRACE': `${Boolean(
|
||||
process.env.SHOULD_REPORT_TRACE
|
||||
process.env.SHOULD_REPORT_TRACE === 'true'
|
||||
)}`,
|
||||
'process.env.TRACE_REPORT_ENDPOINT': `"${process.env.TRACE_REPORT_ENDPOINT}"`,
|
||||
runtimeConfig: getRuntimeConfig({
|
||||
|
@ -49,8 +49,7 @@ export function generateRandUTF16Chars(bytes: number) {
|
||||
}
|
||||
|
||||
export class TraceReporter {
|
||||
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
||||
static traceReportEndpoint = process.env.TRACE_REPORT_ENDPOINT!;
|
||||
static traceReportEndpoint = process.env.TRACE_REPORT_ENDPOINT;
|
||||
static shouldReportTrace = process.env.SHOULD_REPORT_TRACE;
|
||||
|
||||
private spansCache = new Array<TraceSpan>();
|
||||
@ -108,6 +107,10 @@ export class TraceReporter {
|
||||
}
|
||||
|
||||
public static reportToTraceEndpoint(payload: string): void {
|
||||
if (!TraceReporter.traceReportEndpoint) {
|
||||
console.warn('No trace report endpoint found!');
|
||||
return;
|
||||
}
|
||||
if (typeof navigator !== 'undefined') {
|
||||
navigator.sendBeacon(TraceReporter.traceReportEndpoint, payload);
|
||||
} else {
|
||||
@ -201,6 +204,6 @@ export class TraceReporter {
|
||||
};
|
||||
}
|
||||
|
||||
export const traceReporter = !process.env.SHOULD_REPORT_TRACE
|
||||
? null
|
||||
: TraceReporter.getInstance();
|
||||
export const traceReporter = process.env.SHOULD_REPORT_TRACE
|
||||
? TraceReporter.getInstance()
|
||||
: null;
|
||||
|
Loading…
Reference in New Issue
Block a user