Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Make a responsibility more explicit in the analytics shared component…
… #3329
- Loading branch information
1 parent
73a37ab
commit f4c224f
Showing
3 changed files
with
19 additions
and
15 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
17 changes: 17 additions & 0 deletions
17
src/read-side/html-pages/shared-components/analytics/fathom.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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, | ||
); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,2 @@ | ||
export { fathom, googleTagManager, googleTagManagerNoScript } from './analytics'; | ||
export { googleTagManager, googleTagManagerNoScript } from './analytics'; | ||
export { fathom } from './fathom'; |
f4c224f
There was a problem hiding this comment.
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).