From ec6119a44ca81e88c27e9afb5fa2ffefee587713 Mon Sep 17 00:00:00 2001 From: mrjvs Date: Thu, 25 Jan 2024 22:19:09 +0100 Subject: [PATCH] add scrape-tool to reports --- src/backend/helpers/report.ts | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/src/backend/helpers/report.ts b/src/backend/helpers/report.ts index 283f0915..4822a867 100644 --- a/src/backend/helpers/report.ts +++ b/src/backend/helpers/report.ts @@ -3,7 +3,9 @@ import { nanoid } from "nanoid"; import { ofetch } from "ofetch"; import { useCallback } from "react"; +import { isExtensionActiveCached } from "@/backend/extension/messaging"; import { ScrapingItems, ScrapingSegment } from "@/hooks/useProviderScrape"; +import { useAuthStore } from "@/stores/auth"; import { PlayerMeta } from "@/stores/player/slices/source"; // for anybody who cares - these are anonymous metrics. @@ -25,6 +27,15 @@ export type ProviderMetric = { 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) { const topMessage = error.toString(); const stackTraceLines = (error.stack ?? "").split("\n", lines + 1); @@ -37,6 +48,7 @@ export async function reportProviders(items: ProviderMetric[]): Promise { method: "POST", body: { items, + tool: getScrapeTool(), batchId: batchId(), }, });