Browse Source

Merge branch 'dev' into dev

pull/825/head
RyloRiz 2 years ago committed by GitHub
parent
commit
ccaa772e1a
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
  1. 2
      src/backend/extension/compatibility.ts
  2. 12
      src/backend/helpers/report.ts

2
src/backend/extension/compatibility.ts

@ -1,6 +1,6 @@
import { satisfies } from "semver"; import { satisfies } from "semver";
const allowedExtensionRange = "~1.0.0"; const allowedExtensionRange = "~1.0.2";
export function isAllowedExtensionVersion(version: string): boolean { export function isAllowedExtensionVersion(version: string): boolean {
return satisfies(version, allowedExtensionRange); return satisfies(version, allowedExtensionRange);

12
src/backend/helpers/report.ts

@ -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…
Cancel
Save