fix: Allow custom API URL in Google Analytics 4 provider options (#1653)

Co-authored-by: Patryk Kuniczak <p.kuniczak@gmail.com>
This commit is contained in:
Honwhy Wang
2026-02-13 03:34:05 +08:00
committed by GitHub
parent 27ffff7e0a
commit 2e2272d07a
@@ -4,6 +4,7 @@ import type { BaseAnalyticsEvent } from '../types';
const DEFAULT_ENGAGEMENT_TIME_IN_MSEC = 100;
export interface GoogleAnalytics4ProviderOptions {
apiUrl?: string;
apiSecret: string;
measurementId: string;
}
@@ -18,7 +19,7 @@ export const googleAnalytics4 =
): Promise<void> => {
const url = new URL(
config?.debug ? '/debug/mp/collect' : '/mp/collect',
'https://www.google-analytics.com',
options.apiUrl ?? 'https://www.google-analytics.com',
);
if (options.apiSecret)
url.searchParams.set('api_secret', options.apiSecret);