Skip to content

Commit

Permalink
feat(app): add umami
Browse files Browse the repository at this point in the history
  • Loading branch information
yjl9903 committed Jan 8, 2024
1 parent f8ffdc4 commit 2f40f20
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 2 deletions.
7 changes: 6 additions & 1 deletion packages/app/astro.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,12 @@ export default defineConfig({
/**
* Cloudflare Web Analytics configuration
*/
CF_BEACON: 'aa68fa3bf166467082bc79ba029b057f'
CF_BEACON: 'aa68fa3bf166467082bc79ba029b057f',
/**
* Umami Cloud
*/
UMAMI_HOST: 'us.umami.is',
UMAMI_ID: '7e93a10d-26a9-4a3a-aa36-99294a5296f3'
}
})
],
Expand Down
4 changes: 4 additions & 0 deletions packages/app/src/env.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,4 +21,8 @@ declare module '~build/meta' {
export const WORKER_HOST: string;

export const CF_BEACON: string | undefined;

export const UMAMI_HOST: string | undefined;

export const UMAMI_ID: string | undefined;
}
10 changes: 9 additions & 1 deletion packages/app/src/layouts/Layout.astro
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
---
import { CF_BEACON } from '~build/meta';
import { CF_BEACON, UMAMI_HOST, UMAMI_ID } from '~build/meta';
import { pwaInfo } from 'virtual:pwa-info';
import { ViewTransitions } from 'astro:transitions';
Expand Down Expand Up @@ -298,5 +298,13 @@ function followSearch(params: Record<string, string>) {
: undefined}
data-cf-beacon={`{"token": "${CF_BEACON}"}`}></script>
<!-- End Cloudflare Web Analytics -->

<!-- Umami Cloud -->
{
!import.meta.env.DEV && UMAMI_HOST && UMAMI_ID ? (
<script defer src={`https://${UMAMI_HOST}/script.js`} data-website-id={UMAMI_ID} />
) : null
}
<!-- End Umami Cloud -->
</body>
</html>

0 comments on commit 2f40f20

Please sign in to comment.