Skip to content

Conversation

@0010aor
Copy link
Owner

@0010aor 0010aor commented Apr 25, 2025

This is a proposed revision of #64 (original PR by @muhammedsirajudeen).
I've tested and adjusted some things. Happy to discuss or merge if it looks good.

Thanks a lot for the contribution! Here are some things that I think we can improve:

  • Uses internationalization: all consent text is now translated and localized.
  • Initializes PostHog only after user consent, improving privacy compliance.
  • Uses the styles defined in @/theme.tsx for consistent UI, or creates new semantic tokens.
  • Maintains main.tsx as the entry point.

Please don’t forget to use Biome to format the code and set up the pre-commit tool to resolve linting issues before committing.

Great work!

@muhammedsirajudeen
Copy link
Contributor

It looks great.

@muhammedsirajudeen
Copy link
Contributor

shall i close #64

@0010aor 0010aor requested a review from jose-fernandez April 25, 2025 10:33
@sonegs sonegs requested review from sonegs and removed request for jose-fernandez April 25, 2025 11:33
Copy link
Collaborator

@sonegs sonegs left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@0010aor LGTM 🚀

const CONSENT_KEY = 'analytics_consent'

const AnalyticsConsent: FC = () => {
const [, setAcceptConsent] = useState<boolean>(false)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🚔 🚔 🚔

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

const [acceptConsent, setAcceptConsent] = useState<boolean>(false)

But maybe you must to check the use of this state (looks like it is not neccessary)

setAcceptConsent(false)
setShowConsent(true)
}
}, [])
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If we not use some dependency in useEffect hook, the performance will be damaged because this code will be run with each javascript change.

Checking the logic inside of this useEffect, looks like we just need to check the changes in storedConsent const, so we can add it like a dependency.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
}, [])
}, [storedConsent])

Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If we not use some dependency in useEffect hook, the performance will be damaged because this code will be run with each javascript change.

Checking the logic inside of this useEffect, looks like we just need to check the changes in storedConsent const, so we can add it like a dependency.

I think in this case, the empty dependency array ([]) is intentional we just want the useEffect to run once when the component mounts. Since we’re reading from localStorage on initial load, we only need to check the user’s consent status once when the app starts.

import { useTranslation } from 'react-i18next'
import { FaTimes as CloseIcon } from 'react-icons/fa'

const CONSENT_KEY = 'analytics_consent'
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could be interesting add a directory to save this kind of const values. Add a new directory in frontend/src/ called lib (in the future, we will a refactor of the arquitecture about that). Inside it, add a new directory called const.

In this directory, we can add a new file called analytics.ts, where we can save and export this kind of consts. Please, add a comment to explain the purpose of this const.

@0010aor 0010aor merged commit e6a7b95 into main Apr 30, 2025
2 checks passed
@0010aor 0010aor deleted the review/cookie-consent-banner branch April 30, 2025 12:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants