From d498086fdd4775d5e6de9d666cb4c65493808f9f Mon Sep 17 00:00:00 2001 From: Gao Sun Date: Mon, 3 Jun 2024 11:59:26 +0800 Subject: [PATCH] refactor(console): fix plausible hostname (#5968) --- packages/console/src/components/Conversion/utils.ts | 1 + packages/console/src/hooks/use-plausible-pageview.ts | 3 +-- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/console/src/components/Conversion/utils.ts b/packages/console/src/components/Conversion/utils.ts index 1b73ba0a9..39dc63368 100644 --- a/packages/console/src/components/Conversion/utils.ts +++ b/packages/console/src/components/Conversion/utils.ts @@ -16,6 +16,7 @@ export enum GtagConversionId { } export const redditPixelId = 't2_ggt11omdo'; +/** The data domain to aggregate the data for Plausible. */ export const plausibleDataDomain = 'logto.io'; const logtoProductionHostname = 'logto.io'; diff --git a/packages/console/src/hooks/use-plausible-pageview.ts b/packages/console/src/hooks/use-plausible-pageview.ts index 5b1657112..b97e548c3 100644 --- a/packages/console/src/hooks/use-plausible-pageview.ts +++ b/packages/console/src/hooks/use-plausible-pageview.ts @@ -3,7 +3,6 @@ import debug from 'debug'; import { useEffect } from 'react'; import { type RouteObject, useLocation } from 'react-router-dom'; -import { plausibleDataDomain } from '@/components/Conversion/utils'; import { getRoutePattern } from '@/utils/route'; const log = debug('usePlausiblePageview'); @@ -25,7 +24,7 @@ export const usePlausiblePageview = (routes: RouteObject[], prefix: string) => { // https://plausible.io/docs/custom-locations#3-specify-a-custom-location window.plausible?.('pageview', { u: - appendPath(new URL('https://' + plausibleDataDomain), prefix, routePattern).href + + appendPath(new URL('https://' + window.location.hostname), prefix, routePattern).href + window.location.search, }); }, [pathname, prefix, routes]);