Skip to content

Commit 6fe2d57

Browse files
authored
Dashboard: Fix GA4 banner (#13914)
1 parent f798657 commit 6fe2d57

File tree

4 files changed

+26
-12
lines changed

4 files changed

+26
-12
lines changed

packages/design-system/src/components/button/button.tsx

-1
Original file line numberDiff line numberDiff line change
@@ -186,7 +186,6 @@ const buttonColors = {
186186

187187
const rectangle = css<ElementProps>`
188188
${({ $type }) => $type && buttonColors[$type]};
189-
min-width: 1px;
190189
min-height: 1em;
191190
border-radius: ${({ theme }) => theme.borders.radius.small};
192191

packages/wp-dashboard/src/components/editorSettings/googleAnalytics/index.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -346,7 +346,7 @@ function GoogleAnalyticsSettings({
346346
</DropdownContainer>
347347
</>
348348
)}
349-
{!googleAnalyticsId || googleAnalyticsId.startsWith('UA-') ? (
349+
{googleAnalyticsId.startsWith('UA-') ? (
350350
<WarningContainer>
351351
<WarningIcon aria-hidden />
352352
<Message>
@@ -381,7 +381,7 @@ function GoogleAnalyticsSettings({
381381
}}
382382
>
383383
{__(
384-
'As <a>previously announced</a>, Universal Analytics will stop processing new visits starting <b>July 1, 2023</b>. We recommend switching to <a2>Google Analytics 4</a2> (GA4), our analytics product of record.',
384+
'Universal Analytics <a>stopped processing new visits</a> starting <b>July 1, 2023</b>. We recommend switching to <a2>Google Analytics 4</a2> (GA4).',
385385
'web-stories'
386386
)}
387387
</TranslateWithMarkup>

packages/wp-dashboard/src/components/ga4Banner/index.js

+20-5
Original file line numberDiff line numberDiff line change
@@ -59,9 +59,24 @@ const StyledLink = styled(Link)`
5959

6060
function GoogleAnalytics4BannerContainer() {
6161
const {
62+
capabilities: { canManageSettings } = {},
6263
plugins: { siteKit = {} },
6364
} = useConfig();
6465

66+
const fetchSettings = useEditorSettings(
67+
({
68+
actions: {
69+
settingsApi: { fetchSettings },
70+
},
71+
}) => fetchSettings
72+
);
73+
74+
useEffect(() => {
75+
if (canManageSettings) {
76+
fetchSettings();
77+
}
78+
}, [canManageSettings, fetchSettings]);
79+
6580
const isUsingUniversalAnalytics = useEditorSettings(
6681
({
6782
state: {
@@ -121,7 +136,7 @@ function GoogleAnalytics4BannerContainer() {
121136
}}
122137
>
123138
{__(
124-
'As <a>previously announced</a>, Universal Analytics will stop processing new visits starting <b>July 1, 2023</b>. We recommend switching to <a2>Google Analytics 4</a2> (GA4), our analytics product of record.',
139+
'Universal Analytics <a>stopped processing new visits</a> starting <b>July 1, 2023</b>. We recommend switching to <a2>Google Analytics 4</a2> (GA4).',
125140
'web-stories'
126141
)}
127142
</TranslateWithMarkup>
@@ -144,7 +159,7 @@ export default function GoogleAnalytics4Banner() {
144159
currentPath: state.currentPath,
145160
hasAvailableRoutes: state.availableRoutes.length > 0,
146161
}));
147-
const headerEl = useRef(null);
162+
const headerRef = useRef(null);
148163
const [, forceUpdate] = useState(false);
149164

150165
useEffect(() => {
@@ -159,14 +174,14 @@ export default function GoogleAnalytics4Banner() {
159174
EDITOR_SETTINGS_ROUTE,
160175
].includes(currentPath)
161176
) {
162-
headerEl.current = document.getElementById('body-view-options-header');
177+
headerRef.current = document.getElementById('body-view-options-header');
163178
forceUpdate((value) => !value);
164179
}
165180
}, [currentPath, hasAvailableRoutes]);
166181

167-
if (!headerEl.current) {
182+
if (!headerRef.current) {
168183
return null;
169184
}
170185

171-
return createPortal(<GoogleAnalytics4BannerContainer />, headerEl.current);
186+
return createPortal(<GoogleAnalytics4BannerContainer />, headerRef.current);
172187
}

packages/wp-dashboard/src/components/updateBanner/index.js

+4-4
Original file line numberDiff line numberDiff line change
@@ -143,7 +143,7 @@ export default function UpdateBanner() {
143143
currentPath: state.currentPath,
144144
hasAvailableRoutes: state.availableRoutes.length > 0,
145145
}));
146-
const headerEl = useRef(null);
146+
const headerRef = useRef(null);
147147
const [, forceUpdate] = useState(false);
148148

149149
useEffect(() => {
@@ -158,14 +158,14 @@ export default function UpdateBanner() {
158158
EDITOR_SETTINGS_ROUTE,
159159
].includes(currentPath)
160160
) {
161-
headerEl.current = document.getElementById('body-view-options-header');
161+
headerRef.current = document.getElementById('body-view-options-header');
162162
forceUpdate((value) => !value);
163163
}
164164
}, [currentPath, hasAvailableRoutes]);
165165

166-
if (!headerEl.current) {
166+
if (!headerRef.current) {
167167
return null;
168168
}
169169

170-
return createPortal(<UpdateBannerContainer />, headerEl.current);
170+
return createPortal(<UpdateBannerContainer />, headerRef.current);
171171
}

0 commit comments

Comments
 (0)