@shware/analytics 0.1.17 → 0.2.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 (80) hide show
  1. package/dist/index.cjs.map +1 -1
  2. package/dist/index.d.cts +3 -1
  3. package/dist/index.d.ts +3 -1
  4. package/dist/index.mjs.map +1 -1
  5. package/dist/next/index.cjs +109 -5
  6. package/dist/next/index.cjs.map +1 -1
  7. package/dist/next/index.d.cts +21 -2
  8. package/dist/next/index.d.ts +21 -2
  9. package/dist/next/index.mjs +96 -4
  10. package/dist/next/index.mjs.map +1 -1
  11. package/dist/react-router/index.cjs +98 -4
  12. package/dist/react-router/index.cjs.map +1 -1
  13. package/dist/react-router/index.d.cts +21 -2
  14. package/dist/react-router/index.d.ts +21 -2
  15. package/dist/react-router/index.mjs +95 -3
  16. package/dist/react-router/index.mjs.map +1 -1
  17. package/dist/schema/index.cjs +1 -0
  18. package/dist/schema/index.cjs.map +1 -1
  19. package/dist/schema/index.d.cts +17 -12
  20. package/dist/schema/index.d.ts +17 -12
  21. package/dist/schema/index.mjs +1 -0
  22. package/dist/schema/index.mjs.map +1 -1
  23. package/dist/server/conversions-api.cjs +246 -0
  24. package/dist/server/conversions-api.cjs.map +1 -0
  25. package/dist/server/conversions-api.d.cts +15 -0
  26. package/dist/server/conversions-api.d.ts +15 -0
  27. package/dist/server/conversions-api.mjs +227 -0
  28. package/dist/server/conversions-api.mjs.map +1 -0
  29. package/dist/setup/index.cjs.map +1 -1
  30. package/dist/setup/index.d.cts +3 -1
  31. package/dist/setup/index.d.ts +3 -1
  32. package/dist/setup/index.mjs.map +1 -1
  33. package/dist/track/fbq.cjs +142 -0
  34. package/dist/track/fbq.cjs.map +1 -0
  35. package/dist/track/fbq.d.cts +279 -0
  36. package/dist/track/fbq.d.ts +279 -0
  37. package/dist/track/fbq.mjs +115 -0
  38. package/dist/track/fbq.mjs.map +1 -0
  39. package/dist/track/{ga.cjs → gtag.cjs} +38 -51
  40. package/dist/track/gtag.cjs.map +1 -0
  41. package/dist/track/gtag.d.cts +525 -0
  42. package/dist/track/gtag.d.ts +525 -0
  43. package/dist/track/gtag.mjs +64 -0
  44. package/dist/track/gtag.mjs.map +1 -0
  45. package/dist/track/index.cjs.map +1 -1
  46. package/dist/track/index.d.cts +3 -2
  47. package/dist/track/index.d.ts +3 -2
  48. package/dist/track/index.mjs.map +1 -1
  49. package/dist/{types/index.cjs → track/types.cjs} +2 -2
  50. package/dist/track/types.cjs.map +1 -0
  51. package/dist/track/types.d.cts +116 -0
  52. package/dist/track/types.d.ts +116 -0
  53. package/dist/track/types.mjs +1 -0
  54. package/dist/visitor/index.cjs.map +1 -1
  55. package/dist/visitor/index.d.cts +1 -1
  56. package/dist/visitor/index.d.ts +1 -1
  57. package/dist/visitor/index.mjs.map +1 -1
  58. package/dist/visitor/types.cjs +19 -0
  59. package/dist/visitor/types.cjs.map +1 -0
  60. package/dist/visitor/types.d.cts +16 -0
  61. package/dist/visitor/types.d.ts +16 -0
  62. package/dist/visitor/types.mjs +1 -0
  63. package/dist/visitor/types.mjs.map +1 -0
  64. package/dist/web/index.cjs +4 -0
  65. package/dist/web/index.cjs.map +1 -1
  66. package/dist/web/index.d.cts +2 -1
  67. package/dist/web/index.d.ts +2 -1
  68. package/dist/web/index.mjs +4 -0
  69. package/dist/web/index.mjs.map +1 -1
  70. package/package.json +11 -1
  71. package/dist/track/ga.cjs.map +0 -1
  72. package/dist/track/ga.d.cts +0 -4
  73. package/dist/track/ga.d.ts +0 -4
  74. package/dist/track/ga.mjs +0 -76
  75. package/dist/track/ga.mjs.map +0 -1
  76. package/dist/types/index.cjs.map +0 -1
  77. package/dist/types/index.d.cts +0 -327
  78. package/dist/types/index.d.ts +0 -327
  79. package/dist/types/index.mjs +0 -1
  80. /package/dist/{types/index.mjs.map → track/types.mjs.map} +0 -0
@@ -0,0 +1,279 @@
1
+ import { Item } from './gtag.js';
2
+ import { EventName, TrackName, TrackProperties } from './types.js';
3
+
4
+ type Content = {
5
+ id: string;
6
+ quantity: number;
7
+ item_price?: number;
8
+ title?: string;
9
+ description?: string;
10
+ brand?: string;
11
+ category?: string;
12
+ delivery_category?: string;
13
+ };
14
+ /**
15
+ * reference: https://developers.facebook.com/docs/meta-pixel/advanced/advanced-matching
16
+ * reference: https://developers.facebook.com/docs/marketing-api/conversions-api/parameters/customer-information-parameters
17
+ */
18
+ type MatchingParameters = {
19
+ /** Email: Unhashed lowercase or hashed SHA-256 */
20
+ em?: string;
21
+ /** First Name: Lowercase letters */
22
+ fn?: string;
23
+ /** Last Name: Lowercase letters */
24
+ ln?: string;
25
+ /** Phone Number: Digits only including country code and area code */
26
+ ph?: string;
27
+ /**
28
+ * External ID: Any unique ID from the advertiser, such as loyalty membership ID, user ID, and
29
+ * external cookie ID.
30
+ */
31
+ external_id?: string;
32
+ /** Gender: Single lowercase letter, f or m, if unknown, leave blank */
33
+ ge?: 'f' | 'm' | '';
34
+ /** Birthdate: Digits only with birth year, month, then day, YYYYMMDD */
35
+ db?: number;
36
+ /** City: Lowercase with any spaces removed, e.g. "menlopark" */
37
+ ct?: string;
38
+ /** State or Province: Lowercase two-letter state or province code, e.g. "ca" */
39
+ st?: string;
40
+ /** Zip or Postal Code: String */
41
+ zp?: string;
42
+ /** Country: Lowercase two-letter country code, e.g. "us" */
43
+ country?: string;
44
+ /** Client IP Address: Do not hash. */
45
+ client_ip_address?: string;
46
+ /** Client User Agent: Do not hash. */
47
+ client_user_agent?: string;
48
+ /**
49
+ * Click ID: Do not hash.
50
+ * The Facebook click ID value is stored in the _fbc browser cookie under your domain. See
51
+ * Managing fbc and fbp Parameters for how to get this value or generate this value from a fbclid
52
+ * query parameter.
53
+ *
54
+ * The format is fb.${subdomain_index}.${creation_time}.${fbclid}.
55
+ */
56
+ fbc?: string;
57
+ /**
58
+ * Browser ID: Do not hash.
59
+ * The Facebook browser ID value is stored in the _fbp browser cookie under your domain. See
60
+ * Managing fbc and fbp Parameters for how to get this value.
61
+ *
62
+ * The format is fb.${subdomain_index}.${creation_time}.${random_number}.
63
+ */
64
+ fbp?: string;
65
+ /**
66
+ * Subscription ID: Do not hash.
67
+ * The subscription ID for the user in this transaction; it is similar to the order ID for an
68
+ * individual product.
69
+ */
70
+ subscription_id?: string;
71
+ /**
72
+ * Facebook Login ID: Do not hash.
73
+ * The ID issued by Meta when a person first logs into an instance of an app. This is also known
74
+ * as App-Scoped ID.
75
+ */
76
+ fb_login_id?: number;
77
+ /**
78
+ * Lead ID: Do not hash.
79
+ * The ID associated with a lead generated by [Meta's Lead Ads](https://developers.facebook.com/docs/marketing-api/guides/lead-ads).
80
+ */
81
+ lead_id?: number;
82
+ /**
83
+ * Install ID: Do not hash.
84
+ * Your install ID. This field represents unique application installation instances.
85
+ * Note: This parameter is for app events only.
86
+ */
87
+ anon_id?: string;
88
+ /**
89
+ * Your mobile advertiser ID, the advertising ID from an Android device or the Advertising
90
+ * Identifier (IDFA) from an Apple device.
91
+ */
92
+ madid?: string;
93
+ /**
94
+ * Page ID: Do not hash.
95
+ * Your Page ID. Specifies the page ID associated with the event. Use the Facebook page ID of the
96
+ * page associated with the bot.
97
+ */
98
+ page_id?: string;
99
+ /**
100
+ * Page Scoped User ID: Do not hash.
101
+ * Specifies the page-scoped user ID associated with the messenger bot that logs the event. Use
102
+ * the page-scoped user ID provided to your webhook.
103
+ */
104
+ page_scoped_user_id?: string;
105
+ /**
106
+ * Do not hash.
107
+ * Click ID generated by Meta for ads that click to WhatsApp.
108
+ */
109
+ ctwa_clid?: string;
110
+ /**
111
+ * Do not hash.
112
+ * Instagram Account ID that is associated with the business.
113
+ */
114
+ ig_account_id?: string;
115
+ /**
116
+ * Do not hash.
117
+ * Users who interact with Instagram are identified by Instagram-Scoped User IDs (IGSID). IGSID
118
+ * can be obtained from this webhook.
119
+ */
120
+ ig_sid?: string;
121
+ };
122
+ /**
123
+ * You can include the following predefined object properties with any custom events, and any
124
+ * standard events that support them. Format your parameter object data using JSON. Learn more about
125
+ * event parameters with Blueprint.
126
+ */
127
+ type ObjectProperties = {
128
+ content_category?: string;
129
+ content_ids?: string[];
130
+ content_name?: string;
131
+ /**
132
+ * Either product or product_group based on the content_ids or contents being passed. If the IDs
133
+ * being passed in content_ids or contents parameter are IDs of products, then the value should be
134
+ * product. If product group IDs are being passed, then the value should be product_group.
135
+ *
136
+ * If no content_type is provided, Meta will match the event to every item that has the same ID,
137
+ * independent of its type.
138
+ */
139
+ content_type?: 'product' | 'product_group' | (string & {});
140
+ contents?: Content[];
141
+ delivery_category?: 'in_store' | 'curbside' | 'home_delivery';
142
+ currency?: string;
143
+ num_items?: number;
144
+ predicted_ltv?: number;
145
+ search_string?: string;
146
+ /** Used with the CompleteRegistration event, to show the status of the registration. */
147
+ status?: boolean;
148
+ value?: number;
149
+ };
150
+ /**
151
+ * reference: https://developers.facebook.com/docs/marketing-api/conversions-api/payload-helper
152
+ */
153
+ type StandardEvents = {
154
+ AddPaymentInfo: {
155
+ content_ids?: string[];
156
+ contents?: Content[];
157
+ currency?: string;
158
+ value?: number;
159
+ };
160
+ AddToCart: {
161
+ content_ids?: string[];
162
+ content_type?: string;
163
+ contents?: Content[];
164
+ currency?: string;
165
+ value?: number;
166
+ };
167
+ AddToWishlist: {
168
+ content_ids?: string[];
169
+ contents?: Content[];
170
+ currency?: string;
171
+ value?: number;
172
+ };
173
+ CompleteRegistration: {
174
+ currency?: string;
175
+ value?: number;
176
+ method?: string;
177
+ };
178
+ Contact: {};
179
+ CustomizeProduct: {};
180
+ Donate: {};
181
+ FindLocation: {};
182
+ InitiateCheckout: {
183
+ content_ids?: string[];
184
+ contents?: Content[];
185
+ currency?: string;
186
+ num_items?: number;
187
+ value?: number;
188
+ };
189
+ Lead: {
190
+ currency?: string;
191
+ value?: number;
192
+ };
193
+ Purchase: {
194
+ content_ids?: string[];
195
+ content_type?: string;
196
+ contents?: Content[];
197
+ currency: string;
198
+ num_items?: number;
199
+ value: number;
200
+ };
201
+ Schedule: {};
202
+ Search: {
203
+ content_ids?: string[];
204
+ content_type?: string;
205
+ contents?: Content[];
206
+ currency?: string;
207
+ search_string?: string;
208
+ value?: number;
209
+ };
210
+ StartTrial: {
211
+ currency?: string;
212
+ predicted_ltv?: number;
213
+ value?: number;
214
+ };
215
+ SubmitApplication: {};
216
+ Subscribe: {
217
+ currency?: string;
218
+ predicted_ltv?: number;
219
+ value?: number;
220
+ };
221
+ ViewContent: {
222
+ content_ids?: string[];
223
+ content_type?: string;
224
+ contents?: Content[];
225
+ currency?: string;
226
+ value?: number;
227
+ };
228
+ };
229
+ type JSONValue = null | string | number | boolean | Array<JSONValue> | {
230
+ [value: string]: JSONValue;
231
+ };
232
+ type PixelId = `${number}`;
233
+ type Options = {
234
+ eventID?: string;
235
+ };
236
+ /**
237
+ * reference: https://developers.facebook.com/docs/meta-pixel/reference#standard-events
238
+ *
239
+ * We determine if events are identical based on their ID and name. So, for an event to be deduplicated:
240
+ * - In corresponding events, a Meta Pixel's eventID must match the Conversion API's event_id.
241
+ * - In corresponding events, a Meta Pixel's event must match the Conversion API's event_name.
242
+ *
243
+ * reference: https://developers.facebook.com/docs/marketing-api/conversions-api/parameters/customer-information-parameters
244
+ */
245
+ interface Pixel {
246
+ /**
247
+ * reference: https://stackoverflow.com/questions/62304291/sending-user-data-parameters-via-pixel
248
+ *
249
+ * Call init the normal default way first:
250
+ * `fbq('init', 'XXXXX')`
251
+ *
252
+ * And at a later point in time, when you have obtained additional user data, you can call init
253
+ * again basically enriching the already running fbq instance with additional data:
254
+ * `fbq('init', 'XXXXX', { external_id: 1234, em: 'abc@abc.com' } )`
255
+ *
256
+ * Only caveat is that you have to send an event after this additional init call, otherwise the
257
+ * provided data will not be sent to Facebook.
258
+ */
259
+ fbq(type: 'init', pixelId: PixelId, parameters?: MatchingParameters): void;
260
+ /** Enable Manual Only mode. (value = false) */
261
+ fbq(type: 'set', key: 'autoConfig', value: boolean, pixelId: PixelId): void;
262
+ fbq<T extends keyof StandardEvents>(type: 'track', event: T, properties?: StandardEvents[T] & ObjectProperties, options?: Options): void;
263
+ fbq(type: 'trackCustom', event: string, properties?: Record<string, JSONValue> & ObjectProperties, options?: Options): void;
264
+ /** https://developers.facebook.com/docs/meta-pixel/guides/track-multiple-events/ */
265
+ fbq<T extends keyof StandardEvents>(type: 'trackSingle', pixelId: PixelId, event: T, properties?: StandardEvents[T] & ObjectProperties, options?: Options): void;
266
+ /** https://developers.facebook.com/docs/meta-pixel/guides/track-multiple-events/ */
267
+ fbq(type: 'trackSingleCustom', pixelId: PixelId, event: string, properties?: Record<string, JSONValue> & ObjectProperties, options?: Options): void;
268
+ }
269
+ /**
270
+ * Please download this CSV filefor examples of properly normalized and hashed data for the
271
+ * parameters below.
272
+ */
273
+ declare function normalize(parameters: MatchingParameters): MatchingParameters;
274
+ declare function mapItems(items?: Item[]): ObjectProperties;
275
+ type Mapped<F extends keyof StandardEvents> = ['track', F, StandardEvents[F] & ObjectProperties];
276
+ type Missed<F extends string> = ['trackCustom', F, Record<string, JSONValue> & ObjectProperties];
277
+ declare function mapFBEvent<T extends EventName>(name: TrackName<T>, properties?: TrackProperties<T>): Mapped<keyof StandardEvents> | Missed<TrackName<T>>;
278
+
279
+ export { type Content, type MatchingParameters, type ObjectProperties, type Options, type Pixel, type PixelId, type StandardEvents, mapFBEvent, mapItems, normalize };
@@ -0,0 +1,115 @@
1
+ // src/track/fbq.ts
2
+ function normalize(parameters) {
3
+ var _a, _b, _c, _d, _e, _f, _g, _h, _i;
4
+ return {
5
+ ...parameters,
6
+ em: (_a = parameters.em) == null ? void 0 : _a.toLowerCase().trim(),
7
+ ph: (_b = parameters.ph) == null ? void 0 : _b.replace(/[\+\-\(\)\s]/g, "").replace(/^0+/, ""),
8
+ zp: (_d = (_c = parameters.zp) == null ? void 0 : _c.split("-").at(0)) == null ? void 0 : _d.trim(),
9
+ fn: (_e = parameters.fn) == null ? void 0 : _e.toLowerCase().trim(),
10
+ ln: (_f = parameters.ln) == null ? void 0 : _f.toLowerCase().trim(),
11
+ ct: (_g = parameters.ct) == null ? void 0 : _g.toLowerCase().replace(/[s/-]/g, "").trim(),
12
+ st: (_h = parameters.st) == null ? void 0 : _h.toLowerCase().replace(/[s/-/,.]/g, "").trim(),
13
+ country: (_i = parameters.country) == null ? void 0 : _i.toLowerCase().replace(/[s/-]/g, "").trim()
14
+ };
15
+ }
16
+ function mapItems(items) {
17
+ if (!items) return {};
18
+ const categories = Array.from(new Set(items.map((i) => i.item_category).filter(Boolean)));
19
+ const contents = items.map(
20
+ ({ item_id, quantity, price, item_name, item_brand, item_category, ...others }) => ({
21
+ id: item_id,
22
+ quantity: quantity ?? 1,
23
+ item_price: price,
24
+ title: item_name,
25
+ brand: item_brand,
26
+ category: item_category
27
+ })
28
+ );
29
+ return {
30
+ content_category: categories.length === 1 ? categories.at(0) : void 0,
31
+ contents,
32
+ content_ids: contents.map((c) => c.id),
33
+ num_items: items.reduce((acc, i) => acc + (i.quantity ?? 1), 0)
34
+ };
35
+ }
36
+ function mapFBEvent(name, properties) {
37
+ if (name === "add_payment_info") {
38
+ const p = properties;
39
+ return [
40
+ "track",
41
+ "AddPaymentInfo",
42
+ { currency: p == null ? void 0 : p.currency, value: p == null ? void 0 : p.value, ...mapItems(p == null ? void 0 : p.items) }
43
+ ];
44
+ } else if (name === "add_to_cart") {
45
+ const p = properties;
46
+ return [
47
+ "track",
48
+ "AddToCart",
49
+ { currency: p == null ? void 0 : p.currency, value: p == null ? void 0 : p.value, ...mapItems(p == null ? void 0 : p.items) }
50
+ ];
51
+ } else if (name === "add_to_wishlist") {
52
+ const p = properties;
53
+ return [
54
+ "track",
55
+ "AddToWishlist",
56
+ { currency: p == null ? void 0 : p.currency, value: p == null ? void 0 : p.value, ...mapItems(p == null ? void 0 : p.items) }
57
+ ];
58
+ } else if (name === "login") {
59
+ const p = properties;
60
+ return ["track", "CompleteRegistration", { method: p == null ? void 0 : p.method }];
61
+ } else if (name === "contact") {
62
+ return ["track", "Contact", {}];
63
+ } else if (name === "customize_product") {
64
+ return ["track", "CustomizeProduct", {}];
65
+ } else if (name === "donate") {
66
+ return ["track", "Donate", {}];
67
+ } else if (name === "find_location") {
68
+ return ["track", "FindLocation", {}];
69
+ } else if (name === "begin_checkout") {
70
+ const p = properties;
71
+ return [
72
+ "track",
73
+ "InitiateCheckout",
74
+ { currency: p == null ? void 0 : p.currency, value: p == null ? void 0 : p.value, ...mapItems(p == null ? void 0 : p.items) }
75
+ ];
76
+ } else if (name === "generate_lead") {
77
+ const p = properties;
78
+ return ["track", "Lead", { currency: p == null ? void 0 : p.currency, value: p == null ? void 0 : p.value }];
79
+ } else if (name === "purchase") {
80
+ const p = properties;
81
+ return [
82
+ "track",
83
+ "Purchase",
84
+ { currency: (p == null ? void 0 : p.currency) ?? "usd", value: (p == null ? void 0 : p.value) ?? 0, ...mapItems(p == null ? void 0 : p.items) }
85
+ ];
86
+ } else if (name === "schedule") {
87
+ return ["track", "Schedule", {}];
88
+ } else if (name === "search") {
89
+ const p = properties;
90
+ return ["track", "Search", { search_string: p == null ? void 0 : p.search_term }];
91
+ } else if (name === "trial_begin") {
92
+ const p = properties;
93
+ return ["track", "StartTrial", { currency: p == null ? void 0 : p.currency, value: p == null ? void 0 : p.value }];
94
+ } else if (name === "submit_application") {
95
+ return ["track", "SubmitApplication", {}];
96
+ } else if (name === "subscribe") {
97
+ const p = properties;
98
+ return ["track", "Subscribe", { currency: p == null ? void 0 : p.currency, value: p == null ? void 0 : p.value }];
99
+ } else if (name === "view_item") {
100
+ const p = properties;
101
+ return [
102
+ "track",
103
+ "ViewContent",
104
+ { currency: p == null ? void 0 : p.currency, value: p == null ? void 0 : p.value, ...mapItems(p == null ? void 0 : p.items) }
105
+ ];
106
+ } else {
107
+ return ["trackCustom", name, properties ?? {}];
108
+ }
109
+ }
110
+ export {
111
+ mapFBEvent,
112
+ mapItems,
113
+ normalize
114
+ };
115
+ //# sourceMappingURL=fbq.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/track/fbq.ts"],"sourcesContent":["import type { Item } from './gtag';\nimport type { EventName, TrackName, TrackProperties } from './types';\n\nexport type Content = {\n id: string;\n quantity: number;\n item_price?: number;\n title?: string;\n description?: string;\n brand?: string;\n category?: string;\n delivery_category?: string;\n};\n\n/**\n * reference: https://developers.facebook.com/docs/meta-pixel/advanced/advanced-matching\n * reference: https://developers.facebook.com/docs/marketing-api/conversions-api/parameters/customer-information-parameters\n */\nexport type MatchingParameters = {\n /** Email: Unhashed lowercase or hashed SHA-256 */\n em?: string;\n\n /** First Name: Lowercase letters */\n fn?: string;\n\n /** Last Name: Lowercase letters */\n ln?: string;\n\n /** Phone Number: Digits only including country code and area code */\n ph?: string;\n\n /**\n * External ID: Any unique ID from the advertiser, such as loyalty membership ID, user ID, and\n * external cookie ID.\n */\n external_id?: string;\n\n /** Gender: Single lowercase letter, f or m, if unknown, leave blank */\n ge?: 'f' | 'm' | '';\n\n /** Birthdate: Digits only with birth year, month, then day, YYYYMMDD */\n db?: number;\n\n /** City: Lowercase with any spaces removed, e.g. \"menlopark\" */\n ct?: string;\n\n /** State or Province: Lowercase two-letter state or province code, e.g. \"ca\" */\n st?: string;\n\n /** Zip or Postal Code: String */\n zp?: string;\n\n /** Country: Lowercase two-letter country code, e.g. \"us\" */\n country?: string;\n\n /** Client IP Address: Do not hash. */\n client_ip_address?: string;\n\n /** Client User Agent: Do not hash. */\n client_user_agent?: string;\n\n /**\n * Click ID: Do not hash.\n * The Facebook click ID value is stored in the _fbc browser cookie under your domain. See\n * Managing fbc and fbp Parameters for how to get this value or generate this value from a fbclid\n * query parameter.\n *\n * The format is fb.${subdomain_index}.${creation_time}.${fbclid}.\n */\n fbc?: string;\n\n /**\n * Browser ID: Do not hash.\n * The Facebook browser ID value is stored in the _fbp browser cookie under your domain. See\n * Managing fbc and fbp Parameters for how to get this value.\n *\n * The format is fb.${subdomain_index}.${creation_time}.${random_number}.\n */\n fbp?: string;\n\n /**\n * Subscription ID: Do not hash.\n * The subscription ID for the user in this transaction; it is similar to the order ID for an\n * individual product.\n */\n subscription_id?: string;\n\n /**\n * Facebook Login ID: Do not hash.\n * The ID issued by Meta when a person first logs into an instance of an app. This is also known\n * as App-Scoped ID.\n */\n fb_login_id?: number;\n\n /**\n * Lead ID: Do not hash.\n * The ID associated with a lead generated by [Meta's Lead Ads](https://developers.facebook.com/docs/marketing-api/guides/lead-ads).\n */\n lead_id?: number;\n\n /**\n * Install ID: Do not hash.\n * Your install ID. This field represents unique application installation instances.\n * Note: This parameter is for app events only.\n */\n anon_id?: string;\n\n /**\n * Your mobile advertiser ID, the advertising ID from an Android device or the Advertising\n * Identifier (IDFA) from an Apple device.\n */\n madid?: string;\n\n /**\n * Page ID: Do not hash.\n * Your Page ID. Specifies the page ID associated with the event. Use the Facebook page ID of the\n * page associated with the bot.\n */\n page_id?: string;\n\n /**\n * Page Scoped User ID: Do not hash.\n * Specifies the page-scoped user ID associated with the messenger bot that logs the event. Use\n * the page-scoped user ID provided to your webhook.\n */\n page_scoped_user_id?: string;\n\n /**\n * Do not hash.\n * Click ID generated by Meta for ads that click to WhatsApp.\n */\n ctwa_clid?: string;\n\n /**\n * Do not hash.\n * Instagram Account ID that is associated with the business.\n */\n ig_account_id?: string;\n\n /**\n * Do not hash.\n * Users who interact with Instagram are identified by Instagram-Scoped User IDs (IGSID). IGSID\n * can be obtained from this webhook.\n */\n ig_sid?: string;\n};\n\n/**\n * You can include the following predefined object properties with any custom events, and any\n * standard events that support them. Format your parameter object data using JSON. Learn more about\n * event parameters with Blueprint.\n */\nexport type ObjectProperties = {\n content_category?: string;\n content_ids?: string[];\n content_name?: string;\n\n /**\n * Either product or product_group based on the content_ids or contents being passed. If the IDs\n * being passed in content_ids or contents parameter are IDs of products, then the value should be\n * product. If product group IDs are being passed, then the value should be product_group.\n *\n * If no content_type is provided, Meta will match the event to every item that has the same ID,\n * independent of its type.\n */\n content_type?: 'product' | 'product_group' | (string & {});\n contents?: Content[];\n delivery_category?: 'in_store' | 'curbside' | 'home_delivery';\n currency?: string;\n num_items?: number;\n predicted_ltv?: number;\n search_string?: string;\n\n /** Used with the CompleteRegistration event, to show the status of the registration. */\n status?: boolean;\n value?: number;\n};\n\n/**\n * reference: https://developers.facebook.com/docs/marketing-api/conversions-api/payload-helper\n */\nexport type StandardEvents = {\n AddPaymentInfo: {\n content_ids?: string[];\n contents?: Content[];\n currency?: string;\n value?: number;\n };\n AddToCart: {\n content_ids?: string[];\n content_type?: string;\n contents?: Content[]; // Required for Advantage+ catalog ads: contents\n currency?: string;\n value?: number;\n };\n AddToWishlist: {\n content_ids?: string[];\n contents?: Content[];\n currency?: string;\n value?: number;\n };\n CompleteRegistration: {\n currency?: string;\n value?: number;\n method?: string;\n };\n Contact: {};\n CustomizeProduct: {};\n Donate: {};\n FindLocation: {};\n InitiateCheckout: {\n content_ids?: string[];\n contents?: Content[];\n currency?: string;\n num_items?: number;\n value?: number;\n };\n Lead: {\n currency?: string;\n value?: number;\n };\n Purchase: {\n content_ids?: string[]; // Required for Advantage+ catalog ads: contents or content_ids\n content_type?: string;\n contents?: Content[]; // Required for Advantage+ catalog ads: contents or content_ids\n currency: string; // required\n num_items?: number;\n value: number; // required\n };\n Schedule: {};\n Search: {\n content_ids?: string[]; // Required for Advantage+ catalog ads: contents or content_ids\n content_type?: string;\n contents?: Content[]; // Required for Advantage+ catalog ads: contents or content_ids\n currency?: string;\n search_string?: string;\n value?: number;\n };\n StartTrial: {\n currency?: string;\n predicted_ltv?: number;\n value?: number;\n };\n SubmitApplication: {};\n Subscribe: {\n currency?: string;\n predicted_ltv?: number;\n value?: number;\n };\n ViewContent: {\n content_ids?: string[]; // Required for Advantage+ catalog ads: contents or content_ids\n content_type?: string;\n contents?: Content[]; // Required for Advantage+ catalog ads: contents or content_ids\n currency?: string;\n value?: number;\n };\n};\n\ntype JSONValue =\n | null\n | string\n | number\n | boolean\n | Array<JSONValue>\n | { [value: string]: JSONValue };\n\nexport type PixelId = `${number}`;\nexport type Options = { eventID?: string };\n\n/**\n * reference: https://developers.facebook.com/docs/meta-pixel/reference#standard-events\n *\n * We determine if events are identical based on their ID and name. So, for an event to be deduplicated:\n * - In corresponding events, a Meta Pixel's eventID must match the Conversion API's event_id.\n * - In corresponding events, a Meta Pixel's event must match the Conversion API's event_name.\n *\n * reference: https://developers.facebook.com/docs/marketing-api/conversions-api/parameters/customer-information-parameters\n */\nexport interface Pixel {\n /**\n * reference: https://stackoverflow.com/questions/62304291/sending-user-data-parameters-via-pixel\n *\n * Call init the normal default way first:\n * `fbq('init', 'XXXXX')`\n *\n * And at a later point in time, when you have obtained additional user data, you can call init\n * again basically enriching the already running fbq instance with additional data:\n * `fbq('init', 'XXXXX', { external_id: 1234, em: 'abc@abc.com' } )`\n *\n * Only caveat is that you have to send an event after this additional init call, otherwise the\n * provided data will not be sent to Facebook.\n */\n fbq(type: 'init', pixelId: PixelId, parameters?: MatchingParameters): void;\n\n /** Enable Manual Only mode. (value = false) */\n fbq(type: 'set', key: 'autoConfig', value: boolean, pixelId: PixelId): void;\n\n fbq<T extends keyof StandardEvents>(\n type: 'track',\n event: T,\n properties?: StandardEvents[T] & ObjectProperties,\n options?: Options\n ): void;\n\n fbq(\n type: 'trackCustom',\n event: string,\n properties?: Record<string, JSONValue> & ObjectProperties,\n options?: Options\n ): void;\n\n /** https://developers.facebook.com/docs/meta-pixel/guides/track-multiple-events/ */\n fbq<T extends keyof StandardEvents>(\n type: 'trackSingle',\n pixelId: PixelId,\n event: T,\n properties?: StandardEvents[T] & ObjectProperties,\n options?: Options\n ): void;\n\n /** https://developers.facebook.com/docs/meta-pixel/guides/track-multiple-events/ */\n fbq(\n type: 'trackSingleCustom',\n pixelId: PixelId,\n event: string,\n properties?: Record<string, JSONValue> & ObjectProperties,\n options?: Options\n ): void;\n}\n\n/**\n * Please download this CSV filefor examples of properly normalized and hashed data for the\n * parameters below.\n */\nexport function normalize(parameters: MatchingParameters): MatchingParameters {\n return {\n ...parameters,\n em: parameters.em?.toLowerCase().trim(),\n ph: parameters.ph?.replace(/[\\+\\-\\(\\)\\s]/g, '').replace(/^0+/, ''),\n zp: parameters.zp?.split('-').at(0)?.trim(),\n fn: parameters.fn?.toLowerCase().trim(),\n ln: parameters.ln?.toLowerCase().trim(),\n ct: parameters.ct?.toLowerCase().replace(/[s/-]/g, '').trim(),\n st: parameters.st\n ?.toLowerCase()\n .replace(/[s/-/,.]/g, '')\n .trim(),\n country: parameters.country?.toLowerCase().replace(/[s/-]/g, '').trim(),\n };\n}\n\nexport function mapItems(items?: Item[]): ObjectProperties {\n if (!items) return {};\n const categories = Array.from(new Set(items.map((i) => i.item_category).filter(Boolean)));\n const contents: Content[] = items.map(\n ({ item_id, quantity, price, item_name, item_brand, item_category, ...others }) => ({\n id: item_id!,\n quantity: quantity ?? 1,\n item_price: price,\n title: item_name,\n brand: item_brand,\n category: item_category,\n })\n );\n\n return {\n content_category: categories.length === 1 ? categories.at(0) : undefined,\n contents,\n content_ids: contents.map((c) => c.id),\n num_items: items.reduce((acc, i) => acc + (i.quantity ?? 1), 0),\n };\n}\n\ntype Mapped<F extends keyof StandardEvents> = ['track', F, StandardEvents[F] & ObjectProperties];\ntype Missed<F extends string> = ['trackCustom', F, Record<string, JSONValue> & ObjectProperties];\n\nexport function mapFBEvent<T extends EventName>(\n name: TrackName<T>,\n properties?: TrackProperties<T>\n): Mapped<keyof StandardEvents> | Missed<TrackName<T>> {\n if (name === 'add_payment_info') {\n const p = properties as TrackProperties<'add_payment_info'> | undefined;\n return [\n 'track',\n 'AddPaymentInfo',\n { currency: p?.currency, value: p?.value, ...mapItems(p?.items) },\n ];\n } else if (name === 'add_to_cart') {\n const p = properties as TrackProperties<'add_to_cart'> | undefined;\n return [\n 'track',\n 'AddToCart',\n { currency: p?.currency, value: p?.value, ...mapItems(p?.items) },\n ];\n } else if (name === 'add_to_wishlist') {\n const p = properties as TrackProperties<'add_to_wishlist'> | undefined;\n return [\n 'track',\n 'AddToWishlist',\n { currency: p?.currency, value: p?.value, ...mapItems(p?.items) },\n ];\n } else if (name === 'login') {\n const p = properties as TrackProperties<'login'> | undefined;\n return ['track', 'CompleteRegistration', { method: p?.method }];\n } else if (name === 'contact') {\n return ['track', 'Contact', {}];\n } else if (name === 'customize_product') {\n return ['track', 'CustomizeProduct', {}];\n } else if (name === 'donate') {\n return ['track', 'Donate', {}];\n } else if (name === 'find_location') {\n return ['track', 'FindLocation', {}];\n } else if (name === 'begin_checkout') {\n const p = properties as TrackProperties<'begin_checkout'> | undefined;\n return [\n 'track',\n 'InitiateCheckout',\n { currency: p?.currency, value: p?.value, ...mapItems(p?.items) },\n ];\n } else if (name === 'generate_lead') {\n const p = properties as TrackProperties<'generate_lead'> | undefined;\n return ['track', 'Lead', { currency: p?.currency, value: p?.value }];\n } else if (name === 'purchase') {\n const p = properties as TrackProperties<'purchase'> | undefined;\n return [\n 'track',\n 'Purchase',\n { currency: p?.currency ?? 'usd', value: p?.value ?? 0, ...mapItems(p?.items) },\n ];\n } else if (name === 'schedule') {\n return ['track', 'Schedule', {}];\n } else if (name === 'search') {\n const p = properties as TrackProperties<'search'> | undefined;\n return ['track', 'Search', { search_string: p?.search_term }];\n } else if (name === 'trial_begin') {\n const p = properties as TrackProperties<'trial_begin'> | undefined;\n return ['track', 'StartTrial', { currency: p?.currency, value: p?.value }];\n } else if (name === 'submit_application') {\n return ['track', 'SubmitApplication', {}];\n } else if (name === 'subscribe') {\n const p = properties as TrackProperties<'subscribe'> | undefined;\n return ['track', 'Subscribe', { currency: p?.currency, value: p?.value }];\n } else if (name === 'view_item') {\n const p = properties as TrackProperties<'view_item'> | undefined;\n return [\n 'track',\n 'ViewContent',\n { currency: p?.currency, value: p?.value, ...mapItems(p?.items) },\n ];\n } else {\n return ['trackCustom', name, properties ?? {}];\n }\n}\n"],"mappings":"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","names":[]}
@@ -17,71 +17,57 @@ var __copyProps = (to, from, except, desc) => {
17
17
  };
18
18
  var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
19
 
20
- // src/track/ga.ts
21
- var ga_exports = {};
22
- __export(ga_exports, {
23
- reservedEventNames: () => reservedEventNames,
24
- standardEventNames: () => standardEventNames
20
+ // src/track/gtag.ts
21
+ var gtag_exports = {};
22
+ __export(gtag_exports, {
23
+ reservedEventNames: () => reservedEventNames
25
24
  });
26
- module.exports = __toCommonJS(ga_exports);
27
- var standardEventNames = [
28
- "add_payment_info",
29
- "add_shipping_info",
30
- "add_to_cart",
31
- "add_to_wishlist",
32
- "begin_checkout",
33
- "close_convert_lead",
34
- "close_unconvert_lead",
35
- "disqualify_lead",
36
- "earn_virtual_currency",
37
- "generate_lead",
38
- "join_group",
39
- "level_end",
40
- "level_start",
41
- "level_up",
42
- "login",
43
- "post_score",
44
- "purchase",
45
- "qualify_lead",
46
- "refund",
47
- "remove_from_cart",
48
- "search",
49
- "select_content",
50
- "select_item",
51
- "select_promotion",
52
- "share",
53
- "sign_up",
54
- "spend_virtual_currency",
55
- "tutorial_begin",
56
- "tutorial_complete",
57
- "unlock_achievement",
58
- "view_cart",
59
- "view_item",
60
- "view_item_list",
61
- "view_promotion",
62
- "working_lead"
25
+ module.exports = __toCommonJS(gtag_exports);
26
+ var reservedWebEventNames = [
27
+ "app_remove",
28
+ "app_store_refund",
29
+ "app_store_subscription_cancel",
30
+ "app_store_subscription_renew",
31
+ "click",
32
+ "error",
33
+ "file_download",
34
+ "first_open",
35
+ "first_visit",
36
+ "form_start",
37
+ "form_submit",
38
+ "in_app_purchase",
39
+ "page_view",
40
+ "scroll",
41
+ "session_start",
42
+ "user_engagement",
43
+ "view_complete",
44
+ "video_progress",
45
+ "video_start",
46
+ "view_search_results"
63
47
  ];
64
- var reservedEventNames = [
48
+ var reservedAppEventNames = [
65
49
  "ad_activeview",
66
50
  "ad_click",
67
51
  "ad_exposure",
52
+ "ad_impression",
68
53
  "ad_query",
69
54
  "ad_reward",
70
55
  "adunit_exposure",
71
- "app_background",
72
56
  "app_clear_data",
73
57
  "app_exception",
58
+ "app_install",
74
59
  "app_remove",
75
60
  "app_store_refund",
76
- "app_store_subscription_cancel",
77
- "app_store_subscription_convert",
78
- "app_store_subscription_renew",
79
61
  "app_update",
80
62
  "app_upgrade",
81
63
  "dynamic_link_app_open",
82
64
  "dynamic_link_app_update",
83
65
  "dynamic_link_first_open",
84
66
  "error",
67
+ "firebase_campaign",
68
+ "firebase_in_app_message_action",
69
+ "firebase_in_app_message_dismiss",
70
+ "firebase_in_app_message_impression",
85
71
  "first_open",
86
72
  "first_visit",
87
73
  "in_app_purchase",
@@ -89,14 +75,15 @@ var reservedEventNames = [
89
75
  "notification_foreground",
90
76
  "notification_open",
91
77
  "notification_receive",
78
+ "notification_send",
92
79
  "os_update",
80
+ "screen_view",
93
81
  "session_start",
94
- "session_start_with_rollout",
95
82
  "user_engagement"
96
83
  ];
84
+ var reservedEventNames = [...reservedWebEventNames, ...reservedAppEventNames];
97
85
  // Annotate the CommonJS export names for ESM import in node:
98
86
  0 && (module.exports = {
99
- reservedEventNames,
100
- standardEventNames
87
+ reservedEventNames
101
88
  });
102
- //# sourceMappingURL=ga.cjs.map
89
+ //# sourceMappingURL=gtag.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/track/gtag.ts"],"sourcesContent":["/** reference: https://support.google.com/analytics/answer/13316687 */\nconst reservedWebEventNames = [\n 'app_remove',\n 'app_store_refund',\n 'app_store_subscription_cancel',\n 'app_store_subscription_renew',\n 'click',\n 'error',\n 'file_download',\n 'first_open',\n 'first_visit',\n 'form_start',\n 'form_submit',\n 'in_app_purchase',\n 'page_view',\n 'scroll',\n 'session_start',\n 'user_engagement',\n 'view_complete',\n 'video_progress',\n 'video_start',\n 'view_search_results',\n] as const;\n\nconst reservedAppEventNames = [\n 'ad_activeview',\n 'ad_click',\n 'ad_exposure',\n 'ad_impression',\n 'ad_query',\n 'ad_reward',\n 'adunit_exposure',\n 'app_clear_data',\n 'app_exception',\n 'app_install',\n 'app_remove',\n 'app_store_refund',\n 'app_update',\n 'app_upgrade',\n 'dynamic_link_app_open',\n 'dynamic_link_app_update',\n 'dynamic_link_first_open',\n 'error',\n 'firebase_campaign',\n 'firebase_in_app_message_action',\n 'firebase_in_app_message_dismiss',\n 'firebase_in_app_message_impression',\n 'first_open',\n 'first_visit',\n 'in_app_purchase',\n 'notification_dismiss',\n 'notification_foreground',\n 'notification_open',\n 'notification_receive',\n 'notification_send',\n 'os_update',\n 'screen_view',\n 'session_start',\n 'user_engagement',\n] as const;\n\nexport const reservedEventNames = [...reservedWebEventNames, ...reservedAppEventNames] as const;\n\ntype ReservedWebEventNames = (typeof reservedWebEventNames)[number];\ntype ReservedAppEventNames = (typeof reservedAppEventNames)[number];\nexport type ReservedEventNames = ReservedWebEventNames | ReservedAppEventNames;\n\nexport type ReservedEventValues =\n | 'cid'\n | 'currency'\n | 'customer_id'\n | 'customerid'\n | 'dclid'\n | 'gclid'\n | 'session_id'\n | 'sessionid'\n | 'sfmc_id'\n | 'sid'\n | 'srsltid'\n | 'uid'\n | 'user_id'\n | 'userid'\n | `_${string}`\n | `firebase_${string}`\n | `ga_${string}`\n | `google_${string}`\n | `gtag.${string}`;\n\nexport type ReservedUserPropertiesNames =\n | 'cid'\n | 'customer_id'\n | 'customerid'\n | 'first_open_after_install'\n | 'first_open_time'\n | 'first_visit_time'\n | 'google_allow_ad_personalization_signals'\n | 'last_advertising_id_reset'\n | 'last_deep_link_referrer'\n | 'last_gclid'\n | 'lifetime_user_engagement'\n | 'non_personalized_ads'\n | 'session_id'\n | 'session_number'\n | 'sessionid'\n | 'sfmc_id'\n | 'sid'\n | 'uid'\n | 'user_id'\n | 'userid'\n | `_${string}`\n | `firebase_${string}`\n | `ga_${string}`\n | `google_${string}`;\n\nexport type UserPropertiesValue = string | boolean | number | null | undefined;\nexport type UserProperties = {\n [key: string]: UserPropertiesValue;\n} & {\n [key in ReservedUserPropertiesNames]?: never;\n};\n\n/**\n * reference: https://support.google.com/analytics/answer/14078702\n * You must turn on user-provided data collection in Google Analytics.\n *\n * Validate your user-provided data implementation: https://support.google.com/analytics/answer/14171683\n *\n * Usage: gtag('set', 'user_data', { email: 'abc@abc.com' })\n *\n * In order to standardize the hash results, prior to hashing one of these values you must:\n *\n * - Remove leading and trailing whitespaces.\n * - Convert the text to lowercase.\n * - Format phone numbers according to the E164 standard.\n * - Remove all periods (.) that precede the domain name in gmail.com and googlemail.com email addresses.\n * */\ntype UserProvidedDataAddress = {\n first_name?: string;\n last_name?: string;\n street?: string;\n city?: string;\n /** User province, state, or region. Example: `Hampshire` */\n region?: string;\n postal_code?: string;\n /**\n * User country code.\n * Example: 'UK'. Use 2-letter country codes, per the ISO 3166-1 alpha-2 standard.\n */\n country?: string;\n};\n\n/**\n * In order to standardize the hash results, prior to hashing one of these values you must:\n *\n * - Remove leading and trailing whitespaces.\n * - Convert the text to lowercase.\n * - Format phone numbers according to the E164 standard.\n * - Remove all periods (.) that precede the domain name in gmail.com and googlemail.com email addresses.\n */\nexport type UserProvidedData = {\n email?: string | string[];\n /**\n * User phone number. Must be in E.164 format, which means it must be 11 to 15 digits including a\n * plus sign (+) prefix and country code with no dashes, parentheses, or spaces.\n *\n * Example: ‘+11231234567’\n */\n phone_number?: string | string[];\n address?: UserProvidedDataAddress | UserProvidedDataAddress[];\n};\n\nexport type GaId = `G-${Uppercase<string>}`;\nexport type GtmId = `GTM-${Uppercase<string>}`;\n\nexport type CampaignMedium =\n | 'email'\n | 'organic'\n | 'cpc'\n | 'banner'\n | 'social'\n | 'referral'\n | 'affiliate'\n | 'video'\n | 'display'\n | 'sms'\n | 'push'\n | 'qr'\n | 'audio'\n | (string & {});\n\nexport type CampaignSource =\n | 'google' // don't need to set\n | 'googleads'\n | 'bing'\n | 'bingads'\n | 'metaads'\n | 'facebook'\n | 'twitter'\n | 'linkedin'\n | 'instagram'\n | 'tiktok'\n | 'youtube'\n | 'newsletter'\n | `website_${string}`\n | `affiliate_${string}`\n | (string & {});\n\nexport type Campaign = {\n id?: string;\n name?: string;\n term?: string;\n content?: string;\n medium?: CampaignMedium;\n source?: CampaignSource;\n};\n\nexport type Config = {\n allow_google_signals?: boolean;\n allow_ad_personalization_signals?: boolean;\n\n campaign_content?: string;\n campaign_id?: string;\n campaign_medium?: CampaignMedium;\n campaign_name?: string;\n campaign_source?: CampaignSource;\n campaign_term?: string;\n\n /**\n * @deprecated\n * Key Point: Use the campaign_ prefixed version of each campaign value instead of this field.\n */\n campaign?: Campaign;\n\n client_id?: string;\n content_group?: string;\n\n cookie_domain?: 'none' | 'auto' | string;\n cookie_expires?: number;\n cookie_flags?: string;\n cookie_path?: string;\n cookie_prefix?: string;\n cookie_update?: boolean;\n\n ignore_referrer?: boolean;\n language?: string;\n\n page_location?: string;\n page_referrer?: string;\n page_title?: string;\n\n send_page_view?: boolean;\n screen_resolution?: `${number}x${number}`;\n user_id?: string;\n user_properties?: UserProperties;\n};\n\nexport type Item = {\n item_id: string;\n item_name: string;\n affiliation?: 'Google Store' | (string & {});\n coupon?: string;\n discount?: number;\n index?: number;\n item_brand?: string;\n item_category?: string;\n item_category2?: string;\n item_category3?: string;\n item_category4?: string;\n item_category5?: string;\n item_list_id?: string;\n item_list_name?: string;\n item_variant?: string;\n location_id?: string;\n price?: number;\n quantity?: number;\n};\n\nexport type PromotionItem = {\n creative_name?: string;\n creative_slot?: string;\n promotion_id?: string;\n promotion_name?: string;\n};\n\n/**\n * ref: https://developers.google.com/analytics/devguides/collection/ga4/reference/events?client_type=gtag\n * ref: https://firebase.google.com/docs/reference/android/com/google/firebase/analytics/FirebaseAnalytics.Event\n * */\nexport type StandardEvents = {\n // Google Analytics 4 Recommended Events\n add_payment_info: {\n currency: string;\n value: number;\n coupon?: string;\n payment_type?: string;\n items: Item[];\n };\n add_shipping_info: {\n currency: string;\n value: number;\n coupon?: string;\n shipping_tier?: string;\n items: Item[];\n };\n add_to_cart: {\n currency: string;\n value: number;\n items: Item[];\n };\n add_to_wishlist: {\n currency: string;\n value: number;\n items: Item[];\n };\n begin_checkout: {\n currency: string;\n value: number;\n coupon?: string;\n items: Item[];\n };\n close_convert_lead: {\n currency: string;\n value: number;\n };\n close_unconvert_lead: {\n currency: string;\n value: number;\n unconvert_lead_reason?: string;\n };\n disqualify_lead: {\n currency: string;\n value: number;\n disqualified_lead_reason?: string;\n };\n earn_virtual_currency: {\n virtual_currency_name?: string;\n value?: number;\n };\n generate_lead: {\n currency: string;\n value: number;\n lead_source?: string;\n };\n join_group: {\n group_id?: string;\n };\n level_end: {\n level_name?: string;\n success?: boolean;\n };\n level_start: {\n level_name?: string;\n };\n level_up: {\n level?: number;\n level_name?: string;\n character?: string;\n };\n login: {\n method?: string;\n };\n post_score: {\n score: number;\n level?: number;\n character?: string;\n };\n purchase: {\n currency: string;\n value: number;\n transaction_id: string;\n coupon?: string;\n shipping?: number; // Shipping cost associated with a transaction.\n tax?: number;\n items?: Item[];\n };\n qualify_lead: {\n currency: string;\n value: number;\n };\n refund: {\n currency: string;\n value: number;\n transaction_id: string;\n coupon?: string;\n shipping?: number;\n tax?: number;\n items?: Item[];\n };\n remove_from_cart: {\n currency: string;\n value: number;\n items: Item[];\n };\n search: {\n search_term: string;\n };\n select_content: {\n content_type?: string;\n content_id?: string;\n };\n select_item: {\n item_list_id?: string;\n item_list_name?: string;\n items: Item[];\n };\n select_promotion: {\n creative_name?: string;\n creative_slot?: string;\n promotion_id?: string;\n promotion_name?: string;\n items?: (Item & PromotionItem)[];\n };\n share: {\n method?: string;\n content_type?: string;\n item_id?: string;\n };\n sign_up: {\n method?: string;\n };\n spend_virtual_currency: {\n value: number;\n virtual_currency_name: string;\n item_name?: string;\n };\n tutorial_begin: undefined;\n tutorial_complete: undefined;\n unlock_achievement: {\n achievement_id: string;\n };\n view_cart: {\n currency: string;\n value: number;\n items: Item[];\n };\n view_item: {\n currency: string;\n value: number;\n items: Item[];\n };\n view_item_list: {\n currency: string;\n item_list_id?: string;\n item_list_name?: string;\n items: Item[];\n };\n view_promotion: {\n creative_name?: string;\n creative_slot?: string;\n promotion_id?: string;\n promotion_name?: string;\n items: (Item & PromotionItem)[];\n };\n working_lead: {\n currency: string;\n value: number;\n lead_status?: string;\n };\n\n // Firebase Analytics events, event_name 40 characters limit, 25 parameters limit\n ad_impression: {\n value?: number;\n currency?: string;\n ad_format?: string;\n ad_platform?: string;\n ad_source?: string;\n ad_unit_name?: string;\n };\n app_open: undefined;\n campaign_details: {\n source: string;\n medium: string;\n campaign: string;\n term?: string;\n content?: string;\n aclid?: string;\n cp1?: string;\n };\n screen_view: { screen_name?: string; screen_class?: string };\n view_search_results: { search_term: string };\n\n // Added events\n trial_begin: {\n currency: string;\n value: number;\n };\n\n subscribe: {\n currency: string;\n value: number;\n };\n};\n\n/**\n * reference: https://developers.google.com/analytics/devguides/collection/ga4/reference/config\n * reference: https://developers.google.com/analytics/devguides/collection/ga4/reference/events?client_type=gtag\n */\nexport interface Gtag {\n /**\n * To disable advertising features based on third-party advertising identifiers, set\n * allow_google_signals to false.\n *\n * @param allow - Whether to allow Google signals.\n * @default true\n */\n gtag(event: 'set', option: 'allow_google_signals', allow: boolean): void;\n\n /**\n * Set to false to disable advertising personalization features.\n *\n * @param allow - Whether to allow ad personalization signals.\n * @default true\n */\n gtag(event: 'set', option: 'allow_ad_personalization_signals', allow: boolean): void;\n\n /**\n * Used for A/B testing and content-targeted ads. Use campaign_content to differentiate ads or\n * links that point to the same URL.\n */\n gtag(event: 'set', option: 'campaign_content', content: string): void;\n\n /**\n * Used to identify which campaign this referral references. Use campaign_id to identify a\n * specific campaign.\n */\n gtag(event: 'set', option: 'campaign_id', id: string): void;\n\n /** Use campaign_medium to identify a medium such as email or cost-per-click. */\n gtag(event: 'set', option: 'campaign_medium', medium: CampaignMedium): void;\n\n /**\n * Used for keyword analysis. Use campaign_name to identify a specific product promotion or\n * strategic campaign.\n */\n gtag(event: 'set', option: 'campaign_name', name: string): void;\n\n /** Use campaign_source to identify a search engine, newsletter name, or other source. */\n gtag(event: 'set', option: 'campaign_source', source: CampaignSource): void;\n\n /** Used for paid search. Use campaign_term to note the keywords for this ad. */\n gtag(event: 'set', option: 'campaign_term', term: string): void;\n\n /**\n * @deprecated\n * Key Point: Use the campaign_ prefixed version of each campaign value instead of this field.\n */\n gtag(event: 'set', option: 'campaign', params: Campaign): void;\n\n /**\n * Pseudonymously identifies a browser instance. By default, this value is stored as part of the\n * first-party Analytics cookie with a two-year expiration.\n */\n gtag(event: 'set', option: 'client_id', id: string): void;\n\n /** example: gtag('set', 'content_group', '/news/sports'); */\n gtag(event: 'set', option: 'content_group', group: string): void;\n\n /**\n * Specifies the domain used to store the analytics cookie.\n * Set to 'none' to set the cookie without specifying a domain.\n * Set to 'auto' (the default value) to set the cookie to the top level domain plus one\n * subdomain (eTLD +1). For example if cookie_domain is set to 'auto' https://example.com would\n * use example.com for the domain, and https://subdomain.example.com would also use example.com\n * for the domain.\n *\n * @param domain - The domain used to store the analytics cookie.\n * @default 'auto'\n */\n gtag(event: 'set', option: 'cookie_domain', domain: 'none' | 'auto' | string): void;\n\n /**\n * Every time a hit is sent to Google Analytics, the cookie expiration time is updated to be the\n * current time plus the value of the cookie_expires field. This means that if you use the default\n * value time of two years (63072000 seconds), and a user visits your site every month, their\n * cookie will never expire.\n *\n * If you set the cookie_expires time to 0 (zero) seconds, the cookie turns into a session based\n * cookie and expires once the current browser session ends.\n *\n * Caution: If you set the cookie to expire too quickly, you will inflate your user count and\n * decrease the quality of your measurement.\n *\n * @param expires - The number of seconds until the cookie expires.\n * @default 63072000\n */\n gtag(event: 'set', option: 'cookie_expires', expires: number): void;\n\n /**\n * Appends additional flags to the cookie when set. Flags must be separated by semicolons. See\n * [write a new cookie](https://developer.mozilla.org/en-US/docs/Web/API/Document/cookie#write_a_new_cookie) for some examples of flags to set.\n */\n gtag(event: 'set', option: 'cookie_flags', flags: string): void;\n\n /** Specifies the subpath used to store the analytics cookie. */\n gtag(event: 'set', option: 'cookie_path', path: string): void;\n\n /** Specifies a prefix to prepend to analytics cookie names. */\n gtag(event: 'set', option: 'cookie_prefix', prefix: string): void;\n\n /**\n * When cookie_update is set to true, gtag.js will update cookies on each page load. This will\n * update the cookie expiration to be set relative to the most recent visit to the site. For\n * example, if cookie expiration is set to one week, and a user visits using the same browser\n * every five days, the cookie expiration will be updated on each visit and will effectively\n * never expire.\n *\n * When set to false, cookies are not updated on each page load. This has the effect of cookie\n * expiration being relative to the first time a user visited the site.\n *\n * @param update - Whether to update the cookie on each page load.\n * @default true\n */\n gtag(event: 'set', option: 'cookie_update', update: boolean): void;\n\n /**\n * Set to true to indicate to Analytics that the referrer shouldn't be displayed as a traffic\n * source. [Learn when to use this field](https://support.google.com/analytics/answer/10327750#set-parameter)\n *\n * @param ignore - Whether to ignore the referrer.\n * @default false\n */\n gtag(event: 'set', option: 'ignore_referrer', ignore: boolean): void;\n\n /**\n * Specifies the language preference of the user. Defaults to the user's navigator.language value.\n *\n * @param language - The language preference of the user.\n * @default navigator.language\n */\n gtag(event: 'set', option: 'language', language: string): void;\n\n /**\n * Specifies the full URL of the page. Defaults to the user's document.location value.\n *\n * @param location - The full URL of the page. Character limit 1000\n * @default document.location\n */\n gtag(event: 'set', option: 'page_location', location: string): void;\n\n /**\n * Specifies which referral source brought traffic to a page. This value is also used to compute\n * the traffic source. The format of this value is a URL. Defaults to the user's document.referrer\n * value.\n *\n * @param referrer - The referral source. Character limit 420\n * @default document.referrer\n */\n gtag(event: 'set', option: 'page_referrer', referrer: string): void;\n\n /**\n * The title of the page or document. Defaults to the user's document.title value.\n *\n * @param title - The title of the page or document. Character limit 300\n * @default document.title\n */\n gtag(event: 'set', option: 'page_title', title: string): void;\n\n /**\n * Set to false to prevent the default snippet from sending a page_view.\n *\n * @param send - Whether to send a page_view.\n * @default true\n */\n gtag(event: 'set', option: 'send_page_view', send: boolean): void;\n\n /**\n * Specifies the resolution of the screen. Should be two positive integers separated by an x. For\n * example, for an 800px by 600px screen, the value would be 800x600. Calculated from the user's\n * window.screen value.\n *\n * @param resolution - The resolution of the screen.\n * @default window.screen\n */\n gtag(event: 'set', option: 'screen_resolution', resolution: `${number}x${number}`): void;\n\n /**\n * Specifies a known identifier for a user provided by the site owner/library user. It must not\n * itself be PII (personally identifiable information). The value should never be persisted in\n * Google Analytics cookies or other Analytics provided storage.\n *\n * @param userId - The user ID. Character limit 256\n */\n gtag(event: 'set', option: 'user_id', userId: string): void;\n\n /**\n * User properties are attributes that can be used to describe segments of your user base, such\n * as language preference or geographic location. Up to 25 additional user properties can be set\n * per project.\n *\n * @param name - The name of the user property. Character limit 24\n * @param value - The value of the user property. Character limit 36\n */\n gtag(event: 'set', option: 'user_properties', properties: UserProperties): void;\n\n gtag(event: 'set', option: 'user_data', data: UserProvidedData): void;\n\n /**\n * gtag('config', ...) Set for a single stream\n * gtag('set', ...) Set globally\n */\n gtag(event: 'config', gaId: GaId, config?: Config): void;\n\n gtag<T extends string>(\n event: 'event',\n eventName: T extends keyof StandardEvents ? T : string,\n eventParams?: T extends keyof StandardEvents\n ? StandardEvents[T]\n : Record<string, string | number | boolean | null | undefined>\n ): void;\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AACA,IAAM,wBAAwB;AAAA,EAC5B;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF;AAEA,IAAM,wBAAwB;AAAA,EAC5B;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF;AAEO,IAAM,qBAAqB,CAAC,GAAG,uBAAuB,GAAG,qBAAqB;","names":[]}