Skip to content

Commit 90de4a7

Browse files
authored
Integrate Pendo tracking script (#261)
1 parent 8bfe5d0 commit 90de4a7

File tree

5 files changed

+854
-769
lines changed

5 files changed

+854
-769
lines changed

i18n.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ const appLocales = [
1818
Locale.CHINESE,
1919
] as const
2020

21-
export type AppLocale = typeof appLocales[number]
21+
export type AppLocale = (typeof appLocales)[number]
2222

2323
export type AppTranslations = Translations & {
2424
[key in AppLocale]: {

package.json

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -20,19 +20,19 @@
2020
"pre-push": "yarn build"
2121
},
2222
"dependencies": {
23-
"@docsearch/react": "^3.3.0",
24-
"@edgeandnode/components": "^24.0.7",
23+
"@docsearch/react": "^3.3.2",
24+
"@edgeandnode/components": "^24.5.0",
2525
"@emotion/react": "^11.10.5",
26-
"@mdx-js/loader": "^2.1.5",
27-
"@mdx-js/react": "^2.1.5",
26+
"@mdx-js/loader": "^2.2.1",
27+
"@mdx-js/react": "^2.2.1",
2828
"@next/mdx": "^12.3.4",
2929
"@radix-ui/react-collapsible": "1.0.1",
3030
"@radix-ui/react-popover": "^1.0.2",
3131
"@radix-ui/react-visually-hidden": "^1.0.1",
3232
"@reach/auto-id": "^0.18.0",
3333
"lodash": "^4.17.21",
3434
"next": "^12.3.4",
35-
"next-seo": "^5.14.1",
35+
"next-seo": "^5.15.0",
3636
"prism-react-renderer": "^1.3.5",
3737
"react": "^17.0.2",
3838
"react-dom": "^17.0.2",
@@ -48,20 +48,20 @@
4848
"@svgr/webpack": "^6.5.1",
4949
"@types/color": "^3.0.3",
5050
"@types/lodash": "^4.14.191",
51-
"@types/node": "^16.18.4",
51+
"@types/node": "^16.18.11",
5252
"@types/react": "^17.0.52",
5353
"@types/react-dom": "^17.0.18",
5454
"acorn": "^8.8.1",
5555
"acorn-jsx": "^5.3.2",
56-
"eslint": "^8.28.0",
57-
"husky": "^8.0.2",
58-
"lint-staged": "^13.0.4",
56+
"eslint": "^8.31.0",
57+
"husky": "^8.0.3",
58+
"lint-staged": "^13.1.0",
5959
"path": "^0.12.7",
60-
"prettier": "^2.8.0",
60+
"prettier": "^2.8.2",
6161
"remark-frontmatter": "^4.0.1",
6262
"remark-mdx-frontmatter": "^2.1.1",
6363
"serialize-as-code": "^2.0.2",
64-
"typescript": "4.9.3",
64+
"typescript": "4.9.4",
6565
"unist-util-visit": "^4.1.1",
6666
"url": "^0.11.0"
6767
},

pages/_app.tsx

Lines changed: 39 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@ import { AppProps } from 'next/app'
33
import Head from 'next/head'
44
import NextLink from 'next/link'
55
import { useRouter } from 'next/router'
6-
import Script from 'next/script'
76
import { DefaultSeo, DefaultSeoProps } from 'next-seo'
87
import { useCallback, useMemo, useState } from 'react'
98
import useBus from 'use-bus'
@@ -105,55 +104,45 @@ const MyApp = ({ Component, pageProps }: AppProps) => {
105104
)
106105

107106
return (
108-
<>
109-
<Script id="tracking" type="module">{`
110-
const _paq = window._paq = window._paq || [];
111-
_paq.push(['trackPageView'], ['enableLinkTracking'], ['setTrackerUrl', 'https://thegraph.matomo.cloud/matomo.php'], ['setSiteId', '1']);
112-
const g = document.createElement('script');
113-
g.async = true;
114-
g.src = '//cdn.matomo.cloud/thegraph.matomo.cloud/matomo.js';
115-
document.body.append(g);
116-
`}</Script>
117-
<I18nProvider
118-
supportedLocales={supportedLocales}
119-
translations={translations}
120-
locale={locale}
121-
setLocale={setLocale}
122-
pathWithoutLocale={pathWithoutLocale}
123-
>
124-
<DefaultSeoWithLocale />
125-
<ThemeProvider disableSmoothScrolling={isSearchOpen ? true : disableSmoothScrolling} headComponent={Head}>
126-
<div sx={{ position: 'absolute', inset: 0, overflow: 'hidden' }}>
127-
<div
128-
sx={{
129-
position: 'absolute',
130-
top: 0,
131-
insetInline: 0,
132-
minHeight: '768px',
133-
backgroundImage: `url('${process.env.BASE_PATH}/img/page-background.png')`,
134-
backgroundSize: 'cover',
135-
backgroundPosition: 'center top',
136-
'@media (min-width: 1440px)': {
137-
aspectRatio: '1440/768',
138-
},
139-
}}
140-
/>
141-
</div>
142-
<Layout
143-
headerSticky
144-
headerContent={
145-
<div dir="ltr">
146-
<NavigationMarketing activeRoute="/docs" NextLink={NextLink} rightAlignItems={[localeSwitcher]} />
147-
</div>
148-
}
149-
mainContainer
150-
footerContent={<Footer localeSwitcher={localeSwitcher} />}
151-
>
152-
<Component {...pageProps} />
153-
</Layout>
154-
</ThemeProvider>
155-
</I18nProvider>
156-
</>
107+
<I18nProvider
108+
supportedLocales={supportedLocales}
109+
translations={translations}
110+
locale={locale}
111+
setLocale={setLocale}
112+
pathWithoutLocale={pathWithoutLocale}
113+
>
114+
<DefaultSeoWithLocale />
115+
<ThemeProvider disableSmoothScrolling={isSearchOpen ? true : disableSmoothScrolling} headComponent={Head}>
116+
<div sx={{ position: 'absolute', inset: 0, overflow: 'hidden' }}>
117+
<div
118+
sx={{
119+
position: 'absolute',
120+
top: 0,
121+
insetInline: 0,
122+
minHeight: '768px',
123+
backgroundImage: `url('${process.env.BASE_PATH}/img/page-background.png')`,
124+
backgroundSize: 'cover',
125+
backgroundPosition: 'center top',
126+
'@media (min-width: 1440px)': {
127+
aspectRatio: '1440/768',
128+
},
129+
}}
130+
/>
131+
</div>
132+
<Layout
133+
headerSticky
134+
headerContent={
135+
<div dir="ltr">
136+
<NavigationMarketing activeRoute="/docs" NextLink={NextLink} rightAlignItems={[localeSwitcher]} />
137+
</div>
138+
}
139+
mainContainer
140+
footerContent={<Footer localeSwitcher={localeSwitcher} />}
141+
>
142+
<Component {...pageProps} />
143+
</Layout>
144+
</ThemeProvider>
145+
</I18nProvider>
157146
)
158147
}
159148

pages/_document.tsx

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import Document, { DocumentContext, DocumentInitialProps, Head, Html, Main, NextScript } from 'next/document'
2+
import Script from 'next/script'
23

34
import { defaultLocale, extractLocaleFromPath, getHtmlAttributesForLocale, Locale } from '@edgeandnode/components'
45

@@ -33,6 +34,24 @@ export default class MyDocument extends Document {
3334
<body>
3435
<Main />
3536
<NextScript />
37+
<Script id="matomo" type="module" strategy="afterInteractive">{`
38+
const _paq = window._paq = window._paq || [];
39+
_paq.push(['trackPageView'], ['enableLinkTracking'], ['setTrackerUrl', 'https://thegraph.matomo.cloud/matomo.php'], ['setSiteId', '1']);
40+
const g = document.createElement('script');
41+
g.async = true;
42+
g.src = '//cdn.matomo.cloud/thegraph.matomo.cloud/matomo.js';
43+
document.body.append(g);
44+
`}</Script>
45+
<Script id="pendo" type="module" strategy="afterInteractive">{`
46+
(function(p,e,n,d,o){
47+
var v,w,x,y,z;o=p[d]=p[d]||{};o._q=o._q||[];
48+
v=['initialize','identify','updateOptions','pageLoad','track'];for(w=0,x=v.length;w<x;++w)(function(m){
49+
o[m]=o[m]||function(){o._q[m===v[0]?'unshift':'push']([m].concat([].slice.call(arguments,0)));};})(v[w]);
50+
y=e.createElement(n);y.async=!0;y.src='https://cdn.pendo.io/agent/static/5eb7ddca-220c-4327-47bf-a1916db8f489/pendo.js';
51+
z=e.getElementsByTagName(n)[0];z.parentNode.insertBefore(y,z);
52+
})(window,document,'script','pendo');
53+
pendo.initialize();
54+
`}</Script>
3655
</body>
3756
</Html>
3857
)

0 commit comments

Comments
 (0)