Skip to content

Commit aab7b2d

Browse files
Merge pull request #134 from threshold-network/chore/cookie3
chore: add cookie3 script
2 parents de5c743 + 29624c8 commit aab7b2d

File tree

3 files changed

+26
-1
lines changed

3 files changed

+26
-1
lines changed

.env.example

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,3 @@
11
GATSBY_GTM_ID=GTM-XXXXXXX
2-
GATSBY_GTM_SUPPORT=false
2+
GATSBY_GTM_SUPPORT=false
3+
GATSBY_COOKIE3_SITE_ID=XXXXXXXXXXXXXXXX

.github/workflows/ci.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ jobs:
3636
env:
3737
PUBLIC_URL: /${{ github.head_ref }}
3838
GATSBY_SUBGRAPH_API_KEY: ${{ secrets.SUBGRAPH_API_KEY }}
39+
GATSBY_COOKIE3_SITE_ID: ${{ secrets.COOKIE3_SITE_ID }}
3940

4041
- name: Build
4142
if: github.event_name == 'push'
@@ -48,6 +49,7 @@ jobs:
4849
GATSBY_GTM_SUPPORT: true
4950
GATSBY_GTM_ID: ${{ secrets.GTM_ID }}
5051
GATSBY_SUBGRAPH_API_KEY: ${{ secrets.SUBGRAPH_API_KEY }}
52+
GATSBY_COOKIE3_SITE_ID: ${{ secrets.COOKIE3_SITE_ID }}
5153

5254
- uses: actions/upload-artifact@v4
5355
with:

gatsby-ssr.tsx

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,23 @@
1+
import React from "react"
2+
import type { GatsbySSR } from "gatsby"
3+
4+
const COOKIE3_SCRIPT_VERSION = "0.11.24"
5+
6+
export const onRenderBody: GatsbySSR["onRenderBody"] = ({
7+
setHeadComponents,
8+
}) => {
9+
if (process.env.GATSBY_COOKIE3_SITE_ID) {
10+
setHeadComponents([
11+
<script
12+
key="cookie3-analytics"
13+
src={`https://cdn.markfi.xyz/scripts/analytics/${COOKIE3_SCRIPT_VERSION}/cookie3.analytics.min.js`}
14+
integrity="sha384-lp8ATuGdLnhwAutE0SOVmSINtZ4DObSNjODmbbjYxaX92FOPBLyZjN+wVIaoK4Qy"
15+
crossOrigin="anonymous"
16+
{...{ "site-id": process.env.GATSBY_COOKIE3_SITE_ID }}
17+
async={true}
18+
/>,
19+
])
20+
}
21+
}
22+
123
export { wrapPageElement } from "./gatsby-browser"

0 commit comments

Comments
 (0)