Skip to content

Commit

Permalink
fix: change Sentry configuration and changelog crash (#371)
Browse files Browse the repository at this point in the history
  • Loading branch information
jog1t committed Sep 27, 2024
1 parent db03f46 commit a6ced3c
Show file tree
Hide file tree
Showing 5 changed files with 32 additions and 21 deletions.
8 changes: 8 additions & 0 deletions apps/hub/src/components/error-component.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,10 @@ import {
Text,
} from "@rivet-gg/components";
import { Icon, faBomb } from "@rivet-gg/icons";
import * as Sentry from "@sentry/react";
import { useQueryClient } from "@tanstack/react-query";
import type { ErrorComponentProps } from "@tanstack/react-router";
import { useEffect } from "react";
import { NotFoundComponent } from "./not-found-component";

export const ErrorComponent = ({
Expand All @@ -20,6 +22,12 @@ export const ErrorComponent = ({
}: Partial<ErrorComponentProps>) => {
const queryClient = useQueryClient();

useEffect(() => {
if (error) {
Sentry.captureException(error);
}
}, [error]);

if (isRivetError(error)) {
if (error.statusCode === 404) {
return <NotFoundComponent />;
Expand Down
36 changes: 21 additions & 15 deletions apps/hub/src/components/header/changelog.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ export function ChangelogEntry({
<div>
<img
src={`https://rivet.gg/${images[0].url}`}
alt={images[0].alt}
alt={"Changelog entry"}
className="rounded-md border my-4 h-[200px] object-cover w-full"
/>

Expand Down Expand Up @@ -95,29 +95,35 @@ export function Changelog() {
);

const hasNewChangelog = !lastChangelog
? true
? data.length > 0
: data.some((entry) => new Date(entry.published) > new Date(lastChangelog));

const trigger = (
<NavItem
asChild
className="hidden md:inline-block relative py-3 data-open:text-foreground"
>
<a href="https://rivet.gg/changelog" target="_blank" rel="noreferrer">
{hasNewChangelog ? (
<span className="absolute top-2 -right-1.5 size-1.5 rounded-full bg-primary animate-pulse" />
) : null}
Changelog
</a>
</NavItem>
);

if (data.length === 0) {
return trigger;
}

return (
<WithTooltip
onOpenChange={(isOpen) => {
if (isOpen) {
setLast(data[0].published);
}
}}
trigger={
<NavItem
asChild
className="hidden md:inline-block relative py-3 data-open:text-foreground"
>
<a href="https://rivet.gg/changelog" target="_blank" rel="noreferrer">
{hasNewChangelog ? (
<span className="absolute top-2 -right-1.5 size-1.5 rounded-full bg-primary animate-pulse" />
) : null}
Changelog
</a>
</NavItem>
}
trigger={trigger}
content={<ChangelogEntry {...data[0]} />}
/>
);
Expand Down
2 changes: 1 addition & 1 deletion apps/hub/src/domains/user/queries/query-options.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ export const selfProfileIdentityIdQueryOptions = () => {

export const changelogQueryOptions = () => {
return queryOptions({
queryKey: ["changelog"],
queryKey: ["changelog", __APP_GIT_COMMIT__],
staleTime: timing.hours(1),
queryFn: async () => {
const response = await fetch("https://rivet.gg/changelog.json");
Expand Down
3 changes: 1 addition & 2 deletions apps/hub/src/domains/user/queries/type.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
import { z } from "zod";

export const ChangelogItem = z.object({
id: z.string(),
published: z.string(),
images: z.array(z.object({ url: z.string(), alt: z.string() })),
images: z.array(z.object({ url: z.string() })),
title: z.string(),
description: z.string(),
slug: z.string(),
Expand Down
4 changes: 1 addition & 3 deletions apps/hub/vite.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,7 @@ export default defineConfig({
org: "rivet-gaming",
project: "hub",
authToken: process.env.SENTRY_AUTH_TOKEN,
release: {
name: `${GIT_BRANCH}@${GIT_SHA}`,
},
release: GIT_BRANCH === "main" ? { name: GIT_SHA } : undefined,
})
: null,
],
Expand Down

0 comments on commit a6ced3c

Please sign in to comment.