mirror of
https://github.com/jakejarvis/jarv.is.git
synced 2026-01-11 04:02:56 -05:00
bump next
This commit is contained in:
@@ -2,20 +2,26 @@ import * as Sentry from "@sentry/node";
|
||||
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
||||
import * as Tracing from "@sentry/tracing";
|
||||
|
||||
// https://docs.sentry.io/platforms/node/configuration/options/
|
||||
Sentry.init({
|
||||
dsn: process.env.SENTRY_DSN || process.env.NEXT_PUBLIC_SENTRY_DSN || "",
|
||||
environment: process.env.NODE_ENV || process.env.VERCEL_ENV || process.env.NEXT_PUBLIC_VERCEL_ENV || "",
|
||||
tracesSampleRate: 1.0,
|
||||
});
|
||||
const IsomorphicSentry = () => {
|
||||
// https://docs.sentry.io/platforms/node/configuration/options/
|
||||
Sentry.init({
|
||||
dsn: process.env.SENTRY_DSN || process.env.NEXT_PUBLIC_SENTRY_DSN || "",
|
||||
environment: process.env.NODE_ENV || process.env.VERCEL_ENV || process.env.NEXT_PUBLIC_VERCEL_ENV || "",
|
||||
tracesSampleRate: 1.0,
|
||||
});
|
||||
|
||||
return Sentry;
|
||||
};
|
||||
|
||||
export const logServerError = async (error: string | Error) => {
|
||||
try {
|
||||
const sentryInstance = IsomorphicSentry();
|
||||
|
||||
// log error to sentry
|
||||
Sentry.captureException(error);
|
||||
sentryInstance.captureException(error);
|
||||
// give it 2 seconds to finish sending:
|
||||
// https://docs.sentry.io/platforms/node/configuration/draining/
|
||||
await Sentry.flush(2000);
|
||||
await sentryInstance.flush(2000);
|
||||
} catch (sentryError) {
|
||||
// cue inception bong
|
||||
console.error("Encountered an error logging an error... We are doomed.", sentryError);
|
||||
@@ -28,4 +34,4 @@ export const logServerError = async (error: string | Error) => {
|
||||
return true;
|
||||
};
|
||||
|
||||
export default Sentry;
|
||||
export default IsomorphicSentry;
|
||||
|
||||
@@ -24,45 +24,43 @@ const {
|
||||
ToInteger,
|
||||
} = faunadb.query;
|
||||
|
||||
export default function run() {
|
||||
// initializes the empty database
|
||||
CreateCollection({ name: "hits" });
|
||||
// initializes the empty database
|
||||
CreateCollection({ name: "hits" });
|
||||
|
||||
// this allows us to quickly pull a post's corresponding row
|
||||
CreateIndex({
|
||||
name: "hits_by_slug",
|
||||
source: Collection("hits"),
|
||||
terms: [
|
||||
{
|
||||
field: ["data", "slug"],
|
||||
},
|
||||
],
|
||||
unique: false,
|
||||
serialized: true,
|
||||
});
|
||||
// this allows us to quickly pull a post's corresponding row
|
||||
CreateIndex({
|
||||
name: "hits_by_slug",
|
||||
source: Collection("hits"),
|
||||
terms: [
|
||||
{
|
||||
field: ["data", "slug"],
|
||||
},
|
||||
],
|
||||
unique: false,
|
||||
serialized: true,
|
||||
});
|
||||
|
||||
// a wrapper to get a post's row, add one to it, and return the new tally
|
||||
CreateFunction({
|
||||
name: "increment_hit",
|
||||
body: Query(
|
||||
Lambda(
|
||||
"slug",
|
||||
Let(
|
||||
{ match: Match(Index("hits_by_slug"), Var("slug")) },
|
||||
If(
|
||||
Exists(Var("match")),
|
||||
Let(
|
||||
{
|
||||
ref: Select("ref", Get(Var("match"))),
|
||||
hits: ToInteger(Select("hits", Select("data", Get(Var("match"))))),
|
||||
},
|
||||
Update(Var("ref"), { data: { hits: Add(Var("hits"), 1) } })
|
||||
),
|
||||
Create(Collection("hits"), { data: { slug: Var("slug"), hits: 1 } })
|
||||
)
|
||||
// a wrapper to get a post's row, add one to it, and return the new tally
|
||||
CreateFunction({
|
||||
name: "increment_hit",
|
||||
body: Query(
|
||||
Lambda(
|
||||
"slug",
|
||||
Let(
|
||||
{ match: Match(Index("hits_by_slug"), Var("slug")) },
|
||||
If(
|
||||
Exists(Var("match")),
|
||||
Let(
|
||||
{
|
||||
ref: Select("ref", Get(Var("match"))),
|
||||
hits: ToInteger(Select("hits", Select("data", Get(Var("match"))))),
|
||||
},
|
||||
Update(Var("ref"), { data: { hits: Add(Var("hits"), 1) } })
|
||||
),
|
||||
Create(Collection("hits"), { data: { slug: Var("slug"), hits: 1 } })
|
||||
)
|
||||
)
|
||||
),
|
||||
role: Role("server"),
|
||||
});
|
||||
}
|
||||
)
|
||||
),
|
||||
role: Role("server"),
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user