@shware/analytics 3.5.2 → 3.6.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/server/index.cjs +3 -0
- package/dist/server/index.cjs.map +1 -1
- package/dist/server/index.d.cts +2 -0
- package/dist/server/index.d.ts +2 -0
- package/dist/server/index.mjs +2 -0
- package/dist/server/index.mjs.map +1 -1
- package/dist/server/openai-conversions-api.cjs +107 -0
- package/dist/server/openai-conversions-api.cjs.map +1 -0
- package/dist/server/openai-conversions-api.d.cts +47 -0
- package/dist/server/openai-conversions-api.d.ts +47 -0
- package/dist/server/openai-conversions-api.mjs +81 -0
- package/dist/server/openai-conversions-api.mjs.map +1 -0
- package/dist/tanstack/index.cjs +28 -0
- package/dist/tanstack/index.cjs.map +1 -1
- package/dist/tanstack/index.d.cts +2 -1
- package/dist/tanstack/index.d.ts +2 -1
- package/dist/tanstack/index.mjs +28 -0
- package/dist/tanstack/index.mjs.map +1 -1
- package/dist/third-parties/google-analytics.cjs.map +1 -1
- package/dist/third-parties/google-analytics.mjs.map +1 -1
- package/dist/third-parties/index.cjs +5 -0
- package/dist/third-parties/index.cjs.map +1 -1
- package/dist/third-parties/index.d.cts +2 -0
- package/dist/third-parties/index.d.ts +2 -0
- package/dist/third-parties/index.mjs +3 -0
- package/dist/third-parties/index.mjs.map +1 -1
- package/dist/third-parties/linkedin-insight-tag.cjs.map +1 -1
- package/dist/third-parties/linkedin-insight-tag.mjs.map +1 -1
- package/dist/third-parties/meta-pixel.cjs.map +1 -1
- package/dist/third-parties/meta-pixel.mjs.map +1 -1
- package/dist/third-parties/openai-pixel.cjs +78 -0
- package/dist/third-parties/openai-pixel.cjs.map +1 -0
- package/dist/third-parties/openai-pixel.d.cts +23 -0
- package/dist/third-parties/openai-pixel.d.ts +23 -0
- package/dist/third-parties/openai-pixel.mjs +52 -0
- package/dist/third-parties/openai-pixel.mjs.map +1 -0
- package/dist/third-parties/reddit-pixel.cjs.map +1 -1
- package/dist/third-parties/reddit-pixel.mjs.map +1 -1
- package/dist/track/gtag.cjs.map +1 -1
- package/dist/track/gtag.d.cts +45 -12
- package/dist/track/gtag.d.ts +45 -12
- package/dist/track/gtag.mjs.map +1 -1
- package/dist/track/oaiq.cjs +155 -0
- package/dist/track/oaiq.cjs.map +1 -0
- package/dist/track/oaiq.d.cts +110 -0
- package/dist/track/oaiq.d.ts +110 -0
- package/dist/track/oaiq.mjs +128 -0
- package/dist/track/oaiq.mjs.map +1 -0
- package/package.json +1 -1
|
@@ -23,26 +23,31 @@ __export(third_parties_exports, {
|
|
|
23
23
|
sendFBEvent: () => import_meta_pixel.sendFBEvent,
|
|
24
24
|
sendGAEvent: () => import_google_analytics.sendGAEvent,
|
|
25
25
|
sendLinkedinEvent: () => import_linkedin_insight_tag.sendLinkedinEvent,
|
|
26
|
+
sendOpenAIEvent: () => import_openai_pixel.sendOpenAIEvent,
|
|
26
27
|
sendRedditEvent: () => import_reddit_pixel.sendRedditEvent,
|
|
27
28
|
setFBUser: () => import_meta_pixel.setFBUser,
|
|
28
29
|
setGAUser: () => import_google_analytics.setGAUser,
|
|
29
30
|
setLinkedinUser: () => import_linkedin_insight_tag.setLinkedinUser,
|
|
31
|
+
setOpenAIUser: () => import_openai_pixel.setOpenAIUser,
|
|
30
32
|
setRedditUser: () => import_reddit_pixel.setRedditUser
|
|
31
33
|
});
|
|
32
34
|
module.exports = __toCommonJS(third_parties_exports);
|
|
33
35
|
var import_google_analytics = require("./google-analytics.cjs");
|
|
34
36
|
var import_meta_pixel = require("./meta-pixel.cjs");
|
|
35
37
|
var import_linkedin_insight_tag = require("./linkedin-insight-tag.cjs");
|
|
38
|
+
var import_openai_pixel = require("./openai-pixel.cjs");
|
|
36
39
|
var import_reddit_pixel = require("./reddit-pixel.cjs");
|
|
37
40
|
// Annotate the CommonJS export names for ESM import in node:
|
|
38
41
|
0 && (module.exports = {
|
|
39
42
|
sendFBEvent,
|
|
40
43
|
sendGAEvent,
|
|
41
44
|
sendLinkedinEvent,
|
|
45
|
+
sendOpenAIEvent,
|
|
42
46
|
sendRedditEvent,
|
|
43
47
|
setFBUser,
|
|
44
48
|
setGAUser,
|
|
45
49
|
setLinkedinUser,
|
|
50
|
+
setOpenAIUser,
|
|
46
51
|
setRedditUser
|
|
47
52
|
});
|
|
48
53
|
//# sourceMappingURL=index.cjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/third-parties/index.ts"],"sourcesContent":["export { sendGAEvent, setGAUser } from './google-analytics';\nexport { sendFBEvent, setFBUser } from './meta-pixel';\nexport { sendLinkedinEvent, setLinkedinUser } from './linkedin-insight-tag';\nexport { sendRedditEvent, setRedditUser } from './reddit-pixel';\n\nexport type { LinkedinConversionConfig } from './linkedin-insight-tag';\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,8BAAuC;AACvC,wBAAuC;AACvC,kCAAmD;AACnD,0BAA+C;","names":[]}
|
|
1
|
+
{"version":3,"sources":["../../src/third-parties/index.ts"],"sourcesContent":["export { sendGAEvent, setGAUser } from './google-analytics';\nexport { sendFBEvent, setFBUser } from './meta-pixel';\nexport { sendLinkedinEvent, setLinkedinUser } from './linkedin-insight-tag';\nexport { sendOpenAIEvent, setOpenAIUser } from './openai-pixel';\nexport { sendRedditEvent, setRedditUser } from './reddit-pixel';\n\nexport type { LinkedinConversionConfig } from './linkedin-insight-tag';\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,8BAAuC;AACvC,wBAAuC;AACvC,kCAAmD;AACnD,0BAA+C;AAC/C,0BAA+C;","names":[]}
|
|
@@ -1,10 +1,12 @@
|
|
|
1
1
|
export { sendGAEvent, setGAUser } from './google-analytics.cjs';
|
|
2
2
|
export { sendFBEvent, setFBUser } from './meta-pixel.cjs';
|
|
3
3
|
export { LinkedinConversionConfig, sendLinkedinEvent, setLinkedinUser } from './linkedin-insight-tag.cjs';
|
|
4
|
+
export { sendOpenAIEvent, setOpenAIUser } from './openai-pixel.cjs';
|
|
4
5
|
export { sendRedditEvent, setRedditUser } from './reddit-pixel.cjs';
|
|
5
6
|
import '../track/gtag.cjs';
|
|
6
7
|
import '../track/types.cjs';
|
|
7
8
|
import '../visitor/types.cjs';
|
|
8
9
|
import '../track/fbq.cjs';
|
|
9
10
|
import '../track/lintrk.cjs';
|
|
11
|
+
import '../track/oaiq.cjs';
|
|
10
12
|
import '../track/rdt.cjs';
|
|
@@ -1,10 +1,12 @@
|
|
|
1
1
|
export { sendGAEvent, setGAUser } from './google-analytics.js';
|
|
2
2
|
export { sendFBEvent, setFBUser } from './meta-pixel.js';
|
|
3
3
|
export { LinkedinConversionConfig, sendLinkedinEvent, setLinkedinUser } from './linkedin-insight-tag.js';
|
|
4
|
+
export { sendOpenAIEvent, setOpenAIUser } from './openai-pixel.js';
|
|
4
5
|
export { sendRedditEvent, setRedditUser } from './reddit-pixel.js';
|
|
5
6
|
import '../track/gtag.js';
|
|
6
7
|
import '../track/types.js';
|
|
7
8
|
import '../visitor/types.js';
|
|
8
9
|
import '../track/fbq.js';
|
|
9
10
|
import '../track/lintrk.js';
|
|
11
|
+
import '../track/oaiq.js';
|
|
10
12
|
import '../track/rdt.js';
|
|
@@ -2,15 +2,18 @@
|
|
|
2
2
|
import { sendGAEvent, setGAUser } from "./google-analytics.mjs";
|
|
3
3
|
import { sendFBEvent, setFBUser } from "./meta-pixel.mjs";
|
|
4
4
|
import { sendLinkedinEvent, setLinkedinUser } from "./linkedin-insight-tag.mjs";
|
|
5
|
+
import { sendOpenAIEvent, setOpenAIUser } from "./openai-pixel.mjs";
|
|
5
6
|
import { sendRedditEvent, setRedditUser } from "./reddit-pixel.mjs";
|
|
6
7
|
export {
|
|
7
8
|
sendFBEvent,
|
|
8
9
|
sendGAEvent,
|
|
9
10
|
sendLinkedinEvent,
|
|
11
|
+
sendOpenAIEvent,
|
|
10
12
|
sendRedditEvent,
|
|
11
13
|
setFBUser,
|
|
12
14
|
setGAUser,
|
|
13
15
|
setLinkedinUser,
|
|
16
|
+
setOpenAIUser,
|
|
14
17
|
setRedditUser
|
|
15
18
|
};
|
|
16
19
|
//# sourceMappingURL=index.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/third-parties/index.ts"],"sourcesContent":["export { sendGAEvent, setGAUser } from './google-analytics';\nexport { sendFBEvent, setFBUser } from './meta-pixel';\nexport { sendLinkedinEvent, setLinkedinUser } from './linkedin-insight-tag';\nexport { sendRedditEvent, setRedditUser } from './reddit-pixel';\n\nexport type { LinkedinConversionConfig } from './linkedin-insight-tag';\n"],"mappings":";AAAA,SAAS,aAAa,iBAAiB;AACvC,SAAS,aAAa,iBAAiB;AACvC,SAAS,mBAAmB,uBAAuB;AACnD,SAAS,iBAAiB,qBAAqB;","names":[]}
|
|
1
|
+
{"version":3,"sources":["../../src/third-parties/index.ts"],"sourcesContent":["export { sendGAEvent, setGAUser } from './google-analytics';\nexport { sendFBEvent, setFBUser } from './meta-pixel';\nexport { sendLinkedinEvent, setLinkedinUser } from './linkedin-insight-tag';\nexport { sendOpenAIEvent, setOpenAIUser } from './openai-pixel';\nexport { sendRedditEvent, setRedditUser } from './reddit-pixel';\n\nexport type { LinkedinConversionConfig } from './linkedin-insight-tag';\n"],"mappings":";AAAA,SAAS,aAAa,iBAAiB;AACvC,SAAS,aAAa,iBAAiB;AACvC,SAAS,mBAAmB,uBAAuB;AACnD,SAAS,iBAAiB,qBAAqB;AAC/C,SAAS,iBAAiB,qBAAqB;","names":[]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/third-parties/linkedin-insight-tag.ts"],"sourcesContent":["import type { Lintrk } from '../track/lintrk';\nimport type { EventName, TrackName, TrackProperties } from '../track/types';\nimport { getFirst } from '../utils/field';\nimport type { UpdateVisitorDTO } from '../visitor/types';\n\ndeclare global {\n //
|
|
1
|
+
{"version":3,"sources":["../../src/third-parties/linkedin-insight-tag.ts"],"sourcesContent":["import type { Lintrk } from '../track/lintrk';\nimport type { EventName, TrackName, TrackProperties } from '../track/types';\nimport { getFirst } from '../utils/field';\nimport type { UpdateVisitorDTO } from '../visitor/types';\n\ndeclare global {\n // oxlint-disable-next-line typescript/no-empty-object-type\n interface Window extends Lintrk {}\n}\n\n/**\n * LinkedIn Conversion Config:\n * example:\n * {\n * purchase: 123,\n * add_to_cart: 456,\n * add_to_wishlist: 789,\n * }\n */\nexport type LinkedinConversionConfig = Record<Lowercase<string>, 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;\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 as Lowercase<string>];\n if (!conversion_id) return;\n window.lintrk('track', { conversion_id, event_id });\n };\n}\n\nexport function setLinkedinUser({ 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(data?.email);\n if (!email) return;\n window.lintrk('setUserData', { email });\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAEA,mBAAyB;AAmBlB,SAAS,kBAAkB,QAAkC;AAClE,SAAO,CACL,MACA,aACA,aACG;AACH,QAAI,OAAO,WAAW,eAAe,CAAC,OAAO,QAAQ;AACnD,cAAQ,KAAK,iCAAiC;AAC9C;AAAA,IACF;AACA,QAAI,OAAO,SAAS,KAAK,SAAS,WAAW,EAAG;AAChD,QAAI,OAAO,SAAS,KAAK,SAAS,WAAW,EAAG;AAEhD,UAAM,gBAAgB,OAAO,IAAyB;AACtD,QAAI,CAAC,cAAe;AACpB,WAAO,OAAO,SAAS,EAAE,eAAe,SAAS,CAAC;AAAA,EACpD;AACF;AAEO,SAAS,gBAAgB,EAAE,KAAK,GAAqB;AAC1D,MAAI,OAAO,WAAW,eAAe,CAAC,OAAO,QAAQ;AACnD,YAAQ,KAAK,iCAAiC;AAC9C;AAAA,EACF;AAEA,QAAM,YAAQ,uBAAS,6BAAM,KAAK;AAClC,MAAI,CAAC,MAAO;AACZ,SAAO,OAAO,eAAe,EAAE,MAAM,CAAC;AACxC;","names":[]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/third-parties/linkedin-insight-tag.ts"],"sourcesContent":["import type { Lintrk } from '../track/lintrk';\nimport type { EventName, TrackName, TrackProperties } from '../track/types';\nimport { getFirst } from '../utils/field';\nimport type { UpdateVisitorDTO } from '../visitor/types';\n\ndeclare global {\n //
|
|
1
|
+
{"version":3,"sources":["../../src/third-parties/linkedin-insight-tag.ts"],"sourcesContent":["import type { Lintrk } from '../track/lintrk';\nimport type { EventName, TrackName, TrackProperties } from '../track/types';\nimport { getFirst } from '../utils/field';\nimport type { UpdateVisitorDTO } from '../visitor/types';\n\ndeclare global {\n // oxlint-disable-next-line typescript/no-empty-object-type\n interface Window extends Lintrk {}\n}\n\n/**\n * LinkedIn Conversion Config:\n * example:\n * {\n * purchase: 123,\n * add_to_cart: 456,\n * add_to_wishlist: 789,\n * }\n */\nexport type LinkedinConversionConfig = Record<Lowercase<string>, 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;\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 as Lowercase<string>];\n if (!conversion_id) return;\n window.lintrk('track', { conversion_id, event_id });\n };\n}\n\nexport function setLinkedinUser({ 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(data?.email);\n if (!email) return;\n window.lintrk('setUserData', { email });\n}\n"],"mappings":";AAEA,SAAS,gBAAgB;AAmBlB,SAAS,kBAAkB,QAAkC;AAClE,SAAO,CACL,MACA,aACA,aACG;AACH,QAAI,OAAO,WAAW,eAAe,CAAC,OAAO,QAAQ;AACnD,cAAQ,KAAK,iCAAiC;AAC9C;AAAA,IACF;AACA,QAAI,OAAO,SAAS,KAAK,SAAS,WAAW,EAAG;AAChD,QAAI,OAAO,SAAS,KAAK,SAAS,WAAW,EAAG;AAEhD,UAAM,gBAAgB,OAAO,IAAyB;AACtD,QAAI,CAAC,cAAe;AACpB,WAAO,OAAO,SAAS,EAAE,eAAe,SAAS,CAAC;AAAA,EACpD;AACF;AAEO,SAAS,gBAAgB,EAAE,KAAK,GAAqB;AAC1D,MAAI,OAAO,WAAW,eAAe,CAAC,OAAO,QAAQ;AACnD,YAAQ,KAAK,iCAAiC;AAC9C;AAAA,EACF;AAEA,QAAM,QAAQ,SAAS,6BAAM,KAAK;AAClC,MAAI,CAAC,MAAO;AACZ,SAAO,OAAO,eAAe,EAAE,MAAM,CAAC;AACxC;","names":[]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/third-parties/meta-pixel.ts"],"sourcesContent":["import { type FBQ, type PixelId, mapFBEvent } from '../track/fbq';\nimport type { EventName, TrackName, TrackProperties } from '../track/types';\nimport { getFirst } from '../utils/field';\nimport type { UpdateVisitorDTO } from '../visitor/types';\n\ndeclare global {\n //
|
|
1
|
+
{"version":3,"sources":["../../src/third-parties/meta-pixel.ts"],"sourcesContent":["import { type FBQ, type PixelId, mapFBEvent } from '../track/fbq';\nimport type { EventName, TrackName, TrackProperties } from '../track/types';\nimport { getFirst } from '../utils/field';\nimport type { UpdateVisitorDTO } from '../visitor/types';\n\ndeclare global {\n // oxlint-disable-next-line typescript/no-empty-object-type\n interface Window extends FBQ {}\n}\n\nconst metrics = ['CLS', 'FCP', 'FID', 'INP', 'LCP', 'TTFB'];\n\nexport function sendFBEvent<T extends EventName>(\n name: TrackName<T>,\n properties?: TrackProperties<T>,\n event_id?: string\n) {\n if (typeof window === 'undefined' || !window.fbq) {\n console.warn('fbq has not been initialized');\n return;\n }\n if (metrics.includes(name)) return;\n if (window.location.host.includes('127.0.0.1')) return;\n if (window.location.host.includes('localhost')) return;\n\n const options = { eventID: event_id };\n const [type, fbEventName, fbEventProperties] = mapFBEvent(name, properties);\n if (type === 'track') {\n window.fbq(type, fbEventName, fbEventProperties, options);\n } else {\n window.fbq(type, fbEventName, fbEventProperties, options);\n }\n}\n\nexport function setFBUser(pixelId: PixelId) {\n return ({ user_id, data }: UpdateVisitorDTO) => {\n if (typeof window === 'undefined' || !window.fbq) {\n console.warn('fbq has not been initialized');\n return;\n }\n\n const address = getFirst(data?.address);\n\n window.fbq('init', pixelId, {\n em: getFirst(data?.email),\n fn: address?.first_name,\n ln: address?.last_name,\n ph: getFirst(data?.phone_number),\n external_id: user_id,\n ct: address?.city,\n st: address?.street,\n zp: address?.postal_code,\n country: address?.country,\n });\n };\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,iBAAmD;AAEnD,mBAAyB;AAQzB,IAAM,UAAU,CAAC,OAAO,OAAO,OAAO,OAAO,OAAO,MAAM;AAEnD,SAAS,YACd,MACA,YACA,UACA;AACA,MAAI,OAAO,WAAW,eAAe,CAAC,OAAO,KAAK;AAChD,YAAQ,KAAK,8BAA8B;AAC3C;AAAA,EACF;AACA,MAAI,QAAQ,SAAS,IAAI,EAAG;AAC5B,MAAI,OAAO,SAAS,KAAK,SAAS,WAAW,EAAG;AAChD,MAAI,OAAO,SAAS,KAAK,SAAS,WAAW,EAAG;AAEhD,QAAM,UAAU,EAAE,SAAS,SAAS;AACpC,QAAM,CAAC,MAAM,aAAa,iBAAiB,QAAI,uBAAW,MAAM,UAAU;AAC1E,MAAI,SAAS,SAAS;AACpB,WAAO,IAAI,MAAM,aAAa,mBAAmB,OAAO;AAAA,EAC1D,OAAO;AACL,WAAO,IAAI,MAAM,aAAa,mBAAmB,OAAO;AAAA,EAC1D;AACF;AAEO,SAAS,UAAU,SAAkB;AAC1C,SAAO,CAAC,EAAE,SAAS,KAAK,MAAwB;AAC9C,QAAI,OAAO,WAAW,eAAe,CAAC,OAAO,KAAK;AAChD,cAAQ,KAAK,8BAA8B;AAC3C;AAAA,IACF;AAEA,UAAM,cAAU,uBAAS,6BAAM,OAAO;AAEtC,WAAO,IAAI,QAAQ,SAAS;AAAA,MAC1B,QAAI,uBAAS,6BAAM,KAAK;AAAA,MACxB,IAAI,mCAAS;AAAA,MACb,IAAI,mCAAS;AAAA,MACb,QAAI,uBAAS,6BAAM,YAAY;AAAA,MAC/B,aAAa;AAAA,MACb,IAAI,mCAAS;AAAA,MACb,IAAI,mCAAS;AAAA,MACb,IAAI,mCAAS;AAAA,MACb,SAAS,mCAAS;AAAA,IACpB,CAAC;AAAA,EACH;AACF;","names":[]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/third-parties/meta-pixel.ts"],"sourcesContent":["import { type FBQ, type PixelId, mapFBEvent } from '../track/fbq';\nimport type { EventName, TrackName, TrackProperties } from '../track/types';\nimport { getFirst } from '../utils/field';\nimport type { UpdateVisitorDTO } from '../visitor/types';\n\ndeclare global {\n //
|
|
1
|
+
{"version":3,"sources":["../../src/third-parties/meta-pixel.ts"],"sourcesContent":["import { type FBQ, type PixelId, mapFBEvent } from '../track/fbq';\nimport type { EventName, TrackName, TrackProperties } from '../track/types';\nimport { getFirst } from '../utils/field';\nimport type { UpdateVisitorDTO } from '../visitor/types';\n\ndeclare global {\n // oxlint-disable-next-line typescript/no-empty-object-type\n interface Window extends FBQ {}\n}\n\nconst metrics = ['CLS', 'FCP', 'FID', 'INP', 'LCP', 'TTFB'];\n\nexport function sendFBEvent<T extends EventName>(\n name: TrackName<T>,\n properties?: TrackProperties<T>,\n event_id?: string\n) {\n if (typeof window === 'undefined' || !window.fbq) {\n console.warn('fbq has not been initialized');\n return;\n }\n if (metrics.includes(name)) return;\n if (window.location.host.includes('127.0.0.1')) return;\n if (window.location.host.includes('localhost')) return;\n\n const options = { eventID: event_id };\n const [type, fbEventName, fbEventProperties] = mapFBEvent(name, properties);\n if (type === 'track') {\n window.fbq(type, fbEventName, fbEventProperties, options);\n } else {\n window.fbq(type, fbEventName, fbEventProperties, options);\n }\n}\n\nexport function setFBUser(pixelId: PixelId) {\n return ({ user_id, data }: UpdateVisitorDTO) => {\n if (typeof window === 'undefined' || !window.fbq) {\n console.warn('fbq has not been initialized');\n return;\n }\n\n const address = getFirst(data?.address);\n\n window.fbq('init', pixelId, {\n em: getFirst(data?.email),\n fn: address?.first_name,\n ln: address?.last_name,\n ph: getFirst(data?.phone_number),\n external_id: user_id,\n ct: address?.city,\n st: address?.street,\n zp: address?.postal_code,\n country: address?.country,\n });\n };\n}\n"],"mappings":";AAAA,SAAiC,kBAAkB;AAEnD,SAAS,gBAAgB;AAQzB,IAAM,UAAU,CAAC,OAAO,OAAO,OAAO,OAAO,OAAO,MAAM;AAEnD,SAAS,YACd,MACA,YACA,UACA;AACA,MAAI,OAAO,WAAW,eAAe,CAAC,OAAO,KAAK;AAChD,YAAQ,KAAK,8BAA8B;AAC3C;AAAA,EACF;AACA,MAAI,QAAQ,SAAS,IAAI,EAAG;AAC5B,MAAI,OAAO,SAAS,KAAK,SAAS,WAAW,EAAG;AAChD,MAAI,OAAO,SAAS,KAAK,SAAS,WAAW,EAAG;AAEhD,QAAM,UAAU,EAAE,SAAS,SAAS;AACpC,QAAM,CAAC,MAAM,aAAa,iBAAiB,IAAI,WAAW,MAAM,UAAU;AAC1E,MAAI,SAAS,SAAS;AACpB,WAAO,IAAI,MAAM,aAAa,mBAAmB,OAAO;AAAA,EAC1D,OAAO;AACL,WAAO,IAAI,MAAM,aAAa,mBAAmB,OAAO;AAAA,EAC1D;AACF;AAEO,SAAS,UAAU,SAAkB;AAC1C,SAAO,CAAC,EAAE,SAAS,KAAK,MAAwB;AAC9C,QAAI,OAAO,WAAW,eAAe,CAAC,OAAO,KAAK;AAChD,cAAQ,KAAK,8BAA8B;AAC3C;AAAA,IACF;AAEA,UAAM,UAAU,SAAS,6BAAM,OAAO;AAEtC,WAAO,IAAI,QAAQ,SAAS;AAAA,MAC1B,IAAI,SAAS,6BAAM,KAAK;AAAA,MACxB,IAAI,mCAAS;AAAA,MACb,IAAI,mCAAS;AAAA,MACb,IAAI,SAAS,6BAAM,YAAY;AAAA,MAC/B,aAAa;AAAA,MACb,IAAI,mCAAS;AAAA,MACb,IAAI,mCAAS;AAAA,MACb,IAAI,mCAAS;AAAA,MACb,SAAS,mCAAS;AAAA,IACpB,CAAC;AAAA,EACH;AACF;","names":[]}
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
|
|
20
|
+
// src/third-parties/openai-pixel.ts
|
|
21
|
+
var openai_pixel_exports = {};
|
|
22
|
+
__export(openai_pixel_exports, {
|
|
23
|
+
sendOpenAIEvent: () => sendOpenAIEvent,
|
|
24
|
+
setOpenAIUser: () => setOpenAIUser
|
|
25
|
+
});
|
|
26
|
+
module.exports = __toCommonJS(openai_pixel_exports);
|
|
27
|
+
var import_oaiq = require("../track/oaiq.cjs");
|
|
28
|
+
var import_field = require("../utils/field.cjs");
|
|
29
|
+
var metrics = ["CLS", "FCP", "FID", "INP", "LCP", "TTFB"];
|
|
30
|
+
function clean(value) {
|
|
31
|
+
return JSON.parse(JSON.stringify(value));
|
|
32
|
+
}
|
|
33
|
+
function sendOpenAIEvent(name, properties, eventId) {
|
|
34
|
+
if (typeof window === "undefined" || !window.oaiq) {
|
|
35
|
+
console.warn("oaiq has not been initialized");
|
|
36
|
+
return;
|
|
37
|
+
}
|
|
38
|
+
if (metrics.includes(name)) return;
|
|
39
|
+
if (window.location.host.includes("127.0.0.1")) return;
|
|
40
|
+
if (window.location.host.includes("localhost")) return;
|
|
41
|
+
const { type, data } = (0, import_oaiq.mapOAIEvent)(name, properties);
|
|
42
|
+
if (type === "custom") {
|
|
43
|
+
window.oaiq("measure", "custom", clean(data), { event_id: eventId, custom_event_name: name });
|
|
44
|
+
} else {
|
|
45
|
+
window.oaiq("measure", type, clean(data), { event_id: eventId });
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
async function sha256(value) {
|
|
49
|
+
const bytes = new TextEncoder().encode(value);
|
|
50
|
+
const digest = await crypto.subtle.digest("SHA-256", bytes);
|
|
51
|
+
return Array.from(new Uint8Array(digest)).map((byte) => byte.toString(16).padStart(2, "0")).join("");
|
|
52
|
+
}
|
|
53
|
+
function setOpenAIUser(pixelId) {
|
|
54
|
+
return ({ user_id, data }) => {
|
|
55
|
+
var _a, _b, _c;
|
|
56
|
+
if (typeof window === "undefined" || !window.oaiq) {
|
|
57
|
+
console.warn("oaiq has not been initialized");
|
|
58
|
+
return;
|
|
59
|
+
}
|
|
60
|
+
const email = (_a = (0, import_field.getFirst)(data == null ? void 0 : data.email)) == null ? void 0 : _a.trim().toLowerCase();
|
|
61
|
+
const address = (0, import_field.getFirst)(data == null ? void 0 : data.address);
|
|
62
|
+
const base = {
|
|
63
|
+
country: (_b = address == null ? void 0 : address.country) == null ? void 0 : _b.trim().toUpperCase(),
|
|
64
|
+
city: (_c = address == null ? void 0 : address.city) == null ? void 0 : _c.trim().toLowerCase(),
|
|
65
|
+
zip_code: address == null ? void 0 : address.postal_code
|
|
66
|
+
};
|
|
67
|
+
const init = (hashed) => {
|
|
68
|
+
window.oaiq("init", { pixelId, user: clean({ ...base, ...hashed }) });
|
|
69
|
+
};
|
|
70
|
+
Promise.all([email ? sha256(email) : void 0, user_id ? sha256(user_id) : void 0]).then(([email_sha256, external_id_sha256]) => init({ email_sha256, external_id_sha256 })).catch(() => init({}));
|
|
71
|
+
};
|
|
72
|
+
}
|
|
73
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
74
|
+
0 && (module.exports = {
|
|
75
|
+
sendOpenAIEvent,
|
|
76
|
+
setOpenAIUser
|
|
77
|
+
});
|
|
78
|
+
//# sourceMappingURL=openai-pixel.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/third-parties/openai-pixel.ts"],"sourcesContent":["import { type OAIQ, type OAIQUser, mapOAIEvent } from '../track/oaiq';\nimport type { EventName, TrackName, TrackProperties } from '../track/types';\nimport { getFirst } from '../utils/field';\nimport type { UpdateVisitorDTO } from '../visitor/types';\n\ndeclare global {\n // oxlint-disable-next-line typescript/no-empty-object-type\n interface Window extends OAIQ {}\n}\n\nconst metrics = ['CLS', 'FCP', 'FID', 'INP', 'LCP', 'TTFB'];\n\n/** Drop `undefined` fields so the SDK only receives populated values. */\n// oxlint-disable-next-line @typescript-eslint/no-explicit-any\nfunction clean(value: unknown): any {\n return JSON.parse(JSON.stringify(value));\n}\n\n/**\n * Forward an internal track event to the OpenAI measurement pixel.\n * `eventId` is reused as the OpenAI `event_id` so browser events deduplicate against the\n * Conversions API. https://developers.openai.com/ads/measurement-pixel\n */\nexport function sendOpenAIEvent<T extends EventName>(\n name: TrackName<T>,\n properties?: TrackProperties<T>,\n eventId?: string\n) {\n if (typeof window === 'undefined' || !window.oaiq) {\n console.warn('oaiq has not been initialized');\n return;\n }\n if (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 { type, data } = mapOAIEvent(name, properties);\n if (type === 'custom') {\n window.oaiq('measure', 'custom', clean(data), { event_id: eventId, custom_event_name: name });\n } else {\n window.oaiq('measure', type, clean(data), { event_id: eventId });\n }\n}\n\n/** SHA-256 hex digest, lowercase — the format OpenAI expects for hashed identity fields. */\nasync function sha256(value: string): Promise<string> {\n const bytes = new TextEncoder().encode(value);\n const digest = await crypto.subtle.digest('SHA-256', bytes);\n return Array.from(new Uint8Array(digest))\n .map((byte) => byte.toString(16).padStart(2, '0'))\n .join('');\n}\n\n/**\n * Re-initialize the pixel with hashed user identity for better conversion matching. Email and\n * external id are hashed client-side; geographic fields are sent raw. Hashing is asynchronous,\n * so the `init` call is deferred until the digests resolve.\n */\nexport function setOpenAIUser(pixelId: string) {\n return ({ user_id, data }: UpdateVisitorDTO) => {\n if (typeof window === 'undefined' || !window.oaiq) {\n console.warn('oaiq has not been initialized');\n return;\n }\n\n const email = getFirst(data?.email)?.trim().toLowerCase();\n const address = getFirst(data?.address);\n\n const base: OAIQUser = {\n country: address?.country?.trim().toUpperCase(),\n city: address?.city?.trim().toLowerCase(),\n zip_code: address?.postal_code,\n };\n\n const init = (hashed: Partial<OAIQUser>) => {\n window.oaiq('init', { pixelId, user: clean({ ...base, ...hashed }) });\n };\n\n Promise.all([email ? sha256(email) : undefined, user_id ? sha256(user_id) : undefined])\n .then(([email_sha256, external_id_sha256]) => init({ email_sha256, external_id_sha256 }))\n .catch(() => init({}));\n };\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,kBAAsD;AAEtD,mBAAyB;AAQzB,IAAM,UAAU,CAAC,OAAO,OAAO,OAAO,OAAO,OAAO,MAAM;AAI1D,SAAS,MAAM,OAAqB;AAClC,SAAO,KAAK,MAAM,KAAK,UAAU,KAAK,CAAC;AACzC;AAOO,SAAS,gBACd,MACA,YACA,SACA;AACA,MAAI,OAAO,WAAW,eAAe,CAAC,OAAO,MAAM;AACjD,YAAQ,KAAK,+BAA+B;AAC5C;AAAA,EACF;AACA,MAAI,QAAQ,SAAS,IAAI,EAAG;AAC5B,MAAI,OAAO,SAAS,KAAK,SAAS,WAAW,EAAG;AAChD,MAAI,OAAO,SAAS,KAAK,SAAS,WAAW,EAAG;AAEhD,QAAM,EAAE,MAAM,KAAK,QAAI,yBAAY,MAAM,UAAU;AACnD,MAAI,SAAS,UAAU;AACrB,WAAO,KAAK,WAAW,UAAU,MAAM,IAAI,GAAG,EAAE,UAAU,SAAS,mBAAmB,KAAK,CAAC;AAAA,EAC9F,OAAO;AACL,WAAO,KAAK,WAAW,MAAM,MAAM,IAAI,GAAG,EAAE,UAAU,QAAQ,CAAC;AAAA,EACjE;AACF;AAGA,eAAe,OAAO,OAAgC;AACpD,QAAM,QAAQ,IAAI,YAAY,EAAE,OAAO,KAAK;AAC5C,QAAM,SAAS,MAAM,OAAO,OAAO,OAAO,WAAW,KAAK;AAC1D,SAAO,MAAM,KAAK,IAAI,WAAW,MAAM,CAAC,EACrC,IAAI,CAAC,SAAS,KAAK,SAAS,EAAE,EAAE,SAAS,GAAG,GAAG,CAAC,EAChD,KAAK,EAAE;AACZ;AAOO,SAAS,cAAc,SAAiB;AAC7C,SAAO,CAAC,EAAE,SAAS,KAAK,MAAwB;AA3DlD;AA4DI,QAAI,OAAO,WAAW,eAAe,CAAC,OAAO,MAAM;AACjD,cAAQ,KAAK,+BAA+B;AAC5C;AAAA,IACF;AAEA,UAAM,SAAQ,gCAAS,6BAAM,KAAK,MAApB,mBAAuB,OAAO;AAC5C,UAAM,cAAU,uBAAS,6BAAM,OAAO;AAEtC,UAAM,OAAiB;AAAA,MACrB,UAAS,wCAAS,YAAT,mBAAkB,OAAO;AAAA,MAClC,OAAM,wCAAS,SAAT,mBAAe,OAAO;AAAA,MAC5B,UAAU,mCAAS;AAAA,IACrB;AAEA,UAAM,OAAO,CAAC,WAA8B;AAC1C,aAAO,KAAK,QAAQ,EAAE,SAAS,MAAM,MAAM,EAAE,GAAG,MAAM,GAAG,OAAO,CAAC,EAAE,CAAC;AAAA,IACtE;AAEA,YAAQ,IAAI,CAAC,QAAQ,OAAO,KAAK,IAAI,QAAW,UAAU,OAAO,OAAO,IAAI,MAAS,CAAC,EACnF,KAAK,CAAC,CAAC,cAAc,kBAAkB,MAAM,KAAK,EAAE,cAAc,mBAAmB,CAAC,CAAC,EACvF,MAAM,MAAM,KAAK,CAAC,CAAC,CAAC;AAAA,EACzB;AACF;","names":[]}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { OAIQ } from '../track/oaiq.cjs';
|
|
2
|
+
import { EventName, TrackName, TrackProperties } from '../track/types.cjs';
|
|
3
|
+
import { UpdateVisitorDTO } from '../visitor/types.cjs';
|
|
4
|
+
import '../track/gtag.cjs';
|
|
5
|
+
|
|
6
|
+
declare global {
|
|
7
|
+
interface Window extends OAIQ {
|
|
8
|
+
}
|
|
9
|
+
}
|
|
10
|
+
/**
|
|
11
|
+
* Forward an internal track event to the OpenAI measurement pixel.
|
|
12
|
+
* `eventId` is reused as the OpenAI `event_id` so browser events deduplicate against the
|
|
13
|
+
* Conversions API. https://developers.openai.com/ads/measurement-pixel
|
|
14
|
+
*/
|
|
15
|
+
declare function sendOpenAIEvent<T extends EventName>(name: TrackName<T>, properties?: TrackProperties<T>, eventId?: string): void;
|
|
16
|
+
/**
|
|
17
|
+
* Re-initialize the pixel with hashed user identity for better conversion matching. Email and
|
|
18
|
+
* external id are hashed client-side; geographic fields are sent raw. Hashing is asynchronous,
|
|
19
|
+
* so the `init` call is deferred until the digests resolve.
|
|
20
|
+
*/
|
|
21
|
+
declare function setOpenAIUser(pixelId: string): ({ user_id, data }: UpdateVisitorDTO) => void;
|
|
22
|
+
|
|
23
|
+
export { sendOpenAIEvent, setOpenAIUser };
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { OAIQ } from '../track/oaiq.js';
|
|
2
|
+
import { EventName, TrackName, TrackProperties } from '../track/types.js';
|
|
3
|
+
import { UpdateVisitorDTO } from '../visitor/types.js';
|
|
4
|
+
import '../track/gtag.js';
|
|
5
|
+
|
|
6
|
+
declare global {
|
|
7
|
+
interface Window extends OAIQ {
|
|
8
|
+
}
|
|
9
|
+
}
|
|
10
|
+
/**
|
|
11
|
+
* Forward an internal track event to the OpenAI measurement pixel.
|
|
12
|
+
* `eventId` is reused as the OpenAI `event_id` so browser events deduplicate against the
|
|
13
|
+
* Conversions API. https://developers.openai.com/ads/measurement-pixel
|
|
14
|
+
*/
|
|
15
|
+
declare function sendOpenAIEvent<T extends EventName>(name: TrackName<T>, properties?: TrackProperties<T>, eventId?: string): void;
|
|
16
|
+
/**
|
|
17
|
+
* Re-initialize the pixel with hashed user identity for better conversion matching. Email and
|
|
18
|
+
* external id are hashed client-side; geographic fields are sent raw. Hashing is asynchronous,
|
|
19
|
+
* so the `init` call is deferred until the digests resolve.
|
|
20
|
+
*/
|
|
21
|
+
declare function setOpenAIUser(pixelId: string): ({ user_id, data }: UpdateVisitorDTO) => void;
|
|
22
|
+
|
|
23
|
+
export { sendOpenAIEvent, setOpenAIUser };
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
// src/third-parties/openai-pixel.ts
|
|
2
|
+
import { mapOAIEvent } from "../track/oaiq.mjs";
|
|
3
|
+
import { getFirst } from "../utils/field.mjs";
|
|
4
|
+
var metrics = ["CLS", "FCP", "FID", "INP", "LCP", "TTFB"];
|
|
5
|
+
function clean(value) {
|
|
6
|
+
return JSON.parse(JSON.stringify(value));
|
|
7
|
+
}
|
|
8
|
+
function sendOpenAIEvent(name, properties, eventId) {
|
|
9
|
+
if (typeof window === "undefined" || !window.oaiq) {
|
|
10
|
+
console.warn("oaiq has not been initialized");
|
|
11
|
+
return;
|
|
12
|
+
}
|
|
13
|
+
if (metrics.includes(name)) return;
|
|
14
|
+
if (window.location.host.includes("127.0.0.1")) return;
|
|
15
|
+
if (window.location.host.includes("localhost")) return;
|
|
16
|
+
const { type, data } = mapOAIEvent(name, properties);
|
|
17
|
+
if (type === "custom") {
|
|
18
|
+
window.oaiq("measure", "custom", clean(data), { event_id: eventId, custom_event_name: name });
|
|
19
|
+
} else {
|
|
20
|
+
window.oaiq("measure", type, clean(data), { event_id: eventId });
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
async function sha256(value) {
|
|
24
|
+
const bytes = new TextEncoder().encode(value);
|
|
25
|
+
const digest = await crypto.subtle.digest("SHA-256", bytes);
|
|
26
|
+
return Array.from(new Uint8Array(digest)).map((byte) => byte.toString(16).padStart(2, "0")).join("");
|
|
27
|
+
}
|
|
28
|
+
function setOpenAIUser(pixelId) {
|
|
29
|
+
return ({ user_id, data }) => {
|
|
30
|
+
var _a, _b, _c;
|
|
31
|
+
if (typeof window === "undefined" || !window.oaiq) {
|
|
32
|
+
console.warn("oaiq has not been initialized");
|
|
33
|
+
return;
|
|
34
|
+
}
|
|
35
|
+
const email = (_a = getFirst(data == null ? void 0 : data.email)) == null ? void 0 : _a.trim().toLowerCase();
|
|
36
|
+
const address = getFirst(data == null ? void 0 : data.address);
|
|
37
|
+
const base = {
|
|
38
|
+
country: (_b = address == null ? void 0 : address.country) == null ? void 0 : _b.trim().toUpperCase(),
|
|
39
|
+
city: (_c = address == null ? void 0 : address.city) == null ? void 0 : _c.trim().toLowerCase(),
|
|
40
|
+
zip_code: address == null ? void 0 : address.postal_code
|
|
41
|
+
};
|
|
42
|
+
const init = (hashed) => {
|
|
43
|
+
window.oaiq("init", { pixelId, user: clean({ ...base, ...hashed }) });
|
|
44
|
+
};
|
|
45
|
+
Promise.all([email ? sha256(email) : void 0, user_id ? sha256(user_id) : void 0]).then(([email_sha256, external_id_sha256]) => init({ email_sha256, external_id_sha256 })).catch(() => init({}));
|
|
46
|
+
};
|
|
47
|
+
}
|
|
48
|
+
export {
|
|
49
|
+
sendOpenAIEvent,
|
|
50
|
+
setOpenAIUser
|
|
51
|
+
};
|
|
52
|
+
//# sourceMappingURL=openai-pixel.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/third-parties/openai-pixel.ts"],"sourcesContent":["import { type OAIQ, type OAIQUser, mapOAIEvent } from '../track/oaiq';\nimport type { EventName, TrackName, TrackProperties } from '../track/types';\nimport { getFirst } from '../utils/field';\nimport type { UpdateVisitorDTO } from '../visitor/types';\n\ndeclare global {\n // oxlint-disable-next-line typescript/no-empty-object-type\n interface Window extends OAIQ {}\n}\n\nconst metrics = ['CLS', 'FCP', 'FID', 'INP', 'LCP', 'TTFB'];\n\n/** Drop `undefined` fields so the SDK only receives populated values. */\n// oxlint-disable-next-line @typescript-eslint/no-explicit-any\nfunction clean(value: unknown): any {\n return JSON.parse(JSON.stringify(value));\n}\n\n/**\n * Forward an internal track event to the OpenAI measurement pixel.\n * `eventId` is reused as the OpenAI `event_id` so browser events deduplicate against the\n * Conversions API. https://developers.openai.com/ads/measurement-pixel\n */\nexport function sendOpenAIEvent<T extends EventName>(\n name: TrackName<T>,\n properties?: TrackProperties<T>,\n eventId?: string\n) {\n if (typeof window === 'undefined' || !window.oaiq) {\n console.warn('oaiq has not been initialized');\n return;\n }\n if (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 { type, data } = mapOAIEvent(name, properties);\n if (type === 'custom') {\n window.oaiq('measure', 'custom', clean(data), { event_id: eventId, custom_event_name: name });\n } else {\n window.oaiq('measure', type, clean(data), { event_id: eventId });\n }\n}\n\n/** SHA-256 hex digest, lowercase — the format OpenAI expects for hashed identity fields. */\nasync function sha256(value: string): Promise<string> {\n const bytes = new TextEncoder().encode(value);\n const digest = await crypto.subtle.digest('SHA-256', bytes);\n return Array.from(new Uint8Array(digest))\n .map((byte) => byte.toString(16).padStart(2, '0'))\n .join('');\n}\n\n/**\n * Re-initialize the pixel with hashed user identity for better conversion matching. Email and\n * external id are hashed client-side; geographic fields are sent raw. Hashing is asynchronous,\n * so the `init` call is deferred until the digests resolve.\n */\nexport function setOpenAIUser(pixelId: string) {\n return ({ user_id, data }: UpdateVisitorDTO) => {\n if (typeof window === 'undefined' || !window.oaiq) {\n console.warn('oaiq has not been initialized');\n return;\n }\n\n const email = getFirst(data?.email)?.trim().toLowerCase();\n const address = getFirst(data?.address);\n\n const base: OAIQUser = {\n country: address?.country?.trim().toUpperCase(),\n city: address?.city?.trim().toLowerCase(),\n zip_code: address?.postal_code,\n };\n\n const init = (hashed: Partial<OAIQUser>) => {\n window.oaiq('init', { pixelId, user: clean({ ...base, ...hashed }) });\n };\n\n Promise.all([email ? sha256(email) : undefined, user_id ? sha256(user_id) : undefined])\n .then(([email_sha256, external_id_sha256]) => init({ email_sha256, external_id_sha256 }))\n .catch(() => init({}));\n };\n}\n"],"mappings":";AAAA,SAAmC,mBAAmB;AAEtD,SAAS,gBAAgB;AAQzB,IAAM,UAAU,CAAC,OAAO,OAAO,OAAO,OAAO,OAAO,MAAM;AAI1D,SAAS,MAAM,OAAqB;AAClC,SAAO,KAAK,MAAM,KAAK,UAAU,KAAK,CAAC;AACzC;AAOO,SAAS,gBACd,MACA,YACA,SACA;AACA,MAAI,OAAO,WAAW,eAAe,CAAC,OAAO,MAAM;AACjD,YAAQ,KAAK,+BAA+B;AAC5C;AAAA,EACF;AACA,MAAI,QAAQ,SAAS,IAAI,EAAG;AAC5B,MAAI,OAAO,SAAS,KAAK,SAAS,WAAW,EAAG;AAChD,MAAI,OAAO,SAAS,KAAK,SAAS,WAAW,EAAG;AAEhD,QAAM,EAAE,MAAM,KAAK,IAAI,YAAY,MAAM,UAAU;AACnD,MAAI,SAAS,UAAU;AACrB,WAAO,KAAK,WAAW,UAAU,MAAM,IAAI,GAAG,EAAE,UAAU,SAAS,mBAAmB,KAAK,CAAC;AAAA,EAC9F,OAAO;AACL,WAAO,KAAK,WAAW,MAAM,MAAM,IAAI,GAAG,EAAE,UAAU,QAAQ,CAAC;AAAA,EACjE;AACF;AAGA,eAAe,OAAO,OAAgC;AACpD,QAAM,QAAQ,IAAI,YAAY,EAAE,OAAO,KAAK;AAC5C,QAAM,SAAS,MAAM,OAAO,OAAO,OAAO,WAAW,KAAK;AAC1D,SAAO,MAAM,KAAK,IAAI,WAAW,MAAM,CAAC,EACrC,IAAI,CAAC,SAAS,KAAK,SAAS,EAAE,EAAE,SAAS,GAAG,GAAG,CAAC,EAChD,KAAK,EAAE;AACZ;AAOO,SAAS,cAAc,SAAiB;AAC7C,SAAO,CAAC,EAAE,SAAS,KAAK,MAAwB;AA3DlD;AA4DI,QAAI,OAAO,WAAW,eAAe,CAAC,OAAO,MAAM;AACjD,cAAQ,KAAK,+BAA+B;AAC5C;AAAA,IACF;AAEA,UAAM,SAAQ,cAAS,6BAAM,KAAK,MAApB,mBAAuB,OAAO;AAC5C,UAAM,UAAU,SAAS,6BAAM,OAAO;AAEtC,UAAM,OAAiB;AAAA,MACrB,UAAS,wCAAS,YAAT,mBAAkB,OAAO;AAAA,MAClC,OAAM,wCAAS,SAAT,mBAAe,OAAO;AAAA,MAC5B,UAAU,mCAAS;AAAA,IACrB;AAEA,UAAM,OAAO,CAAC,WAA8B;AAC1C,aAAO,KAAK,QAAQ,EAAE,SAAS,MAAM,MAAM,EAAE,GAAG,MAAM,GAAG,OAAO,CAAC,EAAE,CAAC;AAAA,IACtE;AAEA,YAAQ,IAAI,CAAC,QAAQ,OAAO,KAAK,IAAI,QAAW,UAAU,OAAO,OAAO,IAAI,MAAS,CAAC,EACnF,KAAK,CAAC,CAAC,cAAc,kBAAkB,MAAM,KAAK,EAAE,cAAc,mBAAmB,CAAC,CAAC,EACvF,MAAM,MAAM,KAAK,CAAC,CAAC,CAAC;AAAA,EACzB;AACF;","names":[]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/third-parties/reddit-pixel.ts"],"sourcesContent":["import { type PixelId, type RDT, mapRDTEvent } from '../track/rdt';\nimport type { EventName, TrackName, TrackProperties } from '../track/types';\nimport { getFirst } from '../utils/field';\nimport type { UpdateVisitorDTO } from '../visitor/types';\n\ndeclare global {\n //
|
|
1
|
+
{"version":3,"sources":["../../src/third-parties/reddit-pixel.ts"],"sourcesContent":["import { type PixelId, type RDT, mapRDTEvent } from '../track/rdt';\nimport type { EventName, TrackName, TrackProperties } from '../track/types';\nimport { getFirst } from '../utils/field';\nimport type { UpdateVisitorDTO } from '../visitor/types';\n\ndeclare global {\n // oxlint-disable-next-line typescript/no-empty-object-type\n interface Window extends RDT {}\n}\n\nconst metrics = ['CLS', 'FCP', 'FID', 'INP', 'LCP', 'TTFB'];\n\nexport function sendRedditEvent<T extends EventName>(\n name: TrackName<T>,\n properties?: TrackProperties<T>,\n eventId?: string\n) {\n if (typeof window === 'undefined' || !window.rdt) {\n console.warn('rdt has not been initialized');\n return;\n }\n if (metrics.includes(name)) return;\n if (window.location.host.includes('127.0.0.1')) return;\n if (window.location.host.includes('localhost')) return;\n\n const [type, params] = mapRDTEvent(name, properties, eventId);\n if (type === 'Custom') {\n window.rdt('track', type, JSON.parse(JSON.stringify(params)));\n } else {\n window.rdt('track', type, JSON.parse(JSON.stringify(params)));\n }\n}\n\nexport function setRedditUser(pixelId: PixelId) {\n return ({ user_id, data }: UpdateVisitorDTO) => {\n if (!window.rdt) {\n console.warn('rdt has not been initialized');\n return;\n }\n\n window.rdt('init', pixelId, {\n email: getFirst(data?.email),\n phoneNumber: getFirst(data?.phone_number),\n externalId: user_id,\n });\n };\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,iBAAoD;AAEpD,mBAAyB;AAQzB,IAAM,UAAU,CAAC,OAAO,OAAO,OAAO,OAAO,OAAO,MAAM;AAEnD,SAAS,gBACd,MACA,YACA,SACA;AACA,MAAI,OAAO,WAAW,eAAe,CAAC,OAAO,KAAK;AAChD,YAAQ,KAAK,8BAA8B;AAC3C;AAAA,EACF;AACA,MAAI,QAAQ,SAAS,IAAI,EAAG;AAC5B,MAAI,OAAO,SAAS,KAAK,SAAS,WAAW,EAAG;AAChD,MAAI,OAAO,SAAS,KAAK,SAAS,WAAW,EAAG;AAEhD,QAAM,CAAC,MAAM,MAAM,QAAI,wBAAY,MAAM,YAAY,OAAO;AAC5D,MAAI,SAAS,UAAU;AACrB,WAAO,IAAI,SAAS,MAAM,KAAK,MAAM,KAAK,UAAU,MAAM,CAAC,CAAC;AAAA,EAC9D,OAAO;AACL,WAAO,IAAI,SAAS,MAAM,KAAK,MAAM,KAAK,UAAU,MAAM,CAAC,CAAC;AAAA,EAC9D;AACF;AAEO,SAAS,cAAc,SAAkB;AAC9C,SAAO,CAAC,EAAE,SAAS,KAAK,MAAwB;AAC9C,QAAI,CAAC,OAAO,KAAK;AACf,cAAQ,KAAK,8BAA8B;AAC3C;AAAA,IACF;AAEA,WAAO,IAAI,QAAQ,SAAS;AAAA,MAC1B,WAAO,uBAAS,6BAAM,KAAK;AAAA,MAC3B,iBAAa,uBAAS,6BAAM,YAAY;AAAA,MACxC,YAAY;AAAA,IACd,CAAC;AAAA,EACH;AACF;","names":[]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/third-parties/reddit-pixel.ts"],"sourcesContent":["import { type PixelId, type RDT, mapRDTEvent } from '../track/rdt';\nimport type { EventName, TrackName, TrackProperties } from '../track/types';\nimport { getFirst } from '../utils/field';\nimport type { UpdateVisitorDTO } from '../visitor/types';\n\ndeclare global {\n //
|
|
1
|
+
{"version":3,"sources":["../../src/third-parties/reddit-pixel.ts"],"sourcesContent":["import { type PixelId, type RDT, mapRDTEvent } from '../track/rdt';\nimport type { EventName, TrackName, TrackProperties } from '../track/types';\nimport { getFirst } from '../utils/field';\nimport type { UpdateVisitorDTO } from '../visitor/types';\n\ndeclare global {\n // oxlint-disable-next-line typescript/no-empty-object-type\n interface Window extends RDT {}\n}\n\nconst metrics = ['CLS', 'FCP', 'FID', 'INP', 'LCP', 'TTFB'];\n\nexport function sendRedditEvent<T extends EventName>(\n name: TrackName<T>,\n properties?: TrackProperties<T>,\n eventId?: string\n) {\n if (typeof window === 'undefined' || !window.rdt) {\n console.warn('rdt has not been initialized');\n return;\n }\n if (metrics.includes(name)) return;\n if (window.location.host.includes('127.0.0.1')) return;\n if (window.location.host.includes('localhost')) return;\n\n const [type, params] = mapRDTEvent(name, properties, eventId);\n if (type === 'Custom') {\n window.rdt('track', type, JSON.parse(JSON.stringify(params)));\n } else {\n window.rdt('track', type, JSON.parse(JSON.stringify(params)));\n }\n}\n\nexport function setRedditUser(pixelId: PixelId) {\n return ({ user_id, data }: UpdateVisitorDTO) => {\n if (!window.rdt) {\n console.warn('rdt has not been initialized');\n return;\n }\n\n window.rdt('init', pixelId, {\n email: getFirst(data?.email),\n phoneNumber: getFirst(data?.phone_number),\n externalId: user_id,\n });\n };\n}\n"],"mappings":";AAAA,SAAiC,mBAAmB;AAEpD,SAAS,gBAAgB;AAQzB,IAAM,UAAU,CAAC,OAAO,OAAO,OAAO,OAAO,OAAO,MAAM;AAEnD,SAAS,gBACd,MACA,YACA,SACA;AACA,MAAI,OAAO,WAAW,eAAe,CAAC,OAAO,KAAK;AAChD,YAAQ,KAAK,8BAA8B;AAC3C;AAAA,EACF;AACA,MAAI,QAAQ,SAAS,IAAI,EAAG;AAC5B,MAAI,OAAO,SAAS,KAAK,SAAS,WAAW,EAAG;AAChD,MAAI,OAAO,SAAS,KAAK,SAAS,WAAW,EAAG;AAEhD,QAAM,CAAC,MAAM,MAAM,IAAI,YAAY,MAAM,YAAY,OAAO;AAC5D,MAAI,SAAS,UAAU;AACrB,WAAO,IAAI,SAAS,MAAM,KAAK,MAAM,KAAK,UAAU,MAAM,CAAC,CAAC;AAAA,EAC9D,OAAO;AACL,WAAO,IAAI,SAAS,MAAM,KAAK,MAAM,KAAK,UAAU,MAAM,CAAC,CAAC;AAAA,EAC9D;AACF;AAEO,SAAS,cAAc,SAAkB;AAC9C,SAAO,CAAC,EAAE,SAAS,KAAK,MAAwB;AAC9C,QAAI,CAAC,OAAO,KAAK;AACf,cAAQ,KAAK,8BAA8B;AAC3C;AAAA,IACF;AAEA,WAAO,IAAI,QAAQ,SAAS;AAAA,MAC1B,OAAO,SAAS,6BAAM,KAAK;AAAA,MAC3B,aAAa,SAAS,6BAAM,YAAY;AAAA,MACxC,YAAY;AAAA,IACd,CAAC;AAAA,EACH;AACF;","names":[]}
|
package/dist/track/gtag.cjs.map
CHANGED
|
@@ -1 +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\nexport type SurveyProperties = {\n id?: string;\n feature?: Lowercase<string>;\n trigger?: Lowercase<string>;\n};\n\nexport type SurveyQA = {\n q1: string;\n a1: string;\n q2?: string;\n a2?: string;\n q3?: string;\n a3?: string;\n q4?: string;\n a4?: string;\n q5?: string;\n a5?: string;\n q6?: string;\n a6?: string;\n completed?: boolean;\n};\n\nexport type NPSScore = 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | number;\nexport type CASTScore = 1 | 2 | 3 | 4 | 5 | number;\nexport type CESScore = 1 | 2 | 3 | 4 | 5 | number;\n\n/** ref: https://support.google.com/analytics/answer/9216061 */\nexport type EnhancedMeasurementEvents = {\n page_view: {\n page_path: string;\n page_title: string;\n page_referrer?: string;\n page_location?: string;\n previous_page_path?: string;\n engagement_time_msec?: number;\n };\n // Scrolls: the first time a user reaches the bottom of each page\n // (i.e., when a 90% vertical depth becomes visible)\n scroll: {\n engagement_time_msec: number;\n };\n // Outbound clicks\n click: {\n link_id: string;\n link_url: string;\n link_text: string; // added\n link_domain: string;\n link_classes: string;\n outbound: boolean;\n };\n // Site search\n view_search_results: {\n search_term: string;\n };\n // Video engagement\n video_start: {\n video_current_time: number;\n video_duration: number;\n video_percent: number;\n video_provider: 'youtube' | 'vimeo' | 'html5' | (string & {});\n video_title: string;\n video_url: string;\n visible: boolean;\n };\n video_progress: {\n video_current_time: number;\n video_duration: number;\n video_percent: number;\n video_provider: 'youtube' | 'vimeo' | 'html5' | (string & {});\n video_title: string;\n video_url: string;\n visible: boolean;\n };\n video_complete: {\n video_current_time: number;\n video_duration: number;\n video_percent: number;\n video_provider: 'youtube' | 'vimeo' | 'html5' | (string & {});\n video_title: string;\n video_url: string;\n visible: boolean;\n };\n // File downloads:\n file_download: {\n file_extension: string;\n file_name: string;\n link_classes: string;\n link_id: string;\n link_text: string;\n link_url: string;\n };\n // Form interactions\n form_start: {\n form_id: string;\n form_name: string;\n form_destination: string;\n };\n form_submit: {\n form_id: string;\n form_name: string;\n form_destination: string;\n form_submit_text: string;\n };\n};\n\n/** ref: https://support.google.com/analytics/answer/9234069 */\nexport type AutomaticallyCollectedEvents = EnhancedMeasurementEvents & {\n first_visit: {\n page_path: string;\n page_title: string;\n page_referrer?: string;\n page_location?: string;\n };\n first_open: {\n screen_name: string;\n screen_class: string;\n };\n in_app_purchase: {\n product_id: string;\n price: number;\n value: number;\n currency: string;\n quantity: number;\n subscription?: boolean;\n free_trial?: boolean;\n introductory_price?: number;\n };\n notification_dismiss: {\n // Android only\n topic: string;\n label: string;\n message_id: string;\n message_name: string;\n message_time: number;\n message_device_time: number;\n message_channel: string;\n };\n notification_foreground: {\n topic: string;\n label: string;\n message_id: string;\n message_name: string;\n message_type: string;\n message_time: number;\n message_device_time: number;\n message_channel: string;\n };\n notification_open: {\n topic: string;\n label: string;\n message_id: string;\n message_name: string;\n message_time: number;\n message_device_time: number;\n message_channel: string;\n };\n notification_receive: {\n // Android only\n topic: string;\n label: string;\n message_id: string;\n message_name: string;\n message_type: string;\n message_time: number;\n message_device_time: number;\n message_channel: string;\n };\n // Note: The 'screen_view' event is automatically sent only when using Android or iOS native SDKs.\n // If you are using React Native, you need to send this event manually; it should not be ignored.\n session_start: undefined;\n user_engagement: {\n engagement_time_msec: number;\n trigger: 'pagehide' | 'visibilitychange' | 'background';\n };\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 RecommendedEvents = {\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 source?: string; // added\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?:\n | 'google'\n | 'apple'\n | 'facebook'\n | 'twitter'\n | 'linkedin'\n | 'github'\n | 'microsoft'\n | 'wechat'\n | 'onetap'\n | 'phone'\n | 'email'\n | (string & {});\n source?: string; // added\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 source?: string; // added\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 system_activity_type?: string; // added\n platform_post_id?: string; // added\n };\n sign_up: {\n method?: string;\n source?: string; // added\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: {\n screen_name?: string;\n screen_class?: string;\n previous_screen_class?: string; // added\n engagement_time_msec?: number;\n };\n};\n\nexport type AddedRecommendedEvents = {\n logout: undefined;\n trial_begin: {\n currency: string;\n value: number;\n source?: string; // added\n };\n subscribe: {\n currency: string;\n value: number;\n source?: string; // added\n };\n // survey\n survey_shown: SurveyProperties;\n survey_sent: SurveyProperties & SurveyQA;\n survey_dismissed: SurveyProperties;\n /**\n * Net promoter score: Get an industry-recognized benchmark\n * How likely are you to recommend us to a friend?\n * */\n nps_shown: SurveyProperties;\n nps_sent: SurveyProperties & { score: NPSScore; feedback?: string };\n nps_dismissed: SurveyProperties;\n /**\n * Customer satisfaction score: Works best after a checkout or support flow\n * How satisfied are you with xxx?\n * */\n cast_shown: SurveyProperties;\n cast_sent: SurveyProperties & { score: CASTScore; feedback?: string };\n cast_dismissed: SurveyProperties;\n /**\n * Customer effort score: Works well with churn surveys\n * How easy is it to use the feature?\n * */\n ces_shown: SurveyProperties;\n ces_sent: SurveyProperties & { score: CESScore; feedback?: string };\n ces_dismissed: SurveyProperties;\n};\n\nexport type StandardEvents = AutomaticallyCollectedEvents &\n RecommendedEvents &\n AddedRecommendedEvents;\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":[]}
|
|
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 * To standardize the hash results, before 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 * To standardize the hash results, before 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\nexport type SurveyProperties = {\n id?: string;\n feature?: Lowercase<string>;\n trigger?: Lowercase<string>;\n};\n\nexport type SurveyQA = {\n q1: string;\n a1: string;\n q2?: string;\n a2?: string;\n q3?: string;\n a3?: string;\n q4?: string;\n a4?: string;\n q5?: string;\n a5?: string;\n q6?: string;\n a6?: string;\n completed?: boolean;\n};\n\nexport type NPSScore = 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | number;\nexport type CASTScore = 1 | 2 | 3 | 4 | 5 | number;\nexport type CESScore = 1 | 2 | 3 | 4 | 5 | number;\n\n/** ref: https://support.google.com/analytics/answer/9216061 */\nexport type EnhancedMeasurementEvents = {\n page_view: {\n page_path: string;\n page_title: string;\n page_referrer?: string;\n page_location?: string;\n previous_page_path?: string;\n engagement_time_msec?: number;\n };\n // Scrolls: the first time a user reaches the bottom of each page\n // (i.e., when a 90% vertical depth becomes visible)\n scroll: {\n engagement_time_msec: number;\n };\n // Outbound clicks\n click: {\n link_id: string;\n link_url: string;\n link_text: string; // added\n link_domain: string;\n link_classes: string;\n outbound: boolean;\n };\n // Site search\n view_search_results: {\n search_term: string;\n };\n // Video engagement\n video_start: {\n video_current_time: number;\n video_duration: number;\n video_percent: number;\n video_provider: 'youtube' | 'vimeo' | 'html5' | (string & {});\n video_title: string;\n video_url: string;\n visible: boolean;\n };\n video_progress: {\n video_current_time: number;\n video_duration: number;\n video_percent: number;\n video_provider: 'youtube' | 'vimeo' | 'html5' | (string & {});\n video_title: string;\n video_url: string;\n visible: boolean;\n };\n video_complete: {\n video_current_time: number;\n video_duration: number;\n video_percent: number;\n video_provider: 'youtube' | 'vimeo' | 'html5' | (string & {});\n video_title: string;\n video_url: string;\n visible: boolean;\n };\n // File downloads:\n file_download: {\n file_extension: string;\n file_name: string;\n link_classes: string;\n link_id: string;\n link_text: string;\n link_url: string;\n };\n // Form interactions\n form_start: {\n form_id: string;\n form_name: string;\n form_destination: string;\n };\n form_submit: {\n form_id: string;\n form_name: string;\n form_destination: string;\n form_submit_text: string;\n };\n};\n\n/** ref: https://support.google.com/analytics/answer/9234069 */\nexport type AutomaticallyCollectedEvents = EnhancedMeasurementEvents & {\n first_visit: {\n page_path: string;\n page_title: string;\n page_referrer?: string;\n page_location?: string;\n };\n first_open: {\n screen_name: string;\n screen_class: string;\n };\n in_app_purchase: {\n product_id: string;\n price: number;\n value: number;\n currency: string;\n quantity: number;\n subscription?: boolean;\n free_trial?: boolean;\n introductory_price?: number;\n };\n notification_dismiss: {\n // Android only\n topic: string;\n label: string;\n message_id: string;\n message_name: string;\n message_time: number;\n message_device_time: number;\n message_channel: string;\n };\n notification_foreground: {\n topic: string;\n label: string;\n message_id: string;\n message_name: string;\n message_type: string;\n message_time: number;\n message_device_time: number;\n message_channel: string;\n };\n notification_open: {\n topic: string;\n label: string;\n message_id: string;\n message_name: string;\n message_time: number;\n message_device_time: number;\n message_channel: string;\n };\n notification_receive: {\n // Android only\n topic: string;\n label: string;\n message_id: string;\n message_name: string;\n message_type: string;\n message_time: number;\n message_device_time: number;\n message_channel: string;\n };\n // Note: The 'screen_view' event is automatically sent only when using Android or iOS native SDKs.\n // If you are using React Native, you need to send this event manually; it should not be ignored.\n session_start: undefined;\n user_engagement: {\n engagement_time_msec: number;\n trigger: 'pagehide' | 'visibilitychange' | 'background';\n };\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 RecommendedEvents = {\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 source?: string; // added\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?:\n | 'google'\n | 'apple'\n | 'facebook'\n | 'twitter'\n | 'linkedin'\n | 'github'\n | 'microsoft'\n | 'wechat'\n | 'onetap'\n | 'phone'\n | 'email'\n | (string & {});\n source?: string; // added\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 source?: string; // added\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 system_activity_type?: string; // added\n platform_post_id?: string; // added\n };\n sign_up: {\n method?: string;\n source?: string; // added\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: {\n screen_name?: string;\n screen_class?: string;\n previous_screen_class?: string; // added\n engagement_time_msec?: number;\n };\n};\n\n/**\n * Extra commonly used events that are NOT part of the GA standard event set.\n * Added to satisfy additional analytics needs.\n */\nexport type AddedRecommendedEvents = {\n logout: undefined;\n trial_begin: {\n currency: string;\n value: number;\n source?: string; // added\n items?: Item[]; // added, the plan(s) enrolled (first item's id maps to OpenAI plan_id)\n };\n subscribe: {\n currency: string;\n value: number;\n source?: string; // added\n items?: Item[]; // added, the plan(s) enrolled (first item's id maps to OpenAI plan_id)\n };\n // survey\n survey_shown: SurveyProperties;\n survey_sent: SurveyProperties & SurveyQA;\n survey_dismissed: SurveyProperties;\n /**\n * Net promoter score: Get an industry-recognized benchmark\n * How likely are you to recommend us to a friend?\n * */\n nps_shown: SurveyProperties;\n nps_sent: SurveyProperties & { score: NPSScore; feedback?: string };\n nps_dismissed: SurveyProperties;\n /**\n * Customer satisfaction score: Works best after a checkout or support flow\n * How satisfied are you with xxx?\n * */\n cast_shown: SurveyProperties;\n cast_sent: SurveyProperties & { score: CASTScore; feedback?: string };\n cast_dismissed: SurveyProperties;\n /**\n * Customer effort score: Works well with churn surveys\n * How easy is it to use the feature?\n * */\n ces_shown: SurveyProperties;\n ces_sent: SurveyProperties & { score: CESScore; feedback?: string };\n ces_dismissed: SurveyProperties;\n};\n\nexport type StandardEvents = AutomaticallyCollectedEvents &\n RecommendedEvents &\n AddedRecommendedEvents;\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 event\n * @param option\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 event\n * @param option\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 event\n * @param option\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 (63,072,000 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 event\n * @param option\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 event\n * @param option\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 event\n * @param option\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 event\n * @param option\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 event\n * @param option\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 event\n * @param option\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 event\n * @param option\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 event\n * @param option\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 event\n * @param option\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 event\n * @param option\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 event\n * @param option\n * @param properties\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":[]}
|