mirror of
https://github.com/movie-web/movie-web.git
synced 2024-11-11 05:15:08 +01:00
truncate stacktrace and remove hostname
This commit is contained in:
parent
bb192ee21f
commit
bd4378c056
@ -17,17 +17,20 @@ export type ProviderMetric = {
|
|||||||
embedId?: string;
|
embedId?: string;
|
||||||
errorMessage?: string;
|
errorMessage?: string;
|
||||||
fullError?: string;
|
fullError?: string;
|
||||||
hostname?: string;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
function getStackTrace(error: Error, lines: number) {
|
||||||
|
const topMessage = error.toString();
|
||||||
|
const stackTraceLines = (error.stack ?? "").split("\n", lines + 1);
|
||||||
|
stackTraceLines.pop();
|
||||||
|
return `${topMessage}\n\n${stackTraceLines.join("\n")}`;
|
||||||
|
}
|
||||||
|
|
||||||
export async function reportProviders(items: ProviderMetric[]): Promise<void> {
|
export async function reportProviders(items: ProviderMetric[]): Promise<void> {
|
||||||
return ofetch(metricsEndpoint, {
|
return ofetch(metricsEndpoint, {
|
||||||
method: "POST",
|
method: "POST",
|
||||||
body: {
|
body: {
|
||||||
items: items.map((v) => ({
|
items,
|
||||||
...v,
|
|
||||||
hostname: window.location.hostname,
|
|
||||||
})),
|
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@ -69,9 +72,7 @@ export function scrapeSegmentToProviderMetric(
|
|||||||
episodeId,
|
episodeId,
|
||||||
seasonId,
|
seasonId,
|
||||||
errorMessage: segment.reason ?? error?.message,
|
errorMessage: segment.reason ?? error?.message,
|
||||||
fullError: error
|
fullError: error ? getStackTrace(error, 5) : undefined,
|
||||||
? `${error.toString()}\n\n${error.stack ?? ""}`
|
|
||||||
: undefined,
|
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user