@v-tilt/browser 1.6.0 → 1.7.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/array.full.js +1 -1
- package/dist/array.full.js.map +1 -1
- package/dist/array.js +1 -1
- package/dist/array.js.map +1 -1
- package/dist/array.no-external.js +1 -1
- package/dist/array.no-external.js.map +1 -1
- package/dist/chat.js +1 -1
- package/dist/chat.js.map +1 -1
- package/dist/constants.d.ts +1 -1
- package/dist/entrypoints/server.es.d.ts +12 -0
- package/dist/external-scripts-loader.js +1 -1
- package/dist/main.js +1 -1
- package/dist/main.js.map +1 -1
- package/dist/module.d.ts +6 -3
- package/dist/module.js +1 -1
- package/dist/module.js.map +1 -1
- package/dist/module.no-external.d.ts +6 -3
- package/dist/module.no-external.js +1 -1
- package/dist/module.no-external.js.map +1 -1
- package/dist/server.d.ts +105 -0
- package/dist/server.js +2 -0
- package/dist/server.js.map +1 -0
- package/dist/types.d.ts +3 -1
- package/dist/vtilt.d.ts +3 -2
- package/package.json +1 -2
- package/lib/config.d.ts +0 -17
- package/lib/config.js +0 -76
- package/lib/constants.d.ts +0 -178
- package/lib/constants.js +0 -656
- package/lib/entrypoints/all-external-dependencies.d.ts +0 -8
- package/lib/entrypoints/all-external-dependencies.js +0 -10
- package/lib/entrypoints/array.d.ts +0 -2
- package/lib/entrypoints/array.full.d.ts +0 -17
- package/lib/entrypoints/array.full.js +0 -19
- package/lib/entrypoints/array.js +0 -4
- package/lib/entrypoints/array.no-external.d.ts +0 -1
- package/lib/entrypoints/array.no-external.js +0 -4
- package/lib/entrypoints/chat.d.ts +0 -22
- package/lib/entrypoints/chat.js +0 -32
- package/lib/entrypoints/external-scripts-loader.d.ts +0 -24
- package/lib/entrypoints/external-scripts-loader.js +0 -104
- package/lib/entrypoints/main.cjs.d.ts +0 -4
- package/lib/entrypoints/main.cjs.js +0 -29
- package/lib/entrypoints/module.es.d.ts +0 -4
- package/lib/entrypoints/module.es.js +0 -23
- package/lib/entrypoints/module.no-external.es.d.ts +0 -4
- package/lib/entrypoints/module.no-external.es.js +0 -23
- package/lib/entrypoints/recorder.d.ts +0 -23
- package/lib/entrypoints/recorder.js +0 -42
- package/lib/entrypoints/web-vitals.d.ts +0 -14
- package/lib/entrypoints/web-vitals.js +0 -29
- package/lib/extensions/chat/chat-wrapper.d.ts +0 -196
- package/lib/extensions/chat/chat-wrapper.js +0 -545
- package/lib/extensions/chat/chat.d.ts +0 -99
- package/lib/extensions/chat/chat.js +0 -1891
- package/lib/extensions/chat/index.d.ts +0 -10
- package/lib/extensions/chat/index.js +0 -27
- package/lib/extensions/chat/types.d.ts +0 -159
- package/lib/extensions/chat/types.js +0 -22
- package/lib/extensions/history-autocapture.d.ts +0 -17
- package/lib/extensions/history-autocapture.js +0 -105
- package/lib/extensions/replay/index.d.ts +0 -13
- package/lib/extensions/replay/index.js +0 -31
- package/lib/extensions/replay/session-recording-utils.d.ts +0 -92
- package/lib/extensions/replay/session-recording-utils.js +0 -212
- package/lib/extensions/replay/session-recording-wrapper.d.ts +0 -61
- package/lib/extensions/replay/session-recording-wrapper.js +0 -149
- package/lib/extensions/replay/session-recording.d.ts +0 -95
- package/lib/extensions/replay/session-recording.js +0 -700
- package/lib/extensions/replay/types.d.ts +0 -211
- package/lib/extensions/replay/types.js +0 -8
- package/lib/geolocation.d.ts +0 -5
- package/lib/geolocation.js +0 -31
- package/lib/rate-limiter.d.ts +0 -52
- package/lib/rate-limiter.js +0 -80
- package/lib/request-queue.d.ts +0 -78
- package/lib/request-queue.js +0 -156
- package/lib/request.d.ts +0 -54
- package/lib/request.js +0 -265
- package/lib/retry-queue.d.ts +0 -64
- package/lib/retry-queue.js +0 -182
- package/lib/session.d.ts +0 -66
- package/lib/session.js +0 -191
- package/lib/storage.d.ts +0 -117
- package/lib/storage.js +0 -438
- package/lib/types.d.ts +0 -350
- package/lib/types.js +0 -24
- package/lib/user-manager.d.ts +0 -154
- package/lib/user-manager.js +0 -589
- package/lib/utils/event-utils.d.ts +0 -52
- package/lib/utils/event-utils.js +0 -305
- package/lib/utils/globals.d.ts +0 -235
- package/lib/utils/globals.js +0 -30
- package/lib/utils/index.d.ts +0 -46
- package/lib/utils/index.js +0 -134
- package/lib/utils/patch.d.ts +0 -6
- package/lib/utils/patch.js +0 -39
- package/lib/utils/request-utils.d.ts +0 -17
- package/lib/utils/request-utils.js +0 -80
- package/lib/utils/type-utils.d.ts +0 -4
- package/lib/utils/type-utils.js +0 -9
- package/lib/utils/user-agent-utils.d.ts +0 -18
- package/lib/utils/user-agent-utils.js +0 -411
- package/lib/vtilt.d.ts +0 -359
- package/lib/vtilt.js +0 -1188
- package/lib/web-vitals.d.ts +0 -95
- package/lib/web-vitals.js +0 -380
package/lib/utils/event-utils.js
DELETED
|
@@ -1,305 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
/**
|
|
3
|
-
* Event utilities
|
|
4
|
-
* Functions for extracting event properties, campaign parameters, and person info
|
|
5
|
-
*/
|
|
6
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
7
|
-
exports.COOKIE_CAMPAIGN_PARAMS = exports.MASKED = exports.EVENT_TO_PERSON_PROPERTIES = exports.CAMPAIGN_PARAMS = exports.PERSONAL_DATA_CAMPAIGN_PARAMS = void 0;
|
|
8
|
-
exports.getCampaignParams = getCampaignParams;
|
|
9
|
-
exports.getSearchInfo = getSearchInfo;
|
|
10
|
-
exports.getBrowserLanguage = getBrowserLanguage;
|
|
11
|
-
exports.getBrowserLanguagePrefix = getBrowserLanguagePrefix;
|
|
12
|
-
exports.getReferrer = getReferrer;
|
|
13
|
-
exports.getReferringDomain = getReferringDomain;
|
|
14
|
-
exports.getReferrerInfo = getReferrerInfo;
|
|
15
|
-
exports.getPersonInfo = getPersonInfo;
|
|
16
|
-
exports.getPersonPropsFromInfo = getPersonPropsFromInfo;
|
|
17
|
-
exports.getInitialPersonPropsFromInfo = getInitialPersonPropsFromInfo;
|
|
18
|
-
exports.getTimezone = getTimezone;
|
|
19
|
-
exports.getTimezoneOffset = getTimezoneOffset;
|
|
20
|
-
exports.getEventProperties = getEventProperties;
|
|
21
|
-
const request_utils_1 = require("./request-utils");
|
|
22
|
-
const index_1 = require("./index");
|
|
23
|
-
const globals_1 = require("./globals");
|
|
24
|
-
const user_agent_utils_1 = require("./user-agent-utils");
|
|
25
|
-
const constants_1 = require("../constants");
|
|
26
|
-
const URL_REGEX_PREFIX = "https?://(.*)";
|
|
27
|
-
// Campaign parameters that could be considered personal data (e.g., GDPR)
|
|
28
|
-
// These can be masked in URLs and properties before being sent
|
|
29
|
-
exports.PERSONAL_DATA_CAMPAIGN_PARAMS = [
|
|
30
|
-
"gclid", // google ads
|
|
31
|
-
"gclsrc", // google ads 360
|
|
32
|
-
"dclid", // google display ads
|
|
33
|
-
"gbraid", // google ads, web to app
|
|
34
|
-
"wbraid", // google ads, app to web
|
|
35
|
-
"fbclid", // facebook
|
|
36
|
-
"msclkid", // microsoft
|
|
37
|
-
"twclid", // twitter
|
|
38
|
-
"li_fat_id", // linkedin
|
|
39
|
-
"igshid", // instagram
|
|
40
|
-
"ttclid", // tiktok
|
|
41
|
-
"rdt_cid", // reddit
|
|
42
|
-
"epik", // pinterest
|
|
43
|
-
"qclid", // quora
|
|
44
|
-
"sccid", // snapchat
|
|
45
|
-
"irclid", // impact
|
|
46
|
-
"_kx", // klaviyo
|
|
47
|
-
];
|
|
48
|
-
exports.CAMPAIGN_PARAMS = (0, index_1.extendArray)([
|
|
49
|
-
"utm_source",
|
|
50
|
-
"utm_medium",
|
|
51
|
-
"utm_campaign",
|
|
52
|
-
"utm_content",
|
|
53
|
-
"utm_term",
|
|
54
|
-
"gad_source", // google ads source
|
|
55
|
-
"mc_cid", // mailchimp campaign id
|
|
56
|
-
], exports.PERSONAL_DATA_CAMPAIGN_PARAMS);
|
|
57
|
-
// Properties that should be automatically copied from events to person properties
|
|
58
|
-
exports.EVENT_TO_PERSON_PROPERTIES = [
|
|
59
|
-
// Mobile app properties
|
|
60
|
-
"$app_build",
|
|
61
|
-
"$app_name",
|
|
62
|
-
"$app_namespace",
|
|
63
|
-
"$app_version",
|
|
64
|
-
// Web browser properties
|
|
65
|
-
"$browser",
|
|
66
|
-
"$browser_version",
|
|
67
|
-
"$device_type",
|
|
68
|
-
"$current_url",
|
|
69
|
-
"$pathname",
|
|
70
|
-
"$os",
|
|
71
|
-
"$os_name", // Special case: treated as alias of $os
|
|
72
|
-
"$os_version",
|
|
73
|
-
"$referring_domain",
|
|
74
|
-
"$referrer",
|
|
75
|
-
"$screen_height",
|
|
76
|
-
"$screen_width",
|
|
77
|
-
"$viewport_height",
|
|
78
|
-
"$viewport_width",
|
|
79
|
-
"$raw_user_agent",
|
|
80
|
-
];
|
|
81
|
-
exports.MASKED = "<masked>";
|
|
82
|
-
// Campaign params that can be read from cookies (currently not implemented)
|
|
83
|
-
exports.COOKIE_CAMPAIGN_PARAMS = [
|
|
84
|
-
"li_fat_id", // linkedin
|
|
85
|
-
];
|
|
86
|
-
/**
|
|
87
|
-
* Get campaign parameters from URL
|
|
88
|
-
* Extracts UTM and other campaign tracking parameters from current page URL
|
|
89
|
-
* Masks personal data parameters if configured
|
|
90
|
-
*/
|
|
91
|
-
function getCampaignParams(customTrackedParams, maskPersonalDataProperties, customPersonalDataProperties) {
|
|
92
|
-
if (!globals_1.document) {
|
|
93
|
-
return {};
|
|
94
|
-
}
|
|
95
|
-
const paramsToMask = maskPersonalDataProperties
|
|
96
|
-
? (0, index_1.extendArray)([], exports.PERSONAL_DATA_CAMPAIGN_PARAMS, customPersonalDataProperties || [])
|
|
97
|
-
: [];
|
|
98
|
-
// Initially get campaign params from the URL
|
|
99
|
-
const urlCampaignParams = _getCampaignParamsFromUrl((0, request_utils_1.maskQueryParams)(globals_1.document.URL, paramsToMask, exports.MASKED), customTrackedParams);
|
|
100
|
-
// But we can also get some of them from the cookie store
|
|
101
|
-
// For now, we'll skip cookie-based campaign params (would need cookie store implementation)
|
|
102
|
-
const cookieCampaignParams = {};
|
|
103
|
-
// Prefer the values found in the urlCampaignParams if possible
|
|
104
|
-
// `extend` will override the values if found in the second argument
|
|
105
|
-
return (0, index_1.extend)(cookieCampaignParams, urlCampaignParams);
|
|
106
|
-
}
|
|
107
|
-
function _getCampaignParamsFromUrl(url, customParams) {
|
|
108
|
-
const campaign_keywords = exports.CAMPAIGN_PARAMS.concat(customParams || []);
|
|
109
|
-
const params = {};
|
|
110
|
-
(0, index_1.each)(campaign_keywords, function (kwkey) {
|
|
111
|
-
const kw = (0, request_utils_1.getQueryParam)(url, kwkey);
|
|
112
|
-
params[kwkey] = kw ? kw : null;
|
|
113
|
-
});
|
|
114
|
-
return params;
|
|
115
|
-
}
|
|
116
|
-
function _getSearchEngine(referrer) {
|
|
117
|
-
if (!referrer) {
|
|
118
|
-
return null;
|
|
119
|
-
}
|
|
120
|
-
else {
|
|
121
|
-
if (referrer.search(URL_REGEX_PREFIX + "google.([^/?]*)") === 0) {
|
|
122
|
-
return "google";
|
|
123
|
-
}
|
|
124
|
-
else if (referrer.search(URL_REGEX_PREFIX + "bing.com") === 0) {
|
|
125
|
-
return "bing";
|
|
126
|
-
}
|
|
127
|
-
else if (referrer.search(URL_REGEX_PREFIX + "yahoo.com") === 0) {
|
|
128
|
-
return "yahoo";
|
|
129
|
-
}
|
|
130
|
-
else if (referrer.search(URL_REGEX_PREFIX + "duckduckgo.com") === 0) {
|
|
131
|
-
return "duckduckgo";
|
|
132
|
-
}
|
|
133
|
-
else {
|
|
134
|
-
return null;
|
|
135
|
-
}
|
|
136
|
-
}
|
|
137
|
-
}
|
|
138
|
-
function _getSearchInfoFromReferrer(referrer) {
|
|
139
|
-
const search = _getSearchEngine(referrer);
|
|
140
|
-
const param = search !== "yahoo" ? "q" : "p";
|
|
141
|
-
const ret = {};
|
|
142
|
-
if (!(0, index_1.isNull)(search)) {
|
|
143
|
-
ret["$search_engine"] = search;
|
|
144
|
-
const keyword = globals_1.document ? (0, request_utils_1.getQueryParam)(globals_1.document.referrer, param) : "";
|
|
145
|
-
if (keyword.length) {
|
|
146
|
-
ret["ph_keyword"] = keyword;
|
|
147
|
-
}
|
|
148
|
-
}
|
|
149
|
-
return ret;
|
|
150
|
-
}
|
|
151
|
-
function getSearchInfo() {
|
|
152
|
-
const referrer = globals_1.document === null || globals_1.document === void 0 ? void 0 : globals_1.document.referrer;
|
|
153
|
-
if (!referrer) {
|
|
154
|
-
return {};
|
|
155
|
-
}
|
|
156
|
-
return _getSearchInfoFromReferrer(referrer);
|
|
157
|
-
}
|
|
158
|
-
function getBrowserLanguage() {
|
|
159
|
-
if (typeof navigator === "undefined") {
|
|
160
|
-
return undefined;
|
|
161
|
-
}
|
|
162
|
-
return (navigator.language || // Any modern browser
|
|
163
|
-
navigator.userLanguage // IE11
|
|
164
|
-
);
|
|
165
|
-
}
|
|
166
|
-
function getBrowserLanguagePrefix() {
|
|
167
|
-
const lang = getBrowserLanguage();
|
|
168
|
-
return typeof lang === "string" ? lang.split("-")[0] : undefined;
|
|
169
|
-
}
|
|
170
|
-
function getReferrer() {
|
|
171
|
-
return (globals_1.document === null || globals_1.document === void 0 ? void 0 : globals_1.document.referrer) || "$direct";
|
|
172
|
-
}
|
|
173
|
-
function getReferringDomain() {
|
|
174
|
-
var _a;
|
|
175
|
-
if (!(globals_1.document === null || globals_1.document === void 0 ? void 0 : globals_1.document.referrer)) {
|
|
176
|
-
return "$direct";
|
|
177
|
-
}
|
|
178
|
-
return ((_a = (0, request_utils_1.convertToURL)(globals_1.document.referrer)) === null || _a === void 0 ? void 0 : _a.host) || "$direct";
|
|
179
|
-
}
|
|
180
|
-
/**
|
|
181
|
-
* Get referrer information
|
|
182
|
-
* Returns current referrer and referring domain
|
|
183
|
-
*/
|
|
184
|
-
function getReferrerInfo() {
|
|
185
|
-
return {
|
|
186
|
-
$referrer: getReferrer(),
|
|
187
|
-
$referring_domain: getReferringDomain(),
|
|
188
|
-
};
|
|
189
|
-
}
|
|
190
|
-
/**
|
|
191
|
-
* Get person info for initial storage
|
|
192
|
-
* Extracts referrer and URL info, masks personal data if configured
|
|
193
|
-
* Returns compact format (r: referrer, u: url) for storage efficiency
|
|
194
|
-
*/
|
|
195
|
-
function getPersonInfo(maskPersonalDataProperties, customPersonalDataProperties) {
|
|
196
|
-
const paramsToMask = maskPersonalDataProperties
|
|
197
|
-
? (0, index_1.extendArray)([], exports.PERSONAL_DATA_CAMPAIGN_PARAMS, customPersonalDataProperties || [])
|
|
198
|
-
: [];
|
|
199
|
-
const url = globals_1.location === null || globals_1.location === void 0 ? void 0 : globals_1.location.href.substring(0, 1000);
|
|
200
|
-
// Compact format for storage efficiency (stored in localStorage)
|
|
201
|
-
return {
|
|
202
|
-
r: getReferrer().substring(0, 1000),
|
|
203
|
-
u: url ? (0, request_utils_1.maskQueryParams)(url, paramsToMask, exports.MASKED) : undefined,
|
|
204
|
-
};
|
|
205
|
-
}
|
|
206
|
-
/**
|
|
207
|
-
* Convert person info to person properties
|
|
208
|
-
* Extracts referrer, URL, campaign params, and search info from stored person info
|
|
209
|
-
*/
|
|
210
|
-
function getPersonPropsFromInfo(info) {
|
|
211
|
-
var _a;
|
|
212
|
-
const { r: referrer, u: url } = info;
|
|
213
|
-
const referring_domain = referrer == null
|
|
214
|
-
? undefined
|
|
215
|
-
: referrer === "$direct"
|
|
216
|
-
? "$direct"
|
|
217
|
-
: (_a = (0, request_utils_1.convertToURL)(referrer)) === null || _a === void 0 ? void 0 : _a.host;
|
|
218
|
-
const props = {
|
|
219
|
-
$referrer: referrer,
|
|
220
|
-
$referring_domain: referring_domain,
|
|
221
|
-
};
|
|
222
|
-
if (url) {
|
|
223
|
-
props["$current_url"] = url;
|
|
224
|
-
const location = (0, request_utils_1.convertToURL)(url);
|
|
225
|
-
props["$host"] = location === null || location === void 0 ? void 0 : location.host;
|
|
226
|
-
props["$pathname"] = location === null || location === void 0 ? void 0 : location.pathname;
|
|
227
|
-
const campaignParams = _getCampaignParamsFromUrl(url);
|
|
228
|
-
(0, index_1.extend)(props, campaignParams);
|
|
229
|
-
}
|
|
230
|
-
if (referrer) {
|
|
231
|
-
const searchInfo = _getSearchInfoFromReferrer(referrer);
|
|
232
|
-
(0, index_1.extend)(props, searchInfo);
|
|
233
|
-
}
|
|
234
|
-
return props;
|
|
235
|
-
}
|
|
236
|
-
/**
|
|
237
|
-
* Convert person info to initial person properties
|
|
238
|
-
* Generates $initial_* properties from person info (preserves first values)
|
|
239
|
-
*/
|
|
240
|
-
function getInitialPersonPropsFromInfo(info) {
|
|
241
|
-
const personProps = getPersonPropsFromInfo(info);
|
|
242
|
-
const props = {};
|
|
243
|
-
(0, index_1.each)(personProps, function (val, key) {
|
|
244
|
-
props[`$initial_${(0, index_1.stripLeadingDollar)(String(key))}`] = val;
|
|
245
|
-
});
|
|
246
|
-
return props;
|
|
247
|
-
}
|
|
248
|
-
function getTimezone() {
|
|
249
|
-
try {
|
|
250
|
-
return Intl.DateTimeFormat().resolvedOptions().timeZone;
|
|
251
|
-
}
|
|
252
|
-
catch (_a) {
|
|
253
|
-
return undefined;
|
|
254
|
-
}
|
|
255
|
-
}
|
|
256
|
-
function getTimezoneOffset() {
|
|
257
|
-
try {
|
|
258
|
-
return new Date().getTimezoneOffset();
|
|
259
|
-
}
|
|
260
|
-
catch (_a) {
|
|
261
|
-
return undefined;
|
|
262
|
-
}
|
|
263
|
-
}
|
|
264
|
-
/**
|
|
265
|
-
* Get event properties that should be added to all events
|
|
266
|
-
* Returns all event context properties (browser, device, URL, etc.) plus event metadata
|
|
267
|
-
* Note: Only properties in EVENT_TO_PERSON_PROPERTIES are copied to person properties
|
|
268
|
-
*/
|
|
269
|
-
function getEventProperties(maskPersonalDataProperties, customPersonalDataProperties) {
|
|
270
|
-
if (!globals_1.userAgent) {
|
|
271
|
-
return {};
|
|
272
|
-
}
|
|
273
|
-
const paramsToMask = maskPersonalDataProperties
|
|
274
|
-
? (0, index_1.extendArray)([], exports.PERSONAL_DATA_CAMPAIGN_PARAMS, customPersonalDataProperties || [])
|
|
275
|
-
: [];
|
|
276
|
-
const [os_name, os_version] = (0, user_agent_utils_1.detectOS)(globals_1.userAgent);
|
|
277
|
-
return (0, index_1.extend)((0, index_1.stripEmptyProperties)({
|
|
278
|
-
$os: os_name,
|
|
279
|
-
$os_version: os_version,
|
|
280
|
-
$browser: (0, user_agent_utils_1.detectBrowser)(globals_1.userAgent, navigator.vendor),
|
|
281
|
-
$device: (0, user_agent_utils_1.detectDevice)(globals_1.userAgent),
|
|
282
|
-
$device_type: (0, user_agent_utils_1.detectDeviceType)(globals_1.userAgent),
|
|
283
|
-
$timezone: getTimezone(),
|
|
284
|
-
$timezone_offset: getTimezoneOffset(),
|
|
285
|
-
}), {
|
|
286
|
-
$current_url: (0, request_utils_1.maskQueryParams)(globals_1.location === null || globals_1.location === void 0 ? void 0 : globals_1.location.href, paramsToMask, exports.MASKED),
|
|
287
|
-
$host: globals_1.location === null || globals_1.location === void 0 ? void 0 : globals_1.location.host,
|
|
288
|
-
$pathname: globals_1.location === null || globals_1.location === void 0 ? void 0 : globals_1.location.pathname,
|
|
289
|
-
$raw_user_agent: globals_1.userAgent.length > 1000
|
|
290
|
-
? globals_1.userAgent.substring(0, 997) + "..."
|
|
291
|
-
: globals_1.userAgent,
|
|
292
|
-
$browser_version: (0, user_agent_utils_1.detectBrowserVersion)(globals_1.userAgent, navigator.vendor),
|
|
293
|
-
$browser_language: getBrowserLanguage(),
|
|
294
|
-
$browser_language_prefix: getBrowserLanguagePrefix(),
|
|
295
|
-
$screen_height: globals_1.window === null || globals_1.window === void 0 ? void 0 : globals_1.window.screen.height,
|
|
296
|
-
$screen_width: globals_1.window === null || globals_1.window === void 0 ? void 0 : globals_1.window.screen.width,
|
|
297
|
-
$viewport_height: globals_1.window === null || globals_1.window === void 0 ? void 0 : globals_1.window.innerHeight,
|
|
298
|
-
$viewport_width: globals_1.window === null || globals_1.window === void 0 ? void 0 : globals_1.window.innerWidth,
|
|
299
|
-
$lib: "web",
|
|
300
|
-
$lib_version: constants_1.SDK_VERSION,
|
|
301
|
-
$insert_id: Math.random().toString(36).substring(2, 10) +
|
|
302
|
-
Math.random().toString(36).substring(2, 10),
|
|
303
|
-
$time: Date.now() / 1000, // epoch time in seconds
|
|
304
|
-
});
|
|
305
|
-
}
|
package/lib/utils/globals.d.ts
DELETED
|
@@ -1,235 +0,0 @@
|
|
|
1
|
-
declare const win: (Window & typeof globalThis) | undefined;
|
|
2
|
-
/**
|
|
3
|
-
* Extension kinds that can be lazy loaded
|
|
4
|
-
*/
|
|
5
|
-
export type VTiltExtensionKind = "recorder" | "web-vitals" | "chat";
|
|
6
|
-
/**
|
|
7
|
-
* Interface for lazy-loaded session recording (set by recorder.ts)
|
|
8
|
-
* Matches LazyLoadedSessionRecordingInterface in session-recording-wrapper.ts
|
|
9
|
-
*/
|
|
10
|
-
export interface LazyLoadedSessionRecordingInterface {
|
|
11
|
-
start: (startReason?: string) => void;
|
|
12
|
-
stop: () => void;
|
|
13
|
-
sessionId: string;
|
|
14
|
-
status: string;
|
|
15
|
-
isStarted: boolean;
|
|
16
|
-
onRemoteConfig?: (response: any) => void;
|
|
17
|
-
log: (message: string, level: "log" | "warn" | "error") => void;
|
|
18
|
-
updateConfig: (config: any) => void;
|
|
19
|
-
}
|
|
20
|
-
/**
|
|
21
|
-
* Web Vitals metric callback type
|
|
22
|
-
*/
|
|
23
|
-
export type WebVitalsMetricCallback = (metric: any) => void;
|
|
24
|
-
/**
|
|
25
|
-
* Options for web vitals callbacks
|
|
26
|
-
*/
|
|
27
|
-
export interface WebVitalsCallbackOptions {
|
|
28
|
-
/** Report all changes (useful for CLS which updates over time) */
|
|
29
|
-
reportAllChanges?: boolean;
|
|
30
|
-
}
|
|
31
|
-
/**
|
|
32
|
-
* Web Vitals callback function type (with optional options)
|
|
33
|
-
*/
|
|
34
|
-
export type WebVitalsCallbackFn = (callback: WebVitalsMetricCallback, options?: WebVitalsCallbackOptions) => void;
|
|
35
|
-
/**
|
|
36
|
-
* Web Vitals callbacks interface (set by web-vitals.ts entrypoint)
|
|
37
|
-
*/
|
|
38
|
-
export interface WebVitalsCallbacks {
|
|
39
|
-
onLCP: WebVitalsCallbackFn;
|
|
40
|
-
onCLS: WebVitalsCallbackFn;
|
|
41
|
-
onFCP: WebVitalsCallbackFn;
|
|
42
|
-
onINP: WebVitalsCallbackFn;
|
|
43
|
-
onTTFB?: WebVitalsCallbackFn;
|
|
44
|
-
}
|
|
45
|
-
/**
|
|
46
|
-
* Chat message structure (matches PostgreSQL chat_messages table)
|
|
47
|
-
* Note: Read status is determined by cursor comparison, not per-message
|
|
48
|
-
*/
|
|
49
|
-
export interface ChatMessage {
|
|
50
|
-
id: string;
|
|
51
|
-
channel_id: string;
|
|
52
|
-
sender_type: "user" | "agent" | "ai" | "system";
|
|
53
|
-
sender_id: string | null;
|
|
54
|
-
sender_name: string | null;
|
|
55
|
-
sender_avatar_url: string | null;
|
|
56
|
-
content: string;
|
|
57
|
-
content_type: "text" | "html" | "attachment";
|
|
58
|
-
metadata: Record<string, unknown>;
|
|
59
|
-
created_at: string;
|
|
60
|
-
}
|
|
61
|
-
/**
|
|
62
|
-
* Chat channel structure (maps 1:1 to Ably channel)
|
|
63
|
-
*/
|
|
64
|
-
export interface ChatChannel {
|
|
65
|
-
id: string;
|
|
66
|
-
project_id: string;
|
|
67
|
-
person_id: string;
|
|
68
|
-
distinct_id: string;
|
|
69
|
-
status: "open" | "closed" | "snoozed";
|
|
70
|
-
ai_mode: boolean;
|
|
71
|
-
unread_count: number;
|
|
72
|
-
last_message_at: string | null;
|
|
73
|
-
last_message_preview: string | null;
|
|
74
|
-
last_message_sender: "user" | "agent" | "ai" | "system" | null;
|
|
75
|
-
user_last_read_at: string | null;
|
|
76
|
-
agent_last_read_at: string | null;
|
|
77
|
-
created_at: string;
|
|
78
|
-
}
|
|
79
|
-
/**
|
|
80
|
-
* Lightweight channel summary for channel list view
|
|
81
|
-
* Used to avoid loading full channel data until user selects one
|
|
82
|
-
*/
|
|
83
|
-
export interface ChatChannelSummary {
|
|
84
|
-
id: string;
|
|
85
|
-
status: "open" | "closed" | "snoozed";
|
|
86
|
-
ai_mode: boolean;
|
|
87
|
-
last_message_at: string | null;
|
|
88
|
-
last_message_preview: string | null;
|
|
89
|
-
last_message_sender: "user" | "agent" | "ai" | "system" | null;
|
|
90
|
-
unread_count: number;
|
|
91
|
-
user_last_read_at: string | null;
|
|
92
|
-
created_at: string;
|
|
93
|
-
}
|
|
94
|
-
/**
|
|
95
|
-
* Widget view state - determines what UI to show
|
|
96
|
-
*/
|
|
97
|
-
export type ChatWidgetView = "list" | "conversation";
|
|
98
|
-
/**
|
|
99
|
-
* Chat widget configuration
|
|
100
|
-
*
|
|
101
|
-
* Settings can come from two sources:
|
|
102
|
-
* 1. Dashboard (fetched from /api/chat/settings) - "snippet-only" mode
|
|
103
|
-
* 2. Code config (passed to vt.init) - overrides dashboard settings
|
|
104
|
-
*
|
|
105
|
-
* This enables Intercom-like flexibility: just add snippet OR customize with code.
|
|
106
|
-
*/
|
|
107
|
-
export interface ChatConfig {
|
|
108
|
-
/**
|
|
109
|
-
* Enable/disable chat widget.
|
|
110
|
-
* - undefined: Use dashboard setting (auto-fetch)
|
|
111
|
-
* - true: Enable (override dashboard)
|
|
112
|
-
* - false: Disable entirely
|
|
113
|
-
*/
|
|
114
|
-
enabled?: boolean;
|
|
115
|
-
/**
|
|
116
|
-
* Auto-fetch settings from dashboard (default: true)
|
|
117
|
-
* When true, SDK fetches /api/chat/settings and uses those as base config.
|
|
118
|
-
* Code config always overrides fetched settings.
|
|
119
|
-
*/
|
|
120
|
-
autoConfig?: boolean;
|
|
121
|
-
/** Widget position (default: 'bottom-right') */
|
|
122
|
-
position?: "bottom-right" | "bottom-left";
|
|
123
|
-
/** Widget header/greeting message */
|
|
124
|
-
greeting?: string;
|
|
125
|
-
/** Widget primary color */
|
|
126
|
-
color?: string;
|
|
127
|
-
/** Start in AI mode (default: true) */
|
|
128
|
-
aiMode?: boolean;
|
|
129
|
-
/** AI greeting message (first message from AI) */
|
|
130
|
-
aiGreeting?: string;
|
|
131
|
-
/** Preload widget script on idle vs on-demand */
|
|
132
|
-
preload?: boolean;
|
|
133
|
-
/** Custom theme */
|
|
134
|
-
theme?: ChatTheme;
|
|
135
|
-
/** Offline message shown when business is unavailable */
|
|
136
|
-
offlineMessage?: string;
|
|
137
|
-
/** Collect email when offline */
|
|
138
|
-
collectEmailOffline?: boolean;
|
|
139
|
-
}
|
|
140
|
-
/**
|
|
141
|
-
* Chat theme customization
|
|
142
|
-
*/
|
|
143
|
-
export interface ChatTheme {
|
|
144
|
-
primaryColor?: string;
|
|
145
|
-
fontFamily?: string;
|
|
146
|
-
borderRadius?: string;
|
|
147
|
-
headerBgColor?: string;
|
|
148
|
-
userBubbleColor?: string;
|
|
149
|
-
agentBubbleColor?: string;
|
|
150
|
-
}
|
|
151
|
-
/**
|
|
152
|
-
* Interface for lazy-loaded chat widget (set by chat.ts entrypoint)
|
|
153
|
-
*/
|
|
154
|
-
export interface LazyLoadedChatInterface {
|
|
155
|
-
readonly isOpen: boolean;
|
|
156
|
-
readonly isConnected: boolean;
|
|
157
|
-
readonly isLoading: boolean;
|
|
158
|
-
readonly unreadCount: number;
|
|
159
|
-
readonly channel: ChatChannel | null;
|
|
160
|
-
readonly channels: ChatChannelSummary[];
|
|
161
|
-
readonly currentView: ChatWidgetView;
|
|
162
|
-
open(): void;
|
|
163
|
-
close(): void;
|
|
164
|
-
toggle(): void;
|
|
165
|
-
show(): void;
|
|
166
|
-
hide(): void;
|
|
167
|
-
/** Fetch/refresh the list of user's channels */
|
|
168
|
-
getChannels(): Promise<void>;
|
|
169
|
-
/** Select a channel and load its messages */
|
|
170
|
-
selectChannel(channelId: string): Promise<void>;
|
|
171
|
-
/** Create a new channel and enter it */
|
|
172
|
-
createChannel(): Promise<void>;
|
|
173
|
-
/** Go back to channel list from conversation view */
|
|
174
|
-
goToChannelList(): void;
|
|
175
|
-
sendMessage(content: string): Promise<void>;
|
|
176
|
-
markAsRead(): void;
|
|
177
|
-
onMessage(callback: (message: ChatMessage) => void): () => void;
|
|
178
|
-
onTyping(callback: (isTyping: boolean, senderType: string) => void): () => void;
|
|
179
|
-
onConnectionChange(callback: (connected: boolean) => void): () => void;
|
|
180
|
-
destroy(): void;
|
|
181
|
-
}
|
|
182
|
-
/**
|
|
183
|
-
* VTilt Extensions interface for dynamically loaded modules
|
|
184
|
-
* This is the contract between lazily loaded extensions and the SDK
|
|
185
|
-
*/
|
|
186
|
-
export interface VTiltExtensions {
|
|
187
|
-
/** Load an external dependency script */
|
|
188
|
-
loadExternalDependency?: (instance: any, // VTilt instance - using any to avoid circular imports
|
|
189
|
-
kind: VTiltExtensionKind, callback: (error?: string | Event, event?: Event) => void) => void;
|
|
190
|
-
/** rrweb record function (set by recorder.ts) */
|
|
191
|
-
rrweb?: {
|
|
192
|
-
record: any;
|
|
193
|
-
version?: string;
|
|
194
|
-
};
|
|
195
|
-
/** rrweb plugins (set by recorder.ts) */
|
|
196
|
-
rrwebPlugins?: {
|
|
197
|
-
getRecordConsolePlugin?: () => any;
|
|
198
|
-
getRecordNetworkPlugin?: (options: any) => any;
|
|
199
|
-
};
|
|
200
|
-
/** Factory to create LazyLoadedSessionRecording (set by recorder.ts) */
|
|
201
|
-
initSessionRecording?: (instance: any, config?: any) => LazyLoadedSessionRecordingInterface;
|
|
202
|
-
/** Web Vitals callbacks (set by web-vitals.ts entrypoint) */
|
|
203
|
-
webVitalsCallbacks?: WebVitalsCallbacks;
|
|
204
|
-
/** Factory to create LazyLoadedChat (set by chat.ts entrypoint) */
|
|
205
|
-
initChat?: (instance: any, config?: ChatConfig) => LazyLoadedChatInterface;
|
|
206
|
-
}
|
|
207
|
-
export type AssignableWindow = Window & typeof globalThis & {
|
|
208
|
-
/** Main VTilt instance */
|
|
209
|
-
vt: any;
|
|
210
|
-
/** VTilt Extensions for dynamically loaded modules */
|
|
211
|
-
__VTiltExtensions__?: VTiltExtensions;
|
|
212
|
-
};
|
|
213
|
-
export declare const ArrayProto: any[];
|
|
214
|
-
export declare const nativeForEach: (callbackfn: (value: any, index: number, array: any[]) => void, thisArg?: any) => void;
|
|
215
|
-
export declare const nativeIndexOf: (searchElement: any, fromIndex?: number) => number;
|
|
216
|
-
export declare const navigator: Navigator | undefined;
|
|
217
|
-
export declare const document: Document | undefined;
|
|
218
|
-
export declare const location: Location | undefined;
|
|
219
|
-
export declare const fetch: typeof globalThis.fetch | undefined;
|
|
220
|
-
export declare const XMLHttpRequest: {
|
|
221
|
-
new (): XMLHttpRequest;
|
|
222
|
-
prototype: XMLHttpRequest;
|
|
223
|
-
readonly UNSENT: 0;
|
|
224
|
-
readonly OPENED: 1;
|
|
225
|
-
readonly HEADERS_RECEIVED: 2;
|
|
226
|
-
readonly LOADING: 3;
|
|
227
|
-
readonly DONE: 4;
|
|
228
|
-
} | undefined;
|
|
229
|
-
export declare const AbortController: {
|
|
230
|
-
new (): AbortController;
|
|
231
|
-
prototype: AbortController;
|
|
232
|
-
} | undefined;
|
|
233
|
-
export declare const userAgent: string | undefined;
|
|
234
|
-
export declare const assignableWindow: AssignableWindow;
|
|
235
|
-
export { win as window };
|
package/lib/utils/globals.js
DELETED
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
/*
|
|
3
|
-
* Global helpers to protect access to browser globals in a way that is safer for different targets
|
|
4
|
-
* like DOM, SSR, Web workers etc.
|
|
5
|
-
*
|
|
6
|
-
* NOTE: Typically we want the "window" but globalThis works for both the typical browser context as
|
|
7
|
-
* well as other contexts such as the web worker context. Window is still exported for any bits that explicitly require it.
|
|
8
|
-
* If in doubt - export the global you need from this file and use that as an optional value. This way the code path is forced
|
|
9
|
-
* to handle the case where the global is not available.
|
|
10
|
-
*/
|
|
11
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
-
exports.window = exports.assignableWindow = exports.userAgent = exports.AbortController = exports.XMLHttpRequest = exports.fetch = exports.location = exports.document = exports.navigator = exports.nativeIndexOf = exports.nativeForEach = exports.ArrayProto = void 0;
|
|
13
|
-
// Note: We use 'any' for VTilt to avoid circular imports
|
|
14
|
-
// The actual type checking happens in the external-scripts-loader.ts
|
|
15
|
-
const win = typeof window !== "undefined" ? window : undefined;
|
|
16
|
-
exports.window = win;
|
|
17
|
-
const global = typeof globalThis !== "undefined" ? globalThis : win;
|
|
18
|
-
exports.ArrayProto = Array.prototype;
|
|
19
|
-
exports.nativeForEach = exports.ArrayProto.forEach;
|
|
20
|
-
exports.nativeIndexOf = exports.ArrayProto.indexOf;
|
|
21
|
-
exports.navigator = global === null || global === void 0 ? void 0 : global.navigator;
|
|
22
|
-
exports.document = global === null || global === void 0 ? void 0 : global.document;
|
|
23
|
-
exports.location = global === null || global === void 0 ? void 0 : global.location;
|
|
24
|
-
exports.fetch = global === null || global === void 0 ? void 0 : global.fetch;
|
|
25
|
-
exports.XMLHttpRequest = (global === null || global === void 0 ? void 0 : global.XMLHttpRequest) && "withCredentials" in new global.XMLHttpRequest()
|
|
26
|
-
? global.XMLHttpRequest
|
|
27
|
-
: undefined;
|
|
28
|
-
exports.AbortController = global === null || global === void 0 ? void 0 : global.AbortController;
|
|
29
|
-
exports.userAgent = exports.navigator === null || exports.navigator === void 0 ? void 0 : exports.navigator.userAgent;
|
|
30
|
-
exports.assignableWindow = win !== null && win !== void 0 ? win : {};
|
package/lib/utils/index.d.ts
DELETED
|
@@ -1,46 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Generate uuid to identify the session. Random, not data-derived
|
|
3
|
-
*/
|
|
4
|
-
export declare function uuidv4(): string;
|
|
5
|
-
/**
|
|
6
|
-
* Validate user agent string
|
|
7
|
-
*/
|
|
8
|
-
export declare function isValidUserAgent(userAgent: string): boolean;
|
|
9
|
-
/**
|
|
10
|
-
* Validate payload string
|
|
11
|
-
*/
|
|
12
|
-
export declare function isValidPayload(payloadStr: string): boolean;
|
|
13
|
-
/**
|
|
14
|
-
* Check if current environment is a test environment
|
|
15
|
-
*/
|
|
16
|
-
export declare function isTestEnvironment(): boolean;
|
|
17
|
-
/**
|
|
18
|
-
* Iterate over an array or object
|
|
19
|
-
*/
|
|
20
|
-
export declare function each<T>(obj: T[] | Record<string, T> | null | undefined, iterator: (value: T, key: string | number) => void, thisArg?: any): void;
|
|
21
|
-
/**
|
|
22
|
-
* Use this instead of element.addEventListener to avoid eslint errors
|
|
23
|
-
* This properly implements the default options for passive event listeners
|
|
24
|
-
*/
|
|
25
|
-
export declare function addEventListener(element: Window | Document | Element | undefined, event: string, callback: EventListener, options?: AddEventListenerOptions): void;
|
|
26
|
-
/**
|
|
27
|
-
* Extend object with properties from another object
|
|
28
|
-
*/
|
|
29
|
-
export declare function extend<T extends Record<string, any>>(target: T, source: Record<string, any> | null | undefined): T;
|
|
30
|
-
/**
|
|
31
|
-
* Extend array with additional items
|
|
32
|
-
* Mutates the base array and returns it (matches PostHog's behavior)
|
|
33
|
-
*/
|
|
34
|
-
export declare function extendArray<T>(base: T[], ...additional: T[][]): T[];
|
|
35
|
-
/**
|
|
36
|
-
* Strip properties with empty values (null, undefined, empty string)
|
|
37
|
-
*/
|
|
38
|
-
export declare function stripEmptyProperties<T extends Record<string, any>>(obj: T): Partial<T>;
|
|
39
|
-
/**
|
|
40
|
-
* Strip leading dollar sign from string
|
|
41
|
-
*/
|
|
42
|
-
export declare function stripLeadingDollar(str: string): string;
|
|
43
|
-
/**
|
|
44
|
-
* Check if value is null
|
|
45
|
-
*/
|
|
46
|
-
export declare function isNull(value: any): boolean;
|