@shware/analytics 3.6.4 → 3.7.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 +50 -3
- package/dist/_virtual/_rolldown/runtime.cjs +23 -0
- package/dist/constants/storage.cjs +12 -37
- package/dist/constants/storage.cjs.map +1 -1
- package/dist/constants/storage.d.cts +10 -8
- package/dist/constants/storage.d.cts.map +1 -0
- package/dist/constants/storage.d.mts +13 -0
- package/dist/constants/storage.d.mts.map +1 -0
- package/dist/constants/storage.mjs +12 -13
- package/dist/constants/storage.mjs.map +1 -1
- package/dist/feedback/index.cjs +14 -40
- package/dist/feedback/index.cjs.map +1 -1
- package/dist/feedback/index.d.cts +4 -4
- package/dist/feedback/index.d.cts.map +1 -0
- package/dist/feedback/index.d.mts +6 -0
- package/dist/feedback/index.d.mts.map +1 -0
- package/dist/feedback/index.mjs +12 -14
- package/dist/feedback/index.mjs.map +1 -1
- package/dist/hooks/use-app-analytics.cjs +46 -65
- package/dist/hooks/use-app-analytics.cjs.map +1 -1
- package/dist/hooks/use-app-analytics.d.cts +3 -1
- package/dist/hooks/use-app-analytics.d.cts.map +1 -0
- package/dist/hooks/use-app-analytics.d.mts +5 -0
- package/dist/hooks/use-app-analytics.d.mts.map +1 -0
- package/dist/hooks/use-app-analytics.mjs +41 -36
- package/dist/hooks/use-app-analytics.mjs.map +1 -1
- package/dist/hooks/use-click-id-persistence.cjs +43 -65
- package/dist/hooks/use-click-id-persistence.cjs.map +1 -1
- package/dist/hooks/use-click-id-persistence.d.cts +3 -1
- package/dist/hooks/use-click-id-persistence.d.cts.map +1 -0
- package/dist/hooks/use-click-id-persistence.d.mts +5 -0
- package/dist/hooks/use-click-id-persistence.d.mts.map +1 -0
- package/dist/hooks/use-click-id-persistence.mjs +40 -38
- package/dist/hooks/use-click-id-persistence.mjs.map +1 -1
- package/dist/hooks/use-outbound-click-analytics.cjs +33 -55
- package/dist/hooks/use-outbound-click-analytics.cjs.map +1 -1
- package/dist/hooks/use-outbound-click-analytics.d.cts +3 -1
- package/dist/hooks/use-outbound-click-analytics.d.cts.map +1 -0
- package/dist/hooks/{use-outbound-click-analytics.d.ts → use-outbound-click-analytics.d.mts} +3 -1
- package/dist/hooks/use-outbound-click-analytics.d.mts.map +1 -0
- package/dist/hooks/use-outbound-click-analytics.mjs +31 -29
- package/dist/hooks/use-outbound-click-analytics.mjs.map +1 -1
- package/dist/hooks/use-previous.cjs +11 -35
- package/dist/hooks/use-previous.cjs.map +1 -1
- package/dist/hooks/use-previous.d.cts +3 -1
- package/dist/hooks/use-previous.d.cts.map +1 -0
- package/dist/hooks/use-previous.d.mts +5 -0
- package/dist/hooks/use-previous.d.mts.map +1 -0
- package/dist/hooks/use-previous.mjs +9 -9
- package/dist/hooks/use-previous.mjs.map +1 -1
- package/dist/hooks/use-track-impression.cjs +24 -51
- package/dist/hooks/use-track-impression.cjs.map +1 -1
- package/dist/hooks/use-track-impression.d.cts +5 -6
- package/dist/hooks/use-track-impression.d.cts.map +1 -0
- package/dist/hooks/use-track-impression.d.mts +6 -0
- package/dist/hooks/use-track-impression.d.mts.map +1 -0
- package/dist/hooks/use-track-impression.mjs +22 -25
- package/dist/hooks/use-track-impression.mjs.map +1 -1
- package/dist/hooks/use-web-analytics.cjs +98 -109
- package/dist/hooks/use-web-analytics.cjs.map +1 -1
- package/dist/hooks/use-web-analytics.d.cts +3 -1
- package/dist/hooks/use-web-analytics.d.cts.map +1 -0
- package/dist/hooks/{use-web-analytics.d.ts → use-web-analytics.d.mts} +3 -1
- package/dist/hooks/use-web-analytics.d.mts.map +1 -0
- package/dist/hooks/use-web-analytics.mjs +93 -80
- package/dist/hooks/use-web-analytics.mjs.map +1 -1
- package/dist/index.cjs +28 -74
- package/dist/index.d.cts +11 -13
- package/dist/index.d.mts +11 -0
- package/dist/index.mjs +3 -34
- package/dist/link/index.cjs +31 -58
- package/dist/link/index.cjs.map +1 -1
- package/dist/link/index.d.cts +7 -7
- package/dist/link/index.d.cts.map +1 -0
- package/dist/link/index.d.mts +11 -0
- package/dist/link/index.d.mts.map +1 -0
- package/dist/link/index.mjs +28 -31
- package/dist/link/index.mjs.map +1 -1
- package/dist/native/fbsdk.cjs +12 -33
- package/dist/native/fbsdk.cjs.map +1 -1
- package/dist/native/fbsdk.d.cts +4 -4
- package/dist/native/fbsdk.d.cts.map +1 -0
- package/dist/native/{fbsdk.d.ts → fbsdk.d.mts} +4 -4
- package/dist/native/fbsdk.d.mts.map +1 -0
- package/dist/native/fbsdk.mjs +10 -7
- package/dist/native/fbsdk.mjs.map +1 -1
- package/dist/native/fingerprint.cjs +41 -64
- package/dist/native/fingerprint.cjs.map +1 -1
- package/dist/native/fingerprint.d.cts +22 -20
- package/dist/native/fingerprint.d.cts.map +1 -0
- package/dist/native/fingerprint.d.mts +28 -0
- package/dist/native/fingerprint.d.mts.map +1 -0
- package/dist/native/fingerprint.mjs +36 -42
- package/dist/native/fingerprint.mjs.map +1 -1
- package/dist/native/firebase.cjs +12 -39
- package/dist/native/firebase.cjs.map +1 -1
- package/dist/native/firebase.d.cts +4 -4
- package/dist/native/firebase.d.cts.map +1 -0
- package/dist/native/firebase.d.mts +6 -0
- package/dist/native/firebase.d.mts.map +1 -0
- package/dist/native/firebase.mjs +10 -13
- package/dist/native/firebase.mjs.map +1 -1
- package/dist/native/index.cjs +11 -45
- package/dist/native/index.d.cts +4 -7
- package/dist/native/index.d.mts +4 -0
- package/dist/native/index.mjs +2 -12
- package/dist/native/posthog.cjs +5 -30
- package/dist/native/posthog.cjs.map +1 -1
- package/dist/native/posthog.d.cts +3 -1
- package/dist/native/posthog.d.cts.map +1 -0
- package/dist/native/posthog.d.mts +5 -0
- package/dist/native/posthog.d.mts.map +1 -0
- package/dist/native/posthog.mjs +5 -6
- package/dist/native/posthog.mjs.map +1 -1
- package/dist/native/setup.cjs +91 -129
- package/dist/native/setup.cjs.map +1 -1
- package/dist/native/setup.d.cts +6 -6
- package/dist/native/setup.d.cts.map +1 -0
- package/dist/native/{setup.d.ts → setup.d.mts} +6 -6
- package/dist/native/setup.d.mts.map +1 -0
- package/dist/native/setup.mjs +83 -105
- package/dist/native/setup.mjs.map +1 -1
- package/dist/next/index.cjs +72 -145
- package/dist/next/index.cjs.map +1 -1
- package/dist/next/index.d.cts +18 -19
- package/dist/next/index.d.cts.map +1 -0
- package/dist/next/index.d.mts +21 -0
- package/dist/next/index.d.mts.map +1 -0
- package/dist/next/index.mjs +65 -107
- package/dist/next/index.mjs.map +1 -1
- package/dist/react-router/index.cjs +80 -144
- package/dist/react-router/index.cjs.map +1 -1
- package/dist/react-router/index.d.cts +18 -19
- package/dist/react-router/index.d.cts.map +1 -0
- package/dist/react-router/index.d.mts +21 -0
- package/dist/react-router/index.d.mts.map +1 -0
- package/dist/react-router/index.mjs +75 -115
- package/dist/react-router/index.mjs.map +1 -1
- package/dist/schema/index.cjs +188 -233
- package/dist/schema/index.cjs.map +1 -1
- package/dist/schema/index.d.cts +236 -235
- package/dist/schema/index.d.cts.map +1 -0
- package/dist/schema/index.d.mts +325 -0
- package/dist/schema/index.d.mts.map +1 -0
- package/dist/schema/index.mjs +178 -222
- package/dist/schema/index.mjs.map +1 -1
- package/dist/server/index.cjs +9 -40
- package/dist/server/index.d.cts +5 -9
- package/dist/server/index.d.mts +5 -0
- package/dist/server/index.mjs +5 -12
- package/dist/server/linkedin-conversions-api.cjs +66 -95
- package/dist/server/linkedin-conversions-api.cjs.map +1 -1
- package/dist/server/linkedin-conversions-api.d.cts +45 -45
- package/dist/server/linkedin-conversions-api.d.cts.map +1 -0
- package/dist/server/linkedin-conversions-api.d.mts +56 -0
- package/dist/server/linkedin-conversions-api.d.mts.map +1 -0
- package/dist/server/linkedin-conversions-api.mjs +63 -68
- package/dist/server/linkedin-conversions-api.mjs.map +1 -1
- package/dist/server/meta-conversions-api.cjs +157 -265
- package/dist/server/meta-conversions-api.cjs.map +1 -1
- package/dist/server/meta-conversions-api.d.cts +8 -9
- package/dist/server/meta-conversions-api.d.cts.map +1 -0
- package/dist/server/meta-conversions-api.d.mts +10 -0
- package/dist/server/meta-conversions-api.d.mts.map +1 -0
- package/dist/server/meta-conversions-api.mjs +151 -243
- package/dist/server/meta-conversions-api.mjs.map +1 -1
- package/dist/server/openai-conversions-api.cjs +69 -96
- package/dist/server/openai-conversions-api.cjs.map +1 -1
- package/dist/server/openai-conversions-api.d.cts +34 -34
- package/dist/server/openai-conversions-api.d.cts.map +1 -0
- package/dist/server/openai-conversions-api.d.mts +47 -0
- package/dist/server/openai-conversions-api.d.mts.map +1 -0
- package/dist/server/openai-conversions-api.mjs +65 -68
- package/dist/server/openai-conversions-api.mjs.map +1 -1
- package/dist/server/reddit-conversions-api.cjs +64 -91
- package/dist/server/reddit-conversions-api.cjs.map +1 -1
- package/dist/server/reddit-conversions-api.d.cts +61 -61
- package/dist/server/reddit-conversions-api.d.cts.map +1 -0
- package/dist/server/reddit-conversions-api.d.mts +75 -0
- package/dist/server/reddit-conversions-api.d.mts.map +1 -0
- package/dist/server/reddit-conversions-api.mjs +59 -62
- package/dist/server/reddit-conversions-api.mjs.map +1 -1
- package/dist/setup/index.cjs +34 -63
- package/dist/setup/index.cjs.map +1 -1
- package/dist/setup/index.d.cts +30 -30
- package/dist/setup/index.d.cts.map +1 -0
- package/dist/setup/index.d.mts +41 -0
- package/dist/setup/index.d.mts.map +1 -0
- package/dist/setup/index.mjs +31 -36
- package/dist/setup/index.mjs.map +1 -1
- package/dist/setup/session.cjs +70 -106
- package/dist/setup/session.cjs.map +1 -1
- package/dist/setup/session.d.cts +26 -24
- package/dist/setup/session.d.cts.map +1 -0
- package/dist/setup/session.d.mts +31 -0
- package/dist/setup/session.d.mts.map +1 -0
- package/dist/setup/session.mjs +68 -80
- package/dist/setup/session.mjs.map +1 -1
- package/dist/tanstack/index.cjs +86 -156
- package/dist/tanstack/index.cjs.map +1 -1
- package/dist/tanstack/index.d.cts +19 -20
- package/dist/tanstack/index.d.cts.map +1 -0
- package/dist/tanstack/index.d.mts +22 -0
- package/dist/tanstack/index.d.mts.map +1 -0
- package/dist/tanstack/index.mjs +81 -127
- package/dist/tanstack/index.mjs.map +1 -1
- package/dist/third-parties/google-analytics.cjs +18 -43
- package/dist/third-parties/google-analytics.cjs.map +1 -1
- package/dist/third-parties/google-analytics.d.cts +7 -7
- package/dist/third-parties/google-analytics.d.cts.map +1 -0
- package/dist/third-parties/google-analytics.d.mts +12 -0
- package/dist/third-parties/google-analytics.d.mts.map +1 -0
- package/dist/third-parties/google-analytics.mjs +16 -17
- package/dist/third-parties/google-analytics.mjs.map +1 -1
- package/dist/third-parties/ignored-events.cjs +35 -68
- package/dist/third-parties/ignored-events.cjs.map +1 -1
- package/dist/third-parties/ignored-events.d.cts +3 -1
- package/dist/third-parties/ignored-events.d.cts.map +1 -0
- package/dist/third-parties/ignored-events.d.mts +5 -0
- package/dist/third-parties/ignored-events.d.mts.map +1 -0
- package/dist/third-parties/ignored-events.mjs +34 -43
- package/dist/third-parties/ignored-events.mjs.map +1 -1
- package/dist/third-parties/index.cjs +16 -53
- package/dist/third-parties/index.d.cts +6 -12
- package/dist/third-parties/index.d.mts +6 -0
- package/dist/third-parties/index.mjs +1 -14
- package/dist/third-parties/linkedin-insight-tag.cjs +28 -50
- package/dist/third-parties/linkedin-insight-tag.cjs.map +1 -1
- package/dist/third-parties/linkedin-insight-tag.d.cts +8 -9
- package/dist/third-parties/linkedin-insight-tag.d.cts.map +1 -0
- package/dist/third-parties/{linkedin-insight-tag.d.ts → linkedin-insight-tag.d.mts} +8 -9
- package/dist/third-parties/linkedin-insight-tag.d.mts.map +1 -0
- package/dist/third-parties/linkedin-insight-tag.mjs +25 -23
- package/dist/third-parties/linkedin-insight-tag.mjs.map +1 -1
- package/dist/third-parties/meta-pixel.cjs +45 -66
- package/dist/third-parties/meta-pixel.cjs.map +1 -1
- package/dist/third-parties/meta-pixel.d.cts +7 -8
- package/dist/third-parties/meta-pixel.d.cts.map +1 -0
- package/dist/third-parties/meta-pixel.d.mts +12 -0
- package/dist/third-parties/meta-pixel.d.mts.map +1 -0
- package/dist/third-parties/meta-pixel.mjs +41 -38
- package/dist/third-parties/meta-pixel.mjs.map +1 -1
- package/dist/third-parties/openai-pixel.cjs +63 -68
- package/dist/third-parties/openai-pixel.cjs.map +1 -1
- package/dist/third-parties/openai-pixel.d.cts +7 -8
- package/dist/third-parties/openai-pixel.d.cts.map +1 -0
- package/dist/third-parties/{openai-pixel.d.ts → openai-pixel.d.mts} +7 -8
- package/dist/third-parties/openai-pixel.d.mts.map +1 -0
- package/dist/third-parties/openai-pixel.mjs +60 -41
- package/dist/third-parties/openai-pixel.mjs.map +1 -1
- package/dist/third-parties/posthog.cjs +23 -43
- package/dist/third-parties/posthog.cjs.map +1 -1
- package/dist/third-parties/posthog.d.cts +5 -5
- package/dist/third-parties/posthog.d.cts.map +1 -0
- package/dist/third-parties/{posthog.d.ts → posthog.d.mts} +5 -5
- package/dist/third-parties/posthog.d.mts.map +1 -0
- package/dist/third-parties/posthog.mjs +20 -16
- package/dist/third-parties/posthog.mjs.map +1 -1
- package/dist/third-parties/reddit-pixel.cjs +37 -58
- package/dist/third-parties/reddit-pixel.cjs.map +1 -1
- package/dist/third-parties/reddit-pixel.d.cts +7 -8
- package/dist/third-parties/reddit-pixel.d.cts.map +1 -0
- package/dist/third-parties/reddit-pixel.d.mts +12 -0
- package/dist/third-parties/reddit-pixel.d.mts.map +1 -0
- package/dist/third-parties/reddit-pixel.mjs +33 -30
- package/dist/third-parties/reddit-pixel.mjs.map +1 -1
- package/dist/track/fbq.cjs +179 -135
- package/dist/track/fbq.cjs.map +1 -1
- package/dist/track/fbq.d.cts +234 -233
- package/dist/track/fbq.d.cts.map +1 -0
- package/dist/track/fbq.d.mts +280 -0
- package/dist/track/fbq.d.mts.map +1 -0
- package/dist/track/fbq.mjs +176 -108
- package/dist/track/fbq.mjs.map +1 -1
- package/dist/track/gtag.cjs +63 -86
- package/dist/track/gtag.cjs.map +1 -1
- package/dist/track/gtag.d.cts +682 -682
- package/dist/track/gtag.d.cts.map +1 -0
- package/dist/track/gtag.d.mts +762 -0
- package/dist/track/gtag.d.mts.map +1 -0
- package/dist/track/gtag.mjs +62 -61
- package/dist/track/gtag.mjs.map +1 -1
- package/dist/track/index.cjs +111 -136
- package/dist/track/index.cjs.map +1 -1
- package/dist/track/index.d.cts +8 -8
- package/dist/track/index.d.cts.map +1 -0
- package/dist/track/{index.d.ts → index.d.mts} +8 -8
- package/dist/track/index.d.mts.map +1 -0
- package/dist/track/index.mjs +105 -106
- package/dist/track/index.mjs.map +1 -1
- package/dist/track/lintrk.cjs +0 -19
- package/dist/track/lintrk.d.cts +12 -10
- package/dist/track/lintrk.d.cts.map +1 -0
- package/dist/track/lintrk.d.mts +14 -0
- package/dist/track/lintrk.d.mts.map +1 -0
- package/dist/track/lintrk.mjs +1 -1
- package/dist/track/oaiq.cjs +153 -146
- package/dist/track/oaiq.cjs.map +1 -1
- package/dist/track/oaiq.d.cts +65 -64
- package/dist/track/oaiq.d.cts.map +1 -0
- package/dist/track/oaiq.d.mts +112 -0
- package/dist/track/oaiq.d.mts.map +1 -0
- package/dist/track/oaiq.mjs +149 -118
- package/dist/track/oaiq.mjs.map +1 -1
- package/dist/track/rdt.cjs +66 -110
- package/dist/track/rdt.cjs.map +1 -1
- package/dist/track/rdt.d.cts +74 -73
- package/dist/track/rdt.d.cts.map +1 -0
- package/dist/track/rdt.d.mts +97 -0
- package/dist/track/rdt.d.mts.map +1 -0
- package/dist/track/rdt.mjs +63 -83
- package/dist/track/rdt.mjs.map +1 -1
- package/dist/track/types.cjs +0 -19
- package/dist/track/types.d.cts +140 -111
- package/dist/track/types.d.cts.map +1 -0
- package/dist/track/types.d.mts +171 -0
- package/dist/track/types.d.mts.map +1 -0
- package/dist/track/types.mjs +1 -1
- package/dist/utils/field.cjs +8 -32
- package/dist/utils/field.cjs.map +1 -1
- package/dist/utils/field.d.cts +3 -1
- package/dist/utils/field.d.cts.map +1 -0
- package/dist/utils/{field.d.ts → field.d.mts} +3 -1
- package/dist/utils/field.d.mts.map +1 -0
- package/dist/utils/field.mjs +7 -7
- package/dist/utils/field.mjs.map +1 -1
- package/dist/utils/stripe.cjs +25 -49
- package/dist/utils/stripe.cjs.map +1 -1
- package/dist/utils/stripe.d.cts +3 -1
- package/dist/utils/stripe.d.cts.map +1 -0
- package/dist/utils/{stripe.d.ts → stripe.d.mts} +3 -1
- package/dist/utils/stripe.d.mts.map +1 -0
- package/dist/utils/stripe.mjs +23 -23
- package/dist/utils/stripe.mjs.map +1 -1
- package/dist/visitor/index.cjs +54 -86
- package/dist/visitor/index.cjs.map +1 -1
- package/dist/visitor/index.d.cts +4 -5
- package/dist/visitor/index.d.cts.map +1 -0
- package/dist/visitor/{index.d.ts → index.d.mts} +4 -5
- package/dist/visitor/index.d.mts.map +1 -0
- package/dist/visitor/index.mjs +51 -59
- package/dist/visitor/index.mjs.map +1 -1
- package/dist/visitor/types.cjs +0 -19
- package/dist/visitor/types.d.cts +15 -14
- package/dist/visitor/types.d.cts.map +1 -0
- package/dist/visitor/types.d.mts +21 -0
- package/dist/visitor/types.d.mts.map +1 -0
- package/dist/visitor/types.mjs +1 -1
- package/dist/web/index.cjs +108 -148
- package/dist/web/index.cjs.map +1 -1
- package/dist/web/index.d.cts +5 -6
- package/dist/web/index.d.cts.map +1 -0
- package/dist/web/index.d.mts +9 -0
- package/dist/web/index.d.mts.map +1 -0
- package/dist/web/index.mjs +101 -109
- package/dist/web/index.mjs.map +1 -1
- package/package.json +102 -49
- package/dist/constants/storage.d.ts +0 -11
- package/dist/feedback/index.d.ts +0 -6
- package/dist/hooks/use-app-analytics.d.ts +0 -3
- package/dist/hooks/use-click-id-persistence.d.ts +0 -3
- package/dist/hooks/use-previous.d.ts +0 -3
- package/dist/hooks/use-track-impression.d.ts +0 -7
- package/dist/index.cjs.map +0 -1
- package/dist/index.d.ts +0 -13
- package/dist/index.mjs.map +0 -1
- package/dist/link/index.d.ts +0 -11
- package/dist/native/fingerprint.d.ts +0 -26
- package/dist/native/firebase.d.ts +0 -6
- package/dist/native/index.cjs.map +0 -1
- package/dist/native/index.d.ts +0 -7
- package/dist/native/index.mjs.map +0 -1
- package/dist/native/posthog.d.ts +0 -3
- package/dist/next/index.d.ts +0 -22
- package/dist/react-router/index.d.ts +0 -22
- package/dist/schema/index.d.ts +0 -324
- package/dist/server/index.cjs.map +0 -1
- package/dist/server/index.d.ts +0 -9
- package/dist/server/index.mjs.map +0 -1
- package/dist/server/linkedin-conversions-api.d.ts +0 -56
- package/dist/server/meta-conversions-api.d.ts +0 -11
- package/dist/server/openai-conversions-api.d.ts +0 -47
- package/dist/server/reddit-conversions-api.d.ts +0 -75
- package/dist/setup/index.d.ts +0 -41
- package/dist/setup/session.d.ts +0 -29
- package/dist/tanstack/index.d.ts +0 -23
- package/dist/third-parties/google-analytics.d.ts +0 -12
- package/dist/third-parties/ignored-events.d.ts +0 -3
- package/dist/third-parties/index.cjs.map +0 -1
- package/dist/third-parties/index.d.ts +0 -12
- package/dist/third-parties/index.mjs.map +0 -1
- package/dist/third-parties/meta-pixel.d.ts +0 -13
- package/dist/third-parties/reddit-pixel.d.ts +0 -13
- package/dist/track/fbq.d.ts +0 -279
- package/dist/track/gtag.d.ts +0 -762
- package/dist/track/lintrk.cjs.map +0 -1
- package/dist/track/lintrk.d.ts +0 -12
- package/dist/track/lintrk.mjs.map +0 -1
- package/dist/track/oaiq.d.ts +0 -111
- package/dist/track/rdt.d.ts +0 -96
- package/dist/track/types.cjs.map +0 -1
- package/dist/track/types.d.ts +0 -142
- package/dist/track/types.mjs.map +0 -1
- package/dist/visitor/types.cjs.map +0 -1
- package/dist/visitor/types.d.ts +0 -20
- package/dist/visitor/types.mjs.map +0 -1
- package/dist/web/index.d.ts +0 -10
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { EventName, TrackName, TrackProperties } from "../track/types.mjs";
|
|
2
|
+
import { UpdateVisitorDTO } from "../visitor/types.mjs";
|
|
3
|
+
import { FBQ, PixelId } from "../track/fbq.mjs";
|
|
4
|
+
//#region src/third-parties/meta-pixel.d.ts
|
|
5
|
+
declare global {
|
|
6
|
+
interface Window extends FBQ {}
|
|
7
|
+
}
|
|
8
|
+
declare function sendFBEvent<T extends EventName>(name: TrackName<T>, properties?: TrackProperties<T>, event_id?: string): void;
|
|
9
|
+
declare function setFBUser(pixelId: PixelId): ({ user_id, data }: UpdateVisitorDTO) => void;
|
|
10
|
+
//#endregion
|
|
11
|
+
export { sendFBEvent, setFBUser };
|
|
12
|
+
//# sourceMappingURL=meta-pixel.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"meta-pixel.d.mts","names":[],"sources":["../../src/third-parties/meta-pixel.ts"],"mappings":";;;;QAKQ;YAEI,eAAe;;iBAKX,YAAY,UAAU,WACpC,MAAM,UAAU,IAChB,aAAa,gBAAgB,IAC7B;iBAmBc,UAAU,SAAS,aAAO,SAAA,QACb"}
|
|
@@ -1,45 +1,48 @@
|
|
|
1
|
-
// src/third-parties/meta-pixel.ts
|
|
2
1
|
import { mapFBEvent } from "../track/fbq.mjs";
|
|
3
2
|
import { getFirst } from "../utils/field.mjs";
|
|
4
|
-
|
|
3
|
+
//#region src/third-parties/meta-pixel.ts
|
|
4
|
+
const metrics = [
|
|
5
|
+
"CLS",
|
|
6
|
+
"FCP",
|
|
7
|
+
"FID",
|
|
8
|
+
"INP",
|
|
9
|
+
"LCP",
|
|
10
|
+
"TTFB"
|
|
11
|
+
];
|
|
5
12
|
function sendFBEvent(name, properties, event_id) {
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
} else {
|
|
18
|
-
window.fbq(type, fbEventName, fbEventProperties, options);
|
|
19
|
-
}
|
|
13
|
+
if (typeof window === "undefined" || !window.fbq) {
|
|
14
|
+
console.warn("fbq has not been initialized");
|
|
15
|
+
return;
|
|
16
|
+
}
|
|
17
|
+
if (metrics.includes(name)) return;
|
|
18
|
+
if (window.location.host.includes("127.0.0.1")) return;
|
|
19
|
+
if (window.location.host.includes("localhost")) return;
|
|
20
|
+
const options = { eventID: event_id };
|
|
21
|
+
const [type, fbEventName, fbEventProperties] = mapFBEvent(name, properties);
|
|
22
|
+
if (type === "track") window.fbq(type, fbEventName, fbEventProperties, options);
|
|
23
|
+
else window.fbq(type, fbEventName, fbEventProperties, options);
|
|
20
24
|
}
|
|
21
25
|
function setFBUser(pixelId) {
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
26
|
+
return ({ user_id, data }) => {
|
|
27
|
+
if (typeof window === "undefined" || !window.fbq) {
|
|
28
|
+
console.warn("fbq has not been initialized");
|
|
29
|
+
return;
|
|
30
|
+
}
|
|
31
|
+
const address = getFirst(data?.address);
|
|
32
|
+
window.fbq("init", pixelId, {
|
|
33
|
+
em: getFirst(data?.email),
|
|
34
|
+
fn: address?.first_name,
|
|
35
|
+
ln: address?.last_name,
|
|
36
|
+
ph: getFirst(data?.phone_number),
|
|
37
|
+
external_id: user_id,
|
|
38
|
+
ct: address?.city,
|
|
39
|
+
st: address?.street,
|
|
40
|
+
zp: address?.postal_code,
|
|
41
|
+
country: address?.country
|
|
42
|
+
});
|
|
43
|
+
};
|
|
40
44
|
}
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
};
|
|
45
|
+
//#endregion
|
|
46
|
+
export { sendFBEvent, setFBUser };
|
|
47
|
+
|
|
45
48
|
//# sourceMappingURL=meta-pixel.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/third-parties/meta-pixel.ts"],"sourcesContent":["import { type FBQ, type PixelId, mapFBEvent } from '../track/fbq';\nimport type { EventName, TrackName, TrackProperties } from '../track/types';\nimport { getFirst } from '../utils/field';\nimport type { UpdateVisitorDTO } from '../visitor/types';\n\ndeclare global {\n // oxlint-disable-next-line typescript/no-empty-object-type\n interface Window extends FBQ {}\n}\n\nconst metrics = ['CLS', 'FCP', 'FID', 'INP', 'LCP', 'TTFB'];\n\nexport function sendFBEvent<T extends EventName>(\n name: TrackName<T>,\n properties?: TrackProperties<T>,\n event_id?: string\n) {\n if (typeof window === 'undefined' || !window.fbq) {\n console.warn('fbq has not been initialized');\n return;\n }\n if (metrics.includes(name)) return;\n if (window.location.host.includes('127.0.0.1')) return;\n if (window.location.host.includes('localhost')) return;\n\n const options = { eventID: event_id };\n const [type, fbEventName, fbEventProperties] = mapFBEvent(name, properties);\n if (type === 'track') {\n window.fbq(type, fbEventName, fbEventProperties, options);\n } else {\n window.fbq(type, fbEventName, fbEventProperties, options);\n }\n}\n\nexport function setFBUser(pixelId: PixelId) {\n return ({ user_id, data }: UpdateVisitorDTO) => {\n if (typeof window === 'undefined' || !window.fbq) {\n console.warn('fbq has not been initialized');\n return;\n }\n\n const address = getFirst(data?.address);\n\n window.fbq('init', pixelId, {\n em: getFirst(data?.email),\n fn: address?.first_name,\n ln: address?.last_name,\n ph: getFirst(data?.phone_number),\n external_id: user_id,\n ct: address?.city,\n st: address?.street,\n zp: address?.postal_code,\n country: address?.country,\n });\n };\n}\n"],"mappings":"
|
|
1
|
+
{"version":3,"file":"meta-pixel.mjs","names":[],"sources":["../../src/third-parties/meta-pixel.ts"],"sourcesContent":["import { type FBQ, type PixelId, mapFBEvent } from '../track/fbq';\nimport type { EventName, TrackName, TrackProperties } from '../track/types';\nimport { getFirst } from '../utils/field';\nimport type { UpdateVisitorDTO } from '../visitor/types';\n\ndeclare global {\n // oxlint-disable-next-line typescript/no-empty-object-type\n interface Window extends FBQ {}\n}\n\nconst metrics = ['CLS', 'FCP', 'FID', 'INP', 'LCP', 'TTFB'];\n\nexport function sendFBEvent<T extends EventName>(\n name: TrackName<T>,\n properties?: TrackProperties<T>,\n event_id?: string\n) {\n if (typeof window === 'undefined' || !window.fbq) {\n console.warn('fbq has not been initialized');\n return;\n }\n if (metrics.includes(name)) return;\n if (window.location.host.includes('127.0.0.1')) return;\n if (window.location.host.includes('localhost')) return;\n\n const options = { eventID: event_id };\n const [type, fbEventName, fbEventProperties] = mapFBEvent(name, properties);\n if (type === 'track') {\n window.fbq(type, fbEventName, fbEventProperties, options);\n } else {\n window.fbq(type, fbEventName, fbEventProperties, options);\n }\n}\n\nexport function setFBUser(pixelId: PixelId) {\n return ({ user_id, data }: UpdateVisitorDTO) => {\n if (typeof window === 'undefined' || !window.fbq) {\n console.warn('fbq has not been initialized');\n return;\n }\n\n const address = getFirst(data?.address);\n\n window.fbq('init', pixelId, {\n em: getFirst(data?.email),\n fn: address?.first_name,\n ln: address?.last_name,\n ph: getFirst(data?.phone_number),\n external_id: user_id,\n ct: address?.city,\n st: address?.street,\n zp: address?.postal_code,\n country: address?.country,\n });\n };\n}\n"],"mappings":";;;AAUA,MAAM,UAAU;CAAC;CAAO;CAAO;CAAO;CAAO;CAAO;AAAM;AAE1D,SAAgB,YACd,MACA,YACA,UACA;CACA,IAAI,OAAO,WAAW,eAAe,CAAC,OAAO,KAAK;EAChD,QAAQ,KAAK,8BAA8B;EAC3C;CACF;CACA,IAAI,QAAQ,SAAS,IAAI,GAAG;CAC5B,IAAI,OAAO,SAAS,KAAK,SAAS,WAAW,GAAG;CAChD,IAAI,OAAO,SAAS,KAAK,SAAS,WAAW,GAAG;CAEhD,MAAM,UAAU,EAAE,SAAS,SAAS;CACpC,MAAM,CAAC,MAAM,aAAa,qBAAqB,WAAW,MAAM,UAAU;CAC1E,IAAI,SAAS,SACX,OAAO,IAAI,MAAM,aAAa,mBAAmB,OAAO;MAExD,OAAO,IAAI,MAAM,aAAa,mBAAmB,OAAO;AAE5D;AAEA,SAAgB,UAAU,SAAkB;CAC1C,QAAQ,EAAE,SAAS,WAA6B;EAC9C,IAAI,OAAO,WAAW,eAAe,CAAC,OAAO,KAAK;GAChD,QAAQ,KAAK,8BAA8B;GAC3C;EACF;EAEA,MAAM,UAAU,SAAS,MAAM,OAAO;EAEtC,OAAO,IAAI,QAAQ,SAAS;GAC1B,IAAI,SAAS,MAAM,KAAK;GACxB,IAAI,SAAS;GACb,IAAI,SAAS;GACb,IAAI,SAAS,MAAM,YAAY;GAC/B,aAAa;GACb,IAAI,SAAS;GACb,IAAI,SAAS;GACb,IAAI,SAAS;GACb,SAAS,SAAS;EACpB,CAAC;CACH;AACF"}
|
|
@@ -1,77 +1,72 @@
|
|
|
1
|
-
"
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
var __export = (target, all) => {
|
|
7
|
-
for (var name in all)
|
|
8
|
-
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
-
};
|
|
10
|
-
var __copyProps = (to, from, except, desc) => {
|
|
11
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
-
for (let key of __getOwnPropNames(from))
|
|
13
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
-
}
|
|
16
|
-
return to;
|
|
17
|
-
};
|
|
18
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
-
|
|
20
|
-
// src/third-parties/openai-pixel.ts
|
|
21
|
-
var openai_pixel_exports = {};
|
|
22
|
-
__export(openai_pixel_exports, {
|
|
23
|
-
sendOpenAIEvent: () => sendOpenAIEvent,
|
|
24
|
-
setOpenAIUser: () => setOpenAIUser
|
|
25
|
-
});
|
|
26
|
-
module.exports = __toCommonJS(openai_pixel_exports);
|
|
27
|
-
var import_oaiq = require("../track/oaiq.cjs");
|
|
28
|
-
var import_field = require("../utils/field.cjs");
|
|
1
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
|
+
const require_utils_field = require("../utils/field.cjs");
|
|
3
|
+
const require_track_oaiq = require("../track/oaiq.cjs");
|
|
4
|
+
//#region src/third-parties/openai-pixel.ts
|
|
5
|
+
/** Drop `undefined` fields so the SDK only receives populated values. */
|
|
29
6
|
function clean(value) {
|
|
30
|
-
|
|
7
|
+
return JSON.parse(JSON.stringify(value));
|
|
31
8
|
}
|
|
9
|
+
/**
|
|
10
|
+
* Forward an internal track event to the OpenAI measurement pixel.
|
|
11
|
+
* `eventId` is reused as the OpenAI `event_id` so browser events deduplicate against the
|
|
12
|
+
* Conversions API. https://developers.openai.com/ads/measurement-pixel
|
|
13
|
+
*/
|
|
32
14
|
function sendOpenAIEvent(name, properties, eventId) {
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
15
|
+
if (typeof window === "undefined" || !window.oaiq) {
|
|
16
|
+
console.warn("oaiq has not been initialized");
|
|
17
|
+
return;
|
|
18
|
+
}
|
|
19
|
+
if (require_track_oaiq.NON_AD_EVENTS.includes(name)) return;
|
|
20
|
+
if (window.location.host.includes("127.0.0.1")) return;
|
|
21
|
+
if (window.location.host.includes("localhost")) return;
|
|
22
|
+
const { type, data } = require_track_oaiq.mapOAIEvent(name, properties);
|
|
23
|
+
if (type === "custom") window.oaiq("measure", "custom", clean(data), {
|
|
24
|
+
event_id: eventId,
|
|
25
|
+
custom_event_name: name
|
|
26
|
+
});
|
|
27
|
+
else window.oaiq("measure", type, clean(data), { event_id: eventId });
|
|
46
28
|
}
|
|
29
|
+
/** SHA-256 hex digest, lowercase — the format OpenAI expects for hashed identity fields. */
|
|
47
30
|
async function sha256(value) {
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
31
|
+
const bytes = new TextEncoder().encode(value);
|
|
32
|
+
const digest = await crypto.subtle.digest("SHA-256", bytes);
|
|
33
|
+
return Array.from(new Uint8Array(digest)).map((byte) => byte.toString(16).padStart(2, "0")).join("");
|
|
51
34
|
}
|
|
35
|
+
/**
|
|
36
|
+
* Re-initialize the pixel with hashed user identity for better conversion matching. Email and
|
|
37
|
+
* external id are hashed client-side; geographic fields are sent raw. Hashing is asynchronous,
|
|
38
|
+
* so the `init` call is deferred until the digests resolve.
|
|
39
|
+
*/
|
|
52
40
|
function setOpenAIUser(pixelId) {
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
41
|
+
return ({ user_id, data }) => {
|
|
42
|
+
if (typeof window === "undefined" || !window.oaiq) {
|
|
43
|
+
console.warn("oaiq has not been initialized");
|
|
44
|
+
return;
|
|
45
|
+
}
|
|
46
|
+
const email = require_utils_field.getFirst(data?.email)?.trim().toLowerCase();
|
|
47
|
+
const address = require_utils_field.getFirst(data?.address);
|
|
48
|
+
const base = {
|
|
49
|
+
country: address?.country?.trim().toUpperCase(),
|
|
50
|
+
city: address?.city?.trim().toLowerCase(),
|
|
51
|
+
zip_code: address?.postal_code
|
|
52
|
+
};
|
|
53
|
+
const init = (hashed) => {
|
|
54
|
+
window.oaiq("init", {
|
|
55
|
+
pixelId,
|
|
56
|
+
user: clean({
|
|
57
|
+
...base,
|
|
58
|
+
...hashed
|
|
59
|
+
})
|
|
60
|
+
});
|
|
61
|
+
};
|
|
62
|
+
Promise.all([email ? sha256(email) : void 0, user_id ? sha256(user_id) : void 0]).then(([email_sha256, external_id_sha256]) => init({
|
|
63
|
+
email_sha256,
|
|
64
|
+
external_id_sha256
|
|
65
|
+
})).catch(() => init({}));
|
|
66
|
+
};
|
|
71
67
|
}
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
});
|
|
68
|
+
//#endregion
|
|
69
|
+
exports.sendOpenAIEvent = sendOpenAIEvent;
|
|
70
|
+
exports.setOpenAIUser = setOpenAIUser;
|
|
71
|
+
|
|
77
72
|
//# sourceMappingURL=openai-pixel.cjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/third-parties/openai-pixel.ts"],"sourcesContent":["import { NON_AD_EVENTS, type OAIQ, type OAIQUser, mapOAIEvent } from '../track/oaiq';\nimport type { EventName, TrackName, TrackProperties } from '../track/types';\nimport { getFirst } from '../utils/field';\nimport type { UpdateVisitorDTO } from '../visitor/types';\n\ndeclare global {\n // oxlint-disable-next-line typescript/no-empty-object-type\n interface Window extends OAIQ {}\n}\n\n/** Drop `undefined` fields so the SDK only receives populated values. */\n// oxlint-disable-next-line @typescript-eslint/no-explicit-any\nfunction clean(value: unknown): any {\n return JSON.parse(JSON.stringify(value));\n}\n\n/**\n * Forward an internal track event to the OpenAI measurement pixel.\n * `eventId` is reused as the OpenAI `event_id` so browser events deduplicate against the\n * Conversions API. https://developers.openai.com/ads/measurement-pixel\n */\nexport function sendOpenAIEvent<T extends EventName>(\n name: TrackName<T>,\n properties?: TrackProperties<T>,\n eventId?: string\n) {\n if (typeof window === 'undefined' || !window.oaiq) {\n console.warn('oaiq has not been initialized');\n return;\n }\n if (NON_AD_EVENTS.includes(name)) return;\n if (window.location.host.includes('127.0.0.1')) return;\n if (window.location.host.includes('localhost')) return;\n\n const { type, data } = mapOAIEvent(name, properties);\n if (type === 'custom') {\n window.oaiq('measure', 'custom', clean(data), { event_id: eventId, custom_event_name: name });\n } else {\n window.oaiq('measure', type, clean(data), { event_id: eventId });\n }\n}\n\n/** SHA-256 hex digest, lowercase — the format OpenAI expects for hashed identity fields. */\nasync function sha256(value: string): Promise<string> {\n const bytes = new TextEncoder().encode(value);\n const digest = await crypto.subtle.digest('SHA-256', bytes);\n return Array.from(new Uint8Array(digest))\n .map((byte) => byte.toString(16).padStart(2, '0'))\n .join('');\n}\n\n/**\n * Re-initialize the pixel with hashed user identity for better conversion matching. Email and\n * external id are hashed client-side; geographic fields are sent raw. Hashing is asynchronous,\n * so the `init` call is deferred until the digests resolve.\n */\nexport function setOpenAIUser(pixelId: string) {\n return ({ user_id, data }: UpdateVisitorDTO) => {\n if (typeof window === 'undefined' || !window.oaiq) {\n console.warn('oaiq has not been initialized');\n return;\n }\n\n const email = getFirst(data?.email)?.trim().toLowerCase();\n const address = getFirst(data?.address);\n\n const base: OAIQUser = {\n country: address?.country?.trim().toUpperCase(),\n city: address?.city?.trim().toLowerCase(),\n zip_code: address?.postal_code,\n };\n\n const init = (hashed: Partial<OAIQUser>) => {\n window.oaiq('init', { pixelId, user: clean({ ...base, ...hashed }) });\n };\n\n Promise.all([email ? sha256(email) : undefined, user_id ? sha256(user_id) : undefined])\n .then(([email_sha256, external_id_sha256]) => init({ email_sha256, external_id_sha256 }))\n .catch(() => init({}));\n };\n}\n"],"mappings":"
|
|
1
|
+
{"version":3,"file":"openai-pixel.cjs","names":["NON_AD_EVENTS","mapOAIEvent","getFirst"],"sources":["../../src/third-parties/openai-pixel.ts"],"sourcesContent":["import { NON_AD_EVENTS, type OAIQ, type OAIQUser, mapOAIEvent } from '../track/oaiq';\nimport type { EventName, TrackName, TrackProperties } from '../track/types';\nimport { getFirst } from '../utils/field';\nimport type { UpdateVisitorDTO } from '../visitor/types';\n\ndeclare global {\n // oxlint-disable-next-line typescript/no-empty-object-type\n interface Window extends OAIQ {}\n}\n\n/** Drop `undefined` fields so the SDK only receives populated values. */\n// oxlint-disable-next-line @typescript-eslint/no-explicit-any\nfunction clean(value: unknown): any {\n return JSON.parse(JSON.stringify(value));\n}\n\n/**\n * Forward an internal track event to the OpenAI measurement pixel.\n * `eventId` is reused as the OpenAI `event_id` so browser events deduplicate against the\n * Conversions API. https://developers.openai.com/ads/measurement-pixel\n */\nexport function sendOpenAIEvent<T extends EventName>(\n name: TrackName<T>,\n properties?: TrackProperties<T>,\n eventId?: string\n) {\n if (typeof window === 'undefined' || !window.oaiq) {\n console.warn('oaiq has not been initialized');\n return;\n }\n if (NON_AD_EVENTS.includes(name)) return;\n if (window.location.host.includes('127.0.0.1')) return;\n if (window.location.host.includes('localhost')) return;\n\n const { type, data } = mapOAIEvent(name, properties);\n if (type === 'custom') {\n window.oaiq('measure', 'custom', clean(data), { event_id: eventId, custom_event_name: name });\n } else {\n window.oaiq('measure', type, clean(data), { event_id: eventId });\n }\n}\n\n/** SHA-256 hex digest, lowercase — the format OpenAI expects for hashed identity fields. */\nasync function sha256(value: string): Promise<string> {\n const bytes = new TextEncoder().encode(value);\n const digest = await crypto.subtle.digest('SHA-256', bytes);\n return Array.from(new Uint8Array(digest))\n .map((byte) => byte.toString(16).padStart(2, '0'))\n .join('');\n}\n\n/**\n * Re-initialize the pixel with hashed user identity for better conversion matching. Email and\n * external id are hashed client-side; geographic fields are sent raw. Hashing is asynchronous,\n * so the `init` call is deferred until the digests resolve.\n */\nexport function setOpenAIUser(pixelId: string) {\n return ({ user_id, data }: UpdateVisitorDTO) => {\n if (typeof window === 'undefined' || !window.oaiq) {\n console.warn('oaiq has not been initialized');\n return;\n }\n\n const email = getFirst(data?.email)?.trim().toLowerCase();\n const address = getFirst(data?.address);\n\n const base: OAIQUser = {\n country: address?.country?.trim().toUpperCase(),\n city: address?.city?.trim().toLowerCase(),\n zip_code: address?.postal_code,\n };\n\n const init = (hashed: Partial<OAIQUser>) => {\n window.oaiq('init', { pixelId, user: clean({ ...base, ...hashed }) });\n };\n\n Promise.all([email ? sha256(email) : undefined, user_id ? sha256(user_id) : undefined])\n .then(([email_sha256, external_id_sha256]) => init({ email_sha256, external_id_sha256 }))\n .catch(() => init({}));\n };\n}\n"],"mappings":";;;;;AAYA,SAAS,MAAM,OAAqB;CAClC,OAAO,KAAK,MAAM,KAAK,UAAU,KAAK,CAAC;AACzC;;;;;;AAOA,SAAgB,gBACd,MACA,YACA,SACA;CACA,IAAI,OAAO,WAAW,eAAe,CAAC,OAAO,MAAM;EACjD,QAAQ,KAAK,+BAA+B;EAC5C;CACF;CACA,IAAIA,mBAAAA,cAAc,SAAS,IAAI,GAAG;CAClC,IAAI,OAAO,SAAS,KAAK,SAAS,WAAW,GAAG;CAChD,IAAI,OAAO,SAAS,KAAK,SAAS,WAAW,GAAG;CAEhD,MAAM,EAAE,MAAM,SAASC,mBAAAA,YAAY,MAAM,UAAU;CACnD,IAAI,SAAS,UACX,OAAO,KAAK,WAAW,UAAU,MAAM,IAAI,GAAG;EAAE,UAAU;EAAS,mBAAmB;CAAK,CAAC;MAE5F,OAAO,KAAK,WAAW,MAAM,MAAM,IAAI,GAAG,EAAE,UAAU,QAAQ,CAAC;AAEnE;;AAGA,eAAe,OAAO,OAAgC;CACpD,MAAM,QAAQ,IAAI,YAAY,CAAC,CAAC,OAAO,KAAK;CAC5C,MAAM,SAAS,MAAM,OAAO,OAAO,OAAO,WAAW,KAAK;CAC1D,OAAO,MAAM,KAAK,IAAI,WAAW,MAAM,CAAC,CAAC,CACtC,KAAK,SAAS,KAAK,SAAS,EAAE,CAAC,CAAC,SAAS,GAAG,GAAG,CAAC,CAAC,CACjD,KAAK,EAAE;AACZ;;;;;;AAOA,SAAgB,cAAc,SAAiB;CAC7C,QAAQ,EAAE,SAAS,WAA6B;EAC9C,IAAI,OAAO,WAAW,eAAe,CAAC,OAAO,MAAM;GACjD,QAAQ,KAAK,+BAA+B;GAC5C;EACF;EAEA,MAAM,QAAQC,oBAAAA,SAAS,MAAM,KAAK,CAAC,EAAE,KAAK,CAAC,CAAC,YAAY;EACxD,MAAM,UAAUA,oBAAAA,SAAS,MAAM,OAAO;EAEtC,MAAM,OAAiB;GACrB,SAAS,SAAS,SAAS,KAAK,CAAC,CAAC,YAAY;GAC9C,MAAM,SAAS,MAAM,KAAK,CAAC,CAAC,YAAY;GACxC,UAAU,SAAS;EACrB;EAEA,MAAM,QAAQ,WAA8B;GAC1C,OAAO,KAAK,QAAQ;IAAE;IAAS,MAAM,MAAM;KAAE,GAAG;KAAM,GAAG;IAAO,CAAC;GAAE,CAAC;EACtE;EAEA,QAAQ,IAAI,CAAC,QAAQ,OAAO,KAAK,IAAI,KAAA,GAAW,UAAU,OAAO,OAAO,IAAI,KAAA,CAAS,CAAC,CAAC,CACpF,MAAM,CAAC,cAAc,wBAAwB,KAAK;GAAE;GAAc;EAAmB,CAAC,CAAC,CAAC,CACxF,YAAY,KAAK,CAAC,CAAC,CAAC;CACzB;AACF"}
|
|
@@ -1,11 +1,9 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
|
|
5
|
-
|
|
1
|
+
import { EventName, TrackName, TrackProperties } from "../track/types.cjs";
|
|
2
|
+
import { UpdateVisitorDTO } from "../visitor/types.cjs";
|
|
3
|
+
import { OAIQ } from "../track/oaiq.cjs";
|
|
4
|
+
//#region src/third-parties/openai-pixel.d.ts
|
|
6
5
|
declare global {
|
|
7
|
-
|
|
8
|
-
}
|
|
6
|
+
interface Window extends OAIQ {}
|
|
9
7
|
}
|
|
10
8
|
/**
|
|
11
9
|
* Forward an internal track event to the OpenAI measurement pixel.
|
|
@@ -19,5 +17,6 @@ declare function sendOpenAIEvent<T extends EventName>(name: TrackName<T>, proper
|
|
|
19
17
|
* so the `init` call is deferred until the digests resolve.
|
|
20
18
|
*/
|
|
21
19
|
declare function setOpenAIUser(pixelId: string): ({ user_id, data }: UpdateVisitorDTO) => void;
|
|
22
|
-
|
|
20
|
+
//#endregion
|
|
23
21
|
export { sendOpenAIEvent, setOpenAIUser };
|
|
22
|
+
//# sourceMappingURL=openai-pixel.d.cts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"openai-pixel.d.cts","names":[],"sources":["../../src/third-parties/openai-pixel.ts"],"mappings":";;;;QAKQ;YAEI,eAAe;;;;;;;iBAcX,gBAAgB,UAAU,WACxC,MAAM,UAAU,IAChB,aAAa,gBAAgB,IAC7B;;;;;;iBAgCc,cAAc,qBAAe,SAAA,QAChB"}
|
|
@@ -1,11 +1,9 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
|
|
5
|
-
|
|
1
|
+
import { EventName, TrackName, TrackProperties } from "../track/types.mjs";
|
|
2
|
+
import { UpdateVisitorDTO } from "../visitor/types.mjs";
|
|
3
|
+
import { OAIQ } from "../track/oaiq.mjs";
|
|
4
|
+
//#region src/third-parties/openai-pixel.d.ts
|
|
6
5
|
declare global {
|
|
7
|
-
|
|
8
|
-
}
|
|
6
|
+
interface Window extends OAIQ {}
|
|
9
7
|
}
|
|
10
8
|
/**
|
|
11
9
|
* Forward an internal track event to the OpenAI measurement pixel.
|
|
@@ -19,5 +17,6 @@ declare function sendOpenAIEvent<T extends EventName>(name: TrackName<T>, proper
|
|
|
19
17
|
* so the `init` call is deferred until the digests resolve.
|
|
20
18
|
*/
|
|
21
19
|
declare function setOpenAIUser(pixelId: string): ({ user_id, data }: UpdateVisitorDTO) => void;
|
|
22
|
-
|
|
20
|
+
//#endregion
|
|
23
21
|
export { sendOpenAIEvent, setOpenAIUser };
|
|
22
|
+
//# sourceMappingURL=openai-pixel.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"openai-pixel.d.mts","names":[],"sources":["../../src/third-parties/openai-pixel.ts"],"mappings":";;;;QAKQ;YAEI,eAAe;;;;;;;iBAcX,gBAAgB,UAAU,WACxC,MAAM,UAAU,IAChB,aAAa,gBAAgB,IAC7B;;;;;;iBAgCc,cAAc,qBAAe,SAAA,QAChB"}
|
|
@@ -1,51 +1,70 @@
|
|
|
1
|
-
// src/third-parties/openai-pixel.ts
|
|
2
|
-
import { NON_AD_EVENTS, mapOAIEvent } from "../track/oaiq.mjs";
|
|
3
1
|
import { getFirst } from "../utils/field.mjs";
|
|
2
|
+
import { NON_AD_EVENTS, mapOAIEvent } from "../track/oaiq.mjs";
|
|
3
|
+
//#region src/third-parties/openai-pixel.ts
|
|
4
|
+
/** Drop `undefined` fields so the SDK only receives populated values. */
|
|
4
5
|
function clean(value) {
|
|
5
|
-
|
|
6
|
+
return JSON.parse(JSON.stringify(value));
|
|
6
7
|
}
|
|
8
|
+
/**
|
|
9
|
+
* Forward an internal track event to the OpenAI measurement pixel.
|
|
10
|
+
* `eventId` is reused as the OpenAI `event_id` so browser events deduplicate against the
|
|
11
|
+
* Conversions API. https://developers.openai.com/ads/measurement-pixel
|
|
12
|
+
*/
|
|
7
13
|
function sendOpenAIEvent(name, properties, eventId) {
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
14
|
+
if (typeof window === "undefined" || !window.oaiq) {
|
|
15
|
+
console.warn("oaiq has not been initialized");
|
|
16
|
+
return;
|
|
17
|
+
}
|
|
18
|
+
if (NON_AD_EVENTS.includes(name)) return;
|
|
19
|
+
if (window.location.host.includes("127.0.0.1")) return;
|
|
20
|
+
if (window.location.host.includes("localhost")) return;
|
|
21
|
+
const { type, data } = mapOAIEvent(name, properties);
|
|
22
|
+
if (type === "custom") window.oaiq("measure", "custom", clean(data), {
|
|
23
|
+
event_id: eventId,
|
|
24
|
+
custom_event_name: name
|
|
25
|
+
});
|
|
26
|
+
else window.oaiq("measure", type, clean(data), { event_id: eventId });
|
|
21
27
|
}
|
|
28
|
+
/** SHA-256 hex digest, lowercase — the format OpenAI expects for hashed identity fields. */
|
|
22
29
|
async function sha256(value) {
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
30
|
+
const bytes = new TextEncoder().encode(value);
|
|
31
|
+
const digest = await crypto.subtle.digest("SHA-256", bytes);
|
|
32
|
+
return Array.from(new Uint8Array(digest)).map((byte) => byte.toString(16).padStart(2, "0")).join("");
|
|
26
33
|
}
|
|
34
|
+
/**
|
|
35
|
+
* Re-initialize the pixel with hashed user identity for better conversion matching. Email and
|
|
36
|
+
* external id are hashed client-side; geographic fields are sent raw. Hashing is asynchronous,
|
|
37
|
+
* so the `init` call is deferred until the digests resolve.
|
|
38
|
+
*/
|
|
27
39
|
function setOpenAIUser(pixelId) {
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
40
|
+
return ({ user_id, data }) => {
|
|
41
|
+
if (typeof window === "undefined" || !window.oaiq) {
|
|
42
|
+
console.warn("oaiq has not been initialized");
|
|
43
|
+
return;
|
|
44
|
+
}
|
|
45
|
+
const email = getFirst(data?.email)?.trim().toLowerCase();
|
|
46
|
+
const address = getFirst(data?.address);
|
|
47
|
+
const base = {
|
|
48
|
+
country: address?.country?.trim().toUpperCase(),
|
|
49
|
+
city: address?.city?.trim().toLowerCase(),
|
|
50
|
+
zip_code: address?.postal_code
|
|
51
|
+
};
|
|
52
|
+
const init = (hashed) => {
|
|
53
|
+
window.oaiq("init", {
|
|
54
|
+
pixelId,
|
|
55
|
+
user: clean({
|
|
56
|
+
...base,
|
|
57
|
+
...hashed
|
|
58
|
+
})
|
|
59
|
+
});
|
|
60
|
+
};
|
|
61
|
+
Promise.all([email ? sha256(email) : void 0, user_id ? sha256(user_id) : void 0]).then(([email_sha256, external_id_sha256]) => init({
|
|
62
|
+
email_sha256,
|
|
63
|
+
external_id_sha256
|
|
64
|
+
})).catch(() => init({}));
|
|
65
|
+
};
|
|
46
66
|
}
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
};
|
|
67
|
+
//#endregion
|
|
68
|
+
export { sendOpenAIEvent, setOpenAIUser };
|
|
69
|
+
|
|
51
70
|
//# sourceMappingURL=openai-pixel.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/third-parties/openai-pixel.ts"],"sourcesContent":["import { NON_AD_EVENTS, type OAIQ, type OAIQUser, mapOAIEvent } from '../track/oaiq';\nimport type { EventName, TrackName, TrackProperties } from '../track/types';\nimport { getFirst } from '../utils/field';\nimport type { UpdateVisitorDTO } from '../visitor/types';\n\ndeclare global {\n // oxlint-disable-next-line typescript/no-empty-object-type\n interface Window extends OAIQ {}\n}\n\n/** Drop `undefined` fields so the SDK only receives populated values. */\n// oxlint-disable-next-line @typescript-eslint/no-explicit-any\nfunction clean(value: unknown): any {\n return JSON.parse(JSON.stringify(value));\n}\n\n/**\n * Forward an internal track event to the OpenAI measurement pixel.\n * `eventId` is reused as the OpenAI `event_id` so browser events deduplicate against the\n * Conversions API. https://developers.openai.com/ads/measurement-pixel\n */\nexport function sendOpenAIEvent<T extends EventName>(\n name: TrackName<T>,\n properties?: TrackProperties<T>,\n eventId?: string\n) {\n if (typeof window === 'undefined' || !window.oaiq) {\n console.warn('oaiq has not been initialized');\n return;\n }\n if (NON_AD_EVENTS.includes(name)) return;\n if (window.location.host.includes('127.0.0.1')) return;\n if (window.location.host.includes('localhost')) return;\n\n const { type, data } = mapOAIEvent(name, properties);\n if (type === 'custom') {\n window.oaiq('measure', 'custom', clean(data), { event_id: eventId, custom_event_name: name });\n } else {\n window.oaiq('measure', type, clean(data), { event_id: eventId });\n }\n}\n\n/** SHA-256 hex digest, lowercase — the format OpenAI expects for hashed identity fields. */\nasync function sha256(value: string): Promise<string> {\n const bytes = new TextEncoder().encode(value);\n const digest = await crypto.subtle.digest('SHA-256', bytes);\n return Array.from(new Uint8Array(digest))\n .map((byte) => byte.toString(16).padStart(2, '0'))\n .join('');\n}\n\n/**\n * Re-initialize the pixel with hashed user identity for better conversion matching. Email and\n * external id are hashed client-side; geographic fields are sent raw. Hashing is asynchronous,\n * so the `init` call is deferred until the digests resolve.\n */\nexport function setOpenAIUser(pixelId: string) {\n return ({ user_id, data }: UpdateVisitorDTO) => {\n if (typeof window === 'undefined' || !window.oaiq) {\n console.warn('oaiq has not been initialized');\n return;\n }\n\n const email = getFirst(data?.email)?.trim().toLowerCase();\n const address = getFirst(data?.address);\n\n const base: OAIQUser = {\n country: address?.country?.trim().toUpperCase(),\n city: address?.city?.trim().toLowerCase(),\n zip_code: address?.postal_code,\n };\n\n const init = (hashed: Partial<OAIQUser>) => {\n window.oaiq('init', { pixelId, user: clean({ ...base, ...hashed }) });\n };\n\n Promise.all([email ? sha256(email) : undefined, user_id ? sha256(user_id) : undefined])\n .then(([email_sha256, external_id_sha256]) => init({ email_sha256, external_id_sha256 }))\n .catch(() => init({}));\n };\n}\n"],"mappings":"
|
|
1
|
+
{"version":3,"file":"openai-pixel.mjs","names":[],"sources":["../../src/third-parties/openai-pixel.ts"],"sourcesContent":["import { NON_AD_EVENTS, type OAIQ, type OAIQUser, mapOAIEvent } from '../track/oaiq';\nimport type { EventName, TrackName, TrackProperties } from '../track/types';\nimport { getFirst } from '../utils/field';\nimport type { UpdateVisitorDTO } from '../visitor/types';\n\ndeclare global {\n // oxlint-disable-next-line typescript/no-empty-object-type\n interface Window extends OAIQ {}\n}\n\n/** Drop `undefined` fields so the SDK only receives populated values. */\n// oxlint-disable-next-line @typescript-eslint/no-explicit-any\nfunction clean(value: unknown): any {\n return JSON.parse(JSON.stringify(value));\n}\n\n/**\n * Forward an internal track event to the OpenAI measurement pixel.\n * `eventId` is reused as the OpenAI `event_id` so browser events deduplicate against the\n * Conversions API. https://developers.openai.com/ads/measurement-pixel\n */\nexport function sendOpenAIEvent<T extends EventName>(\n name: TrackName<T>,\n properties?: TrackProperties<T>,\n eventId?: string\n) {\n if (typeof window === 'undefined' || !window.oaiq) {\n console.warn('oaiq has not been initialized');\n return;\n }\n if (NON_AD_EVENTS.includes(name)) return;\n if (window.location.host.includes('127.0.0.1')) return;\n if (window.location.host.includes('localhost')) return;\n\n const { type, data } = mapOAIEvent(name, properties);\n if (type === 'custom') {\n window.oaiq('measure', 'custom', clean(data), { event_id: eventId, custom_event_name: name });\n } else {\n window.oaiq('measure', type, clean(data), { event_id: eventId });\n }\n}\n\n/** SHA-256 hex digest, lowercase — the format OpenAI expects for hashed identity fields. */\nasync function sha256(value: string): Promise<string> {\n const bytes = new TextEncoder().encode(value);\n const digest = await crypto.subtle.digest('SHA-256', bytes);\n return Array.from(new Uint8Array(digest))\n .map((byte) => byte.toString(16).padStart(2, '0'))\n .join('');\n}\n\n/**\n * Re-initialize the pixel with hashed user identity for better conversion matching. Email and\n * external id are hashed client-side; geographic fields are sent raw. Hashing is asynchronous,\n * so the `init` call is deferred until the digests resolve.\n */\nexport function setOpenAIUser(pixelId: string) {\n return ({ user_id, data }: UpdateVisitorDTO) => {\n if (typeof window === 'undefined' || !window.oaiq) {\n console.warn('oaiq has not been initialized');\n return;\n }\n\n const email = getFirst(data?.email)?.trim().toLowerCase();\n const address = getFirst(data?.address);\n\n const base: OAIQUser = {\n country: address?.country?.trim().toUpperCase(),\n city: address?.city?.trim().toLowerCase(),\n zip_code: address?.postal_code,\n };\n\n const init = (hashed: Partial<OAIQUser>) => {\n window.oaiq('init', { pixelId, user: clean({ ...base, ...hashed }) });\n };\n\n Promise.all([email ? sha256(email) : undefined, user_id ? sha256(user_id) : undefined])\n .then(([email_sha256, external_id_sha256]) => init({ email_sha256, external_id_sha256 }))\n .catch(() => init({}));\n };\n}\n"],"mappings":";;;;AAYA,SAAS,MAAM,OAAqB;CAClC,OAAO,KAAK,MAAM,KAAK,UAAU,KAAK,CAAC;AACzC;;;;;;AAOA,SAAgB,gBACd,MACA,YACA,SACA;CACA,IAAI,OAAO,WAAW,eAAe,CAAC,OAAO,MAAM;EACjD,QAAQ,KAAK,+BAA+B;EAC5C;CACF;CACA,IAAI,cAAc,SAAS,IAAI,GAAG;CAClC,IAAI,OAAO,SAAS,KAAK,SAAS,WAAW,GAAG;CAChD,IAAI,OAAO,SAAS,KAAK,SAAS,WAAW,GAAG;CAEhD,MAAM,EAAE,MAAM,SAAS,YAAY,MAAM,UAAU;CACnD,IAAI,SAAS,UACX,OAAO,KAAK,WAAW,UAAU,MAAM,IAAI,GAAG;EAAE,UAAU;EAAS,mBAAmB;CAAK,CAAC;MAE5F,OAAO,KAAK,WAAW,MAAM,MAAM,IAAI,GAAG,EAAE,UAAU,QAAQ,CAAC;AAEnE;;AAGA,eAAe,OAAO,OAAgC;CACpD,MAAM,QAAQ,IAAI,YAAY,CAAC,CAAC,OAAO,KAAK;CAC5C,MAAM,SAAS,MAAM,OAAO,OAAO,OAAO,WAAW,KAAK;CAC1D,OAAO,MAAM,KAAK,IAAI,WAAW,MAAM,CAAC,CAAC,CACtC,KAAK,SAAS,KAAK,SAAS,EAAE,CAAC,CAAC,SAAS,GAAG,GAAG,CAAC,CAAC,CACjD,KAAK,EAAE;AACZ;;;;;;AAOA,SAAgB,cAAc,SAAiB;CAC7C,QAAQ,EAAE,SAAS,WAA6B;EAC9C,IAAI,OAAO,WAAW,eAAe,CAAC,OAAO,MAAM;GACjD,QAAQ,KAAK,+BAA+B;GAC5C;EACF;EAEA,MAAM,QAAQ,SAAS,MAAM,KAAK,CAAC,EAAE,KAAK,CAAC,CAAC,YAAY;EACxD,MAAM,UAAU,SAAS,MAAM,OAAO;EAEtC,MAAM,OAAiB;GACrB,SAAS,SAAS,SAAS,KAAK,CAAC,CAAC,YAAY;GAC9C,MAAM,SAAS,MAAM,KAAK,CAAC,CAAC,YAAY;GACxC,UAAU,SAAS;EACrB;EAEA,MAAM,QAAQ,WAA8B;GAC1C,OAAO,KAAK,QAAQ;IAAE;IAAS,MAAM,MAAM;KAAE,GAAG;KAAM,GAAG;IAAO,CAAC;GAAE,CAAC;EACtE;EAEA,QAAQ,IAAI,CAAC,QAAQ,OAAO,KAAK,IAAI,KAAA,GAAW,UAAU,OAAO,OAAO,IAAI,KAAA,CAAS,CAAC,CAAC,CACpF,MAAM,CAAC,cAAc,wBAAwB,KAAK;GAAE;GAAc;EAAmB,CAAC,CAAC,CAAC,CACxF,YAAY,KAAK,CAAC,CAAC,CAAC;CACzB;AACF"}
|
|
@@ -1,48 +1,28 @@
|
|
|
1
|
-
"
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
-
}
|
|
16
|
-
return to;
|
|
17
|
-
};
|
|
18
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
-
|
|
20
|
-
// src/third-parties/posthog.ts
|
|
21
|
-
var posthog_exports = {};
|
|
22
|
-
__export(posthog_exports, {
|
|
23
|
-
sendPosthogEvent: () => sendPosthogEvent,
|
|
24
|
-
setPosthogUser: () => setPosthogUser
|
|
25
|
-
});
|
|
26
|
-
module.exports = __toCommonJS(posthog_exports);
|
|
27
|
-
var import_posthog_js = require("posthog-js");
|
|
28
|
-
var import_field = require("../utils/field.cjs");
|
|
29
|
-
var metrics = ["CLS", "FCP", "FID", "INP", "LCP", "TTFB"];
|
|
1
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
|
+
const require_utils_field = require("../utils/field.cjs");
|
|
3
|
+
let posthog_js = require("posthog-js");
|
|
4
|
+
//#region src/third-parties/posthog.ts
|
|
5
|
+
const metrics = [
|
|
6
|
+
"CLS",
|
|
7
|
+
"FCP",
|
|
8
|
+
"FID",
|
|
9
|
+
"INP",
|
|
10
|
+
"LCP",
|
|
11
|
+
"TTFB"
|
|
12
|
+
];
|
|
30
13
|
function sendPosthogEvent(name, properties) {
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
import_posthog_js.posthog.reset();
|
|
37
|
-
}
|
|
14
|
+
if (metrics.includes(name)) return;
|
|
15
|
+
if (window.location.host.includes("127.0.0.1")) return;
|
|
16
|
+
if (window.location.host.includes("localhost")) return;
|
|
17
|
+
posthog_js.posthog.capture(name, properties);
|
|
18
|
+
if (name === "logout") posthog_js.posthog.reset();
|
|
38
19
|
}
|
|
39
20
|
function setPosthogUser({ user_id, distinct_id, data }) {
|
|
40
|
-
|
|
41
|
-
|
|
21
|
+
if (!distinct_id && !user_id) return;
|
|
22
|
+
posthog_js.posthog.identify(distinct_id ?? user_id, { email: require_utils_field.getFirst(data?.email) });
|
|
42
23
|
}
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
});
|
|
24
|
+
//#endregion
|
|
25
|
+
exports.sendPosthogEvent = sendPosthogEvent;
|
|
26
|
+
exports.setPosthogUser = setPosthogUser;
|
|
27
|
+
|
|
48
28
|
//# sourceMappingURL=posthog.cjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/third-parties/posthog.ts"],"sourcesContent":["import { posthog } from 'posthog-js';\nimport type { EventName, TrackName, TrackProperties } from '../track/types';\nimport { getFirst } from '../utils/field';\nimport type { UpdateVisitorDTO } from '../visitor/types';\n\nconst metrics = ['CLS', 'FCP', 'FID', 'INP', 'LCP', 'TTFB'];\n\nexport function sendPosthogEvent<T extends EventName>(\n name: TrackName<T>,\n properties?: TrackProperties<T>\n) {\n if (metrics.includes(name)) return;\n if (window.location.host.includes('127.0.0.1')) return;\n if (window.location.host.includes('localhost')) return;\n\n posthog.capture(name, properties);\n if (name === 'logout') {\n posthog.reset();\n }\n}\n\nexport function setPosthogUser({ user_id, distinct_id, data }: UpdateVisitorDTO) {\n if (!distinct_id && !user_id) return;\n posthog.identify(distinct_id ?? user_id, { email: getFirst(data?.email) });\n}\n"],"mappings":"
|
|
1
|
+
{"version":3,"file":"posthog.cjs","names":["getFirst"],"sources":["../../src/third-parties/posthog.ts"],"sourcesContent":["import { posthog } from 'posthog-js';\nimport type { EventName, TrackName, TrackProperties } from '../track/types';\nimport { getFirst } from '../utils/field';\nimport type { UpdateVisitorDTO } from '../visitor/types';\n\nconst metrics = ['CLS', 'FCP', 'FID', 'INP', 'LCP', 'TTFB'];\n\nexport function sendPosthogEvent<T extends EventName>(\n name: TrackName<T>,\n properties?: TrackProperties<T>\n) {\n if (metrics.includes(name)) return;\n if (window.location.host.includes('127.0.0.1')) return;\n if (window.location.host.includes('localhost')) return;\n\n posthog.capture(name, properties);\n if (name === 'logout') {\n posthog.reset();\n }\n}\n\nexport function setPosthogUser({ user_id, distinct_id, data }: UpdateVisitorDTO) {\n if (!distinct_id && !user_id) return;\n posthog.identify(distinct_id ?? user_id, { email: getFirst(data?.email) });\n}\n"],"mappings":";;;;AAKA,MAAM,UAAU;CAAC;CAAO;CAAO;CAAO;CAAO;CAAO;AAAM;AAE1D,SAAgB,iBACd,MACA,YACA;CACA,IAAI,QAAQ,SAAS,IAAI,GAAG;CAC5B,IAAI,OAAO,SAAS,KAAK,SAAS,WAAW,GAAG;CAChD,IAAI,OAAO,SAAS,KAAK,SAAS,WAAW,GAAG;CAEhD,WAAA,QAAQ,QAAQ,MAAM,UAAU;CAChC,IAAI,SAAS,UACX,WAAA,QAAQ,MAAM;AAElB;AAEA,SAAgB,eAAe,EAAE,SAAS,aAAa,QAA0B;CAC/E,IAAI,CAAC,eAAe,CAAC,SAAS;CAC9B,WAAA,QAAQ,SAAS,eAAe,SAAS,EAAE,OAAOA,oBAAAA,SAAS,MAAM,KAAK,EAAE,CAAC;AAC3E"}
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { EventName, TrackName, TrackProperties } from
|
|
2
|
-
import { UpdateVisitorDTO } from
|
|
3
|
-
|
|
4
|
-
|
|
1
|
+
import { EventName, TrackName, TrackProperties } from "../track/types.cjs";
|
|
2
|
+
import { UpdateVisitorDTO } from "../visitor/types.cjs";
|
|
3
|
+
//#region src/third-parties/posthog.d.ts
|
|
5
4
|
declare function sendPosthogEvent<T extends EventName>(name: TrackName<T>, properties?: TrackProperties<T>): void;
|
|
6
5
|
declare function setPosthogUser({ user_id, distinct_id, data }: UpdateVisitorDTO): void;
|
|
7
|
-
|
|
6
|
+
//#endregion
|
|
8
7
|
export { sendPosthogEvent, setPosthogUser };
|
|
8
|
+
//# sourceMappingURL=posthog.d.cts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"posthog.d.cts","names":[],"sources":["../../src/third-parties/posthog.ts"],"mappings":";;;iBAOgB,iBAAiB,UAAU,WACzC,MAAM,UAAU,IAChB,aAAa,gBAAgB;iBAYf,iBAAiB,SAAS,aAAa,QAAQ"}
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { EventName, TrackName, TrackProperties } from
|
|
2
|
-
import { UpdateVisitorDTO } from
|
|
3
|
-
|
|
4
|
-
|
|
1
|
+
import { EventName, TrackName, TrackProperties } from "../track/types.mjs";
|
|
2
|
+
import { UpdateVisitorDTO } from "../visitor/types.mjs";
|
|
3
|
+
//#region src/third-parties/posthog.d.ts
|
|
5
4
|
declare function sendPosthogEvent<T extends EventName>(name: TrackName<T>, properties?: TrackProperties<T>): void;
|
|
6
5
|
declare function setPosthogUser({ user_id, distinct_id, data }: UpdateVisitorDTO): void;
|
|
7
|
-
|
|
6
|
+
//#endregion
|
|
8
7
|
export { sendPosthogEvent, setPosthogUser };
|
|
8
|
+
//# sourceMappingURL=posthog.d.mts.map
|