@roottale/analytics-runtime 0.8.0 → 0.10.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +97 -0
- package/dist/{chunk-7RAWH2ET.js → chunk-752LEZBA.js} +4 -3
- package/dist/{chunk-7RAWH2ET.js.map → chunk-752LEZBA.js.map} +1 -1
- package/dist/{chunk-2F5EKINL.js → chunk-CKIYSGG4.js} +111 -2
- package/dist/chunk-CKIYSGG4.js.map +1 -0
- package/dist/{chunk-3NUDF5U2.js → chunk-HIDBZ22L.js} +104 -6
- package/dist/chunk-HIDBZ22L.js.map +1 -0
- package/dist/chunk-HISUF7TR.js +49 -0
- package/dist/chunk-HISUF7TR.js.map +1 -0
- package/dist/chunk-WJ6QUIXG.js +262 -0
- package/dist/chunk-WJ6QUIXG.js.map +1 -0
- package/dist/click-journey.d.ts +25 -0
- package/dist/click-journey.js +14 -0
- package/dist/click-journey.js.map +1 -0
- package/dist/events.d.ts +98 -12
- package/dist/events.js +19 -3
- package/dist/index.d.ts +13 -3
- package/dist/index.js +33 -7
- package/dist/index.js.map +1 -1
- package/dist/next.js +4 -2
- package/dist/next.js.map +1 -1
- package/dist/react.js +5 -4
- package/dist/react.js.map +1 -1
- package/package.json +8 -3
- package/dist/chunk-2F5EKINL.js.map +0 -1
- package/dist/chunk-3NUDF5U2.js.map +0 -1
- package/dist/chunk-LG34MRCQ.js +0 -153
- package/dist/chunk-LG34MRCQ.js.map +0 -1
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import {
|
|
2
|
+
isAiReferralId
|
|
3
|
+
} from "./chunk-KKGWQGIR.js";
|
|
4
|
+
|
|
5
|
+
// src/click-journey.ts
|
|
6
|
+
var CLICK_JOURNEY_MAX_PATHS = 10;
|
|
7
|
+
var CLICK_JOURNEY_MAX_BYTES = 1200;
|
|
8
|
+
var CLICK_JOURNEY_IDLE_MS = 30 * 60 * 1e3;
|
|
9
|
+
function record(value) {
|
|
10
|
+
return value !== null && typeof value === "object" && !Array.isArray(value) ? value : null;
|
|
11
|
+
}
|
|
12
|
+
function text(value, max) {
|
|
13
|
+
if (typeof value !== "string") return "";
|
|
14
|
+
return Array.from(value).filter((char) => char.charCodeAt(0) >= 32 && char.charCodeAt(0) !== 127).join("").trim().slice(0, max);
|
|
15
|
+
}
|
|
16
|
+
function normalizeClickJourney(value) {
|
|
17
|
+
const input = record(value);
|
|
18
|
+
const source = record(input?.s);
|
|
19
|
+
if (input?.v !== 1 || !Array.isArray(input.p) || !source) return null;
|
|
20
|
+
if (!input.p.length || input.p.length > CLICK_JOURNEY_MAX_PATHS) return null;
|
|
21
|
+
const paths = [];
|
|
22
|
+
for (const path of input.p) {
|
|
23
|
+
if (typeof path !== "string" || !path.startsWith("/") || path.startsWith("//")) return null;
|
|
24
|
+
const clean = text(path.split(/[?#]/)[0], 256);
|
|
25
|
+
if (!clean) return null;
|
|
26
|
+
paths.push(clean);
|
|
27
|
+
}
|
|
28
|
+
const s = {};
|
|
29
|
+
if (source.ref === 1) s.ref = 1;
|
|
30
|
+
if (source.gc === 1) s.gc = 1;
|
|
31
|
+
const air = text(source.air, 32);
|
|
32
|
+
if (isAiReferralId(air)) s.air = air;
|
|
33
|
+
const host = text(source.rh, 253).toLowerCase();
|
|
34
|
+
if (!s.air && /^[a-z0-9.-]{1,253}$/.test(host)) s.rh = host;
|
|
35
|
+
for (const key of ["us", "um", "uc", "rs"]) {
|
|
36
|
+
const item = text(source[key], key === "rs" ? 32 : 100);
|
|
37
|
+
if (item) s[key] = item;
|
|
38
|
+
}
|
|
39
|
+
const result = { v: 1, p: paths, s, ...input.cut === 1 ? { cut: 1 } : {} };
|
|
40
|
+
return new TextEncoder().encode(JSON.stringify(result)).length <= CLICK_JOURNEY_MAX_BYTES ? result : null;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
export {
|
|
44
|
+
CLICK_JOURNEY_MAX_PATHS,
|
|
45
|
+
CLICK_JOURNEY_MAX_BYTES,
|
|
46
|
+
CLICK_JOURNEY_IDLE_MS,
|
|
47
|
+
normalizeClickJourney
|
|
48
|
+
};
|
|
49
|
+
//# sourceMappingURL=chunk-HISUF7TR.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/click-journey.ts"],"sourcesContent":["import { isAiReferralId } from \"./ai-referrals\";\n\n/** 클릭 한 건에 함께 저장하는 경로. 방문자 ID나 시각은 포함하지 않는다. */\nexport interface ClickJourney {\n readonly v: 1;\n readonly p: readonly string[];\n readonly s: ClickJourneySource;\n /** 경로 길이 제한·수집 시작 누락으로 전체 이동을 알 수 없을 때. */\n readonly cut?: 1;\n}\n\nexport interface ClickJourneySource {\n readonly ref?: 1;\n readonly rh?: string;\n readonly air?: string;\n readonly us?: string;\n readonly um?: string;\n readonly uc?: string;\n readonly rs?: string;\n readonly gc?: 1;\n}\n\nexport const CLICK_JOURNEY_MAX_PATHS = 10;\nexport const CLICK_JOURNEY_MAX_BYTES = 1200;\nexport const CLICK_JOURNEY_IDLE_MS = 30 * 60 * 1000;\n\nfunction record(value: unknown): Record<string, unknown> | null {\n return value !== null && typeof value === \"object\" && !Array.isArray(value)\n ? (value as Record<string, unknown>)\n : null;\n}\n\nfunction text(value: unknown, max: number): string {\n if (typeof value !== \"string\") return \"\";\n return Array.from(value)\n .filter((char) => char.charCodeAt(0) >= 32 && char.charCodeAt(0) !== 127)\n .join(\"\").trim().slice(0, max);\n}\n\n/** /collect와 관리자 모두 같은 허용 목록으로 재구성한다. */\nexport function normalizeClickJourney(value: unknown): ClickJourney | null {\n const input = record(value);\n const source = record(input?.s);\n if (input?.v !== 1 || !Array.isArray(input.p) || !source) return null;\n if (!input.p.length || input.p.length > CLICK_JOURNEY_MAX_PATHS) return null;\n const paths: string[] = [];\n for (const path of input.p) {\n if (typeof path !== \"string\" || !path.startsWith(\"/\") || path.startsWith(\"//\")) return null;\n const clean = text(path.split(/[?#]/)[0], 256);\n if (!clean) return null;\n paths.push(clean);\n }\n const s: { -readonly [K in keyof ClickJourneySource]: ClickJourneySource[K] } = {};\n if (source.ref === 1) s.ref = 1;\n if (source.gc === 1) s.gc = 1;\n const air = text(source.air, 32);\n if (isAiReferralId(air)) s.air = air;\n const host = text(source.rh, 253).toLowerCase();\n if (!s.air && /^[a-z0-9.-]{1,253}$/.test(host)) s.rh = host;\n for (const key of [\"us\", \"um\", \"uc\", \"rs\"] as const) {\n const item = text(source[key], key === \"rs\" ? 32 : 100);\n if (item) s[key] = item;\n }\n const result: ClickJourney = { v: 1, p: paths, s, ...(input.cut === 1 ? { cut: 1 } : {}) };\n return new TextEncoder().encode(JSON.stringify(result)).length <= CLICK_JOURNEY_MAX_BYTES\n ? result : null;\n}\n"],"mappings":";;;;;AAsBO,IAAM,0BAA0B;AAChC,IAAM,0BAA0B;AAChC,IAAM,wBAAwB,KAAK,KAAK;AAE/C,SAAS,OAAO,OAAgD;AAC9D,SAAO,UAAU,QAAQ,OAAO,UAAU,YAAY,CAAC,MAAM,QAAQ,KAAK,IACrE,QACD;AACN;AAEA,SAAS,KAAK,OAAgB,KAAqB;AACjD,MAAI,OAAO,UAAU,SAAU,QAAO;AACtC,SAAO,MAAM,KAAK,KAAK,EACpB,OAAO,CAAC,SAAS,KAAK,WAAW,CAAC,KAAK,MAAM,KAAK,WAAW,CAAC,MAAM,GAAG,EACvE,KAAK,EAAE,EAAE,KAAK,EAAE,MAAM,GAAG,GAAG;AACjC;AAGO,SAAS,sBAAsB,OAAqC;AACzE,QAAM,QAAQ,OAAO,KAAK;AAC1B,QAAM,SAAS,OAAO,OAAO,CAAC;AAC9B,MAAI,OAAO,MAAM,KAAK,CAAC,MAAM,QAAQ,MAAM,CAAC,KAAK,CAAC,OAAQ,QAAO;AACjE,MAAI,CAAC,MAAM,EAAE,UAAU,MAAM,EAAE,SAAS,wBAAyB,QAAO;AACxE,QAAM,QAAkB,CAAC;AACzB,aAAW,QAAQ,MAAM,GAAG;AAC1B,QAAI,OAAO,SAAS,YAAY,CAAC,KAAK,WAAW,GAAG,KAAK,KAAK,WAAW,IAAI,EAAG,QAAO;AACvF,UAAM,QAAQ,KAAK,KAAK,MAAM,MAAM,EAAE,CAAC,GAAG,GAAG;AAC7C,QAAI,CAAC,MAAO,QAAO;AACnB,UAAM,KAAK,KAAK;AAAA,EAClB;AACA,QAAM,IAA0E,CAAC;AACjF,MAAI,OAAO,QAAQ,EAAG,GAAE,MAAM;AAC9B,MAAI,OAAO,OAAO,EAAG,GAAE,KAAK;AAC5B,QAAM,MAAM,KAAK,OAAO,KAAK,EAAE;AAC/B,MAAI,eAAe,GAAG,EAAG,GAAE,MAAM;AACjC,QAAM,OAAO,KAAK,OAAO,IAAI,GAAG,EAAE,YAAY;AAC9C,MAAI,CAAC,EAAE,OAAO,sBAAsB,KAAK,IAAI,EAAG,GAAE,KAAK;AACvD,aAAW,OAAO,CAAC,MAAM,MAAM,MAAM,IAAI,GAAY;AACnD,UAAM,OAAO,KAAK,OAAO,GAAG,GAAG,QAAQ,OAAO,KAAK,GAAG;AACtD,QAAI,KAAM,GAAE,GAAG,IAAI;AAAA,EACrB;AACA,QAAM,SAAuB,EAAE,GAAG,GAAG,GAAG,OAAO,GAAG,GAAI,MAAM,QAAQ,IAAI,EAAE,KAAK,EAAE,IAAI,CAAC,EAAG;AACzF,SAAO,IAAI,YAAY,EAAE,OAAO,KAAK,UAAU,MAAM,CAAC,EAAE,UAAU,0BAC9D,SAAS;AACf;","names":[]}
|
|
@@ -0,0 +1,262 @@
|
|
|
1
|
+
// src/form-error-contract.ts
|
|
2
|
+
var FORM_ERROR_CODES = [
|
|
3
|
+
"required",
|
|
4
|
+
"format",
|
|
5
|
+
"length",
|
|
6
|
+
"range",
|
|
7
|
+
"invalid",
|
|
8
|
+
"verification",
|
|
9
|
+
"rate_limited",
|
|
10
|
+
"network",
|
|
11
|
+
"server",
|
|
12
|
+
"unknown"
|
|
13
|
+
];
|
|
14
|
+
function normalizeFormError(value) {
|
|
15
|
+
const code = value.error_code;
|
|
16
|
+
if (typeof code !== "string" || !FORM_ERROR_CODES.includes(code)) return null;
|
|
17
|
+
const id = (input) => typeof input === "string" && /^[a-zA-Z0-9_:-]{1,100}$/.test(input) ? input : "";
|
|
18
|
+
const formId = id(value.form_id);
|
|
19
|
+
if (!formId) return null;
|
|
20
|
+
return { form_id: formId, field_id: id(value.field_id), error_code: code };
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
// src/site-error-contract.ts
|
|
24
|
+
var SITE_ERROR_CODES = ["script", "promise", "resource", "request"];
|
|
25
|
+
var SITE_ERROR_LIMIT = 10;
|
|
26
|
+
function normalizeSiteError(value) {
|
|
27
|
+
const code = value.error_code;
|
|
28
|
+
if (typeof code !== "string" || !SITE_ERROR_CODES.includes(code)) return null;
|
|
29
|
+
const operation = typeof value.operation === "string" && /^[a-zA-Z0-9_:-]{1,100}$/.test(value.operation) ? value.operation : "";
|
|
30
|
+
const status = Number(value.status_code);
|
|
31
|
+
return {
|
|
32
|
+
error_code: code,
|
|
33
|
+
operation,
|
|
34
|
+
status_code: Number.isInteger(status) && status >= 400 && status <= 599 ? String(status) : ""
|
|
35
|
+
};
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
// src/contact-links.ts
|
|
39
|
+
var CONTACT_LINK_RULES = {
|
|
40
|
+
protocols: {
|
|
41
|
+
"tel:": { event: "phone_click" },
|
|
42
|
+
"mailto:": { event: "email_click" }
|
|
43
|
+
},
|
|
44
|
+
hosts: {
|
|
45
|
+
"pf.kakao.com": { event: "chat_click", provider: "kakao" },
|
|
46
|
+
"open.kakao.com": { event: "chat_click", provider: "kakao" },
|
|
47
|
+
"talk.naver.com": { event: "chat_click", provider: "naver" },
|
|
48
|
+
"booking.naver.com": { event: "booking_click", provider: "naver" },
|
|
49
|
+
"m.booking.naver.com": { event: "booking_click", provider: "naver" }
|
|
50
|
+
}
|
|
51
|
+
};
|
|
52
|
+
function contactTrackForHref(href) {
|
|
53
|
+
try {
|
|
54
|
+
const url = new URL(href);
|
|
55
|
+
const protocols = CONTACT_LINK_RULES.protocols;
|
|
56
|
+
const hosts = CONTACT_LINK_RULES.hosts;
|
|
57
|
+
if (Object.hasOwn(protocols, url.protocol)) return protocols[url.protocol] ?? null;
|
|
58
|
+
if (url.protocol !== "https:" && url.protocol !== "http:") return null;
|
|
59
|
+
return Object.hasOwn(hosts, url.hostname) ? hosts[url.hostname] ?? null : null;
|
|
60
|
+
} catch {
|
|
61
|
+
return null;
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
function ctaTrackAttributes(href, cta, placement) {
|
|
65
|
+
const contact = contactTrackForHref(href);
|
|
66
|
+
return {
|
|
67
|
+
"data-track": contact?.event ?? "cta_click",
|
|
68
|
+
...contact?.provider ? { "data-track-provider": contact.provider } : {},
|
|
69
|
+
"data-track-cta": cta,
|
|
70
|
+
"data-track-placement": placement
|
|
71
|
+
};
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
// src/events.ts
|
|
75
|
+
var TRACK_EVENTS = {
|
|
76
|
+
pageview: { ga4: false, journey: true, dims: ["pid"], wireDims: ["pid"] },
|
|
77
|
+
lead_submit: {
|
|
78
|
+
ga4: true,
|
|
79
|
+
ga4Name: "generate_lead",
|
|
80
|
+
journey: true,
|
|
81
|
+
dims: ["form_id"],
|
|
82
|
+
wireDims: ["form_id"]
|
|
83
|
+
},
|
|
84
|
+
form_submit_attempt: {
|
|
85
|
+
ga4: false,
|
|
86
|
+
journey: true,
|
|
87
|
+
dims: ["form_id"],
|
|
88
|
+
wireDims: ["form_id"]
|
|
89
|
+
},
|
|
90
|
+
phone_click: {
|
|
91
|
+
ga4: true,
|
|
92
|
+
ga4Name: "phone_call_click",
|
|
93
|
+
journey: true,
|
|
94
|
+
dims: ["placement", "cta_id"],
|
|
95
|
+
wireDims: ["trackPlacement", "trackCta"]
|
|
96
|
+
},
|
|
97
|
+
email_click: {
|
|
98
|
+
ga4: true,
|
|
99
|
+
ga4Name: "email_click",
|
|
100
|
+
journey: true,
|
|
101
|
+
dims: ["placement", "cta_id"],
|
|
102
|
+
wireDims: ["trackPlacement", "trackCta"]
|
|
103
|
+
},
|
|
104
|
+
chat_click: {
|
|
105
|
+
ga4: true,
|
|
106
|
+
ga4Name: "chat_click",
|
|
107
|
+
journey: true,
|
|
108
|
+
dims: ["provider", "placement", "cta_id"],
|
|
109
|
+
wireDims: ["trackProvider", "trackPlacement", "trackCta"]
|
|
110
|
+
},
|
|
111
|
+
booking_click: {
|
|
112
|
+
ga4: true,
|
|
113
|
+
ga4Name: "booking_outbound",
|
|
114
|
+
journey: true,
|
|
115
|
+
dims: ["provider", "placement", "cta_id"],
|
|
116
|
+
wireDims: ["trackProvider", "trackPlacement", "trackCta"]
|
|
117
|
+
},
|
|
118
|
+
cta_click: {
|
|
119
|
+
ga4: false,
|
|
120
|
+
journey: true,
|
|
121
|
+
dims: ["cta_id", "placement", "click_kind"],
|
|
122
|
+
wireDims: ["trackCta", "trackPlacement", "trackKind"]
|
|
123
|
+
},
|
|
124
|
+
button_click: {
|
|
125
|
+
ga4: false,
|
|
126
|
+
journey: false,
|
|
127
|
+
dims: ["button_id", "placement"],
|
|
128
|
+
wireDims: ["trackButton", "trackPlacement"]
|
|
129
|
+
},
|
|
130
|
+
cta_view: {
|
|
131
|
+
ga4: false,
|
|
132
|
+
journey: false,
|
|
133
|
+
dims: ["cta_id", "placement", "click_event"],
|
|
134
|
+
wireDims: ["cta_id", "placement", "click_event"]
|
|
135
|
+
},
|
|
136
|
+
cta_engage: {
|
|
137
|
+
ga4: false,
|
|
138
|
+
journey: false,
|
|
139
|
+
dims: ["cta_id", "placement", "click_event"],
|
|
140
|
+
wireDims: ["cta_id", "placement", "click_event"]
|
|
141
|
+
},
|
|
142
|
+
form_error: {
|
|
143
|
+
ga4: false,
|
|
144
|
+
journey: false,
|
|
145
|
+
dims: ["form_id", "field_id", "error_code"],
|
|
146
|
+
wireDims: ["form_id", "field_id", "error_code"]
|
|
147
|
+
},
|
|
148
|
+
site_error: {
|
|
149
|
+
ga4: false,
|
|
150
|
+
journey: false,
|
|
151
|
+
dims: ["error_code", "operation", "status_code"],
|
|
152
|
+
wireDims: ["error_code", "operation", "status_code"]
|
|
153
|
+
},
|
|
154
|
+
pricing_view: {
|
|
155
|
+
ga4: false,
|
|
156
|
+
journey: false,
|
|
157
|
+
dims: ["item"],
|
|
158
|
+
wireDims: ["trackItem"]
|
|
159
|
+
},
|
|
160
|
+
pricing_expand: {
|
|
161
|
+
ga4: false,
|
|
162
|
+
journey: false,
|
|
163
|
+
dims: ["item"],
|
|
164
|
+
wireDims: ["trackItem"]
|
|
165
|
+
},
|
|
166
|
+
faq_open: {
|
|
167
|
+
ga4: false,
|
|
168
|
+
journey: false,
|
|
169
|
+
dims: ["q_index"],
|
|
170
|
+
wireDims: ["trackQ"]
|
|
171
|
+
},
|
|
172
|
+
gallery_interact: {
|
|
173
|
+
ga4: false,
|
|
174
|
+
journey: false,
|
|
175
|
+
dims: ["spot"],
|
|
176
|
+
wireDims: ["trackSpot"]
|
|
177
|
+
},
|
|
178
|
+
form_start: {
|
|
179
|
+
ga4: false,
|
|
180
|
+
journey: false,
|
|
181
|
+
dims: ["form_id"],
|
|
182
|
+
wireDims: ["form_id"]
|
|
183
|
+
},
|
|
184
|
+
form_abandon: {
|
|
185
|
+
ga4: false,
|
|
186
|
+
journey: false,
|
|
187
|
+
dims: ["form_id", "last_field"],
|
|
188
|
+
wireDims: ["form_id", "last_field"]
|
|
189
|
+
},
|
|
190
|
+
section_view: {
|
|
191
|
+
ga4: false,
|
|
192
|
+
journey: false,
|
|
193
|
+
dims: ["section_id"],
|
|
194
|
+
wireDims: ["section_id"]
|
|
195
|
+
},
|
|
196
|
+
scroll_depth: {
|
|
197
|
+
ga4: false,
|
|
198
|
+
journey: false,
|
|
199
|
+
dims: ["pct"],
|
|
200
|
+
wireDims: ["pct"]
|
|
201
|
+
},
|
|
202
|
+
read_complete: {
|
|
203
|
+
ga4: false,
|
|
204
|
+
journey: false,
|
|
205
|
+
dims: ["pid"],
|
|
206
|
+
wireDims: ["pid"]
|
|
207
|
+
}
|
|
208
|
+
};
|
|
209
|
+
var CLICK_EVENTS = [
|
|
210
|
+
"phone_click",
|
|
211
|
+
"email_click",
|
|
212
|
+
"chat_click",
|
|
213
|
+
"booking_click",
|
|
214
|
+
"cta_click",
|
|
215
|
+
"button_click",
|
|
216
|
+
"cta_call",
|
|
217
|
+
"cta_map",
|
|
218
|
+
"cta_channel",
|
|
219
|
+
"cta_link",
|
|
220
|
+
"cta_banner",
|
|
221
|
+
"cta_hero",
|
|
222
|
+
"service_card"
|
|
223
|
+
];
|
|
224
|
+
function isClickEvent(name) {
|
|
225
|
+
return CLICK_EVENTS.includes(name);
|
|
226
|
+
}
|
|
227
|
+
function clickKind(event, explicitKind) {
|
|
228
|
+
if (event === "button_click" || event === "service_card") return "button";
|
|
229
|
+
if (event === "cta_click") {
|
|
230
|
+
return explicitKind === "cta" || explicitKind === "button" ? explicitKind : "unclassified";
|
|
231
|
+
}
|
|
232
|
+
return CLICK_EVENTS.includes(event) ? "cta" : "unclassified";
|
|
233
|
+
}
|
|
234
|
+
function isTrackEvent(name) {
|
|
235
|
+
return Object.prototype.hasOwnProperty.call(TRACK_EVENTS, name);
|
|
236
|
+
}
|
|
237
|
+
var GA4_MIRROR = (() => {
|
|
238
|
+
const out = {};
|
|
239
|
+
for (const name of Object.keys(TRACK_EVENTS)) {
|
|
240
|
+
const def = TRACK_EVENTS[name];
|
|
241
|
+
if (def.ga4 && def.ga4Name) out[name] = def.ga4Name;
|
|
242
|
+
}
|
|
243
|
+
return out;
|
|
244
|
+
})();
|
|
245
|
+
|
|
246
|
+
export {
|
|
247
|
+
CONTACT_LINK_RULES,
|
|
248
|
+
contactTrackForHref,
|
|
249
|
+
ctaTrackAttributes,
|
|
250
|
+
FORM_ERROR_CODES,
|
|
251
|
+
normalizeFormError,
|
|
252
|
+
SITE_ERROR_CODES,
|
|
253
|
+
SITE_ERROR_LIMIT,
|
|
254
|
+
normalizeSiteError,
|
|
255
|
+
TRACK_EVENTS,
|
|
256
|
+
CLICK_EVENTS,
|
|
257
|
+
isClickEvent,
|
|
258
|
+
clickKind,
|
|
259
|
+
isTrackEvent,
|
|
260
|
+
GA4_MIRROR
|
|
261
|
+
};
|
|
262
|
+
//# sourceMappingURL=chunk-WJ6QUIXG.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/form-error-contract.ts","../src/site-error-contract.ts","../src/contact-links.ts","../src/events.ts"],"sourcesContent":["/** 고정 오류 코드만 보낸다. 입력값·서버 오류 메시지는 수집 계약에 없다. */\nexport const FORM_ERROR_CODES = [\n \"required\", \"format\", \"length\", \"range\", \"invalid\",\n \"verification\", \"rate_limited\", \"network\", \"server\", \"unknown\",\n] as const;\nexport type FormErrorCode = typeof FORM_ERROR_CODES[number];\n\nexport interface FormErrorDimensions {\n form_id: string;\n field_id: string;\n error_code: FormErrorCode;\n}\n\nexport function normalizeFormError(value: Record<string, unknown>): FormErrorDimensions | null {\n const code = value.error_code;\n if (typeof code !== \"string\" || !(FORM_ERROR_CODES as readonly string[]).includes(code)) return null;\n // 식별자는 폼 정의의 고정 key만 허용한다. 값·문장·URL을 넣으면 버린다.\n const id = (input: unknown) => typeof input === \"string\" && /^[a-zA-Z0-9_:-]{1,100}$/.test(input) ? input : \"\";\n const formId = id(value.form_id);\n if (!formId) return null;\n return { form_id: formId, field_id: id(value.field_id), error_code: code as FormErrorCode };\n}\n","export const SITE_ERROR_CODES = [\"script\", \"promise\", \"resource\", \"request\"] as const;\nexport type SiteErrorCode = typeof SITE_ERROR_CODES[number];\nexport const SITE_ERROR_LIMIT = 10;\n\nexport function normalizeSiteError(value: Record<string, unknown>): {\n error_code: SiteErrorCode; operation: string; status_code: string;\n} | null {\n const code = value.error_code;\n if (typeof code !== \"string\" || !(SITE_ERROR_CODES as readonly string[]).includes(code)) return null;\n const operation = typeof value.operation === \"string\" && /^[a-zA-Z0-9_:-]{1,100}$/.test(value.operation)\n ? value.operation : \"\";\n const status = Number(value.status_code);\n return { error_code: code as SiteErrorCode, operation,\n status_code: Number.isInteger(status) && status >= 400 && status <= 599 ? String(status) : \"\" };\n}\n","/** 연락 링크 분류 원장. Node·브라우저·인라인 비콘이 같은 데이터만 사용한다. */\nexport interface ContactTrack {\n readonly event: \"phone_click\" | \"email_click\" | \"chat_click\" | \"booking_click\";\n readonly provider?: \"kakao\" | \"naver\";\n}\n\nexport const CONTACT_LINK_RULES = {\n protocols: {\n \"tel:\": { event: \"phone_click\" },\n \"mailto:\": { event: \"email_click\" },\n },\n hosts: {\n \"pf.kakao.com\": { event: \"chat_click\", provider: \"kakao\" },\n \"open.kakao.com\": { event: \"chat_click\", provider: \"kakao\" },\n \"talk.naver.com\": { event: \"chat_click\", provider: \"naver\" },\n \"booking.naver.com\": { event: \"booking_click\", provider: \"naver\" },\n \"m.booking.naver.com\": { event: \"booking_click\", provider: \"naver\" },\n },\n} as const satisfies {\n protocols: Readonly<Record<string, ContactTrack>>;\n hosts: Readonly<Record<string, ContactTrack>>;\n};\n\n/** base URL 없이 해석하므로 상대 경로는 제외한다. 호스트는 정확히 일치해야 한다. */\nexport function contactTrackForHref(href: string): ContactTrack | null {\n try {\n const url = new URL(href);\n const protocols: Readonly<Record<string, ContactTrack>> = CONTACT_LINK_RULES.protocols;\n const hosts: Readonly<Record<string, ContactTrack>> = CONTACT_LINK_RULES.hosts;\n if (Object.hasOwn(protocols, url.protocol)) return protocols[url.protocol] ?? null;\n if (url.protocol !== \"https:\" && url.protocol !== \"http:\") return null;\n return Object.hasOwn(hosts, url.hostname) ? hosts[url.hostname] ?? null : null;\n } catch {\n return null;\n }\n}\n\n/** 명시적인 CTA용 표식. 일반 본문 링크에는 연락 링크로 판정된 경우에만 사용한다. */\nexport function ctaTrackAttributes(href: string, cta: string, placement: string): Record<string, string> {\n const contact = contactTrackForHref(href);\n return {\n \"data-track\": contact?.event ?? \"cta_click\",\n ...(contact?.provider ? { \"data-track-provider\": contact.provider } : {}),\n \"data-track-cta\": cta,\n \"data-track-placement\": placement,\n };\n}\n","// 설계(measurement-design-draft.md) §1 — 이벤트 사전 SSoT. 이름·GA4 미러 대상\n// 여부·GA4 이벤트명·journey 기록 여부·허용 차원 키(d1/d2/d3 슬롯 매핑 순서)를\n// 여기 한 곳에 고정한다. api-core `/collect` 가 본 사전을 import 해 allowlist\n// 로 쓴다(설계 §4 — 사전 밖 `ev` 는 204 drop). 브라우저 의존 0(순수 데이터) —\n// edge(api-core)·node·browser 어디서나 import 가능.\n//\n// `directions_click`·`vcard_save` 는 v1 제외(설계 §1 각주) — starter 에 실\n// 지도 링크 계약이 아직 없고 / bio-pages 는 별도 앱이라 링크 계약 신설 시\n// 사전에 등록한다.\n//\n// journey 플래그(설계 §3): sessionStorage 여정 링버퍼(journey.ts)에 담을\n// 이벤트만 true. 설계는 \"pageview + 전환 사다리 이벤트\"라 표현하는데, 본\n// 사전은 이를 pageview + GA4 미러 대상(확정 전환 신호: lead_submit·\n// phone_click·email_click·chat_click·booking_click) + 그 직전 단계인\n// form_submit_attempt와 CTA 클릭을 기록한다. form_start·faq_open 등 참여\n// 신호는 scroll_depth·section_view 같은 고빈도 신호와 마찬가지로 journey 에서\n// 제외 — 방문 여정은 \"전환에 이르는 궤적\"만 남긴다(§3 취지).\nexport interface TrackEventDef {\n /** GA4 로 미러 발화하는 이벤트인지(설계 §0 게이트 계약). */\n readonly ga4: boolean;\n /** GA4 미러 시 사용할 gtag 이벤트명. `ga4=true` 일 때만 존재. */\n readonly ga4Name?: string;\n /** sessionStorage 여정 링버퍼(journey.ts)에 기록할지. */\n readonly journey: boolean;\n /**\n * 허용 차원 키(의미상 이름) — 순서대로 blob d1/d2/d3 슬롯에 매핑(설계 §4).\n * 어드민 표시·문서용 semantic name. 실제 payload 파싱은 {@link wireDims}.\n */\n readonly dims: readonly string[];\n /**\n * `dims` 와 순서 동일하되 **실제 /collect JSON payload 상의 키 이름**\n * (beacon.ts RUNTIME 이 두 경로로 값을 보내기 때문에 `dims` 와 다를 수 있다):\n * - 클릭 위임(`[data-track]` delegated click): `dataset` 의 `data-track-*`\n * camelCase 키를 그대로 전송(`data-track-placement`→`trackPlacement`,\n * `data-track-cta`→`trackCta`, `data-track-q`→`trackQ`,\n * `data-track-provider`→`trackProvider`).\n * - JS 직접 호출(`trackCustomEvent`/`window.__rtTrack` — observers.ts·\n * lead-form-meta.client.tsx·not-found 404 비콘 등): 호출부가 이미\n * `dims` 와 같은 snake_case 키(`section_id`·`pct`·`pid`·`form_id`·\n * `last_field`)로 extra 객체를 만들어 보낸다.\n * api-core `/collect` 가 이 키로 body 에서 값을 읽어 blob d1/d2/d3 에 채운다.\n */\n readonly wireDims?: readonly string[];\n}\n\nexport const TRACK_EVENTS = {\n pageview: { ga4: false, journey: true, dims: [\"pid\"], wireDims: [\"pid\"] },\n lead_submit: {\n ga4: true,\n ga4Name: \"generate_lead\",\n journey: true,\n dims: [\"form_id\"],\n wireDims: [\"form_id\"],\n },\n form_submit_attempt: {\n ga4: false,\n journey: true,\n dims: [\"form_id\"],\n wireDims: [\"form_id\"],\n },\n phone_click: {\n ga4: true,\n ga4Name: \"phone_call_click\",\n journey: true,\n dims: [\"placement\", \"cta_id\"],\n wireDims: [\"trackPlacement\", \"trackCta\"],\n },\n email_click: {\n ga4: true,\n ga4Name: \"email_click\",\n journey: true,\n dims: [\"placement\", \"cta_id\"],\n wireDims: [\"trackPlacement\", \"trackCta\"],\n },\n chat_click: {\n ga4: true,\n ga4Name: \"chat_click\",\n journey: true,\n dims: [\"provider\", \"placement\", \"cta_id\"],\n wireDims: [\"trackProvider\", \"trackPlacement\", \"trackCta\"],\n },\n booking_click: {\n ga4: true,\n ga4Name: \"booking_outbound\",\n journey: true,\n dims: [\"provider\", \"placement\", \"cta_id\"],\n wireDims: [\"trackProvider\", \"trackPlacement\", \"trackCta\"],\n },\n cta_click: {\n ga4: false,\n journey: true,\n dims: [\"cta_id\", \"placement\", \"click_kind\"],\n wireDims: [\"trackCta\", \"trackPlacement\", \"trackKind\"],\n },\n button_click: {\n ga4: false,\n journey: false,\n dims: [\"button_id\", \"placement\"],\n wireDims: [\"trackButton\", \"trackPlacement\"],\n },\n cta_view: {\n ga4: false, journey: false,\n dims: [\"cta_id\", \"placement\", \"click_event\"],\n wireDims: [\"cta_id\", \"placement\", \"click_event\"],\n },\n cta_engage: {\n ga4: false, journey: false,\n dims: [\"cta_id\", \"placement\", \"click_event\"],\n wireDims: [\"cta_id\", \"placement\", \"click_event\"],\n },\n form_error: {\n ga4: false, journey: false,\n dims: [\"form_id\", \"field_id\", \"error_code\"],\n wireDims: [\"form_id\", \"field_id\", \"error_code\"],\n },\n site_error: {\n ga4: false, journey: false,\n dims: [\"error_code\", \"operation\", \"status_code\"],\n wireDims: [\"error_code\", \"operation\", \"status_code\"],\n },\n pricing_view: {\n ga4: false,\n journey: false,\n dims: [\"item\"],\n wireDims: [\"trackItem\"],\n },\n pricing_expand: {\n ga4: false,\n journey: false,\n dims: [\"item\"],\n wireDims: [\"trackItem\"],\n },\n faq_open: {\n ga4: false,\n journey: false,\n dims: [\"q_index\"],\n wireDims: [\"trackQ\"],\n },\n gallery_interact: {\n ga4: false,\n journey: false,\n dims: [\"spot\"],\n wireDims: [\"trackSpot\"],\n },\n form_start: {\n ga4: false,\n journey: false,\n dims: [\"form_id\"],\n wireDims: [\"form_id\"],\n },\n form_abandon: {\n ga4: false,\n journey: false,\n dims: [\"form_id\", \"last_field\"],\n wireDims: [\"form_id\", \"last_field\"],\n },\n section_view: {\n ga4: false,\n journey: false,\n dims: [\"section_id\"],\n wireDims: [\"section_id\"],\n },\n scroll_depth: {\n ga4: false,\n journey: false,\n dims: [\"pct\"],\n wireDims: [\"pct\"],\n },\n read_complete: {\n ga4: false,\n journey: false,\n dims: [\"pid\"],\n wireDims: [\"pid\"],\n },\n} as const satisfies Record<string, TrackEventDef>;\n\nexport type TrackEventName = keyof typeof TRACK_EVENTS;\n\nexport { FORM_ERROR_CODES, normalizeFormError, type FormErrorCode } from \"./form-error-contract\";\nexport { SITE_ERROR_CODES, normalizeSiteError, type SiteErrorCode } from \"./site-error-contract\";\n\n/** ROOT-ADMIN 버튼 성과와 클릭 경로가 공유하는 이벤트 범위. */\nexport const CLICK_EVENTS = [\n \"phone_click\", \"email_click\", \"chat_click\", \"booking_click\", \"cta_click\",\n \"button_click\", \"cta_call\", \"cta_map\", \"cta_channel\", \"cta_link\",\n \"cta_banner\", \"cta_hero\", \"service_card\",\n];\n\nexport function isClickEvent(name: string): boolean { return CLICK_EVENTS.includes(name); }\n\nexport type ClickKind = \"cta\" | \"button\" | \"unclassified\";\n\n/**\n * 과거 cta_click에는 자동 수집한 메뉴·목차·펼치기도 섞여 있다.\n * 명시적인 구분 정보가 없는 기록을 CTA 또는 일반 버튼으로 추정하지 않는다.\n */\nexport function clickKind(event: string, explicitKind?: string): ClickKind {\n if (event === \"button_click\" || event === \"service_card\") return \"button\";\n if (event === \"cta_click\") {\n return explicitKind === \"cta\" || explicitKind === \"button\"\n ? explicitKind\n : \"unclassified\";\n }\n return CLICK_EVENTS.includes(event) ? \"cta\" : \"unclassified\";\n}\n\n/** `name` 이 사전에 등록된 이벤트인지 — api-core `/collect` allowlist 가드로 재사용. */\nexport function isTrackEvent(name: string): name is TrackEventName {\n return Object.prototype.hasOwnProperty.call(TRACK_EVENTS, name);\n}\n\n/**\n * GA4 미러 대상 이벤트만 뽑은 파생 상수 — `{eventName: ga4EventName}`.\n * `ga4-bridge.ts` 가 이 맵으로 미러 여부·gtag 이벤트명을 조회한다. 사전이\n * SSoT 이므로 이 상수는 `TRACK_EVENTS` 에서 계산될 뿐 별도로 유지하지 않는다.\n */\nexport const GA4_MIRROR: Readonly<Partial<Record<TrackEventName, string>>> =\n (() => {\n const out: Partial<Record<TrackEventName, string>> = {};\n for (const name of Object.keys(TRACK_EVENTS) as TrackEventName[]) {\n const def = TRACK_EVENTS[name];\n if (def.ga4 && def.ga4Name) out[name] = def.ga4Name;\n }\n return out;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AAA,IACZ,KAAK;AAAA,IACL,SAAS;AAAA,IACT,MAAM,CAAC,KAAK;AAAA,IACZ,UAAU,CAAC,KAAK;AAAA,EAClB;AAAA,EACA,eAAe;AAAA,IACb,KAAK;AAAA,IACL,SAAS;AAAA,IACT,MAAM,CAAC,KAAK;AAAA,IACZ,UAAU,CAAC,KAAK;AAAA,EAClB;AACF;AAQO,IAAM,eAAe;AAAA,EAC1B;AAAA,EAAe;AAAA,EAAe;AAAA,EAAc;AAAA,EAAiB;AAAA,EAC7D;AAAA,EAAgB;AAAA,EAAY;AAAA,EAAW;AAAA,EAAe;AAAA,EACtD;AAAA,EAAc;AAAA,EAAY;AAC5B;AAEO,SAAS,aAAa,MAAuB;AAAE,SAAO,aAAa,SAAS,IAAI;AAAG;AAQnF,SAAS,UAAU,OAAe,cAAkC;AACzE,MAAI,UAAU,kBAAkB,UAAU,eAAgB,QAAO;AACjE,MAAI,UAAU,aAAa;AACzB,WAAO,iBAAiB,SAAS,iBAAiB,WAC9C,eACA;AAAA,EACN;AACA,SAAO,aAAa,SAAS,KAAK,IAAI,QAAQ;AAChD;AAGO,SAAS,aAAa,MAAsC;AACjE,SAAO,OAAO,UAAU,eAAe,KAAK,cAAc,IAAI;AAChE;AAOO,IAAM,cACV,MAAM;AACL,QAAM,MAA+C,CAAC;AACtD,aAAW,QAAQ,OAAO,KAAK,YAAY,GAAuB;AAChE,UAAM,MAAM,aAAa,IAAI;AAC7B,QAAI,IAAI,OAAO,IAAI,QAAS,KAAI,IAAI,IAAI,IAAI;AAAA,EAC9C;AACA,SAAO;AACT,GAAG;","names":[]}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
/** 클릭 한 건에 함께 저장하는 경로. 방문자 ID나 시각은 포함하지 않는다. */
|
|
2
|
+
interface ClickJourney {
|
|
3
|
+
readonly v: 1;
|
|
4
|
+
readonly p: readonly string[];
|
|
5
|
+
readonly s: ClickJourneySource;
|
|
6
|
+
/** 경로 길이 제한·수집 시작 누락으로 전체 이동을 알 수 없을 때. */
|
|
7
|
+
readonly cut?: 1;
|
|
8
|
+
}
|
|
9
|
+
interface ClickJourneySource {
|
|
10
|
+
readonly ref?: 1;
|
|
11
|
+
readonly rh?: string;
|
|
12
|
+
readonly air?: string;
|
|
13
|
+
readonly us?: string;
|
|
14
|
+
readonly um?: string;
|
|
15
|
+
readonly uc?: string;
|
|
16
|
+
readonly rs?: string;
|
|
17
|
+
readonly gc?: 1;
|
|
18
|
+
}
|
|
19
|
+
declare const CLICK_JOURNEY_MAX_PATHS = 10;
|
|
20
|
+
declare const CLICK_JOURNEY_MAX_BYTES = 1200;
|
|
21
|
+
declare const CLICK_JOURNEY_IDLE_MS: number;
|
|
22
|
+
/** /collect와 관리자 모두 같은 허용 목록으로 재구성한다. */
|
|
23
|
+
declare function normalizeClickJourney(value: unknown): ClickJourney | null;
|
|
24
|
+
|
|
25
|
+
export { CLICK_JOURNEY_IDLE_MS, CLICK_JOURNEY_MAX_BYTES, CLICK_JOURNEY_MAX_PATHS, type ClickJourney, type ClickJourneySource, normalizeClickJourney };
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import {
|
|
2
|
+
CLICK_JOURNEY_IDLE_MS,
|
|
3
|
+
CLICK_JOURNEY_MAX_BYTES,
|
|
4
|
+
CLICK_JOURNEY_MAX_PATHS,
|
|
5
|
+
normalizeClickJourney
|
|
6
|
+
} from "./chunk-HISUF7TR.js";
|
|
7
|
+
import "./chunk-KKGWQGIR.js";
|
|
8
|
+
export {
|
|
9
|
+
CLICK_JOURNEY_IDLE_MS,
|
|
10
|
+
CLICK_JOURNEY_MAX_BYTES,
|
|
11
|
+
CLICK_JOURNEY_MAX_PATHS,
|
|
12
|
+
normalizeClickJourney
|
|
13
|
+
};
|
|
14
|
+
//# sourceMappingURL=click-journey.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
|
package/dist/events.d.ts
CHANGED
|
@@ -1,3 +1,63 @@
|
|
|
1
|
+
/** 고정 오류 코드만 보낸다. 입력값·서버 오류 메시지는 수집 계약에 없다. */
|
|
2
|
+
declare const FORM_ERROR_CODES: readonly ["required", "format", "length", "range", "invalid", "verification", "rate_limited", "network", "server", "unknown"];
|
|
3
|
+
type FormErrorCode = typeof FORM_ERROR_CODES[number];
|
|
4
|
+
interface FormErrorDimensions {
|
|
5
|
+
form_id: string;
|
|
6
|
+
field_id: string;
|
|
7
|
+
error_code: FormErrorCode;
|
|
8
|
+
}
|
|
9
|
+
declare function normalizeFormError(value: Record<string, unknown>): FormErrorDimensions | null;
|
|
10
|
+
|
|
11
|
+
declare const SITE_ERROR_CODES: readonly ["script", "promise", "resource", "request"];
|
|
12
|
+
type SiteErrorCode = typeof SITE_ERROR_CODES[number];
|
|
13
|
+
declare function normalizeSiteError(value: Record<string, unknown>): {
|
|
14
|
+
error_code: SiteErrorCode;
|
|
15
|
+
operation: string;
|
|
16
|
+
status_code: string;
|
|
17
|
+
} | null;
|
|
18
|
+
|
|
19
|
+
/** 연락 링크 분류 원장. Node·브라우저·인라인 비콘이 같은 데이터만 사용한다. */
|
|
20
|
+
interface ContactTrack {
|
|
21
|
+
readonly event: "phone_click" | "email_click" | "chat_click" | "booking_click";
|
|
22
|
+
readonly provider?: "kakao" | "naver";
|
|
23
|
+
}
|
|
24
|
+
declare const CONTACT_LINK_RULES: {
|
|
25
|
+
readonly protocols: {
|
|
26
|
+
readonly "tel:": {
|
|
27
|
+
readonly event: "phone_click";
|
|
28
|
+
};
|
|
29
|
+
readonly "mailto:": {
|
|
30
|
+
readonly event: "email_click";
|
|
31
|
+
};
|
|
32
|
+
};
|
|
33
|
+
readonly hosts: {
|
|
34
|
+
readonly "pf.kakao.com": {
|
|
35
|
+
readonly event: "chat_click";
|
|
36
|
+
readonly provider: "kakao";
|
|
37
|
+
};
|
|
38
|
+
readonly "open.kakao.com": {
|
|
39
|
+
readonly event: "chat_click";
|
|
40
|
+
readonly provider: "kakao";
|
|
41
|
+
};
|
|
42
|
+
readonly "talk.naver.com": {
|
|
43
|
+
readonly event: "chat_click";
|
|
44
|
+
readonly provider: "naver";
|
|
45
|
+
};
|
|
46
|
+
readonly "booking.naver.com": {
|
|
47
|
+
readonly event: "booking_click";
|
|
48
|
+
readonly provider: "naver";
|
|
49
|
+
};
|
|
50
|
+
readonly "m.booking.naver.com": {
|
|
51
|
+
readonly event: "booking_click";
|
|
52
|
+
readonly provider: "naver";
|
|
53
|
+
};
|
|
54
|
+
};
|
|
55
|
+
};
|
|
56
|
+
/** base URL 없이 해석하므로 상대 경로는 제외한다. 호스트는 정확히 일치해야 한다. */
|
|
57
|
+
declare function contactTrackForHref(href: string): ContactTrack | null;
|
|
58
|
+
/** 명시적인 CTA용 표식. 일반 본문 링크에는 연락 링크로 판정된 경우에만 사용한다. */
|
|
59
|
+
declare function ctaTrackAttributes(href: string, cta: string, placement: string): Record<string, string>;
|
|
60
|
+
|
|
1
61
|
interface TrackEventDef {
|
|
2
62
|
/** GA4 로 미러 발화하는 이벤트인지(설계 §0 게이트 계약). */
|
|
3
63
|
readonly ga4: boolean;
|
|
@@ -49,33 +109,33 @@ declare const TRACK_EVENTS: {
|
|
|
49
109
|
readonly ga4: true;
|
|
50
110
|
readonly ga4Name: "phone_call_click";
|
|
51
111
|
readonly journey: true;
|
|
52
|
-
readonly dims: readonly ["placement"];
|
|
53
|
-
readonly wireDims: readonly ["trackPlacement"];
|
|
112
|
+
readonly dims: readonly ["placement", "cta_id"];
|
|
113
|
+
readonly wireDims: readonly ["trackPlacement", "trackCta"];
|
|
54
114
|
};
|
|
55
115
|
readonly email_click: {
|
|
56
116
|
readonly ga4: true;
|
|
57
117
|
readonly ga4Name: "email_click";
|
|
58
118
|
readonly journey: true;
|
|
59
|
-
readonly dims: readonly ["placement"];
|
|
60
|
-
readonly wireDims: readonly ["trackPlacement"];
|
|
119
|
+
readonly dims: readonly ["placement", "cta_id"];
|
|
120
|
+
readonly wireDims: readonly ["trackPlacement", "trackCta"];
|
|
61
121
|
};
|
|
62
122
|
readonly chat_click: {
|
|
63
123
|
readonly ga4: true;
|
|
64
124
|
readonly ga4Name: "chat_click";
|
|
65
125
|
readonly journey: true;
|
|
66
|
-
readonly dims: readonly ["provider", "placement"];
|
|
67
|
-
readonly wireDims: readonly ["trackProvider", "trackPlacement"];
|
|
126
|
+
readonly dims: readonly ["provider", "placement", "cta_id"];
|
|
127
|
+
readonly wireDims: readonly ["trackProvider", "trackPlacement", "trackCta"];
|
|
68
128
|
};
|
|
69
129
|
readonly booking_click: {
|
|
70
130
|
readonly ga4: true;
|
|
71
131
|
readonly ga4Name: "booking_outbound";
|
|
72
132
|
readonly journey: true;
|
|
73
|
-
readonly dims: readonly ["provider", "placement"];
|
|
74
|
-
readonly wireDims: readonly ["trackProvider", "trackPlacement"];
|
|
133
|
+
readonly dims: readonly ["provider", "placement", "cta_id"];
|
|
134
|
+
readonly wireDims: readonly ["trackProvider", "trackPlacement", "trackCta"];
|
|
75
135
|
};
|
|
76
136
|
readonly cta_click: {
|
|
77
137
|
readonly ga4: false;
|
|
78
|
-
readonly journey:
|
|
138
|
+
readonly journey: true;
|
|
79
139
|
readonly dims: readonly ["cta_id", "placement", "click_kind"];
|
|
80
140
|
readonly wireDims: readonly ["trackCta", "trackPlacement", "trackKind"];
|
|
81
141
|
};
|
|
@@ -85,6 +145,30 @@ declare const TRACK_EVENTS: {
|
|
|
85
145
|
readonly dims: readonly ["button_id", "placement"];
|
|
86
146
|
readonly wireDims: readonly ["trackButton", "trackPlacement"];
|
|
87
147
|
};
|
|
148
|
+
readonly cta_view: {
|
|
149
|
+
readonly ga4: false;
|
|
150
|
+
readonly journey: false;
|
|
151
|
+
readonly dims: readonly ["cta_id", "placement", "click_event"];
|
|
152
|
+
readonly wireDims: readonly ["cta_id", "placement", "click_event"];
|
|
153
|
+
};
|
|
154
|
+
readonly cta_engage: {
|
|
155
|
+
readonly ga4: false;
|
|
156
|
+
readonly journey: false;
|
|
157
|
+
readonly dims: readonly ["cta_id", "placement", "click_event"];
|
|
158
|
+
readonly wireDims: readonly ["cta_id", "placement", "click_event"];
|
|
159
|
+
};
|
|
160
|
+
readonly form_error: {
|
|
161
|
+
readonly ga4: false;
|
|
162
|
+
readonly journey: false;
|
|
163
|
+
readonly dims: readonly ["form_id", "field_id", "error_code"];
|
|
164
|
+
readonly wireDims: readonly ["form_id", "field_id", "error_code"];
|
|
165
|
+
};
|
|
166
|
+
readonly site_error: {
|
|
167
|
+
readonly ga4: false;
|
|
168
|
+
readonly journey: false;
|
|
169
|
+
readonly dims: readonly ["error_code", "operation", "status_code"];
|
|
170
|
+
readonly wireDims: readonly ["error_code", "operation", "status_code"];
|
|
171
|
+
};
|
|
88
172
|
readonly pricing_view: {
|
|
89
173
|
readonly ga4: false;
|
|
90
174
|
readonly journey: false;
|
|
@@ -141,8 +225,10 @@ declare const TRACK_EVENTS: {
|
|
|
141
225
|
};
|
|
142
226
|
};
|
|
143
227
|
type TrackEventName = keyof typeof TRACK_EVENTS;
|
|
144
|
-
|
|
145
|
-
|
|
228
|
+
|
|
229
|
+
/** ROOT-ADMIN 버튼 성과와 클릭 경로가 공유하는 이벤트 범위. */
|
|
230
|
+
declare const CLICK_EVENTS: string[];
|
|
231
|
+
declare function isClickEvent(name: string): boolean;
|
|
146
232
|
type ClickKind = "cta" | "button" | "unclassified";
|
|
147
233
|
/**
|
|
148
234
|
* 과거 cta_click에는 자동 수집한 메뉴·목차·펼치기도 섞여 있다.
|
|
@@ -158,4 +244,4 @@ declare function isTrackEvent(name: string): name is TrackEventName;
|
|
|
158
244
|
*/
|
|
159
245
|
declare const GA4_MIRROR: Readonly<Partial<Record<TrackEventName, string>>>;
|
|
160
246
|
|
|
161
|
-
export { CLICK_EVENTS, type ClickKind, GA4_MIRROR, TRACK_EVENTS, type TrackEventDef, type TrackEventName, clickKind, isTrackEvent };
|
|
247
|
+
export { CLICK_EVENTS, CONTACT_LINK_RULES, type ClickKind, type ContactTrack, FORM_ERROR_CODES, type FormErrorCode, GA4_MIRROR, SITE_ERROR_CODES, type SiteErrorCode, TRACK_EVENTS, type TrackEventDef, type TrackEventName, clickKind, contactTrackForHref, ctaTrackAttributes, isClickEvent, isTrackEvent, normalizeFormError, normalizeSiteError };
|
package/dist/events.js
CHANGED
|
@@ -1,15 +1,31 @@
|
|
|
1
1
|
import {
|
|
2
2
|
CLICK_EVENTS,
|
|
3
|
+
CONTACT_LINK_RULES,
|
|
4
|
+
FORM_ERROR_CODES,
|
|
3
5
|
GA4_MIRROR,
|
|
6
|
+
SITE_ERROR_CODES,
|
|
4
7
|
TRACK_EVENTS,
|
|
5
8
|
clickKind,
|
|
6
|
-
|
|
7
|
-
|
|
9
|
+
contactTrackForHref,
|
|
10
|
+
ctaTrackAttributes,
|
|
11
|
+
isClickEvent,
|
|
12
|
+
isTrackEvent,
|
|
13
|
+
normalizeFormError,
|
|
14
|
+
normalizeSiteError
|
|
15
|
+
} from "./chunk-WJ6QUIXG.js";
|
|
8
16
|
export {
|
|
9
17
|
CLICK_EVENTS,
|
|
18
|
+
CONTACT_LINK_RULES,
|
|
19
|
+
FORM_ERROR_CODES,
|
|
10
20
|
GA4_MIRROR,
|
|
21
|
+
SITE_ERROR_CODES,
|
|
11
22
|
TRACK_EVENTS,
|
|
12
23
|
clickKind,
|
|
13
|
-
|
|
24
|
+
contactTrackForHref,
|
|
25
|
+
ctaTrackAttributes,
|
|
26
|
+
isClickEvent,
|
|
27
|
+
isTrackEvent,
|
|
28
|
+
normalizeFormError,
|
|
29
|
+
normalizeSiteError
|
|
14
30
|
};
|
|
15
31
|
//# sourceMappingURL=events.js.map
|
package/dist/index.d.ts
CHANGED
|
@@ -2,7 +2,8 @@ import { C as ConsentCategory, a as ConsentState, T as TagProvider, A as Analyti
|
|
|
2
2
|
export { c as ConsentValue, R as ResolvedTag, d as TagConfig } from './types-VA3xp0bt.js';
|
|
3
3
|
export { AI_REFERRAL_IDS, AI_REFERRAL_LABEL, AiReferralId, AiReferralMetric, aiReferralRulesLiteral, aiUtmSourceAliases, classifyAiReferral, classifyAiUtmSource, isAiReferralId, summarizeAiReferrals } from './ai-referrals.js';
|
|
4
4
|
export { ENTRY_CHANNEL_IDS, ENTRY_CHANNEL_LABEL, EntryChannelId, EntryChannelSignals, IN_APP_BROWSERS, IN_APP_SOURCE_PREFIX, InAppBrowserId, classifyEntryChannel, inAppBrowserFromSource, inAppBrowserFromUserAgent, isEntryChannelId, isInternalCampaignClick, isOwnerToolReferrer, normalizeReferrerHost } from './entry-channels.js';
|
|
5
|
-
|
|
5
|
+
import { FormErrorCode, SiteErrorCode } from './events.js';
|
|
6
|
+
export { CLICK_EVENTS, CONTACT_LINK_RULES, ClickKind, ContactTrack, FORM_ERROR_CODES, GA4_MIRROR, SITE_ERROR_CODES, TRACK_EVENTS, TrackEventDef, TrackEventName, clickKind, contactTrackForHref, ctaTrackAttributes, isClickEvent, isTrackEvent, normalizeFormError, normalizeSiteError } from './events.js';
|
|
6
7
|
|
|
7
8
|
declare const ALL_CONSENT_CATEGORIES: readonly ConsentCategory[];
|
|
8
9
|
/**
|
|
@@ -212,7 +213,7 @@ interface JourneyEntry {
|
|
|
212
213
|
}
|
|
213
214
|
/**
|
|
214
215
|
* journey 기록 브리지 스크립트. `<RootTaleAnalytics>` 가 beacon 스크립트와
|
|
215
|
-
* 함께
|
|
216
|
+
* 함께 항상 주입하되 첫 pageview 이전에 설치한다 — 1차 캡처 인프라라 opt-out 프롭 없음(ga4
|
|
216
217
|
* 미러와 달리).
|
|
217
218
|
*/
|
|
218
219
|
declare function renderJourneyBridgeScript(): string;
|
|
@@ -249,4 +250,13 @@ declare global {
|
|
|
249
250
|
}
|
|
250
251
|
}
|
|
251
252
|
|
|
252
|
-
|
|
253
|
+
/** 사용자 정의 검증·접수 실패를 기록한다. 오류 메시지나 입력값을 넘기지 않는다. */
|
|
254
|
+
declare function trackFormError(formId: string, code: FormErrorCode, fieldId?: string): void;
|
|
255
|
+
|
|
256
|
+
/** 처리된 요청 실패를 연결한다. operation은 고정 작업명이며 URL·오류 문장을 보내지 않는다. */
|
|
257
|
+
declare function trackSiteError(code: SiteErrorCode, options?: {
|
|
258
|
+
operation?: string;
|
|
259
|
+
status?: number;
|
|
260
|
+
}): void;
|
|
261
|
+
|
|
262
|
+
export { ALL_CONSENT_CATEGORIES, ATTRIBUTION_STORAGE_KEY, ATTRIBUTION_TTL_MS, AnalyticsManifest, AnalyticsSiteConfig, BEACON_PROTOCOL_VERSION, type BeaconOptions, CONSENT_STORAGE_KEY, type ConsentBannerOptions, ConsentCategory, ConsentState, DEFAULT_CONSENT, DENIED_CONSENT, type FirstTouchAttribution, FormErrorCode, INTERNAL_TRAFFIC_STORAGE_KEY, JOURNEY_MAX_ITEMS, JOURNEY_STORAGE_KEY, type JourneyEntry, type LastTouchAttribution, type LastTouchChannel, PROVIDER_CONSENT, SiteErrorCode, TagProvider, buildManifest, initObservers, isTagAllowed, readJourney, renderBeaconScript, renderConsentBannerMarkup, renderConsentBannerScript, renderConsentBootstrap, renderGa4BridgeScript, renderJourneyBridgeScript, renderLoaderScript, teardownObservers, trackCustomEvent, trackFormError, trackSiteError };
|