Skip to content

Commit 45554e9

Browse files
rebelchrisclaude
andauthored
feat: pass referrer to boot endpoint for default theme (#5298)
Co-authored-by: Claude Opus 4.5 <noreply@anthropic.com>
1 parent 647eb97 commit 45554e9

File tree

3 files changed

+34
-10
lines changed

3 files changed

+34
-10
lines changed

packages/extension/src/background/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ const sendBootData = async (_, tab: Tabs.Tab) => {
5252

5353
const [deviceId, boot] = await Promise.all([
5454
getOrGenerateDeviceId(),
55-
getBootData('companion', href),
55+
getBootData({ app: 'companion', url: href }),
5656
]);
5757

5858
let settingsOutput = boot.settings;

packages/shared/src/contexts/BootProvider.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -178,7 +178,8 @@ export const BootDataProvider = ({
178178
} = useQuery<Partial<Boot>>({
179179
queryKey: BOOT_QUERY_KEY,
180180
queryFn: async () => {
181-
const result = await getBootData(app);
181+
const pathname = globalThis?.location?.pathname;
182+
const result = await getBootData({ app, pathname });
182183
preloadFeedsRef.current({ feeds: result.feeds, user: result.user });
183184

184185
return result;

packages/shared/src/lib/boot.ts

Lines changed: 31 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -86,13 +86,28 @@ export type BootCacheData = Pick<
8686
| 'geo'
8787
> & { lastModifier?: string; isAndroidApp?: boolean };
8888

89-
const getBootURL = (app: string, url?: string) => {
89+
/**
90+
* Get normalized referrer type from pathname
91+
* Only returns known referrer identifiers for privacy
92+
*/
93+
const getReferrerType = (pathname?: string): string | undefined => {
94+
if (pathname?.startsWith('/recruiter')) {
95+
return 'recruiter';
96+
}
97+
return undefined;
98+
};
99+
100+
const getBootURL = (app: string, url?: string, pathname?: string) => {
90101
const appRoute = app === 'companion' ? '/companion' : '';
91102
const params = new URLSearchParams();
92103
params.append('v', process.env.CURRENT_VERSION);
93104
if (url) {
94105
params.append('url', url);
95106
}
107+
const referrer = getReferrerType(pathname);
108+
if (referrer) {
109+
params.append('referrer', referrer);
110+
}
96111

97112
return `${apiUrl}/boot${appRoute}?${params}`;
98113
};
@@ -108,19 +123,27 @@ const enrichBootWithFeatures = async (boot: Boot): Promise<Boot> => {
108123
return { ...boot, exp: { ...boot.exp, features: JSON.parse(features) } };
109124
};
110125

111-
export async function getBootData(
112-
app: string,
113-
url?: string,
114-
options?: Record<'cookies', string>,
115-
): Promise<Boot> {
116-
const bootURL = getBootURL(app, url);
126+
interface GetBootDataParams {
127+
app: string;
128+
url?: string;
129+
cookies?: string;
130+
pathname?: string;
131+
}
132+
133+
export async function getBootData({
134+
app,
135+
url,
136+
cookies,
137+
pathname,
138+
}: GetBootDataParams): Promise<Boot> {
139+
const bootURL = getBootURL(app, url, pathname);
117140
const res = await fetch(bootURL, {
118141
method: 'GET',
119142
credentials: 'include',
120143
headers: {
121144
app,
122145
'Content-Type': 'application/json',
123-
...(options?.cookies && { Cookie: options.cookies }),
146+
...(cookies && { Cookie: cookies }),
124147
},
125148
});
126149
const result = await res.json();

0 commit comments

Comments
 (0)