Skip to content

Commit 13ca970

Browse files
committed
Move getCloudUrlFromRegion to shared/utils/urls
1 parent acfe028 commit 13ca970

10 files changed

Lines changed: 23 additions & 20 deletions

File tree

apps/code/src/main/services/github-integration/service.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { getCloudUrlFromRegion } from "@shared/constants/oauth";
1+
import { getCloudUrlFromRegion } from "@shared/utils/urls";
22
import { shell } from "electron";
33
import { injectable } from "inversify";
44
import { logger } from "../../utils/logger";

apps/code/src/main/services/linear-integration/service.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { getCloudUrlFromRegion } from "@shared/constants/oauth.js";
1+
import { getCloudUrlFromRegion } from "@shared/utils/urls.js";
22
import { shell } from "electron";
33
import { injectable } from "inversify";
44
import { logger } from "../../utils/logger.js";

apps/code/src/main/services/oauth/service.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,10 @@ import * as crypto from "node:crypto";
22
import * as http from "node:http";
33
import type { Socket } from "node:net";
44
import {
5-
getCloudUrlFromRegion,
65
getOauthClientIdFromRegion,
76
OAUTH_SCOPES,
87
} from "@shared/constants/oauth";
8+
import { getCloudUrlFromRegion } from "@shared/utils/urls";
99
import { shell } from "electron";
1010
import { inject, injectable } from "inversify";
1111
import { MAIN_TOKENS } from "../../di/tokens";

apps/code/src/renderer/features/auth/stores/authStore.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { useSeatStore } from "@features/billing/stores/seatStore";
22
import { PostHogAPIClient } from "@renderer/api/posthogClient";
33
import { trpcClient } from "@renderer/trpc/client";
4-
import { getCloudUrlFromRegion } from "@shared/constants/oauth";
4+
import { getCloudUrlFromRegion } from "@shared/utils/urls";
55
import { ANALYTICS_EVENTS } from "@shared/types/analytics";
66
import type { CloudRegion } from "@shared/types/oauth";
77
import { useNavigationStore } from "@stores/navigationStore";

apps/code/src/renderer/features/inbox/components/InboxSignalsTab.tsx

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,10 +54,14 @@ import {
5454
Text,
5555
Tooltip,
5656
} from "@radix-ui/themes";
57+
<<<<<<< HEAD
5758
import explorerHog from "@renderer/assets/images/explorer-hog.png";
5859
import graphsHog from "@renderer/assets/images/graphs-hog.png";
5960
import mailHog from "@renderer/assets/images/mail-hog.png";
6061
import { getCloudUrlFromRegion } from "@shared/constants/oauth";
62+
=======
63+
import { getCloudUrlFromRegion } from "@shared/utils/urls";
64+
>>>>>>> ed81b3be (Move getCloudUrlFromRegion to shared/utils/urls)
6165
import type {
6266
SignalReportArtefact,
6367
SignalReportsQueryParams,

apps/code/src/renderer/features/sessions/service/service.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -185,7 +185,7 @@ vi.mock("@utils/notifications", () => ({
185185
vi.mock("@renderer/utils/toast", () => ({
186186
toast: { error: vi.fn() },
187187
}));
188-
vi.mock("@shared/constants/oauth", () => ({
188+
vi.mock("@shared/utils/urls", () => ({
189189
getCloudUrlFromRegion: () => "https://api.anthropic.com",
190190
}));
191191
vi.mock("@utils/session", async () => {

apps/code/src/renderer/features/sessions/service/service.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ import { DEFAULT_GATEWAY_MODEL } from "@posthog/agent/gateway-models";
3030
import { getIsOnline } from "@renderer/stores/connectivityStore";
3131
import { trpcClient } from "@renderer/trpc/client";
3232
import { toast } from "@renderer/utils/toast";
33-
import { getCloudUrlFromRegion } from "@shared/constants/oauth";
33+
import { getCloudUrlFromRegion } from "@shared/utils/urls";
3434
import {
3535
type CloudTaskUpdatePayload,
3636
type EffortLevel,

apps/code/src/renderer/features/sidebar/components/ProjectSwitcher.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ import {
3030
Text,
3131
} from "@radix-ui/themes";
3232
import { trpcClient } from "@renderer/trpc/client";
33-
import { getCloudUrlFromRegion } from "@shared/constants/oauth";
33+
import { getCloudUrlFromRegion } from "@shared/utils/urls";
3434
import { isMac } from "@utils/platform";
3535
import { useCallback, useEffect, useRef, useState } from "react";
3636
import "./ProjectSwitcher.css";

apps/code/src/shared/constants/oauth.ts

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -53,18 +53,6 @@ export const REGION_LABELS: Record<CloudRegion, string> = {
5353
export const TOKEN_REFRESH_BUFFER_MS = 30 * 60 * 1000; // 30 minutes before expiry
5454
export const TOKEN_REFRESH_FORCE_MS = 60 * 1000; // Force refresh when <1 min to expiry, even with active sessions
5555

56-
export function getCloudUrlFromRegion(region: CloudRegion): string {
57-
switch (region) {
58-
case "us":
59-
return "https://us.posthog.com";
60-
case "eu":
61-
return "https://eu.posthog.com";
62-
case "dev":
63-
return "http://localhost:8010";
64-
}
65-
}
66-
67-
6856
export function getOauthClientIdFromRegion(region: CloudRegion): string {
6957
switch (region) {
7058
case "us":

apps/code/src/shared/utils/urls.ts

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,16 @@
11
import { useAuthStore } from "@features/auth/stores/authStore";
2-
import { getCloudUrlFromRegion } from "@shared/constants/oauth";
2+
import type { CloudRegion } from "@shared/types/oauth";
3+
4+
export function getCloudUrlFromRegion(region: CloudRegion): string {
5+
switch (region) {
6+
case "us":
7+
return "https://us.posthog.com";
8+
case "eu":
9+
return "https://eu.posthog.com";
10+
case "dev":
11+
return "http://localhost:8010";
12+
}
13+
}
314

415
export function getPostHogUrl(path: string): string {
516
const region = useAuthStore.getState().cloudRegion;

0 commit comments

Comments
 (0)