Skip to content

Commit

Permalink
Make a responsibility more explicit in the analytics shared component…
Browse files Browse the repository at this point in the history
… #3329
  • Loading branch information
davidcmoulton committed May 8, 2024
1 parent 73a37ab commit f4c224f
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 15 deletions.
14 changes: 0 additions & 14 deletions src/read-side/html-pages/shared-components/analytics/analytics.ts
Expand Up @@ -63,10 +63,6 @@ const renderTagManagerNoScript = (tagManagerId: string) => `
<!-- End Google Tag Manager (noscript) -->
`;

const renderFathomScript = (fathomId: string) => `
<script src="https://cdn.usefathom.com/script.js" data-site="${fathomId}" defer data-cookieconsent="ignore"></script>
`;

export const googleTagManager = (userId: O.Option<UserId>): HtmlFragment => pipe(
process.env.GOOGLE_TAG_MANAGER_ID,
O.fromNullable,
Expand All @@ -86,13 +82,3 @@ export const googleTagManagerNoScript = (): HtmlFragment => pipe(
),
toHtmlFragment,
);

export const fathom = (): HtmlFragment => pipe(
process.env.FATHOM_SITE_ID,
O.fromNullable,
O.match(
constant(''),
renderFathomScript,
),
toHtmlFragment,
);
17 changes: 17 additions & 0 deletions src/read-side/html-pages/shared-components/analytics/fathom.ts
@@ -0,0 +1,17 @@
import * as O from 'fp-ts/Option';
import { constant, pipe } from 'fp-ts/function';
import { HtmlFragment, toHtmlFragment } from '../../../../types/html-fragment';

const renderFathomScript = (fathomId: string) => `
<script src="https://cdn.usefathom.com/script.js" data-site="${fathomId}" defer data-cookieconsent="ignore"></script>
`;

export const fathom = (): HtmlFragment => pipe(
process.env.FATHOM_SITE_ID,
O.fromNullable,
O.match(
constant(''),
renderFathomScript,
),
toHtmlFragment,
);
@@ -1 +1,2 @@
export { fathom, googleTagManager, googleTagManagerNoScript } from './analytics';
export { googleTagManager, googleTagManagerNoScript } from './analytics';
export { fathom } from './fathom';

1 comment on commit f4c224f

@davidcmoulton
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Relates to ticket #3229 (not 3329 as mentioned in the commit message).

Please sign in to comment.