From 508842e528150ff24a69976078ba9d80bd740310 Mon Sep 17 00:00:00 2001 From: Giorgos Karapiperidis Date: Wed, 25 Sep 2024 09:05:25 +0000 Subject: [PATCH] feat: added proxySrc, fileName for segment proxy --- docs/content/scripts/tracking/segment.md | 2 ++ src/runtime/registry/segment.ts | 4 +++- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/docs/content/scripts/tracking/segment.md b/docs/content/scripts/tracking/segment.md index daa0aaff..6bce47a7 100644 --- a/docs/content/scripts/tracking/segment.md +++ b/docs/content/scripts/tracking/segment.md @@ -115,6 +115,8 @@ You must provide the options when setting up the script for the first time. export const SegmentOptions = object({ writeKey: string(), analyticsKey: optional(string()), + proxySrc: optional(string()), + fileName: optional(string()), }) ``` diff --git a/src/runtime/registry/segment.ts b/src/runtime/registry/segment.ts index d1f02e79..47482474 100644 --- a/src/runtime/registry/segment.ts +++ b/src/runtime/registry/segment.ts @@ -6,6 +6,8 @@ import type { RegistryScriptInput } from '#nuxt-scripts' export const SegmentOptions = object({ writeKey: string(), analyticsKey: optional(string()), + proxySrc: optional(string()), + fileName: optional(string()), }) export type SegmentInput = RegistryScriptInput @@ -45,7 +47,7 @@ export function useScriptSegment(_options?: SegmentInput) return { scriptInput: { 'data-global-segment-analytics-key': k, - 'src': joinURL('https://cdn.segment.com/analytics.js/v1', options?.writeKey || '', 'analytics.min.js'), + 'src': joinURL(options?.proxySrc || 'https://cdn.segment.com/analytics.js/v1', options?.writeKey || '', options?.fileName || 'analytics.min.js'), }, clientInit: import.meta.server ? undefined