@shware/analytics 8.13.0 → 8.14.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/dist/attribution/classify.d.cts +6 -7
- package/dist/attribution/classify.d.cts.map +1 -1
- package/dist/attribution/classify.d.mts +6 -7
- package/dist/attribution/classify.d.mts.map +1 -1
- package/dist/attribution/vocabulary.d.cts +24 -25
- package/dist/attribution/vocabulary.d.cts.map +1 -1
- package/dist/attribution/vocabulary.d.mts +24 -25
- package/dist/attribution/vocabulary.d.mts.map +1 -1
- package/dist/click-id/index.d.cts +18 -19
- package/dist/click-id/index.d.cts.map +1 -1
- package/dist/click-id/index.d.mts +18 -19
- package/dist/click-id/index.d.mts.map +1 -1
- package/dist/constants/storage.d.cts +1 -2
- package/dist/constants/storage.d.cts.map +1 -1
- package/dist/constants/storage.d.mts +1 -2
- package/dist/constants/storage.d.mts.map +1 -1
- package/dist/feedback/index.d.cts +1 -2
- package/dist/feedback/index.d.cts.map +1 -1
- package/dist/feedback/index.d.mts +1 -2
- package/dist/feedback/index.d.mts.map +1 -1
- package/dist/hooks/use-app-analytics.d.cts +1 -2
- package/dist/hooks/use-app-analytics.d.cts.map +1 -1
- package/dist/hooks/use-app-analytics.d.mts +1 -2
- package/dist/hooks/use-app-analytics.d.mts.map +1 -1
- package/dist/hooks/use-outbound-click-analytics.d.cts +1 -2
- package/dist/hooks/use-outbound-click-analytics.d.cts.map +1 -1
- package/dist/hooks/use-outbound-click-analytics.d.mts +1 -2
- package/dist/hooks/use-outbound-click-analytics.d.mts.map +1 -1
- package/dist/hooks/use-previous.d.cts +1 -2
- package/dist/hooks/use-previous.d.cts.map +1 -1
- package/dist/hooks/use-previous.d.mts +1 -2
- package/dist/hooks/use-previous.d.mts.map +1 -1
- package/dist/hooks/use-report-web-vitals.d.cts +1 -2
- package/dist/hooks/use-report-web-vitals.d.cts.map +1 -1
- package/dist/hooks/use-report-web-vitals.d.mts +1 -2
- package/dist/hooks/use-report-web-vitals.d.mts.map +1 -1
- package/dist/hooks/use-track-impression.d.cts +1 -2
- package/dist/hooks/use-track-impression.d.cts.map +1 -1
- package/dist/hooks/use-track-impression.d.mts +1 -2
- package/dist/hooks/use-track-impression.d.mts.map +1 -1
- package/dist/hooks/use-uet-id-sync.d.cts +1 -2
- package/dist/hooks/use-uet-id-sync.d.cts.map +1 -1
- package/dist/hooks/use-uet-id-sync.d.mts +1 -2
- package/dist/hooks/use-uet-id-sync.d.mts.map +1 -1
- package/dist/hooks/use-web-analytics.d.cts +1 -2
- package/dist/hooks/use-web-analytics.d.cts.map +1 -1
- package/dist/hooks/use-web-analytics.d.mts +1 -2
- package/dist/hooks/use-web-analytics.d.mts.map +1 -1
- package/dist/link/index.d.cts +3 -4
- package/dist/link/index.d.cts.map +1 -1
- package/dist/link/index.d.mts +3 -4
- package/dist/link/index.d.mts.map +1 -1
- package/dist/native/fbsdk.d.cts +1 -2
- package/dist/native/fbsdk.d.cts.map +1 -1
- package/dist/native/fbsdk.d.mts +1 -2
- package/dist/native/fbsdk.d.mts.map +1 -1
- package/dist/native/fingerprint.d.cts +4 -5
- package/dist/native/fingerprint.d.cts.map +1 -1
- package/dist/native/fingerprint.d.mts +4 -5
- package/dist/native/fingerprint.d.mts.map +1 -1
- package/dist/native/firebase.d.cts +1 -2
- package/dist/native/firebase.d.cts.map +1 -1
- package/dist/native/firebase.d.mts +1 -2
- package/dist/native/firebase.d.mts.map +1 -1
- package/dist/native/posthog.d.cts +1 -2
- package/dist/native/posthog.d.cts.map +1 -1
- package/dist/native/posthog.d.mts +1 -2
- package/dist/native/posthog.d.mts.map +1 -1
- package/dist/native/setup.d.cts +4 -5
- package/dist/native/setup.d.cts.map +1 -1
- package/dist/native/setup.d.mts +4 -5
- package/dist/native/setup.d.mts.map +1 -1
- package/dist/next/index.cjs +14 -14
- package/dist/next/index.cjs.map +1 -1
- package/dist/next/index.d.cts +1 -2
- package/dist/next/index.d.cts.map +1 -1
- package/dist/next/index.d.mts +1 -2
- package/dist/next/index.d.mts.map +1 -1
- package/dist/next/index.mjs +3 -3
- package/dist/react-router/index.d.cts +1 -2
- package/dist/react-router/index.d.cts.map +1 -1
- package/dist/react-router/index.d.mts +1 -2
- package/dist/react-router/index.d.mts.map +1 -1
- package/dist/schema/index.cjs +32 -2
- package/dist/schema/index.cjs.map +1 -1
- package/dist/schema/index.d.cts +155 -18
- package/dist/schema/index.d.cts.map +1 -1
- package/dist/schema/index.d.mts +155 -18
- package/dist/schema/index.d.mts.map +1 -1
- package/dist/schema/index.mjs +32 -2
- package/dist/schema/index.mjs.map +1 -1
- package/dist/server/action-source.d.cts +3 -4
- package/dist/server/action-source.d.cts.map +1 -1
- package/dist/server/action-source.d.mts +3 -4
- package/dist/server/action-source.d.mts.map +1 -1
- package/dist/server/google-data-manager.d.cts +9 -10
- package/dist/server/google-data-manager.d.cts.map +1 -1
- package/dist/server/google-data-manager.d.mts +9 -10
- package/dist/server/google-data-manager.d.mts.map +1 -1
- package/dist/server/linkedin-conversions-api.d.cts +4 -5
- package/dist/server/linkedin-conversions-api.d.cts.map +1 -1
- package/dist/server/linkedin-conversions-api.d.mts +4 -5
- package/dist/server/linkedin-conversions-api.d.mts.map +1 -1
- package/dist/server/meta-capi.d.cts +5 -6
- package/dist/server/meta-capi.d.cts.map +1 -1
- package/dist/server/meta-capi.d.mts +5 -6
- package/dist/server/meta-capi.d.mts.map +1 -1
- package/dist/server/meta-conversions-api.d.cts +4 -5
- package/dist/server/meta-conversions-api.d.cts.map +1 -1
- package/dist/server/meta-conversions-api.d.mts +4 -5
- package/dist/server/meta-conversions-api.d.mts.map +1 -1
- package/dist/server/microsoft-conversions-api.d.cts +11 -12
- package/dist/server/microsoft-conversions-api.d.cts.map +1 -1
- package/dist/server/microsoft-conversions-api.d.mts +11 -12
- package/dist/server/microsoft-conversions-api.d.mts.map +1 -1
- package/dist/server/openai-conversions-api.d.cts +5 -6
- package/dist/server/openai-conversions-api.d.cts.map +1 -1
- package/dist/server/openai-conversions-api.d.mts +5 -6
- package/dist/server/openai-conversions-api.d.mts.map +1 -1
- package/dist/server/page-location.d.cts +1 -2
- package/dist/server/page-location.d.cts.map +1 -1
- package/dist/server/page-location.d.mts +1 -2
- package/dist/server/page-location.d.mts.map +1 -1
- package/dist/server/reddit-conversions-api.d.cts +4 -5
- package/dist/server/reddit-conversions-api.d.cts.map +1 -1
- package/dist/server/reddit-conversions-api.d.mts +4 -5
- package/dist/server/reddit-conversions-api.d.mts.map +1 -1
- package/dist/setup/index.d.cts +5 -6
- package/dist/setup/index.d.cts.map +1 -1
- package/dist/setup/index.d.mts +5 -6
- package/dist/setup/index.d.mts.map +1 -1
- package/dist/setup/session.d.cts +2 -3
- package/dist/setup/session.d.cts.map +1 -1
- package/dist/setup/session.d.mts +2 -3
- package/dist/setup/session.d.mts.map +1 -1
- package/dist/tanstack/analytics.d.cts +1 -2
- package/dist/tanstack/analytics.d.cts.map +1 -1
- package/dist/tanstack/analytics.d.mts +1 -2
- package/dist/tanstack/analytics.d.mts.map +1 -1
- package/dist/tanstack/middleware.d.cts +3 -4
- package/dist/tanstack/middleware.d.cts.map +1 -1
- package/dist/tanstack/middleware.d.mts +3 -4
- package/dist/tanstack/middleware.d.mts.map +1 -1
- package/dist/test/setup.d.cts +3 -4
- package/dist/test/setup.d.cts.map +1 -1
- package/dist/test/setup.d.mts +3 -4
- package/dist/test/setup.d.mts.map +1 -1
- package/dist/third-parties/google-analytics.d.cts +2 -3
- package/dist/third-parties/google-analytics.d.cts.map +1 -1
- package/dist/third-parties/google-analytics.d.mts +2 -3
- package/dist/third-parties/google-analytics.d.mts.map +1 -1
- package/dist/third-parties/ignored-events.d.cts +1 -2
- package/dist/third-parties/ignored-events.d.cts.map +1 -1
- package/dist/third-parties/ignored-events.d.mts +1 -2
- package/dist/third-parties/ignored-events.d.mts.map +1 -1
- package/dist/third-parties/linkedin-insight-tag.d.cts +3 -4
- package/dist/third-parties/linkedin-insight-tag.d.cts.map +1 -1
- package/dist/third-parties/linkedin-insight-tag.d.mts +3 -4
- package/dist/third-parties/linkedin-insight-tag.d.mts.map +1 -1
- package/dist/third-parties/meta-pixel.d.cts +2 -3
- package/dist/third-parties/meta-pixel.d.cts.map +1 -1
- package/dist/third-parties/meta-pixel.d.mts +2 -3
- package/dist/third-parties/meta-pixel.d.mts.map +1 -1
- package/dist/third-parties/microsoft-uet.d.cts +6 -7
- package/dist/third-parties/microsoft-uet.d.cts.map +1 -1
- package/dist/third-parties/microsoft-uet.d.mts +6 -7
- package/dist/third-parties/microsoft-uet.d.mts.map +1 -1
- package/dist/third-parties/openai-pixel.d.cts +2 -3
- package/dist/third-parties/openai-pixel.d.cts.map +1 -1
- package/dist/third-parties/openai-pixel.d.mts +2 -3
- package/dist/third-parties/openai-pixel.d.mts.map +1 -1
- package/dist/third-parties/posthog.d.cts +2 -3
- package/dist/third-parties/posthog.d.cts.map +1 -1
- package/dist/third-parties/posthog.d.mts +2 -3
- package/dist/third-parties/posthog.d.mts.map +1 -1
- package/dist/third-parties/reddit-pixel.d.cts +2 -3
- package/dist/third-parties/reddit-pixel.d.cts.map +1 -1
- package/dist/third-parties/reddit-pixel.d.mts +2 -3
- package/dist/third-parties/reddit-pixel.d.mts.map +1 -1
- package/dist/track/fbq.d.cts +10 -11
- package/dist/track/fbq.d.cts.map +1 -1
- package/dist/track/fbq.d.mts +10 -11
- package/dist/track/fbq.d.mts.map +1 -1
- package/dist/track/gtag.d.cts +26 -27
- package/dist/track/gtag.d.cts.map +1 -1
- package/dist/track/gtag.d.mts +26 -27
- package/dist/track/gtag.d.mts.map +1 -1
- package/dist/track/index.d.cts +4 -5
- package/dist/track/index.d.cts.map +1 -1
- package/dist/track/index.d.mts +4 -5
- package/dist/track/index.d.mts.map +1 -1
- package/dist/track/lintrk.d.cts +1 -2
- package/dist/track/lintrk.d.cts.map +1 -1
- package/dist/track/lintrk.d.mts +1 -2
- package/dist/track/lintrk.d.mts.map +1 -1
- package/dist/track/oaiq.d.cts +17 -18
- package/dist/track/oaiq.d.cts.map +1 -1
- package/dist/track/oaiq.d.mts +17 -18
- package/dist/track/oaiq.d.mts.map +1 -1
- package/dist/track/rdt.d.cts +10 -11
- package/dist/track/rdt.d.cts.map +1 -1
- package/dist/track/rdt.d.mts +10 -11
- package/dist/track/rdt.d.mts.map +1 -1
- package/dist/track/types.d.cts +20 -21
- package/dist/track/types.d.cts.map +1 -1
- package/dist/track/types.d.mts +20 -21
- package/dist/track/types.d.mts.map +1 -1
- package/dist/track/uetq.d.cts +8 -9
- package/dist/track/uetq.d.cts.map +1 -1
- package/dist/track/uetq.d.mts +8 -9
- package/dist/track/uetq.d.mts.map +1 -1
- package/dist/utils/field.d.cts +1 -2
- package/dist/utils/field.d.cts.map +1 -1
- package/dist/utils/field.d.mts +1 -2
- package/dist/utils/field.d.mts.map +1 -1
- package/dist/utils/sha256.d.cts +1 -2
- package/dist/utils/sha256.d.cts.map +1 -1
- package/dist/utils/sha256.d.mts +1 -2
- package/dist/utils/sha256.d.mts.map +1 -1
- package/dist/utils/stripe.d.cts +2 -3
- package/dist/utils/stripe.d.cts.map +1 -1
- package/dist/utils/stripe.d.mts +2 -3
- package/dist/utils/stripe.d.mts.map +1 -1
- package/dist/visitor/index.d.cts +2 -3
- package/dist/visitor/index.d.cts.map +1 -1
- package/dist/visitor/index.d.mts +2 -3
- package/dist/visitor/index.d.mts.map +1 -1
- package/dist/visitor/types.d.cts +4 -5
- package/dist/visitor/types.d.cts.map +1 -1
- package/dist/visitor/types.d.mts +4 -5
- package/dist/visitor/types.d.mts.map +1 -1
- package/dist/web/index.d.cts +3 -4
- package/dist/web/index.d.cts.map +1 -1
- package/dist/web/index.d.mts +3 -4
- package/dist/web/index.d.mts.map +1 -1
- package/dist/web/page-key.d.cts +1 -2
- package/dist/web/page-key.d.cts.map +1 -1
- package/dist/web/page-key.d.mts +1 -2
- package/dist/web/page-key.d.mts.map +1 -1
- package/package.json +27 -27
package/dist/schema/index.d.mts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { iso, z } from "zod/mini";
|
|
2
2
|
//#region src/schema/index.d.ts
|
|
3
|
-
declare const ALL_PLATFORMS: ["ios", "android", "web", "macos", "windows", "linux", "unknown"];
|
|
4
|
-
declare const ALL_ENVIRONMENTS: ["development", "production"];
|
|
5
|
-
declare const tagsSchema: z.ZodMiniObject<{
|
|
3
|
+
export declare const ALL_PLATFORMS: ["ios", "android", "web", "macos", "windows", "linux", "unknown"];
|
|
4
|
+
export declare const ALL_ENVIRONMENTS: ["development", "production"];
|
|
5
|
+
export declare const tagsSchema: z.ZodMiniObject<{
|
|
6
6
|
os: z.ZodMiniOptional<z.ZodMiniString<string>>;
|
|
7
7
|
os_name: z.ZodMiniOptional<z.ZodMiniString<string>>;
|
|
8
8
|
os_version: z.ZodMiniOptional<z.ZodMiniString<string>>;
|
|
@@ -63,8 +63,8 @@ declare const tagsSchema: z.ZodMiniObject<{
|
|
|
63
63
|
utm_creative_format: z.ZodMiniOptional<z.ZodMiniString<string>>;
|
|
64
64
|
utm_marketing_tactic: z.ZodMiniOptional<z.ZodMiniString<string>>;
|
|
65
65
|
}, z.core.$strip>;
|
|
66
|
-
declare const propertiesSchema: z.ZodMiniOptional<z.ZodMiniPipe<z.ZodMiniRecord<z.ZodMiniString<string>, z.ZodMiniUnion<readonly [z.ZodMiniPipe<z.ZodMiniString<string>, z.ZodMiniTransform<string, string>>, z.ZodMiniNumber<number>, z.ZodMiniBoolean<boolean>, z.ZodMiniNull, z.ZodMiniPipe<z.ZodMiniArray<z.ZodMiniPipe<z.ZodMiniRecord<z.ZodMiniString<string>, z.ZodMiniUnion<readonly [z.ZodMiniPipe<z.ZodMiniString<string>, z.ZodMiniTransform<string, string>>, z.ZodMiniNumber<number>, z.ZodMiniBoolean<boolean>, z.ZodMiniNull]>>, z.ZodMiniTransform<Record<string, string | number | boolean | null>, Record<string, string | number | boolean | null>>>>, z.ZodMiniTransform<Record<string, string | number | boolean | null>[], Record<string, string | number | boolean | null>[]>>]>>, z.ZodMiniTransform<Record<string, string | number | boolean | Record<string, string | number | boolean | null>[] | null>, Record<string, string | number | boolean | Record<string, string | number | boolean | null>[] | null>>>>;
|
|
67
|
-
declare const createTrackEventSchema: z.ZodMiniArray<z.ZodMiniObject<{
|
|
66
|
+
export declare const propertiesSchema: z.ZodMiniOptional<z.ZodMiniPipe<z.ZodMiniRecord<z.ZodMiniString<string>, z.ZodMiniUnion<readonly [z.ZodMiniPipe<z.ZodMiniString<string>, z.ZodMiniTransform<string, string>>, z.ZodMiniNumber<number>, z.ZodMiniBoolean<boolean>, z.ZodMiniNull, z.ZodMiniPipe<z.ZodMiniArray<z.ZodMiniPipe<z.ZodMiniRecord<z.ZodMiniString<string>, z.ZodMiniUnion<readonly [z.ZodMiniPipe<z.ZodMiniString<string>, z.ZodMiniTransform<string, string>>, z.ZodMiniNumber<number>, z.ZodMiniBoolean<boolean>, z.ZodMiniNull]>>, z.ZodMiniTransform<Record<string, string | number | boolean | null>, Record<string, string | number | boolean | null>>>>, z.ZodMiniTransform<Record<string, string | number | boolean | null>[], Record<string, string | number | boolean | null>[]>>]>>, z.ZodMiniTransform<Record<string, string | number | boolean | Record<string, string | number | boolean | null>[] | null>, Record<string, string | number | boolean | Record<string, string | number | boolean | null>[] | null>>>>;
|
|
67
|
+
export declare const createTrackEventSchema: z.ZodMiniPipe<z.ZodMiniArray<z.ZodMiniObject<{
|
|
68
68
|
name: z.ZodMiniString<string>;
|
|
69
69
|
visitor_id: z.ZodMiniUUID;
|
|
70
70
|
session_id: z.ZodMiniUUID;
|
|
@@ -144,8 +144,146 @@ declare const createTrackEventSchema: z.ZodMiniArray<z.ZodMiniObject<{
|
|
|
144
144
|
utm_marketing_tactic: z.ZodMiniOptional<z.ZodMiniString<string>>;
|
|
145
145
|
}, z.core.$strip>;
|
|
146
146
|
properties: z.ZodMiniOptional<z.ZodMiniPipe<z.ZodMiniRecord<z.ZodMiniString<string>, z.ZodMiniUnion<readonly [z.ZodMiniPipe<z.ZodMiniString<string>, z.ZodMiniTransform<string, string>>, z.ZodMiniNumber<number>, z.ZodMiniBoolean<boolean>, z.ZodMiniNull, z.ZodMiniPipe<z.ZodMiniArray<z.ZodMiniPipe<z.ZodMiniRecord<z.ZodMiniString<string>, z.ZodMiniUnion<readonly [z.ZodMiniPipe<z.ZodMiniString<string>, z.ZodMiniTransform<string, string>>, z.ZodMiniNumber<number>, z.ZodMiniBoolean<boolean>, z.ZodMiniNull]>>, z.ZodMiniTransform<Record<string, string | number | boolean | null>, Record<string, string | number | boolean | null>>>>, z.ZodMiniTransform<Record<string, string | number | boolean | null>[], Record<string, string | number | boolean | null>[]>>]>>, z.ZodMiniTransform<Record<string, string | number | boolean | Record<string, string | number | boolean | null>[] | null>, Record<string, string | number | boolean | Record<string, string | number | boolean | null>[] | null>>>>;
|
|
147
|
-
}, z.core.$strip
|
|
148
|
-
|
|
147
|
+
}, z.core.$strip>>, z.ZodMiniTransform<{
|
|
148
|
+
name: string;
|
|
149
|
+
visitor_id: string;
|
|
150
|
+
session_id: string;
|
|
151
|
+
platform: "android" | "ios" | "linux" | "macos" | "unknown" | "web" | "windows";
|
|
152
|
+
environment: "development" | "production";
|
|
153
|
+
timestamp: string;
|
|
154
|
+
tags: {
|
|
155
|
+
os?: string | undefined;
|
|
156
|
+
os_name?: string | undefined;
|
|
157
|
+
os_version?: string | undefined;
|
|
158
|
+
browser?: string | undefined;
|
|
159
|
+
browser_name?: string | undefined;
|
|
160
|
+
browser_version?: string | undefined;
|
|
161
|
+
device?: string | undefined;
|
|
162
|
+
device_id?: string | undefined;
|
|
163
|
+
device_type?: string | undefined;
|
|
164
|
+
device_vendor?: string | undefined;
|
|
165
|
+
device_pixel_ratio?: number | undefined;
|
|
166
|
+
screen_width?: number | undefined;
|
|
167
|
+
screen_height?: number | undefined;
|
|
168
|
+
screen_resolution?: `${number}x${number}` | undefined;
|
|
169
|
+
release?: string | undefined;
|
|
170
|
+
language?: string | undefined;
|
|
171
|
+
time_zone?: string | undefined;
|
|
172
|
+
page_location?: string | undefined;
|
|
173
|
+
page_referrer?: string | undefined;
|
|
174
|
+
page_title?: string | undefined;
|
|
175
|
+
page_load_id?: string | undefined;
|
|
176
|
+
source_url?: string | undefined;
|
|
177
|
+
advertising_id?: string | undefined;
|
|
178
|
+
install_referrer?: string | undefined;
|
|
179
|
+
fbc?: string | undefined;
|
|
180
|
+
fbp?: string | undefined;
|
|
181
|
+
fbclid?: string | undefined;
|
|
182
|
+
ad_id?: string | undefined;
|
|
183
|
+
ad_name?: string | undefined;
|
|
184
|
+
adset_id?: string | undefined;
|
|
185
|
+
adset_name?: string | undefined;
|
|
186
|
+
campaign_id?: string | undefined;
|
|
187
|
+
campaign_name?: string | undefined;
|
|
188
|
+
placement?: string | undefined;
|
|
189
|
+
gclid?: string | undefined;
|
|
190
|
+
gclsrc?: string | undefined;
|
|
191
|
+
gad_source?: string | undefined;
|
|
192
|
+
gad_campaignid?: string | undefined;
|
|
193
|
+
rdt_cid?: string | undefined;
|
|
194
|
+
rdt_uuid?: string | undefined;
|
|
195
|
+
dclid?: string | undefined;
|
|
196
|
+
ko_click_id?: string | undefined;
|
|
197
|
+
li_fat_id?: string | undefined;
|
|
198
|
+
msclkid?: string | undefined;
|
|
199
|
+
sccid?: string | undefined;
|
|
200
|
+
ttclid?: string | undefined;
|
|
201
|
+
twclid?: string | undefined;
|
|
202
|
+
wbraid?: string | undefined;
|
|
203
|
+
gbraid?: string | undefined;
|
|
204
|
+
yclid?: string | undefined;
|
|
205
|
+
utm_source?: string | undefined;
|
|
206
|
+
utm_medium?: string | undefined;
|
|
207
|
+
utm_campaign?: string | undefined;
|
|
208
|
+
utm_term?: string | undefined;
|
|
209
|
+
utm_content?: string | undefined;
|
|
210
|
+
utm_id?: string | undefined;
|
|
211
|
+
utm_source_platform?: string | undefined;
|
|
212
|
+
utm_creative_format?: string | undefined;
|
|
213
|
+
utm_marketing_tactic?: string | undefined;
|
|
214
|
+
};
|
|
215
|
+
properties?: Record<string, string | number | boolean | Record<string, string | number | boolean | null>[] | null> | undefined;
|
|
216
|
+
}[], {
|
|
217
|
+
name: string;
|
|
218
|
+
visitor_id: string;
|
|
219
|
+
session_id: string;
|
|
220
|
+
platform: "android" | "ios" | "linux" | "macos" | "unknown" | "web" | "windows";
|
|
221
|
+
environment: "development" | "production";
|
|
222
|
+
timestamp: string;
|
|
223
|
+
tags: {
|
|
224
|
+
os?: string | undefined;
|
|
225
|
+
os_name?: string | undefined;
|
|
226
|
+
os_version?: string | undefined;
|
|
227
|
+
browser?: string | undefined;
|
|
228
|
+
browser_name?: string | undefined;
|
|
229
|
+
browser_version?: string | undefined;
|
|
230
|
+
device?: string | undefined;
|
|
231
|
+
device_id?: string | undefined;
|
|
232
|
+
device_type?: string | undefined;
|
|
233
|
+
device_vendor?: string | undefined;
|
|
234
|
+
device_pixel_ratio?: number | undefined;
|
|
235
|
+
screen_width?: number | undefined;
|
|
236
|
+
screen_height?: number | undefined;
|
|
237
|
+
screen_resolution?: `${number}x${number}` | undefined;
|
|
238
|
+
release?: string | undefined;
|
|
239
|
+
language?: string | undefined;
|
|
240
|
+
time_zone?: string | undefined;
|
|
241
|
+
page_location?: string | undefined;
|
|
242
|
+
page_referrer?: string | undefined;
|
|
243
|
+
page_title?: string | undefined;
|
|
244
|
+
page_load_id?: string | undefined;
|
|
245
|
+
source_url?: string | undefined;
|
|
246
|
+
advertising_id?: string | undefined;
|
|
247
|
+
install_referrer?: string | undefined;
|
|
248
|
+
fbc?: string | undefined;
|
|
249
|
+
fbp?: string | undefined;
|
|
250
|
+
fbclid?: string | undefined;
|
|
251
|
+
ad_id?: string | undefined;
|
|
252
|
+
ad_name?: string | undefined;
|
|
253
|
+
adset_id?: string | undefined;
|
|
254
|
+
adset_name?: string | undefined;
|
|
255
|
+
campaign_id?: string | undefined;
|
|
256
|
+
campaign_name?: string | undefined;
|
|
257
|
+
placement?: string | undefined;
|
|
258
|
+
gclid?: string | undefined;
|
|
259
|
+
gclsrc?: string | undefined;
|
|
260
|
+
gad_source?: string | undefined;
|
|
261
|
+
gad_campaignid?: string | undefined;
|
|
262
|
+
rdt_cid?: string | undefined;
|
|
263
|
+
rdt_uuid?: string | undefined;
|
|
264
|
+
dclid?: string | undefined;
|
|
265
|
+
ko_click_id?: string | undefined;
|
|
266
|
+
li_fat_id?: string | undefined;
|
|
267
|
+
msclkid?: string | undefined;
|
|
268
|
+
sccid?: string | undefined;
|
|
269
|
+
ttclid?: string | undefined;
|
|
270
|
+
twclid?: string | undefined;
|
|
271
|
+
wbraid?: string | undefined;
|
|
272
|
+
gbraid?: string | undefined;
|
|
273
|
+
yclid?: string | undefined;
|
|
274
|
+
utm_source?: string | undefined;
|
|
275
|
+
utm_medium?: string | undefined;
|
|
276
|
+
utm_campaign?: string | undefined;
|
|
277
|
+
utm_term?: string | undefined;
|
|
278
|
+
utm_content?: string | undefined;
|
|
279
|
+
utm_id?: string | undefined;
|
|
280
|
+
utm_source_platform?: string | undefined;
|
|
281
|
+
utm_creative_format?: string | undefined;
|
|
282
|
+
utm_marketing_tactic?: string | undefined;
|
|
283
|
+
};
|
|
284
|
+
properties?: Record<string, string | number | boolean | Record<string, string | number | boolean | null>[] | null> | undefined;
|
|
285
|
+
}[]>>;
|
|
286
|
+
export declare const createVisitorSchema: z.ZodMiniObject<{
|
|
149
287
|
device_id: z.ZodMiniString<string>;
|
|
150
288
|
platform: z.ZodMiniEnum<{
|
|
151
289
|
android: "android";
|
|
@@ -233,7 +371,7 @@ declare const createVisitorSchema: z.ZodMiniObject<{
|
|
|
233
371
|
* @see https://support.google.com/analytics/answer/14078702
|
|
234
372
|
* @see https://support.google.com/google-ads/answer/13258081
|
|
235
373
|
*/
|
|
236
|
-
declare const userProvidedDataSchema: z.ZodMiniObject<{
|
|
374
|
+
export declare const userProvidedDataSchema: z.ZodMiniObject<{
|
|
237
375
|
email: z.ZodMiniOptional<z.ZodMiniUnion<readonly [z.ZodMiniPipe<z.ZodMiniString<string>, z.ZodMiniEmail>, z.ZodMiniArray<z.ZodMiniPipe<z.ZodMiniString<string>, z.ZodMiniEmail>>]>>;
|
|
238
376
|
phone_number: z.ZodMiniOptional<z.ZodMiniUnion<readonly [z.ZodMiniPipe<z.ZodMiniString<string>, z.ZodMiniE164>, z.ZodMiniArray<z.ZodMiniPipe<z.ZodMiniString<string>, z.ZodMiniE164>>]>>;
|
|
239
377
|
address: z.ZodMiniOptional<z.ZodMiniUnion<readonly [z.ZodMiniObject<{
|
|
@@ -254,7 +392,7 @@ declare const userProvidedDataSchema: z.ZodMiniObject<{
|
|
|
254
392
|
country: z.ZodMiniOptional<z.ZodMiniString<string>>;
|
|
255
393
|
}, z.core.$strip>>]>>;
|
|
256
394
|
}, z.core.$strip>;
|
|
257
|
-
declare const updateVisitorSchema: z.ZodMiniObject<{
|
|
395
|
+
export declare const updateVisitorSchema: z.ZodMiniObject<{
|
|
258
396
|
user_id: z.ZodMiniOptional<z.ZodMiniUUID>;
|
|
259
397
|
user_data: z.ZodMiniOptional<z.ZodMiniObject<{
|
|
260
398
|
email: z.ZodMiniOptional<z.ZodMiniUnion<readonly [z.ZodMiniPipe<z.ZodMiniString<string>, z.ZodMiniEmail>, z.ZodMiniArray<z.ZodMiniPipe<z.ZodMiniString<string>, z.ZodMiniEmail>>]>>;
|
|
@@ -340,7 +478,7 @@ declare const updateVisitorSchema: z.ZodMiniObject<{
|
|
|
340
478
|
}, z.core.$strip>;
|
|
341
479
|
properties: z.ZodMiniOptional<z.ZodMiniPipe<z.ZodMiniRecord<z.ZodMiniString<string>, z.ZodMiniUnion<readonly [z.ZodMiniPipe<z.ZodMiniString<string>, z.ZodMiniTransform<string, string>>, z.ZodMiniNumber<number>, z.ZodMiniBoolean<boolean>, z.ZodMiniNull]>>, z.ZodMiniTransform<Record<string, string | number | boolean | null>, Record<string, string | number | boolean | null>>>>;
|
|
342
480
|
}, z.core.$strip>;
|
|
343
|
-
declare const createFeedbackSchema: z.ZodMiniObject<{
|
|
481
|
+
export declare const createFeedbackSchema: z.ZodMiniObject<{
|
|
344
482
|
name: z.ZodMiniString<string>;
|
|
345
483
|
email: z.ZodMiniEmail;
|
|
346
484
|
message: z.ZodMiniString<string>;
|
|
@@ -349,7 +487,7 @@ declare const createFeedbackSchema: z.ZodMiniObject<{
|
|
|
349
487
|
* The schema for creating a link.
|
|
350
488
|
* @see https://support.google.com/analytics/answer/10917952
|
|
351
489
|
* */
|
|
352
|
-
declare const createLinkSchema: z.ZodMiniObject<{
|
|
490
|
+
export declare const createLinkSchema: z.ZodMiniObject<{
|
|
353
491
|
url: z.ZodMiniURL;
|
|
354
492
|
utm_id: z.ZodMiniOptional<z.ZodMiniPipe<z.ZodMiniString<string>, z.ZodMiniTransform<string | undefined, string>>>;
|
|
355
493
|
utm_source: z.ZodMiniString<string>;
|
|
@@ -361,12 +499,11 @@ declare const createLinkSchema: z.ZodMiniObject<{
|
|
|
361
499
|
utm_creative_format: z.ZodMiniOptional<z.ZodMiniPipe<z.ZodMiniString<string>, z.ZodMiniTransform<string | undefined, string>>>;
|
|
362
500
|
utm_marketing_tactic: z.ZodMiniOptional<z.ZodMiniPipe<z.ZodMiniString<string>, z.ZodMiniTransform<string | undefined, string>>>;
|
|
363
501
|
}, z.core.$strip>;
|
|
364
|
-
type CreateTrackEventDTO = z.output<typeof createTrackEventSchema>;
|
|
365
|
-
type CreateFeedbackDTO = z.output<typeof createFeedbackSchema>;
|
|
366
|
-
type CreateLinkDTO = z.output<typeof createLinkSchema>;
|
|
367
|
-
type CreateVisitorDTO = z.output<typeof createVisitorSchema>;
|
|
368
|
-
type UserProvidedDataDTO = z.output<typeof userProvidedDataSchema>;
|
|
369
|
-
type UpdateVisitorDTO = z.output<typeof updateVisitorSchema>;
|
|
502
|
+
export type CreateTrackEventDTO = z.output<typeof createTrackEventSchema>;
|
|
503
|
+
export type CreateFeedbackDTO = z.output<typeof createFeedbackSchema>;
|
|
504
|
+
export type CreateLinkDTO = z.output<typeof createLinkSchema>;
|
|
505
|
+
export type CreateVisitorDTO = z.output<typeof createVisitorSchema>;
|
|
506
|
+
export type UserProvidedDataDTO = z.output<typeof userProvidedDataSchema>;
|
|
507
|
+
export type UpdateVisitorDTO = z.output<typeof updateVisitorSchema>;
|
|
370
508
|
//#endregion
|
|
371
|
-
export { ALL_ENVIRONMENTS, ALL_PLATFORMS, CreateFeedbackDTO, CreateLinkDTO, CreateTrackEventDTO, CreateVisitorDTO, UpdateVisitorDTO, UserProvidedDataDTO, createFeedbackSchema, createLinkSchema, createTrackEventSchema, createVisitorSchema, propertiesSchema, tagsSchema, updateVisitorSchema, userProvidedDataSchema };
|
|
372
509
|
//# sourceMappingURL=index.d.mts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.mts","names":[],"sources":["../../src/schema/index.ts"],"mappings":";;
|
|
1
|
+
{"version":3,"file":"index.d.mts","names":[],"sources":["../../src/schema/index.ts"],"mappings":";;qBAmFa;qBAUA;qBAEA,YAAU,EAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6ErB,EAAA,KAAA;qBAEW,kBAAgB,EAAA,gBAAA,EAAA,YAAA,EAAA,cAAA,EAAA,uBAAA,EAAA,uBAAA,EAAA,YAAA,EAAA,uBAAA,EAAA,mCAAA,EAAA,uBAAA,EAAA,yBAAA,EAAA,aAAA,EAAA,YAAA,EAAA,aAAA,EAAA,YAAA,EAAA,cAAA,EAAA,uBAAA,EAAA,uBAAA,EAAA,YAAA,EAAA,uBAAA,EAAA,mCAAA,EAAA,uBAAA,EAAA,yBAAA,EAAA,gBAAA,EAAA,iBAAA,kDAAA,qDAAA,EAAA,iBAAA,oDAAA,yDAAA,EAAA,iBAAA,2CAAA,4DAAA,2CAAA;qBA4ChB,wBAAsB,EAAA,YAAA,EAAA,aAAA,EAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;qBAgBtB,qBAAmB,EAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAM9B,EAAA,KAAA;;;;;;;;;;;qBA6BW,wBAAsB,EAAA;;;;;;;;;;;;;;;;;;;;GAIjC,EAAA,KAAA;qBAEW,qBAAmB,EAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAK9B,EAAA,KAAA;qBAEW,sBAAoB,EAAA;;;;GAI/B,EAAA,KAAA;;;;;qBAWW,kBAAgB,EAAA;;;;;;;;;;;GA+C3B,EAAA,KAAA;YAEU,sBAAsB,EAAE,cAAc;YACtC,oBAAoB,EAAE,cAAc;YACpC,gBAAgB,EAAE,cAAc;YAChC,mBAAmB,EAAE,cAAc;YACnC,sBAAsB,EAAE,cAAc;YACtC,mBAAmB,EAAE,cAAc"}
|
package/dist/schema/index.mjs
CHANGED
|
@@ -135,7 +135,37 @@ const visitorPropertiesSchema = optional(pipe(record(string(), union([
|
|
|
135
135
|
boolean(),
|
|
136
136
|
null$1()
|
|
137
137
|
])), transform(takeProperties)));
|
|
138
|
-
|
|
138
|
+
/**
|
|
139
|
+
* How far an event's time may be from the server's before the client clock it was stamped with is
|
|
140
|
+
* taken as wrong. A batch legitimately arrives late — a tab frozen in the background, a
|
|
141
|
+
* session_start held back after a failed batch — by hours, not days; a phone set to another year
|
|
142
|
+
* writes its sessions into that year.
|
|
143
|
+
*/
|
|
144
|
+
const MAX_CLOCK_SKEW = 864e5;
|
|
145
|
+
/**
|
|
146
|
+
* Puts the events stamped by a wrong client clock onto the server's, where they are parsed. Only
|
|
147
|
+
* the events outside `MAX_CLOCK_SKEW` move, so one bad event cannot drag the rest of its batch
|
|
148
|
+
* along: they move together by their own latest one — the wrong clock at sending — keeping their
|
|
149
|
+
* order and spacing, and one still out after that (a batch mixing two wrong clocks) is on no clock
|
|
150
|
+
* at all and takes the server's time. Corrected rather than rejected, for the same reason values
|
|
151
|
+
* are truncated: a wrong clock should cost the event its time, not the batch its events.
|
|
152
|
+
*/
|
|
153
|
+
function alignClock(events, now = Date.now()) {
|
|
154
|
+
const within = (time) => Math.abs(now - time) <= MAX_CLOCK_SKEW;
|
|
155
|
+
const times = events.map((event) => Date.parse(event.timestamp));
|
|
156
|
+
const wrong = times.filter((time) => !within(time));
|
|
157
|
+
if (wrong.length === 0) return events;
|
|
158
|
+
const offset = now - Math.max(...wrong);
|
|
159
|
+
return events.map((event, i) => {
|
|
160
|
+
if (within(times[i])) return event;
|
|
161
|
+
const shifted = times[i] + offset;
|
|
162
|
+
return {
|
|
163
|
+
...event,
|
|
164
|
+
timestamp: new Date(within(shifted) ? shifted : now).toISOString()
|
|
165
|
+
};
|
|
166
|
+
});
|
|
167
|
+
}
|
|
168
|
+
const createTrackEventSchema = pipe(array(object({
|
|
139
169
|
name: string().check(trim(), minLength(1), maxLength(64)),
|
|
140
170
|
visitor_id: uuid(),
|
|
141
171
|
session_id: uuid(),
|
|
@@ -144,7 +174,7 @@ const createTrackEventSchema = array(object({
|
|
|
144
174
|
timestamp: iso.datetime(),
|
|
145
175
|
tags: tagsSchema,
|
|
146
176
|
properties: propertiesSchema
|
|
147
|
-
})).check(minLength(1), maxLength(100));
|
|
177
|
+
})).check(minLength(1), maxLength(100)), transform((events) => alignClock(events)));
|
|
148
178
|
const createVisitorSchema = object({
|
|
149
179
|
device_id: string().check(trim(), minLength(1), maxLength(36)),
|
|
150
180
|
platform: enum$1(ALL_PLATFORMS),
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.mjs","names":["_null","_enum"],"sources":["../../src/schema/index.ts"],"sourcesContent":["import {\n enum as _enum,\n null as _null,\n array,\n boolean,\n e164,\n email,\n iso,\n maxLength,\n minLength,\n number,\n object,\n optional,\n pipe,\n record,\n regex,\n string,\n toLowerCase,\n toUpperCase,\n transform,\n trim,\n union,\n url,\n uuid,\n type z,\n} from 'zod/mini';\nimport type { Environment, Platform } from '../track/types';\n\nconst MAX_KEY_LENGTH = 128;\nconst MAX_VALUE_LENGTH = 512;\nconst MAX_PROPERTIES = 64;\n\n/**\n * Truncated rather than rejected. These schemas validate a whole batch at once, so refusing one\n * oversized value costs every event that traveled with it — and the values that overrun are the\n * ones derived from the page (a link's text, a URL carrying a long query), which no client can\n * bound in advance. A shortened value is worth more than a lost batch.\n */\nconst propertyText = pipe(\n string(),\n transform((value) => value.slice(0, MAX_VALUE_LENGTH))\n);\n\n/**\n * Keys are written by hand in instrumentation code, so an unusable one is a mistake in the host\n * rather than something the visitor typed. It is still dropped rather than rejected, for the same\n * reason: the mistake should cost that property, not the batch it happens to be in. Truncating a\n * key is not an option — two long keys would silently become one field.\n *\n * The key schema below is deliberately permissive so that this transform is reached at all; the\n * trimming it used to do happens here instead. `MAX_PROPERTIES` keeps the first N in insertion\n * order.\n */\nfunction takeProperties<T>(data: Record<string, T>): Record<string, T> {\n const result: Record<string, T> = {};\n let count = 0;\n for (const [rawKey, value] of Object.entries(data)) {\n if (count >= MAX_PROPERTIES) break;\n const key = rawKey.trim();\n if (!key || key.length > MAX_KEY_LENGTH) continue;\n result[key] = value;\n count++;\n }\n return result;\n}\n\n/**\n * Capped at GA4's own item-list limit, and truncated rather than rejected like every other\n * property limit here: an unbounded array is the one field a caller could still blow a batch\n * up with after the value and key limits.\n */\nconst MAX_ITEMS = 200;\n\nconst items = pipe(\n array(\n pipe(\n record(string(), union([propertyText, number(), boolean(), _null()])),\n transform(takeProperties)\n )\n ),\n transform((list) => list.slice(0, MAX_ITEMS))\n);\n\nexport const ALL_PLATFORMS = [\n 'ios',\n 'android',\n 'web',\n 'macos',\n 'windows',\n 'linux',\n 'unknown',\n] as const satisfies Platform[];\n\nexport const ALL_ENVIRONMENTS = ['development', 'production'] as const satisfies Environment[];\n\nexport const tagsSchema = object({\n os: optional(string()),\n os_name: optional(string()),\n os_version: optional(string()),\n browser: optional(string()),\n browser_name: optional(string()),\n browser_version: optional(string()),\n device: optional(string()),\n device_id: optional(string().check(trim(), minLength(1), maxLength(36))),\n device_type: optional(string()),\n device_vendor: optional(string()),\n device_pixel_ratio: optional(number()),\n screen_width: optional(number()),\n screen_height: optional(number()),\n screen_resolution: optional(\n pipe(\n string().check(regex(/^\\d+x\\d+$/)),\n transform((v) => v as `${number}x${number}`)\n )\n ),\n release: optional(string()),\n language: optional(string()),\n time_zone: optional(string()),\n page_location: optional(string()),\n page_referrer: optional(string()),\n page_title: optional(string()),\n page_load_id: optional(string()),\n /**\n * @deprecated Renamed to `page_location` in 7.0.0. Accepted so that events from clients\n * still on an older SDK are not stripped of their page URL at this boundary — a browser\n * bundle stays cached long after a backend deploys. Remove once those clients are gone;\n * `pageLocation` in `server/page-location.ts` is the only reader.\n */\n source_url: optional(string()),\n // app info\n advertising_id: optional(string()),\n install_referrer: optional(string()),\n // Meta Ads\n fbc: optional(string()),\n fbp: optional(string()),\n fbclid: optional(string()),\n ad_id: optional(string()),\n ad_name: optional(string()),\n adset_id: optional(string()),\n adset_name: optional(string()),\n campaign_id: optional(string()),\n campaign_name: optional(string()),\n placement: optional(string()),\n // Google Ads\n gclid: optional(string()),\n gclsrc: optional(string()),\n gad_source: optional(string()),\n gad_campaignid: optional(string()),\n // Reddit ads\n rdt_cid: optional(string()),\n rdt_uuid: optional(string()),\n // click ids\n dclid: optional(string()),\n ko_click_id: optional(string()),\n li_fat_id: optional(string()),\n msclkid: optional(string()),\n sccid: optional(string()),\n ttclid: optional(string()),\n twclid: optional(string()),\n wbraid: optional(string()),\n gbraid: optional(string()),\n yclid: optional(string()),\n // utm params\n utm_source: optional(string()),\n utm_medium: optional(string()),\n utm_campaign: optional(string()),\n utm_term: optional(string()),\n utm_content: optional(string()),\n utm_id: optional(string()),\n utm_source_platform: optional(string()),\n utm_creative_format: optional(string()),\n utm_marketing_tactic: optional(string()),\n});\n\nexport const propertiesSchema = optional(\n pipe(\n record(string(), union([propertyText, number(), boolean(), _null(), items])),\n transform(takeProperties)\n )\n);\n\n/** Visitor properties differ from event properties only in taking no nested item lists. */\nconst visitorPropertiesSchema = optional(\n pipe(\n record(string(), union([propertyText, number(), boolean(), _null()])),\n transform(takeProperties)\n )\n);\n\nexport const createTrackEventSchema = array(\n object({\n name: string().check(trim(), minLength(1), maxLength(64)),\n visitor_id: uuid(),\n session_id: uuid(),\n platform: _enum(ALL_PLATFORMS),\n environment: _enum(ALL_ENVIRONMENTS),\n timestamp: iso.datetime(),\n tags: tagsSchema,\n properties: propertiesSchema,\n })\n).check(minLength(1), maxLength(100));\n\nexport const createVisitorSchema = object({\n device_id: string().check(trim(), minLength(1), maxLength(36)),\n platform: _enum(ALL_PLATFORMS),\n environment: _enum(ALL_ENVIRONMENTS),\n tags: tagsSchema,\n properties: visitorPropertiesSchema,\n});\n\nconst emailValue = pipe(string().check(trim(), toLowerCase(), maxLength(320)), email());\n\n/** E.164: a plus sign (+) prefix, country code, then digits only, no dashes/parens/spaces. */\nconst phoneValue = pipe(string().check(trim()), e164());\n\nconst addressValue = object({\n first_name: optional(string().check(trim(), maxLength(128))),\n last_name: optional(string().check(trim(), maxLength(128))),\n street: optional(string().check(trim(), maxLength(256))),\n city: optional(string().check(trim(), maxLength(128))),\n /** User province, state, or region. Example: `Hampshire` */\n region: optional(string().check(trim(), maxLength(128))),\n postal_code: optional(string().check(trim(), maxLength(32))),\n /** 2-letter country code, per the ISO 3166-1 alpha-2 standard. Example: `UK` */\n country: optional(string().check(trim(), toUpperCase(), regex(/^[A-Z]{2}$/))),\n});\n\n/**\n * User-provided data (UPD) used for enhanced conversions, Customer Match, and demographics.\n * Values are sent unhashed; Google normalizes and hashes them before they reach its servers.\n *\n * Multiple values may be sent to increase the match rate: up to 3 emails, 3 phone numbers, and\n * 2 addresses.\n *\n * @see https://support.google.com/analytics/answer/14078702\n * @see https://support.google.com/google-ads/answer/13258081\n */\nexport const userProvidedDataSchema = object({\n email: optional(union([emailValue, array(emailValue).check(minLength(1), maxLength(3))])),\n phone_number: optional(union([phoneValue, array(phoneValue).check(minLength(1), maxLength(3))])),\n address: optional(union([addressValue, array(addressValue).check(minLength(1), maxLength(2))])),\n});\n\nexport const updateVisitorSchema = object({\n user_id: optional(uuid()),\n user_data: optional(userProvidedDataSchema),\n tags: tagsSchema,\n properties: visitorPropertiesSchema,\n});\n\nexport const createFeedbackSchema = object({\n name: string().check(minLength(1), maxLength(256)),\n email: email().check(maxLength(320)),\n message: string().check(minLength(1), maxLength(65536)),\n});\n\nconst noEmptyString = pipe(\n string().check(maxLength(256)),\n transform((v) => (v ? v : undefined))\n);\n\n/**\n * The schema for creating a link.\n * @see https://support.google.com/analytics/answer/10917952\n * */\nexport const createLinkSchema = object({\n /** The URL that the user is redirected to. */\n url: url().check(minLength(1), maxLength(1024)), // required\n\n /**\n * Campaign ID. Used to identify a specific campaign or promotion. This is a required key for GA4\n * data import. Use the same IDs that you use when uploading campaign cost data.\n */\n utm_id: optional(noEmptyString),\n\n /** Referrer, for example: google, newsletter4, billboard */\n utm_source: string().check(minLength(1), maxLength(256)), // required\n\n /** Marketing medium, for example: cpc, banner, email */\n utm_medium: string().check(minLength(1), maxLength(256)), // required\n\n /** Product, slogan, promo code, for example, spring_sale */\n utm_campaign: string().check(minLength(1), maxLength(256)), // required\n\n /** Paid keyword */\n utm_term: optional(noEmptyString),\n\n /**\n * Use to differentiate creatives. For example, if you have two call-to-action links within the\n * same email message, you can use utm_content and set different values for each so you can tell\n * which version is more effective.\n */\n utm_content: optional(noEmptyString),\n\n /**\n * The platform responsible for directing traffic to a given Analytics property (such as a buying\n * platform that sets budgets and targeting criteria or a platform that manages organic traffic\n * data). For example, Search Ads 360 or Display & Video 360.\n */\n utm_source_platform: optional(noEmptyString),\n\n /**\n * Type of creative, for example, display, native, video, search, utm_creative_format is not\n * currently reported in Google Analytics 4 properties.\n */\n utm_creative_format: optional(noEmptyString),\n\n /**\n * Targeting criteria applied to a campaign, for example, remarketing, prospecting,\n * utm_marketing_tactic is not currently reported in Google Analytics 4 properties.\n * */\n utm_marketing_tactic: optional(noEmptyString),\n});\n\nexport type CreateTrackEventDTO = z.output<typeof createTrackEventSchema>;\nexport type CreateFeedbackDTO = z.output<typeof createFeedbackSchema>;\nexport type CreateLinkDTO = z.output<typeof createLinkSchema>;\nexport type CreateVisitorDTO = z.output<typeof createVisitorSchema>;\nexport type UserProvidedDataDTO = z.output<typeof userProvidedDataSchema>;\nexport type UpdateVisitorDTO = z.output<typeof updateVisitorSchema>;\n"],"mappings":";;AA4BA,MAAM,iBAAiB;AACvB,MAAM,mBAAmB;AACzB,MAAM,iBAAiB;;;;;;;AAQvB,MAAM,eAAe,KACnB,OAAO,GACP,WAAW,UAAU,MAAM,MAAM,GAAG,gBAAgB,CAAC,CACvD;;;;;;;;;;;AAYA,SAAS,eAAkB,MAA4C;CACrE,MAAM,SAA4B,CAAC;CACnC,IAAI,QAAQ;CACZ,KAAK,MAAM,CAAC,QAAQ,UAAU,OAAO,QAAQ,IAAI,GAAG;EAClD,IAAI,SAAS,gBAAgB;EAC7B,MAAM,MAAM,OAAO,KAAK;EACxB,IAAI,CAAC,OAAO,IAAI,SAAS,gBAAgB;EACzC,OAAO,OAAO;EACd;CACF;CACA,OAAO;AACT;;;;;;AAOA,MAAM,YAAY;AAElB,MAAM,QAAQ,KACZ,MACE,KACE,OAAO,OAAO,GAAG,MAAM;CAAC;CAAc,OAAO;CAAG,QAAQ;CAAGA,OAAM;AAAC,CAAC,CAAC,GACpE,UAAU,cAAc,CAC1B,CACF,GACA,WAAW,SAAS,KAAK,MAAM,GAAG,SAAS,CAAC,CAC9C;AAEA,MAAa,gBAAgB;CAC3B;CACA;CACA;CACA;C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G,UAAU,GAAG,CAAC;;CAGzD,UAAU,SAAS,aAAa;;;;;;CAOhC,aAAa,SAAS,aAAa;;;;;;CAOnC,qBAAqB,SAAS,aAAa;;;;;CAM3C,qBAAqB,SAAS,aAAa;;;;;CAM3C,sBAAsB,SAAS,aAAa;AAC9C,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.mjs","names":["_null","_enum"],"sources":["../../src/schema/index.ts"],"sourcesContent":["import {\n enum as _enum,\n null as _null,\n array,\n boolean,\n e164,\n email,\n iso,\n maxLength,\n minLength,\n number,\n object,\n optional,\n pipe,\n record,\n regex,\n string,\n toLowerCase,\n toUpperCase,\n transform,\n trim,\n union,\n url,\n uuid,\n type z,\n} from 'zod/mini';\nimport type { Environment, Platform } from '../track/types';\n\nconst MAX_KEY_LENGTH = 128;\nconst MAX_VALUE_LENGTH = 512;\nconst MAX_PROPERTIES = 64;\n\n/**\n * Truncated rather than rejected. These schemas validate a whole batch at once, so refusing one\n * oversized value costs every event that traveled with it — and the values that overrun are the\n * ones derived from the page (a link's text, a URL carrying a long query), which no client can\n * bound in advance. A shortened value is worth more than a lost batch.\n */\nconst propertyText = pipe(\n string(),\n transform((value) => value.slice(0, MAX_VALUE_LENGTH))\n);\n\n/**\n * Keys are written by hand in instrumentation code, so an unusable one is a mistake in the host\n * rather than something the visitor typed. It is still dropped rather than rejected, for the same\n * reason: the mistake should cost that property, not the batch it happens to be in. Truncating a\n * key is not an option — two long keys would silently become one field.\n *\n * The key schema below is deliberately permissive so that this transform is reached at all; the\n * trimming it used to do happens here instead. `MAX_PROPERTIES` keeps the first N in insertion\n * order.\n */\nfunction takeProperties<T>(data: Record<string, T>): Record<string, T> {\n const result: Record<string, T> = {};\n let count = 0;\n for (const [rawKey, value] of Object.entries(data)) {\n if (count >= MAX_PROPERTIES) break;\n const key = rawKey.trim();\n if (!key || key.length > MAX_KEY_LENGTH) continue;\n result[key] = value;\n count++;\n }\n return result;\n}\n\n/**\n * Capped at GA4's own item-list limit, and truncated rather than rejected like every other\n * property limit here: an unbounded array is the one field a caller could still blow a batch\n * up with after the value and key limits.\n */\nconst MAX_ITEMS = 200;\n\nconst items = pipe(\n array(\n pipe(\n record(string(), union([propertyText, number(), boolean(), _null()])),\n transform(takeProperties)\n )\n ),\n transform((list) => list.slice(0, MAX_ITEMS))\n);\n\nexport const ALL_PLATFORMS = [\n 'ios',\n 'android',\n 'web',\n 'macos',\n 'windows',\n 'linux',\n 'unknown',\n] as const satisfies Platform[];\n\nexport const ALL_ENVIRONMENTS = ['development', 'production'] as const satisfies Environment[];\n\nexport const tagsSchema = object({\n os: optional(string()),\n os_name: optional(string()),\n os_version: optional(string()),\n browser: optional(string()),\n browser_name: optional(string()),\n browser_version: optional(string()),\n device: optional(string()),\n device_id: optional(string().check(trim(), minLength(1), maxLength(36))),\n device_type: optional(string()),\n device_vendor: optional(string()),\n device_pixel_ratio: optional(number()),\n screen_width: optional(number()),\n screen_height: optional(number()),\n screen_resolution: optional(\n pipe(\n string().check(regex(/^\\d+x\\d+$/)),\n transform((v) => v as `${number}x${number}`)\n )\n ),\n release: optional(string()),\n language: optional(string()),\n time_zone: optional(string()),\n page_location: optional(string()),\n page_referrer: optional(string()),\n page_title: optional(string()),\n page_load_id: optional(string()),\n /**\n * @deprecated Renamed to `page_location` in 7.0.0. Accepted so that events from clients\n * still on an older SDK are not stripped of their page URL at this boundary — a browser\n * bundle stays cached long after a backend deploys. Remove once those clients are gone;\n * `pageLocation` in `server/page-location.ts` is the only reader.\n */\n source_url: optional(string()),\n // app info\n advertising_id: optional(string()),\n install_referrer: optional(string()),\n // Meta Ads\n fbc: optional(string()),\n fbp: optional(string()),\n fbclid: optional(string()),\n ad_id: optional(string()),\n ad_name: optional(string()),\n adset_id: optional(string()),\n adset_name: optional(string()),\n campaign_id: optional(string()),\n campaign_name: optional(string()),\n placement: optional(string()),\n // Google Ads\n gclid: optional(string()),\n gclsrc: optional(string()),\n gad_source: optional(string()),\n gad_campaignid: optional(string()),\n // Reddit ads\n rdt_cid: optional(string()),\n rdt_uuid: optional(string()),\n // click ids\n dclid: optional(string()),\n ko_click_id: optional(string()),\n li_fat_id: optional(string()),\n msclkid: optional(string()),\n sccid: optional(string()),\n ttclid: optional(string()),\n twclid: optional(string()),\n wbraid: optional(string()),\n gbraid: optional(string()),\n yclid: optional(string()),\n // utm params\n utm_source: optional(string()),\n utm_medium: optional(string()),\n utm_campaign: optional(string()),\n utm_term: optional(string()),\n utm_content: optional(string()),\n utm_id: optional(string()),\n utm_source_platform: optional(string()),\n utm_creative_format: optional(string()),\n utm_marketing_tactic: optional(string()),\n});\n\nexport const propertiesSchema = optional(\n pipe(\n record(string(), union([propertyText, number(), boolean(), _null(), items])),\n transform(takeProperties)\n )\n);\n\n/** Visitor properties differ from event properties only in taking no nested item lists. */\nconst visitorPropertiesSchema = optional(\n pipe(\n record(string(), union([propertyText, number(), boolean(), _null()])),\n transform(takeProperties)\n )\n);\n\n/**\n * How far an event's time may be from the server's before the client clock it was stamped with is\n * taken as wrong. A batch legitimately arrives late — a tab frozen in the background, a\n * session_start held back after a failed batch — by hours, not days; a phone set to another year\n * writes its sessions into that year.\n */\nconst MAX_CLOCK_SKEW = 24 * 60 * 60 * 1000;\n\n/**\n * Puts the events stamped by a wrong client clock onto the server's, where they are parsed. Only\n * the events outside `MAX_CLOCK_SKEW` move, so one bad event cannot drag the rest of its batch\n * along: they move together by their own latest one — the wrong clock at sending — keeping their\n * order and spacing, and one still out after that (a batch mixing two wrong clocks) is on no clock\n * at all and takes the server's time. Corrected rather than rejected, for the same reason values\n * are truncated: a wrong clock should cost the event its time, not the batch its events.\n */\nfunction alignClock<T extends { timestamp: string }>(events: T[], now = Date.now()): T[] {\n const within = (time: number) => Math.abs(now - time) <= MAX_CLOCK_SKEW;\n const times = events.map((event) => Date.parse(event.timestamp));\n const wrong = times.filter((time) => !within(time));\n if (wrong.length === 0) return events;\n const offset = now - Math.max(...wrong);\n return events.map((event, i) => {\n if (within(times[i])) return event;\n const shifted = times[i] + offset;\n return { ...event, timestamp: new Date(within(shifted) ? shifted : now).toISOString() };\n });\n}\n\nexport const createTrackEventSchema = pipe(\n array(\n object({\n name: string().check(trim(), minLength(1), maxLength(64)),\n visitor_id: uuid(),\n session_id: uuid(),\n platform: _enum(ALL_PLATFORMS),\n environment: _enum(ALL_ENVIRONMENTS),\n timestamp: iso.datetime(),\n tags: tagsSchema,\n properties: propertiesSchema,\n })\n ).check(minLength(1), maxLength(100)),\n transform((events) => alignClock(events))\n);\n\nexport const createVisitorSchema = object({\n device_id: string().check(trim(), minLength(1), maxLength(36)),\n platform: _enum(ALL_PLATFORMS),\n environment: _enum(ALL_ENVIRONMENTS),\n tags: tagsSchema,\n properties: visitorPropertiesSchema,\n});\n\nconst emailValue = pipe(string().check(trim(), toLowerCase(), maxLength(320)), email());\n\n/** E.164: a plus sign (+) prefix, country code, then digits only, no dashes/parens/spaces. */\nconst phoneValue = pipe(string().check(trim()), e164());\n\nconst addressValue = object({\n first_name: optional(string().check(trim(), maxLength(128))),\n last_name: optional(string().check(trim(), maxLength(128))),\n street: optional(string().check(trim(), maxLength(256))),\n city: optional(string().check(trim(), maxLength(128))),\n /** User province, state, or region. Example: `Hampshire` */\n region: optional(string().check(trim(), maxLength(128))),\n postal_code: optional(string().check(trim(), maxLength(32))),\n /** 2-letter country code, per the ISO 3166-1 alpha-2 standard. Example: `UK` */\n country: optional(string().check(trim(), toUpperCase(), regex(/^[A-Z]{2}$/))),\n});\n\n/**\n * User-provided data (UPD) used for enhanced conversions, Customer Match, and demographics.\n * Values are sent unhashed; Google normalizes and hashes them before they reach its servers.\n *\n * Multiple values may be sent to increase the match rate: up to 3 emails, 3 phone numbers, and\n * 2 addresses.\n *\n * @see https://support.google.com/analytics/answer/14078702\n * @see https://support.google.com/google-ads/answer/13258081\n */\nexport const userProvidedDataSchema = object({\n email: optional(union([emailValue, array(emailValue).check(minLength(1), maxLength(3))])),\n phone_number: optional(union([phoneValue, array(phoneValue).check(minLength(1), maxLength(3))])),\n address: optional(union([addressValue, array(addressValue).check(minLength(1), maxLength(2))])),\n});\n\nexport const updateVisitorSchema = object({\n user_id: optional(uuid()),\n user_data: optional(userProvidedDataSchema),\n tags: tagsSchema,\n properties: visitorPropertiesSchema,\n});\n\nexport const createFeedbackSchema = object({\n name: string().check(minLength(1), maxLength(256)),\n email: email().check(maxLength(320)),\n message: string().check(minLength(1), maxLength(65536)),\n});\n\nconst noEmptyString = pipe(\n string().check(maxLength(256)),\n transform((v) => (v ? v : undefined))\n);\n\n/**\n * The schema for creating a link.\n * @see https://support.google.com/analytics/answer/10917952\n * */\nexport const createLinkSchema = object({\n /** The URL that the user is redirected to. */\n url: url().check(minLength(1), maxLength(1024)), // required\n\n /**\n * Campaign ID. Used to identify a specific campaign or promotion. This is a required key for GA4\n * data import. Use the same IDs that you use when uploading campaign cost data.\n */\n utm_id: optional(noEmptyString),\n\n /** Referrer, for example: google, newsletter4, billboard */\n utm_source: string().check(minLength(1), maxLength(256)), // required\n\n /** Marketing medium, for example: cpc, banner, email */\n utm_medium: string().check(minLength(1), maxLength(256)), // required\n\n /** Product, slogan, promo code, for example, spring_sale */\n utm_campaign: string().check(minLength(1), maxLength(256)), // required\n\n /** Paid keyword */\n utm_term: optional(noEmptyString),\n\n /**\n * Use to differentiate creatives. For example, if you have two call-to-action links within the\n * same email message, you can use utm_content and set different values for each so you can tell\n * which version is more effective.\n */\n utm_content: optional(noEmptyString),\n\n /**\n * The platform responsible for directing traffic to a given Analytics property (such as a buying\n * platform that sets budgets and targeting criteria or a platform that manages organic traffic\n * data). For example, Search Ads 360 or Display & Video 360.\n */\n utm_source_platform: optional(noEmptyString),\n\n /**\n * Type of creative, for example, display, native, video, search, utm_creative_format is not\n * currently reported in Google Analytics 4 properties.\n */\n utm_creative_format: optional(noEmptyString),\n\n /**\n * Targeting criteria applied to a campaign, for example, remarketing, prospecting,\n * utm_marketing_tactic is not currently reported in Google Analytics 4 properties.\n * */\n utm_marketing_tactic: optional(noEmptyString),\n});\n\nexport type CreateTrackEventDTO = z.output<typeof createTrackEventSchema>;\nexport type CreateFeedbackDTO = z.output<typeof createFeedbackSchema>;\nexport type CreateLinkDTO = z.output<typeof createLinkSchema>;\nexport type CreateVisitorDTO = z.output<typeof createVisitorSchema>;\nexport type UserProvidedDataDTO = z.output<typeof userProvidedDataSchema>;\nexport type UpdateVisitorDTO = z.output<typeof updateVisitorSchema>;\n"],"mappings":";;AA4BA,MAAM,iBAAiB;AACvB,MAAM,mBAAmB;AACzB,MAAM,iBAAiB;;;;;;;AAQvB,MAAM,eAAe,KACnB,OAAO,GACP,WAAW,UAAU,MAAM,MAAM,GAAG,gBAAgB,CAAC,CACvD;;;;;;;;;;;AAYA,SAAS,eAAkB,MAA4C;CACrE,MAAM,SAA4B,CAAC;CACnC,IAAI,QAAQ;CACZ,KAAK,MAAM,CAAC,QAAQ,UAAU,OAAO,QAAQ,IAAI,GAAG;EAClD,IAAI,SAAS,gBAAgB;EAC7B,MAAM,MAAM,OAAO,KAAK;EACxB,IAAI,CAAC,OAAO,IAAI,SAAS,gBAAgB;EACzC,OAAO,OAAO;EACd;CACF;CACA,OAAO;AACT;;;;;;AAOA,MAAM,YAAY;AAElB,MAAM,QAAQ,KACZ,MACE,KACE,OAAO,OAAO,GAAG,MAAM;CAAC;CAAc,OAAO;CAAG,QAAQ;CAAGA,OAAM;AAAC,CAAC,CAAC,GACpE,UAAU,cAAc,CAC1B,CACF,GACA,WAAW,SAAS,KAAK,MAAM,GAAG,SAAS,CAAC,CAC9C;AAEA,MAAa,gBAAgB;CAC3B;CACA;CACA;CACA;CACA;CACA;CACA;AACF;AAEA,MAAa,mBAAmB,CAAC,eAAe,YAAY;AAE5D,MAAa,aAAa,OAAO;CAC/B,IAAI,SAAS,OAAO,CAAC;CACrB,SAAS,SAAS,OAAO,CAAC;CAC1B,YAAY,SAAS,OAAO,CAAC;CAC7B,SAAS,SAAS,OAAO,CAAC;CAC1B,cAAc,SAAS,OAAO,CAAC;CAC/B,iBAAi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GAC7B,WAAW,MAAO,IAAI,IAAI,KAAA,CAAU,CACtC;;;;;AAMA,MAAa,mBAAmB,OAAO;;CAErC,KAAK,IAAI,CAAC,CAAC,MAAM,UAAU,CAAC,GAAG,UAAU,IAAI,CAAC;;;;;CAM9C,QAAQ,SAAS,aAAa;;CAG9B,YAAY,OAAO,CAAC,CAAC,MAAM,UAAU,CAAC,GAAG,UAAU,GAAG,CAAC;;CAGvD,YAAY,OAAO,CAAC,CAAC,MAAM,UAAU,CAAC,GAAG,UAAU,GAAG,CAAC;;CAGvD,cAAc,OAAO,CAAC,CAAC,MAAM,UAAU,CAAC,GAAG,UAAU,GAAG,CAAC;;CAGzD,UAAU,SAAS,aAAa;;;;;;CAOhC,aAAa,SAAS,aAAa;;;;;;CAOnC,qBAAqB,SAAS,aAAa;;;;;CAM3C,qBAAqB,SAAS,aAAa;;;;;CAM3C,sBAAsB,SAAS,aAAa;AAC9C,CAAC"}
|
|
@@ -5,16 +5,15 @@ import { Platform } from "../track/types.cjs";
|
|
|
5
5
|
* own name and its own spelling: Meta `action_source`, Reddit `action_source`, OpenAI
|
|
6
6
|
* `action_source`. Each sender maps this to its vendor vocabulary.
|
|
7
7
|
*/
|
|
8
|
-
type ActionSource = 'web' | 'app';
|
|
8
|
+
export type ActionSource = 'web' | 'app';
|
|
9
9
|
/**
|
|
10
10
|
* What a caller may state explicitly. `offline` is deliberately absent from the derived set:
|
|
11
11
|
* it describes how a conversion was collected — in store, imported from a CRM, taken over the
|
|
12
12
|
* phone — not what device it came from, so no platform implies it. Such events are built by a
|
|
13
13
|
* backend rather than reported by a client SDK, which is why the sender takes it as an argument.
|
|
14
14
|
*/
|
|
15
|
-
type EventActionSource = ActionSource | 'offline';
|
|
15
|
+
export type EventActionSource = ActionSource | 'offline';
|
|
16
16
|
/** An explicit action source always wins; otherwise it is derived from the event's platform. */
|
|
17
|
-
declare function resolveActionSource(platform: Platform, actionSource?: EventActionSource): EventActionSource | undefined;
|
|
17
|
+
export declare function resolveActionSource(platform: Platform, actionSource?: EventActionSource): EventActionSource | undefined;
|
|
18
18
|
//#endregion
|
|
19
|
-
export { ActionSource, EventActionSource, resolveActionSource };
|
|
20
19
|
//# sourceMappingURL=action-source.d.cts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"action-source.d.cts","names":[],"sources":["../../src/server/action-source.ts"],"mappings":";;;;;;;
|
|
1
|
+
{"version":3,"file":"action-source.d.cts","names":[],"sources":["../../src/server/action-source.ts"],"mappings":";;;;;;;YAOY;;;;;;;YAQA,oBAAoB;;wBAyBhB,oBACd,UAAU,UACV,eAAe,oBACd"}
|
|
@@ -5,16 +5,15 @@ import { Platform } from "../track/types.mjs";
|
|
|
5
5
|
* own name and its own spelling: Meta `action_source`, Reddit `action_source`, OpenAI
|
|
6
6
|
* `action_source`. Each sender maps this to its vendor vocabulary.
|
|
7
7
|
*/
|
|
8
|
-
type ActionSource = 'web' | 'app';
|
|
8
|
+
export type ActionSource = 'web' | 'app';
|
|
9
9
|
/**
|
|
10
10
|
* What a caller may state explicitly. `offline` is deliberately absent from the derived set:
|
|
11
11
|
* it describes how a conversion was collected — in store, imported from a CRM, taken over the
|
|
12
12
|
* phone — not what device it came from, so no platform implies it. Such events are built by a
|
|
13
13
|
* backend rather than reported by a client SDK, which is why the sender takes it as an argument.
|
|
14
14
|
*/
|
|
15
|
-
type EventActionSource = ActionSource | 'offline';
|
|
15
|
+
export type EventActionSource = ActionSource | 'offline';
|
|
16
16
|
/** An explicit action source always wins; otherwise it is derived from the event's platform. */
|
|
17
|
-
declare function resolveActionSource(platform: Platform, actionSource?: EventActionSource): EventActionSource | undefined;
|
|
17
|
+
export declare function resolveActionSource(platform: Platform, actionSource?: EventActionSource): EventActionSource | undefined;
|
|
18
18
|
//#endregion
|
|
19
|
-
export { ActionSource, EventActionSource, resolveActionSource };
|
|
20
19
|
//# sourceMappingURL=action-source.d.mts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"action-source.d.mts","names":[],"sources":["../../src/server/action-source.ts"],"mappings":";;;;;;;
|
|
1
|
+
{"version":3,"file":"action-source.d.mts","names":[],"sources":["../../src/server/action-source.ts"],"mappings":";;;;;;;YAOY;;;;;;;YAQA,oBAAoB;;wBAyBhB,oBACd,UAAU,UACV,eAAe,oBACd"}
|
|
@@ -5,8 +5,8 @@ import { TrackEvent, UserProvidedData } from "../track/types.cjs";
|
|
|
5
5
|
* events upload, everything else is skipped silently. In the hybrid setup this is the id of
|
|
6
6
|
* the SAME conversion action the gtag tag reports to.
|
|
7
7
|
*/
|
|
8
|
-
type GoogleAdsConversionConfig = Record<Lowercase<string>, number | string>;
|
|
9
|
-
interface GoogleAdsAuth {
|
|
8
|
+
export type GoogleAdsConversionConfig = Record<Lowercase<string>, number | string>;
|
|
9
|
+
export interface GoogleAdsAuth {
|
|
10
10
|
/** OAuth2 access token with the `datamanager` scope. Short-lived; the caller refreshes it. */
|
|
11
11
|
accessToken: string;
|
|
12
12
|
/** The Google Ads account the conversion actions live in. Dashes are tolerated: '123-456-7890'. */
|
|
@@ -18,11 +18,11 @@ interface GoogleAdsAuth {
|
|
|
18
18
|
* EEA/UK/CH consent, applied request-wide. Google drops EEA conversions without granted
|
|
19
19
|
* `adUserData` from bidding, so a host with consent signals should pass them.
|
|
20
20
|
*/
|
|
21
|
-
interface GoogleAdsConsent {
|
|
21
|
+
export interface GoogleAdsConsent {
|
|
22
22
|
adUserData?: 'CONSENT_GRANTED' | 'CONSENT_DENIED' | 'CONSENT_STATUS_UNSPECIFIED';
|
|
23
23
|
adPersonalization?: 'CONSENT_GRANTED' | 'CONSENT_DENIED' | 'CONSENT_STATUS_UNSPECIFIED';
|
|
24
24
|
}
|
|
25
|
-
interface GoogleAdsConversionsOptions {
|
|
25
|
+
export interface GoogleAdsConversionsOptions {
|
|
26
26
|
/** Validates the payload server-side without recording conversions. */
|
|
27
27
|
validateOnly?: boolean;
|
|
28
28
|
consent?: GoogleAdsConsent;
|
|
@@ -32,9 +32,9 @@ interface GoogleAdsConversionsOptions {
|
|
|
32
32
|
* username's dots and everything from '+' on are removed; for every other domain they are kept.
|
|
33
33
|
* https://developers.google.com/data-manager/api/devguides/format-data
|
|
34
34
|
*/
|
|
35
|
-
declare function normalizeEmail(input: string): string;
|
|
35
|
+
export declare function normalizeEmail(input: string): string;
|
|
36
36
|
/** One entry of the `events` array. Field names are the REST (camelCase) spellings. */
|
|
37
|
-
interface DataManagerEvent {
|
|
37
|
+
export interface DataManagerEvent {
|
|
38
38
|
destinationReferences: string[];
|
|
39
39
|
transactionId: string;
|
|
40
40
|
/** RFC 3339 — `created_at` as stored, unlike the legacy API's bespoke format. */
|
|
@@ -58,8 +58,8 @@ interface DataManagerEvent {
|
|
|
58
58
|
* the legacy upload, an event with no click id at all is still worth sending when it carries
|
|
59
59
|
* user identifiers — that is the enhanced-conversions match path.
|
|
60
60
|
*/
|
|
61
|
-
declare function getDataManagerEvent(event: TrackEvent<any>, config: GoogleAdsConversionConfig, data?: UserProvidedData): DataManagerEvent | undefined;
|
|
62
|
-
interface DataManagerResponse {
|
|
61
|
+
export declare function getDataManagerEvent(event: TrackEvent<any>, config: GoogleAdsConversionConfig, data?: UserProvidedData): DataManagerEvent | undefined;
|
|
62
|
+
export interface DataManagerResponse {
|
|
63
63
|
requestId?: string;
|
|
64
64
|
}
|
|
65
65
|
/**
|
|
@@ -69,7 +69,6 @@ interface DataManagerResponse {
|
|
|
69
69
|
* the builder is strict about only emitting events the API can accept. A batch beyond the
|
|
70
70
|
* 2000-event request cap goes out as sequential requests; the first response is returned.
|
|
71
71
|
*/
|
|
72
|
-
declare function sendEvents(auth: GoogleAdsAuth, config: GoogleAdsConversionConfig, events: TrackEvent<any>[], data?: UserProvidedData, options?: GoogleAdsConversionsOptions): Promise<DataManagerResponse | undefined>;
|
|
72
|
+
export declare function sendEvents(auth: GoogleAdsAuth, config: GoogleAdsConversionConfig, events: TrackEvent<any>[], data?: UserProvidedData, options?: GoogleAdsConversionsOptions): Promise<DataManagerResponse | undefined>;
|
|
73
73
|
//#endregion
|
|
74
|
-
export { DataManagerEvent, DataManagerResponse, GoogleAdsAuth, GoogleAdsConsent, GoogleAdsConversionConfig, GoogleAdsConversionsOptions, getDataManagerEvent, normalizeEmail, sendEvents };
|
|
75
74
|
//# sourceMappingURL=google-data-manager.d.cts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"google-data-manager.d.cts","names":[],"sources":["../../src/server/google-data-manager.ts"],"mappings":";;;;;;;
|
|
1
|
+
{"version":3,"file":"google-data-manager.d.cts","names":[],"sources":["../../src/server/google-data-manager.ts"],"mappings":";;;;;;;YAqCY,4BAA4B,OAAO;iBAE9B;;EAEf;;EAEA;;EAEA;;;;;;iBAOe;EACf;EACA;;iBAGe;;EAEf;EACA,UAAU;;;;;;;wBAQI,eAAe;;iBA2Cd;EACf;EACA;;EAEA;EACA;EACA;EACA;EACA;IAAkB;IAAgB;IAAiB;;EACnD;IAAa,iBAAiB;;;;;;;;;;wBAUhB,oBAEd,OAAO,iBACP,QAAQ,2BACR,OAAM,mBACL;iBAwCc;EACf;;;;;;;;;wBAaoB,WACpB,MAAM,eACN,QAAQ,2BAER,QAAQ,mBACR,OAAM,kBACN,UAAS,8BACR,QAAQ"}
|
|
@@ -5,8 +5,8 @@ import { TrackEvent, UserProvidedData } from "../track/types.mjs";
|
|
|
5
5
|
* events upload, everything else is skipped silently. In the hybrid setup this is the id of
|
|
6
6
|
* the SAME conversion action the gtag tag reports to.
|
|
7
7
|
*/
|
|
8
|
-
type GoogleAdsConversionConfig = Record<Lowercase<string>, number | string>;
|
|
9
|
-
interface GoogleAdsAuth {
|
|
8
|
+
export type GoogleAdsConversionConfig = Record<Lowercase<string>, number | string>;
|
|
9
|
+
export interface GoogleAdsAuth {
|
|
10
10
|
/** OAuth2 access token with the `datamanager` scope. Short-lived; the caller refreshes it. */
|
|
11
11
|
accessToken: string;
|
|
12
12
|
/** The Google Ads account the conversion actions live in. Dashes are tolerated: '123-456-7890'. */
|
|
@@ -18,11 +18,11 @@ interface GoogleAdsAuth {
|
|
|
18
18
|
* EEA/UK/CH consent, applied request-wide. Google drops EEA conversions without granted
|
|
19
19
|
* `adUserData` from bidding, so a host with consent signals should pass them.
|
|
20
20
|
*/
|
|
21
|
-
interface GoogleAdsConsent {
|
|
21
|
+
export interface GoogleAdsConsent {
|
|
22
22
|
adUserData?: 'CONSENT_GRANTED' | 'CONSENT_DENIED' | 'CONSENT_STATUS_UNSPECIFIED';
|
|
23
23
|
adPersonalization?: 'CONSENT_GRANTED' | 'CONSENT_DENIED' | 'CONSENT_STATUS_UNSPECIFIED';
|
|
24
24
|
}
|
|
25
|
-
interface GoogleAdsConversionsOptions {
|
|
25
|
+
export interface GoogleAdsConversionsOptions {
|
|
26
26
|
/** Validates the payload server-side without recording conversions. */
|
|
27
27
|
validateOnly?: boolean;
|
|
28
28
|
consent?: GoogleAdsConsent;
|
|
@@ -32,9 +32,9 @@ interface GoogleAdsConversionsOptions {
|
|
|
32
32
|
* username's dots and everything from '+' on are removed; for every other domain they are kept.
|
|
33
33
|
* https://developers.google.com/data-manager/api/devguides/format-data
|
|
34
34
|
*/
|
|
35
|
-
declare function normalizeEmail(input: string): string;
|
|
35
|
+
export declare function normalizeEmail(input: string): string;
|
|
36
36
|
/** One entry of the `events` array. Field names are the REST (camelCase) spellings. */
|
|
37
|
-
interface DataManagerEvent {
|
|
37
|
+
export interface DataManagerEvent {
|
|
38
38
|
destinationReferences: string[];
|
|
39
39
|
transactionId: string;
|
|
40
40
|
/** RFC 3339 — `created_at` as stored, unlike the legacy API's bespoke format. */
|
|
@@ -58,8 +58,8 @@ interface DataManagerEvent {
|
|
|
58
58
|
* the legacy upload, an event with no click id at all is still worth sending when it carries
|
|
59
59
|
* user identifiers — that is the enhanced-conversions match path.
|
|
60
60
|
*/
|
|
61
|
-
declare function getDataManagerEvent(event: TrackEvent<any>, config: GoogleAdsConversionConfig, data?: UserProvidedData): DataManagerEvent | undefined;
|
|
62
|
-
interface DataManagerResponse {
|
|
61
|
+
export declare function getDataManagerEvent(event: TrackEvent<any>, config: GoogleAdsConversionConfig, data?: UserProvidedData): DataManagerEvent | undefined;
|
|
62
|
+
export interface DataManagerResponse {
|
|
63
63
|
requestId?: string;
|
|
64
64
|
}
|
|
65
65
|
/**
|
|
@@ -69,7 +69,6 @@ interface DataManagerResponse {
|
|
|
69
69
|
* the builder is strict about only emitting events the API can accept. A batch beyond the
|
|
70
70
|
* 2000-event request cap goes out as sequential requests; the first response is returned.
|
|
71
71
|
*/
|
|
72
|
-
declare function sendEvents(auth: GoogleAdsAuth, config: GoogleAdsConversionConfig, events: TrackEvent<any>[], data?: UserProvidedData, options?: GoogleAdsConversionsOptions): Promise<DataManagerResponse | undefined>;
|
|
72
|
+
export declare function sendEvents(auth: GoogleAdsAuth, config: GoogleAdsConversionConfig, events: TrackEvent<any>[], data?: UserProvidedData, options?: GoogleAdsConversionsOptions): Promise<DataManagerResponse | undefined>;
|
|
73
73
|
//#endregion
|
|
74
|
-
export { DataManagerEvent, DataManagerResponse, GoogleAdsAuth, GoogleAdsConsent, GoogleAdsConversionConfig, GoogleAdsConversionsOptions, getDataManagerEvent, normalizeEmail, sendEvents };
|
|
75
74
|
//# sourceMappingURL=google-data-manager.d.mts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"google-data-manager.d.mts","names":[],"sources":["../../src/server/google-data-manager.ts"],"mappings":";;;;;;;
|
|
1
|
+
{"version":3,"file":"google-data-manager.d.mts","names":[],"sources":["../../src/server/google-data-manager.ts"],"mappings":";;;;;;;YAqCY,4BAA4B,OAAO;iBAE9B;;EAEf;;EAEA;;EAEA;;;;;;iBAOe;EACf;EACA;;iBAGe;;EAEf;EACA,UAAU;;;;;;;wBAQI,eAAe;;iBA2Cd;EACf;EACA;;EAEA;EACA;EACA;EACA;EACA;IAAkB;IAAgB;IAAiB;;EACnD;IAAa,iBAAiB;;;;;;;;;;wBAUhB,oBAEd,OAAO,iBACP,QAAQ,2BACR,OAAM,mBACL;iBAwCc;EACf;;;;;;;;;wBAaoB,WACpB,MAAM,eACN,QAAQ,2BAER,QAAQ,mBACR,OAAM,kBACN,UAAS,8BACR,QAAQ"}
|
|
@@ -5,7 +5,7 @@ import { TrackEvent, UserProvidedData } from "../track/types.cjs";
|
|
|
5
5
|
* here and is no longer in the schema; the IP and Android ones are.
|
|
6
6
|
*/
|
|
7
7
|
type UserIdType = 'SHA256_EMAIL' | 'LINKEDIN_FIRST_PARTY_ADS_TRACKING_UUID' | 'ACXIOM_ID' | 'PLAINTEXT_IP_ADDRESS' | 'SHA256_IP_ADDRESS' | 'GOOGLE_AID';
|
|
8
|
-
interface CreateLinkedinEventDTO {
|
|
8
|
+
export interface CreateLinkedinEventDTO {
|
|
9
9
|
/**
|
|
10
10
|
* For any conversion that you want to send through multiple methods, such as Insight Tag and
|
|
11
11
|
* Conversions API, you must create a conversion rule for each data source (browser and server).
|
|
@@ -56,11 +56,10 @@ interface CreateLinkedinEventDTO {
|
|
|
56
56
|
lead?: `urn:li:leadGenFormResponse:${string}`;
|
|
57
57
|
};
|
|
58
58
|
}
|
|
59
|
-
interface CreateMultipleLinkedinEventsDTO {
|
|
59
|
+
export interface CreateMultipleLinkedinEventsDTO {
|
|
60
60
|
elements: CreateLinkedinEventDTO[];
|
|
61
61
|
}
|
|
62
|
-
type LinkedinConversionConfig = Record<Lowercase<string>, number>;
|
|
63
|
-
declare function sendEvents(accessToken: string, config: LinkedinConversionConfig, events: TrackEvent<any>[], data?: UserProvidedData): Promise<void>;
|
|
62
|
+
export type LinkedinConversionConfig = Record<Lowercase<string>, number>;
|
|
63
|
+
export declare function sendEvents(accessToken: string, config: LinkedinConversionConfig, events: TrackEvent<any>[], data?: UserProvidedData): Promise<void>;
|
|
64
64
|
//#endregion
|
|
65
|
-
export { CreateLinkedinEventDTO, CreateMultipleLinkedinEventsDTO, LinkedinConversionConfig, sendEvents };
|
|
66
65
|
//# sourceMappingURL=linkedin-conversions-api.d.cts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"linkedin-conversions-api.d.cts","names":[],"sources":["../../src/server/linkedin-conversions-api.ts"],"mappings":";;;;;;KAcK;
|
|
1
|
+
{"version":3,"file":"linkedin-conversions-api.d.cts","names":[],"sources":["../../src/server/linkedin-conversions-api.ts"],"mappings":";;;;;;KAcK;iBAQY;;;;;;;;;EASf;;;;;EAMA;;EAGA;EACA;IAAmB;IAAsB;;EACzC;IACE;MAAW,QAAQ;MAAY;;;;;;;;IAO/B;MACE;MACA;MACA;MACA;MACA;;;;;;IAOF;;;;;IAMA;;;iBAIa;EACf,UAAU;;YA4BA,2BAA2B,OAAO;wBAExB,WACpB,qBACA,QAAQ,0BAER,QAAQ,mBACR,OAAM,mBAAqB"}
|
|
@@ -5,7 +5,7 @@ import { TrackEvent, UserProvidedData } from "../track/types.mjs";
|
|
|
5
5
|
* here and is no longer in the schema; the IP and Android ones are.
|
|
6
6
|
*/
|
|
7
7
|
type UserIdType = 'SHA256_EMAIL' | 'LINKEDIN_FIRST_PARTY_ADS_TRACKING_UUID' | 'ACXIOM_ID' | 'PLAINTEXT_IP_ADDRESS' | 'SHA256_IP_ADDRESS' | 'GOOGLE_AID';
|
|
8
|
-
interface CreateLinkedinEventDTO {
|
|
8
|
+
export interface CreateLinkedinEventDTO {
|
|
9
9
|
/**
|
|
10
10
|
* For any conversion that you want to send through multiple methods, such as Insight Tag and
|
|
11
11
|
* Conversions API, you must create a conversion rule for each data source (browser and server).
|
|
@@ -56,11 +56,10 @@ interface CreateLinkedinEventDTO {
|
|
|
56
56
|
lead?: `urn:li:leadGenFormResponse:${string}`;
|
|
57
57
|
};
|
|
58
58
|
}
|
|
59
|
-
interface CreateMultipleLinkedinEventsDTO {
|
|
59
|
+
export interface CreateMultipleLinkedinEventsDTO {
|
|
60
60
|
elements: CreateLinkedinEventDTO[];
|
|
61
61
|
}
|
|
62
|
-
type LinkedinConversionConfig = Record<Lowercase<string>, number>;
|
|
63
|
-
declare function sendEvents(accessToken: string, config: LinkedinConversionConfig, events: TrackEvent<any>[], data?: UserProvidedData): Promise<void>;
|
|
62
|
+
export type LinkedinConversionConfig = Record<Lowercase<string>, number>;
|
|
63
|
+
export declare function sendEvents(accessToken: string, config: LinkedinConversionConfig, events: TrackEvent<any>[], data?: UserProvidedData): Promise<void>;
|
|
64
64
|
//#endregion
|
|
65
|
-
export { CreateLinkedinEventDTO, CreateMultipleLinkedinEventsDTO, LinkedinConversionConfig, sendEvents };
|
|
66
65
|
//# sourceMappingURL=linkedin-conversions-api.d.mts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"linkedin-conversions-api.d.mts","names":[],"sources":["../../src/server/linkedin-conversions-api.ts"],"mappings":";;;;;;KAcK;
|
|
1
|
+
{"version":3,"file":"linkedin-conversions-api.d.mts","names":[],"sources":["../../src/server/linkedin-conversions-api.ts"],"mappings":";;;;;;KAcK;iBAQY;;;;;;;;;EASf;;;;;EAMA;;EAGA;EACA;IAAmB;IAAsB;;EACzC;IACE;MAAW,QAAQ;MAAY;;;;;;;;IAO/B;MACE;MACA;MACA;MACA;MACA;;;;;;IAOF;;;;;IAMA;;;iBAIa;EACf,UAAU;;YA4BA,2BAA2B,OAAO;wBAExB,WACpB,qBACA,QAAQ,0BAER,QAAQ,mBACR,OAAM,mBAAqB"}
|