From 3b41a52185a5cacff379eece345aaaf87647a2d8 Mon Sep 17 00:00:00 2001 From: Braian Mellor Date: Tue, 15 Oct 2024 13:04:11 -0300 Subject: [PATCH] fix: isAppleSilicon using withClientHints (#931) --- TODO.md | 3 ++- src/hooks/useAdvancedUserAgentData.ts | 5 ++++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/TODO.md b/TODO.md index eff685b0..68f3bdfd 100644 --- a/TODO.md +++ b/TODO.md @@ -4,6 +4,7 @@ | :------------------------------------------------------------------------------------ | :--------------------------------------------------------------------: | :----------------------------------------------------------------------------------------------------------- | | [src/variables.ts](src/variables.ts#L1) | [#323](https://github.com/decentraland/decentraland-gatsby/issues/323) | remove on v6, move to ./dom/types.ts | | [src/components/HTML.tsx](src/components/HTML.tsx#L1) | [#323](https://github.com/decentraland/decentraland-gatsby/issues/323) | remove on v6 | +| [src/hooks/useAdvancedUserAgentData.ts](src/hooks/useAdvancedUserAgentData.ts#L1) | [@2fd](https://github.com/2fd) | add Docs, set as good practice | | [src/hooks/useEditor.ts](src/hooks/useEditor.ts#L1) | [@2fd](https://github.com/2fd) | replace for Formik and Yup on v6 | | [src/hooks/useEntityStore.ts](src/hooks/useEntityStore.ts#L1) | [#323](https://github.com/decentraland/decentraland-gatsby/issues/323) | remove on v6 | | [src/hooks/useEntityStoreSelector.ts](src/hooks/useEntityStoreSelector.ts#L1) | [#323](https://github.com/decentraland/decentraland-gatsby/issues/323) | remove on v6 | @@ -20,7 +21,6 @@ | [src/hooks/useStore.ts](src/hooks/useStore.ts#L1) | [#323](https://github.com/decentraland/decentraland-gatsby/issues/323) | remove on v6 | | [src/hooks/useTransaction.ts](src/hooks/useTransaction.ts#L1) | [@2fd](https://github.com/2fd) | looks to big, refactor? | | [src/hooks/useURLSearchParams.ts](src/hooks/useURLSearchParams.ts#L1) | [#323](https://github.com/decentraland/decentraland-gatsby/issues/323) | remove on v6 | -| [src/hooks/useUserAgentData.ts](src/hooks/useUserAgentData.ts#L1) | [@2fd](https://github.com/2fd) | add Docs, set as good practice | | [src/hooks/useWindowScroll.ts](src/hooks/useWindowScroll.ts#L1) | [@2fd](https://github.com/2fd) | check for a better options, may cause a lot of unnecessary re renders | | [src/utils/EntityStore.ts](src/utils/EntityStore.ts#L1) | [#323](https://github.com/decentraland/decentraland-gatsby/issues/323) | remove on v6 | | [src/utils/isMobile.ts](src/utils/isMobile.ts#L1) | [#323](https://github.com/decentraland/decentraland-gatsby/issues/323) | remove on v6, use hook useUserAgentData | @@ -31,6 +31,7 @@ | [src/components/Layout/Layout.tsx](src/components/Layout/Layout.tsx#L316) | [#323](https://github.com/decentraland/decentraland-gatsby/issues/323) | remove on v6 use bem notation | | [src/context/Auth/AuthProvider.tsx](src/context/Auth/AuthProvider.tsx#L44) | | Remove after all dApps get the user identity from localhost | | [src/entities/Blockchain/keys.ts](src/entities/Blockchain/keys.ts#L1) | [#323](https://github.com/decentraland/decentraland-gatsby/issues/323) | remove on v6 | +| [src/entities/Slack/utils.ts](src/entities/Slack/utils.ts#L12) | | should we use @slack/web-api? | | [src/utils/api/Catalyst.ts](src/utils/api/Catalyst.ts#L67) | [#323](https://github.com/decentraland/decentraland-gatsby/issues/323) | remove on v6 | | [src/utils/api/Catalyst.ts](src/utils/api/Catalyst.ts#L79) | [#323](https://github.com/decentraland/decentraland-gatsby/issues/323) | remove on v6 | | [src/utils/api/Catalyst.ts](src/utils/api/Catalyst.ts#L122) | [#323](https://github.com/decentraland/decentraland-gatsby/issues/323) | remove on v6 | diff --git a/src/hooks/useAdvancedUserAgentData.ts b/src/hooks/useAdvancedUserAgentData.ts index d96aabf9..29a88eb1 100644 --- a/src/hooks/useAdvancedUserAgentData.ts +++ b/src/hooks/useAdvancedUserAgentData.ts @@ -43,6 +43,7 @@ export default function useAdvancedUserAgentData(): [ setLoading(true) const ua = new UAParser(navigator.userAgent) const uaData = ua.getResult() + const uaDataWithClientHints = await uaData.withClientHints() const browser = { name: uaData.browser.name ?? DEFAULT_VALUE, version: uaData.browser.version ?? DEFAULT_VALUE, @@ -64,7 +65,9 @@ export default function useAdvancedUserAgentData(): [ let architecture: string if (!cpuData.architecture) { architecture = - os.name === 'macOS' && isAppleSilicon(ua) ? 'arm64' : 'Unknown' + os.name === 'macOS' && isAppleSilicon(uaDataWithClientHints) + ? 'arm64' + : 'Unknown' } else { architecture = cpuData.architecture }