@talkfurther/events 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +37 -0
- package/dist/events.d.ts +181 -0
- package/dist/index.cjs +88 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.ts +10 -0
- package/dist/index.modern.js +86 -0
- package/dist/index.modern.js.map +1 -0
- package/dist/index.module.js +87 -0
- package/dist/index.module.js.map +1 -0
- package/dist/index.umd.js +93 -0
- package/dist/index.umd.js.map +1 -0
- package/package.json +30 -0
package/README.md
ADDED
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
# @talkfurther/events
|
|
2
|
+
|
|
3
|
+
Shared analytics event definitions used across Further's products. Each event is defined with a [zod](https://zod.dev/) schema that documents its fields, types, and descriptions.
|
|
4
|
+
|
|
5
|
+
If you are looking for event documentation please see Analytics Profiles in Further Dashboard settings.
|
|
6
|
+
|
|
7
|
+
## Usage
|
|
8
|
+
|
|
9
|
+
```typescript
|
|
10
|
+
import { analyticsEvents, getEventFields } from "@talkfurther/events";
|
|
11
|
+
import type { AnalyticsEventName, AnalyticsEventData } from "@talkfurther/events";
|
|
12
|
+
|
|
13
|
+
// Access an event definition
|
|
14
|
+
const event = analyticsEvents.form_submitted;
|
|
15
|
+
console.log(event.defaultName); // "further.form_submitted"
|
|
16
|
+
console.log(event.description); // "Fired when a form is successfully submitted"
|
|
17
|
+
|
|
18
|
+
// Validate event data against the schema
|
|
19
|
+
const result = event.schema.safeParse(data);
|
|
20
|
+
|
|
21
|
+
// Get field metadata (used by the dashboard to render event docs)
|
|
22
|
+
const fields = getEventFields("form_submitted");
|
|
23
|
+
// [{ name: "formId", description: "...", required: true }, ...]
|
|
24
|
+
```
|
|
25
|
+
|
|
26
|
+
## Adding a new event
|
|
27
|
+
|
|
28
|
+
1. Define the event in `events.ts` with a `defaultName`, `description`, and zod `schema`
|
|
29
|
+
2. Use `.describe()` on each field — these descriptions are shown in the dashboard profile editor
|
|
30
|
+
3. Rebuild: `npm run build`
|
|
31
|
+
|
|
32
|
+
## Building
|
|
33
|
+
|
|
34
|
+
```
|
|
35
|
+
npm run build # one-time build with microbundle
|
|
36
|
+
npm run dev # watch mode
|
|
37
|
+
```
|
package/dist/events.d.ts
ADDED
|
@@ -0,0 +1,181 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
export declare const analyticsEvents: {
|
|
3
|
+
readonly form_viewed: {
|
|
4
|
+
readonly defaultName: "further.form_viewed";
|
|
5
|
+
readonly description: "Fired when a form becomes visible to the user";
|
|
6
|
+
readonly schema: z.ZodObject<{
|
|
7
|
+
formId: z.ZodString;
|
|
8
|
+
formName: z.ZodString;
|
|
9
|
+
timestamp: z.ZodString;
|
|
10
|
+
pageUrl: z.ZodString;
|
|
11
|
+
visitorId: z.ZodString;
|
|
12
|
+
visitId: z.ZodString;
|
|
13
|
+
}, "strip", z.ZodTypeAny, {
|
|
14
|
+
formId: string;
|
|
15
|
+
formName: string;
|
|
16
|
+
timestamp: string;
|
|
17
|
+
pageUrl: string;
|
|
18
|
+
visitorId: string;
|
|
19
|
+
visitId: string;
|
|
20
|
+
}, {
|
|
21
|
+
formId: string;
|
|
22
|
+
formName: string;
|
|
23
|
+
timestamp: string;
|
|
24
|
+
pageUrl: string;
|
|
25
|
+
visitorId: string;
|
|
26
|
+
visitId: string;
|
|
27
|
+
}>;
|
|
28
|
+
};
|
|
29
|
+
readonly form_started: {
|
|
30
|
+
readonly defaultName: "further.form_started";
|
|
31
|
+
readonly description: "Fired when the user interacts with a form field for the first time";
|
|
32
|
+
readonly schema: z.ZodObject<{
|
|
33
|
+
formId: z.ZodString;
|
|
34
|
+
formName: z.ZodString;
|
|
35
|
+
timestamp: z.ZodString;
|
|
36
|
+
pageUrl: z.ZodString;
|
|
37
|
+
visitorId: z.ZodString;
|
|
38
|
+
visitId: z.ZodString;
|
|
39
|
+
}, "strip", z.ZodTypeAny, {
|
|
40
|
+
formId: string;
|
|
41
|
+
formName: string;
|
|
42
|
+
timestamp: string;
|
|
43
|
+
pageUrl: string;
|
|
44
|
+
visitorId: string;
|
|
45
|
+
visitId: string;
|
|
46
|
+
}, {
|
|
47
|
+
formId: string;
|
|
48
|
+
formName: string;
|
|
49
|
+
timestamp: string;
|
|
50
|
+
pageUrl: string;
|
|
51
|
+
visitorId: string;
|
|
52
|
+
visitId: string;
|
|
53
|
+
}>;
|
|
54
|
+
};
|
|
55
|
+
readonly form_submitted: {
|
|
56
|
+
readonly defaultName: "further.form_submitted";
|
|
57
|
+
readonly description: "Fired when a form is successfully submitted";
|
|
58
|
+
readonly schema: z.ZodObject<{
|
|
59
|
+
formId: z.ZodString;
|
|
60
|
+
formName: z.ZodString;
|
|
61
|
+
fieldCount: z.ZodNumber;
|
|
62
|
+
communityId: z.ZodNumber;
|
|
63
|
+
communityName: z.ZodString;
|
|
64
|
+
timestamp: z.ZodString;
|
|
65
|
+
pageUrl: z.ZodString;
|
|
66
|
+
visitorId: z.ZodString;
|
|
67
|
+
visitId: z.ZodString;
|
|
68
|
+
}, "strip", z.ZodTypeAny, {
|
|
69
|
+
formId: string;
|
|
70
|
+
formName: string;
|
|
71
|
+
timestamp: string;
|
|
72
|
+
pageUrl: string;
|
|
73
|
+
visitorId: string;
|
|
74
|
+
visitId: string;
|
|
75
|
+
fieldCount: number;
|
|
76
|
+
communityId: number;
|
|
77
|
+
communityName: string;
|
|
78
|
+
}, {
|
|
79
|
+
formId: string;
|
|
80
|
+
formName: string;
|
|
81
|
+
timestamp: string;
|
|
82
|
+
pageUrl: string;
|
|
83
|
+
visitorId: string;
|
|
84
|
+
visitId: string;
|
|
85
|
+
fieldCount: number;
|
|
86
|
+
communityId: number;
|
|
87
|
+
communityName: string;
|
|
88
|
+
}>;
|
|
89
|
+
};
|
|
90
|
+
readonly lead_created: {
|
|
91
|
+
readonly defaultName: "further.lead_created";
|
|
92
|
+
readonly description: "Fired when a new lead is captured via any channel";
|
|
93
|
+
readonly schema: z.ZodObject<{
|
|
94
|
+
leadId: z.ZodNumber;
|
|
95
|
+
channelSource: z.ZodString;
|
|
96
|
+
formId: z.ZodOptional<z.ZodString>;
|
|
97
|
+
formName: z.ZodOptional<z.ZodString>;
|
|
98
|
+
chatId: z.ZodOptional<z.ZodNumber>;
|
|
99
|
+
chatName: z.ZodOptional<z.ZodString>;
|
|
100
|
+
communityId: z.ZodNumber;
|
|
101
|
+
communityName: z.ZodString;
|
|
102
|
+
timestamp: z.ZodString;
|
|
103
|
+
pageUrl: z.ZodString;
|
|
104
|
+
visitorId: z.ZodString;
|
|
105
|
+
visitId: z.ZodString;
|
|
106
|
+
}, "strip", z.ZodTypeAny, {
|
|
107
|
+
timestamp: string;
|
|
108
|
+
pageUrl: string;
|
|
109
|
+
visitorId: string;
|
|
110
|
+
visitId: string;
|
|
111
|
+
communityId: number;
|
|
112
|
+
communityName: string;
|
|
113
|
+
leadId: number;
|
|
114
|
+
channelSource: string;
|
|
115
|
+
formId?: string | undefined;
|
|
116
|
+
formName?: string | undefined;
|
|
117
|
+
chatId?: number | undefined;
|
|
118
|
+
chatName?: string | undefined;
|
|
119
|
+
}, {
|
|
120
|
+
timestamp: string;
|
|
121
|
+
pageUrl: string;
|
|
122
|
+
visitorId: string;
|
|
123
|
+
visitId: string;
|
|
124
|
+
communityId: number;
|
|
125
|
+
communityName: string;
|
|
126
|
+
leadId: number;
|
|
127
|
+
channelSource: string;
|
|
128
|
+
formId?: string | undefined;
|
|
129
|
+
formName?: string | undefined;
|
|
130
|
+
chatId?: number | undefined;
|
|
131
|
+
chatName?: string | undefined;
|
|
132
|
+
}>;
|
|
133
|
+
};
|
|
134
|
+
readonly tour_scheduled: {
|
|
135
|
+
readonly defaultName: "further.tour_scheduled";
|
|
136
|
+
readonly description: "Fired when a tour is scheduled via any channel";
|
|
137
|
+
readonly schema: z.ZodObject<{
|
|
138
|
+
leadId: z.ZodNumber;
|
|
139
|
+
tourDate: z.ZodOptional<z.ZodString>;
|
|
140
|
+
channelSource: z.ZodString;
|
|
141
|
+
formId: z.ZodOptional<z.ZodString>;
|
|
142
|
+
formName: z.ZodOptional<z.ZodString>;
|
|
143
|
+
chatId: z.ZodOptional<z.ZodNumber>;
|
|
144
|
+
chatName: z.ZodOptional<z.ZodString>;
|
|
145
|
+
communityId: z.ZodNumber;
|
|
146
|
+
communityName: z.ZodString;
|
|
147
|
+
timestamp: z.ZodString;
|
|
148
|
+
pageUrl: z.ZodString;
|
|
149
|
+
visitorId: z.ZodString;
|
|
150
|
+
visitId: z.ZodString;
|
|
151
|
+
}, "strip", z.ZodTypeAny, {
|
|
152
|
+
timestamp: string;
|
|
153
|
+
pageUrl: string;
|
|
154
|
+
visitorId: string;
|
|
155
|
+
visitId: string;
|
|
156
|
+
communityId: number;
|
|
157
|
+
communityName: string;
|
|
158
|
+
leadId: number;
|
|
159
|
+
channelSource: string;
|
|
160
|
+
formId?: string | undefined;
|
|
161
|
+
formName?: string | undefined;
|
|
162
|
+
chatId?: number | undefined;
|
|
163
|
+
chatName?: string | undefined;
|
|
164
|
+
tourDate?: string | undefined;
|
|
165
|
+
}, {
|
|
166
|
+
timestamp: string;
|
|
167
|
+
pageUrl: string;
|
|
168
|
+
visitorId: string;
|
|
169
|
+
visitId: string;
|
|
170
|
+
communityId: number;
|
|
171
|
+
communityName: string;
|
|
172
|
+
leadId: number;
|
|
173
|
+
channelSource: string;
|
|
174
|
+
formId?: string | undefined;
|
|
175
|
+
formName?: string | undefined;
|
|
176
|
+
chatId?: number | undefined;
|
|
177
|
+
chatName?: string | undefined;
|
|
178
|
+
tourDate?: string | undefined;
|
|
179
|
+
}>;
|
|
180
|
+
};
|
|
181
|
+
};
|
package/dist/index.cjs
ADDED
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
var zod = require('zod');
|
|
2
|
+
|
|
3
|
+
const baseEvent = {
|
|
4
|
+
timestamp: zod.z.string().datetime().describe("ISO 8601 timestamp of when the event occurred"),
|
|
5
|
+
pageUrl: zod.z.string().url().describe("URL of the page where the event occurred"),
|
|
6
|
+
visitorId: zod.z.string().describe("Anonymous visitor UUID for cross-event correlation"),
|
|
7
|
+
visitId: zod.z.string().describe("Visit/session UUID for session-level funnel analysis")
|
|
8
|
+
};
|
|
9
|
+
const communityEvent = {
|
|
10
|
+
communityId: zod.z.number().int().describe("ID of the community associated with the event"),
|
|
11
|
+
communityName: zod.z.string().describe("Name of the community associated with the event")
|
|
12
|
+
};
|
|
13
|
+
const analyticsEvents = {
|
|
14
|
+
form_viewed: {
|
|
15
|
+
defaultName: "further.form_viewed",
|
|
16
|
+
description: "Fired when a form becomes visible to the user",
|
|
17
|
+
schema: zod.z.object({
|
|
18
|
+
...baseEvent,
|
|
19
|
+
formId: zod.z.string().describe("Unique identifier of the form"),
|
|
20
|
+
formName: zod.z.string().describe("Human-readable form name")
|
|
21
|
+
})
|
|
22
|
+
},
|
|
23
|
+
form_started: {
|
|
24
|
+
defaultName: "further.form_started",
|
|
25
|
+
description: "Fired when the user interacts with a form field for the first time",
|
|
26
|
+
schema: zod.z.object({
|
|
27
|
+
...baseEvent,
|
|
28
|
+
formId: zod.z.string().describe("Unique identifier of the form"),
|
|
29
|
+
formName: zod.z.string().describe("Human-readable form name")
|
|
30
|
+
})
|
|
31
|
+
},
|
|
32
|
+
form_submitted: {
|
|
33
|
+
defaultName: "further.form_submitted",
|
|
34
|
+
description: "Fired when a form is successfully submitted",
|
|
35
|
+
schema: zod.z.object({
|
|
36
|
+
...baseEvent,
|
|
37
|
+
...communityEvent,
|
|
38
|
+
formId: zod.z.string().describe("Unique identifier of the form"),
|
|
39
|
+
formName: zod.z.string().describe("Human-readable form name"),
|
|
40
|
+
fieldCount: zod.z.number().int().describe("Number of fields submitted")
|
|
41
|
+
})
|
|
42
|
+
},
|
|
43
|
+
lead_created: {
|
|
44
|
+
defaultName: "further.lead_created",
|
|
45
|
+
description: "Fired when a new lead is captured via any channel",
|
|
46
|
+
schema: zod.z.object({
|
|
47
|
+
...baseEvent,
|
|
48
|
+
...communityEvent,
|
|
49
|
+
leadId: zod.z.number().int().describe("Internal lead ID for CRM correlation"),
|
|
50
|
+
channelSource: zod.z.string().describe("Channel source that captured the lead (e.g. conversational_webform, static_webform, chat_api, conversational_ivr)"),
|
|
51
|
+
formId: zod.z.string().optional().describe("Form ID, if the lead came from a form"),
|
|
52
|
+
formName: zod.z.string().optional().describe("Form name, if the lead came from a form"),
|
|
53
|
+
chatId: zod.z.number().int().optional().describe("Chat/VSA ID, if the lead came from a chat widget"),
|
|
54
|
+
chatName: zod.z.string().optional().describe("Chat/VSA name, if the lead came from a chat widget")
|
|
55
|
+
})
|
|
56
|
+
},
|
|
57
|
+
tour_scheduled: {
|
|
58
|
+
defaultName: "further.tour_scheduled",
|
|
59
|
+
description: "Fired when a tour is scheduled via any channel",
|
|
60
|
+
schema: zod.z.object({
|
|
61
|
+
...baseEvent,
|
|
62
|
+
...communityEvent,
|
|
63
|
+
leadId: zod.z.number().int().describe("Internal lead ID for CRM correlation"),
|
|
64
|
+
tourDate: zod.z.string().optional().describe("ISO 8601 tour start date/time. Optional because the tour date may not always be parseable from user input."),
|
|
65
|
+
channelSource: zod.z.string().describe("Channel source that captured the lead (e.g. conversational_webform, static_webform, chat_api, conversational_ivr)"),
|
|
66
|
+
formId: zod.z.string().optional().describe("Form ID, if the tour was scheduled from a form"),
|
|
67
|
+
formName: zod.z.string().optional().describe("Form name, if the tour was scheduled from a form"),
|
|
68
|
+
chatId: zod.z.number().int().optional().describe("Chat/VSA ID, if the tour was scheduled from a chat widget"),
|
|
69
|
+
chatName: zod.z.string().optional().describe("Chat/VSA name, if the tour was scheduled from a chat widget")
|
|
70
|
+
})
|
|
71
|
+
}
|
|
72
|
+
};
|
|
73
|
+
|
|
74
|
+
function getEventFields(eventKey) {
|
|
75
|
+
const shape = analyticsEvents[eventKey].schema.shape;
|
|
76
|
+
return Object.entries(shape).map(_ref => {
|
|
77
|
+
let [name, field] = _ref;
|
|
78
|
+
return {
|
|
79
|
+
name,
|
|
80
|
+
description: field.description || "",
|
|
81
|
+
required: !field.isOptional()
|
|
82
|
+
};
|
|
83
|
+
});
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
exports.analyticsEvents = analyticsEvents;
|
|
87
|
+
exports.getEventFields = getEventFields;
|
|
88
|
+
//# sourceMappingURL=index.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.cjs","sources":["../events.ts","../index.ts"],"sourcesContent":["import { z } from \"zod\";\n\nconst baseEvent = {\n timestamp: z.string().datetime().describe(\"ISO 8601 timestamp of when the event occurred\"),\n pageUrl: z.string().url().describe(\"URL of the page where the event occurred\"),\n visitorId: z.string().describe(\"Anonymous visitor UUID for cross-event correlation\"),\n visitId: z.string().describe(\"Visit/session UUID for session-level funnel analysis\"),\n};\n\nconst communityEvent = {\n communityId: z.number().int().describe(\"ID of the community associated with the event\"),\n communityName: z.string().describe(\"Name of the community associated with the event\"),\n};\n\nexport const analyticsEvents = {\n form_viewed: {\n defaultName: \"further.form_viewed\",\n description: \"Fired when a form becomes visible to the user\",\n schema: z.object({\n ...baseEvent,\n formId: z.string().describe(\"Unique identifier of the form\"),\n formName: z.string().describe(\"Human-readable form name\"),\n }),\n },\n\n form_started: {\n defaultName: \"further.form_started\",\n description: \"Fired when the user interacts with a form field for the first time\",\n schema: z.object({\n ...baseEvent,\n formId: z.string().describe(\"Unique identifier of the form\"),\n formName: z.string().describe(\"Human-readable form name\"),\n }),\n },\n\n form_submitted: {\n defaultName: \"further.form_submitted\",\n description: \"Fired when a form is successfully submitted\",\n schema: z.object({\n ...baseEvent,\n ...communityEvent,\n formId: z.string().describe(\"Unique identifier of the form\"),\n formName: z.string().describe(\"Human-readable form name\"),\n fieldCount: z.number().int().describe(\"Number of fields submitted\"),\n }),\n },\n\n lead_created: {\n defaultName: \"further.lead_created\",\n description: \"Fired when a new lead is captured via any channel\",\n schema: z.object({\n ...baseEvent,\n ...communityEvent,\n leadId: z.number().int().describe(\"Internal lead ID for CRM correlation\"),\n channelSource: z.string().describe(\"Channel source that captured the lead (e.g. conversational_webform, static_webform, chat_api, conversational_ivr)\"),\n formId: z.string().optional().describe(\"Form ID, if the lead came from a form\"),\n formName: z.string().optional().describe(\"Form name, if the lead came from a form\"),\n chatId: z.number().int().optional().describe(\"Chat/VSA ID, if the lead came from a chat widget\"),\n chatName: z.string().optional().describe(\"Chat/VSA name, if the lead came from a chat widget\"),\n }),\n },\n tour_scheduled: {\n defaultName: \"further.tour_scheduled\",\n description: \"Fired when a tour is scheduled via any channel\",\n schema: z.object({\n ...baseEvent,\n ...communityEvent,\n leadId: z.number().int().describe(\"Internal lead ID for CRM correlation\"),\n tourDate: z.string().optional().describe(\"ISO 8601 tour start date/time. Optional because the tour date may not always be parseable from user input.\"),\n channelSource: z.string().describe(\"Channel source that captured the lead (e.g. conversational_webform, static_webform, chat_api, conversational_ivr)\"),\n formId: z.string().optional().describe(\"Form ID, if the tour was scheduled from a form\"),\n formName: z.string().optional().describe(\"Form name, if the tour was scheduled from a form\"),\n chatId: z.number().int().optional().describe(\"Chat/VSA ID, if the tour was scheduled from a chat widget\"),\n chatName: z.string().optional().describe(\"Chat/VSA name, if the tour was scheduled from a chat widget\"),\n }),\n },\n} as const;\n","import { z } from \"zod\";\nimport { analyticsEvents } from \"./events\";\n\nexport { analyticsEvents } from \"./events\";\n\nexport type AnalyticsEventName = keyof typeof analyticsEvents;\n\nexport type AnalyticsEventData<T extends AnalyticsEventName> = z.infer<(typeof analyticsEvents)[T][\"schema\"]>;\n\nexport function getEventFields(eventKey: AnalyticsEventName) {\n const shape = analyticsEvents[eventKey].schema.shape;\n return Object.entries(shape).map(([name, field]) => ({\n name,\n description: (field as z.ZodTypeAny).description || \"\",\n required: !(field as z.ZodTypeAny).isOptional(),\n }));\n}\n"],"names":["baseEvent","timestamp","z","string","datetime","describe","pageUrl","url","visitorId","visitId","communityEvent","communityId","number","int","communityName","analyticsEvents","form_viewed","defaultName","description","schema","object","formId","formName","form_started","form_submitted","fieldCount","lead_created","leadId","channelSource","optional","chatId","chatName","tour_scheduled","tourDate","getEventFields","eventKey","shape","Object","entries","map","_ref","name","field","required","isOptional"],"mappings":";;AAEA,MAAMA,SAAS,GAAG;AAChBC,EAAAA,SAAS,EAAEC,KAAC,CAACC,MAAM,EAAE,CAACC,QAAQ,EAAE,CAACC,QAAQ,CAAC,+CAA+C,CAAC;AAC1FC,EAAAA,OAAO,EAAEJ,KAAC,CAACC,MAAM,EAAE,CAACI,GAAG,EAAE,CAACF,QAAQ,CAAC,0CAA0C,CAAC;EAC9EG,SAAS,EAAEN,KAAC,CAACC,MAAM,EAAE,CAACE,QAAQ,CAAC,oDAAoD,CAAC;EACpFI,OAAO,EAAEP,KAAC,CAACC,MAAM,EAAE,CAACE,QAAQ,CAAC,sDAAsD,CAAA;CACpF,CAAA;AAED,MAAMK,cAAc,GAAG;AACrBC,EAAAA,WAAW,EAAET,KAAC,CAACU,MAAM,EAAE,CAACC,GAAG,EAAE,CAACR,QAAQ,CAAC,+CAA+C,CAAC;EACvFS,aAAa,EAAEZ,KAAC,CAACC,MAAM,EAAE,CAACE,QAAQ,CAAC,iDAAiD,CAAA;CACrF,CAAA;AAEM,MAAMU,eAAe,GAAG;AAC7BC,EAAAA,WAAW,EAAE;AACXC,IAAAA,WAAW,EAAE,qBAAqB;AAClCC,IAAAA,WAAW,EAAE,+CAA+C;AAC5DC,IAAAA,MAAM,EAAEjB,KAAC,CAACkB,MAAM,CAAC;AACf,MAAA,GAAGpB,SAAS;MACZqB,MAAM,EAAEnB,KAAC,CAACC,MAAM,EAAE,CAACE,QAAQ,CAAC,+BAA+B,CAAC;MAC5DiB,QAAQ,EAAEpB,KAAC,CAACC,MAAM,EAAE,CAACE,QAAQ,CAAC,0BAA0B,CAAA;KACzD,CAAA;GACF;AAEDkB,EAAAA,YAAY,EAAE;AACZN,IAAAA,WAAW,EAAE,sBAAsB;AACnCC,IAAAA,WAAW,EAAE,oEAAoE;AACjFC,IAAAA,MAAM,EAAEjB,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7B,KAAC,CAACC,MAAM,EAAE,CAAC0B,QAAQ,EAAE,CAACxB,QAAQ,CAAC,6DAA6D,CAAA;KACvG,CAAA;AACF,GAAA;;;AClEG,SAAU6B,cAAcA,CAACC,QAA4B,EAAA;EACzD,MAAMC,KAAK,GAAGrB,eAAe,CAACoB,QAAQ,CAAC,CAAChB,MAAM,CAACiB,KAAK,CAAA;EACpD,OAAOC,MAAM,CAACC,OAAO,CAACF,KAAK,CAAC,CAACG,GAAG,CAACC,IAAA,IAAA;AAAA,IAAA,IAAC,CAACC,IAAI,EAAEC,KAAK,CAAC,GAAAF,IAAA,CAAA;IAAA,OAAM;MACnDC,IAAI;AACJvB,MAAAA,WAAW,EAAGwB,KAAsB,CAACxB,WAAW,IAAI,EAAE;AACtDyB,MAAAA,QAAQ,EAAE,CAAED,KAAsB,CAACE,UAAU,EAAE;KAChD,CAAA;AAAA,GAAC,CAAC,CAAA;AACL;;;;;"}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
import { analyticsEvents } from "./events";
|
|
3
|
+
export { analyticsEvents } from "./events";
|
|
4
|
+
export type AnalyticsEventName = keyof typeof analyticsEvents;
|
|
5
|
+
export type AnalyticsEventData<T extends AnalyticsEventName> = z.infer<(typeof analyticsEvents)[T]["schema"]>;
|
|
6
|
+
export declare function getEventFields(eventKey: AnalyticsEventName): {
|
|
7
|
+
name: string;
|
|
8
|
+
description: string;
|
|
9
|
+
required: boolean;
|
|
10
|
+
}[];
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
|
|
3
|
+
function _extends() {
|
|
4
|
+
return _extends = Object.assign ? Object.assign.bind() : function (n) {
|
|
5
|
+
for (var e = 1; e < arguments.length; e++) {
|
|
6
|
+
var t = arguments[e];
|
|
7
|
+
for (var r in t) ({}).hasOwnProperty.call(t, r) && (n[r] = t[r]);
|
|
8
|
+
}
|
|
9
|
+
return n;
|
|
10
|
+
}, _extends.apply(null, arguments);
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
const baseEvent = {
|
|
14
|
+
timestamp: z.string().datetime().describe("ISO 8601 timestamp of when the event occurred"),
|
|
15
|
+
pageUrl: z.string().url().describe("URL of the page where the event occurred"),
|
|
16
|
+
visitorId: z.string().describe("Anonymous visitor UUID for cross-event correlation"),
|
|
17
|
+
visitId: z.string().describe("Visit/session UUID for session-level funnel analysis")
|
|
18
|
+
};
|
|
19
|
+
const communityEvent = {
|
|
20
|
+
communityId: z.number().int().describe("ID of the community associated with the event"),
|
|
21
|
+
communityName: z.string().describe("Name of the community associated with the event")
|
|
22
|
+
};
|
|
23
|
+
const analyticsEvents = {
|
|
24
|
+
form_viewed: {
|
|
25
|
+
defaultName: "further.form_viewed",
|
|
26
|
+
description: "Fired when a form becomes visible to the user",
|
|
27
|
+
schema: z.object(_extends({}, baseEvent, {
|
|
28
|
+
formId: z.string().describe("Unique identifier of the form"),
|
|
29
|
+
formName: z.string().describe("Human-readable form name")
|
|
30
|
+
}))
|
|
31
|
+
},
|
|
32
|
+
form_started: {
|
|
33
|
+
defaultName: "further.form_started",
|
|
34
|
+
description: "Fired when the user interacts with a form field for the first time",
|
|
35
|
+
schema: z.object(_extends({}, baseEvent, {
|
|
36
|
+
formId: z.string().describe("Unique identifier of the form"),
|
|
37
|
+
formName: z.string().describe("Human-readable form name")
|
|
38
|
+
}))
|
|
39
|
+
},
|
|
40
|
+
form_submitted: {
|
|
41
|
+
defaultName: "further.form_submitted",
|
|
42
|
+
description: "Fired when a form is successfully submitted",
|
|
43
|
+
schema: z.object(_extends({}, baseEvent, communityEvent, {
|
|
44
|
+
formId: z.string().describe("Unique identifier of the form"),
|
|
45
|
+
formName: z.string().describe("Human-readable form name"),
|
|
46
|
+
fieldCount: z.number().int().describe("Number of fields submitted")
|
|
47
|
+
}))
|
|
48
|
+
},
|
|
49
|
+
lead_created: {
|
|
50
|
+
defaultName: "further.lead_created",
|
|
51
|
+
description: "Fired when a new lead is captured via any channel",
|
|
52
|
+
schema: z.object(_extends({}, baseEvent, communityEvent, {
|
|
53
|
+
leadId: z.number().int().describe("Internal lead ID for CRM correlation"),
|
|
54
|
+
channelSource: z.string().describe("Channel source that captured the lead (e.g. conversational_webform, static_webform, chat_api, conversational_ivr)"),
|
|
55
|
+
formId: z.string().optional().describe("Form ID, if the lead came from a form"),
|
|
56
|
+
formName: z.string().optional().describe("Form name, if the lead came from a form"),
|
|
57
|
+
chatId: z.number().int().optional().describe("Chat/VSA ID, if the lead came from a chat widget"),
|
|
58
|
+
chatName: z.string().optional().describe("Chat/VSA name, if the lead came from a chat widget")
|
|
59
|
+
}))
|
|
60
|
+
},
|
|
61
|
+
tour_scheduled: {
|
|
62
|
+
defaultName: "further.tour_scheduled",
|
|
63
|
+
description: "Fired when a tour is scheduled via any channel",
|
|
64
|
+
schema: z.object(_extends({}, baseEvent, communityEvent, {
|
|
65
|
+
leadId: z.number().int().describe("Internal lead ID for CRM correlation"),
|
|
66
|
+
tourDate: z.string().optional().describe("ISO 8601 tour start date/time. Optional because the tour date may not always be parseable from user input."),
|
|
67
|
+
channelSource: z.string().describe("Channel source that captured the lead (e.g. conversational_webform, static_webform, chat_api, conversational_ivr)"),
|
|
68
|
+
formId: z.string().optional().describe("Form ID, if the tour was scheduled from a form"),
|
|
69
|
+
formName: z.string().optional().describe("Form name, if the tour was scheduled from a form"),
|
|
70
|
+
chatId: z.number().int().optional().describe("Chat/VSA ID, if the tour was scheduled from a chat widget"),
|
|
71
|
+
chatName: z.string().optional().describe("Chat/VSA name, if the tour was scheduled from a chat widget")
|
|
72
|
+
}))
|
|
73
|
+
}
|
|
74
|
+
};
|
|
75
|
+
|
|
76
|
+
function getEventFields(eventKey) {
|
|
77
|
+
const shape = analyticsEvents[eventKey].schema.shape;
|
|
78
|
+
return Object.entries(shape).map(([name, field]) => ({
|
|
79
|
+
name,
|
|
80
|
+
description: field.description || "",
|
|
81
|
+
required: !field.isOptional()
|
|
82
|
+
}));
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
export { analyticsEvents, getEventFields };
|
|
86
|
+
//# sourceMappingURL=index.modern.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.modern.js","sources":["../events.ts","../index.ts"],"sourcesContent":["import { z } from \"zod\";\n\nconst baseEvent = {\n timestamp: z.string().datetime().describe(\"ISO 8601 timestamp of when the event occurred\"),\n pageUrl: z.string().url().describe(\"URL of the page where the event occurred\"),\n visitorId: z.string().describe(\"Anonymous visitor UUID for cross-event correlation\"),\n visitId: z.string().describe(\"Visit/session UUID for session-level funnel analysis\"),\n};\n\nconst communityEvent = {\n communityId: z.number().int().describe(\"ID of the community associated with the event\"),\n communityName: z.string().describe(\"Name of the community associated with the event\"),\n};\n\nexport const analyticsEvents = {\n form_viewed: {\n defaultName: \"further.form_viewed\",\n description: \"Fired when a form becomes visible to the user\",\n schema: z.object({\n ...baseEvent,\n formId: z.string().describe(\"Unique identifier of the form\"),\n formName: z.string().describe(\"Human-readable form name\"),\n }),\n },\n\n form_started: {\n defaultName: \"further.form_started\",\n description: \"Fired when the user interacts with a form field for the first time\",\n schema: z.object({\n ...baseEvent,\n formId: z.string().describe(\"Unique identifier of the form\"),\n formName: z.string().describe(\"Human-readable form name\"),\n }),\n },\n\n form_submitted: {\n defaultName: \"further.form_submitted\",\n description: \"Fired when a form is successfully submitted\",\n schema: z.object({\n ...baseEvent,\n ...communityEvent,\n formId: z.string().describe(\"Unique identifier of the form\"),\n formName: z.string().describe(\"Human-readable form name\"),\n fieldCount: z.number().int().describe(\"Number of fields submitted\"),\n }),\n },\n\n lead_created: {\n defaultName: \"further.lead_created\",\n description: \"Fired when a new lead is captured via any channel\",\n schema: z.object({\n ...baseEvent,\n ...communityEvent,\n leadId: z.number().int().describe(\"Internal lead ID for CRM correlation\"),\n channelSource: z.string().describe(\"Channel source that captured the lead (e.g. conversational_webform, static_webform, chat_api, conversational_ivr)\"),\n formId: z.string().optional().describe(\"Form ID, if the lead came from a form\"),\n formName: z.string().optional().describe(\"Form name, if the lead came from a form\"),\n chatId: z.number().int().optional().describe(\"Chat/VSA ID, if the lead came from a chat widget\"),\n chatName: z.string().optional().describe(\"Chat/VSA name, if the lead came from a chat widget\"),\n }),\n },\n tour_scheduled: {\n defaultName: \"further.tour_scheduled\",\n description: \"Fired when a tour is scheduled via any channel\",\n schema: z.object({\n ...baseEvent,\n ...communityEvent,\n leadId: z.number().int().describe(\"Internal lead ID for CRM correlation\"),\n tourDate: z.string().optional().describe(\"ISO 8601 tour start date/time. Optional because the tour date may not always be parseable from user input.\"),\n channelSource: z.string().describe(\"Channel source that captured the lead (e.g. conversational_webform, static_webform, chat_api, conversational_ivr)\"),\n formId: z.string().optional().describe(\"Form ID, if the tour was scheduled from a form\"),\n formName: z.string().optional().describe(\"Form name, if the tour was scheduled from a form\"),\n chatId: z.number().int().optional().describe(\"Chat/VSA ID, if the tour was scheduled from a chat widget\"),\n chatName: z.string().optional().describe(\"Chat/VSA name, if the tour was scheduled from a chat widget\"),\n }),\n },\n} as const;\n","import { z } from \"zod\";\nimport { analyticsEvents } from \"./events\";\n\nexport { analyticsEvents } from \"./events\";\n\nexport type AnalyticsEventName = keyof typeof analyticsEvents;\n\nexport type AnalyticsEventData<T extends AnalyticsEventName> = z.infer<(typeof analyticsEvents)[T][\"schema\"]>;\n\nexport function getEventFields(eventKey: AnalyticsEventName) {\n const shape = analyticsEvents[eventKey].schema.shape;\n return Object.entries(shape).map(([name, field]) => ({\n name,\n description: (field as z.ZodTypeAny).description || \"\",\n required: !(field as z.ZodTypeAny).isOptional(),\n }));\n}\n"],"names":["baseEvent","timestamp","z","string","datetime","describe","pageUrl","url","visitorId","visitId","communityEvent","communityId","number","int","communityName","analyticsEvents","form_viewed","defaultName","description","schema","object","_extends","formId","formName","form_started","form_submitted","fieldCount","lead_created","leadId","channelSource","optional","chatId","chatName","tour_scheduled","tourDate","getEventFields","eventKey","shape","Object","entries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AAC,6DAA6D,CAAA;KACvG,CAAA,CAAA;AACF,GAAA;;;AClEG,SAAU8B,cAAcA,CAACC,QAA4B,EAAA;EACzD,MAAMC,KAAK,GAAGtB,eAAe,CAACqB,QAAQ,CAAC,CAACjB,MAAM,CAACkB,KAAK,CAAA;AACpD,EAAA,OAAOC,MAAM,CAACC,OAAO,CAACF,KAAK,CAAC,CAACG,GAAG,CAAC,CAAC,CAACC,IAAI,EAAEC,KAAK,CAAC,MAAM;IACnDD,IAAI;AACJvB,IAAAA,WAAW,EAAGwB,KAAsB,CAACxB,WAAW,IAAI,EAAE;AACtDyB,IAAAA,QAAQ,EAAE,CAAED,KAAsB,CAACE,UAAU,EAAE;AAChD,GAAA,CAAC,CAAC,CAAA;AACL;;;;"}
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
|
|
3
|
+
const baseEvent = {
|
|
4
|
+
timestamp: z.string().datetime().describe("ISO 8601 timestamp of when the event occurred"),
|
|
5
|
+
pageUrl: z.string().url().describe("URL of the page where the event occurred"),
|
|
6
|
+
visitorId: z.string().describe("Anonymous visitor UUID for cross-event correlation"),
|
|
7
|
+
visitId: z.string().describe("Visit/session UUID for session-level funnel analysis")
|
|
8
|
+
};
|
|
9
|
+
const communityEvent = {
|
|
10
|
+
communityId: z.number().int().describe("ID of the community associated with the event"),
|
|
11
|
+
communityName: z.string().describe("Name of the community associated with the event")
|
|
12
|
+
};
|
|
13
|
+
const analyticsEvents = {
|
|
14
|
+
form_viewed: {
|
|
15
|
+
defaultName: "further.form_viewed",
|
|
16
|
+
description: "Fired when a form becomes visible to the user",
|
|
17
|
+
schema: z.object({
|
|
18
|
+
...baseEvent,
|
|
19
|
+
formId: z.string().describe("Unique identifier of the form"),
|
|
20
|
+
formName: z.string().describe("Human-readable form name")
|
|
21
|
+
})
|
|
22
|
+
},
|
|
23
|
+
form_started: {
|
|
24
|
+
defaultName: "further.form_started",
|
|
25
|
+
description: "Fired when the user interacts with a form field for the first time",
|
|
26
|
+
schema: z.object({
|
|
27
|
+
...baseEvent,
|
|
28
|
+
formId: z.string().describe("Unique identifier of the form"),
|
|
29
|
+
formName: z.string().describe("Human-readable form name")
|
|
30
|
+
})
|
|
31
|
+
},
|
|
32
|
+
form_submitted: {
|
|
33
|
+
defaultName: "further.form_submitted",
|
|
34
|
+
description: "Fired when a form is successfully submitted",
|
|
35
|
+
schema: z.object({
|
|
36
|
+
...baseEvent,
|
|
37
|
+
...communityEvent,
|
|
38
|
+
formId: z.string().describe("Unique identifier of the form"),
|
|
39
|
+
formName: z.string().describe("Human-readable form name"),
|
|
40
|
+
fieldCount: z.number().int().describe("Number of fields submitted")
|
|
41
|
+
})
|
|
42
|
+
},
|
|
43
|
+
lead_created: {
|
|
44
|
+
defaultName: "further.lead_created",
|
|
45
|
+
description: "Fired when a new lead is captured via any channel",
|
|
46
|
+
schema: z.object({
|
|
47
|
+
...baseEvent,
|
|
48
|
+
...communityEvent,
|
|
49
|
+
leadId: z.number().int().describe("Internal lead ID for CRM correlation"),
|
|
50
|
+
channelSource: z.string().describe("Channel source that captured the lead (e.g. conversational_webform, static_webform, chat_api, conversational_ivr)"),
|
|
51
|
+
formId: z.string().optional().describe("Form ID, if the lead came from a form"),
|
|
52
|
+
formName: z.string().optional().describe("Form name, if the lead came from a form"),
|
|
53
|
+
chatId: z.number().int().optional().describe("Chat/VSA ID, if the lead came from a chat widget"),
|
|
54
|
+
chatName: z.string().optional().describe("Chat/VSA name, if the lead came from a chat widget")
|
|
55
|
+
})
|
|
56
|
+
},
|
|
57
|
+
tour_scheduled: {
|
|
58
|
+
defaultName: "further.tour_scheduled",
|
|
59
|
+
description: "Fired when a tour is scheduled via any channel",
|
|
60
|
+
schema: z.object({
|
|
61
|
+
...baseEvent,
|
|
62
|
+
...communityEvent,
|
|
63
|
+
leadId: z.number().int().describe("Internal lead ID for CRM correlation"),
|
|
64
|
+
tourDate: z.string().optional().describe("ISO 8601 tour start date/time. Optional because the tour date may not always be parseable from user input."),
|
|
65
|
+
channelSource: z.string().describe("Channel source that captured the lead (e.g. conversational_webform, static_webform, chat_api, conversational_ivr)"),
|
|
66
|
+
formId: z.string().optional().describe("Form ID, if the tour was scheduled from a form"),
|
|
67
|
+
formName: z.string().optional().describe("Form name, if the tour was scheduled from a form"),
|
|
68
|
+
chatId: z.number().int().optional().describe("Chat/VSA ID, if the tour was scheduled from a chat widget"),
|
|
69
|
+
chatName: z.string().optional().describe("Chat/VSA name, if the tour was scheduled from a chat widget")
|
|
70
|
+
})
|
|
71
|
+
}
|
|
72
|
+
};
|
|
73
|
+
|
|
74
|
+
function getEventFields(eventKey) {
|
|
75
|
+
const shape = analyticsEvents[eventKey].schema.shape;
|
|
76
|
+
return Object.entries(shape).map(_ref => {
|
|
77
|
+
let [name, field] = _ref;
|
|
78
|
+
return {
|
|
79
|
+
name,
|
|
80
|
+
description: field.description || "",
|
|
81
|
+
required: !field.isOptional()
|
|
82
|
+
};
|
|
83
|
+
});
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
export { analyticsEvents, getEventFields };
|
|
87
|
+
//# sourceMappingURL=index.module.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.module.js","sources":["../events.ts","../index.ts"],"sourcesContent":["import { z } from \"zod\";\n\nconst baseEvent = {\n timestamp: z.string().datetime().describe(\"ISO 8601 timestamp of when the event occurred\"),\n pageUrl: z.string().url().describe(\"URL of the page where the event occurred\"),\n visitorId: z.string().describe(\"Anonymous visitor UUID for cross-event correlation\"),\n visitId: z.string().describe(\"Visit/session UUID for session-level funnel analysis\"),\n};\n\nconst communityEvent = {\n communityId: z.number().int().describe(\"ID of the community associated with the event\"),\n communityName: z.string().describe(\"Name of the community associated with the event\"),\n};\n\nexport const analyticsEvents = {\n form_viewed: {\n defaultName: \"further.form_viewed\",\n description: \"Fired when a form becomes visible to the user\",\n schema: z.object({\n ...baseEvent,\n formId: z.string().describe(\"Unique identifier of the form\"),\n formName: z.string().describe(\"Human-readable form name\"),\n }),\n },\n\n form_started: {\n defaultName: \"further.form_started\",\n description: \"Fired when the user interacts with a form field for the first time\",\n schema: z.object({\n ...baseEvent,\n formId: z.string().describe(\"Unique identifier of the form\"),\n formName: z.string().describe(\"Human-readable form name\"),\n }),\n },\n\n form_submitted: {\n defaultName: \"further.form_submitted\",\n description: \"Fired when a form is successfully submitted\",\n schema: z.object({\n ...baseEvent,\n ...communityEvent,\n formId: z.string().describe(\"Unique identifier of the form\"),\n formName: z.string().describe(\"Human-readable form name\"),\n fieldCount: z.number().int().describe(\"Number of fields submitted\"),\n }),\n },\n\n lead_created: {\n defaultName: \"further.lead_created\",\n description: \"Fired when a new lead is captured via any channel\",\n schema: z.object({\n ...baseEvent,\n ...communityEvent,\n leadId: z.number().int().describe(\"Internal lead ID for CRM correlation\"),\n channelSource: z.string().describe(\"Channel source that captured the lead (e.g. conversational_webform, static_webform, chat_api, conversational_ivr)\"),\n formId: z.string().optional().describe(\"Form ID, if the lead came from a form\"),\n formName: z.string().optional().describe(\"Form name, if the lead came from a form\"),\n chatId: z.number().int().optional().describe(\"Chat/VSA ID, if the lead came from a chat widget\"),\n chatName: z.string().optional().describe(\"Chat/VSA name, if the lead came from a chat widget\"),\n }),\n },\n tour_scheduled: {\n defaultName: \"further.tour_scheduled\",\n description: \"Fired when a tour is scheduled via any channel\",\n schema: z.object({\n ...baseEvent,\n ...communityEvent,\n leadId: z.number().int().describe(\"Internal lead ID for CRM correlation\"),\n tourDate: z.string().optional().describe(\"ISO 8601 tour start date/time. Optional because the tour date may not always be parseable from user input.\"),\n channelSource: z.string().describe(\"Channel source that captured the lead (e.g. conversational_webform, static_webform, chat_api, conversational_ivr)\"),\n formId: z.string().optional().describe(\"Form ID, if the tour was scheduled from a form\"),\n formName: z.string().optional().describe(\"Form name, if the tour was scheduled from a form\"),\n chatId: z.number().int().optional().describe(\"Chat/VSA ID, if the tour was scheduled from a chat widget\"),\n chatName: z.string().optional().describe(\"Chat/VSA name, if the tour was scheduled from a chat widget\"),\n }),\n },\n} as const;\n","import { z } from \"zod\";\nimport { analyticsEvents } from \"./events\";\n\nexport { analyticsEvents } from \"./events\";\n\nexport type AnalyticsEventName = keyof typeof analyticsEvents;\n\nexport type AnalyticsEventData<T extends AnalyticsEventName> = z.infer<(typeof analyticsEvents)[T][\"schema\"]>;\n\nexport function getEventFields(eventKey: AnalyticsEventName) {\n const shape = analyticsEvents[eventKey].schema.shape;\n return Object.entries(shape).map(([name, field]) => ({\n name,\n description: (field as z.ZodTypeAny).description || \"\",\n required: !(field as z.ZodTypeAny).isOptional(),\n }));\n}\n"],"names":["baseEvent","timestamp","z","string","datetime","describe","pageUrl","url","visitorId","visitId","communityEvent","communityId","number","int","communityName","analyticsEvents","form_viewed","defaultName","description","schema","object","formId","formName","form_started","form_submitted","fieldCount","lead_created","leadId","channelSource","optional","chatId","chatName","tour_scheduled","tourDate","getEventFields","eventKey","shape","Object","entries","map","_ref","name","field","required","isOptional"],"mappings":";;AAEA,MAAMA,SAAS,GAAG;AAChBC,EAAAA,SAAS,EAAEC,CAAC,CAACC,MAAM,EAAE,CAACC,QAAQ,EAAE,CAACC,QAAQ,CAAC,+CAA+C,CAAC;AAC1FC,EAAAA,OAAO,EAAEJ,CAAC,CAACC,MAAM,EAAE,CAACI,GAAG,EAAE,CAACF,QAAQ,CAAC,0CAA0C,CAAC;EAC9EG,SAAS,EAAEN,CAAC,CAACC,MAAM,EAAE,CAACE,QAAQ,CAAC,oDAAoD,CAAC;EACpFI,OAAO,EAAEP,CAAC,CAACC,MAAM,EAAE,CAACE,QAAQ,CAAC,sDAAsD,CAAA;CACpF,CAAA;AAED,MAAMK,cAAc,GAAG;AACrBC,EAAAA,WAAW,EAAET,CAAC,CAACU,MAAM,EAAE,CAACC,GAAG,EAAE,CAACR,QAAQ,CAAC,+CAA+C,CAAC;EACvFS,aAAa,EAAEZ,CAAC,CAACC,MAAM,EAAE,CAACE,QAAQ,CAAC,iDAAiD,CAAA;CACrF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AC0B,QAAQ,EAAE,CAACxB,QAAQ,CAAC,4GAA4G,CAAC;MACtJuB,aAAa,EAAE1B,CAAC,CAACC,MAAM,EAAE,CAACE,QAAQ,CAAC,mHAAmH,CAAC;AACvJgB,MAAAA,MAAM,EAAEnB,CAAC,CAACC,MAAM,EAAE,CAAC0B,QAAQ,EAAE,CAACxB,QAAQ,CAAC,gDAAgD,CAAC;AACxFiB,MAAAA,QAAQ,EAAEpB,CAAC,CAACC,MAAM,EAAE,CAAC0B,QAAQ,EAAE,CAACxB,QAAQ,CAAC,kDAAkD,CAAC;AAC5FyB,MAAAA,MAAM,EAAE5B,CAAC,CAACU,MAAM,EAAE,CAACC,GAAG,EAAE,CAACgB,QAAQ,EAAE,CAACxB,QAAQ,CAAC,2DAA2D,CAAC;AACzG0B,MAAAA,QAAQ,EAAE7B,CAAC,CAACC,MAAM,EAAE,CAAC0B,QAAQ,EAAE,CAACxB,QAAQ,CAAC,6DAA6D,CAAA;KACvG,CAAA;AACF,GAAA;;;AClEG,SAAU6B,cAAcA,CAACC,QAA4B,EAAA;EACzD,MAAMC,KAAK,GAAGrB,eAAe,CAACoB,QAAQ,CAAC,CAAChB,MAAM,CAACiB,KAAK,CAAA;EACpD,OAAOC,MAAM,CAACC,OAAO,CAACF,KAAK,CAAC,CAACG,GAAG,CAACC,IAAA,IAAA;AAAA,IAAA,IAAC,CAACC,IAAI,EAAEC,KAAK,CAAC,GAAAF,IAAA,CAAA;IAAA,OAAM;MACnDC,IAAI;AACJvB,MAAAA,WAAW,EAAGwB,KAAsB,CAACxB,WAAW,IAAI,EAAE;AACtDyB,MAAAA,QAAQ,EAAE,CAAED,KAAsB,CAACE,UAAU,EAAE;KAChD,CAAA;AAAA,GAAC,CAAC,CAAA;AACL;;;;"}
|
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
(function (global, factory) {
|
|
2
|
+
typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('zod')) :
|
|
3
|
+
typeof define === 'function' && define.amd ? define(['exports', 'zod'], factory) :
|
|
4
|
+
(global = global || self, factory(global.events = {}, global.zod));
|
|
5
|
+
})(this, (function (exports, zod) {
|
|
6
|
+
const baseEvent = {
|
|
7
|
+
timestamp: zod.z.string().datetime().describe("ISO 8601 timestamp of when the event occurred"),
|
|
8
|
+
pageUrl: zod.z.string().url().describe("URL of the page where the event occurred"),
|
|
9
|
+
visitorId: zod.z.string().describe("Anonymous visitor UUID for cross-event correlation"),
|
|
10
|
+
visitId: zod.z.string().describe("Visit/session UUID for session-level funnel analysis")
|
|
11
|
+
};
|
|
12
|
+
const communityEvent = {
|
|
13
|
+
communityId: zod.z.number().int().describe("ID of the community associated with the event"),
|
|
14
|
+
communityName: zod.z.string().describe("Name of the community associated with the event")
|
|
15
|
+
};
|
|
16
|
+
const analyticsEvents = {
|
|
17
|
+
form_viewed: {
|
|
18
|
+
defaultName: "further.form_viewed",
|
|
19
|
+
description: "Fired when a form becomes visible to the user",
|
|
20
|
+
schema: zod.z.object({
|
|
21
|
+
...baseEvent,
|
|
22
|
+
formId: zod.z.string().describe("Unique identifier of the form"),
|
|
23
|
+
formName: zod.z.string().describe("Human-readable form name")
|
|
24
|
+
})
|
|
25
|
+
},
|
|
26
|
+
form_started: {
|
|
27
|
+
defaultName: "further.form_started",
|
|
28
|
+
description: "Fired when the user interacts with a form field for the first time",
|
|
29
|
+
schema: zod.z.object({
|
|
30
|
+
...baseEvent,
|
|
31
|
+
formId: zod.z.string().describe("Unique identifier of the form"),
|
|
32
|
+
formName: zod.z.string().describe("Human-readable form name")
|
|
33
|
+
})
|
|
34
|
+
},
|
|
35
|
+
form_submitted: {
|
|
36
|
+
defaultName: "further.form_submitted",
|
|
37
|
+
description: "Fired when a form is successfully submitted",
|
|
38
|
+
schema: zod.z.object({
|
|
39
|
+
...baseEvent,
|
|
40
|
+
...communityEvent,
|
|
41
|
+
formId: zod.z.string().describe("Unique identifier of the form"),
|
|
42
|
+
formName: zod.z.string().describe("Human-readable form name"),
|
|
43
|
+
fieldCount: zod.z.number().int().describe("Number of fields submitted")
|
|
44
|
+
})
|
|
45
|
+
},
|
|
46
|
+
lead_created: {
|
|
47
|
+
defaultName: "further.lead_created",
|
|
48
|
+
description: "Fired when a new lead is captured via any channel",
|
|
49
|
+
schema: zod.z.object({
|
|
50
|
+
...baseEvent,
|
|
51
|
+
...communityEvent,
|
|
52
|
+
leadId: zod.z.number().int().describe("Internal lead ID for CRM correlation"),
|
|
53
|
+
channelSource: zod.z.string().describe("Channel source that captured the lead (e.g. conversational_webform, static_webform, chat_api, conversational_ivr)"),
|
|
54
|
+
formId: zod.z.string().optional().describe("Form ID, if the lead came from a form"),
|
|
55
|
+
formName: zod.z.string().optional().describe("Form name, if the lead came from a form"),
|
|
56
|
+
chatId: zod.z.number().int().optional().describe("Chat/VSA ID, if the lead came from a chat widget"),
|
|
57
|
+
chatName: zod.z.string().optional().describe("Chat/VSA name, if the lead came from a chat widget")
|
|
58
|
+
})
|
|
59
|
+
},
|
|
60
|
+
tour_scheduled: {
|
|
61
|
+
defaultName: "further.tour_scheduled",
|
|
62
|
+
description: "Fired when a tour is scheduled via any channel",
|
|
63
|
+
schema: zod.z.object({
|
|
64
|
+
...baseEvent,
|
|
65
|
+
...communityEvent,
|
|
66
|
+
leadId: zod.z.number().int().describe("Internal lead ID for CRM correlation"),
|
|
67
|
+
tourDate: zod.z.string().optional().describe("ISO 8601 tour start date/time. Optional because the tour date may not always be parseable from user input."),
|
|
68
|
+
channelSource: zod.z.string().describe("Channel source that captured the lead (e.g. conversational_webform, static_webform, chat_api, conversational_ivr)"),
|
|
69
|
+
formId: zod.z.string().optional().describe("Form ID, if the tour was scheduled from a form"),
|
|
70
|
+
formName: zod.z.string().optional().describe("Form name, if the tour was scheduled from a form"),
|
|
71
|
+
chatId: zod.z.number().int().optional().describe("Chat/VSA ID, if the tour was scheduled from a chat widget"),
|
|
72
|
+
chatName: zod.z.string().optional().describe("Chat/VSA name, if the tour was scheduled from a chat widget")
|
|
73
|
+
})
|
|
74
|
+
}
|
|
75
|
+
};
|
|
76
|
+
|
|
77
|
+
function getEventFields(eventKey) {
|
|
78
|
+
const shape = analyticsEvents[eventKey].schema.shape;
|
|
79
|
+
return Object.entries(shape).map(_ref => {
|
|
80
|
+
let [name, field] = _ref;
|
|
81
|
+
return {
|
|
82
|
+
name,
|
|
83
|
+
description: field.description || "",
|
|
84
|
+
required: !field.isOptional()
|
|
85
|
+
};
|
|
86
|
+
});
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
exports.analyticsEvents = analyticsEvents;
|
|
90
|
+
exports.getEventFields = getEventFields;
|
|
91
|
+
|
|
92
|
+
}));
|
|
93
|
+
//# sourceMappingURL=index.umd.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.umd.js","sources":["../events.ts","../index.ts"],"sourcesContent":["import { z } from \"zod\";\n\nconst baseEvent = {\n timestamp: z.string().datetime().describe(\"ISO 8601 timestamp of when the event occurred\"),\n pageUrl: z.string().url().describe(\"URL of the page where the event occurred\"),\n visitorId: z.string().describe(\"Anonymous visitor UUID for cross-event correlation\"),\n visitId: z.string().describe(\"Visit/session UUID for session-level funnel analysis\"),\n};\n\nconst communityEvent = {\n communityId: z.number().int().describe(\"ID of the community associated with the event\"),\n communityName: z.string().describe(\"Name of the community associated with the event\"),\n};\n\nexport const analyticsEvents = {\n form_viewed: {\n defaultName: \"further.form_viewed\",\n description: \"Fired when a form becomes visible to the user\",\n schema: z.object({\n ...baseEvent,\n formId: z.string().describe(\"Unique identifier of the form\"),\n formName: z.string().describe(\"Human-readable form name\"),\n }),\n },\n\n form_started: {\n defaultName: \"further.form_started\",\n description: \"Fired when the user interacts with a form field for the first time\",\n schema: z.object({\n ...baseEvent,\n formId: z.string().describe(\"Unique identifier of the form\"),\n formName: z.string().describe(\"Human-readable form name\"),\n }),\n },\n\n form_submitted: {\n defaultName: \"further.form_submitted\",\n description: \"Fired when a form is successfully submitted\",\n schema: z.object({\n ...baseEvent,\n ...communityEvent,\n formId: z.string().describe(\"Unique identifier of the form\"),\n formName: z.string().describe(\"Human-readable form name\"),\n fieldCount: z.number().int().describe(\"Number of fields submitted\"),\n }),\n },\n\n lead_created: {\n defaultName: \"further.lead_created\",\n description: \"Fired when a new lead is captured via any channel\",\n schema: z.object({\n ...baseEvent,\n ...communityEvent,\n leadId: z.number().int().describe(\"Internal lead ID for CRM correlation\"),\n channelSource: z.string().describe(\"Channel source that captured the lead (e.g. conversational_webform, static_webform, chat_api, conversational_ivr)\"),\n formId: z.string().optional().describe(\"Form ID, if the lead came from a form\"),\n formName: z.string().optional().describe(\"Form name, if the lead came from a form\"),\n chatId: z.number().int().optional().describe(\"Chat/VSA ID, if the lead came from a chat widget\"),\n chatName: z.string().optional().describe(\"Chat/VSA name, if the lead came from a chat widget\"),\n }),\n },\n tour_scheduled: {\n defaultName: \"further.tour_scheduled\",\n description: \"Fired when a tour is scheduled via any channel\",\n schema: z.object({\n ...baseEvent,\n ...communityEvent,\n leadId: z.number().int().describe(\"Internal lead ID for CRM correlation\"),\n tourDate: z.string().optional().describe(\"ISO 8601 tour start date/time. Optional because the tour date may not always be parseable from user input.\"),\n channelSource: z.string().describe(\"Channel source that captured the lead (e.g. conversational_webform, static_webform, chat_api, conversational_ivr)\"),\n formId: z.string().optional().describe(\"Form ID, if the tour was scheduled from a form\"),\n formName: z.string().optional().describe(\"Form name, if the tour was scheduled from a form\"),\n chatId: z.number().int().optional().describe(\"Chat/VSA ID, if the tour was scheduled from a chat widget\"),\n chatName: z.string().optional().describe(\"Chat/VSA name, if the tour was scheduled from a chat widget\"),\n }),\n },\n} as const;\n","import { z } from \"zod\";\nimport { analyticsEvents } from \"./events\";\n\nexport { analyticsEvents } from \"./events\";\n\nexport type AnalyticsEventName = keyof typeof analyticsEvents;\n\nexport type AnalyticsEventData<T extends AnalyticsEventName> = z.infer<(typeof analyticsEvents)[T][\"schema\"]>;\n\nexport function getEventFields(eventKey: AnalyticsEventName) {\n const shape = analyticsEvents[eventKey].schema.shape;\n return Object.entries(shape).map(([name, field]) => ({\n name,\n description: (field as z.ZodTypeAny).description || \"\",\n required: !(field as z.ZodTypeAny).isOptional(),\n }));\n}\n"],"names":["baseEvent","timestamp","z","string","datetime","describe","pageUrl","url","visitorId","visitId","communityEvent","communityId","number","int","communityName","analyticsEvents","form_viewed","defaultName","description","schema","object","formId","formName","form_started","form_submitted","fieldCount","lead_created","leadId","channelSource","optional","chatId","chatName","tour_scheduled","tourDate","getEventFields","eventKey","shape","Object","entries","map","_ref","name","field","required","isOptional"],"mappings":";;;;;EAEA,MAAMA,SAAS,GAAG;EAChBC,EAAAA,SAAS,EAAEC,KAAC,CAACC,MAAM,EAAE,CAACC,QAAQ,EAAE,CAACC,QAAQ,CAAC,+CAA+C,CAAC;EAC1FC,EAAAA,OAAO,EAAEJ,KAAC,CAACC,MAAM,EAAE,CAACI,GAAG,EAAE,CAACF,QAAQ,CAAC,0CAA0C,CAAC;IAC9EG,SAAS,EAAEN,KAAC,CAACC,MAAM,EAAE,CAACE,QAAQ,CAAC,oDAAoD,CAAC;IACpFI,OAAO,EAAEP,KAAC,CAACC,MAAM,EAAE,CAACE,QAAQ,CAAC,sDAAsD,CAAA;GACpF,CAAA;EAED,MAAMK,cAAc,GAAG;EACrBC,EAAAA,WAAW,EAAET,KAAC,CAACU,MAAM,EAAE,CAACC,GAAG,EAAE,CAACR,QAAQ,CAAC,+CAA+C,CAAC;IACvFS,aAAa,EAAEZ,KAAC,CAACC,MAAM,EAAE,CAACE,QAAQ,CAAC,iDAAiD,CAAA;GACrF,CAAA;AAEM,QAAMU,eAAe,GAAG;EAC7BC,EAAAA,WAAW,EAAE;EACXC,IAAAA,WAAW,EAAE,qBAAqB;EAClCC,IAAAA,WAAW,EAAE,+CAA+C;EAC5DC,IAAAA,MAAM,EAAEjB,KAAC,CAACkB,MAAM,CAAC;EACf,MAAA,GAAGpB,SAAS;QACZqB,MAAM,EAAEnB,KAAC,CAACC,MAAM,EAAE,CAACE,Q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AAQ,EAAEpB,KAAC,CAACC,MAAM,EAAE,CAAC0B,QAAQ,EAAE,CAACxB,QAAQ,CAAC,kDAAkD,CAAC;EAC5FyB,MAAAA,MAAM,EAAE5B,KAAC,CAACU,MAAM,EAAE,CAACC,GAAG,EAAE,CAACgB,QAAQ,EAAE,CAACxB,QAAQ,CAAC,2DAA2D,CAAC;EACzG0B,MAAAA,QAAQ,EAAE7B,KAAC,CAACC,MAAM,EAAE,CAAC0B,QAAQ,EAAE,CAACxB,QAAQ,CAAC,6DAA6D,CAAA;OACvG,CAAA;EACF,GAAA;;;EClEG,SAAU6B,cAAcA,CAACC,QAA4B,EAAA;IACzD,MAAMC,KAAK,GAAGrB,eAAe,CAACoB,QAAQ,CAAC,CAAChB,MAAM,CAACiB,KAAK,CAAA;IACpD,OAAOC,MAAM,CAACC,OAAO,CAACF,KAAK,CAAC,CAACG,GAAG,CAACC,IAAA,IAAA;EAAA,IAAA,IAAC,CAACC,IAAI,EAAEC,KAAK,CAAC,GAAAF,IAAA,CAAA;MAAA,OAAM;QACnDC,IAAI;EACJvB,MAAAA,WAAW,EAAGwB,KAAsB,CAACxB,WAAW,IAAI,EAAE;EACtDyB,MAAAA,QAAQ,EAAE,CAAED,KAAsB,CAACE,UAAU,EAAE;OAChD,CAAA;EAAA,GAAC,CAAC,CAAA;EACL;;;;;;;;;"}
|
package/package.json
ADDED
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@talkfurther/events",
|
|
3
|
+
"type": "module",
|
|
4
|
+
"version": "0.1.0",
|
|
5
|
+
"source": "index.ts",
|
|
6
|
+
"exports": {
|
|
7
|
+
"source": "./index.ts",
|
|
8
|
+
"types": "./dist/index.d.ts",
|
|
9
|
+
"require": "./dist/index.cjs",
|
|
10
|
+
"default": "./dist/index.modern.js"
|
|
11
|
+
},
|
|
12
|
+
"types": "./dist/index.d.ts",
|
|
13
|
+
"main": "./dist/index.cjs",
|
|
14
|
+
"module": "./dist/index.module.js",
|
|
15
|
+
"unpkg": "./dist/index.umd.js",
|
|
16
|
+
"files": [
|
|
17
|
+
"dist"
|
|
18
|
+
],
|
|
19
|
+
"dependencies": {
|
|
20
|
+
"zod": "^3.23.0"
|
|
21
|
+
},
|
|
22
|
+
"devDependencies": {
|
|
23
|
+
"microbundle": "^0.15.1"
|
|
24
|
+
},
|
|
25
|
+
"scripts": {
|
|
26
|
+
"dev": "microbundle watch --no-compress",
|
|
27
|
+
"build": "microbundle --no-compress",
|
|
28
|
+
"release": "npm run build && npm publish --access public"
|
|
29
|
+
}
|
|
30
|
+
}
|