@aranova/tracking-react 0.15.0 → 0.16.0
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/README.md +43 -0
- package/dist/index.d.mts +129 -5
- package/dist/index.d.ts +129 -5
- package/dist/index.js +252 -63
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +252 -63
- package/dist/index.mjs.map +1 -1
- package/dist/phone.js +88 -62
- package/dist/phone.js.map +1 -1
- package/dist/phone.mjs +88 -62
- package/dist/phone.mjs.map +1 -1
- package/dist/sales.js.map +1 -1
- package/dist/sales.mjs.map +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -119,6 +119,49 @@ tracking.trackEvent("phone_click", {
|
|
|
119
119
|
});
|
|
120
120
|
```
|
|
121
121
|
|
|
122
|
+
### CTA clicks — manual or auto-capture
|
|
123
|
+
|
|
124
|
+
Fire `cta_click` yourself for full control over the name:
|
|
125
|
+
|
|
126
|
+
```tsx
|
|
127
|
+
tracking.trackEvent("cta_click", {
|
|
128
|
+
cta_name: "Book appointment",
|
|
129
|
+
section: "hero",
|
|
130
|
+
destination_url: "/booking",
|
|
131
|
+
page: { path: window.location.pathname },
|
|
132
|
+
});
|
|
133
|
+
```
|
|
134
|
+
|
|
135
|
+
Or opt into **auto-capture** and skip per-button code. Add `autoCapture` to the
|
|
136
|
+
`cta_click` registration — this attaches a single delegated click listener:
|
|
137
|
+
|
|
138
|
+
```tsx
|
|
139
|
+
manual: {
|
|
140
|
+
cta_click: { autoCapture: {} }, // default selector: [data-aranova-cta]
|
|
141
|
+
// or target existing classes: { autoCapture: { selector: "a.cta, .btn-primary" } }
|
|
142
|
+
},
|
|
143
|
+
```
|
|
144
|
+
|
|
145
|
+
Then tag your CTAs in markup — no imports, no handlers:
|
|
146
|
+
|
|
147
|
+
```tsx
|
|
148
|
+
<a href="/booking" data-aranova-cta="Book now" data-aranova-section="hero">Book now</a>
|
|
149
|
+
<button data-aranova-cta="Get a quote">Get a quote</button>
|
|
150
|
+
```
|
|
151
|
+
|
|
152
|
+
`cta_name` resolves to the `data-aranova-cta` value, else the element's trimmed text
|
|
153
|
+
(capped 120 chars), else `tag#id`. `section` comes from an optional `data-aranova-section`;
|
|
154
|
+
`href`/`destination_url` and a short `element` descriptor are captured automatically. Point
|
|
155
|
+
the selector at real CTAs (an explicit attribute is the safe default) — every matching click
|
|
156
|
+
is counted, including ones that later `stopPropagation`.
|
|
157
|
+
|
|
158
|
+
### Automatic dwell + exit (`page_exit`)
|
|
159
|
+
|
|
160
|
+
`page_exit` is captured automatically — no registration. On SPA navigation, tab hide, and
|
|
161
|
+
page unload it records the **active** (visible) time spent on the page plus the max scroll
|
|
162
|
+
depth reached, delivered via a keepalive beacon so the final page still counts. This powers
|
|
163
|
+
per-page dwell and drop-off in the dashboard Analytics tab; there is nothing to configure.
|
|
164
|
+
|
|
122
165
|
## Phone Fields
|
|
123
166
|
|
|
124
167
|
Bundled `libphonenumber-js`: parse/format utils + a React input. Display is configurable; the
|
package/dist/index.d.mts
CHANGED
|
@@ -127,6 +127,8 @@ declare const ctaClickMetadataSchema: z.ZodObject<{
|
|
|
127
127
|
}>;
|
|
128
128
|
section: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
129
129
|
destination_url: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
130
|
+
href: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
131
|
+
element: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
130
132
|
}, "strict", z.ZodTypeAny, {
|
|
131
133
|
page: {
|
|
132
134
|
path: string;
|
|
@@ -134,6 +136,8 @@ declare const ctaClickMetadataSchema: z.ZodObject<{
|
|
|
134
136
|
cta_name: string;
|
|
135
137
|
section?: string | null | undefined;
|
|
136
138
|
destination_url?: string | null | undefined;
|
|
139
|
+
href?: string | null | undefined;
|
|
140
|
+
element?: string | null | undefined;
|
|
137
141
|
}, {
|
|
138
142
|
page: {
|
|
139
143
|
path: string;
|
|
@@ -141,14 +145,34 @@ declare const ctaClickMetadataSchema: z.ZodObject<{
|
|
|
141
145
|
cta_name: string;
|
|
142
146
|
section?: string | null | undefined;
|
|
143
147
|
destination_url?: string | null | undefined;
|
|
148
|
+
href?: string | null | undefined;
|
|
149
|
+
element?: string | null | undefined;
|
|
144
150
|
}>;
|
|
145
151
|
type CtaClickMetadata = z.infer<typeof ctaClickMetadataSchema>;
|
|
146
152
|
/**
|
|
147
153
|
* Registration config for `cta_click`.
|
|
148
154
|
*
|
|
149
|
-
*
|
|
155
|
+
* The event stays manually fireable; `autoCapture` additionally attaches a
|
|
156
|
+
* delegated click listener that fires it for any element matching `selector`
|
|
157
|
+
* (default `[data-aranova-cta]`) — tag your CTAs, get analytics for free.
|
|
150
158
|
*/
|
|
151
|
-
declare const ctaClickConfigSchema: z.ZodObject<{
|
|
159
|
+
declare const ctaClickConfigSchema: z.ZodObject<{
|
|
160
|
+
autoCapture: z.ZodOptional<z.ZodObject<{
|
|
161
|
+
selector: z.ZodOptional<z.ZodString>;
|
|
162
|
+
}, "strict", z.ZodTypeAny, {
|
|
163
|
+
selector?: string | undefined;
|
|
164
|
+
}, {
|
|
165
|
+
selector?: string | undefined;
|
|
166
|
+
}>>;
|
|
167
|
+
}, "strict", z.ZodTypeAny, {
|
|
168
|
+
autoCapture?: {
|
|
169
|
+
selector?: string | undefined;
|
|
170
|
+
} | undefined;
|
|
171
|
+
}, {
|
|
172
|
+
autoCapture?: {
|
|
173
|
+
selector?: string | undefined;
|
|
174
|
+
} | undefined;
|
|
175
|
+
}>;
|
|
152
176
|
type CtaClickConfig = z.infer<typeof ctaClickConfigSchema>;
|
|
153
177
|
|
|
154
178
|
/**
|
|
@@ -312,6 +336,49 @@ declare const multiPageSessionConfigSchema: z.ZodObject<{
|
|
|
312
336
|
}>;
|
|
313
337
|
type MultiPageSessionConfig = z.infer<typeof multiPageSessionConfigSchema>;
|
|
314
338
|
|
|
339
|
+
/**
|
|
340
|
+
* Metadata for the automatic `page_exit` event.
|
|
341
|
+
*
|
|
342
|
+
* Fired when the user leaves a page (SPA navigation away, tab hidden, or
|
|
343
|
+
* pagehide). `dwell_ms` is the ACTIVE (visible) time spent on the page segment
|
|
344
|
+
* being closed — hidden time never counts, matching `time_on_site` semantics.
|
|
345
|
+
* A page revisited after being hidden emits another `page_exit` for the next
|
|
346
|
+
* visible segment, so summing `dwell_ms` per page/session yields total active
|
|
347
|
+
* dwell without double counting.
|
|
348
|
+
*/
|
|
349
|
+
declare const pageExitMetadataSchema: z.ZodObject<{
|
|
350
|
+
dwell_ms: z.ZodNumber;
|
|
351
|
+
max_scroll_percent: z.ZodNullable<z.ZodNumber>;
|
|
352
|
+
page: z.ZodObject<{
|
|
353
|
+
path: z.ZodString;
|
|
354
|
+
}, "strict", z.ZodTypeAny, {
|
|
355
|
+
path: string;
|
|
356
|
+
}, {
|
|
357
|
+
path: string;
|
|
358
|
+
}>;
|
|
359
|
+
}, "strict", z.ZodTypeAny, {
|
|
360
|
+
page: {
|
|
361
|
+
path: string;
|
|
362
|
+
};
|
|
363
|
+
dwell_ms: number;
|
|
364
|
+
max_scroll_percent: number | null;
|
|
365
|
+
}, {
|
|
366
|
+
page: {
|
|
367
|
+
path: string;
|
|
368
|
+
};
|
|
369
|
+
dwell_ms: number;
|
|
370
|
+
max_scroll_percent: number | null;
|
|
371
|
+
}>;
|
|
372
|
+
type PageExitMetadata = z.infer<typeof pageExitMetadataSchema>;
|
|
373
|
+
/**
|
|
374
|
+
* Registration config for automatic `page_exit`.
|
|
375
|
+
*
|
|
376
|
+
* SDK-internal: attached unconditionally (like `sdk_heartbeat`), so there are
|
|
377
|
+
* no registration options.
|
|
378
|
+
*/
|
|
379
|
+
declare const pageExitConfigSchema: z.ZodObject<{}, "strict", z.ZodTypeAny, {}, {}>;
|
|
380
|
+
type PageExitConfig = z.infer<typeof pageExitConfigSchema>;
|
|
381
|
+
|
|
315
382
|
/**
|
|
316
383
|
* Metadata for the automatic `page_view` event.
|
|
317
384
|
*
|
|
@@ -843,6 +910,33 @@ declare const EVENT_REGISTRY: {
|
|
|
843
910
|
}>;
|
|
844
911
|
readonly configSchema: z.ZodObject<{}, "strict", z.ZodTypeAny, {}, {}>;
|
|
845
912
|
};
|
|
913
|
+
readonly page_exit: {
|
|
914
|
+
readonly kind: "automatic";
|
|
915
|
+
readonly metadataSchema: z.ZodObject<{
|
|
916
|
+
dwell_ms: z.ZodNumber;
|
|
917
|
+
max_scroll_percent: z.ZodNullable<z.ZodNumber>;
|
|
918
|
+
page: z.ZodObject<{
|
|
919
|
+
path: z.ZodString;
|
|
920
|
+
}, "strict", z.ZodTypeAny, {
|
|
921
|
+
path: string;
|
|
922
|
+
}, {
|
|
923
|
+
path: string;
|
|
924
|
+
}>;
|
|
925
|
+
}, "strict", z.ZodTypeAny, {
|
|
926
|
+
page: {
|
|
927
|
+
path: string;
|
|
928
|
+
};
|
|
929
|
+
dwell_ms: number;
|
|
930
|
+
max_scroll_percent: number | null;
|
|
931
|
+
}, {
|
|
932
|
+
page: {
|
|
933
|
+
path: string;
|
|
934
|
+
};
|
|
935
|
+
dwell_ms: number;
|
|
936
|
+
max_scroll_percent: number | null;
|
|
937
|
+
}>;
|
|
938
|
+
readonly configSchema: z.ZodObject<{}, "strict", z.ZodTypeAny, {}, {}>;
|
|
939
|
+
};
|
|
846
940
|
readonly form_submit: {
|
|
847
941
|
readonly kind: "manual";
|
|
848
942
|
readonly metadataSchema: z.ZodObject<{
|
|
@@ -962,6 +1056,8 @@ declare const EVENT_REGISTRY: {
|
|
|
962
1056
|
}>;
|
|
963
1057
|
section: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
964
1058
|
destination_url: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
1059
|
+
href: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
1060
|
+
element: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
965
1061
|
}, "strict", z.ZodTypeAny, {
|
|
966
1062
|
page: {
|
|
967
1063
|
path: string;
|
|
@@ -969,6 +1065,8 @@ declare const EVENT_REGISTRY: {
|
|
|
969
1065
|
cta_name: string;
|
|
970
1066
|
section?: string | null | undefined;
|
|
971
1067
|
destination_url?: string | null | undefined;
|
|
1068
|
+
href?: string | null | undefined;
|
|
1069
|
+
element?: string | null | undefined;
|
|
972
1070
|
}, {
|
|
973
1071
|
page: {
|
|
974
1072
|
path: string;
|
|
@@ -976,8 +1074,26 @@ declare const EVENT_REGISTRY: {
|
|
|
976
1074
|
cta_name: string;
|
|
977
1075
|
section?: string | null | undefined;
|
|
978
1076
|
destination_url?: string | null | undefined;
|
|
1077
|
+
href?: string | null | undefined;
|
|
1078
|
+
element?: string | null | undefined;
|
|
1079
|
+
}>;
|
|
1080
|
+
readonly configSchema: z.ZodObject<{
|
|
1081
|
+
autoCapture: z.ZodOptional<z.ZodObject<{
|
|
1082
|
+
selector: z.ZodOptional<z.ZodString>;
|
|
1083
|
+
}, "strict", z.ZodTypeAny, {
|
|
1084
|
+
selector?: string | undefined;
|
|
1085
|
+
}, {
|
|
1086
|
+
selector?: string | undefined;
|
|
1087
|
+
}>>;
|
|
1088
|
+
}, "strict", z.ZodTypeAny, {
|
|
1089
|
+
autoCapture?: {
|
|
1090
|
+
selector?: string | undefined;
|
|
1091
|
+
} | undefined;
|
|
1092
|
+
}, {
|
|
1093
|
+
autoCapture?: {
|
|
1094
|
+
selector?: string | undefined;
|
|
1095
|
+
} | undefined;
|
|
979
1096
|
}>;
|
|
980
|
-
readonly configSchema: z.ZodObject<{}, "strict", z.ZodTypeAny, {}, {}>;
|
|
981
1097
|
};
|
|
982
1098
|
};
|
|
983
1099
|
/**
|
|
@@ -1006,6 +1122,7 @@ type MetadataByName = {
|
|
|
1006
1122
|
multi_page_session: MultiPageSessionMetadata;
|
|
1007
1123
|
form_start: FormStartMetadata;
|
|
1008
1124
|
sdk_heartbeat: SdkHeartbeatMetadata;
|
|
1125
|
+
page_exit: PageExitMetadata;
|
|
1009
1126
|
form_submit: FormSubmitMetadata;
|
|
1010
1127
|
phone_click: PhoneClickMetadata;
|
|
1011
1128
|
cta_click: CtaClickMetadata;
|
|
@@ -1018,6 +1135,7 @@ type ConfigByName = {
|
|
|
1018
1135
|
multi_page_session: MultiPageSessionConfig;
|
|
1019
1136
|
form_start: FormStartConfig;
|
|
1020
1137
|
sdk_heartbeat: SdkHeartbeatConfig;
|
|
1138
|
+
page_exit: PageExitConfig;
|
|
1021
1139
|
form_submit: FormSubmitConfig;
|
|
1022
1140
|
phone_click: PhoneClickConfig;
|
|
1023
1141
|
cta_click: CtaClickConfig;
|
|
@@ -1132,8 +1250,14 @@ interface TrackEventInput {
|
|
|
1132
1250
|
interface TrackingClient {
|
|
1133
1251
|
/** Enqueue an event for batched delivery. */
|
|
1134
1252
|
trackEvent: (input: TrackEventInput) => void;
|
|
1135
|
-
/** Flush queued events immediately. */
|
|
1253
|
+
/** Flush queued events immediately (fetch, non-keepalive). */
|
|
1136
1254
|
flush: () => Promise<void>;
|
|
1255
|
+
/**
|
|
1256
|
+
* Flush queued events through the keepalive transport so the request
|
|
1257
|
+
* survives document unload. Use from `pagehide`/`visibilitychange:hidden`
|
|
1258
|
+
* handlers — a plain `flush()` there is aborted by the browser on unload.
|
|
1259
|
+
*/
|
|
1260
|
+
flushBeacon: () => void;
|
|
1137
1261
|
/** Return the current rolling session id. */
|
|
1138
1262
|
getSessionId: () => string;
|
|
1139
1263
|
/** Return the persistent visitor id. */
|
|
@@ -1482,4 +1606,4 @@ interface PhoneFieldProps extends Omit<InputHTMLAttributes<HTMLInputElement>, "t
|
|
|
1482
1606
|
*/
|
|
1483
1607
|
declare const PhoneField: react.ForwardRefExoticComponent<PhoneFieldProps & react.RefAttributes<HTMLInputElement>>;
|
|
1484
1608
|
|
|
1485
|
-
export { ALL_AUTOMATIC_EVENT_NAMES, ALL_MANUAL_EVENT_NAMES, AdPlatformTracking, type AdPlatformTrackingProps, type AutomaticEventName, ConsentBanner, type ConsentBannerProps, ConsentChoiceState, ConsentSource, ConsentState, ConversionConfig, type CreateTrackingOptions, type CreateTrackingResult, type CtaClickConfig, type CtaClickMetadata, EVENT_REGISTRY, type EventConfig, type EventKind, type EventMetadata, type EventName, type FormStartConfig, type FormStartMetadata, FormSubmitConfig, FormSubmitMetadata, GoogleAdsTracking, type GoogleAdsTrackingProps, GtagEnvironmentMap, type ManualEventName, MetaPixelEnvironmentMap, type MultiPageSessionConfig, type MultiPageSessionMetadata, type PageViewConfig, type PageViewMetadata, ParsedPhone, type PhoneClickConfig, type PhoneClickMetadata, PhoneConfig, PhoneDisplayFormat, PhoneField, type PhoneFieldApi, type PhoneFieldProps, type PhoneInputProps, type RegisteredAutomaticEvents, type RegisteredManualEvents, SPECIFIC_PAGE_NAMES, type ScrollDepthConfig, type ScrollDepthMetadata, type SdkHeartbeatConfig, type SdkHeartbeatMetadata, type SpecificPageName, type SpecificPageVisitConfig, type SpecificPageVisitMetadata, TRACKING_PARAM_KEYS, type TimeOnSiteConfig, type TimeOnSiteMetadata, type TrackableEvent, type TrackingClient, TrackingClientContext, TrackingEventCreatePayload, TrackingInstallSurface, TrackingParams, type TrackingProviderProps, TrackingSessionUpsertPayload, type TriggerRegistryConfig, type TypedTrackEventOptions, type TypedTrackingClient, type UseConsentResult, type UseCookiePreferencesOptions, type UseCookiePreferencesResult, type UsePhoneFieldOptions, captureTrackingParamsFromLocation, createTracking, createTrackingClientContext, createTrackingEventCreatePayload, createTrackingSessionUpsertPayload, ctaClickConfigSchema, ctaClickMetadataSchema, formStartConfigSchema, formStartMetadataSchema, getEventDefinition, multiPageSessionConfigSchema, multiPageSessionMetadataSchema, pageViewConfigSchema, pageViewMetadataSchema, phoneClickConfigSchema, phoneClickMetadataSchema, scrollDepthConfigSchema, scrollDepthMetadataSchema, sdkHeartbeatConfigSchema, sdkHeartbeatMetadataSchema, sdkHeartbeatTriggersSchema, specificPageNameSchema, specificPageVisitConfigSchema, specificPageVisitMetadataSchema, timeOnSiteConfigSchema, timeOnSiteMetadataSchema, useConsent, useConsentState, useCookiePreferences, useGclid, usePhoneConfig, usePhoneField, useTrackingParams };
|
|
1609
|
+
export { ALL_AUTOMATIC_EVENT_NAMES, ALL_MANUAL_EVENT_NAMES, AdPlatformTracking, type AdPlatformTrackingProps, type AutomaticEventName, ConsentBanner, type ConsentBannerProps, ConsentChoiceState, ConsentSource, ConsentState, ConversionConfig, type CreateTrackingOptions, type CreateTrackingResult, type CtaClickConfig, type CtaClickMetadata, EVENT_REGISTRY, type EventConfig, type EventKind, type EventMetadata, type EventName, type FormStartConfig, type FormStartMetadata, FormSubmitConfig, FormSubmitMetadata, GoogleAdsTracking, type GoogleAdsTrackingProps, GtagEnvironmentMap, type ManualEventName, MetaPixelEnvironmentMap, type MultiPageSessionConfig, type MultiPageSessionMetadata, type PageExitConfig, type PageExitMetadata, type PageViewConfig, type PageViewMetadata, ParsedPhone, type PhoneClickConfig, type PhoneClickMetadata, PhoneConfig, PhoneDisplayFormat, PhoneField, type PhoneFieldApi, type PhoneFieldProps, type PhoneInputProps, type RegisteredAutomaticEvents, type RegisteredManualEvents, SPECIFIC_PAGE_NAMES, type ScrollDepthConfig, type ScrollDepthMetadata, type SdkHeartbeatConfig, type SdkHeartbeatMetadata, type SpecificPageName, type SpecificPageVisitConfig, type SpecificPageVisitMetadata, TRACKING_PARAM_KEYS, type TimeOnSiteConfig, type TimeOnSiteMetadata, type TrackableEvent, type TrackingClient, TrackingClientContext, TrackingEventCreatePayload, TrackingInstallSurface, TrackingParams, type TrackingProviderProps, TrackingSessionUpsertPayload, type TriggerRegistryConfig, type TypedTrackEventOptions, type TypedTrackingClient, type UseConsentResult, type UseCookiePreferencesOptions, type UseCookiePreferencesResult, type UsePhoneFieldOptions, captureTrackingParamsFromLocation, createTracking, createTrackingClientContext, createTrackingEventCreatePayload, createTrackingSessionUpsertPayload, ctaClickConfigSchema, ctaClickMetadataSchema, formStartConfigSchema, formStartMetadataSchema, getEventDefinition, multiPageSessionConfigSchema, multiPageSessionMetadataSchema, pageExitConfigSchema, pageExitMetadataSchema, pageViewConfigSchema, pageViewMetadataSchema, phoneClickConfigSchema, phoneClickMetadataSchema, scrollDepthConfigSchema, scrollDepthMetadataSchema, sdkHeartbeatConfigSchema, sdkHeartbeatMetadataSchema, sdkHeartbeatTriggersSchema, specificPageNameSchema, specificPageVisitConfigSchema, specificPageVisitMetadataSchema, timeOnSiteConfigSchema, timeOnSiteMetadataSchema, useConsent, useConsentState, useCookiePreferences, useGclid, usePhoneConfig, usePhoneField, useTrackingParams };
|
package/dist/index.d.ts
CHANGED
|
@@ -127,6 +127,8 @@ declare const ctaClickMetadataSchema: z.ZodObject<{
|
|
|
127
127
|
}>;
|
|
128
128
|
section: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
129
129
|
destination_url: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
130
|
+
href: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
131
|
+
element: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
130
132
|
}, "strict", z.ZodTypeAny, {
|
|
131
133
|
page: {
|
|
132
134
|
path: string;
|
|
@@ -134,6 +136,8 @@ declare const ctaClickMetadataSchema: z.ZodObject<{
|
|
|
134
136
|
cta_name: string;
|
|
135
137
|
section?: string | null | undefined;
|
|
136
138
|
destination_url?: string | null | undefined;
|
|
139
|
+
href?: string | null | undefined;
|
|
140
|
+
element?: string | null | undefined;
|
|
137
141
|
}, {
|
|
138
142
|
page: {
|
|
139
143
|
path: string;
|
|
@@ -141,14 +145,34 @@ declare const ctaClickMetadataSchema: z.ZodObject<{
|
|
|
141
145
|
cta_name: string;
|
|
142
146
|
section?: string | null | undefined;
|
|
143
147
|
destination_url?: string | null | undefined;
|
|
148
|
+
href?: string | null | undefined;
|
|
149
|
+
element?: string | null | undefined;
|
|
144
150
|
}>;
|
|
145
151
|
type CtaClickMetadata = z.infer<typeof ctaClickMetadataSchema>;
|
|
146
152
|
/**
|
|
147
153
|
* Registration config for `cta_click`.
|
|
148
154
|
*
|
|
149
|
-
*
|
|
155
|
+
* The event stays manually fireable; `autoCapture` additionally attaches a
|
|
156
|
+
* delegated click listener that fires it for any element matching `selector`
|
|
157
|
+
* (default `[data-aranova-cta]`) — tag your CTAs, get analytics for free.
|
|
150
158
|
*/
|
|
151
|
-
declare const ctaClickConfigSchema: z.ZodObject<{
|
|
159
|
+
declare const ctaClickConfigSchema: z.ZodObject<{
|
|
160
|
+
autoCapture: z.ZodOptional<z.ZodObject<{
|
|
161
|
+
selector: z.ZodOptional<z.ZodString>;
|
|
162
|
+
}, "strict", z.ZodTypeAny, {
|
|
163
|
+
selector?: string | undefined;
|
|
164
|
+
}, {
|
|
165
|
+
selector?: string | undefined;
|
|
166
|
+
}>>;
|
|
167
|
+
}, "strict", z.ZodTypeAny, {
|
|
168
|
+
autoCapture?: {
|
|
169
|
+
selector?: string | undefined;
|
|
170
|
+
} | undefined;
|
|
171
|
+
}, {
|
|
172
|
+
autoCapture?: {
|
|
173
|
+
selector?: string | undefined;
|
|
174
|
+
} | undefined;
|
|
175
|
+
}>;
|
|
152
176
|
type CtaClickConfig = z.infer<typeof ctaClickConfigSchema>;
|
|
153
177
|
|
|
154
178
|
/**
|
|
@@ -312,6 +336,49 @@ declare const multiPageSessionConfigSchema: z.ZodObject<{
|
|
|
312
336
|
}>;
|
|
313
337
|
type MultiPageSessionConfig = z.infer<typeof multiPageSessionConfigSchema>;
|
|
314
338
|
|
|
339
|
+
/**
|
|
340
|
+
* Metadata for the automatic `page_exit` event.
|
|
341
|
+
*
|
|
342
|
+
* Fired when the user leaves a page (SPA navigation away, tab hidden, or
|
|
343
|
+
* pagehide). `dwell_ms` is the ACTIVE (visible) time spent on the page segment
|
|
344
|
+
* being closed — hidden time never counts, matching `time_on_site` semantics.
|
|
345
|
+
* A page revisited after being hidden emits another `page_exit` for the next
|
|
346
|
+
* visible segment, so summing `dwell_ms` per page/session yields total active
|
|
347
|
+
* dwell without double counting.
|
|
348
|
+
*/
|
|
349
|
+
declare const pageExitMetadataSchema: z.ZodObject<{
|
|
350
|
+
dwell_ms: z.ZodNumber;
|
|
351
|
+
max_scroll_percent: z.ZodNullable<z.ZodNumber>;
|
|
352
|
+
page: z.ZodObject<{
|
|
353
|
+
path: z.ZodString;
|
|
354
|
+
}, "strict", z.ZodTypeAny, {
|
|
355
|
+
path: string;
|
|
356
|
+
}, {
|
|
357
|
+
path: string;
|
|
358
|
+
}>;
|
|
359
|
+
}, "strict", z.ZodTypeAny, {
|
|
360
|
+
page: {
|
|
361
|
+
path: string;
|
|
362
|
+
};
|
|
363
|
+
dwell_ms: number;
|
|
364
|
+
max_scroll_percent: number | null;
|
|
365
|
+
}, {
|
|
366
|
+
page: {
|
|
367
|
+
path: string;
|
|
368
|
+
};
|
|
369
|
+
dwell_ms: number;
|
|
370
|
+
max_scroll_percent: number | null;
|
|
371
|
+
}>;
|
|
372
|
+
type PageExitMetadata = z.infer<typeof pageExitMetadataSchema>;
|
|
373
|
+
/**
|
|
374
|
+
* Registration config for automatic `page_exit`.
|
|
375
|
+
*
|
|
376
|
+
* SDK-internal: attached unconditionally (like `sdk_heartbeat`), so there are
|
|
377
|
+
* no registration options.
|
|
378
|
+
*/
|
|
379
|
+
declare const pageExitConfigSchema: z.ZodObject<{}, "strict", z.ZodTypeAny, {}, {}>;
|
|
380
|
+
type PageExitConfig = z.infer<typeof pageExitConfigSchema>;
|
|
381
|
+
|
|
315
382
|
/**
|
|
316
383
|
* Metadata for the automatic `page_view` event.
|
|
317
384
|
*
|
|
@@ -843,6 +910,33 @@ declare const EVENT_REGISTRY: {
|
|
|
843
910
|
}>;
|
|
844
911
|
readonly configSchema: z.ZodObject<{}, "strict", z.ZodTypeAny, {}, {}>;
|
|
845
912
|
};
|
|
913
|
+
readonly page_exit: {
|
|
914
|
+
readonly kind: "automatic";
|
|
915
|
+
readonly metadataSchema: z.ZodObject<{
|
|
916
|
+
dwell_ms: z.ZodNumber;
|
|
917
|
+
max_scroll_percent: z.ZodNullable<z.ZodNumber>;
|
|
918
|
+
page: z.ZodObject<{
|
|
919
|
+
path: z.ZodString;
|
|
920
|
+
}, "strict", z.ZodTypeAny, {
|
|
921
|
+
path: string;
|
|
922
|
+
}, {
|
|
923
|
+
path: string;
|
|
924
|
+
}>;
|
|
925
|
+
}, "strict", z.ZodTypeAny, {
|
|
926
|
+
page: {
|
|
927
|
+
path: string;
|
|
928
|
+
};
|
|
929
|
+
dwell_ms: number;
|
|
930
|
+
max_scroll_percent: number | null;
|
|
931
|
+
}, {
|
|
932
|
+
page: {
|
|
933
|
+
path: string;
|
|
934
|
+
};
|
|
935
|
+
dwell_ms: number;
|
|
936
|
+
max_scroll_percent: number | null;
|
|
937
|
+
}>;
|
|
938
|
+
readonly configSchema: z.ZodObject<{}, "strict", z.ZodTypeAny, {}, {}>;
|
|
939
|
+
};
|
|
846
940
|
readonly form_submit: {
|
|
847
941
|
readonly kind: "manual";
|
|
848
942
|
readonly metadataSchema: z.ZodObject<{
|
|
@@ -962,6 +1056,8 @@ declare const EVENT_REGISTRY: {
|
|
|
962
1056
|
}>;
|
|
963
1057
|
section: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
964
1058
|
destination_url: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
1059
|
+
href: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
1060
|
+
element: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
965
1061
|
}, "strict", z.ZodTypeAny, {
|
|
966
1062
|
page: {
|
|
967
1063
|
path: string;
|
|
@@ -969,6 +1065,8 @@ declare const EVENT_REGISTRY: {
|
|
|
969
1065
|
cta_name: string;
|
|
970
1066
|
section?: string | null | undefined;
|
|
971
1067
|
destination_url?: string | null | undefined;
|
|
1068
|
+
href?: string | null | undefined;
|
|
1069
|
+
element?: string | null | undefined;
|
|
972
1070
|
}, {
|
|
973
1071
|
page: {
|
|
974
1072
|
path: string;
|
|
@@ -976,8 +1074,26 @@ declare const EVENT_REGISTRY: {
|
|
|
976
1074
|
cta_name: string;
|
|
977
1075
|
section?: string | null | undefined;
|
|
978
1076
|
destination_url?: string | null | undefined;
|
|
1077
|
+
href?: string | null | undefined;
|
|
1078
|
+
element?: string | null | undefined;
|
|
1079
|
+
}>;
|
|
1080
|
+
readonly configSchema: z.ZodObject<{
|
|
1081
|
+
autoCapture: z.ZodOptional<z.ZodObject<{
|
|
1082
|
+
selector: z.ZodOptional<z.ZodString>;
|
|
1083
|
+
}, "strict", z.ZodTypeAny, {
|
|
1084
|
+
selector?: string | undefined;
|
|
1085
|
+
}, {
|
|
1086
|
+
selector?: string | undefined;
|
|
1087
|
+
}>>;
|
|
1088
|
+
}, "strict", z.ZodTypeAny, {
|
|
1089
|
+
autoCapture?: {
|
|
1090
|
+
selector?: string | undefined;
|
|
1091
|
+
} | undefined;
|
|
1092
|
+
}, {
|
|
1093
|
+
autoCapture?: {
|
|
1094
|
+
selector?: string | undefined;
|
|
1095
|
+
} | undefined;
|
|
979
1096
|
}>;
|
|
980
|
-
readonly configSchema: z.ZodObject<{}, "strict", z.ZodTypeAny, {}, {}>;
|
|
981
1097
|
};
|
|
982
1098
|
};
|
|
983
1099
|
/**
|
|
@@ -1006,6 +1122,7 @@ type MetadataByName = {
|
|
|
1006
1122
|
multi_page_session: MultiPageSessionMetadata;
|
|
1007
1123
|
form_start: FormStartMetadata;
|
|
1008
1124
|
sdk_heartbeat: SdkHeartbeatMetadata;
|
|
1125
|
+
page_exit: PageExitMetadata;
|
|
1009
1126
|
form_submit: FormSubmitMetadata;
|
|
1010
1127
|
phone_click: PhoneClickMetadata;
|
|
1011
1128
|
cta_click: CtaClickMetadata;
|
|
@@ -1018,6 +1135,7 @@ type ConfigByName = {
|
|
|
1018
1135
|
multi_page_session: MultiPageSessionConfig;
|
|
1019
1136
|
form_start: FormStartConfig;
|
|
1020
1137
|
sdk_heartbeat: SdkHeartbeatConfig;
|
|
1138
|
+
page_exit: PageExitConfig;
|
|
1021
1139
|
form_submit: FormSubmitConfig;
|
|
1022
1140
|
phone_click: PhoneClickConfig;
|
|
1023
1141
|
cta_click: CtaClickConfig;
|
|
@@ -1132,8 +1250,14 @@ interface TrackEventInput {
|
|
|
1132
1250
|
interface TrackingClient {
|
|
1133
1251
|
/** Enqueue an event for batched delivery. */
|
|
1134
1252
|
trackEvent: (input: TrackEventInput) => void;
|
|
1135
|
-
/** Flush queued events immediately. */
|
|
1253
|
+
/** Flush queued events immediately (fetch, non-keepalive). */
|
|
1136
1254
|
flush: () => Promise<void>;
|
|
1255
|
+
/**
|
|
1256
|
+
* Flush queued events through the keepalive transport so the request
|
|
1257
|
+
* survives document unload. Use from `pagehide`/`visibilitychange:hidden`
|
|
1258
|
+
* handlers — a plain `flush()` there is aborted by the browser on unload.
|
|
1259
|
+
*/
|
|
1260
|
+
flushBeacon: () => void;
|
|
1137
1261
|
/** Return the current rolling session id. */
|
|
1138
1262
|
getSessionId: () => string;
|
|
1139
1263
|
/** Return the persistent visitor id. */
|
|
@@ -1482,4 +1606,4 @@ interface PhoneFieldProps extends Omit<InputHTMLAttributes<HTMLInputElement>, "t
|
|
|
1482
1606
|
*/
|
|
1483
1607
|
declare const PhoneField: react.ForwardRefExoticComponent<PhoneFieldProps & react.RefAttributes<HTMLInputElement>>;
|
|
1484
1608
|
|
|
1485
|
-
export { ALL_AUTOMATIC_EVENT_NAMES, ALL_MANUAL_EVENT_NAMES, AdPlatformTracking, type AdPlatformTrackingProps, type AutomaticEventName, ConsentBanner, type ConsentBannerProps, ConsentChoiceState, ConsentSource, ConsentState, ConversionConfig, type CreateTrackingOptions, type CreateTrackingResult, type CtaClickConfig, type CtaClickMetadata, EVENT_REGISTRY, type EventConfig, type EventKind, type EventMetadata, type EventName, type FormStartConfig, type FormStartMetadata, FormSubmitConfig, FormSubmitMetadata, GoogleAdsTracking, type GoogleAdsTrackingProps, GtagEnvironmentMap, type ManualEventName, MetaPixelEnvironmentMap, type MultiPageSessionConfig, type MultiPageSessionMetadata, type PageViewConfig, type PageViewMetadata, ParsedPhone, type PhoneClickConfig, type PhoneClickMetadata, PhoneConfig, PhoneDisplayFormat, PhoneField, type PhoneFieldApi, type PhoneFieldProps, type PhoneInputProps, type RegisteredAutomaticEvents, type RegisteredManualEvents, SPECIFIC_PAGE_NAMES, type ScrollDepthConfig, type ScrollDepthMetadata, type SdkHeartbeatConfig, type SdkHeartbeatMetadata, type SpecificPageName, type SpecificPageVisitConfig, type SpecificPageVisitMetadata, TRACKING_PARAM_KEYS, type TimeOnSiteConfig, type TimeOnSiteMetadata, type TrackableEvent, type TrackingClient, TrackingClientContext, TrackingEventCreatePayload, TrackingInstallSurface, TrackingParams, type TrackingProviderProps, TrackingSessionUpsertPayload, type TriggerRegistryConfig, type TypedTrackEventOptions, type TypedTrackingClient, type UseConsentResult, type UseCookiePreferencesOptions, type UseCookiePreferencesResult, type UsePhoneFieldOptions, captureTrackingParamsFromLocation, createTracking, createTrackingClientContext, createTrackingEventCreatePayload, createTrackingSessionUpsertPayload, ctaClickConfigSchema, ctaClickMetadataSchema, formStartConfigSchema, formStartMetadataSchema, getEventDefinition, multiPageSessionConfigSchema, multiPageSessionMetadataSchema, pageViewConfigSchema, pageViewMetadataSchema, phoneClickConfigSchema, phoneClickMetadataSchema, scrollDepthConfigSchema, scrollDepthMetadataSchema, sdkHeartbeatConfigSchema, sdkHeartbeatMetadataSchema, sdkHeartbeatTriggersSchema, specificPageNameSchema, specificPageVisitConfigSchema, specificPageVisitMetadataSchema, timeOnSiteConfigSchema, timeOnSiteMetadataSchema, useConsent, useConsentState, useCookiePreferences, useGclid, usePhoneConfig, usePhoneField, useTrackingParams };
|
|
1609
|
+
export { ALL_AUTOMATIC_EVENT_NAMES, ALL_MANUAL_EVENT_NAMES, AdPlatformTracking, type AdPlatformTrackingProps, type AutomaticEventName, ConsentBanner, type ConsentBannerProps, ConsentChoiceState, ConsentSource, ConsentState, ConversionConfig, type CreateTrackingOptions, type CreateTrackingResult, type CtaClickConfig, type CtaClickMetadata, EVENT_REGISTRY, type EventConfig, type EventKind, type EventMetadata, type EventName, type FormStartConfig, type FormStartMetadata, FormSubmitConfig, FormSubmitMetadata, GoogleAdsTracking, type GoogleAdsTrackingProps, GtagEnvironmentMap, type ManualEventName, MetaPixelEnvironmentMap, type MultiPageSessionConfig, type MultiPageSessionMetadata, type PageExitConfig, type PageExitMetadata, type PageViewConfig, type PageViewMetadata, ParsedPhone, type PhoneClickConfig, type PhoneClickMetadata, PhoneConfig, PhoneDisplayFormat, PhoneField, type PhoneFieldApi, type PhoneFieldProps, type PhoneInputProps, type RegisteredAutomaticEvents, type RegisteredManualEvents, SPECIFIC_PAGE_NAMES, type ScrollDepthConfig, type ScrollDepthMetadata, type SdkHeartbeatConfig, type SdkHeartbeatMetadata, type SpecificPageName, type SpecificPageVisitConfig, type SpecificPageVisitMetadata, TRACKING_PARAM_KEYS, type TimeOnSiteConfig, type TimeOnSiteMetadata, type TrackableEvent, type TrackingClient, TrackingClientContext, TrackingEventCreatePayload, TrackingInstallSurface, TrackingParams, type TrackingProviderProps, TrackingSessionUpsertPayload, type TriggerRegistryConfig, type TypedTrackEventOptions, type TypedTrackingClient, type UseConsentResult, type UseCookiePreferencesOptions, type UseCookiePreferencesResult, type UsePhoneFieldOptions, captureTrackingParamsFromLocation, createTracking, createTrackingClientContext, createTrackingEventCreatePayload, createTrackingSessionUpsertPayload, ctaClickConfigSchema, ctaClickMetadataSchema, formStartConfigSchema, formStartMetadataSchema, getEventDefinition, multiPageSessionConfigSchema, multiPageSessionMetadataSchema, pageExitConfigSchema, pageExitMetadataSchema, pageViewConfigSchema, pageViewMetadataSchema, phoneClickConfigSchema, phoneClickMetadataSchema, scrollDepthConfigSchema, scrollDepthMetadataSchema, sdkHeartbeatConfigSchema, sdkHeartbeatMetadataSchema, sdkHeartbeatTriggersSchema, specificPageNameSchema, specificPageVisitConfigSchema, specificPageVisitMetadataSchema, timeOnSiteConfigSchema, timeOnSiteMetadataSchema, useConsent, useConsentState, useCookiePreferences, useGclid, usePhoneConfig, usePhoneField, useTrackingParams };
|