Skip to content

Commit c4486f7

Browse files
committed
Fix sentry error on dev, local scripts and user card icon
1 parent 27b793e commit c4486f7

4 files changed

Lines changed: 48 additions & 9 deletions

File tree

app/mobile/app/_layout.tsx

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ import { SafeAreaProvider } from "react-native-safe-area-context";
3131
import DevSettingsButton from "@/components/DevSettingsButton";
3232
import { hydrateUrlOverrides } from "@/config/urls";
3333
import { AuthProvider, useAuthContext } from "@/features/auth/AuthContext";
34+
import { appVariant } from "@/service/buildInfo";
3435
import { useRegisterPushNotifications } from "@/features/notifications/useRegisterPushNotifications";
3536
import { reconfigureApiClient } from "@/service/client";
3637
import { getNotificationPath } from "@/utils/getNotificationPath";
@@ -91,7 +92,9 @@ function RootNavigator({ fontsLoaded }: { fontsLoaded: boolean }) {
9192
);
9293
}
9394

94-
export default Sentry.wrap(function RootLayout() {
95+
const sentryEnabled = appVariant === "production" || appVariant === "staging";
96+
97+
function RootLayout() {
9598
const colorScheme = useColorScheme();
9699
const [fontsLoaded] = useFonts({
97100
Ubuntu_300Light,
@@ -131,7 +134,9 @@ export default Sentry.wrap(function RootLayout() {
131134
</ThemeProvider>
132135
</SafeAreaProvider>
133136
);
134-
});
137+
}
138+
139+
export default sentryEnabled ? Sentry.wrap(RootLayout) : RootLayout;
135140

136141
/**
137142
* Generates a unique ID for a notification response to prevent duplicate handling.

app/scripts/dev-mobile-setup.py

Lines changed: 34 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,12 @@
1111
python3 scripts/dev-mobile-setup.py --restore # undo all changes
1212
1313
Files modified:
14-
app/proxy/envoy.yaml - adds IP to CORS allow list
15-
app/backend.dev.env - sets COOKIE_DOMAIN and media server URLs
16-
app/web/.env.localdev - sets API and media URLs
17-
app/mobile/.env - switches from staging to local dev mode
14+
app/proxy/envoy.yaml - adds IP to CORS allow list
15+
app/backend.dev.env - sets COOKIE_DOMAIN and media server URLs
16+
app/media.dev.env - sets media server base URL (for image uploads)
17+
app/web/.env.localdev - sets API and media URLs
18+
app/web/.env.development - sets API and media URLs
19+
app/mobile/.env - switches from staging to local dev mode
1820
1921
Note: do NOT commit the envoy.yaml change.
2022
"""
@@ -29,7 +31,9 @@
2931

3032
ENVOY_YAML = APP / "proxy" / "envoy.yaml"
3133
BACKEND_ENV = APP / "backend.dev.env"
34+
MEDIA_ENV = APP / "media.dev.env"
3235
WEB_ENV = APP / "web" / ".env.localdev"
36+
WEB_DEV_ENV = APP / "web" / ".env.development"
3337
MOBILE_ENV = APP / "mobile" / ".env"
3438

3539
MOBILE_ENV_DEFAULT = """\
@@ -80,13 +84,26 @@ def setup(ip: str) -> None:
8084
BACKEND_ENV.write_text(content)
8185
print(" backend.dev.env updated COOKIE_DOMAIN and media server URLs")
8286

87+
# media.dev.env — media server base URL (needed for upload response URLs)
88+
content = MEDIA_ENV.read_text()
89+
content = re.sub(r"^MEDIA_SERVER_BASE_URL=.*", f"MEDIA_SERVER_BASE_URL=http://{ip}:5001", content, flags=re.MULTILINE)
90+
MEDIA_ENV.write_text(content)
91+
print(" media.dev.env updated MEDIA_SERVER_BASE_URL")
92+
8393
# web/.env.localdev — API + media URLs
8494
content = WEB_ENV.read_text()
8595
content = re.sub(r'^NEXT_PUBLIC_API_BASE_URL=.*', f'NEXT_PUBLIC_API_BASE_URL="http://{ip}:8888"', content, flags=re.MULTILINE)
8696
content = re.sub(r'^NEXT_PUBLIC_MEDIA_BASE_URL=.*', f'NEXT_PUBLIC_MEDIA_BASE_URL="http://{ip}:5001"', content, flags=re.MULTILINE)
8797
WEB_ENV.write_text(content)
8898
print(" web/.env.localdev updated API and media URLs")
8999

100+
# web/.env.development — API + media URLs
101+
content = WEB_DEV_ENV.read_text()
102+
content = re.sub(r'^NEXT_PUBLIC_API_BASE_URL=.*', f'NEXT_PUBLIC_API_BASE_URL="http://{ip}:8888"', content, flags=re.MULTILINE)
103+
content = re.sub(r'^NEXT_PUBLIC_MEDIA_BASE_URL=.*', f'NEXT_PUBLIC_MEDIA_BASE_URL="http://{ip}:5001"', content, flags=re.MULTILINE)
104+
WEB_DEV_ENV.write_text(content)
105+
print(" web/.env.development updated API and media URLs")
106+
90107
# mobile/.env — comment out STAGE block, activate LOCAL block with real IP
91108
MOBILE_ENV.write_text(
92109
f"# STAGE:\n"
@@ -130,13 +147,26 @@ def restore() -> None:
130147
BACKEND_ENV.write_text(content)
131148
print(" backend.dev.env restored to localhost")
132149

150+
# media.dev.env — back to localhost
151+
content = MEDIA_ENV.read_text()
152+
content = re.sub(r"^MEDIA_SERVER_BASE_URL=.*", "MEDIA_SERVER_BASE_URL=http://localhost:5001", content, flags=re.MULTILINE)
153+
MEDIA_ENV.write_text(content)
154+
print(" media.dev.env restored to localhost")
155+
133156
# web/.env.localdev — back to localhost
134157
content = WEB_ENV.read_text()
135158
content = re.sub(r'^NEXT_PUBLIC_API_BASE_URL=.*', 'NEXT_PUBLIC_API_BASE_URL="http://localhost:8888"', content, flags=re.MULTILINE)
136159
content = re.sub(r'^NEXT_PUBLIC_MEDIA_BASE_URL=.*', 'NEXT_PUBLIC_MEDIA_BASE_URL="http://localhost:5001"', content, flags=re.MULTILINE)
137160
WEB_ENV.write_text(content)
138161
print(" web/.env.localdev restored to localhost")
139162

163+
# web/.env.development — back to staging
164+
content = WEB_DEV_ENV.read_text()
165+
content = re.sub(r'^NEXT_PUBLIC_API_BASE_URL=.*', 'NEXT_PUBLIC_API_BASE_URL="https://next.couchershq.org/api"', content, flags=re.MULTILINE)
166+
content = re.sub(r'^NEXT_PUBLIC_MEDIA_BASE_URL=.*', 'NEXT_PUBLIC_MEDIA_BASE_URL="https://dev-user-media.couchershq.org"', content, flags=re.MULTILINE)
167+
WEB_DEV_ENV.write_text(content)
168+
print(" web/.env.development restored to staging")
169+
140170
# mobile/.env — back to staging mode
141171
MOBILE_ENV.write_text(MOBILE_ENV_DEFAULT)
142172
print(" mobile/.env restored to staging mode")

app/web/components/UserSummary.tsx

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ import ProfileLink from "components/ProfileLink/ProfileLink";
1313
import { LiteUser } from "proto/api_pb";
1414
import { BlockedUser } from "proto/blocking_pb";
1515
import React, { useState } from "react";
16+
import useIsScreenSizeOrSmaller from "utils/useIsScreenSizeOrSmaller";
1617

1718
import StrongVerificationBadge from "./StrongVerificationBadge";
1819

@@ -83,6 +84,7 @@ export default function UserSummary({
8384
},
8485
);
8586

87+
const isMobile = useIsScreenSizeOrSmaller("mobile");
8688
const [menuAnchorEl, setMenuAnchorEl] = useState<HTMLButtonElement | null>(
8789
null,
8890
);
@@ -158,11 +160,11 @@ export default function UserSummary({
158160
<ProfileLink
159161
userId={"userId" in user ? user.userId : undefined}
160162
username={user.username}
161-
openInNewTab
163+
openInNewTab={!isMobile}
162164
style={{ display: "flex", alignItems: "center" }}
163165
>
164166
{title}
165-
<StyledOpenInNewIcon />
167+
{!isMobile && <StyledOpenInNewIcon />}
166168
</ProfileLink>
167169
) : (
168170
title

docs/run-local-app-on-mobile.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,8 @@ python3 app/scripts/dev-mobile-setup.py --restore
4040
| File | Change |
4141
|------|--------|
4242
| `app/proxy/envoy.yaml` | Adds your IP to the CORS allow list |
43-
| `app/backend.dev.env` | Sets `COOKIE_DOMAIN` and media server URLs to your IP |
43+
| `app/backend.dev.env` | Sets `COOKIE_DOMAIN`, `MEDIA_SERVER_BASE_URL`, and `MEDIA_SERVER_UPLOAD_BASE_URL` |
44+
| `app/media.dev.env` | Sets `MEDIA_SERVER_BASE_URL` (needed for image upload response URLs) |
4445
| `app/web/.env.localdev` | Points API and media URLs at your IP |
46+
| `app/web/.env.development` | Points API and media URLs at your IP |
4547
| `app/mobile/.env` | Switches from staging to local dev mode |

0 commit comments

Comments
 (0)