mirror of
https://github.com/movie-web/movie-web.git
synced 2024-11-11 03:15:07 +01:00
Merge pull request #828 from movie-web/track-usage-type
Add scrape-tool to reports
This commit is contained in:
commit
05c9ddf2c6
@ -3,7 +3,9 @@ import { nanoid } from "nanoid";
|
|||||||
import { ofetch } from "ofetch";
|
import { ofetch } from "ofetch";
|
||||||
import { useCallback } from "react";
|
import { useCallback } from "react";
|
||||||
|
|
||||||
|
import { isExtensionActiveCached } from "@/backend/extension/messaging";
|
||||||
import { ScrapingItems, ScrapingSegment } from "@/hooks/useProviderScrape";
|
import { ScrapingItems, ScrapingSegment } from "@/hooks/useProviderScrape";
|
||||||
|
import { useAuthStore } from "@/stores/auth";
|
||||||
import { PlayerMeta } from "@/stores/player/slices/source";
|
import { PlayerMeta } from "@/stores/player/slices/source";
|
||||||
|
|
||||||
// for anybody who cares - these are anonymous metrics.
|
// for anybody who cares - these are anonymous metrics.
|
||||||
@ -25,6 +27,15 @@ export type ProviderMetric = {
|
|||||||
fullError?: string;
|
fullError?: string;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
export type ScrapeTool = "default" | "custom-proxy" | "extension";
|
||||||
|
|
||||||
|
export function getScrapeTool(): ScrapeTool {
|
||||||
|
if (isExtensionActiveCached()) return "extension";
|
||||||
|
const hasProxySet = !!useAuthStore.getState().proxySet;
|
||||||
|
if (hasProxySet) return "custom-proxy";
|
||||||
|
return "default";
|
||||||
|
}
|
||||||
|
|
||||||
function getStackTrace(error: Error, lines: number) {
|
function getStackTrace(error: Error, lines: number) {
|
||||||
const topMessage = error.toString();
|
const topMessage = error.toString();
|
||||||
const stackTraceLines = (error.stack ?? "").split("\n", lines + 1);
|
const stackTraceLines = (error.stack ?? "").split("\n", lines + 1);
|
||||||
@ -37,6 +48,7 @@ export async function reportProviders(items: ProviderMetric[]): Promise<void> {
|
|||||||
method: "POST",
|
method: "POST",
|
||||||
body: {
|
body: {
|
||||||
items,
|
items,
|
||||||
|
tool: getScrapeTool(),
|
||||||
batchId: batchId(),
|
batchId: batchId(),
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
Loading…
Reference in New Issue
Block a user