@shware/analytics 16.0.0 → 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.
Files changed (162) hide show
  1. package/README.md +76 -1
  2. package/dist/native/fbsdk.cjs +1 -2
  3. package/dist/native/fbsdk.cjs.map +1 -1
  4. package/dist/native/fbsdk.d.cts.map +1 -1
  5. package/dist/native/fbsdk.d.mts.map +1 -1
  6. package/dist/native/fbsdk.mjs +3 -4
  7. package/dist/native/fbsdk.mjs.map +1 -1
  8. package/dist/server/conversions-api-error.cjs +20 -0
  9. package/dist/server/conversions-api-error.cjs.map +1 -0
  10. package/dist/server/conversions-api-error.d.cts +17 -0
  11. package/dist/server/conversions-api-error.d.cts.map +1 -0
  12. package/dist/server/conversions-api-error.d.mts +17 -0
  13. package/dist/server/conversions-api-error.d.mts.map +1 -0
  14. package/dist/server/conversions-api-error.mjs +19 -0
  15. package/dist/server/conversions-api-error.mjs.map +1 -0
  16. package/dist/server/google-data-manager.cjs +24 -26
  17. package/dist/server/google-data-manager.cjs.map +1 -1
  18. package/dist/server/google-data-manager.d.cts +13 -5
  19. package/dist/server/google-data-manager.d.cts.map +1 -1
  20. package/dist/server/google-data-manager.d.mts +13 -5
  21. package/dist/server/google-data-manager.d.mts.map +1 -1
  22. package/dist/server/google-data-manager.mjs +24 -27
  23. package/dist/server/google-data-manager.mjs.map +1 -1
  24. package/dist/server/index.cjs +11 -0
  25. package/dist/server/index.d.cts +10 -7
  26. package/dist/server/index.d.mts +10 -7
  27. package/dist/server/index.mjs +9 -7
  28. package/dist/server/linkedin-conversions-api.cjs +29 -23
  29. package/dist/server/linkedin-conversions-api.cjs.map +1 -1
  30. package/dist/server/linkedin-conversions-api.d.cts +7 -2
  31. package/dist/server/linkedin-conversions-api.d.cts.map +1 -1
  32. package/dist/server/linkedin-conversions-api.d.mts +7 -2
  33. package/dist/server/linkedin-conversions-api.d.mts.map +1 -1
  34. package/dist/server/linkedin-conversions-api.mjs +29 -24
  35. package/dist/server/linkedin-conversions-api.mjs.map +1 -1
  36. package/dist/server/meta-capi.cjs +32 -31
  37. package/dist/server/meta-capi.cjs.map +1 -1
  38. package/dist/server/meta-capi.d.cts +12 -3
  39. package/dist/server/meta-capi.d.cts.map +1 -1
  40. package/dist/server/meta-capi.d.mts +12 -3
  41. package/dist/server/meta-capi.d.mts.map +1 -1
  42. package/dist/server/meta-capi.mjs +33 -33
  43. package/dist/server/meta-capi.mjs.map +1 -1
  44. package/dist/server/microsoft-conversions-api.cjs +33 -28
  45. package/dist/server/microsoft-conversions-api.cjs.map +1 -1
  46. package/dist/server/microsoft-conversions-api.d.cts +14 -2
  47. package/dist/server/microsoft-conversions-api.d.cts.map +1 -1
  48. package/dist/server/microsoft-conversions-api.d.mts +14 -2
  49. package/dist/server/microsoft-conversions-api.d.mts.map +1 -1
  50. package/dist/server/microsoft-conversions-api.mjs +33 -29
  51. package/dist/server/microsoft-conversions-api.mjs.map +1 -1
  52. package/dist/server/openai-conversions-api.cjs +20 -18
  53. package/dist/server/openai-conversions-api.cjs.map +1 -1
  54. package/dist/server/openai-conversions-api.d.cts +7 -0
  55. package/dist/server/openai-conversions-api.d.cts.map +1 -1
  56. package/dist/server/openai-conversions-api.d.mts +7 -0
  57. package/dist/server/openai-conversions-api.d.mts.map +1 -1
  58. package/dist/server/openai-conversions-api.mjs +21 -20
  59. package/dist/server/openai-conversions-api.mjs.map +1 -1
  60. package/dist/server/reddit-conversions-api.cjs +20 -18
  61. package/dist/server/reddit-conversions-api.cjs.map +1 -1
  62. package/dist/server/reddit-conversions-api.d.cts +7 -0
  63. package/dist/server/reddit-conversions-api.d.cts.map +1 -1
  64. package/dist/server/reddit-conversions-api.d.mts +7 -0
  65. package/dist/server/reddit-conversions-api.d.mts.map +1 -1
  66. package/dist/server/reddit-conversions-api.mjs +21 -20
  67. package/dist/server/reddit-conversions-api.mjs.map +1 -1
  68. package/dist/server/setup-conversions.cjs +62 -0
  69. package/dist/server/setup-conversions.cjs.map +1 -0
  70. package/dist/server/setup-conversions.d.cts +97 -0
  71. package/dist/server/setup-conversions.d.cts.map +1 -0
  72. package/dist/server/setup-conversions.d.mts +97 -0
  73. package/dist/server/setup-conversions.d.mts.map +1 -0
  74. package/dist/server/setup-conversions.mjs +60 -0
  75. package/dist/server/setup-conversions.mjs.map +1 -0
  76. package/dist/third-parties/index.d.cts +3 -3
  77. package/dist/third-parties/index.d.mts +3 -3
  78. package/dist/third-parties/integration.cjs +13 -6
  79. package/dist/third-parties/integration.cjs.map +1 -1
  80. package/dist/third-parties/integration.d.cts +12 -8
  81. package/dist/third-parties/integration.d.cts.map +1 -1
  82. package/dist/third-parties/integration.d.mts +12 -8
  83. package/dist/third-parties/integration.d.mts.map +1 -1
  84. package/dist/third-parties/integration.mjs +13 -7
  85. package/dist/third-parties/integration.mjs.map +1 -1
  86. package/dist/third-parties/linkedin-insight-tag.cjs +0 -4
  87. package/dist/third-parties/linkedin-insight-tag.cjs.map +1 -1
  88. package/dist/third-parties/linkedin-insight-tag.d.cts +4 -2
  89. package/dist/third-parties/linkedin-insight-tag.d.cts.map +1 -1
  90. package/dist/third-parties/linkedin-insight-tag.d.mts +4 -2
  91. package/dist/third-parties/linkedin-insight-tag.d.mts.map +1 -1
  92. package/dist/third-parties/linkedin-insight-tag.mjs +0 -4
  93. package/dist/third-parties/linkedin-insight-tag.mjs.map +1 -1
  94. package/dist/third-parties/meta-pixel.cjs +1 -3
  95. package/dist/third-parties/meta-pixel.cjs.map +1 -1
  96. package/dist/third-parties/meta-pixel.d.cts +4 -2
  97. package/dist/third-parties/meta-pixel.d.cts.map +1 -1
  98. package/dist/third-parties/meta-pixel.d.mts +4 -2
  99. package/dist/third-parties/meta-pixel.d.mts.map +1 -1
  100. package/dist/third-parties/meta-pixel.mjs +3 -5
  101. package/dist/third-parties/meta-pixel.mjs.map +1 -1
  102. package/dist/third-parties/microsoft-uet.cjs +7 -2
  103. package/dist/third-parties/microsoft-uet.cjs.map +1 -1
  104. package/dist/third-parties/microsoft-uet.d.cts +10 -3
  105. package/dist/third-parties/microsoft-uet.d.cts.map +1 -1
  106. package/dist/third-parties/microsoft-uet.d.mts +10 -3
  107. package/dist/third-parties/microsoft-uet.d.mts.map +1 -1
  108. package/dist/third-parties/microsoft-uet.mjs +8 -4
  109. package/dist/third-parties/microsoft-uet.mjs.map +1 -1
  110. package/dist/third-parties/openai-pixel.cjs +1 -3
  111. package/dist/third-parties/openai-pixel.cjs.map +1 -1
  112. package/dist/third-parties/openai-pixel.d.cts +4 -2
  113. package/dist/third-parties/openai-pixel.d.cts.map +1 -1
  114. package/dist/third-parties/openai-pixel.d.mts +4 -2
  115. package/dist/third-parties/openai-pixel.d.mts.map +1 -1
  116. package/dist/third-parties/openai-pixel.mjs +3 -5
  117. package/dist/third-parties/openai-pixel.mjs.map +1 -1
  118. package/dist/third-parties/reddit-pixel.cjs +1 -3
  119. package/dist/third-parties/reddit-pixel.cjs.map +1 -1
  120. package/dist/third-parties/reddit-pixel.d.cts +4 -2
  121. package/dist/third-parties/reddit-pixel.d.cts.map +1 -1
  122. package/dist/third-parties/reddit-pixel.d.mts +4 -2
  123. package/dist/third-parties/reddit-pixel.d.mts.map +1 -1
  124. package/dist/third-parties/reddit-pixel.mjs +3 -5
  125. package/dist/third-parties/reddit-pixel.mjs.map +1 -1
  126. package/dist/track/fbq.cjs +5 -0
  127. package/dist/track/fbq.cjs.map +1 -1
  128. package/dist/track/fbq.d.cts +2 -0
  129. package/dist/track/fbq.d.cts.map +1 -1
  130. package/dist/track/fbq.d.mts +2 -0
  131. package/dist/track/fbq.d.mts.map +1 -1
  132. package/dist/track/fbq.mjs +5 -1
  133. package/dist/track/fbq.mjs.map +1 -1
  134. package/dist/track/oaiq.cjs +5 -0
  135. package/dist/track/oaiq.cjs.map +1 -1
  136. package/dist/track/oaiq.d.cts +2 -0
  137. package/dist/track/oaiq.d.cts.map +1 -1
  138. package/dist/track/oaiq.d.mts +2 -0
  139. package/dist/track/oaiq.d.mts.map +1 -1
  140. package/dist/track/oaiq.mjs +5 -1
  141. package/dist/track/oaiq.mjs.map +1 -1
  142. package/dist/track/rdt.cjs +5 -0
  143. package/dist/track/rdt.cjs.map +1 -1
  144. package/dist/track/rdt.d.cts +2 -0
  145. package/dist/track/rdt.d.cts.map +1 -1
  146. package/dist/track/rdt.d.mts +2 -0
  147. package/dist/track/rdt.d.mts.map +1 -1
  148. package/dist/track/rdt.mjs +5 -1
  149. package/dist/track/rdt.mjs.map +1 -1
  150. package/package.json +1 -16
  151. package/dist/server/legacy.cjs +0 -3
  152. package/dist/server/legacy.d.cts +0 -2
  153. package/dist/server/legacy.d.mts +0 -2
  154. package/dist/server/legacy.mjs +0 -1
  155. package/dist/server/meta-conversions-api.cjs +0 -205
  156. package/dist/server/meta-conversions-api.cjs.map +0 -1
  157. package/dist/server/meta-conversions-api.d.cts +0 -8
  158. package/dist/server/meta-conversions-api.d.cts.map +0 -1
  159. package/dist/server/meta-conversions-api.d.mts +0 -8
  160. package/dist/server/meta-conversions-api.d.mts.map +0 -1
  161. package/dist/server/meta-conversions-api.mjs +0 -201
  162. package/dist/server/meta-conversions-api.mjs.map +0 -1
@@ -0,0 +1,97 @@
1
+ import { Environment, EventName, Platform, TrackEvent, TrackName, TrackProperties, TrackTags, UserProvidedData } from "../track/types.mjs";
2
+ type AnyTrackEvent = TrackEvent<any>;
3
+ /**
4
+ * Where `setupConversions` sends events: an ad platform's conversions API, from its factory
5
+ * (`metaConversions`, … next to each sender), or anything else the host forwards events to (a
6
+ * CRM, its own workflows).
7
+ *
8
+ * `send` rejects when it fails, as the SDK's senders do: `setupConversions` logs the failure,
9
+ * with the events' ids, and still sends to the others.
10
+ */
11
+ export interface ConversionDestination {
12
+ readonly send: (events: AnyTrackEvent[], data: UserProvidedData) => Promise<unknown>;
13
+ }
14
+ /**
15
+ * A destination that sends only the events `accepts` lets through, and makes no request when none
16
+ * is left: what each conversions API's factory (`metaConversions`, …) is built on.
17
+ */
18
+ export declare function conversionDestination(accepts: (name: string) => boolean, send: (events: AnyTrackEvent[], data: UserProvidedData) => Promise<unknown>): ConversionDestination;
19
+ /**
20
+ * Who a server-only event is from, as the host knows them: what the ad platforms match a client
21
+ * event on, read from the host's own records.
22
+ *
23
+ * - `tags`: the user's latest session's tags (their cookies — `_fbp`, `_rdt_uuid`, … — page
24
+ * and user agent), with the click ids of the touch the conversion is attributed to over them.
25
+ * - `visitor_id`, `session_id`, `platform`, `environment`: from that session. `platform` decides
26
+ * each platform's action source (website or app), as for a client event.
27
+ * - `data`: the user's identity (`email`, `user_id`, …), hashed by each sender.
28
+ */
29
+ export interface ConversionUser {
30
+ tags: TrackTags;
31
+ visitor_id: string;
32
+ session_id: string;
33
+ platform: Platform;
34
+ environment: Environment;
35
+ data: UserProvidedData;
36
+ }
37
+ /**
38
+ * An event the server reports on its own, with no client behind it: a webhook's purchase,
39
+ * renewal or refund. `id` is the transaction id: `track.store` keeps a redelivered webhook from
40
+ * being reported twice, and the platforms pair it with a browser event under the same id.
41
+ */
42
+ export interface ServerEvent<T extends EventName = EventName> {
43
+ id: string;
44
+ name: TrackName<T>;
45
+ /** The user it belongs to, handed to `track.resolveUser`. */
46
+ userId: string;
47
+ properties?: TrackProperties<T>;
48
+ /** When it happened, as an ISO 8601 string. */
49
+ createdAt: string;
50
+ }
51
+ export interface ConversionsOptions {
52
+ destinations: readonly ConversionDestination[];
53
+ /**
54
+ * How `track` completes and stores a server-only event. Without it `setupConversions` returns
55
+ * only `forward`, for a host that only forwards client events.
56
+ */
57
+ track?: {
58
+ /**
59
+ * The user behind the event, read from the host's records (see `ConversionUser`);
60
+ * `undefined` for one the host has no session of, whose event is then dropped.
61
+ */
62
+ resolveUser: (userId: string) => Promise<ConversionUser | undefined>;
63
+ /**
64
+ * Stores the event, e.g. in the events table, returning whether it was new: `track` sends
65
+ * only an event it stored, so a webhook delivered again (its handler failed on something
66
+ * else) is not reported twice — not every platform deduplicates a server event sent twice.
67
+ */
68
+ store: (event: AnyTrackEvent) => Promise<boolean>;
69
+ };
70
+ }
71
+ /**
72
+ * The server's counterpart of `setupAnalytics({ integrations })`: every destination configured
73
+ * once, with the same per-platform options as the browser integrations, so the conversions API
74
+ * and the tag report the same events.
75
+ *
76
+ * - `forward(events, data)`: the events a client sent, as stored, on to every destination.
77
+ * - `track(event)`: an event the server reports on its own (a webhook's), completed by
78
+ * `track.resolveUser`, stored with `track.store`, then forwarded.
79
+ *
80
+ * Neither throws, so reporting a conversion can never fail the request it runs in — a payment
81
+ * webhook least of all, which its provider would then deliver again and again. A failure is
82
+ * logged with the ids of the events it lost, for them to be found and sent later: a missed
83
+ * conversion costs less than a duplicate one, or a webhook that keeps failing.
84
+ */
85
+ export declare function setupConversions(options: ConversionsOptions & {
86
+ track: NonNullable<ConversionsOptions['track']>;
87
+ }): {
88
+ forward: Forward;
89
+ track: Track;
90
+ };
91
+ export declare function setupConversions(options: ConversionsOptions): {
92
+ forward: Forward;
93
+ };
94
+ type Forward = (events: AnyTrackEvent[], data?: UserProvidedData) => Promise<void>;
95
+ type Track = <T extends EventName>(input: ServerEvent<T>) => Promise<TrackEvent<T> | undefined>;
96
+ export {};
97
+ //# sourceMappingURL=setup-conversions.d.mts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"setup-conversions.d.mts","names":[],"sources":["../../src/server/setup-conversions.ts"],"mappings":";KAYK,gBAAgB;;;;;;;;;iBAUJ;WACN,OAAO,QAAQ,iBAAiB,MAAM,qBAAqB;;;;;;wBAOtD,sBACd,UAAU,0BACV,OAAO,QAAQ,iBAAiB,MAAM,qBAAqB,mBAC1D;;;;;;;;;;;iBAmBc;EACf,MAAM;EACN;EACA;EACA,UAAU;EACV,aAAa;EACb,MAAM;;;;;;;iBAQS,YAAY,UAAU,YAAY;EACjD;EACA,MAAM,UAAU;;EAEhB;EACA,aAAa,gBAAgB;;EAE7B;;iBAGe;EACf,uBAAuB;;;;;EAKvB;;;;;IAKE,cAAc,mBAAmB,QAAQ;;;;;;IAMzC,QAAQ,OAAO,kBAAkB;;;;;;;;;;;;;;;;;wBAkBrB,iBACd,SAAS;EAAuB,OAAO,YAAY;;EAEnD,SAAS;EACT,OAAO;;wBAEO,iBAAiB,SAAS;EAAuB,SAAS;;KAyDrE,WAAW,QAAQ,iBAAiB,OAAO,qBAAqB;KAChE,SAAS,UAAU,WAAW,OAAO,YAAY,OAAO,QAAQ,WAAW"}
@@ -0,0 +1,60 @@
1
+ // src/server/setup-conversions.ts
2
+ /**
3
+ * A destination that sends only the events `accepts` lets through, and makes no request when none
4
+ * is left: what each conversions API's factory (`metaConversions`, …) is built on.
5
+ */
6
+ function conversionDestination(accepts, send) {
7
+ return { send: async (events, data) => {
8
+ const accepted = events.filter((event) => accepts(event.name));
9
+ if (accepted.length > 0) await send(accepted, data);
10
+ } };
11
+ }
12
+ function setupConversions(options) {
13
+ const { destinations, track: trackOptions } = options;
14
+ async function forward(events, data = {}) {
15
+ if (events.length === 0) return;
16
+ const settled = await Promise.allSettled(destinations.map((d) => Promise.resolve().then(() => d.send(events, data))));
17
+ const ids = events.map((event) => event.id).join(", ");
18
+ settled.forEach((outcome) => {
19
+ if (outcome.status === "rejected") console.error(`Conversions not sent, events: ${ids}`, outcome.reason);
20
+ });
21
+ }
22
+ /**
23
+ * Reports a server-only event; resolves with it as sent, or `undefined` when it was not: a
24
+ * user with no session, an event `store` had already stored, or a failure, which is logged.
25
+ */
26
+ async function track({ resolveUser, store }, input) {
27
+ try {
28
+ const user = await resolveUser(input.userId);
29
+ if (!user) {
30
+ console.warn(`Conversion not reported, event: ${input.id}: no session for ${input.userId}`);
31
+ return;
32
+ }
33
+ const event = {
34
+ id: input.id,
35
+ name: input.name,
36
+ properties: input.properties,
37
+ tags: user.tags,
38
+ visitor_id: user.visitor_id,
39
+ session_id: user.session_id,
40
+ platform: user.platform,
41
+ environment: user.environment,
42
+ created_at: input.createdAt
43
+ };
44
+ if (!await store(event)) return void 0;
45
+ await forward([event], user.data);
46
+ return event;
47
+ } catch (e) {
48
+ console.error(`Conversion not reported, event: ${input.id}`, e);
49
+ return;
50
+ }
51
+ }
52
+ if (!trackOptions) return { forward };
53
+ return {
54
+ forward,
55
+ track: (input) => track(trackOptions, input)
56
+ };
57
+ }
58
+ export { conversionDestination, setupConversions };
59
+
60
+ //# sourceMappingURL=setup-conversions.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"setup-conversions.mjs","names":[],"sources":["../../src/server/setup-conversions.ts"],"sourcesContent":["import type {\n Environment,\n EventName,\n Platform,\n TrackEvent,\n TrackName,\n TrackProperties,\n TrackTags,\n UserProvidedData,\n} from '../track/types';\n\n// oxlint-disable-next-line @typescript-eslint/no-explicit-any\ntype AnyTrackEvent = TrackEvent<any>;\n\n/**\n * Where `setupConversions` sends events: an ad platform's conversions API, from its factory\n * (`metaConversions`, … next to each sender), or anything else the host forwards events to (a\n * CRM, its own workflows).\n *\n * `send` rejects when it fails, as the SDK's senders do: `setupConversions` logs the failure,\n * with the events' ids, and still sends to the others.\n */\nexport interface ConversionDestination {\n readonly send: (events: AnyTrackEvent[], data: UserProvidedData) => Promise<unknown>;\n}\n\n/**\n * A destination that sends only the events `accepts` lets through, and makes no request when none\n * is left: what each conversions API's factory (`metaConversions`, …) is built on.\n */\nexport function conversionDestination(\n accepts: (name: string) => boolean,\n send: (events: AnyTrackEvent[], data: UserProvidedData) => Promise<unknown>\n): ConversionDestination {\n return {\n send: async (events, data) => {\n const accepted = events.filter((event) => accepts(event.name));\n if (accepted.length > 0) await send(accepted, data);\n },\n };\n}\n\n/**\n * Who a server-only event is from, as the host knows them: what the ad platforms match a client\n * event on, read from the host's own records.\n *\n * - `tags`: the user's latest session's tags (their cookies — `_fbp`, `_rdt_uuid`, … — page\n * and user agent), with the click ids of the touch the conversion is attributed to over them.\n * - `visitor_id`, `session_id`, `platform`, `environment`: from that session. `platform` decides\n * each platform's action source (website or app), as for a client event.\n * - `data`: the user's identity (`email`, `user_id`, …), hashed by each sender.\n */\nexport interface ConversionUser {\n tags: TrackTags;\n visitor_id: string;\n session_id: string;\n platform: Platform;\n environment: Environment;\n data: UserProvidedData;\n}\n\n/**\n * An event the server reports on its own, with no client behind it: a webhook's purchase,\n * renewal or refund. `id` is the transaction id: `track.store` keeps a redelivered webhook from\n * being reported twice, and the platforms pair it with a browser event under the same id.\n */\nexport interface ServerEvent<T extends EventName = EventName> {\n id: string;\n name: TrackName<T>;\n /** The user it belongs to, handed to `track.resolveUser`. */\n userId: string;\n properties?: TrackProperties<T>;\n /** When it happened, as an ISO 8601 string. */\n createdAt: string;\n}\n\nexport interface ConversionsOptions {\n destinations: readonly ConversionDestination[];\n /**\n * How `track` completes and stores a server-only event. Without it `setupConversions` returns\n * only `forward`, for a host that only forwards client events.\n */\n track?: {\n /**\n * The user behind the event, read from the host's records (see `ConversionUser`);\n * `undefined` for one the host has no session of, whose event is then dropped.\n */\n resolveUser: (userId: string) => Promise<ConversionUser | undefined>;\n /**\n * Stores the event, e.g. in the events table, returning whether it was new: `track` sends\n * only an event it stored, so a webhook delivered again (its handler failed on something\n * else) is not reported twice — not every platform deduplicates a server event sent twice.\n */\n store: (event: AnyTrackEvent) => Promise<boolean>;\n };\n}\n\n/**\n * The server's counterpart of `setupAnalytics({ integrations })`: every destination configured\n * once, with the same per-platform options as the browser integrations, so the conversions API\n * and the tag report the same events.\n *\n * - `forward(events, data)`: the events a client sent, as stored, on to every destination.\n * - `track(event)`: an event the server reports on its own (a webhook's), completed by\n * `track.resolveUser`, stored with `track.store`, then forwarded.\n *\n * Neither throws, so reporting a conversion can never fail the request it runs in — a payment\n * webhook least of all, which its provider would then deliver again and again. A failure is\n * logged with the ids of the events it lost, for them to be found and sent later: a missed\n * conversion costs less than a duplicate one, or a webhook that keeps failing.\n */\nexport function setupConversions(\n options: ConversionsOptions & { track: NonNullable<ConversionsOptions['track']> }\n): {\n forward: Forward;\n track: Track;\n};\nexport function setupConversions(options: ConversionsOptions): { forward: Forward };\nexport function setupConversions(options: ConversionsOptions) {\n const { destinations, track: trackOptions } = options;\n\n async function forward(events: AnyTrackEvent[], data: UserProvidedData = {}) {\n if (events.length === 0) return;\n // Called inside a promise: a `send` that throws synchronously rejects there instead of\n // stopping the destinations after it.\n const settled = await Promise.allSettled(\n destinations.map((d) => Promise.resolve().then(() => d.send(events, data)))\n );\n const ids = events.map((event) => event.id).join(', ');\n settled.forEach((outcome) => {\n if (outcome.status === 'rejected') {\n console.error(`Conversions not sent, events: ${ids}`, outcome.reason);\n }\n });\n }\n\n /**\n * Reports a server-only event; resolves with it as sent, or `undefined` when it was not: a\n * user with no session, an event `store` had already stored, or a failure, which is logged.\n */\n async function track<T extends EventName>(\n { resolveUser, store }: NonNullable<ConversionsOptions['track']>,\n input: ServerEvent<T>\n ): Promise<TrackEvent<T> | undefined> {\n try {\n const user = await resolveUser(input.userId);\n if (!user) {\n console.warn(`Conversion not reported, event: ${input.id}: no session for ${input.userId}`);\n return undefined;\n }\n const event: TrackEvent<T> = {\n id: input.id,\n name: input.name,\n properties: input.properties,\n tags: user.tags,\n visitor_id: user.visitor_id,\n session_id: user.session_id,\n platform: user.platform,\n environment: user.environment,\n created_at: input.createdAt,\n };\n if (!(await store(event))) return undefined;\n await forward([event], user.data);\n return event;\n } catch (e: unknown) {\n console.error(`Conversion not reported, event: ${input.id}`, e);\n return undefined;\n }\n }\n\n if (!trackOptions) return { forward };\n return { forward, track: (input: ServerEvent) => track(trackOptions, input) };\n}\n\ntype Forward = (events: AnyTrackEvent[], data?: UserProvidedData) => Promise<void>;\ntype Track = <T extends EventName>(input: ServerEvent<T>) => Promise<TrackEvent<T> | undefined>;\n"],"mappings":";;;;;AA8BA,SAAgB,sBACd,SACA,MACuB;CACvB,OAAO,EACL,MAAM,OAAO,QAAQ,SAAS;EAC5B,MAAM,WAAW,OAAO,QAAQ,UAAU,QAAQ,MAAM,IAAI,CAAC;EAC7D,IAAI,SAAS,SAAS,GAAG,MAAM,KAAK,UAAU,IAAI;CACpD,EACF;AACF;AA8EA,SAAgB,iBAAiB,SAA6B;CAC5D,MAAM,EAAE,cAAc,OAAO,iBAAiB;CAE9C,eAAe,QAAQ,QAAyB,OAAyB,CAAC,GAAG;EAC3E,IAAI,OAAO,WAAW,GAAG;EAGzB,MAAM,UAAU,MAAM,QAAQ,WAC5B,aAAa,KAAK,MAAM,QAAQ,QAAQ,CAAC,CAAC,WAAW,EAAE,KAAK,QAAQ,IAAI,CAAC,CAAC,CAC5E;EACA,MAAM,MAAM,OAAO,KAAK,UAAU,MAAM,EAAE,CAAC,CAAC,KAAK,IAAI;EACrD,QAAQ,SAAS,YAAY;GAC3B,IAAI,QAAQ,WAAW,YACrB,QAAQ,MAAM,iCAAiC,OAAO,QAAQ,MAAM;EAExE,CAAC;CACH;;;;;CAMA,eAAe,MACb,EAAE,aAAa,SACf,OACoC;EACpC,IAAI;GACF,MAAM,OAAO,MAAM,YAAY,MAAM,MAAM;GAC3C,IAAI,CAAC,MAAM;IACT,QAAQ,KAAK,mCAAmC,MAAM,GAAG,mBAAmB,MAAM,QAAQ;IAC1F;GACF;GACA,MAAM,QAAuB;IAC3B,IAAI,MAAM;IACV,MAAM,MAAM;IACZ,YAAY,MAAM;IAClB,MAAM,KAAK;IACX,YAAY,KAAK;IACjB,YAAY,KAAK;IACjB,UAAU,KAAK;IACf,aAAa,KAAK;IAClB,YAAY,MAAM;GACpB;GACA,IAAI,CAAE,MAAM,MAAM,KAAK,GAAI,OAAO,KAAA;GAClC,MAAM,QAAQ,CAAC,KAAK,GAAG,KAAK,IAAI;GAChC,OAAO;EACT,SAAS,GAAY;GACnB,QAAQ,MAAM,mCAAmC,MAAM,MAAM,CAAC;GAC9D;EACF;CACF;CAEA,IAAI,CAAC,cAAc,OAAO,EAAE,QAAQ;CACpC,OAAO;EAAE;EAAS,QAAQ,UAAuB,MAAM,cAAc,KAAK;CAAE;AAC9E"}
@@ -1,10 +1,10 @@
1
1
  import { AdsOptions, CONVERSION_EVENTS, Integration, IntegrationScript } from "./integration.cjs";
2
- import { googleAnalytics, sendGAEvent, setGAUser } from "./google-analytics.cjs";
3
2
  import { metaAds, sendFBEvent, setFBUser } from "./meta-pixel.cjs";
3
+ import { redditAds, sendRedditEvent, setRedditUser } from "./reddit-pixel.cjs";
4
4
  import { LinkedinConversionConfig, linkedInAds, sendLinkedinEvent, setLinkedinUser } from "./linkedin-insight-tag.cjs";
5
- import { PostHog, PostHogConfig, getLoadedPosthog, getPosthog, posthogAnalytics, posthogFlagsReady, sendPosthogEvent, setPosthogUser } from "./posthog.cjs";
6
5
  import { openaiAds, sendOpenAIEvent, setOpenAIUser } from "./openai-pixel.cjs";
7
- import { redditAds, sendRedditEvent, setRedditUser } from "./reddit-pixel.cjs";
8
6
  import { UETConsent, UETEventParams, UETItem, UETPageType, UETPid } from "../track/uetq.cjs";
9
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
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,10 +1,10 @@
1
1
  import { AdsOptions, CONVERSION_EVENTS, Integration, IntegrationScript } from "./integration.mjs";
2
- import { googleAnalytics, sendGAEvent, setGAUser } from "./google-analytics.mjs";
3
2
  import { metaAds, sendFBEvent, setFBUser } from "./meta-pixel.mjs";
3
+ import { redditAds, sendRedditEvent, setRedditUser } from "./reddit-pixel.mjs";
4
4
  import { LinkedinConversionConfig, linkedInAds, sendLinkedinEvent, setLinkedinUser } from "./linkedin-insight-tag.mjs";
5
- import { PostHog, PostHogConfig, getLoadedPosthog, getPosthog, posthogAnalytics, posthogFlagsReady, sendPosthogEvent, setPosthogUser } from "./posthog.mjs";
6
5
  import { openaiAds, sendOpenAIEvent, setOpenAIUser } from "./openai-pixel.mjs";
7
- import { redditAds, sendRedditEvent, setRedditUser } from "./reddit-pixel.mjs";
8
6
  import { UETConsent, UETEventParams, UETItem, UETPageType, UETPid } from "../track/uetq.mjs";
9
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
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 };
@@ -22,18 +22,25 @@ const CONVERSION_EVENTS = [
22
22
  "contact"
23
23
  ];
24
24
  /**
25
- * An ad tracker that sends only what `isStandard` accepts — the events the platform's mapper
26
- * turns into one of its standard events — and the custom events the host listed. Everything
27
- * else in the product (feature use, clicks, onboarding steps) is behavior analysis, which is
28
- * GA4's and PostHog's job, and only noise to an ad platform's optimization.
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.
29
31
  */
30
- function adsTracker(send, isStandard, customEvents) {
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) {
31
37
  return (name, properties, eventId) => {
32
- if (!isStandard(name) && !customEvents.includes(name)) return;
38
+ if (!accepts(name)) return;
33
39
  return send(name, properties, eventId);
34
40
  };
35
41
  }
36
42
  exports.CONVERSION_EVENTS = CONVERSION_EVENTS;
43
+ exports.adEvents = adEvents;
37
44
  exports.adsTracker = adsTracker;
38
45
 
39
46
  //# sourceMappingURL=integration.cjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"integration.cjs","names":[],"sources":["../../src/third-parties/integration.ts"],"sourcesContent":["import type { EventName, ThirdPartyTracker } 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.\n */\n customEvents?: readonly EventName[];\n}\n\n/**\n * An ad tracker that sends only what `isStandard` accepts — the events the platform's mapper\n * turns into one of its standard events — and the custom events the host listed. Everything\n * else in the product (feature use, clicks, onboarding steps) is behavior analysis, which is\n * GA4's and PostHog's job, and only noise to an ad platform's optimization.\n */\nexport function adsTracker(\n send: ThirdPartyTracker,\n isStandard: (name: string) => boolean,\n customEvents: readonly string[]\n): ThirdPartyTracker {\n return (name, properties, eventId) => {\n if (!isStandard(name) && !customEvents.includes(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;;;;;;;AAiBA,SAAgB,WACd,MACA,YACA,cACmB;CACnB,QAAQ,MAAM,YAAY,YAAY;EACpC,IAAI,CAAC,WAAW,IAAI,KAAK,CAAC,aAAa,SAAS,IAAI,GAAG;EACvD,OAAO,KAAK,MAAM,YAAY,OAAO;CACvC;AACF"}
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"}
@@ -1,4 +1,4 @@
1
- import { EventName, ThirdPartyTracker } from "../track/types.cjs";
1
+ import { ThirdPartyTracker, TrackName } from "../track/types.cjs";
2
2
  import { ThirdPartyUserSetter } from "../visitor/types.cjs";
3
3
  /**
4
4
  * The one script an integration puts on the page, rendered by `<Analytics integrations>`
@@ -43,15 +43,19 @@ export interface AdsOptions {
43
43
  /**
44
44
  * Custom events this platform receives besides the conversions it maps to its standard
45
45
  * events, e.g. one used as an optimization goal or for an audience. Everything else is not
46
- * sent to it.
46
+ * sent to it. The names `track` accepts, so with strict event names a typo is a compile error.
47
47
  */
48
- customEvents?: readonly EventName[];
48
+ customEvents?: readonly TrackName[];
49
49
  }
50
50
  /**
51
- * An ad tracker that sends only what `isStandard` accepts — the events the platform's mapper
52
- * turns into one of its standard events — and the custom events the host listed. Everything
53
- * else in the product (feature use, clicks, onboarding steps) is behavior analysis, which is
54
- * GA4's and PostHog's job, and only noise to an ad platform's optimization.
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.
55
57
  */
56
- export declare function adsTracker(send: ThirdPartyTracker, isStandard: (name: string) => boolean, customEvents: readonly string[]): ThirdPartyTracker;
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;
57
61
  //# sourceMappingURL=integration.d.cts.map
@@ -1 +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;;;;;;;;wBASV,WACd,MAAM,mBACN,aAAa,0BACb,kCACC"}
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"}
@@ -1,4 +1,4 @@
1
- import { EventName, ThirdPartyTracker } from "../track/types.mjs";
1
+ import { ThirdPartyTracker, TrackName } from "../track/types.mjs";
2
2
  import { ThirdPartyUserSetter } from "../visitor/types.mjs";
3
3
  /**
4
4
  * The one script an integration puts on the page, rendered by `<Analytics integrations>`
@@ -43,15 +43,19 @@ export interface AdsOptions {
43
43
  /**
44
44
  * Custom events this platform receives besides the conversions it maps to its standard
45
45
  * events, e.g. one used as an optimization goal or for an audience. Everything else is not
46
- * sent to it.
46
+ * sent to it. The names `track` accepts, so with strict event names a typo is a compile error.
47
47
  */
48
- customEvents?: readonly EventName[];
48
+ customEvents?: readonly TrackName[];
49
49
  }
50
50
  /**
51
- * An ad tracker that sends only what `isStandard` accepts — the events the platform's mapper
52
- * turns into one of its standard events — and the custom events the host listed. Everything
53
- * else in the product (feature use, clicks, onboarding steps) is behavior analysis, which is
54
- * GA4's and PostHog's job, and only noise to an ad platform's optimization.
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.
55
57
  */
56
- export declare function adsTracker(send: ThirdPartyTracker, isStandard: (name: string) => boolean, customEvents: readonly string[]): ThirdPartyTracker;
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;
57
61
  //# sourceMappingURL=integration.d.mts.map
@@ -1 +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;;;;;;;;wBASV,WACd,MAAM,mBACN,aAAa,0BACb,kCACC"}
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"}
@@ -21,17 +21,23 @@ const CONVERSION_EVENTS = [
21
21
  "contact"
22
22
  ];
23
23
  /**
24
- * An ad tracker that sends only what `isStandard` accepts — the events the platform's mapper
25
- * turns into one of its standard events — and the custom events the host listed. Everything
26
- * else in the product (feature use, clicks, onboarding steps) is behavior analysis, which is
27
- * GA4's and PostHog's job, and only noise to an ad platform's optimization.
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.
28
30
  */
29
- function adsTracker(send, isStandard, customEvents) {
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) {
30
36
  return (name, properties, eventId) => {
31
- if (!isStandard(name) && !customEvents.includes(name)) return;
37
+ if (!accepts(name)) return;
32
38
  return send(name, properties, eventId);
33
39
  };
34
40
  }
35
- export { CONVERSION_EVENTS, adsTracker };
41
+ export { CONVERSION_EVENTS, adEvents, adsTracker };
36
42
 
37
43
  //# sourceMappingURL=integration.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"integration.mjs","names":[],"sources":["../../src/third-parties/integration.ts"],"sourcesContent":["import type { EventName, ThirdPartyTracker } 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.\n */\n customEvents?: readonly EventName[];\n}\n\n/**\n * An ad tracker that sends only what `isStandard` accepts — the events the platform's mapper\n * turns into one of its standard events — and the custom events the host listed. Everything\n * else in the product (feature use, clicks, onboarding steps) is behavior analysis, which is\n * GA4's and PostHog's job, and only noise to an ad platform's optimization.\n */\nexport function adsTracker(\n send: ThirdPartyTracker,\n isStandard: (name: string) => boolean,\n customEvents: readonly string[]\n): ThirdPartyTracker {\n return (name, properties, eventId) => {\n if (!isStandard(name) && !customEvents.includes(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;;;;;;;AAiBA,SAAgB,WACd,MACA,YACA,cACmB;CACnB,QAAQ,MAAM,YAAY,YAAY;EACpC,IAAI,CAAC,WAAW,IAAI,KAAK,CAAC,aAAa,SAAS,IAAI,GAAG;EACvD,OAAO,KAAK,MAAM,YAAY,OAAO;CACvC;AACF"}
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,10 +26,6 @@ function setLinkedinUser({ user_data }) {
26
26
  if (!email) return;
27
27
  window.lintrk("setUserData", { email });
28
28
  }
29
- /**
30
- * LinkedIn Insight Tag: only the events in `conversions`, each sent as the conversion id it maps
31
- * to (LinkedIn conversions are created in Campaign Manager and addressed by id).
32
- */
33
29
  function linkedInAds(options) {
34
30
  return {
35
31
  type: "ads",
@@ -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';\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 */\nexport function linkedInAds(options: {\n partnerId: `${number}`;\n conversions: LinkedinConversionConfig;\n}): 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;;;;;AAMA,SAAgB,YAAY,SAGZ;CACd,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
+ {"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"}
@@ -19,8 +19,10 @@ export declare function setLinkedinUser({ user_data }: UpdateVisitorDTO): void;
19
19
  * LinkedIn Insight Tag: only the events in `conversions`, each sent as the conversion id it maps
20
20
  * to (LinkedIn conversions are created in Campaign Manager and addressed by id).
21
21
  */
22
- export declare function linkedInAds(options: {
22
+ /** LinkedIn's configuration, shared by `linkedInAds` and `linkedinConversions` on the server. */
23
+ export interface LinkedInAdsOptions {
23
24
  partnerId: `${number}`;
24
25
  conversions: LinkedinConversionConfig;
25
- }): Integration;
26
+ }
27
+ export declare function linkedInAds(options: LinkedInAdsOptions): Integration;
26
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":";;;;QAMQ;YACI;;IAER,SAAS;;;;;;;YAQD,uCAAuC,KAAK;wBAExC,kBAAkB,QAAQ,4BAChC,UAAU,WAAS,MACnB,UAAU,IAAE,cACJ,gBAAgB,IAAE;wBAgBpB,kBAAkB,aAAa;;;;;wBAe/B,YAAY;EAC1B;EACA,aAAa;IACX"}
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"}
@@ -19,8 +19,10 @@ export declare function setLinkedinUser({ user_data }: UpdateVisitorDTO): void;
19
19
  * LinkedIn Insight Tag: only the events in `conversions`, each sent as the conversion id it maps
20
20
  * to (LinkedIn conversions are created in Campaign Manager and addressed by id).
21
21
  */
22
- export declare function linkedInAds(options: {
22
+ /** LinkedIn's configuration, shared by `linkedInAds` and `linkedinConversions` on the server. */
23
+ export interface LinkedInAdsOptions {
23
24
  partnerId: `${number}`;
24
25
  conversions: LinkedinConversionConfig;
25
- }): Integration;
26
+ }
27
+ export declare function linkedInAds(options: LinkedInAdsOptions): Integration;
26
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":";;;;QAMQ;YACI;;IAER,SAAS;;;;;;;YAQD,uCAAuC,KAAK;wBAExC,kBAAkB,QAAQ,4BAChC,UAAU,WAAS,MACnB,UAAU,IAAE,cACJ,gBAAgB,IAAE;wBAgBpB,kBAAkB,aAAa;;;;;wBAe/B,YAAY;EAC1B;EACA,aAAa;IACX"}
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,10 +25,6 @@ function setLinkedinUser({ user_data }) {
25
25
  if (!email) return;
26
26
  window.lintrk("setUserData", { email });
27
27
  }
28
- /**
29
- * LinkedIn Insight Tag: only the events in `conversions`, each sent as the conversion id it maps
30
- * to (LinkedIn conversions are created in Campaign Manager and addressed by id).
31
- */
32
28
  function linkedInAds(options) {
33
29
  return {
34
30
  type: "ads",
@@ -1 +1 @@
1
- {"version":3,"file":"linkedin-insight-tag.mjs","names":[],"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 */\nexport function linkedInAds(options: {\n partnerId: `${number}`;\n conversions: LinkedinConversionConfig;\n}): 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,QAAQ,SAAS,WAAW,KAAK;CACvC,IAAI,CAAC,OAAO;CACZ,OAAO,OAAO,eAAe,EAAE,MAAM,CAAC;AACxC;;;;;AAMA,SAAgB,YAAY,SAGZ;CACd,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
+ {"version":3,"file":"linkedin-insight-tag.mjs","names":[],"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,QAAQ,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"}
@@ -44,12 +44,10 @@ function setFBUser(pixelId) {
44
44
  });
45
45
  };
46
46
  }
47
- /** Meta Pixel: the events `mapFBEvent` maps to a Meta standard event, and `customEvents`. */
48
47
  function metaAds(options) {
49
- const isStandard = (name) => require_track_fbq.mapFBEvent(name)[0] === "track";
50
48
  return {
51
49
  type: "ads",
52
- track: require_third_parties_integration.adsTracker(sendFBEvent, isStandard, options.customEvents ?? []),
50
+ track: require_third_parties_integration.adsTracker(sendFBEvent, require_third_parties_integration.adEvents(require_track_fbq.isStandardFBEvent, options.customEvents)),
53
51
  setUser: setFBUser(options.pixelId),
54
52
  script: {
55
53
  id: "meta-pixel",
@@ -1 +1 @@
1
- {"version":3,"file":"meta-pixel.cjs","names":["mapFBEvent","getFirst","adsTracker"],"sources":["../../src/third-parties/meta-pixel.ts"],"sourcesContent":["import type { UpdateVisitorDTO } from '../schema/index';\nimport { type FBQ, type PixelId, mapFBEvent } from '../track/fbq';\nimport type { EventName, TrackName, TrackProperties } from '../track/types';\nimport { getFirst } from '../utils/field';\nimport { type AdsOptions, type Integration, adsTracker } from './integration';\n\ndeclare global {\n interface Window {\n /** Undefined until the Meta Pixel script has loaded. */\n fbq?: FBQ['fbq'];\n }\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 false;\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 // The two branches are identical on purpose. `fbq` is overloaded per `type` — 'track' takes a\n // standard event name with its typed properties, 'trackCustom' an arbitrary string — and what\n // `mapFBEvent` returns is a union of both shapes. Narrowing `type` is what picks a single\n // overload; collapsing the branches leaves the call matching none of them.\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, user_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(user_data?.address);\n\n window.fbq('init', pixelId, {\n em: getFirst(user_data?.email),\n fn: address?.first_name,\n ln: address?.last_name,\n ph: getFirst(user_data?.phone_number),\n external_id: user_id,\n ct: address?.city,\n // `st` is Meta's state/province field, not the street address.\n st: address?.region,\n zp: address?.postal_code,\n country: address?.country,\n });\n };\n}\n\n/** Meta Pixel: the events `mapFBEvent` maps to a Meta standard event, and `customEvents`. */\nexport function metaAds(options: { pixelId: PixelId } & AdsOptions): Integration {\n const isStandard = (name: string) => mapFBEvent(name as TrackName)[0] === 'track';\n return {\n type: 'ads',\n track: adsTracker(sendFBEvent, isStandard, options.customEvents ?? []),\n setUser: setFBUser(options.pixelId),\n script: {\n id: 'meta-pixel',\n inline: `\n !(function (f, b, e, v, n, t, s) {\n if (f.fbq) return;\n n = f.fbq = function () {\n n.callMethod ? n.callMethod.apply(n, arguments) : n.queue.push(arguments);\n };\n if (!f._fbq) f._fbq = n;\n n.push = n;\n n.loaded = !0;\n n.version = '2.0';\n n.queue = [];\n t = b.createElement(e);\n t.async = !0;\n t.src = v;\n s = b.getElementsByTagName(e)[0];\n s.parentNode.insertBefore(t, s);\n })(window, document, 'script', 'https://connect.facebook.net/en_US/fbevents.js');\n fbq('init', ${JSON.stringify(options.pixelId)});\n fbq('track', 'PageView');\n `,\n },\n };\n}\n"],"mappings":";;;;;AAaA,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,OAAO;CACT;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,qBAAqBA,kBAAAA,WAAW,MAAM,UAAU;CAK1E,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,gBAAkC;EACnD,IAAI,OAAO,WAAW,eAAe,CAAC,OAAO,KAAK;GAChD,QAAQ,KAAK,8BAA8B;GAC3C;EACF;EAEA,MAAM,UAAUC,oBAAAA,SAAS,WAAW,OAAO;EAE3C,OAAO,IAAI,QAAQ,SAAS;GAC1B,IAAIA,oBAAAA,SAAS,WAAW,KAAK;GAC7B,IAAI,SAAS;GACb,IAAI,SAAS;GACb,IAAIA,oBAAAA,SAAS,WAAW,YAAY;GACpC,aAAa;GACb,IAAI,SAAS;GAEb,IAAI,SAAS;GACb,IAAI,SAAS;GACb,SAAS,SAAS;EACpB,CAAC;CACH;AACF;;AAGA,SAAgB,QAAQ,SAAyD;CAC/E,MAAM,cAAc,SAAiBD,kBAAAA,WAAW,IAAiB,CAAC,CAAC,OAAO;CAC1E,OAAO;EACL,MAAM;EACN,OAAOE,kCAAAA,WAAW,aAAa,YAAY,QAAQ,gBAAgB,CAAC,CAAC;EACrE,SAAS,UAAU,QAAQ,OAAO;EAClC,QAAQ;GACN,IAAI;GACJ,QAAQ;;;;;;;;;;;;;;;;;sBAiBQ,KAAK,UAAU,QAAQ,OAAO,EAAE;;;EAGlD;CACF;AACF"}
1
+ {"version":3,"file":"meta-pixel.cjs","names":["mapFBEvent","getFirst","adsTracker","adEvents","isStandardFBEvent"],"sources":["../../src/third-parties/meta-pixel.ts"],"sourcesContent":["import type { UpdateVisitorDTO } from '../schema/index';\nimport { type FBQ, type PixelId, isStandardFBEvent, mapFBEvent } from '../track/fbq';\nimport type { EventName, TrackName, TrackProperties } from '../track/types';\nimport { getFirst } from '../utils/field';\nimport { type AdsOptions, type Integration, adEvents, adsTracker } from './integration';\n\ndeclare global {\n interface Window {\n /** Undefined until the Meta Pixel script has loaded. */\n fbq?: FBQ['fbq'];\n }\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 false;\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 // The two branches are identical on purpose. `fbq` is overloaded per `type` — 'track' takes a\n // standard event name with its typed properties, 'trackCustom' an arbitrary string — and what\n // `mapFBEvent` returns is a union of both shapes. Narrowing `type` is what picks a single\n // overload; collapsing the branches leaves the call matching none of them.\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, user_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(user_data?.address);\n\n window.fbq('init', pixelId, {\n em: getFirst(user_data?.email),\n fn: address?.first_name,\n ln: address?.last_name,\n ph: getFirst(user_data?.phone_number),\n external_id: user_id,\n ct: address?.city,\n // `st` is Meta's state/province field, not the street address.\n st: address?.region,\n zp: address?.postal_code,\n country: address?.country,\n });\n };\n}\n\n/** Meta Pixel: the events `mapFBEvent` maps to a Meta standard event, and `customEvents`. */\n/** Meta's configuration, shared by `metaAds` in the browser and `metaConversions` on the server. */\nexport interface MetaAdsOptions extends AdsOptions {\n pixelId: PixelId;\n}\n\nexport function metaAds(options: MetaAdsOptions): Integration {\n return {\n type: 'ads',\n track: adsTracker(sendFBEvent, adEvents(isStandardFBEvent, options.customEvents)),\n setUser: setFBUser(options.pixelId),\n script: {\n id: 'meta-pixel',\n inline: `\n !(function (f, b, e, v, n, t, s) {\n if (f.fbq) return;\n n = f.fbq = function () {\n n.callMethod ? n.callMethod.apply(n, arguments) : n.queue.push(arguments);\n };\n if (!f._fbq) f._fbq = n;\n n.push = n;\n n.loaded = !0;\n n.version = '2.0';\n n.queue = [];\n t = b.createElement(e);\n t.async = !0;\n t.src = v;\n s = b.getElementsByTagName(e)[0];\n s.parentNode.insertBefore(t, s);\n })(window, document, 'script', 'https://connect.facebook.net/en_US/fbevents.js');\n fbq('init', ${JSON.stringify(options.pixelId)});\n fbq('track', 'PageView');\n `,\n },\n };\n}\n"],"mappings":";;;;;AAaA,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,OAAO;CACT;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,qBAAqBA,kBAAAA,WAAW,MAAM,UAAU;CAK1E,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,gBAAkC;EACnD,IAAI,OAAO,WAAW,eAAe,CAAC,OAAO,KAAK;GAChD,QAAQ,KAAK,8BAA8B;GAC3C;EACF;EAEA,MAAM,UAAUC,oBAAAA,SAAS,WAAW,OAAO;EAE3C,OAAO,IAAI,QAAQ,SAAS;GAC1B,IAAIA,oBAAAA,SAAS,WAAW,KAAK;GAC7B,IAAI,SAAS;GACb,IAAI,SAAS;GACb,IAAIA,oBAAAA,SAAS,WAAW,YAAY;GACpC,aAAa;GACb,IAAI,SAAS;GAEb,IAAI,SAAS;GACb,IAAI,SAAS;GACb,SAAS,SAAS;EACpB,CAAC;CACH;AACF;AAQA,SAAgB,QAAQ,SAAsC;CAC5D,OAAO;EACL,MAAM;EACN,OAAOC,kCAAAA,WAAW,aAAaC,kCAAAA,SAASC,kBAAAA,mBAAmB,QAAQ,YAAY,CAAC;EAChF,SAAS,UAAU,QAAQ,OAAO;EAClC,QAAQ;GACN,IAAI;GACJ,QAAQ;;;;;;;;;;;;;;;;;sBAiBQ,KAAK,UAAU,QAAQ,OAAO,EAAE;;;EAGlD;CACF;AACF"}
@@ -11,7 +11,9 @@ declare global {
11
11
  export declare function sendFBEvent<T extends EventName>(name: TrackName<T>, properties?: TrackProperties<T>, event_id?: string): false | undefined;
12
12
  export declare function setFBUser(pixelId: PixelId): ({ user_id, user_data }: UpdateVisitorDTO) => void;
13
13
  /** Meta Pixel: the events `mapFBEvent` maps to a Meta standard event, and `customEvents`. */
14
- export declare function metaAds(options: {
14
+ /** Meta's configuration, shared by `metaAds` in the browser and `metaConversions` on the server. */
15
+ export interface MetaAdsOptions extends AdsOptions {
15
16
  pixelId: PixelId;
16
- } & AdsOptions): Integration;
17
+ }
18
+ export declare function metaAds(options: MetaAdsOptions): Integration;
17
19
  //# sourceMappingURL=meta-pixel.d.cts.map
@@ -1 +1 @@
1
- {"version":3,"file":"meta-pixel.d.cts","names":[],"sources":["../../src/third-parties/meta-pixel.ts"],"mappings":";;;;QAMQ;YACI;;IAER,MAAM;;;wBAMM,YAAY,UAAU,WACpC,MAAM,UAAU,IAChB,aAAa,gBAAgB,IAC7B;wBAuBc,UAAU,SAAS,aAAO,SAAA,aACR;;wBAwBlB,QAAQ;EAAW,SAAS;IAAY,aAAa"}
1
+ {"version":3,"file":"meta-pixel.d.cts","names":[],"sources":["../../src/third-parties/meta-pixel.ts"],"mappings":";;;;QAMQ;YACI;;IAER,MAAM;;;wBAMM,YAAY,UAAU,WACpC,MAAM,UAAU,IAChB,aAAa,gBAAgB,IAC7B;wBAuBc,UAAU,SAAS,aAAO,SAAA,aACR;;;iBAyBjB,uBAAuB;EACtC,SAAS;;wBAGK,QAAQ,SAAS,iBAAiB"}
@@ -11,7 +11,9 @@ declare global {
11
11
  export declare function sendFBEvent<T extends EventName>(name: TrackName<T>, properties?: TrackProperties<T>, event_id?: string): false | undefined;
12
12
  export declare function setFBUser(pixelId: PixelId): ({ user_id, user_data }: UpdateVisitorDTO) => void;
13
13
  /** Meta Pixel: the events `mapFBEvent` maps to a Meta standard event, and `customEvents`. */
14
- export declare function metaAds(options: {
14
+ /** Meta's configuration, shared by `metaAds` in the browser and `metaConversions` on the server. */
15
+ export interface MetaAdsOptions extends AdsOptions {
15
16
  pixelId: PixelId;
16
- } & AdsOptions): Integration;
17
+ }
18
+ export declare function metaAds(options: MetaAdsOptions): Integration;
17
19
  //# sourceMappingURL=meta-pixel.d.mts.map
@@ -1 +1 @@
1
- {"version":3,"file":"meta-pixel.d.mts","names":[],"sources":["../../src/third-parties/meta-pixel.ts"],"mappings":";;;;QAMQ;YACI;;IAER,MAAM;;;wBAMM,YAAY,UAAU,WACpC,MAAM,UAAU,IAChB,aAAa,gBAAgB,IAC7B;wBAuBc,UAAU,SAAS,aAAO,SAAA,aACR;;wBAwBlB,QAAQ;EAAW,SAAS;IAAY,aAAa"}
1
+ {"version":3,"file":"meta-pixel.d.mts","names":[],"sources":["../../src/third-parties/meta-pixel.ts"],"mappings":";;;;QAMQ;YACI;;IAER,MAAM;;;wBAMM,YAAY,UAAU,WACpC,MAAM,UAAU,IAChB,aAAa,gBAAgB,IAC7B;wBAuBc,UAAU,SAAS,aAAO,SAAA,aACR;;;iBAyBjB,uBAAuB;EACtC,SAAS;;wBAGK,QAAQ,SAAS,iBAAiB"}