@shware/analytics 15.0.1 → 16.1.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 +164 -36
- package/dist/native/fbsdk.cjs +44 -1
- package/dist/native/fbsdk.cjs.map +1 -1
- package/dist/native/fbsdk.d.cts +23 -1
- package/dist/native/fbsdk.d.cts.map +1 -1
- package/dist/native/fbsdk.d.mts +23 -1
- package/dist/native/fbsdk.d.mts.map +1 -1
- package/dist/native/fbsdk.mjs +44 -3
- package/dist/native/fbsdk.mjs.map +1 -1
- package/dist/native/firebase.cjs +27 -0
- package/dist/native/firebase.cjs.map +1 -1
- package/dist/native/firebase.d.cts +11 -0
- package/dist/native/firebase.d.cts.map +1 -1
- package/dist/native/firebase.d.mts +11 -0
- package/dist/native/firebase.d.mts.map +1 -1
- package/dist/native/firebase.mjs +27 -2
- package/dist/native/firebase.mjs.map +1 -1
- package/dist/next/index.cjs +10 -123
- package/dist/next/index.cjs.map +1 -1
- package/dist/next/index.d.cts +2 -31
- package/dist/next/index.d.cts.map +1 -1
- package/dist/next/index.d.mts +2 -31
- package/dist/next/index.d.mts.map +1 -1
- package/dist/next/index.mjs +10 -123
- package/dist/next/index.mjs.map +1 -1
- package/dist/react/index.cjs +45 -0
- package/dist/react/index.cjs.map +1 -0
- package/dist/react/index.d.cts +15 -0
- package/dist/react/index.d.cts.map +1 -0
- package/dist/react/index.d.mts +15 -0
- package/dist/react/index.d.mts.map +1 -0
- package/dist/react/index.mjs +43 -0
- package/dist/react/index.mjs.map +1 -0
- package/dist/react/use-feature-flag.cjs +23 -0
- package/dist/react/use-feature-flag.cjs.map +1 -0
- package/dist/react/use-feature-flag.d.cts +10 -0
- package/dist/react/use-feature-flag.d.cts.map +1 -0
- package/dist/react/use-feature-flag.d.mts +10 -0
- package/dist/react/use-feature-flag.d.mts.map +1 -0
- package/dist/react/use-feature-flag.mjs +22 -0
- package/dist/react/use-feature-flag.mjs.map +1 -0
- package/dist/server/conversions-api-error.cjs +20 -0
- package/dist/server/conversions-api-error.cjs.map +1 -0
- package/dist/server/conversions-api-error.d.cts +17 -0
- package/dist/server/conversions-api-error.d.cts.map +1 -0
- package/dist/server/conversions-api-error.d.mts +17 -0
- package/dist/server/conversions-api-error.d.mts.map +1 -0
- package/dist/server/conversions-api-error.mjs +19 -0
- package/dist/server/conversions-api-error.mjs.map +1 -0
- package/dist/server/google-data-manager.cjs +24 -26
- package/dist/server/google-data-manager.cjs.map +1 -1
- package/dist/server/google-data-manager.d.cts +13 -5
- package/dist/server/google-data-manager.d.cts.map +1 -1
- package/dist/server/google-data-manager.d.mts +13 -5
- package/dist/server/google-data-manager.d.mts.map +1 -1
- package/dist/server/google-data-manager.mjs +24 -27
- package/dist/server/google-data-manager.mjs.map +1 -1
- package/dist/server/index.cjs +11 -0
- package/dist/server/index.d.cts +10 -7
- package/dist/server/index.d.mts +10 -7
- package/dist/server/index.mjs +9 -7
- package/dist/server/linkedin-conversions-api.cjs +29 -23
- package/dist/server/linkedin-conversions-api.cjs.map +1 -1
- package/dist/server/linkedin-conversions-api.d.cts +7 -2
- package/dist/server/linkedin-conversions-api.d.cts.map +1 -1
- package/dist/server/linkedin-conversions-api.d.mts +7 -2
- package/dist/server/linkedin-conversions-api.d.mts.map +1 -1
- package/dist/server/linkedin-conversions-api.mjs +29 -24
- package/dist/server/linkedin-conversions-api.mjs.map +1 -1
- package/dist/server/meta-capi.cjs +32 -31
- package/dist/server/meta-capi.cjs.map +1 -1
- package/dist/server/meta-capi.d.cts +12 -3
- package/dist/server/meta-capi.d.cts.map +1 -1
- package/dist/server/meta-capi.d.mts +12 -3
- package/dist/server/meta-capi.d.mts.map +1 -1
- package/dist/server/meta-capi.mjs +33 -33
- package/dist/server/meta-capi.mjs.map +1 -1
- package/dist/server/microsoft-conversions-api.cjs +33 -28
- package/dist/server/microsoft-conversions-api.cjs.map +1 -1
- package/dist/server/microsoft-conversions-api.d.cts +14 -2
- package/dist/server/microsoft-conversions-api.d.cts.map +1 -1
- package/dist/server/microsoft-conversions-api.d.mts +14 -2
- package/dist/server/microsoft-conversions-api.d.mts.map +1 -1
- package/dist/server/microsoft-conversions-api.mjs +33 -29
- package/dist/server/microsoft-conversions-api.mjs.map +1 -1
- package/dist/server/openai-conversions-api.cjs +20 -18
- package/dist/server/openai-conversions-api.cjs.map +1 -1
- package/dist/server/openai-conversions-api.d.cts +7 -0
- package/dist/server/openai-conversions-api.d.cts.map +1 -1
- package/dist/server/openai-conversions-api.d.mts +7 -0
- package/dist/server/openai-conversions-api.d.mts.map +1 -1
- package/dist/server/openai-conversions-api.mjs +21 -20
- package/dist/server/openai-conversions-api.mjs.map +1 -1
- package/dist/server/reddit-conversions-api.cjs +20 -18
- package/dist/server/reddit-conversions-api.cjs.map +1 -1
- package/dist/server/reddit-conversions-api.d.cts +8 -1
- package/dist/server/reddit-conversions-api.d.cts.map +1 -1
- package/dist/server/reddit-conversions-api.d.mts +8 -1
- package/dist/server/reddit-conversions-api.d.mts.map +1 -1
- package/dist/server/reddit-conversions-api.mjs +21 -20
- package/dist/server/reddit-conversions-api.mjs.map +1 -1
- package/dist/server/setup-conversions.cjs +62 -0
- package/dist/server/setup-conversions.cjs.map +1 -0
- package/dist/server/setup-conversions.d.cts +97 -0
- package/dist/server/setup-conversions.d.cts.map +1 -0
- package/dist/server/setup-conversions.d.mts +97 -0
- package/dist/server/setup-conversions.d.mts.map +1 -0
- package/dist/server/setup-conversions.mjs +60 -0
- package/dist/server/setup-conversions.mjs.map +1 -0
- package/dist/setup/index.cjs +4 -4
- package/dist/setup/index.cjs.map +1 -1
- package/dist/setup/index.d.cts +16 -6
- package/dist/setup/index.d.cts.map +1 -1
- package/dist/setup/index.d.mts +16 -6
- package/dist/setup/index.d.mts.map +1 -1
- package/dist/setup/index.mjs +4 -4
- package/dist/setup/index.mjs.map +1 -1
- package/dist/tanstack/index.cjs +0 -2
- package/dist/tanstack/index.d.cts +1 -2
- package/dist/tanstack/index.d.mts +1 -2
- package/dist/tanstack/index.mjs +1 -3
- package/dist/third-parties/analytics-props.cjs +28 -0
- package/dist/third-parties/analytics-props.cjs.map +1 -0
- package/dist/third-parties/analytics-props.d.cts +23 -0
- package/dist/third-parties/analytics-props.d.cts.map +1 -0
- package/dist/third-parties/analytics-props.d.mts +23 -0
- package/dist/third-parties/analytics-props.d.mts.map +1 -0
- package/dist/third-parties/analytics-props.mjs +26 -0
- package/dist/third-parties/analytics-props.mjs.map +1 -0
- package/dist/third-parties/google-analytics.cjs +32 -0
- package/dist/third-parties/google-analytics.cjs.map +1 -1
- package/dist/third-parties/google-analytics.d.cts +11 -1
- package/dist/third-parties/google-analytics.d.cts.map +1 -1
- package/dist/third-parties/google-analytics.d.mts +11 -1
- package/dist/third-parties/google-analytics.d.mts.map +1 -1
- package/dist/third-parties/google-analytics.mjs +32 -1
- package/dist/third-parties/google-analytics.mjs.map +1 -1
- package/dist/third-parties/index.cjs +16 -0
- package/dist/third-parties/index.d.cts +9 -7
- package/dist/third-parties/index.d.mts +9 -7
- package/dist/third-parties/index.mjs +9 -7
- package/dist/third-parties/integration.cjs +46 -0
- package/dist/third-parties/integration.cjs.map +1 -0
- package/dist/third-parties/integration.d.cts +61 -0
- package/dist/third-parties/integration.d.cts.map +1 -0
- package/dist/third-parties/integration.d.mts +61 -0
- package/dist/third-parties/integration.d.mts.map +1 -0
- package/dist/third-parties/integration.mjs +43 -0
- package/dist/third-parties/integration.mjs.map +1 -0
- package/dist/third-parties/linkedin-insight-tag.cjs +29 -0
- package/dist/third-parties/linkedin-insight-tag.cjs.map +1 -1
- package/dist/third-parties/linkedin-insight-tag.d.cts +14 -8
- package/dist/third-parties/linkedin-insight-tag.d.cts.map +1 -1
- package/dist/third-parties/linkedin-insight-tag.d.mts +14 -8
- package/dist/third-parties/linkedin-insight-tag.d.mts.map +1 -1
- package/dist/third-parties/linkedin-insight-tag.mjs +29 -1
- package/dist/third-parties/linkedin-insight-tag.mjs.map +1 -1
- package/dist/third-parties/meta-pixel.cjs +32 -0
- package/dist/third-parties/meta-pixel.cjs.map +1 -1
- package/dist/third-parties/meta-pixel.d.cts +7 -0
- package/dist/third-parties/meta-pixel.d.cts.map +1 -1
- package/dist/third-parties/meta-pixel.d.mts +7 -0
- package/dist/third-parties/meta-pixel.d.mts.map +1 -1
- package/dist/third-parties/meta-pixel.mjs +33 -2
- package/dist/third-parties/meta-pixel.mjs.map +1 -1
- package/dist/third-parties/microsoft-uet.cjs +54 -0
- package/dist/third-parties/microsoft-uet.cjs.map +1 -1
- package/dist/third-parties/microsoft-uet.d.cts +36 -0
- package/dist/third-parties/microsoft-uet.d.cts.map +1 -1
- package/dist/third-parties/microsoft-uet.d.mts +36 -0
- package/dist/third-parties/microsoft-uet.d.mts.map +1 -1
- package/dist/third-parties/microsoft-uet.mjs +52 -1
- package/dist/third-parties/microsoft-uet.mjs.map +1 -1
- package/dist/third-parties/openai-pixel.cjs +29 -0
- package/dist/third-parties/openai-pixel.cjs.map +1 -1
- package/dist/third-parties/openai-pixel.d.cts +7 -0
- package/dist/third-parties/openai-pixel.d.cts.map +1 -1
- package/dist/third-parties/openai-pixel.d.mts +7 -0
- package/dist/third-parties/openai-pixel.d.mts.map +1 -1
- package/dist/third-parties/openai-pixel.mjs +30 -2
- package/dist/third-parties/openai-pixel.mjs.map +1 -1
- package/dist/third-parties/posthog.cjs +97 -4
- package/dist/third-parties/posthog.cjs.map +1 -1
- package/dist/third-parties/posthog.d.cts +56 -1
- package/dist/third-parties/posthog.d.cts.map +1 -1
- package/dist/third-parties/posthog.d.mts +56 -1
- package/dist/third-parties/posthog.d.mts.map +1 -1
- package/dist/third-parties/posthog.mjs +91 -2
- package/dist/third-parties/posthog.mjs.map +1 -1
- package/dist/third-parties/reddit-pixel.cjs +30 -0
- package/dist/third-parties/reddit-pixel.cjs.map +1 -1
- package/dist/third-parties/reddit-pixel.d.cts +7 -0
- package/dist/third-parties/reddit-pixel.d.cts.map +1 -1
- package/dist/third-parties/reddit-pixel.d.mts +7 -0
- package/dist/third-parties/reddit-pixel.d.mts.map +1 -1
- package/dist/third-parties/reddit-pixel.mjs +31 -2
- package/dist/third-parties/reddit-pixel.mjs.map +1 -1
- package/dist/track/fbq.cjs +6 -1
- package/dist/track/fbq.cjs.map +1 -1
- package/dist/track/fbq.d.cts +2 -0
- package/dist/track/fbq.d.cts.map +1 -1
- package/dist/track/fbq.d.mts +2 -0
- package/dist/track/fbq.d.mts.map +1 -1
- package/dist/track/fbq.mjs +6 -2
- package/dist/track/fbq.mjs.map +1 -1
- package/dist/track/index.cjs +7 -7
- package/dist/track/index.cjs.map +1 -1
- package/dist/track/index.d.cts.map +1 -1
- package/dist/track/index.d.mts.map +1 -1
- package/dist/track/index.mjs +7 -7
- package/dist/track/index.mjs.map +1 -1
- package/dist/track/oaiq.cjs +5 -0
- package/dist/track/oaiq.cjs.map +1 -1
- package/dist/track/oaiq.d.cts +2 -0
- package/dist/track/oaiq.d.cts.map +1 -1
- package/dist/track/oaiq.d.mts +2 -0
- package/dist/track/oaiq.d.mts.map +1 -1
- package/dist/track/oaiq.mjs +5 -1
- package/dist/track/oaiq.mjs.map +1 -1
- package/dist/track/rdt.cjs +5 -0
- package/dist/track/rdt.cjs.map +1 -1
- package/dist/track/rdt.d.cts +2 -0
- package/dist/track/rdt.d.cts.map +1 -1
- package/dist/track/rdt.d.mts +2 -0
- package/dist/track/rdt.d.mts.map +1 -1
- package/dist/track/rdt.mjs +5 -1
- package/dist/track/rdt.mjs.map +1 -1
- package/dist/visitor/index.cjs +3 -3
- package/dist/visitor/index.cjs.map +1 -1
- package/dist/visitor/index.mjs +3 -3
- package/dist/visitor/index.mjs.map +1 -1
- package/package.json +11 -39
- package/dist/react-router/index.cjs +0 -160
- package/dist/react-router/index.cjs.map +0 -1
- package/dist/react-router/index.d.cts +0 -22
- package/dist/react-router/index.d.cts.map +0 -1
- package/dist/react-router/index.d.mts +0 -22
- package/dist/react-router/index.d.mts.map +0 -1
- package/dist/react-router/index.mjs +0 -159
- package/dist/react-router/index.mjs.map +0 -1
- package/dist/server/legacy.cjs +0 -3
- package/dist/server/legacy.d.cts +0 -2
- package/dist/server/legacy.d.mts +0 -2
- package/dist/server/legacy.mjs +0 -1
- package/dist/server/meta-conversions-api.cjs +0 -205
- package/dist/server/meta-conversions-api.cjs.map +0 -1
- package/dist/server/meta-conversions-api.d.cts +0 -8
- package/dist/server/meta-conversions-api.d.cts.map +0 -1
- package/dist/server/meta-conversions-api.d.mts +0 -8
- package/dist/server/meta-conversions-api.d.mts.map +0 -1
- package/dist/server/meta-conversions-api.mjs +0 -201
- package/dist/server/meta-conversions-api.mjs.map +0 -1
- package/dist/tanstack/analytics.cjs +0 -184
- package/dist/tanstack/analytics.cjs.map +0 -1
- package/dist/tanstack/analytics.d.cts +0 -33
- package/dist/tanstack/analytics.d.cts.map +0 -1
- package/dist/tanstack/analytics.d.mts +0 -33
- package/dist/tanstack/analytics.d.mts.map +0 -1
- package/dist/tanstack/analytics.mjs +0 -183
- package/dist/tanstack/analytics.mjs.map +0 -1
|
@@ -1,6 +1,7 @@
|
|
|
1
|
-
import { Gtag } from "../track/gtag.mjs";
|
|
1
|
+
import { GaId, Gtag } from "../track/gtag.mjs";
|
|
2
2
|
import { EventName, TrackName, TrackProperties } from "../track/types.mjs";
|
|
3
3
|
import { UpdateVisitorDTO } from "../schema/index.mjs";
|
|
4
|
+
import { Integration } from "./integration.mjs";
|
|
4
5
|
declare global {
|
|
5
6
|
interface Window {
|
|
6
7
|
/** Undefined until the Google tag (gtag.js) script has loaded. */
|
|
@@ -9,4 +10,13 @@ declare global {
|
|
|
9
10
|
}
|
|
10
11
|
export declare function sendGAEvent<T extends EventName>(name: TrackName<T>, properties?: TrackProperties<T>): false | undefined;
|
|
11
12
|
export declare function setGAUser({ user_id, user_data }: UpdateVisitorDTO): void;
|
|
13
|
+
/**
|
|
14
|
+
* Google Analytics 4 (gtag.js): every event, for behavior analysis. `src` serves gtag.js from
|
|
15
|
+
* another path (a first-party proxy); `debug` turns on GA4's DebugView for this page.
|
|
16
|
+
*/
|
|
17
|
+
export declare function googleAnalytics(options: {
|
|
18
|
+
id: GaId;
|
|
19
|
+
src?: string;
|
|
20
|
+
debug?: boolean;
|
|
21
|
+
}): Integration;
|
|
12
22
|
//# sourceMappingURL=google-analytics.d.mts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"google-analytics.d.mts","names":[],"sources":["../../src/third-parties/google-analytics.ts"],"mappings":"
|
|
1
|
+
{"version":3,"file":"google-analytics.d.mts","names":[],"sources":["../../src/third-parties/google-analytics.ts"],"mappings":";;;;QAKQ;YACI;;IAER,OAAO;;;wBAIK,YAAY,UAAU,WACpC,MAAM,UAAU,IAChB,aAAa,gBAAgB;wBASf,YAAY,SAAS,aAAa;;;;;wBAelC,gBAAgB;EAAW,IAAI;EAAM;EAAc;IAAoB"}
|
|
@@ -14,6 +14,37 @@ function setGAUser({ user_id, user_data }) {
|
|
|
14
14
|
window.gtag("set", "user_id", user_id || null);
|
|
15
15
|
if (user_data) window.gtag("set", "user_data", user_data);
|
|
16
16
|
}
|
|
17
|
-
|
|
17
|
+
/**
|
|
18
|
+
* Google Analytics 4 (gtag.js): every event, for behavior analysis. `src` serves gtag.js from
|
|
19
|
+
* another path (a first-party proxy); `debug` turns on GA4's DebugView for this page.
|
|
20
|
+
*/
|
|
21
|
+
function googleAnalytics(options) {
|
|
22
|
+
const src = options.src ?? `https://www.googletagmanager.com/gtag/js?id=${options.id}`;
|
|
23
|
+
return {
|
|
24
|
+
type: "analytics",
|
|
25
|
+
track: sendGAEvent,
|
|
26
|
+
setUser: setGAUser,
|
|
27
|
+
script: {
|
|
28
|
+
id: "gtag",
|
|
29
|
+
inline: `
|
|
30
|
+
window.dataLayer = window.dataLayer || [];
|
|
31
|
+
function gtag(){dataLayer.push(arguments);}
|
|
32
|
+
gtag('js', new Date());
|
|
33
|
+
gtag('config', ${JSON.stringify(options.id)}${options.debug ? ", { debug_mode: true }" : ""});
|
|
34
|
+
(function (d, s, u) {
|
|
35
|
+
var j = d.createElement(s);
|
|
36
|
+
j.async = true;
|
|
37
|
+
// A script added here does not inherit the nonce: hand it this one's, or a CSP that
|
|
38
|
+
// allows scripts by nonce (without 'strict-dynamic') blocks gtag.js.
|
|
39
|
+
j.nonce = d.currentScript && d.currentScript.nonce;
|
|
40
|
+
j.src = u;
|
|
41
|
+
var f = d.getElementsByTagName(s)[0];
|
|
42
|
+
f.parentNode.insertBefore(j, f);
|
|
43
|
+
})(document, 'script', ${JSON.stringify(src)});
|
|
44
|
+
`
|
|
45
|
+
}
|
|
46
|
+
};
|
|
47
|
+
}
|
|
48
|
+
export { googleAnalytics, sendGAEvent, setGAUser };
|
|
18
49
|
|
|
19
50
|
//# sourceMappingURL=google-analytics.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"google-analytics.mjs","names":[],"sources":["../../src/third-parties/google-analytics.ts"],"sourcesContent":["import type { UpdateVisitorDTO } from '../schema/index';\nimport type { Gtag } from '../track/gtag';\nimport type { EventName, TrackName, TrackProperties } from '../track/types';\n\ndeclare global {\n interface Window {\n /** Undefined until the Google tag (gtag.js) script has loaded. */\n gtag?: Gtag['gtag'];\n }\n}\n\nexport function sendGAEvent<T extends EventName>(\n name: TrackName<T>,\n properties?: TrackProperties<T>\n) {\n if (typeof window === 'undefined' || !window.gtag) {\n console.warn('GA has not been initialized');\n return false;\n }\n window.gtag('event', name, properties);\n}\n\nexport function setGAUser({ user_id, user_data }: UpdateVisitorDTO) {\n if (typeof window === 'undefined' || !window.gtag) {\n console.warn('GA has not been initialized');\n return;\n }\n // No user is sign-out (`reset()`): GA keeps a set user_id for every later event on the page, so\n // it is cleared explicitly.\n window.gtag('set', 'user_id', user_id || null);\n if (user_data) window.gtag('set', 'user_data', user_data);\n}\n"],"mappings":";
|
|
1
|
+
{"version":3,"file":"google-analytics.mjs","names":[],"sources":["../../src/third-parties/google-analytics.ts"],"sourcesContent":["import type { UpdateVisitorDTO } from '../schema/index';\nimport type { GaId, Gtag } from '../track/gtag';\nimport type { EventName, TrackName, TrackProperties } from '../track/types';\nimport type { Integration } from './integration';\n\ndeclare global {\n interface Window {\n /** Undefined until the Google tag (gtag.js) script has loaded. */\n gtag?: Gtag['gtag'];\n }\n}\n\nexport function sendGAEvent<T extends EventName>(\n name: TrackName<T>,\n properties?: TrackProperties<T>\n) {\n if (typeof window === 'undefined' || !window.gtag) {\n console.warn('GA has not been initialized');\n return false;\n }\n window.gtag('event', name, properties);\n}\n\nexport function setGAUser({ user_id, user_data }: UpdateVisitorDTO) {\n if (typeof window === 'undefined' || !window.gtag) {\n console.warn('GA has not been initialized');\n return;\n }\n // No user is sign-out (`reset()`): GA keeps a set user_id for every later event on the page, so\n // it is cleared explicitly.\n window.gtag('set', 'user_id', user_id || null);\n if (user_data) window.gtag('set', 'user_data', user_data);\n}\n\n/**\n * Google Analytics 4 (gtag.js): every event, for behavior analysis. `src` serves gtag.js from\n * another path (a first-party proxy); `debug` turns on GA4's DebugView for this page.\n */\nexport function googleAnalytics(options: { id: GaId; src?: string; debug?: boolean }): Integration {\n const src = options.src ?? `https://www.googletagmanager.com/gtag/js?id=${options.id}`;\n return {\n type: 'analytics',\n track: sendGAEvent,\n setUser: setGAUser,\n script: {\n id: 'gtag',\n inline: `\n window.dataLayer = window.dataLayer || [];\n function gtag(){dataLayer.push(arguments);}\n gtag('js', new Date());\n gtag('config', ${JSON.stringify(options.id)}${options.debug ? ', { debug_mode: true }' : ''});\n (function (d, s, u) {\n var j = d.createElement(s);\n j.async = true;\n // A script added here does not inherit the nonce: hand it this one's, or a CSP that\n // allows scripts by nonce (without 'strict-dynamic') blocks gtag.js.\n j.nonce = d.currentScript && d.currentScript.nonce;\n j.src = u;\n var f = d.getElementsByTagName(s)[0];\n f.parentNode.insertBefore(j, f);\n })(document, 'script', ${JSON.stringify(src)});\n `,\n },\n };\n}\n"],"mappings":";AAYA,SAAgB,YACd,MACA,YACA;CACA,IAAI,OAAO,WAAW,eAAe,CAAC,OAAO,MAAM;EACjD,QAAQ,KAAK,6BAA6B;EAC1C,OAAO;CACT;CACA,OAAO,KAAK,SAAS,MAAM,UAAU;AACvC;AAEA,SAAgB,UAAU,EAAE,SAAS,aAA+B;CAClE,IAAI,OAAO,WAAW,eAAe,CAAC,OAAO,MAAM;EACjD,QAAQ,KAAK,6BAA6B;EAC1C;CACF;CAGA,OAAO,KAAK,OAAO,WAAW,WAAW,IAAI;CAC7C,IAAI,WAAW,OAAO,KAAK,OAAO,aAAa,SAAS;AAC1D;;;;;AAMA,SAAgB,gBAAgB,SAAmE;CACjG,MAAM,MAAM,QAAQ,OAAO,+CAA+C,QAAQ;CAClF,OAAO;EACL,MAAM;EACN,OAAO;EACP,SAAS;EACT,QAAQ;GACN,IAAI;GACJ,QAAQ;;;;yBAIW,KAAK,UAAU,QAAQ,EAAE,IAAI,QAAQ,QAAQ,2BAA2B,GAAG;;;;;;;;;;iCAUnE,KAAK,UAAU,GAAG,EAAE;;EAEjD;CACF;AACF"}
|
|
@@ -1,15 +1,29 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
|
+
const require_third_parties_integration = require("./integration.cjs");
|
|
2
3
|
const require_third_parties_microsoft_uet = require("./microsoft-uet.cjs");
|
|
4
|
+
const require_third_parties_posthog = require("./posthog.cjs");
|
|
3
5
|
const require_third_parties_google_analytics = require("./google-analytics.cjs");
|
|
4
6
|
const require_third_parties_meta_pixel = require("./meta-pixel.cjs");
|
|
5
7
|
const require_third_parties_linkedin_insight_tag = require("./linkedin-insight-tag.cjs");
|
|
6
8
|
const require_third_parties_openai_pixel = require("./openai-pixel.cjs");
|
|
7
9
|
const require_third_parties_reddit_pixel = require("./reddit-pixel.cjs");
|
|
10
|
+
exports.CONVERSION_EVENTS = require_third_parties_integration.CONVERSION_EVENTS;
|
|
8
11
|
exports.configureUET = require_third_parties_microsoft_uet.configureUET;
|
|
12
|
+
exports.getLoadedPosthog = require_third_parties_posthog.getLoadedPosthog;
|
|
13
|
+
exports.getPosthog = require_third_parties_posthog.getPosthog;
|
|
14
|
+
exports.googleAnalytics = require_third_parties_google_analytics.googleAnalytics;
|
|
15
|
+
exports.linkedInAds = require_third_parties_linkedin_insight_tag.linkedInAds;
|
|
16
|
+
exports.metaAds = require_third_parties_meta_pixel.metaAds;
|
|
17
|
+
exports.microsoftAds = require_third_parties_microsoft_uet.microsoftAds;
|
|
18
|
+
exports.openaiAds = require_third_parties_openai_pixel.openaiAds;
|
|
19
|
+
exports.posthogAnalytics = require_third_parties_posthog.posthogAnalytics;
|
|
20
|
+
exports.posthogFlagsReady = require_third_parties_posthog.posthogFlagsReady;
|
|
21
|
+
exports.redditAds = require_third_parties_reddit_pixel.redditAds;
|
|
9
22
|
exports.sendFBEvent = require_third_parties_meta_pixel.sendFBEvent;
|
|
10
23
|
exports.sendGAEvent = require_third_parties_google_analytics.sendGAEvent;
|
|
11
24
|
exports.sendLinkedinEvent = require_third_parties_linkedin_insight_tag.sendLinkedinEvent;
|
|
12
25
|
exports.sendOpenAIEvent = require_third_parties_openai_pixel.sendOpenAIEvent;
|
|
26
|
+
exports.sendPosthogEvent = require_third_parties_posthog.sendPosthogEvent;
|
|
13
27
|
exports.sendRedditEvent = require_third_parties_reddit_pixel.sendRedditEvent;
|
|
14
28
|
exports.sendUETEvent = require_third_parties_microsoft_uet.sendUETEvent;
|
|
15
29
|
exports.sendUETIdSync = require_third_parties_microsoft_uet.sendUETIdSync;
|
|
@@ -17,7 +31,9 @@ exports.setFBUser = require_third_parties_meta_pixel.setFBUser;
|
|
|
17
31
|
exports.setGAUser = require_third_parties_google_analytics.setGAUser;
|
|
18
32
|
exports.setLinkedinUser = require_third_parties_linkedin_insight_tag.setLinkedinUser;
|
|
19
33
|
exports.setOpenAIUser = require_third_parties_openai_pixel.setOpenAIUser;
|
|
34
|
+
exports.setPosthogUser = require_third_parties_posthog.setPosthogUser;
|
|
20
35
|
exports.setRedditUser = require_third_parties_reddit_pixel.setRedditUser;
|
|
21
36
|
exports.setUETConsent = require_third_parties_microsoft_uet.setUETConsent;
|
|
22
37
|
exports.setUETUser = require_third_parties_microsoft_uet.setUETUser;
|
|
23
38
|
exports.syncUETVisitor = require_third_parties_microsoft_uet.syncUETVisitor;
|
|
39
|
+
exports.uetCustomerIdOf = require_third_parties_microsoft_uet.uetCustomerIdOf;
|
|
@@ -1,8 +1,10 @@
|
|
|
1
|
+
import { AdsOptions, CONVERSION_EVENTS, Integration, IntegrationScript } from "./integration.cjs";
|
|
2
|
+
import { metaAds, sendFBEvent, setFBUser } from "./meta-pixel.cjs";
|
|
3
|
+
import { redditAds, sendRedditEvent, setRedditUser } from "./reddit-pixel.cjs";
|
|
4
|
+
import { LinkedinConversionConfig, linkedInAds, sendLinkedinEvent, setLinkedinUser } from "./linkedin-insight-tag.cjs";
|
|
5
|
+
import { openaiAds, sendOpenAIEvent, setOpenAIUser } from "./openai-pixel.cjs";
|
|
1
6
|
import { UETConsent, UETEventParams, UETItem, UETPageType, UETPid } from "../track/uetq.cjs";
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
|
|
6
|
-
import { sendRedditEvent, setRedditUser } from "./reddit-pixel.cjs";
|
|
7
|
-
import { configureUET, sendUETEvent, sendUETIdSync, setUETConsent, setUETUser, syncUETVisitor } from "./microsoft-uet.cjs";
|
|
8
|
-
export { type LinkedinConversionConfig, type UETConsent, type UETEventParams, type UETItem, type UETPageType, type UETPid, configureUET, sendFBEvent, sendGAEvent, sendLinkedinEvent, sendOpenAIEvent, sendRedditEvent, sendUETEvent, sendUETIdSync, setFBUser, setGAUser, setLinkedinUser, setOpenAIUser, setRedditUser, setUETConsent, setUETUser, syncUETVisitor };
|
|
7
|
+
import { MicrosoftAdsIntegration, configureUET, microsoftAds, sendUETEvent, sendUETIdSync, setUETConsent, setUETUser, syncUETVisitor, uetCustomerIdOf } from "./microsoft-uet.cjs";
|
|
8
|
+
import { googleAnalytics, sendGAEvent, setGAUser } from "./google-analytics.cjs";
|
|
9
|
+
import { PostHog, PostHogConfig, getLoadedPosthog, getPosthog, posthogAnalytics, posthogFlagsReady, sendPosthogEvent, setPosthogUser } from "./posthog.cjs";
|
|
10
|
+
export { type AdsOptions, CONVERSION_EVENTS, type Integration, type IntegrationScript, type LinkedinConversionConfig, type MicrosoftAdsIntegration, type PostHog, type PostHogConfig, type UETConsent, type UETEventParams, type UETItem, type UETPageType, type UETPid, configureUET, getLoadedPosthog, getPosthog, googleAnalytics, linkedInAds, metaAds, microsoftAds, openaiAds, posthogAnalytics, posthogFlagsReady, redditAds, sendFBEvent, sendGAEvent, sendLinkedinEvent, sendOpenAIEvent, sendPosthogEvent, sendRedditEvent, sendUETEvent, sendUETIdSync, setFBUser, setGAUser, setLinkedinUser, setOpenAIUser, setPosthogUser, setRedditUser, setUETConsent, setUETUser, syncUETVisitor, uetCustomerIdOf };
|
|
@@ -1,8 +1,10 @@
|
|
|
1
|
+
import { AdsOptions, CONVERSION_EVENTS, Integration, IntegrationScript } from "./integration.mjs";
|
|
2
|
+
import { metaAds, sendFBEvent, setFBUser } from "./meta-pixel.mjs";
|
|
3
|
+
import { redditAds, sendRedditEvent, setRedditUser } from "./reddit-pixel.mjs";
|
|
4
|
+
import { LinkedinConversionConfig, linkedInAds, sendLinkedinEvent, setLinkedinUser } from "./linkedin-insight-tag.mjs";
|
|
5
|
+
import { openaiAds, sendOpenAIEvent, setOpenAIUser } from "./openai-pixel.mjs";
|
|
1
6
|
import { UETConsent, UETEventParams, UETItem, UETPageType, UETPid } from "../track/uetq.mjs";
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
|
|
6
|
-
import { sendRedditEvent, setRedditUser } from "./reddit-pixel.mjs";
|
|
7
|
-
import { configureUET, sendUETEvent, sendUETIdSync, setUETConsent, setUETUser, syncUETVisitor } from "./microsoft-uet.mjs";
|
|
8
|
-
export { type LinkedinConversionConfig, type UETConsent, type UETEventParams, type UETItem, type UETPageType, type UETPid, configureUET, sendFBEvent, sendGAEvent, sendLinkedinEvent, sendOpenAIEvent, sendRedditEvent, sendUETEvent, sendUETIdSync, setFBUser, setGAUser, setLinkedinUser, setOpenAIUser, setRedditUser, setUETConsent, setUETUser, syncUETVisitor };
|
|
7
|
+
import { MicrosoftAdsIntegration, configureUET, microsoftAds, sendUETEvent, sendUETIdSync, setUETConsent, setUETUser, syncUETVisitor, uetCustomerIdOf } from "./microsoft-uet.mjs";
|
|
8
|
+
import { googleAnalytics, sendGAEvent, setGAUser } from "./google-analytics.mjs";
|
|
9
|
+
import { PostHog, PostHogConfig, getLoadedPosthog, getPosthog, posthogAnalytics, posthogFlagsReady, sendPosthogEvent, setPosthogUser } from "./posthog.mjs";
|
|
10
|
+
export { type AdsOptions, CONVERSION_EVENTS, type Integration, type IntegrationScript, type LinkedinConversionConfig, type MicrosoftAdsIntegration, type PostHog, type PostHogConfig, type UETConsent, type UETEventParams, type UETItem, type UETPageType, type UETPid, configureUET, getLoadedPosthog, getPosthog, googleAnalytics, linkedInAds, metaAds, microsoftAds, openaiAds, posthogAnalytics, posthogFlagsReady, redditAds, sendFBEvent, sendGAEvent, sendLinkedinEvent, sendOpenAIEvent, sendPosthogEvent, sendRedditEvent, sendUETEvent, sendUETIdSync, setFBUser, setGAUser, setLinkedinUser, setOpenAIUser, setPosthogUser, setRedditUser, setUETConsent, setUETUser, syncUETVisitor, uetCustomerIdOf };
|
|
@@ -1,7 +1,9 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
|
|
1
|
+
import { CONVERSION_EVENTS } from "./integration.mjs";
|
|
2
|
+
import { configureUET, microsoftAds, sendUETEvent, sendUETIdSync, setUETConsent, setUETUser, syncUETVisitor, uetCustomerIdOf } from "./microsoft-uet.mjs";
|
|
3
|
+
import { getLoadedPosthog, getPosthog, posthogAnalytics, posthogFlagsReady, sendPosthogEvent, setPosthogUser } from "./posthog.mjs";
|
|
4
|
+
import { googleAnalytics, sendGAEvent, setGAUser } from "./google-analytics.mjs";
|
|
5
|
+
import { metaAds, sendFBEvent, setFBUser } from "./meta-pixel.mjs";
|
|
6
|
+
import { linkedInAds, sendLinkedinEvent, setLinkedinUser } from "./linkedin-insight-tag.mjs";
|
|
7
|
+
import { openaiAds, sendOpenAIEvent, setOpenAIUser } from "./openai-pixel.mjs";
|
|
8
|
+
import { redditAds, sendRedditEvent, setRedditUser } from "./reddit-pixel.mjs";
|
|
9
|
+
export { CONVERSION_EVENTS, configureUET, getLoadedPosthog, getPosthog, googleAnalytics, linkedInAds, metaAds, microsoftAds, openaiAds, posthogAnalytics, posthogFlagsReady, redditAds, sendFBEvent, sendGAEvent, sendLinkedinEvent, sendOpenAIEvent, sendPosthogEvent, sendRedditEvent, sendUETEvent, sendUETIdSync, setFBUser, setGAUser, setLinkedinUser, setOpenAIUser, setPosthogUser, setRedditUser, setUETConsent, setUETUser, syncUETVisitor, uetCustomerIdOf };
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
|
+
// src/third-parties/integration.ts
|
|
3
|
+
/**
|
|
4
|
+
* The GA4 recommended events that are conversions or close to one, for an ad platform with no
|
|
5
|
+
* standard events of its own to map to (Microsoft UET), so it is not sent the whole product.
|
|
6
|
+
*/
|
|
7
|
+
const CONVERSION_EVENTS = [
|
|
8
|
+
"sign_up",
|
|
9
|
+
"login",
|
|
10
|
+
"generate_lead",
|
|
11
|
+
"view_item",
|
|
12
|
+
"add_to_cart",
|
|
13
|
+
"add_to_wishlist",
|
|
14
|
+
"begin_checkout",
|
|
15
|
+
"add_payment_info",
|
|
16
|
+
"purchase",
|
|
17
|
+
"subscribe",
|
|
18
|
+
"trial_begin",
|
|
19
|
+
"search",
|
|
20
|
+
"schedule",
|
|
21
|
+
"submit_application",
|
|
22
|
+
"contact"
|
|
23
|
+
];
|
|
24
|
+
/**
|
|
25
|
+
* Which events an ad platform receives: what `isStandard` accepts — the events its mapper turns
|
|
26
|
+
* into one of its standard events — and the custom events the host listed. Everything else in the
|
|
27
|
+
* product (feature use, clicks, onboarding steps) is behavior analysis, which is GA4's and
|
|
28
|
+
* PostHog's job, and only noise to an ad platform's optimization. The same rule picks what the
|
|
29
|
+
* browser tag and the platform's conversions API send (`@shware/analytics/server`), so the two
|
|
30
|
+
* report the same events.
|
|
31
|
+
*/
|
|
32
|
+
function adEvents(isStandard, customEvents = []) {
|
|
33
|
+
return (name) => isStandard(name) || customEvents.includes(name);
|
|
34
|
+
}
|
|
35
|
+
/** An ad tracker that sends only the events `accepts` lets through (`adEvents`). */
|
|
36
|
+
function adsTracker(send, accepts) {
|
|
37
|
+
return (name, properties, eventId) => {
|
|
38
|
+
if (!accepts(name)) return;
|
|
39
|
+
return send(name, properties, eventId);
|
|
40
|
+
};
|
|
41
|
+
}
|
|
42
|
+
exports.CONVERSION_EVENTS = CONVERSION_EVENTS;
|
|
43
|
+
exports.adEvents = adEvents;
|
|
44
|
+
exports.adsTracker = adsTracker;
|
|
45
|
+
|
|
46
|
+
//# sourceMappingURL=integration.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"integration.cjs","names":[],"sources":["../../src/third-parties/integration.ts"],"sourcesContent":["import type { EventName, ThirdPartyTracker, TrackName } from '../track/types';\nimport type { ThirdPartyUserSetter } from '../visitor/types';\n\n/**\n * The one script an integration puts on the page, rendered by `<Analytics integrations>`\n * (react, next) with the request's `nonce`: an inline snippet that loads the\n * vendor's own script from its host, as every vendor's official snippet does.\n */\nexport interface IntegrationScript {\n /** The element id; also its React key, and how a test or a CSP report finds it. */\n readonly id: string;\n readonly inline: string;\n /** `next/script`'s loading strategy, `afterInteractive` by default; the other frameworks ignore it. */\n readonly strategy?: 'beforeInteractive' | 'afterInteractive' | 'lazyOnload';\n}\n\n/**\n * One third party, configured in one place: how events reach it, how it learns the signed-in\n * user, and the script it needs. Built by the factories in `@shware/analytics/third-parties`\n * (`googleAnalytics`, `metaAds`, …) and handed to both `setupAnalytics({ integrations })` and\n * `<Analytics integrations>`. A host can write its own for a platform the SDK does not cover.\n *\n * `type` says what the platform is for. An `analytics` integration (GA4, PostHog) receives every\n * event, for behavior analysis. An `ads` integration receives only what helps an ad platform\n * optimize and build audiences — the conversion events it maps to its own standard events, plus\n * the custom events it was explicitly given — and filters in its own `track`.\n */\nexport interface Integration {\n readonly type: 'analytics' | 'ads';\n readonly track: ThirdPartyTracker;\n readonly setUser?: ThirdPartyUserSetter;\n readonly script?: IntegrationScript;\n /**\n * Origins `<Analytics>` preconnects to (`react-dom`'s `preconnect`), so the connection is up\n * before the script asks for something there — e.g. where a snippet loads its library from.\n */\n readonly preconnect?: readonly string[];\n}\n\n/**\n * The GA4 recommended events that are conversions or close to one, for an ad platform with no\n * standard events of its own to map to (Microsoft UET), so it is not sent the whole product.\n */\nexport const CONVERSION_EVENTS = [\n 'sign_up',\n 'login',\n 'generate_lead',\n 'view_item',\n 'add_to_cart',\n 'add_to_wishlist',\n 'begin_checkout',\n 'add_payment_info',\n 'purchase',\n 'subscribe',\n 'trial_begin',\n 'search',\n 'schedule',\n 'submit_application',\n 'contact',\n] as const satisfies readonly EventName[];\n\nexport interface AdsOptions {\n /**\n * Custom events this platform receives besides the conversions it maps to its standard\n * events, e.g. one used as an optimization goal or for an audience. Everything else is not\n * sent to it. The names `track` accepts, so with strict event names a typo is a compile error.\n */\n customEvents?: readonly TrackName[];\n}\n\n/**\n * Which events an ad platform receives: what `isStandard` accepts — the events its mapper turns\n * into one of its standard events — and the custom events the host listed. Everything else in the\n * product (feature use, clicks, onboarding steps) is behavior analysis, which is GA4's and\n * PostHog's job, and only noise to an ad platform's optimization. The same rule picks what the\n * browser tag and the platform's conversions API send (`@shware/analytics/server`), so the two\n * report the same events.\n */\nexport function adEvents(\n isStandard: (name: string) => boolean,\n customEvents: readonly string[] = []\n): (name: string) => boolean {\n return (name) => isStandard(name) || customEvents.includes(name);\n}\n\n/** An ad tracker that sends only the events `accepts` lets through (`adEvents`). */\nexport function adsTracker(\n send: ThirdPartyTracker,\n accepts: (name: string) => boolean\n): ThirdPartyTracker {\n return (name, properties, eventId) => {\n if (!accepts(name)) return;\n return send(name, properties, eventId);\n };\n}\n"],"mappings":";;;;;;AA2CA,MAAa,oBAAoB;CAC/B;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;AACF;;;;;;;;;AAmBA,SAAgB,SACd,YACA,eAAkC,CAAC,GACR;CAC3B,QAAQ,SAAS,WAAW,IAAI,KAAK,aAAa,SAAS,IAAI;AACjE;;AAGA,SAAgB,WACd,MACA,SACmB;CACnB,QAAQ,MAAM,YAAY,YAAY;EACpC,IAAI,CAAC,QAAQ,IAAI,GAAG;EACpB,OAAO,KAAK,MAAM,YAAY,OAAO;CACvC;AACF"}
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
import { ThirdPartyTracker, TrackName } from "../track/types.cjs";
|
|
2
|
+
import { ThirdPartyUserSetter } from "../visitor/types.cjs";
|
|
3
|
+
/**
|
|
4
|
+
* The one script an integration puts on the page, rendered by `<Analytics integrations>`
|
|
5
|
+
* (react, next) with the request's `nonce`: an inline snippet that loads the
|
|
6
|
+
* vendor's own script from its host, as every vendor's official snippet does.
|
|
7
|
+
*/
|
|
8
|
+
export interface IntegrationScript {
|
|
9
|
+
/** The element id; also its React key, and how a test or a CSP report finds it. */
|
|
10
|
+
readonly id: string;
|
|
11
|
+
readonly inline: string;
|
|
12
|
+
/** `next/script`'s loading strategy, `afterInteractive` by default; the other frameworks ignore it. */
|
|
13
|
+
readonly strategy?: 'beforeInteractive' | 'afterInteractive' | 'lazyOnload';
|
|
14
|
+
}
|
|
15
|
+
/**
|
|
16
|
+
* One third party, configured in one place: how events reach it, how it learns the signed-in
|
|
17
|
+
* user, and the script it needs. Built by the factories in `@shware/analytics/third-parties`
|
|
18
|
+
* (`googleAnalytics`, `metaAds`, …) and handed to both `setupAnalytics({ integrations })` and
|
|
19
|
+
* `<Analytics integrations>`. A host can write its own for a platform the SDK does not cover.
|
|
20
|
+
*
|
|
21
|
+
* `type` says what the platform is for. An `analytics` integration (GA4, PostHog) receives every
|
|
22
|
+
* event, for behavior analysis. An `ads` integration receives only what helps an ad platform
|
|
23
|
+
* optimize and build audiences — the conversion events it maps to its own standard events, plus
|
|
24
|
+
* the custom events it was explicitly given — and filters in its own `track`.
|
|
25
|
+
*/
|
|
26
|
+
export interface Integration {
|
|
27
|
+
readonly type: 'analytics' | 'ads';
|
|
28
|
+
readonly track: ThirdPartyTracker;
|
|
29
|
+
readonly setUser?: ThirdPartyUserSetter;
|
|
30
|
+
readonly script?: IntegrationScript;
|
|
31
|
+
/**
|
|
32
|
+
* Origins `<Analytics>` preconnects to (`react-dom`'s `preconnect`), so the connection is up
|
|
33
|
+
* before the script asks for something there — e.g. where a snippet loads its library from.
|
|
34
|
+
*/
|
|
35
|
+
readonly preconnect?: readonly string[];
|
|
36
|
+
}
|
|
37
|
+
/**
|
|
38
|
+
* The GA4 recommended events that are conversions or close to one, for an ad platform with no
|
|
39
|
+
* standard events of its own to map to (Microsoft UET), so it is not sent the whole product.
|
|
40
|
+
*/
|
|
41
|
+
export declare const CONVERSION_EVENTS: readonly ["sign_up", "login", "generate_lead", "view_item", "add_to_cart", "add_to_wishlist", "begin_checkout", "add_payment_info", "purchase", "subscribe", "trial_begin", "search", "schedule", "submit_application", "contact"];
|
|
42
|
+
export interface AdsOptions {
|
|
43
|
+
/**
|
|
44
|
+
* Custom events this platform receives besides the conversions it maps to its standard
|
|
45
|
+
* events, e.g. one used as an optimization goal or for an audience. Everything else is not
|
|
46
|
+
* sent to it. The names `track` accepts, so with strict event names a typo is a compile error.
|
|
47
|
+
*/
|
|
48
|
+
customEvents?: readonly TrackName[];
|
|
49
|
+
}
|
|
50
|
+
/**
|
|
51
|
+
* Which events an ad platform receives: what `isStandard` accepts — the events its mapper turns
|
|
52
|
+
* into one of its standard events — and the custom events the host listed. Everything else in the
|
|
53
|
+
* product (feature use, clicks, onboarding steps) is behavior analysis, which is GA4's and
|
|
54
|
+
* PostHog's job, and only noise to an ad platform's optimization. The same rule picks what the
|
|
55
|
+
* browser tag and the platform's conversions API send (`@shware/analytics/server`), so the two
|
|
56
|
+
* report the same events.
|
|
57
|
+
*/
|
|
58
|
+
export declare function adEvents(isStandard: (name: string) => boolean, customEvents?: readonly string[]): (name: string) => boolean;
|
|
59
|
+
/** An ad tracker that sends only the events `accepts` lets through (`adEvents`). */
|
|
60
|
+
export declare function adsTracker(send: ThirdPartyTracker, accepts: (name: string) => boolean): ThirdPartyTracker;
|
|
61
|
+
//# sourceMappingURL=integration.d.cts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"integration.d.cts","names":[],"sources":["../../src/third-parties/integration.ts"],"mappings":";;;;;;;iBAQiB;;WAEN;WACA;;WAEA;;;;;;;;;;;;;iBAcM;WACN;WACA,OAAO;WACP,UAAU;WACV,SAAS;;;;;WAKT;;;;;;qBAOE;iBAkBI;;;;;;EAMf,wBAAwB;;;;;;;;;;wBAWV,SACd,aAAa,0BACb,oCACE;;wBAKY,WACd,MAAM,mBACN,UAAU,2BACT"}
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
import { ThirdPartyTracker, TrackName } from "../track/types.mjs";
|
|
2
|
+
import { ThirdPartyUserSetter } from "../visitor/types.mjs";
|
|
3
|
+
/**
|
|
4
|
+
* The one script an integration puts on the page, rendered by `<Analytics integrations>`
|
|
5
|
+
* (react, next) with the request's `nonce`: an inline snippet that loads the
|
|
6
|
+
* vendor's own script from its host, as every vendor's official snippet does.
|
|
7
|
+
*/
|
|
8
|
+
export interface IntegrationScript {
|
|
9
|
+
/** The element id; also its React key, and how a test or a CSP report finds it. */
|
|
10
|
+
readonly id: string;
|
|
11
|
+
readonly inline: string;
|
|
12
|
+
/** `next/script`'s loading strategy, `afterInteractive` by default; the other frameworks ignore it. */
|
|
13
|
+
readonly strategy?: 'beforeInteractive' | 'afterInteractive' | 'lazyOnload';
|
|
14
|
+
}
|
|
15
|
+
/**
|
|
16
|
+
* One third party, configured in one place: how events reach it, how it learns the signed-in
|
|
17
|
+
* user, and the script it needs. Built by the factories in `@shware/analytics/third-parties`
|
|
18
|
+
* (`googleAnalytics`, `metaAds`, …) and handed to both `setupAnalytics({ integrations })` and
|
|
19
|
+
* `<Analytics integrations>`. A host can write its own for a platform the SDK does not cover.
|
|
20
|
+
*
|
|
21
|
+
* `type` says what the platform is for. An `analytics` integration (GA4, PostHog) receives every
|
|
22
|
+
* event, for behavior analysis. An `ads` integration receives only what helps an ad platform
|
|
23
|
+
* optimize and build audiences — the conversion events it maps to its own standard events, plus
|
|
24
|
+
* the custom events it was explicitly given — and filters in its own `track`.
|
|
25
|
+
*/
|
|
26
|
+
export interface Integration {
|
|
27
|
+
readonly type: 'analytics' | 'ads';
|
|
28
|
+
readonly track: ThirdPartyTracker;
|
|
29
|
+
readonly setUser?: ThirdPartyUserSetter;
|
|
30
|
+
readonly script?: IntegrationScript;
|
|
31
|
+
/**
|
|
32
|
+
* Origins `<Analytics>` preconnects to (`react-dom`'s `preconnect`), so the connection is up
|
|
33
|
+
* before the script asks for something there — e.g. where a snippet loads its library from.
|
|
34
|
+
*/
|
|
35
|
+
readonly preconnect?: readonly string[];
|
|
36
|
+
}
|
|
37
|
+
/**
|
|
38
|
+
* The GA4 recommended events that are conversions or close to one, for an ad platform with no
|
|
39
|
+
* standard events of its own to map to (Microsoft UET), so it is not sent the whole product.
|
|
40
|
+
*/
|
|
41
|
+
export declare const CONVERSION_EVENTS: readonly ["sign_up", "login", "generate_lead", "view_item", "add_to_cart", "add_to_wishlist", "begin_checkout", "add_payment_info", "purchase", "subscribe", "trial_begin", "search", "schedule", "submit_application", "contact"];
|
|
42
|
+
export interface AdsOptions {
|
|
43
|
+
/**
|
|
44
|
+
* Custom events this platform receives besides the conversions it maps to its standard
|
|
45
|
+
* events, e.g. one used as an optimization goal or for an audience. Everything else is not
|
|
46
|
+
* sent to it. The names `track` accepts, so with strict event names a typo is a compile error.
|
|
47
|
+
*/
|
|
48
|
+
customEvents?: readonly TrackName[];
|
|
49
|
+
}
|
|
50
|
+
/**
|
|
51
|
+
* Which events an ad platform receives: what `isStandard` accepts — the events its mapper turns
|
|
52
|
+
* into one of its standard events — and the custom events the host listed. Everything else in the
|
|
53
|
+
* product (feature use, clicks, onboarding steps) is behavior analysis, which is GA4's and
|
|
54
|
+
* PostHog's job, and only noise to an ad platform's optimization. The same rule picks what the
|
|
55
|
+
* browser tag and the platform's conversions API send (`@shware/analytics/server`), so the two
|
|
56
|
+
* report the same events.
|
|
57
|
+
*/
|
|
58
|
+
export declare function adEvents(isStandard: (name: string) => boolean, customEvents?: readonly string[]): (name: string) => boolean;
|
|
59
|
+
/** An ad tracker that sends only the events `accepts` lets through (`adEvents`). */
|
|
60
|
+
export declare function adsTracker(send: ThirdPartyTracker, accepts: (name: string) => boolean): ThirdPartyTracker;
|
|
61
|
+
//# sourceMappingURL=integration.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"integration.d.mts","names":[],"sources":["../../src/third-parties/integration.ts"],"mappings":";;;;;;;iBAQiB;;WAEN;WACA;;WAEA;;;;;;;;;;;;;iBAcM;WACN;WACA,OAAO;WACP,UAAU;WACV,SAAS;;;;;WAKT;;;;;;qBAOE;iBAkBI;;;;;;EAMf,wBAAwB;;;;;;;;;;wBAWV,SACd,aAAa,0BACb,oCACE;;wBAKY,WACd,MAAM,mBACN,UAAU,2BACT"}
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
// src/third-parties/integration.ts
|
|
2
|
+
/**
|
|
3
|
+
* The GA4 recommended events that are conversions or close to one, for an ad platform with no
|
|
4
|
+
* standard events of its own to map to (Microsoft UET), so it is not sent the whole product.
|
|
5
|
+
*/
|
|
6
|
+
const CONVERSION_EVENTS = [
|
|
7
|
+
"sign_up",
|
|
8
|
+
"login",
|
|
9
|
+
"generate_lead",
|
|
10
|
+
"view_item",
|
|
11
|
+
"add_to_cart",
|
|
12
|
+
"add_to_wishlist",
|
|
13
|
+
"begin_checkout",
|
|
14
|
+
"add_payment_info",
|
|
15
|
+
"purchase",
|
|
16
|
+
"subscribe",
|
|
17
|
+
"trial_begin",
|
|
18
|
+
"search",
|
|
19
|
+
"schedule",
|
|
20
|
+
"submit_application",
|
|
21
|
+
"contact"
|
|
22
|
+
];
|
|
23
|
+
/**
|
|
24
|
+
* Which events an ad platform receives: what `isStandard` accepts — the events its mapper turns
|
|
25
|
+
* into one of its standard events — and the custom events the host listed. Everything else in the
|
|
26
|
+
* product (feature use, clicks, onboarding steps) is behavior analysis, which is GA4's and
|
|
27
|
+
* PostHog's job, and only noise to an ad platform's optimization. The same rule picks what the
|
|
28
|
+
* browser tag and the platform's conversions API send (`@shware/analytics/server`), so the two
|
|
29
|
+
* report the same events.
|
|
30
|
+
*/
|
|
31
|
+
function adEvents(isStandard, customEvents = []) {
|
|
32
|
+
return (name) => isStandard(name) || customEvents.includes(name);
|
|
33
|
+
}
|
|
34
|
+
/** An ad tracker that sends only the events `accepts` lets through (`adEvents`). */
|
|
35
|
+
function adsTracker(send, accepts) {
|
|
36
|
+
return (name, properties, eventId) => {
|
|
37
|
+
if (!accepts(name)) return;
|
|
38
|
+
return send(name, properties, eventId);
|
|
39
|
+
};
|
|
40
|
+
}
|
|
41
|
+
export { CONVERSION_EVENTS, adEvents, adsTracker };
|
|
42
|
+
|
|
43
|
+
//# sourceMappingURL=integration.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"integration.mjs","names":[],"sources":["../../src/third-parties/integration.ts"],"sourcesContent":["import type { EventName, ThirdPartyTracker, TrackName } from '../track/types';\nimport type { ThirdPartyUserSetter } from '../visitor/types';\n\n/**\n * The one script an integration puts on the page, rendered by `<Analytics integrations>`\n * (react, next) with the request's `nonce`: an inline snippet that loads the\n * vendor's own script from its host, as every vendor's official snippet does.\n */\nexport interface IntegrationScript {\n /** The element id; also its React key, and how a test or a CSP report finds it. */\n readonly id: string;\n readonly inline: string;\n /** `next/script`'s loading strategy, `afterInteractive` by default; the other frameworks ignore it. */\n readonly strategy?: 'beforeInteractive' | 'afterInteractive' | 'lazyOnload';\n}\n\n/**\n * One third party, configured in one place: how events reach it, how it learns the signed-in\n * user, and the script it needs. Built by the factories in `@shware/analytics/third-parties`\n * (`googleAnalytics`, `metaAds`, …) and handed to both `setupAnalytics({ integrations })` and\n * `<Analytics integrations>`. A host can write its own for a platform the SDK does not cover.\n *\n * `type` says what the platform is for. An `analytics` integration (GA4, PostHog) receives every\n * event, for behavior analysis. An `ads` integration receives only what helps an ad platform\n * optimize and build audiences — the conversion events it maps to its own standard events, plus\n * the custom events it was explicitly given — and filters in its own `track`.\n */\nexport interface Integration {\n readonly type: 'analytics' | 'ads';\n readonly track: ThirdPartyTracker;\n readonly setUser?: ThirdPartyUserSetter;\n readonly script?: IntegrationScript;\n /**\n * Origins `<Analytics>` preconnects to (`react-dom`'s `preconnect`), so the connection is up\n * before the script asks for something there — e.g. where a snippet loads its library from.\n */\n readonly preconnect?: readonly string[];\n}\n\n/**\n * The GA4 recommended events that are conversions or close to one, for an ad platform with no\n * standard events of its own to map to (Microsoft UET), so it is not sent the whole product.\n */\nexport const CONVERSION_EVENTS = [\n 'sign_up',\n 'login',\n 'generate_lead',\n 'view_item',\n 'add_to_cart',\n 'add_to_wishlist',\n 'begin_checkout',\n 'add_payment_info',\n 'purchase',\n 'subscribe',\n 'trial_begin',\n 'search',\n 'schedule',\n 'submit_application',\n 'contact',\n] as const satisfies readonly EventName[];\n\nexport interface AdsOptions {\n /**\n * Custom events this platform receives besides the conversions it maps to its standard\n * events, e.g. one used as an optimization goal or for an audience. Everything else is not\n * sent to it. The names `track` accepts, so with strict event names a typo is a compile error.\n */\n customEvents?: readonly TrackName[];\n}\n\n/**\n * Which events an ad platform receives: what `isStandard` accepts — the events its mapper turns\n * into one of its standard events — and the custom events the host listed. Everything else in the\n * product (feature use, clicks, onboarding steps) is behavior analysis, which is GA4's and\n * PostHog's job, and only noise to an ad platform's optimization. The same rule picks what the\n * browser tag and the platform's conversions API send (`@shware/analytics/server`), so the two\n * report the same events.\n */\nexport function adEvents(\n isStandard: (name: string) => boolean,\n customEvents: readonly string[] = []\n): (name: string) => boolean {\n return (name) => isStandard(name) || customEvents.includes(name);\n}\n\n/** An ad tracker that sends only the events `accepts` lets through (`adEvents`). */\nexport function adsTracker(\n send: ThirdPartyTracker,\n accepts: (name: string) => boolean\n): ThirdPartyTracker {\n return (name, properties, eventId) => {\n if (!accepts(name)) return;\n return send(name, properties, eventId);\n };\n}\n"],"mappings":";;;;;AA2CA,MAAa,oBAAoB;CAC/B;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;AACF;;;;;;;;;AAmBA,SAAgB,SACd,YACA,eAAkC,CAAC,GACR;CAC3B,QAAQ,SAAS,WAAW,IAAI,KAAK,aAAa,SAAS,IAAI;AACjE;;AAGA,SAAgB,WACd,MACA,SACmB;CACnB,QAAQ,MAAM,YAAY,YAAY;EACpC,IAAI,CAAC,QAAQ,IAAI,GAAG;EACpB,OAAO,KAAK,MAAM,YAAY,OAAO;CACvC;AACF"}
|
|
@@ -26,6 +26,35 @@ function setLinkedinUser({ user_data }) {
|
|
|
26
26
|
if (!email) return;
|
|
27
27
|
window.lintrk("setUserData", { email });
|
|
28
28
|
}
|
|
29
|
+
function linkedInAds(options) {
|
|
30
|
+
return {
|
|
31
|
+
type: "ads",
|
|
32
|
+
track: sendLinkedinEvent(options.conversions),
|
|
33
|
+
setUser: setLinkedinUser,
|
|
34
|
+
script: {
|
|
35
|
+
id: "linkedin-insight-tag",
|
|
36
|
+
inline: `
|
|
37
|
+
_linkedin_partner_id = ${JSON.stringify(options.partnerId)};
|
|
38
|
+
window._linkedin_data_partner_ids = window._linkedin_data_partner_ids || [];
|
|
39
|
+
window._linkedin_data_partner_ids.push(_linkedin_partner_id);
|
|
40
|
+
(function(l) {
|
|
41
|
+
if (!l){
|
|
42
|
+
window.lintrk = function(a,b){
|
|
43
|
+
window.lintrk.q.push([a,b])
|
|
44
|
+
};
|
|
45
|
+
window.lintrk.q=[]
|
|
46
|
+
}
|
|
47
|
+
var s = document.getElementsByTagName("script")[0];
|
|
48
|
+
var b = document.createElement("script");
|
|
49
|
+
b.type = "text/javascript";b.async = true;
|
|
50
|
+
b.src = "https://snap.licdn.com/li.lms-analytics/insight.min.js";
|
|
51
|
+
s.parentNode.insertBefore(b, s);
|
|
52
|
+
})(window.lintrk);
|
|
53
|
+
`
|
|
54
|
+
}
|
|
55
|
+
};
|
|
56
|
+
}
|
|
57
|
+
exports.linkedInAds = linkedInAds;
|
|
29
58
|
exports.sendLinkedinEvent = sendLinkedinEvent;
|
|
30
59
|
exports.setLinkedinUser = setLinkedinUser;
|
|
31
60
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"linkedin-insight-tag.cjs","names":["getFirst"],"sources":["../../src/third-parties/linkedin-insight-tag.ts"],"sourcesContent":["import type { UpdateVisitorDTO } from '../schema/index';\nimport type { Lintrk } from '../track/lintrk';\nimport type { EventName, TrackName, TrackProperties } from '../track/types';\nimport { getFirst } from '../utils/field';\n\ndeclare global {\n interface Window {\n /** Undefined until the LinkedIn Insight Tag script has loaded. */\n lintrk?: Lintrk['lintrk'];\n }\n}\n\n/**\n *
|
|
1
|
+
{"version":3,"file":"linkedin-insight-tag.cjs","names":["getFirst"],"sources":["../../src/third-parties/linkedin-insight-tag.ts"],"sourcesContent":["import type { UpdateVisitorDTO } from '../schema/index';\nimport type { Lintrk } from '../track/lintrk';\nimport type { EventName, TrackName, TrackProperties } from '../track/types';\nimport { getFirst } from '../utils/field';\nimport type { Integration } from './integration';\n\ndeclare global {\n interface Window {\n /** Undefined until the LinkedIn Insight Tag script has loaded. */\n lintrk?: Lintrk['lintrk'];\n }\n}\n\n/**\n * Event name → LinkedIn conversion id, e.g. `{ purchase: 123, sign_up: 456 }`. Keys are the\n * names `track` accepts, so with strict event names a typo or undeclared event is a compile error.\n */\nexport type LinkedinConversionConfig = { readonly [K in TrackName]?: number };\n\nexport function sendLinkedinEvent(config: LinkedinConversionConfig) {\n return <T extends EventName>(\n name: TrackName<T>,\n _properties?: TrackProperties<T>,\n event_id?: string\n ) => {\n if (typeof window === 'undefined' || !window.lintrk) {\n console.warn('lintrk has not been initialized');\n return false;\n }\n if (window.location.host.includes('127.0.0.1')) return;\n if (window.location.host.includes('localhost')) return;\n\n const conversion_id = config[name];\n if (!conversion_id) return;\n window.lintrk('track', { conversion_id, event_id });\n };\n}\n\nexport function setLinkedinUser({ user_data }: UpdateVisitorDTO) {\n if (typeof window === 'undefined' || !window.lintrk) {\n console.warn('lintrk has not been initialized');\n return;\n }\n\n const email = getFirst(user_data?.email);\n if (!email) return;\n window.lintrk('setUserData', { email });\n}\n\n/**\n * LinkedIn Insight Tag: only the events in `conversions`, each sent as the conversion id it maps\n * to (LinkedIn conversions are created in Campaign Manager and addressed by id).\n */\n/** LinkedIn's configuration, shared by `linkedInAds` and `linkedinConversions` on the server. */\nexport interface LinkedInAdsOptions {\n partnerId: `${number}`;\n conversions: LinkedinConversionConfig;\n}\n\nexport function linkedInAds(options: LinkedInAdsOptions): Integration {\n return {\n type: 'ads',\n track: sendLinkedinEvent(options.conversions),\n setUser: setLinkedinUser,\n script: {\n id: 'linkedin-insight-tag',\n inline: `\n _linkedin_partner_id = ${JSON.stringify(options.partnerId)};\n window._linkedin_data_partner_ids = window._linkedin_data_partner_ids || [];\n window._linkedin_data_partner_ids.push(_linkedin_partner_id);\n (function(l) {\n if (!l){\n window.lintrk = function(a,b){\n window.lintrk.q.push([a,b])\n };\n window.lintrk.q=[]\n }\n var s = document.getElementsByTagName(\"script\")[0];\n var b = document.createElement(\"script\");\n b.type = \"text/javascript\";b.async = true;\n b.src = \"https://snap.licdn.com/li.lms-analytics/insight.min.js\";\n s.parentNode.insertBefore(b, s);\n })(window.lintrk);\n `,\n },\n };\n}\n"],"mappings":";;;AAmBA,SAAgB,kBAAkB,QAAkC;CAClE,QACE,MACA,aACA,aACG;EACH,IAAI,OAAO,WAAW,eAAe,CAAC,OAAO,QAAQ;GACnD,QAAQ,KAAK,iCAAiC;GAC9C,OAAO;EACT;EACA,IAAI,OAAO,SAAS,KAAK,SAAS,WAAW,GAAG;EAChD,IAAI,OAAO,SAAS,KAAK,SAAS,WAAW,GAAG;EAEhD,MAAM,gBAAgB,OAAO;EAC7B,IAAI,CAAC,eAAe;EACpB,OAAO,OAAO,SAAS;GAAE;GAAe;EAAS,CAAC;CACpD;AACF;AAEA,SAAgB,gBAAgB,EAAE,aAA+B;CAC/D,IAAI,OAAO,WAAW,eAAe,CAAC,OAAO,QAAQ;EACnD,QAAQ,KAAK,iCAAiC;EAC9C;CACF;CAEA,MAAM,QAAQA,oBAAAA,SAAS,WAAW,KAAK;CACvC,IAAI,CAAC,OAAO;CACZ,OAAO,OAAO,eAAe,EAAE,MAAM,CAAC;AACxC;AAYA,SAAgB,YAAY,SAA0C;CACpE,OAAO;EACL,MAAM;EACN,OAAO,kBAAkB,QAAQ,WAAW;EAC5C,SAAS;EACT,QAAQ;GACN,IAAI;GACJ,QAAQ;iCACmB,KAAK,UAAU,QAAQ,SAAS,EAAE;;;;;;;;;;;;;;;;;EAiB/D;CACF;AACF"}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { EventName, TrackName, TrackProperties } from "../track/types.cjs";
|
|
2
2
|
import { UpdateVisitorDTO } from "../schema/index.cjs";
|
|
3
|
+
import { Integration } from "./integration.cjs";
|
|
3
4
|
import { Lintrk } from "../track/lintrk.cjs";
|
|
4
5
|
declare global {
|
|
5
6
|
interface Window {
|
|
@@ -8,15 +9,20 @@ declare global {
|
|
|
8
9
|
}
|
|
9
10
|
}
|
|
10
11
|
/**
|
|
11
|
-
* LinkedIn
|
|
12
|
-
*
|
|
13
|
-
* {
|
|
14
|
-
* purchase: 123,
|
|
15
|
-
* add_to_cart: 456,
|
|
16
|
-
* add_to_wishlist: 789,
|
|
17
|
-
* }
|
|
12
|
+
* Event name → LinkedIn conversion id, e.g. `{ purchase: 123, sign_up: 456 }`. Keys are the
|
|
13
|
+
* names `track` accepts, so with strict event names a typo or undeclared event is a compile error.
|
|
18
14
|
*/
|
|
19
|
-
export type LinkedinConversionConfig =
|
|
15
|
+
export type LinkedinConversionConfig = { readonly [K in TrackName]?: number; };
|
|
20
16
|
export declare function sendLinkedinEvent(config: LinkedinConversionConfig): <T extends EventName>(name: TrackName<T>, _properties?: TrackProperties<T>, event_id?: string) => false | undefined;
|
|
21
17
|
export declare function setLinkedinUser({ user_data }: UpdateVisitorDTO): void;
|
|
18
|
+
/**
|
|
19
|
+
* LinkedIn Insight Tag: only the events in `conversions`, each sent as the conversion id it maps
|
|
20
|
+
* to (LinkedIn conversions are created in Campaign Manager and addressed by id).
|
|
21
|
+
*/
|
|
22
|
+
/** LinkedIn's configuration, shared by `linkedInAds` and `linkedinConversions` on the server. */
|
|
23
|
+
export interface LinkedInAdsOptions {
|
|
24
|
+
partnerId: `${number}`;
|
|
25
|
+
conversions: LinkedinConversionConfig;
|
|
26
|
+
}
|
|
27
|
+
export declare function linkedInAds(options: LinkedInAdsOptions): Integration;
|
|
22
28
|
//# sourceMappingURL=linkedin-insight-tag.d.cts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"linkedin-insight-tag.d.cts","names":[],"sources":["../../src/third-parties/linkedin-insight-tag.ts"],"mappings":"
|
|
1
|
+
{"version":3,"file":"linkedin-insight-tag.d.cts","names":[],"sources":["../../src/third-parties/linkedin-insight-tag.ts"],"mappings":";;;;QAMQ;YACI;;IAER,SAAS;;;;;;;YAQD,uCAAuC,KAAK;wBAExC,kBAAkB,QAAQ,4BAChC,UAAU,WAAS,MACnB,UAAU,IAAE,cACJ,gBAAgB,IAAE;wBAgBpB,kBAAkB,aAAa;;;;;;iBAgB9B;EACf;EACA,aAAa;;wBAGC,YAAY,SAAS,qBAAqB"}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { EventName, TrackName, TrackProperties } from "../track/types.mjs";
|
|
2
2
|
import { UpdateVisitorDTO } from "../schema/index.mjs";
|
|
3
|
+
import { Integration } from "./integration.mjs";
|
|
3
4
|
import { Lintrk } from "../track/lintrk.mjs";
|
|
4
5
|
declare global {
|
|
5
6
|
interface Window {
|
|
@@ -8,15 +9,20 @@ declare global {
|
|
|
8
9
|
}
|
|
9
10
|
}
|
|
10
11
|
/**
|
|
11
|
-
* LinkedIn
|
|
12
|
-
*
|
|
13
|
-
* {
|
|
14
|
-
* purchase: 123,
|
|
15
|
-
* add_to_cart: 456,
|
|
16
|
-
* add_to_wishlist: 789,
|
|
17
|
-
* }
|
|
12
|
+
* Event name → LinkedIn conversion id, e.g. `{ purchase: 123, sign_up: 456 }`. Keys are the
|
|
13
|
+
* names `track` accepts, so with strict event names a typo or undeclared event is a compile error.
|
|
18
14
|
*/
|
|
19
|
-
export type LinkedinConversionConfig =
|
|
15
|
+
export type LinkedinConversionConfig = { readonly [K in TrackName]?: number; };
|
|
20
16
|
export declare function sendLinkedinEvent(config: LinkedinConversionConfig): <T extends EventName>(name: TrackName<T>, _properties?: TrackProperties<T>, event_id?: string) => false | undefined;
|
|
21
17
|
export declare function setLinkedinUser({ user_data }: UpdateVisitorDTO): void;
|
|
18
|
+
/**
|
|
19
|
+
* LinkedIn Insight Tag: only the events in `conversions`, each sent as the conversion id it maps
|
|
20
|
+
* to (LinkedIn conversions are created in Campaign Manager and addressed by id).
|
|
21
|
+
*/
|
|
22
|
+
/** LinkedIn's configuration, shared by `linkedInAds` and `linkedinConversions` on the server. */
|
|
23
|
+
export interface LinkedInAdsOptions {
|
|
24
|
+
partnerId: `${number}`;
|
|
25
|
+
conversions: LinkedinConversionConfig;
|
|
26
|
+
}
|
|
27
|
+
export declare function linkedInAds(options: LinkedInAdsOptions): Integration;
|
|
22
28
|
//# sourceMappingURL=linkedin-insight-tag.d.mts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"linkedin-insight-tag.d.mts","names":[],"sources":["../../src/third-parties/linkedin-insight-tag.ts"],"mappings":"
|
|
1
|
+
{"version":3,"file":"linkedin-insight-tag.d.mts","names":[],"sources":["../../src/third-parties/linkedin-insight-tag.ts"],"mappings":";;;;QAMQ;YACI;;IAER,SAAS;;;;;;;YAQD,uCAAuC,KAAK;wBAExC,kBAAkB,QAAQ,4BAChC,UAAU,WAAS,MACnB,UAAU,IAAE,cACJ,gBAAgB,IAAE;wBAgBpB,kBAAkB,aAAa;;;;;;iBAgB9B;EACf;EACA,aAAa;;wBAGC,YAAY,SAAS,qBAAqB"}
|
|
@@ -25,6 +25,34 @@ function setLinkedinUser({ user_data }) {
|
|
|
25
25
|
if (!email) return;
|
|
26
26
|
window.lintrk("setUserData", { email });
|
|
27
27
|
}
|
|
28
|
-
|
|
28
|
+
function linkedInAds(options) {
|
|
29
|
+
return {
|
|
30
|
+
type: "ads",
|
|
31
|
+
track: sendLinkedinEvent(options.conversions),
|
|
32
|
+
setUser: setLinkedinUser,
|
|
33
|
+
script: {
|
|
34
|
+
id: "linkedin-insight-tag",
|
|
35
|
+
inline: `
|
|
36
|
+
_linkedin_partner_id = ${JSON.stringify(options.partnerId)};
|
|
37
|
+
window._linkedin_data_partner_ids = window._linkedin_data_partner_ids || [];
|
|
38
|
+
window._linkedin_data_partner_ids.push(_linkedin_partner_id);
|
|
39
|
+
(function(l) {
|
|
40
|
+
if (!l){
|
|
41
|
+
window.lintrk = function(a,b){
|
|
42
|
+
window.lintrk.q.push([a,b])
|
|
43
|
+
};
|
|
44
|
+
window.lintrk.q=[]
|
|
45
|
+
}
|
|
46
|
+
var s = document.getElementsByTagName("script")[0];
|
|
47
|
+
var b = document.createElement("script");
|
|
48
|
+
b.type = "text/javascript";b.async = true;
|
|
49
|
+
b.src = "https://snap.licdn.com/li.lms-analytics/insight.min.js";
|
|
50
|
+
s.parentNode.insertBefore(b, s);
|
|
51
|
+
})(window.lintrk);
|
|
52
|
+
`
|
|
53
|
+
}
|
|
54
|
+
};
|
|
55
|
+
}
|
|
56
|
+
export { linkedInAds, sendLinkedinEvent, setLinkedinUser };
|
|
29
57
|
|
|
30
58
|
//# sourceMappingURL=linkedin-insight-tag.mjs.map
|