Compare commits

..

5 Commits

Author SHA1 Message Date
26bef47403 Disable text masking and media blocking
All checks were successful
Test, Build, Deploy / Test, Build, and Deploy (push) Successful in 1m2s
Test, Build, Deploy / Create Sentry Release (push) Successful in 6s
2026-03-15 03:14:19 -04:00
47df3dc55f Combine queries into batches
All checks were successful
Test, Build, Deploy / Test, Build, and Deploy (push) Successful in 45s
Test, Build, Deploy / Create Sentry Release (push) Successful in 6s
2026-03-14 05:18:50 -04:00
994a7a7a58 Include both ray and region in report id
All checks were successful
Test, Build, Deploy / Test, Build, and Deploy (push) Successful in 47s
Test, Build, Deploy / Create Sentry Release (push) Successful in 5s
2026-03-14 02:25:53 -04:00
2ca8cc163d Add trailing slash that is apparently needed
Some checks failed
Test, Build, Deploy / Test, Build, and Deploy (push) Successful in 54s
Test, Build, Deploy / Create Sentry Release (push) Failing after 25s
2026-03-14 02:21:00 -04:00
8e34e2ce24 Send back response from sentry through tunnel
All checks were successful
Test, Build, Deploy / Test, Build, and Deploy (push) Successful in 54s
Test, Build, Deploy / Create Sentry Release (push) Successful in 7s
2026-03-14 01:47:42 -04:00
5 changed files with 57 additions and 59 deletions

View File

@@ -16,7 +16,11 @@ Sentry.init({
useLocation,
useMatches,
}),
Sentry.replayIntegration(),
Sentry.replayIntegration({
blockAllMedia: false,
maskAllInputs: false,
maskAllText: false,
}),
],
replaysOnErrorSampleRate: 1,
replaysSessionSampleRate: 0.02,

View File

@@ -35,29 +35,24 @@ export async function loader({ context }: { context: RequestContext }) {
month = 12;
}
const eventMemberQuery = await context.env.D1.prepare(
"SELECT id, name, roblox_id FROM et_members;",
).all();
const inactivityQuery: D1Result<Record<string, any>> =
await context.env.D1.prepare(
"SELECT decisions, json_extract(user, '$.id') AS uid FROM inactivity_notices WHERE (end BETWEEN DATE('now', 'start of month', '-1 month') AND DATE('now', 'start of month', '-1 day')) OR (start BETWEEN DATE('now', 'start of month', '-1 month') AND DATE('now', 'start of month', '-1 day'));",
).all();
const batchStatements: D1Result<Record<string, any>>[] =
await context.env.D1.batch([
context.env.D1.prepare("SELECT id, name, roblox_id FROM et_members;"),
context.env.D1.prepare(
"SELECT decisions, json_extract(user, '$.id') AS uid FROM inactivity_notices WHERE (end BETWEEN DATE('now', 'start of month', '-1 month') AND DATE('now', 'start of month', '-1 day')) OR (start BETWEEN DATE('now', 'start of month', '-1 month') AND DATE('now', 'start of month', '-1 day'));",
),
context.env.D1.prepare(
"SELECT approved, answered_at, created_by, performed_at, reached_minimum_player_count, type FROM events WHERE month = ? AND year = ?;",
).bind(month, year),
]);
const eventsQuery = await context.env.D1.prepare(
"SELECT approved, answered_at, created_by, performed_at, reached_minimum_player_count, type FROM events WHERE month = ? AND year = ?;",
)
.bind(month, year)
.all();
const memberMap = Object.fromEntries(
eventMemberQuery.results.map((entry) => {
return [
entry.id,
{ name: entry.name, points: 0, roblox_id: entry.roblox_id },
];
batchStatements[0].results.map((e) => {
return [e.id, { name: e.name, points: 0, roblox_id: e.roblox_id }];
}),
);
for (const event of eventsQuery.results as {
for (const event of batchStatements[2].results as {
approved: number;
answered_at: number;
created_by: string;
@@ -77,10 +72,10 @@ export async function loader({ context }: { context: RequestContext }) {
for (const member of Object.keys(memberMap))
if (
(memberMap[member].points < 50 ||
eventsQuery.results.filter(
batchStatements[2].results.filter(
(e) => e.type === "gamenight" && e.created_by === member,
).length === 0) &&
!inactivityQuery.results.find(
!batchStatements[1].results.find(
(i) => i.uid === member && JSON.parse(i.decisions).et,
)
)

View File

@@ -33,37 +33,31 @@ export async function loader({ context }: { context: RequestContext }) {
if (!currentUser) throw new Response(null, { status: 401 });
const d1Promises = [];
const batchStatements = [];
for (const itemType of ["appeals", "inactivity_notices", "reports"])
d1Promises.push(
for (const itemType of ["appeals", "inactivity_notices", "reports"]) {
batchStatements.push(
context.env.D1.prepare(
`SELECT *
FROM ${itemType}
WHERE json_extract(user, '$.id') = ?
ORDER BY created_at DESC;`,
)
.bind(currentUser.id)
.all(),
`SELECT * FROM ${itemType} WHERE json_extract(user, '$.id') = ? ORDER BY created_at DESC;`,
).bind(currentUser.id),
);
const settledPromises = await Promise.allSettled(d1Promises);
let etData: { [k: string]: any } | null = null;
if (currentUser.permissions & (1 << 3)) {
etData = await context.env.D1.prepare(
"SELECT name, points, roblox_id FROM et_members WHERE id = ?;",
)
.bind(currentUser.id)
.first();
}
return {
etData,
items: settledPromises.map((p) => {
if (p.status === "fulfilled") return p.value.results;
if (currentUser.permissions & (1 << 3))
batchStatements.push(
context.env.D1.prepare(
"SELECT name, points, roblox_id FROM et_members WHERE id = ? LIMIT 1;",
).bind(currentUser.id),
);
return null;
const batchResults = await context.env.D1.batch(batchStatements);
return {
etData: batchResults.at(3)?.results?.at(0) as { [k: string]: any } | null,
items: batchResults.map((r) => {
if (r.success) return r.results;
return [];
}) as any as ({ [k: string]: any }[] | null)[],
permissions: currentUser.permissions as number,
};

View File

@@ -194,8 +194,7 @@ export async function onRequestPost(context: RequestContext) {
const reportId = `${Date.now()}${context.request.headers
.get("cf-ray")
?.split("-")
?.at(0)}${crypto.randomUUID().replaceAll("-", "")}`;
?.replace("-", "")}${crypto.randomUUID().replaceAll("-", "")}`;
const { current_user: currentUser } = context.data;
if (filesToProcess.length)

View File

@@ -12,18 +12,24 @@ export async function onRequestPost(context: RequestContext) {
const sentryUrl = new URL(dsn);
await fetch(`https://${sentryUrl.host}/api${sentryUrl.pathname}/envelope`, {
body: clonedRequest.body,
headers: {
"content-type": "application/x-sentry-envelope",
"x-forwarded-for": context.request.headers.get(
"cf-connecting-ip",
) as string,
const resp = await fetch(
`https://${sentryUrl.host}/api${sentryUrl.pathname}/envelope/`,
{
body: clonedRequest.body,
headers: {
"content-type": "application/x-sentry-envelope",
"x-forwarded-for": context.request.headers.get(
"cf-connecting-ip",
) as string,
},
method: "POST",
},
method: "POST",
});
);
return new Response(null, {
status: 204,
return new Response(await resp.text(), {
headers: {
"content-type": resp.headers.get("content-type") || "text/plain",
},
status: resp.status,
});
}