Skip to content

Self-hosted personal gallery application with online photo management and albums, supporting Live/Motion Photos, EXIF parsing, geolocation recognition, and an explore map.

feat(analytics): add Google Analytics Measurement ID support

HoshinoSuzumi106e73b84f0b
diff --git a/.env.example b/.env.example
index d606dd54..3acfee60 100644
--- a/.env.example
+++ b/.env.example
@@ -39,3 +39,6 @@ NUXT_OAUTH_GITHUB_CLIENT_SECRET=
# INSECURE Options - DO NOT use these options in production or on public networks
# Allow cookies to be transmitted over insecure connections, effects login session security
NUXT_ALLOW_INSECURE_COOKIE=false
+
+# Google Analytics Measurement ID (e.g. G-XXXXXXX)
+CFRAME_GTAG=
diff --git a/docs/guide/configuration.md b/docs/guide/configuration.md
index bb756f89..244f21cd 100644
--- a/docs/guide/configuration.md
+++ b/docs/guide/configuration.md
@@ -4,25 +4,26 @@ Whether using Docker or Docker Compose (.env) deployment, configuration is done
## Environment Variables List
-| Environment Variable | Description | Default | Required |
-| ---------------------------------- | ---------------------------------------------- | ----------- | ----------------------------------------- |
-| CFRAME_ADMIN_EMAIL | Initial admin user email | None | Yes, fill in the GitHub account email used for login |
-| CFRAME_ADMIN_NAME | Initial admin username | Chronoframe | No |
-| CFRAME_ADMIN_PASSWORD | Initial admin user password | CF1234@! | No |
-| NUXT_PUBLIC_APP_TITLE | Application title | ChronoFrame | No |
-| NUXT_PUBLIC_APP_SLOGAN | Application slogan | None | No |
-| NUXT_PUBLIC_APP_AUTHOR | Application author | None | No |
-| NUXT_PUBLIC_APP_AVATAR_URL | Application avatar URL | None | No |
-| NUXT_PUBLIC_MAPBOX_ACCESS_TOKEN | Mapbox access token (URL restricted), for map services | None | Yes |
-| NUXT_MAPBOX_ACCESS_TOKEN | Mapbox access token (no URL restriction), for location services | None | No |
-| NUXT_STORAGE_PROVIDER | Storage provider, supports `s3`, `github`, `local` | `s3` | Yes |
-| NUXT_PROVIDER_S3_ENDPOINT | S3 compatible storage service endpoint | None | Required when `NUXT_STORAGE_PROVIDER` is `s3` |
-| NUXT_PROVIDER_S3_BUCKET | S3 bucket name | chronoframe | Required when `NUXT_STORAGE_PROVIDER` is `s3` |
-| NUXT_PROVIDER_S3_REGION | S3 bucket region | auto | Required when `NUXT_STORAGE_PROVIDER` is `s3` |
-| NUXT_PROVIDER_S3_ACCESS_KEY_ID | S3 access key ID | None | Required when `NUXT_STORAGE_PROVIDER` is `s3` |
-| NUXT_PROVIDER_S3_SECRET_ACCESS_KEY | S3 secret access key | None | Required when `NUXT_STORAGE_PROVIDER` is `s3` |
-| NUXT_PROVIDER_S3_PREFIX | S3 storage prefix | photos/ | No |
-| NUXT_PROVIDER_S3_CDN_URL | S3 storage CDN URL | None | No |
-| NUXT_OAUTH_GITHUB_CLIENT_ID | GitHub OAuth app Client ID | None | Yes |
-| NUXT_OAUTH_GITHUB_CLIENT_SECRET | GitHub OAuth app Client Secret | None | Yes |
-| NUXT_SESSION_PASSWORD | Password for encrypting sessions, 32-character random string | None | Yes |
\ No newline at end of file
+| Environment Variable | Description | Default | Required |
+| ---------------------------------- | --------------------------------------------------------------- | ----------- | ---------------------------------------------------- |
+| CFRAME_ADMIN_EMAIL | Initial admin user email | None | Yes, fill in the GitHub account email used for login |
+| CFRAME_ADMIN_NAME | Initial admin username | Chronoframe | No |
+| CFRAME_ADMIN_PASSWORD | Initial admin user password | CF1234@! | No |
+| NUXT_PUBLIC_APP_TITLE | Application title | ChronoFrame | No |
+| NUXT_PUBLIC_APP_SLOGAN | Application slogan | None | No |
+| NUXT_PUBLIC_APP_AUTHOR | Application author | None | No |
+| NUXT_PUBLIC_APP_AVATAR_URL | Application avatar URL | None | No |
+| NUXT_PUBLIC_MAPBOX_ACCESS_TOKEN | Mapbox access token (URL restricted), for map services | None | Yes |
+| NUXT_MAPBOX_ACCESS_TOKEN | Mapbox access token (no URL restriction), for location services | None | No |
+| NUXT_STORAGE_PROVIDER | Storage provider, supports `s3`, `github`, `local` | `s3` | Yes |
+| NUXT_PROVIDER_S3_ENDPOINT | S3 compatible storage service endpoint | None | Required when `NUXT_STORAGE_PROVIDER` is `s3` |
+| NUXT_PROVIDER_S3_BUCKET | S3 bucket name | chronoframe | Required when `NUXT_STORAGE_PROVIDER` is `s3` |
+| NUXT_PROVIDER_S3_REGION | S3 bucket region | auto | Required when `NUXT_STORAGE_PROVIDER` is `s3` |
+| NUXT_PROVIDER_S3_ACCESS_KEY_ID | S3 access key ID | None | Required when `NUXT_STORAGE_PROVIDER` is `s3` |
+| NUXT_PROVIDER_S3_SECRET_ACCESS_KEY | S3 secret access key | None | Required when `NUXT_STORAGE_PROVIDER` is `s3` |
+| NUXT_PROVIDER_S3_PREFIX | S3 storage prefix | photos/ | No |
+| NUXT_PROVIDER_S3_CDN_URL | S3 storage CDN URL | None | No |
+| NUXT_OAUTH_GITHUB_CLIENT_ID | GitHub OAuth app Client ID | None | Yes |
+| NUXT_OAUTH_GITHUB_CLIENT_SECRET | GitHub OAuth app Client Secret | None | Yes |
+| NUXT_SESSION_PASSWORD | Password for encrypting sessions, 32-character random string | None | Yes |
+| CFRAME_GTAG | Google Analytics Tracking ID | None | No |
diff --git a/docs/zh/guide/configuration.md b/docs/zh/guide/configuration.md
index f132de4e..7f4c1b17 100644
--- a/docs/zh/guide/configuration.md
+++ b/docs/zh/guide/configuration.md
@@ -26,3 +26,4 @@
| NUXT_OAUTH_GITHUB_CLIENT_ID | GitHub OAuth 应用的 Client ID | 无 | 是 |
| NUXT_OAUTH_GITHUB_CLIENT_SECRET | GitHub OAuth 应用的 Client Secret | 无 | 是 |
| NUXT_SESSION_PASSWORD | 用于加密会话的密码,32 位随机字符串 | 无 | 是 |
+| CFRAME_GTAG | Google Analytics 追踪 ID | 无 | 否 |
diff --git a/nuxt.config.ts b/nuxt.config.ts
index 0c42c437..71a85f92 100644
--- a/nuxt.config.ts
+++ b/nuxt.config.ts
@@ -22,6 +22,7 @@ export default defineNuxtConfig({
'@nuxtjs/i18n',
'nuxt-mapbox',
'nuxt-og-image',
+ 'nuxt-gtag',
],
css: ['~/assets/css/tailwind.css'],
@@ -96,6 +97,11 @@ export default defineNuxtConfig({
},
},
+ gtag: {
+ enabled: process.env.NODE_ENV === 'production' && !!process.env.CFRAME_GTAG,
+ id: process.env.CFRAME_GTAG || '',
+ },
+
colorMode: {
preference: process.env.NUXT_PUBLIC_COLOR_MODE_PREFERENCE || 'dark',
storageKey: 'cframe-color-mode',
@@ -155,4 +161,4 @@ export default defineNuxtConfig({
{ code: 'ja', name: '日本語', file: 'ja.json', language: 'ja' },
],
},
-})
+})
\ No newline at end of file
diff --git a/package.json b/package.json
index ff593f47..095a4cfe 100644
--- a/package.json
+++ b/package.json
@@ -55,6 +55,7 @@
"motion-v": "^1.7.0",
"nuxt": "^4.1.2",
"nuxt-auth-utils": "0.5.23",
+ "nuxt-gtag": "4.0.0",
"nuxt-mapbox": "1.6.4",
"nuxt-og-image": "5.1.11",
"pinia": "^3.0.3",
diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml
index ff234392..532e504a 100644
--- a/pnpm-lock.yaml
+++ b/pnpm-lock.yaml
@@ -95,6 +95,9 @@ importers:
nuxt-auth-utils:
specifier: 0.5.23
version: 0.5.23([email protected])
+ nuxt-gtag:
+ specifier: 4.0.0
+ version: 4.0.0([email protected])
nuxt-mapbox:
specifier: 1.6.4
@@ -5710,6 +5713,9 @@ packages:
resolution: {integrity: sha512-CYZ2WjU+KCyCDVzjYUM4eEpMF0rkPmkpiFrybTqqQCRpUbPt2h3snswWIpFPXTi+osRCY6Og0W/XLAQgDL4FfQ==}
+ resolution: {integrity: sha512-7Mz8d3Cbrp2WsskJmzTsxO5lYpX7oVLsmsMQPInM+r0/8aGM1LnDnQYdFtTO+j7fsVhMuCa+XZyNrH43EKNfHA==}
+
resolution: {integrity: sha512-g208L1m7diOCRj+lIf6+r+cKcJIR5aA4T0NEKKosUPnuZ2a4wlExb2zFrqXM5yfF2rbZMQee+fQc4H6AR0Oi1w==}
@@ -13833,6 +13839,15 @@ snapshots:
+ dependencies:
+ '@nuxt/kit': 4.1.2([email protected])
+ defu: 6.1.4
+ pathe: 2.0.3
+ ufo: 1.6.1
+ transitivePeerDependencies:
+ - magicast
+
dependencies:
'@mapbox/mapbox-gl-geocoder': 5.1.2