Skip to content

Commit d792eb9

Browse files
author
Juarez Mota
committed
feat: add identity headers to support banner requests when user is signed in
1 parent 1d87623 commit d792eb9

File tree

2 files changed

+17
-5
lines changed

2 files changed

+17
-5
lines changed

dotcom-rendering/src/components/TopBarSupport.importable.tsx

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55
import { css } from '@emotion/react';
66
import { getCookie, isUndefined } from '@guardian/libs';
77
import type { ComponentEvent } from '@guardian/ophan-tracker-js';
8-
import { getHeader } from '@guardian/support-dotcom-components';
98
import type {
109
HeaderPayload,
1110
ModuleData,
@@ -21,8 +20,10 @@ import {
2120
getPurchaseInfo,
2221
shouldHideSupportMessaging,
2322
} from '../lib/contributions';
23+
import { getOptionsHeaders } from '../lib/identity';
24+
import { getHeader } from '../lib/sdcRequests';
2425
import { useBetaAB } from '../lib/useAB';
25-
import { useIsSignedIn } from '../lib/useAuthStatus';
26+
import { useAuthStatus } from '../lib/useAuthStatus';
2627
import { useCountryCode } from '../lib/useCountryCode';
2728
import { usePageViewId } from '../lib/usePageViewId';
2829
import { useConfig } from './ConfigContext';
@@ -56,7 +57,11 @@ const ReaderRevenueLinksRemote = ({
5657
useState<ModuleData<HeaderProps> | null>(null);
5758
const [SupportHeader, setSupportHeader] =
5859
useState<React.ElementType<HeaderProps> | null>(null);
59-
const isSignedIn = useIsSignedIn();
60+
const authStatus = useAuthStatus();
61+
const isSignedIn =
62+
authStatus.kind === 'Pending'
63+
? 'Pending'
64+
: authStatus.kind === 'SignedIn';
6065

6166
const { renderingTarget } = useConfig();
6267
const abTests = useBetaAB();
@@ -90,7 +95,12 @@ const ReaderRevenueLinksRemote = ({
9095
},
9196
};
9297

93-
getHeader(contributionsServiceUrl, requestData)
98+
const headers =
99+
authStatus.kind === 'SignedIn'
100+
? getOptionsHeaders(authStatus).headers
101+
: undefined;
102+
103+
getHeader(contributionsServiceUrl, requestData, headers)
94104
.then((response: ModuleDataResponse<HeaderProps>) => {
95105
if (!response.data) {
96106
return null;
@@ -131,6 +141,7 @@ const ReaderRevenueLinksRemote = ({
131141
pageViewId,
132142
pageUrl,
133143
abTests,
144+
authStatus,
134145
]);
135146

136147
if (SupportHeader !== null && supportHeaderResponse) {

dotcom-rendering/src/lib/sdcRequests.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -112,5 +112,6 @@ export const getGutterLiveblog = (
112112
export const getHeader = (
113113
baseUrl: string,
114114
payload: HeaderPayload,
115+
headers?: HeadersInit,
115116
): Promise<ModuleDataResponse<HeaderProps>> =>
116-
getModuleData('header', baseUrl, payload);
117+
getModuleData('header', baseUrl, payload, headers);

0 commit comments

Comments
 (0)