Skip to content

Commit

Permalink
Move error boundary to provider
Browse files Browse the repository at this point in the history
  • Loading branch information
Isthisanmol committed Aug 8, 2024
1 parent c2462db commit f3be54e
Show file tree
Hide file tree
Showing 9 changed files with 47 additions and 200 deletions.
2 changes: 2 additions & 0 deletions .env.example
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@ PUBLIC_X_RAPIDAPI_KEY="Your api key"
PUBLIC_MAPBOX_ACCESS_TOKEN="Your api key, starts with pk..."
PUBLIC_MAPBOX_DOWNLOADS_TOKEN="Your api key, starts with sk..."
PUBLIC_MAPBOX_DOWNLOADS_TOKEN2="Your api key, starts with sk..."
PUBLIC_BUGSNAG_API_KEY="Bugsnag api key"


# Google OAuth
PUBLIC_WEB_CLIENT_ID="Your Google OAuth web client ID"
Expand Down
19 changes: 7 additions & 12 deletions apps/expo/app/_layout.tsx
Original file line number Diff line number Diff line change
@@ -1,20 +1,15 @@
import React from 'react';
import { Provider } from 'app/provider';
import { Stack } from 'expo-router';
import Bugsnag from '../Bugsnag';

const ErrorBoundary = Bugsnag.getPlugin('react')?.createErrorBoundary(React);

export default function HomeLayout() {
return (
<ErrorBoundary>
<Provider>
<Stack
screenOptions={{
headerShown: false,
}}
/>
</Provider>
</ErrorBoundary>
<Provider>
<Stack
screenOptions={{
headerShown: false,
}}
/>
</Provider>
);
}
2 changes: 2 additions & 0 deletions apps/vite/env.example
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,6 @@ VITE_PUBLIC_CLIENT_URL="Your client url"
VITE_PUBLIC_API_URL="Your api url"
VITE_PUBLIC_MAPBOX_ACCESS_TOKEN="Your api key, starts with pk..."
VITE_PUBLIC_WEB_CLIENT_ID="962352557394-..................apps.googleusercontent.com"
VITE_PUBLIC_BUGSNAG_API_KEY="Bugsnag api key"


177 changes: 2 additions & 175 deletions apps/vite/src/routeTree.gen.ts
Original file line number Diff line number Diff line change
Expand Up @@ -174,163 +174,94 @@ const ProfileSettingsIndexLazyRoute = ProfileSettingsIndexLazyImport.update({
declare module '@tanstack/react-router' {
interface FileRoutesByPath {
'/': {
id: '/'
path: '/'
fullPath: '/'
preLoaderRoute: typeof IndexImport
parentRoute: typeof rootRoute
}
'/destination/query': {
id: '/destination/query'
path: '/destination/query'
fullPath: '/destination/query'
preLoaderRoute: typeof DestinationQueryLazyImport
parentRoute: typeof rootRoute
}
'/item/$itemId': {
id: '/item/$itemId'
path: '/item/$itemId'
fullPath: '/item/$itemId'
preLoaderRoute: typeof ItemItemIdLazyImport
parentRoute: typeof rootRoute
}
'/pack/$id': {
id: '/pack/$id'
path: '/pack/$id'
fullPath: '/pack/$id'
preLoaderRoute: typeof PackIdLazyImport
parentRoute: typeof rootRoute
}
'/pack/create': {
id: '/pack/create'
path: '/pack/create'
fullPath: '/pack/create'
preLoaderRoute: typeof PackCreateLazyImport
parentRoute: typeof rootRoute
}
'/profile/$id': {
id: '/profile/$id'
path: '/profile/$id'
fullPath: '/profile/$id'
preLoaderRoute: typeof ProfileIdLazyImport
parentRoute: typeof rootRoute
}
'/trip/$tripId': {
id: '/trip/$tripId'
path: '/trip/$tripId'
fullPath: '/trip/$tripId'
preLoaderRoute: typeof TripTripIdLazyImport
parentRoute: typeof rootRoute
}
'/trip/create': {
id: '/trip/create'
path: '/trip/create'
fullPath: '/trip/create'
preLoaderRoute: typeof TripCreateLazyImport
parentRoute: typeof rootRoute
}
'/about/': {
id: '/about/'
path: '/about'
fullPath: '/about'
preLoaderRoute: typeof AboutIndexLazyImport
parentRoute: typeof rootRoute
}
'/appearance/': {
id: '/appearance/'
path: '/appearance'
fullPath: '/appearance'
preLoaderRoute: typeof AppearanceIndexLazyImport
parentRoute: typeof rootRoute
}
'/dashboard/': {
id: '/dashboard/'
path: '/dashboard'
fullPath: '/dashboard'
preLoaderRoute: typeof DashboardIndexLazyImport
parentRoute: typeof rootRoute
}
'/feed/': {
id: '/feed/'
path: '/feed'
fullPath: '/feed'
preLoaderRoute: typeof FeedIndexLazyImport
parentRoute: typeof rootRoute
}
'/items/': {
id: '/items/'
path: '/items'
fullPath: '/items'
preLoaderRoute: typeof ItemsIndexLazyImport
parentRoute: typeof rootRoute
}
'/map/': {
id: '/map/'
path: '/map'
fullPath: '/map'
preLoaderRoute: typeof MapIndexLazyImport
parentRoute: typeof rootRoute
}
'/maps/': {
id: '/maps/'
path: '/maps'
fullPath: '/maps'
preLoaderRoute: typeof MapsIndexLazyImport
parentRoute: typeof rootRoute
}
'/packs/': {
id: '/packs/'
path: '/packs'
fullPath: '/packs'
preLoaderRoute: typeof PacksIndexLazyImport
parentRoute: typeof rootRoute
}
'/password-reset/': {
id: '/password-reset/'
path: '/password-reset'
fullPath: '/password-reset'
preLoaderRoute: typeof PasswordResetIndexLazyImport
parentRoute: typeof rootRoute
}
'/privacy/': {
id: '/privacy/'
path: '/privacy'
fullPath: '/privacy'
preLoaderRoute: typeof PrivacyIndexLazyImport
parentRoute: typeof rootRoute
}
'/profile/': {
id: '/profile/'
path: '/profile'
fullPath: '/profile'
preLoaderRoute: typeof ProfileIndexLazyImport
parentRoute: typeof rootRoute
}
'/register/': {
id: '/register/'
path: '/register'
fullPath: '/register'
preLoaderRoute: typeof RegisterIndexLazyImport
parentRoute: typeof rootRoute
}
'/sign-in/': {
id: '/sign-in/'
path: '/sign-in'
fullPath: '/sign-in'
preLoaderRoute: typeof SignInIndexLazyImport
parentRoute: typeof rootRoute
}
'/trips/': {
id: '/trips/'
path: '/trips'
fullPath: '/trips'
preLoaderRoute: typeof TripsIndexLazyImport
parentRoute: typeof rootRoute
}
'/profile/settings/': {
id: '/profile/settings/'
path: '/profile/settings'
fullPath: '/profile/settings'
preLoaderRoute: typeof ProfileSettingsIndexLazyImport
parentRoute: typeof rootRoute
}
Expand All @@ -339,7 +270,7 @@ declare module '@tanstack/react-router' {

// Create and export the route tree

export const routeTree = rootRoute.addChildren({
export const routeTree = rootRoute.addChildren([
IndexRoute,
DestinationQueryLazyRoute,
ItemItemIdLazyRoute,
Expand All @@ -363,110 +294,6 @@ export const routeTree = rootRoute.addChildren({
SignInIndexLazyRoute,
TripsIndexLazyRoute,
ProfileSettingsIndexLazyRoute,
})
])

/* prettier-ignore-end */

/* ROUTE_MANIFEST_START
{
"routes": {
"__root__": {
"filePath": "__root.tsx",
"children": [
"/",
"/destination/query",
"/item/$itemId",
"/pack/$id",
"/pack/create",
"/profile/$id",
"/trip/$tripId",
"/trip/create",
"/about/",
"/appearance/",
"/dashboard/",
"/feed/",
"/items/",
"/map/",
"/maps/",
"/packs/",
"/password-reset/",
"/privacy/",
"/profile/",
"/register/",
"/sign-in/",
"/trips/",
"/profile/settings/"
]
},
"/": {
"filePath": "index.tsx"
},
"/destination/query": {
"filePath": "destination/query.lazy.tsx"
},
"/item/$itemId": {
"filePath": "item/$itemId.lazy.tsx"
},
"/pack/$id": {
"filePath": "pack/$id.lazy.tsx"
},
"/pack/create": {
"filePath": "pack/create.lazy.tsx"
},
"/profile/$id": {
"filePath": "profile/$id.lazy.tsx"
},
"/trip/$tripId": {
"filePath": "trip/$tripId.lazy.tsx"
},
"/trip/create": {
"filePath": "trip/create.lazy.tsx"
},
"/about/": {
"filePath": "about/index.lazy.tsx"
},
"/appearance/": {
"filePath": "appearance/index.lazy.tsx"
},
"/dashboard/": {
"filePath": "dashboard/index.lazy.tsx"
},
"/feed/": {
"filePath": "feed/index.lazy.tsx"
},
"/items/": {
"filePath": "items/index.lazy.tsx"
},
"/map/": {
"filePath": "map/index.lazy.tsx"
},
"/maps/": {
"filePath": "maps/index.lazy.tsx"
},
"/packs/": {
"filePath": "packs/index.lazy.tsx"
},
"/password-reset/": {
"filePath": "password-reset/index.lazy.tsx"
},
"/privacy/": {
"filePath": "privacy/index.lazy.tsx"
},
"/profile/": {
"filePath": "profile/index.lazy.tsx"
},
"/register/": {
"filePath": "register/index.lazy.tsx"
},
"/sign-in/": {
"filePath": "sign-in/index.lazy.tsx"
},
"/trips/": {
"filePath": "trips/index.lazy.tsx"
},
"/profile/settings/": {
"filePath": "profile/settings/index.lazy.tsx"
}
}
}
ROUTE_MANIFEST_END */
8 changes: 4 additions & 4 deletions packages/app/components/feedPreview/FeedPreviewCard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ const FeedPreviewCard: React.FC<FeedPreviewCardProps> = ({ linkStr, item }) => {
>
<RText
color={hexToRGBA(currentTheme.colors.text, 0.8)}
style={{ fontWeight: 'bold', lineHeight: 'normal' }}
style={{ fontWeight: 'bold' }}
>
{formatNumber(formattedWeight)}
{weightUnit}
Expand All @@ -95,7 +95,7 @@ const FeedPreviewCard: React.FC<FeedPreviewCardProps> = ({ linkStr, item }) => {
/>
<RText
color={hexToRGBA(currentTheme.colors.text, 0.8)}
style={{ fontWeight: 'bold', lineHeight: 'normal' }}
style={{ fontWeight: 'bold' }}
>
{item.favorites_count}
</RText>
Expand All @@ -114,7 +114,7 @@ const FeedPreviewCard: React.FC<FeedPreviewCardProps> = ({ linkStr, item }) => {
/>
<RText
color={hexToRGBA(currentTheme.colors.text, 0.8)}
style={{ fontWeight: 'bold', lineHeight: 'normal' }}
style={{ fontWeight: 'bold' }}
>
{new Date(item.createdAt).toLocaleString('en-US', {
month: 'short',
Expand All @@ -128,7 +128,7 @@ const FeedPreviewCard: React.FC<FeedPreviewCardProps> = ({ linkStr, item }) => {
</View>
<RText
color={hexToRGBA(currentTheme.colors.text, 0.8)}
style={{ fontWeight: 'bold', lineHeight: 'normal' }}
style={{ fontWeight: 'bold' }}
>
Ttl Score: {item.total_score}
</RText>
Expand Down
3 changes: 2 additions & 1 deletion apps/expo/Bugsnag.ts → packages/app/provider/Bugsnag.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,10 @@ import Bugsnag from '@bugsnag/expo';
import BugsnagPluginReact from '@bugsnag/plugin-react';
import BugsnagPluginExpoApp from '@bugsnag/plugin-expo-app';
import BugsnagPluginExpoDevice from '@bugsnag/plugin-expo-device';
import { BUGSNAG_API_KEY } from '@packrat/config';

Bugsnag.start({
apiKey: process.env.BUGSNAG_API_KEY,
apiKey: BUGSNAG_API_KEY,
plugins: [BugsnagPluginReact, BugsnagPluginExpoApp, BugsnagPluginExpoDevice],
});

Expand Down
Loading

0 comments on commit f3be54e

Please sign in to comment.