Skip to content

Commit fc97034

Browse files
First draft of Matomo analytics (#78)
* add matomo analytics component Signed-off-by: Jess Chitas <[email protected]> * Add global analytics with client module - Replace page-specific Matomo component with global client module - Analytics runs on all pages automatically via clientModules - Restrict analytics to localhost and Netlify preview deployments only - Use site ID 6 for all environments - Support SPA navigation tracking for page views Signed-off-by: Pete Cheslock <[email protected]> * Refactor Matomo analytics initialization and tracking - Simplified the analytics initialization process by consolidating logic into `resolveMatomoSiteId` and `ensureMatomoInitialized` functions. - Updated site ID resolution to support different environments (localhost, Netlify, production). - Enhanced SPA navigation tracking by ensuring page views are tracked on route updates. - Removed unnecessary checks and streamlined the code for better readability and maintainability. Signed-off-by: Pete Cheslock <[email protected]> * Add privacy policy Signed-off-by: Pete Cheslock <[email protected]> * Add github forks link in header, refactor footer social links and enhance analytics tracking - Enhanced analytics tracking for same-page anchor clicks to improve user interaction insights. - Updated footer social links to use a new structure with improved accessibility and styling. - Move footer image links to existing images in repo - Cleaned up unused code and comments in the configuration file. Signed-off-by: Pete Cheslock <[email protected]> * Enhance analytics tracking to capture same page anchors - Enhanced analytics tracking for same-page anchor clicks to prevent double-counting. - Improved the initialization of analytics and anchor tracking on page load. - Added new dependencies for Babel and Jest to improve testing and build processes. Signed-off-by: Pete Cheslock <[email protected]> --------- Signed-off-by: Jess Chitas <[email protected]> Signed-off-by: Pete Cheslock <[email protected]> Co-authored-by: Jess Chitas <[email protected]>
1 parent 0affdda commit fc97034

File tree

11 files changed

+3230
-357
lines changed

11 files changed

+3230
-357
lines changed

babel.config.cjs

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
module.exports = {
2+
presets: [
3+
[
4+
'@babel/preset-env',
5+
{
6+
targets: { node: 'current' },
7+
},
8+
],
9+
],
10+
};
11+
12+

docusaurus.config.js

Lines changed: 36 additions & 98 deletions
Original file line numberDiff line numberDiff line change
@@ -7,13 +7,6 @@
77
import { themes as prismThemes } from "prism-react-renderer";
88
import remoteContentPlugins from "./remote-content/remote-content.js";
99

10-
//import GHiconUrl from "./docs/assets/github-mark-white.svg";
11-
//import LIiconURL from "./docs/assets/linkedin-mark-white.svg";
12-
//import SlackiconURL from "./docs/assets/slack-mark-white.png";
13-
//import RedditiconURL from "./docs/assets/reddit-mark-white-png";
14-
//import XiconURL from "./docs/assets/x-mark-white.png";
15-
16-
1710

1811
// This runs in Node.js - Don't use client-side code here (browser APIs, JSX...)
1912

@@ -95,6 +88,11 @@ const config = {
9588
}),
9689
],
9790
],
91+
92+
// Client modules - run on every page
93+
clientModules: [
94+
require.resolve('./src/clientModules/analytics.js'),
95+
],
9896

9997
// Plugins configuration
10098
plugins: [
@@ -160,9 +158,9 @@ const config = {
160158
},
161159
{ to: "/blog", label: "News", position: "left" },
162160
{
163-
href: "https://github.com/llm-d/",
164-
position: "right",
165-
className: "github",
161+
type: 'html',
162+
position: 'right',
163+
value: '<iframe src="https://ghbtns.com/github-btn.html?user=llm-d&repo=llm-d&type=star&count=true&size=large" frameborder="0" scrolling="0" width="170" height="30" title="GitHub Star" style="vertical-align: middle;"></iframe>',
166164
},
167165
],
168166
},
@@ -187,11 +185,6 @@ const config = {
187185
label: "Overview",
188186
to: "docs/architecture",
189187
},
190-
/* {
191-
label: "FAQ",
192-
to: "docs/architecture/faq.md",
193-
},
194-
*/
195188
],
196189
},
197190
{
@@ -220,13 +213,8 @@ const config = {
220213
to: "/blog",
221214
},
222215
{
223-
html: `
224-
<a href="https://github.com/llm-d/" target="_blank" rel="noreferrer noopener" aria-label="GitHub Icon">
225-
<img class="github-footer"
226-
src="https://raw.githubusercontent.com/KPRoche/iconography/refs/heads/main/assets/github-mark-white.png"
227-
alt="GitHub Icon" width="30px" height="auto" margin="5px"/>
228-
</a>
229-
`,
216+
label: "Privacy Policy",
217+
href: "https://www.redhat.com/en/about/privacy-policy",
230218
},
231219
],
232220
},
@@ -235,66 +223,36 @@ const config = {
235223
items: [
236224
{
237225
html: `
238-
<a href="https://linkedin.com/company/llm-d" target="_blank" rel="noreferrer noopener" aria-label="LinkedIn Icon">
239-
<img
240-
class="linkedin"
241-
src="https://raw.githubusercontent.com/KPRoche/iconography/refs/heads/main/assets/linkedin-mark-white.png"
242-
alt="LinkedIn Icon"
243-
width="30px"
244-
height="auto"
245-
margin="5px"/>
246-
247-
</a>
248-
`,
249-
},
250-
251-
{
252-
html: `
253-
<a href="https://llm-d.slack.com" target="_blank" rel="noreferrer noopener" aria-label="Slack Icon">
254-
<img class="slack"
255-
src="https://raw.githubusercontent.com/KPRoche/iconography/refs/heads/main/assets/slack-mark-white.png"
256-
alt="Slack Icon" width="30px" height="auto" margin="5px"/>
257-
</a>
258-
`,
259-
},
260-
{
261-
html: `
262-
<a href="https://inviter.co/llm-d-slack" target="_blank" rel="noreferrer noopener" aria-label="Inviter Icon">
263-
<span class="button-link">Join our Slack</span>
264-
<img class="inviter"
265-
src="https://raw.githubusercontent.com/KPRoche/iconography/refs/heads/main/assets/inviter-logo.png"
266-
alt="Slack Inviter link" width="30px" height="auto" margin="5px"/>
267-
</a>
268-
`,
269-
},
270-
271-
{
272-
html: `
273-
<a href="https://www.reddit.com/r/llm_d/" target="_blank" rel="noreferrer noopener" aria-label="Reddit Icon">
274-
<img class="reddit"
275-
src="https://raw.githubusercontent.com/KPRoche/iconography/refs/heads/main/assets/reddit-mark-white.png"
276-
alt="Reddit Icon"
277-
width="30px"
278-
height="auto"
279-
margin="5px"/>
280-
</a>
281-
`,
282-
},
283-
{
284-
html: `
285-
<a href="https://x.com/_llm_d_" target="_blank" rel="noreferrer noopener" aria-label="X Icon">
286-
<img class="x"
287-
src="https://raw.githubusercontent.com/KPRoche/iconography/refs/heads/main/assets/x-mark-white.png"
288-
alt="X Icon"
289-
width="30px"
290-
height="auto" margin="5px"/>
291-
</a>
226+
<div class="footer-socials" role="navigation" aria-label="Social links">
227+
<div class="footer-socials-row">
228+
<a href="https://github.com/llm-d/" target="_blank" rel="noreferrer noopener" aria-label="GitHub">
229+
<img src="/img/new-social/github-mark-white.png" alt="GitHub" />
230+
</a>
231+
<a href="https://linkedin.com/company/llm-d" target="_blank" rel="noreferrer noopener" aria-label="LinkedIn">
232+
<img src="/img/new-social/linkedin-mark-white.png" alt="LinkedIn" />
233+
</a>
234+
<a href="https://llm-d.slack.com" target="_blank" rel="noreferrer noopener" aria-label="Slack">
235+
<img src="/img/new-social/slack-mark-white.png" alt="Slack" />
236+
</a>
237+
<a href="https://www.reddit.com/r/llm_d/" target="_blank" rel="noreferrer noopener" aria-label="Reddit">
238+
<img src="/img/new-social/reddit-mark-white.png" alt="Reddit" />
239+
</a>
240+
<a href="https://x.com/_llm_d_" target="_blank" rel="noreferrer noopener" aria-label="X / Twitter">
241+
<img src="/img/new-social/x-mark-white.png" alt="X / Twitter" />
242+
</a>
243+
</div>
244+
<div class="footer-socials-cta">
245+
<a href="https://inviter.co/llm-d-slack" target="_blank" rel="noreferrer noopener" aria-label="Join our Slack">
246+
<span class="button-link">Join our Slack</span>
247+
<img src="/img/new-social/inviter-logo.png" alt="Slack Invite" />
248+
</a>
249+
</div>
250+
</div>
292251
`,
293252
},
294253
],
295254
},
296255
],
297-
// copyright: `Copyright © ${new Date().getFullYear()} My Project, Inc. Built with Docusaurus.`,
298256
},
299257
prism: {
300258
theme: prismThemes.vsLight,
@@ -306,24 +264,4 @@ const config = {
306264

307265
export default config;
308266

309-
// {
310-
// title: "Social",
311-
// items: [
312-
// {
313-
// className: "linkedin",
314-
// href: "https://linkedin.com/company/llm-d",
315-
// },
316-
// {
317-
// className: "slack",
318-
// href: "https://llm-d.slack.com",
319-
// },
320-
// {
321-
// className: "reddit",
322-
// href: "https://www.reddit.com/r/llm_d/",
323-
// },
324-
// {
325-
// className: "x",
326-
// href: "https://x.com/_llm_d_",
327-
// },
328-
// ],
329-
// },
267+

jest.config.js

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
module.exports = {
2+
testEnvironment: 'jsdom',
3+
verbose: false,
4+
transform: {
5+
'^.+\\.jsx?$': 'babel-jest',
6+
},
7+
moduleNameMapper: {
8+
'^@docusaurus/ExecutionEnvironment$': '<rootDir>/tests/mocks/ExecutionEnvironment.js',
9+
},
10+
};
11+
12+

0 commit comments

Comments
 (0)