Skip to content

Commit

Permalink
feat: save pageviews with timezone
Browse files Browse the repository at this point in the history
  • Loading branch information
olros committed Nov 22, 2023
1 parent 94f5961 commit 083cfc2
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 3 deletions.
3 changes: 1 addition & 2 deletions web/app/routes/api.$teamSlug.$projectSlug.pageview.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import type { ActionFunctionArgs } from '@vercel/remix';
import { json } from '@vercel/remix';
import type { UserAgentData } from '~/user-agent';
import { userAgent } from '~/user-agent';
import { getDate } from '~/utils_api.server';
import { forwardRequestToInternalApi } from '~/utils_edge.server';
import { format } from 'date-fns';
import invariant from 'tiny-invariant';
Expand Down Expand Up @@ -42,7 +41,7 @@ const getPageViewNextRequest = async (request: Request): Promise<Request | undef
const geo = geolocation(request);
const ip = ipAddress(request);
const ua = userAgent(request);
const date = getDate(request);
const date = new Date();

const geoData: PageviewRequestData['geo'] | undefined =
geo.city && geo.country && geo.flag && geo.latitude && geo.longitude ? (geo as PageviewRequestData['geo']) : undefined;
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
-- AlterTable to save timestamps with timezone
ALTER TABLE "PageViewNext" ALTER COLUMN "date" SET DATA TYPE TIMESTAMPTZ(3) USING "date" AT TIME ZONE 'Europe/Oslo';
2 changes: 1 addition & 1 deletion web/prisma/schema.prisma
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ model PageVisitor {
model PageViewNext {
id String @id @default(uuid()) @db.Uuid
date DateTime
date DateTime @db.Timestamptz(3)
pathname String
user_hash String
referrer String?
Expand Down

1 comment on commit 083cfc2

@vercel
Copy link

@vercel vercel bot commented on 083cfc2 Nov 22, 2023

Choose a reason for hiding this comment

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

Successfully deployed to the following URLs:

stats – ./

stats.olafros.com
stats-nu-nine.vercel.app
stats-olros.vercel.app
stats-git-main-olros.vercel.app

Please sign in to comment.