Cap feedback at 10 per user with clustered admin views, and redesign /social/team as a denser job board. Co-authored-by: Cursor <cursoragent@cursor.com>
94 lines
2.8 KiB
TypeScript
94 lines
2.8 KiB
TypeScript
/** Silent client telemetry for feedback — admin-only; never shown in UI. */
|
|
|
|
import { getGuestId } from "./api";
|
|
import { getSocialSession } from "./socialSession";
|
|
|
|
export type FeedbackClientMeta = Record<string, unknown>;
|
|
|
|
function safeLocal(key: string): string {
|
|
try {
|
|
return (localStorage.getItem(key) || "").trim();
|
|
} catch {
|
|
return "";
|
|
}
|
|
}
|
|
|
|
export function collectFeedbackClientMeta(
|
|
extra?: Record<string, unknown>,
|
|
): FeedbackClientMeta {
|
|
if (typeof window === "undefined") {
|
|
return { ...(extra || {}), collectedAt: new Date().toISOString() };
|
|
}
|
|
const session = getSocialSession();
|
|
const nav = window.navigator;
|
|
const conn =
|
|
(nav as Navigator & { connection?: Record<string, unknown> }).connection ||
|
|
null;
|
|
const screen = window.screen;
|
|
return {
|
|
collectedAt: new Date().toISOString(),
|
|
guestId: getGuestId(),
|
|
email: session?.email || "",
|
|
name: session?.name || "",
|
|
href: window.location.href,
|
|
pathname: window.location.pathname,
|
|
search: window.location.search,
|
|
hash: window.location.hash,
|
|
referrer: document.referrer || "",
|
|
title: document.title || "",
|
|
locale: document.documentElement.lang || "",
|
|
language: nav.language || "",
|
|
languages: Array.from(nav.languages || []),
|
|
userAgent: nav.userAgent || "",
|
|
platform: nav.platform || "",
|
|
vendor: nav.vendor || "",
|
|
cookieEnabled: nav.cookieEnabled,
|
|
onLine: nav.onLine,
|
|
maxTouchPoints: nav.maxTouchPoints || 0,
|
|
hardwareConcurrency: nav.hardwareConcurrency || 0,
|
|
deviceMemory:
|
|
(nav as Navigator & { deviceMemory?: number }).deviceMemory || null,
|
|
timezone: Intl.DateTimeFormat().resolvedOptions().timeZone || "",
|
|
timezoneOffsetMin: new Date().getTimezoneOffset(),
|
|
screen: {
|
|
width: screen.width,
|
|
height: screen.height,
|
|
availWidth: screen.availWidth,
|
|
availHeight: screen.availHeight,
|
|
colorDepth: screen.colorDepth,
|
|
pixelDepth: screen.pixelDepth,
|
|
orientation: screen.orientation?.type || "",
|
|
},
|
|
viewport: {
|
|
innerWidth: window.innerWidth,
|
|
innerHeight: window.innerHeight,
|
|
outerWidth: window.outerWidth,
|
|
outerHeight: window.outerHeight,
|
|
devicePixelRatio: window.devicePixelRatio || 1,
|
|
},
|
|
connection: conn
|
|
? {
|
|
type: conn.type ?? null,
|
|
effectiveType: conn.effectiveType ?? null,
|
|
downlink: conn.downlink ?? null,
|
|
rtt: conn.rtt ?? null,
|
|
saveData: conn.saveData ?? null,
|
|
}
|
|
: null,
|
|
accountFlags: {
|
|
paidType: safeLocal("paidType"),
|
|
joinPaid:
|
|
safeLocal("social-join-paid") ||
|
|
(() => {
|
|
try {
|
|
return sessionStorage.getItem("social-join-paid") || "";
|
|
} catch {
|
|
return "";
|
|
}
|
|
})(),
|
|
profileDone: safeLocal("social-join-profile-done"),
|
|
},
|
|
...(extra || {}),
|
|
};
|
|
}
|