11import "server-only" ;
22
3- import { AnalyticsEvent , AnalyticsPageview , HeaderOnlyContext , ServerContext } from "./interfaces" ;
4- import type { AnalyticsMetadata } from "../interfaces" ;
3+ import {
4+ AnalyticsEvent ,
5+ AnalyticsPageview ,
6+ TrackingOptions ,
7+ HeaderOnlyContext ,
8+ ServerContext ,
9+ } from "./interfaces" ;
510import { isDoNotTrackEnabled , parseRequest } from "./utils" ;
611import { parseHeaders } from "./headers" ;
712import { parseUtmParameters } from "./utm" ;
@@ -32,7 +37,7 @@ export async function trackEvent(
3237 hostname,
3338 event : eventName ,
3439 metadata : options . metadata ,
35- ...( parseHeaders ( headers , { } ) ) ,
40+ ...parseHeaders ( headers , options . ignoreMetrics ) ,
3641 } ;
3742
3843 const response = await fetch ( "https://queue.simpleanalyticscdn.com/events" , {
@@ -57,11 +62,7 @@ export async function trackEvent(
5762
5863const PROXY_PATHS = / ^ \/ ( p r o x y \. j s | a u t o - e v e n t s \. j s | s i m p l e \/ .* ) $ / ;
5964
60- type TrackPageviewOptions = {
61- hostname ?: string | undefined ;
62- metadata ?: AnalyticsMetadata ;
63- collectDnt ?: boolean | undefined ;
64- } & ServerContext ;
65+ type TrackPageviewOptions = TrackingOptions & ServerContext ;
6566
6667export async function trackPageview ( options : TrackPageviewOptions ) {
6768 const hostname = options . hostname ?? process . env . SIMPLE_ANALYTICS_HOSTNAME ;
@@ -95,7 +96,10 @@ export async function trackPageview(options: TrackPageviewOptions) {
9596 hostname,
9697 event : "pageview" ,
9798 path,
98- ...( searchParams ? parseUtmParameters ( searchParams , { strictUtm : false } ) : { } ) ,
99+ ...parseHeaders ( headers , options . ignoreMetrics ) ,
100+ ...( searchParams
101+ ? parseUtmParameters ( searchParams , { strictUtm : options . strictUtm ?? true } )
102+ : { } ) ,
99103 } ;
100104
101105 const response = await fetch ( "https://queue.simpleanalyticscdn.com/events" , {
0 commit comments