Skip to content

Commit

Permalink
fix: bugs in the heartbeat method and flip mutation
Browse files Browse the repository at this point in the history
  • Loading branch information
jkrumm committed Jan 24, 2024
1 parent 8c33737 commit 14a0073
Show file tree
Hide file tree
Showing 11 changed files with 53 additions and 477 deletions.
8 changes: 4 additions & 4 deletions sentry.client.config.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
// This file configures the initialization of Sentry on the client.
// The config you add here will be used whenever a users loads a page in their browser.
// https://docs.sentry.io/platforms/javascript/guides/nextjs/
import { env } from 'fpp/env.mjs';

import * as Sentry from "@sentry/nextjs";
import { env } from "fpp/env.mjs";
import * as Sentry from '@sentry/nextjs';

Sentry.init({
enabled: env.NEXT_PUBLIC_NODE_ENV !== "development",
enabled: env.NEXT_PUBLIC_NODE_ENV !== 'development',

dsn: env.NEXT_PUBLIC_SENTRY_DSN,

Expand All @@ -16,7 +16,7 @@ Sentry.init({
tracesSampleRate: 0.1,

// Setting this option to true will print useful information to the console while you're setting up Sentry.
debug: false,
debug: env.NEXT_PUBLIC_NODE_ENV === 'development',

// TODO: think about Session Replay

Expand Down
2 changes: 1 addition & 1 deletion src/middleware.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import { Redis } from '@upstash/redis';
// 8130 / 2004 = 4.06 commands per request
const ratelimit = new Ratelimit({
redis: Redis.fromEnv(),
limiter: Ratelimit.fixedWindow(30, '10 s'),
limiter: Ratelimit.fixedWindow(40, '10 s'),
analytics: true,
});

Expand Down
4 changes: 2 additions & 2 deletions src/pages/api/track-page-view.ts
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ const TrackPageView = withLogger(async (req: AxiomRequest) => {
)[0];

if (!userExists) {
const userPayload = getVisitorPayload(req);
const userPayload = getUserPayload(req);
await db.insert(users).values({
id: userId,
...userPayload,
Expand All @@ -67,7 +67,7 @@ const TrackPageView = withLogger(async (req: AxiomRequest) => {
return NextResponse.json({ userId }, { status: 200 });
});

export const getVisitorPayload = (req: AxiomRequest) => {
export const getUserPayload = (req: AxiomRequest) => {
if (req instanceof NextRequest) {
const ua = userAgent(req);

Expand Down
4 changes: 0 additions & 4 deletions src/server/api/root.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,6 @@ import { configRouter } from 'fpp/server/api/routers/config.router';
import { contactRouter } from 'fpp/server/api/routers/contact.router';
import { roadmapRouter } from 'fpp/server/api/routers/roadmap.router';
import { roomRouter } from 'fpp/server/api/routers/room.router';
import { trackingRouter } from 'fpp/server/api/routers/tracking.router';
import { voteRouter } from 'fpp/server/api/routers/vote.router';
import { createTRPCRouter } from 'fpp/server/api/trpc';

import { roomStateRouter } from 'fpp/server/room-state/room-state.router';
Expand All @@ -14,8 +12,6 @@ export const appRouter = createTRPCRouter({
contact: contactRouter,
config: configRouter,
room: roomRouter,
tracking: trackingRouter,
vote: voteRouter,
roadmap: roadmapRouter,
analytics: analyticsRouter,
});
Expand Down
4 changes: 2 additions & 2 deletions src/server/api/routers/room.router.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ import {
users,
} from 'fpp/server/db/schema';

import { getVisitorPayload } from 'fpp/pages/api/track-page-view';
import { getUserPayload } from 'fpp/pages/api/track-page-view';

const findOpenRoomNumber = async (
// eslint-disable-next-line @typescript-eslint/consistent-type-imports
Expand Down Expand Up @@ -60,7 +60,7 @@ export const roomRouter = createTRPCRouter({

if (!validateNanoId(userId)) {
userId = nanoid();
const userPayload = getVisitorPayload(req as AxiomRequest);
const userPayload = getUserPayload(req as AxiomRequest);
await db.insert(users).values({
id: userId,
...userPayload,
Expand Down
Loading

1 comment on commit 14a0073

@vercel
Copy link

@vercel vercel bot commented on 14a0073 Jan 24, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.