@aranova/tracking-next 0.6.0 → 0.6.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.d.mts CHANGED
@@ -1,12 +1,25 @@
1
- import { C as ConsentState, T as TrackingInstallSurface, a as TrackingClientContext, b as TrackingParams, c as TrackingEventCreatePayload, d as TrackingSessionUpsertPayload } from './types-Gp0ioRiQ.mjs';
2
- export { e as TrackingInitConfig } from './types-Gp0ioRiQ.mjs';
1
+ import { C as ConsentState, T as TrackingInstallSurface, a as TrackingClientContext, b as TrackingParams, c as TrackingEventCreatePayload, d as TrackingSessionUpsertPayload } from './types-B4VZHWnc.mjs';
2
+ export { e as TrackingInitConfig } from './types-B4VZHWnc.mjs';
3
3
  import { z } from 'zod';
4
4
  import * as src from 'src';
5
5
  import * as react_jsx_runtime from 'react/jsx-runtime';
6
6
  import { ReactNode } from 'react';
7
7
 
8
+ /**
9
+ * Google Consent Mode value sent to `gtag('consent', 'update', ...)`.
10
+ */
8
11
  type GtagConsentValue = 'granted' | 'denied';
12
+ /**
13
+ * Read the persisted visitor consent state from localStorage.
14
+ *
15
+ * Returns `pending` when called during SSR or before the visitor has made a
16
+ * choice.
17
+ */
9
18
  declare function getConsentState(): ConsentState;
19
+ /**
20
+ * Persist a visitor consent choice and update Google Consent Mode when gtag is
21
+ * loaded.
22
+ */
10
23
  declare function setConsentState(state: GtagConsentValue): void;
11
24
 
12
25
  interface TrackingContextInput {
@@ -28,13 +41,37 @@ interface TrackingSessionInput {
28
41
  sessionId: string;
29
42
  visitorId?: string | null;
30
43
  }
44
+ /**
45
+ * Build runtime context attached to tracking sessions and events.
46
+ */
31
47
  declare function createTrackingClientContext(surface: TrackingInstallSurface, input?: TrackingContextInput): TrackingClientContext;
48
+ /**
49
+ * Build the session portion of a tracking ingest request.
50
+ */
32
51
  declare function createTrackingSessionUpsertPayload(trackingParams: TrackingParams, input: TrackingSessionInput, context: TrackingClientContext): TrackingSessionUpsertPayload;
52
+ /**
53
+ * Build one event payload before it is batched into a tracking ingest request.
54
+ */
33
55
  declare function createTrackingEventCreatePayload(trackingParams: TrackingParams, input: TrackingEventInput, context: TrackingClientContext): TrackingEventCreatePayload;
34
56
 
57
+ /**
58
+ * Attribution query/cookie keys captured by the SDK.
59
+ */
35
60
  declare const TRACKING_PARAM_KEYS: readonly ["gclid", "fbclid", "utm_source", "utm_medium", "utm_campaign", "utm_term", "utm_content"];
61
+ /**
62
+ * Capture tracking params from a URL, persist them to first-party cookies, and
63
+ * return the current cookie-backed attribution state.
64
+ *
65
+ * Defaults to `window.location.href` in the browser.
66
+ */
36
67
  declare function captureTrackingParamsFromLocation(url?: string, maxAgeSeconds?: number): TrackingParams;
37
68
 
69
+ /**
70
+ * Metadata for a manually fired `cta_click` event.
71
+ *
72
+ * Use this for non-phone calls to action such as directions, appointment
73
+ * buttons, downloads, or external booking links.
74
+ */
38
75
  declare const ctaClickMetadataSchema: z.ZodObject<{
39
76
  cta_name: z.ZodString;
40
77
  page: z.ZodObject<{
@@ -62,9 +99,21 @@ declare const ctaClickMetadataSchema: z.ZodObject<{
62
99
  destination_url?: string | null | undefined;
63
100
  }>;
64
101
  type CtaClickMetadata = z.infer<typeof ctaClickMetadataSchema>;
102
+ /**
103
+ * Registration config for `cta_click`.
104
+ *
105
+ * This event is manual-only and currently has no registration options.
106
+ */
65
107
  declare const ctaClickConfigSchema: z.ZodObject<{}, "strict", z.ZodTypeAny, {}, {}>;
66
108
  type CtaClickConfig = z.infer<typeof ctaClickConfigSchema>;
67
109
 
110
+ /**
111
+ * Metadata for the SDK-internal `sdk_heartbeat` event.
112
+ *
113
+ * The SDK fires this once per new session so the dashboard can show which SDK
114
+ * version, install surface, and trigger registry a client site is running.
115
+ * Consumers do not manually register or fire this event.
116
+ */
68
117
  declare const sdkHeartbeatMetadataSchema: z.ZodObject<{
69
118
  sdk_version: z.ZodString;
70
119
  package_name: z.ZodNullable<z.ZodString>;
@@ -100,9 +149,19 @@ declare const sdkHeartbeatMetadataSchema: z.ZodObject<{
100
149
  trigger_config?: Record<string, Record<string, unknown>> | null | undefined;
101
150
  }>;
102
151
  type SdkHeartbeatMetadata = z.infer<typeof sdkHeartbeatMetadataSchema>;
152
+ /**
153
+ * Internal registration config for `sdk_heartbeat`.
154
+ *
155
+ * This event has no consumer-facing options.
156
+ */
103
157
  declare const sdkHeartbeatConfigSchema: z.ZodObject<{}, "strict", z.ZodTypeAny, {}, {}>;
104
158
  type SdkHeartbeatConfig = z.infer<typeof sdkHeartbeatConfigSchema>;
105
159
 
160
+ /**
161
+ * Metadata for the automatic `form_start` event.
162
+ *
163
+ * The SDK emits this once per form when the visitor first focuses a field.
164
+ */
106
165
  declare const formStartMetadataSchema: z.ZodObject<{
107
166
  form: z.ZodObject<{
108
167
  id: z.ZodString;
@@ -139,6 +198,12 @@ declare const formStartMetadataSchema: z.ZodObject<{
139
198
  };
140
199
  }>;
141
200
  type FormStartMetadata = z.infer<typeof formStartMetadataSchema>;
201
+ /**
202
+ * Registration config for automatic `form_start`.
203
+ *
204
+ * Use `selector` to narrow which forms can trigger the event. When omitted,
205
+ * the SDK observes all `<form>` elements.
206
+ */
142
207
  declare const formStartConfigSchema: z.ZodObject<{
143
208
  selector: z.ZodOptional<z.ZodString>;
144
209
  }, "strict", z.ZodTypeAny, {
@@ -148,9 +213,46 @@ declare const formStartConfigSchema: z.ZodObject<{
148
213
  }>;
149
214
  type FormStartConfig = z.infer<typeof formStartConfigSchema>;
150
215
 
216
+ /**
217
+ * JSON-serializable value accepted by `form_submit.fields[].value`.
218
+ *
219
+ * This intentionally excludes `undefined`, functions, symbols, `Date`
220
+ * instances, and non-finite numbers. Values are stored in PostgreSQL JSONB, so
221
+ * consumers should send only data that has a stable JSON representation.
222
+ */
151
223
  type JsonValue = string | number | boolean | null | JsonValue[] | {
152
224
  [key: string]: JsonValue;
153
225
  };
226
+ /**
227
+ * Metadata for a manually fired `form_submit` event.
228
+ *
229
+ * Register the event with `manual: { form_submit: {} }`, then call
230
+ * `trackEvent('form_submit', metadata)` from the host site's submit handler.
231
+ *
232
+ * `fields` is optional. If present, each field value must be JSON-serializable
233
+ * and should be explicitly allowlisted by the integration. Do not send names,
234
+ * emails, visitor phone numbers, addresses, payment data, medical details,
235
+ * passwords, file contents, or free-text messages.
236
+ *
237
+ * @example
238
+ * ```ts
239
+ * tracking.trackEvent('form_submit', {
240
+ * form: {
241
+ * id: 'lead-form',
242
+ * action: '/api/lead',
243
+ * fields: [
244
+ * {
245
+ * name: 'service_interest',
246
+ * type: 'select',
247
+ * label: 'Service interest',
248
+ * value: 'teeth_whitening',
249
+ * },
250
+ * ],
251
+ * },
252
+ * page: { path: window.location.pathname },
253
+ * });
254
+ * ```
255
+ */
154
256
  declare const formSubmitMetadataSchema: z.ZodObject<{
155
257
  form: z.ZodObject<{
156
258
  id: z.ZodString;
@@ -227,9 +329,21 @@ declare const formSubmitMetadataSchema: z.ZodObject<{
227
329
  };
228
330
  }>;
229
331
  type FormSubmitMetadata = z.infer<typeof formSubmitMetadataSchema>;
332
+ /**
333
+ * Registration config for `form_submit`.
334
+ *
335
+ * This event is manual-only and currently has no registration options. The
336
+ * empty object enables typed `trackEvent('form_submit', ...)` calls.
337
+ */
230
338
  declare const formSubmitConfigSchema: z.ZodObject<{}, "strict", z.ZodTypeAny, {}, {}>;
231
339
  type FormSubmitConfig = z.infer<typeof formSubmitConfigSchema>;
232
340
 
341
+ /**
342
+ * Metadata for the automatic `multi_page_session` event.
343
+ *
344
+ * Fired when the visitor reaches the configured distinct-page threshold in a
345
+ * single tracking session.
346
+ */
233
347
  declare const multiPageSessionMetadataSchema: z.ZodObject<{
234
348
  page_count: z.ZodNumber;
235
349
  page: z.ZodObject<{
@@ -251,6 +365,9 @@ declare const multiPageSessionMetadataSchema: z.ZodObject<{
251
365
  page_count: number;
252
366
  }>;
253
367
  type MultiPageSessionMetadata = z.infer<typeof multiPageSessionMetadataSchema>;
368
+ /**
369
+ * Registration config for automatic `multi_page_session`.
370
+ */
254
371
  declare const multiPageSessionConfigSchema: z.ZodObject<{
255
372
  pageThreshold: z.ZodNumber;
256
373
  }, "strict", z.ZodTypeAny, {
@@ -260,6 +377,13 @@ declare const multiPageSessionConfigSchema: z.ZodObject<{
260
377
  }>;
261
378
  type MultiPageSessionConfig = z.infer<typeof multiPageSessionConfigSchema>;
262
379
 
380
+ /**
381
+ * Metadata for the automatic `page_view` event.
382
+ *
383
+ * The SDK emits this on initial load, SPA route changes, and bfcache restores.
384
+ * Consumers do not call `trackEvent('page_view', ...)`; registering
385
+ * `automatic: { page_view: {} }` enables the SDK-owned trigger.
386
+ */
263
387
  declare const pageViewMetadataSchema: z.ZodObject<{
264
388
  page: z.ZodObject<{
265
389
  title: z.ZodNullable<z.ZodString>;
@@ -314,9 +438,22 @@ declare const pageViewMetadataSchema: z.ZodObject<{
314
438
  } | null | undefined;
315
439
  }>;
316
440
  type PageViewMetadata = z.infer<typeof pageViewMetadataSchema>;
441
+ /**
442
+ * Registration config for automatic `page_view`.
443
+ *
444
+ * `page_view` is required in every trigger registry and currently has no
445
+ * options. Use `{ page_view: {} }`.
446
+ */
317
447
  declare const pageViewConfigSchema: z.ZodObject<{}, "strict", z.ZodTypeAny, {}, {}>;
318
448
  type PageViewConfig = z.infer<typeof pageViewConfigSchema>;
319
449
 
450
+ /**
451
+ * Metadata for a manually fired `phone_click` event.
452
+ *
453
+ * `phone_number` should be the business phone number from the clicked `tel:`
454
+ * link, not a visitor-entered phone number. `section` can distinguish header,
455
+ * footer, hero, or contact-page links.
456
+ */
320
457
  declare const phoneClickMetadataSchema: z.ZodObject<{
321
458
  phone_number: z.ZodString;
322
459
  page: z.ZodObject<{
@@ -341,9 +478,19 @@ declare const phoneClickMetadataSchema: z.ZodObject<{
341
478
  section?: string | null | undefined;
342
479
  }>;
343
480
  type PhoneClickMetadata = z.infer<typeof phoneClickMetadataSchema>;
481
+ /**
482
+ * Registration config for `phone_click`.
483
+ *
484
+ * This event is manual-only and currently has no registration options.
485
+ */
344
486
  declare const phoneClickConfigSchema: z.ZodObject<{}, "strict", z.ZodTypeAny, {}, {}>;
345
487
  type PhoneClickConfig = z.infer<typeof phoneClickConfigSchema>;
346
488
 
489
+ /**
490
+ * Metadata for the automatic `scroll_depth` event.
491
+ *
492
+ * Fired once per configured threshold per page.
493
+ */
347
494
  declare const scrollDepthMetadataSchema: z.ZodObject<{
348
495
  depth_percent: z.ZodNumber;
349
496
  page: z.ZodObject<{
@@ -365,6 +512,11 @@ declare const scrollDepthMetadataSchema: z.ZodObject<{
365
512
  depth_percent: number;
366
513
  }>;
367
514
  type ScrollDepthMetadata = z.infer<typeof scrollDepthMetadataSchema>;
515
+ /**
516
+ * Registration config for automatic `scroll_depth`.
517
+ *
518
+ * `thresholds` are integer percentages from 1 to 100.
519
+ */
368
520
  declare const scrollDepthConfigSchema: z.ZodObject<{
369
521
  thresholds: z.ZodArray<z.ZodNumber, "many">;
370
522
  }, "strict", z.ZodTypeAny, {
@@ -374,8 +526,17 @@ declare const scrollDepthConfigSchema: z.ZodObject<{
374
526
  }>;
375
527
  type ScrollDepthConfig = z.infer<typeof scrollDepthConfigSchema>;
376
528
 
529
+ /**
530
+ * Canonical page intent names supported by `specific_page_visit`.
531
+ */
377
532
  declare const SPECIFIC_PAGE_NAMES: readonly ["contact_page", "about_page", "services_page", "booking_page", "location_page", "pricing_page", "faq_page", "testimonials_page"];
378
533
  type SpecificPageName = (typeof SPECIFIC_PAGE_NAMES)[number];
534
+ /**
535
+ * Metadata for the automatic `specific_page_visit` event.
536
+ *
537
+ * The SDK emits this when the current pathname matches one of the configured
538
+ * named page patterns.
539
+ */
379
540
  declare const specificPageVisitMetadataSchema: z.ZodObject<{
380
541
  page_name: z.ZodEnum<["contact_page", "about_page", "services_page", "booking_page", "location_page", "pricing_page", "faq_page", "testimonials_page"]>;
381
542
  page: z.ZodObject<{
@@ -397,6 +558,12 @@ declare const specificPageVisitMetadataSchema: z.ZodObject<{
397
558
  page_name: "contact_page" | "about_page" | "services_page" | "booking_page" | "location_page" | "pricing_page" | "faq_page" | "testimonials_page";
398
559
  }>;
399
560
  type SpecificPageVisitMetadata = z.infer<typeof specificPageVisitMetadataSchema>;
561
+ /**
562
+ * Registration config for automatic `specific_page_visit`.
563
+ *
564
+ * Each page entry pairs a semantic `name` with a `RegExp` that matches the
565
+ * pathname. Use this instead of hard-coding path regexes downstream.
566
+ */
400
567
  declare const specificPageVisitConfigSchema: z.ZodObject<{
401
568
  pages: z.ZodArray<z.ZodObject<{
402
569
  name: z.ZodEnum<["contact_page", "about_page", "services_page", "booking_page", "location_page", "pricing_page", "faq_page", "testimonials_page"]>;
@@ -421,6 +588,12 @@ declare const specificPageVisitConfigSchema: z.ZodObject<{
421
588
  }>;
422
589
  type SpecificPageVisitConfig = z.infer<typeof specificPageVisitConfigSchema>;
423
590
 
591
+ /**
592
+ * Metadata for the automatic `time_on_site` event.
593
+ *
594
+ * The SDK starts a visibility-aware timer and fires once when visible
595
+ * engagement crosses the configured threshold.
596
+ */
424
597
  declare const timeOnSiteMetadataSchema: z.ZodObject<{
425
598
  duration_ms: z.ZodNumber;
426
599
  page: z.ZodObject<{
@@ -442,6 +615,9 @@ declare const timeOnSiteMetadataSchema: z.ZodObject<{
442
615
  duration_ms: number;
443
616
  }>;
444
617
  type TimeOnSiteMetadata = z.infer<typeof timeOnSiteMetadataSchema>;
618
+ /**
619
+ * Registration config for automatic `time_on_site`.
620
+ */
445
621
  declare const timeOnSiteConfigSchema: z.ZodObject<{
446
622
  thresholdSeconds: z.ZodNumber;
447
623
  }, "strict", z.ZodTypeAny, {
@@ -864,10 +1040,21 @@ declare const EVENT_REGISTRY: {
864
1040
  readonly configSchema: z.ZodObject<{}, "strict", z.ZodTypeAny, {}, {}>;
865
1041
  };
866
1042
  };
1043
+ /**
1044
+ * Name of any event known to the tracking SDK.
1045
+ */
867
1046
  type EventName = keyof typeof EVENT_REGISTRY;
1047
+ /**
1048
+ * Event names that are fired by the SDK when their configured signal occurs.
1049
+ *
1050
+ * Automatic events are not accepted by the typed `trackEvent()` API.
1051
+ */
868
1052
  type AutomaticEventName = {
869
1053
  [K in EventName]: (typeof EVENT_REGISTRY)[K]['kind'] extends 'automatic' ? K : never;
870
1054
  }[EventName];
1055
+ /**
1056
+ * Event names that consumer code can fire manually after registering them.
1057
+ */
871
1058
  type ManualEventName = {
872
1059
  [K in EventName]: (typeof EVENT_REGISTRY)[K]['kind'] extends 'manual' ? K : never;
873
1060
  }[EventName];
@@ -895,8 +1082,44 @@ type ConfigByName = {
895
1082
  phone_click: PhoneClickConfig;
896
1083
  cta_click: CtaClickConfig;
897
1084
  };
1085
+ /**
1086
+ * Metadata payload type for a specific tracking event.
1087
+ *
1088
+ * @example
1089
+ * ```ts
1090
+ * type SubmitMetadata = EventMetadata<'form_submit'>;
1091
+ * ```
1092
+ */
898
1093
  type EventMetadata<K extends EventName> = MetadataByName[K];
1094
+ /**
1095
+ * Trigger registration config type for a specific tracking event.
1096
+ */
899
1097
  type EventConfig<K extends EventName> = ConfigByName[K];
1098
+ /**
1099
+ * Trigger registry passed to `createTracking({ triggers })`.
1100
+ *
1101
+ * `automatic.page_view` is required because every install should capture page
1102
+ * views. Other automatic events are opt-in. Manual events must be registered
1103
+ * here before the typed client accepts `trackEvent()` calls for them.
1104
+ *
1105
+ * @example
1106
+ * ```ts
1107
+ * createTracking({
1108
+ * apiKey,
1109
+ * endpoint,
1110
+ * triggers: {
1111
+ * automatic: {
1112
+ * page_view: {},
1113
+ * time_on_site: { thresholdSeconds: 60 },
1114
+ * },
1115
+ * manual: {
1116
+ * form_submit: {},
1117
+ * phone_click: {},
1118
+ * },
1119
+ * },
1120
+ * });
1121
+ * ```
1122
+ */
900
1123
  type TriggerRegistryConfig = {
901
1124
  automatic: {
902
1125
  page_view: EventConfig<'page_view'>;
@@ -913,29 +1136,70 @@ type TriggerRegistryConfig = {
913
1136
  cta_click: EventConfig<'cta_click'>;
914
1137
  }>;
915
1138
  };
1139
+ /**
1140
+ * Manual event names registered in a concrete trigger registry.
1141
+ *
1142
+ * Used by `TypedTrackingClient` so `trackEvent()` only accepts events the
1143
+ * consumer explicitly enabled.
1144
+ */
916
1145
  type RegisteredManualEvents<TRegistry extends TriggerRegistryConfig> = Extract<keyof NonNullable<TRegistry['manual']>, ManualEventName>;
1146
+ /**
1147
+ * Automatic event names registered in a concrete trigger registry.
1148
+ */
917
1149
  type RegisteredAutomaticEvents<TRegistry extends TriggerRegistryConfig> = Extract<keyof TRegistry['automatic'], AutomaticEventName>;
918
1150
 
1151
+ /**
1152
+ * Input accepted by the low-level stringly-typed client.
1153
+ *
1154
+ * Prefer the typed `trackEvent(eventName, metadata)` facade exposed by
1155
+ * `useTracking()` in React/Next integrations.
1156
+ */
919
1157
  interface TrackEventInput {
1158
+ /** Event name to enqueue. */
920
1159
  eventType: string;
1160
+ /** URL associated with the event. Defaults to the current page URL. */
921
1161
  pageUrl?: string | null;
1162
+ /** Event-specific metadata. */
922
1163
  metadata?: Record<string, unknown> | null;
1164
+ /** Timestamp override. Defaults to queue time. */
923
1165
  occurredAt?: Date | string | null;
924
1166
  }
1167
+ /**
1168
+ * Low-level tracking client responsible for queueing and flushing events.
1169
+ */
925
1170
  interface TrackingClient {
1171
+ /** Enqueue an event for batched delivery. */
926
1172
  trackEvent: (input: TrackEventInput) => void;
1173
+ /** Flush queued events immediately. */
927
1174
  flush: () => Promise<void>;
1175
+ /** Return the current rolling session id. */
928
1176
  getSessionId: () => string;
1177
+ /** Return the persistent visitor id. */
929
1178
  getVisitorId: () => string;
1179
+ /** Remove timers/listeners and prevent future flushes. */
930
1180
  destroy: () => void;
931
1181
  }
932
1182
 
933
1183
  interface TypedTrackEventOptions {
934
- /** Override the page URL captured automatically. Rarely needed. */
1184
+ /**
1185
+ * Override the page URL associated with this event.
1186
+ *
1187
+ * Omit this for normal browser usage; the SDK captures `window.location.href`.
1188
+ */
935
1189
  pageUrl?: string | null;
936
- /** Event timestamp override. Defaults to "now" at queue time. */
1190
+ /**
1191
+ * Override the event timestamp.
1192
+ *
1193
+ * Defaults to the time the event is queued. Accepts a `Date` or ISO string.
1194
+ */
937
1195
  occurredAt?: Date | string | null;
938
1196
  }
1197
+ /**
1198
+ * Typed tracking client returned by `useTracking()`.
1199
+ *
1200
+ * The accepted event names and metadata shapes are narrowed from the concrete
1201
+ * trigger registry supplied to `createTracking()`.
1202
+ */
939
1203
  interface TypedTrackingClient<TRegistry extends TriggerRegistryConfig> {
940
1204
  /**
941
1205
  * Fire a manually-registered event. The event name must be present in
@@ -943,37 +1207,104 @@ interface TypedTrackingClient<TRegistry extends TriggerRegistryConfig> {
943
1207
  * canonical Zod-derived shape.
944
1208
  */
945
1209
  trackEvent<K extends RegisteredManualEvents<TRegistry>>(eventType: K, metadata: EventMetadata<K>, options?: TypedTrackEventOptions): void;
1210
+ /**
1211
+ * Immediately flush queued events to the ingest endpoint.
1212
+ *
1213
+ * Normal consumers rarely need this because the SDK flushes on a debounce,
1214
+ * when the queue reaches the batch threshold, and on `pagehide`.
1215
+ */
946
1216
  flush(): Promise<void>;
1217
+ /**
1218
+ * Return the current rolling session id.
1219
+ */
947
1220
  getSessionId(): string;
1221
+ /**
1222
+ * Return the persistent visitor id for this browser profile.
1223
+ */
948
1224
  getVisitorId(): string;
949
1225
  }
950
1226
 
1227
+ /**
1228
+ * Default non-blocking consent banner for Next.js installs.
1229
+ *
1230
+ * Renders only while consent is `pending`. Accept/decline choices are stored
1231
+ * in localStorage and propagated to Google Consent Mode when gtag is loaded.
1232
+ */
951
1233
  declare function ConsentBanner(): react_jsx_runtime.JSX.Element | null;
952
1234
 
1235
+ /**
1236
+ * Read the captured Google Ads click id from first-party cookies.
1237
+ *
1238
+ * Returns `null` during SSR and before the client has mounted.
1239
+ */
953
1240
  declare function useGclid(): string | null;
1241
+ /**
1242
+ * Read all captured attribution parameters from first-party cookies.
1243
+ *
1244
+ * Values are loaded after mount, so the initial render returns all `null`s.
1245
+ */
954
1246
  declare function useTrackingParams(): TrackingParams;
1247
+ /**
1248
+ * Read the current visitor consent state and update when another tab changes
1249
+ * the stored value.
1250
+ */
955
1251
  declare function useConsentState(): ConsentState;
956
1252
 
957
1253
  interface GoogleAdsTrackingProps {
1254
+ /**
1255
+ * Google Ads tag id, for example `AW-123456789`.
1256
+ */
958
1257
  gtagId: string;
959
1258
  }
1259
+ /**
1260
+ * Next.js client component that loads Google Ads gtag with Consent Mode.
1261
+ *
1262
+ * Render in the root layout `<head>` when the client site runs paid Google
1263
+ * Ads. The component injects Next `<Script>` tags and renders no visible UI.
1264
+ */
960
1265
  declare function GoogleAdsTracking({ gtagId }: GoogleAdsTrackingProps): react_jsx_runtime.JSX.Element;
961
1266
 
962
1267
  interface CreateTrackingOptions<TRegistry extends TriggerRegistryConfig> {
1268
+ /**
1269
+ * Public tracking API key issued for this business.
1270
+ *
1271
+ * This key is safe to expose via `NEXT_PUBLIC_*` env vars.
1272
+ */
963
1273
  apiKey: string;
1274
+ /**
1275
+ * Tracking endpoint base URL, usually ending in `/tracking`.
1276
+ */
964
1277
  endpoint: string;
1278
+ /**
1279
+ * Trigger registry that controls automatic events and typed manual events.
1280
+ */
965
1281
  triggers: TRegistry;
1282
+ /**
1283
+ * Validate manual event metadata at runtime before queueing.
1284
+ *
1285
+ * Enable in development to catch shape bugs. Leave disabled in production so
1286
+ * analytics can never throw into the host app.
1287
+ */
966
1288
  debug?: boolean;
967
1289
  }
968
1290
  interface TrackingProviderProps {
1291
+ /**
1292
+ * Application subtree that should have access to the tracking client.
1293
+ */
969
1294
  children: ReactNode;
970
1295
  }
971
1296
  interface CreateTrackingResult<TRegistry extends TriggerRegistryConfig> {
1297
+ /**
1298
+ * Client component provider for the Next.js App Router integration.
1299
+ */
972
1300
  TrackingProvider: (props: TrackingProviderProps) => ReactNode;
1301
+ /**
1302
+ * Hook that returns the registry-typed tracking client.
1303
+ */
973
1304
  useTracking: () => TypedTrackingClient<TRegistry>;
974
1305
  }
975
1306
  /**
976
- * Next.js App Router version of the createTracking factory. Uses
1307
+ * Next.js App Router version of the `createTracking()` factory. Uses
977
1308
  * `usePathname` + `useSearchParams` from `next/navigation` for SPA route
978
1309
  * detection rather than patching `history.pushState`, because Next's
979
1310
  * router does not always go through the History API for transitions.