korbit-ai[bot] commented on code in PR #32607:
URL: https://github.com/apache/superset/pull/32607#discussion_r1990268190
##########
docs/docusaurus.config.ts:
##########
@@ -329,12 +329,15 @@ const config: Config = {
},
} satisfies ThemeConfig,
scripts: [
- '/script/matomo.js',
// {
// src:
'https://www.bugherd.com/sidebarv2.js?apikey=enilpiu7bgexxsnoqfjtxa',
// async: true,
// },
],
+ customFields: {
+ matomoUrl: 'https://analytics.apache.org',
+ matomoSiteId: '22',
Review Comment:
### Add Types for Matomo Configuration <sub></sub>
<details>
<summary>Tell me more</summary>
###### What is the issue?
Matomo configuration values are hardcoded without type definitions or
explanatory constants.
###### Why this matters
Without proper typing and descriptive constants, it's unclear what these
values represent and what valid inputs would be.
###### Suggested change ∙ *Feature Preview*
```typescript
interface CustomFields {
matomoUrl: string;
matomoSiteId: string;
}
const MATOMO_CONFIG = {
url: 'https://analytics.apache.org',
siteId: '22',
} as const;
customFields: {
matomoUrl: MATOMO_CONFIG.url,
matomoSiteId: MATOMO_CONFIG.siteId,
} satisfies CustomFields,
```
</details>
<sub>
[](https://app.korbit.ai/feedback/aa91ff46-6083-4491-9416-b83dd1994b51/277fb03f-e8b7-487c-8f1d-a59607948de1?suggestedFixEnabled=true)
💬 Looking for more details? Reply to this comment to chat with Korbit.
</sub>
<!--- korbi internal id:5862cebc-f72e-4a80-95e8-b39bd215f0d0 -->
##########
docs/src/theme/Root.js:
##########
@@ -0,0 +1,107 @@
+/* eslint-disable no-undef */
+import { useEffect } from 'react';
+import useDocusaurusContext from '@docusaurus/useDocusaurusContext';
+
+export default function Root({ children }) {
+ const { siteConfig } = useDocusaurusContext();
+ const { customFields } = siteConfig;
+
+ useEffect(() => {
+ const { matomoUrl, matomoSiteId } = customFields;
+
+ if (typeof window !== 'undefined') {
+ // Making testing easier, logging debug junk if we're in development
+ const devMode = window.location.hostname === 'localhost' ? true : false;
Review Comment:
### Overly Complex Boolean Expression <sub></sub>
<details>
<summary>Tell me more</summary>
###### What is the issue?
The ternary operator is unnecessarily complex for a simple boolean
comparison.
###### Why this matters
This verbose syntax adds cognitive overhead when reading the code. The
expression already evaluates to a boolean value.
###### Suggested change ∙ *Feature Preview*
```javascript
const devMode = window.location.hostname === 'localhost';
```
</details>
<sub>
[](https://app.korbit.ai/feedback/aa91ff46-6083-4491-9416-b83dd1994b51/b2753960-cfd3-4c02-b36e-fcff15054fd6?suggestedFixEnabled=true)
💬 Looking for more details? Reply to this comment to chat with Korbit.
</sub>
<!--- korbi internal id:9923d16d-8d03-46ad-84ca-665a125b1c43 -->
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]