1 | import { useShopConfig } from './useShopConfig';
|
2 | export function usePreconnectLinks({ ga = false, gtm = false } = {}) {
|
3 | const { apolloConfig } = useShopConfig();
|
4 |
|
5 | const staticLinks = [
|
6 | {
|
7 | href: 'https://cdn.polyfill.io',
|
8 | crossOrigin: null
|
9 | },
|
10 | (apolloConfig === null || apolloConfig === void 0 ? void 0 : apolloConfig.graphQLURI) && {
|
11 | href: apolloConfig === null || apolloConfig === void 0 ? void 0 : apolloConfig.graphQLURI,
|
12 | crossOrigin: null
|
13 | }
|
14 | ].filter(Boolean);
|
15 |
|
16 | const gaLinks = ga
|
17 | ? [
|
18 | 'https://www.google-analytics.com',
|
19 | 'https://www.google.com',
|
20 | 'https://stats.g.doubleclick.net'
|
21 | ]
|
22 | : [];
|
23 |
|
24 | const gtmLinks = gtm ? ['https://www.googletagmanager.com'] : [];
|
25 | return [
|
26 | ...staticLinks,
|
27 | ...gaLinks.concat(gtmLinks).map(href => ({ href, crossOrigin: null }))
|
28 | ];
|
29 | }
|
30 |
|
\ | No newline at end of file |