Skip to content

Commit

Permalink
chore: major pkg updates
Browse files Browse the repository at this point in the history
  • Loading branch information
lsbyerley committed Jul 19, 2024
1 parent b1357f8 commit c077652
Show file tree
Hide file tree
Showing 18 changed files with 2,005 additions and 1,020 deletions.
2 changes: 1 addition & 1 deletion app/components/progress-bar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ function EpicProgress() {
.getAnimations()
.map(({ finished }) => finished)

Promise.allSettled(animationPromises).then(() => {
void Promise.allSettled(animationPromises).then(() => {
if (!delayedPending) setAnimationComplete(true)
})
}, [delayedPending])
Expand Down
2 changes: 1 addition & 1 deletion app/components/ui/icon.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { type SVGProps } from 'react'
import { cn } from '#app/utils/misc.tsx'
import { type IconName } from '@/icon-name'
import href from './icons/sprite.svg'
import { type IconName } from '@/icon-name'

export { href }
export { IconName }
Expand Down
2 changes: 1 addition & 1 deletion app/entry.client.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { startTransition } from 'react'
import { hydrateRoot } from 'react-dom/client'

if (ENV.MODE === 'production' && ENV.SENTRY_DSN) {
import('./utils/monitoring.client.tsx').then(({ init }) => init())
void import('./utils/monitoring.client.tsx').then(({ init }) => init())
}

startTransition(() => {
Expand Down
29 changes: 20 additions & 9 deletions app/entry.server.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import {
} from '@remix-run/node'
import { RemixServer } from '@remix-run/react'
import * as Sentry from '@sentry/remix'
import chalk from 'chalk'
import { isbot } from 'isbot'
import { renderToPipeableStream } from 'react-dom/server'
import { getEnv, init } from './utils/env.server.ts'
Expand All @@ -19,10 +20,6 @@ const ABORT_DELAY = 5000
init()
global.ENV = getEnv()

if (ENV.MODE === 'production' && ENV.SENTRY_DSN) {
import('./utils/monitoring.server.ts').then(({ init }) => init())
}

type DocRequestArgs = Parameters<HandleDocumentRequestFunction>

export default async function handleRequest(...args: DocRequestArgs) {
Expand All @@ -39,11 +36,15 @@ export default async function handleRequest(...args: DocRequestArgs) {
responseHeaders.set('fly-primary-instance', primaryInstance)
responseHeaders.set('fly-instance', currentInstance)

if (process.env.NODE_ENV === 'production' && process.env.SENTRY_DSN) {
responseHeaders.append('Document-Policy', 'js-profiling')
}

const callbackName = isbot(request.headers.get('user-agent'))
? 'onAllReady'
: 'onShellReady'

const nonce = String(loadContext.cspNonce) ?? undefined
const nonce = loadContext.cspNonce?.toString() ?? ''
return new Promise(async (resolve, reject) => {
let didError = false
// NOTE: this timing will only include things that are rendered in the shell
Expand All @@ -70,10 +71,8 @@ export default async function handleRequest(...args: DocRequestArgs) {
onShellError: (err: unknown) => {
reject(err)
},
onError: (error: unknown) => {
onError: () => {
didError = true

console.error(error)
},
nonce,
},
Expand All @@ -97,9 +96,21 @@ export function handleError(
error: unknown,
{ request }: LoaderFunctionArgs | ActionFunctionArgs,
): void {
// Skip capturing if the request is aborted as Remix docs suggest
// Ref: https://remix.run/docs/en/main/file-conventions/entry.server#handleerror
if (request.signal.aborted) {
return
}
if (error instanceof Error) {
Sentry.captureRemixServerException(error, 'remix.server', request)
console.error(chalk.red(error.stack))
void Sentry.captureRemixServerException(
error,
'remix.server',
request,
true,
)
} else {
console.error(chalk.red(error))
Sentry.captureException(error)
}
}
6 changes: 3 additions & 3 deletions app/routes/_auth+/auth.$provider.callback.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ afterEach(async () => {
test('a new user goes to onboarding', async () => {
const request = await setupRequest()
const response = await loader({ request, params: PARAMS, context: {} }).catch(
e => e,
(e) => e,
)
expect(response).toHaveRedirect('/onboarding/github')
})
Expand All @@ -40,7 +40,7 @@ test('when auth fails, send the user to login with a toast', async () => {
)
const request = await setupRequest()
const response = await loader({ request, params: PARAMS, context: {} }).catch(
e => e,
(e) => e,
)
invariant(response instanceof Response, 'response should be a Response')
expect(response).toHaveRedirect('/login')
Expand Down Expand Up @@ -98,7 +98,7 @@ test(`when a user is logged in and has already connected, it doesn't do anything
})
const response = await loader({ request, params: PARAMS, context: {} })
expect(response).toHaveRedirect('/settings/profile/connections')
expect(response).toSendToast(
await expect(response).toSendToast(
expect.objectContaining({
title: 'Already Connected',
description: expect.stringContaining(githubUser.profile.login),
Expand Down
9 changes: 1 addition & 8 deletions app/routes/bucnation.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
import {
type LoaderFunctionArgs,
type ActionFunctionArgs,
json,
} from '@remix-run/node'
import {
Expand Down Expand Up @@ -73,7 +71,7 @@ export const meta: MetaFunction = ({ data }) => [
},
]

export const loader = async ({ request }: LoaderFunctionArgs) => {
export const loader = async () => {
const hoopsApi = process.env.HOOPS_API;
const responsePromises = await Promise.all([
fetch(`${hoopsApi}/api/etsu/roster`),
Expand All @@ -84,7 +82,6 @@ export const loader = async ({ request }: LoaderFunctionArgs) => {
const responseData = (await Promise.all(
responsePromises.map(response => response.json()),
)) as [RosterApiRes, ScheduleApiRes, StatsApiRes]
// console.log('LOG: loaderData', responseData)

return json({
roster: responseData[0],
Expand All @@ -93,10 +90,6 @@ export const loader = async ({ request }: LoaderFunctionArgs) => {
})
}

export const action = async ({ request }: ActionFunctionArgs) => {
return null
}

export const heightFromInches = (total: number) => {
const feet = Math.floor(total / 12)
const inches = total % 12
Expand Down
2 changes: 1 addition & 1 deletion app/utils/cache.server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ export const cache: CachifiedCache = {
return { metadata, value }
},
async set(key, entry) {
// eslint-disable-next-line @typescript-eslint/no-unnecessary-condition
const { currentIsPrimary, primaryInstance } = await getInstanceInfo()
if (currentIsPrimary) {
cacheDb
Expand Down
2 changes: 1 addition & 1 deletion app/utils/db.server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,6 @@ export const prisma = remember('prisma', () => {
const dur = chalk[color](`${e.duration}ms`)
console.info(`prisma:query - ${dur} - ${e.query}`)
})
client.$connect()
void client.$connect()
return client
})
24 changes: 13 additions & 11 deletions app/utils/monitoring.client.tsx
Original file line number Diff line number Diff line change
@@ -1,9 +1,14 @@
import { useLocation, useMatches } from '@remix-run/react'
import * as Sentry from '@sentry/remix'
import {
init as sentryInit,
browserTracingIntegration,
replayIntegration,
browserProfilingIntegration,
} from '@sentry/remix'
import { useEffect } from 'react'

export function init() {
Sentry.init({
sentryInit({
dsn: ENV.SENTRY_DSN,
environment: ENV.MODE,
beforeSend(event) {
Expand All @@ -20,16 +25,13 @@ export function init() {
return event
},
integrations: [
new Sentry.BrowserTracing({
routingInstrumentation: Sentry.remixRouterInstrumentation(
useEffect,
useLocation,
useMatches,
),
browserTracingIntegration({
useEffect,
useLocation,
useMatches,
}),
// Replay is only available in the client
new Sentry.Replay(),
new Sentry.BrowserProfilingIntegration(),
replayIntegration(),
browserProfilingIntegration(),
],

// Set tracesSampleRate to 1.0 to capture 100%
Expand Down
3 changes: 3 additions & 0 deletions app/utils/providers/constants.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
export const MOCK_CODE_GITHUB = 'MOCK_CODE_GITHUB_KODY'

export const MOCK_CODE_GITHUB_HEADER = 'x-mock-code-github'
2 changes: 1 addition & 1 deletion app/utils/timing.server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ function createTimer(type: string, desc?: string) {
let timingType = timings[type]

if (!timingType) {
// eslint-disable-next-line no-multi-assign
timingType = timings[type] = []
}
timingType.push({ desc, time: performance.now() - start })
Expand Down
7 changes: 7 additions & 0 deletions eslint.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
import { default as defaultConfig } from '@epic-web/config/eslint'

/** @type {import("eslint").Linter.Config} */
export default [
...defaultConfig,
// add custom config objects here:
]
Loading

0 comments on commit c077652

Please sign in to comment.