-
Notifications
You must be signed in to change notification settings - Fork 8
Algolia, PostHog and Google Analytics #203
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
13 commits
Select commit
Hold shift + click to select a range
e47bfa5
Algolia and GA
danciaclara e5e8ce3
added search filters
danciaclara d906e4b
added search filters
danciaclara 56e7d69
added search filters
danciaclara b475eca
changed license error title
danciaclara 0c37c42
increased search results
danciaclara 8e59999
removed search parameters
danciaclara 34b0183
Added old redirects
danciaclara f20bb9e
Added Posthog analytics
danciaclara b7863b4
fixed duplicate redirect
danciaclara 679b0dd
fix: convert variables to envs
sriramveeraghanta 8cac684
fix: formatting
sriramveeraghanta 94b905d
fix: formatting
sriramveeraghanta File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,7 @@ | ||
| # PostHog Analytics | ||
| VITE_POSTHOG_KEY= | ||
|
|
||
| # Algolia Search | ||
| VITE_ALGOLIA_APP_ID= | ||
| VITE_ALGOLIA_API_KEY= | ||
| VITE_ALGOLIA_INDEX_NAME= | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,173 @@ | ||
| <script setup lang="ts"> | ||
| import { ref, onMounted } from 'vue' | ||
|
|
||
| const STORAGE_KEY = 'plane-docs-cookie-consent' | ||
| const showBanner = ref(false) | ||
|
|
||
| function getConsent(): string | null { | ||
| try { | ||
| return localStorage.getItem(STORAGE_KEY) | ||
| } catch { | ||
| return null | ||
| } | ||
| } | ||
|
|
||
| function grantConsent() { | ||
| if (typeof window === 'undefined') return | ||
|
|
||
| // Google Analytics | ||
| if (typeof window.gtag === 'function') { | ||
| window.gtag('consent', 'update', { | ||
| analytics_storage: 'granted' | ||
| }) | ||
| } | ||
|
|
||
| // PostHog (may not be loaded if VITE_POSTHOG_KEY is unset) | ||
| if (window.posthog?.opt_in_capturing) { | ||
| window.posthog.opt_in_capturing() | ||
| } | ||
| } | ||
|
|
||
| function denyConsent() { | ||
| if (typeof window === 'undefined') return | ||
|
|
||
| // Google Analytics — consent stays denied by default, no update needed | ||
|
|
||
| // PostHog (may not be loaded if VITE_POSTHOG_KEY is unset) | ||
| if (window.posthog?.opt_out_capturing) { | ||
| window.posthog.opt_out_capturing() | ||
| } | ||
| } | ||
|
|
||
| function accept() { | ||
| try { | ||
| localStorage.setItem(STORAGE_KEY, 'granted') | ||
| } catch {} | ||
| grantConsent() | ||
| showBanner.value = false | ||
| } | ||
|
|
||
| function decline() { | ||
| try { | ||
| localStorage.setItem(STORAGE_KEY, 'denied') | ||
| } catch {} | ||
| denyConsent() | ||
| showBanner.value = false | ||
| } | ||
|
|
||
| onMounted(() => { | ||
| const consent = getConsent() | ||
| if (consent === 'granted') { | ||
| grantConsent() | ||
| } else if (consent === 'denied') { | ||
| denyConsent() | ||
| } else { | ||
| showBanner.value = true | ||
| } | ||
| }) | ||
| </script> | ||
|
|
||
| <template> | ||
| <Transition name="consent"> | ||
| <div v-if="showBanner" class="consent-banner"> | ||
| <p class="consent-text"> | ||
| We use cookies and analytics to improve your experience. You can accept or decline non-essential cookies. | ||
| </p> | ||
| <div class="consent-actions"> | ||
| <button class="consent-btn consent-btn-decline" @click="decline">Decline</button> | ||
| <button class="consent-btn consent-btn-accept" @click="accept">Accept</button> | ||
| </div> | ||
| </div> | ||
| </Transition> | ||
| </template> | ||
|
|
||
| <style scoped> | ||
| .consent-banner { | ||
| position: fixed; | ||
| bottom: 20px; | ||
| left: 50%; | ||
| transform: translateX(-50%); | ||
| z-index: 100; | ||
| display: flex; | ||
| align-items: center; | ||
| gap: 16px; | ||
| max-width: 680px; | ||
| width: calc(100% - 32px); | ||
| padding: 14px 20px; | ||
| background: var(--vp-c-bg-soft); | ||
| border: 1px solid var(--vp-c-divider); | ||
| border-radius: 12px; | ||
| box-shadow: 0 4px 24px rgba(0, 0, 0, 0.12); | ||
| } | ||
|
|
||
| .consent-text { | ||
| margin: 0; | ||
| font-size: 13px; | ||
| line-height: 1.5; | ||
| color: var(--vp-c-text-2); | ||
| flex: 1; | ||
| } | ||
|
|
||
| .consent-actions { | ||
| display: flex; | ||
| gap: 8px; | ||
| flex-shrink: 0; | ||
| } | ||
|
|
||
| .consent-btn { | ||
| padding: 6px 16px; | ||
| border-radius: 6px; | ||
| font-size: 13px; | ||
| font-weight: 500; | ||
| cursor: pointer; | ||
| border: none; | ||
| white-space: nowrap; | ||
| transition: background 0.15s ease; | ||
| } | ||
|
|
||
| .consent-btn-decline { | ||
| background: transparent; | ||
| color: var(--vp-c-text-2); | ||
| border: 1px solid var(--vp-c-divider); | ||
| } | ||
|
|
||
| .consent-btn-decline:hover { | ||
| background: var(--vp-c-bg-mute); | ||
| } | ||
|
|
||
| .consent-btn-accept { | ||
| background: var(--vp-c-brand-1); | ||
| color: #fff; | ||
| } | ||
|
|
||
| .consent-btn-accept:hover { | ||
| opacity: 0.9; | ||
| } | ||
|
|
||
| @media (max-width: 540px) { | ||
| .consent-banner { | ||
| flex-direction: column; | ||
| align-items: stretch; | ||
| gap: 12px; | ||
| } | ||
| .consent-actions { | ||
| justify-content: flex-end; | ||
| } | ||
| } | ||
|
|
||
| /* Transition */ | ||
| .consent-enter-active { | ||
| transition: opacity 0.3s ease, transform 0.3s ease; | ||
| } | ||
| .consent-leave-active { | ||
| transition: opacity 0.2s ease, transform 0.2s ease; | ||
| } | ||
| .consent-enter-from { | ||
| opacity: 0; | ||
| transform: translateX(-50%) translateY(20px); | ||
| } | ||
| .consent-leave-to { | ||
| opacity: 0; | ||
| transform: translateX(-50%) translateY(20px); | ||
| } | ||
| </style> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Reorder Algolia keys to satisfy dotenv-linter.
Proposed fix
📝 Committable suggestion
🧰 Tools
🪛 dotenv-linter (4.0.0)
[warning] 6-6: [UnorderedKey] The VITE_ALGOLIA_API_KEY key should go before the VITE_ALGOLIA_APP_ID key
(UnorderedKey)
🤖 Prompt for AI Agents