how bad of an idea is it to write to a pageViews column in the db on every pageload lmao?

how bad of an idea is it to write to a pageViews column in the db on every pageload lmao? I'd rather not pay for a 3rd party analytics tool while at a small size
11 Replies
Gaurang
Gaurang3y ago
I've been curious of a good way to handle this as well.
AdmiralGeneralAladeen
yeah a lot of the pricing on the 3rd party tools doesn't scale well at all and idk how well they play with adblockers
Gaurang
Gaurang3y ago
I freelanced for a startup that took this approach via a micro service, basically on initial page load we'd call a micro-service and pass along the current user, which then offloads the handling of writing to a mongodb atlas instance and sending the data off to a 3rd part analytics tool. I didn't really notice any issue with the approach in nextjs
AdmiralGeneralAladeen
not a bad idea actually haha look at the timing of this
AdmiralGeneralAladeen
wont be free, im sure, but this might be a good option in the very near future
Gaurang
Gaurang3y ago
Im sure something similar could be done with an edge function or if u use postgres a remote procedure call might also be feasible.
AdmiralGeneralAladeen
could even simplify it down to a trpc call that writes to the db, I don't think you'd have to wait for a response unless im forgetting
Gaurang
Gaurang3y ago
yea no reason to wait for the response at all. as long as ure handling errors that could def. work.
Gaurang
Gaurang3y ago
interetingly, this was just discussed on nextconf right now: https://partytown.builder.io/nextjs
Partytown
NextJS - Partytown
NextJS - Partytown
Gaurang
Gaurang3y ago
I keep forgetting about partytown.. fyi its still in beta, but it seems very promising
Want results from more Discord servers?
Add your server