@uptrademedia/site-kit 1.0.8 → 1.0.10
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/api-CWtoFJCO.d.mts +137 -0
- package/dist/api-CWtoFJCO.d.ts +137 -0
- package/dist/{api-QUIPJJCX.js → api-UBHLAPUG.js} +20 -20
- package/dist/api-UBHLAPUG.js.map +1 -0
- package/dist/{api-V3BA5PMX.mjs → api-XNF6Q5HO.mjs} +3 -3
- package/dist/api-XNF6Q5HO.mjs.map +1 -0
- package/dist/blog/index.d.mts +131 -5
- package/dist/blog/index.d.ts +131 -5
- package/dist/blog/index.js +532 -302
- package/dist/blog/index.js.map +1 -1
- package/dist/blog/index.mjs +532 -302
- package/dist/blog/index.mjs.map +1 -1
- package/dist/{chunk-QQB4FO4Q.js → chunk-AWAJEIZS.js} +11 -8
- package/dist/chunk-AWAJEIZS.js.map +1 -0
- package/dist/{chunk-MB3WR5KJ.mjs → chunk-CDJL2YGL.mjs} +61 -443
- package/dist/chunk-CDJL2YGL.mjs.map +1 -0
- package/dist/{chunk-TDK7DLCH.js → chunk-FLAA4ZJO.js} +59 -448
- package/dist/chunk-FLAA4ZJO.js.map +1 -0
- package/dist/{chunk-JGQPAXTL.mjs → chunk-H5AGHERY.mjs} +8 -5
- package/dist/chunk-H5AGHERY.mjs.map +1 -0
- package/dist/{chunk-VDI7KYME.js → chunk-IYVJGUYX.js} +8 -4
- package/dist/chunk-IYVJGUYX.js.map +1 -0
- package/dist/{chunk-FQVGK746.mjs → chunk-SKHOW2CI.mjs} +8 -4
- package/dist/chunk-SKHOW2CI.mjs.map +1 -0
- package/dist/cli/index.js +32 -25
- package/dist/cli/index.js.map +1 -1
- package/dist/cli/index.mjs +32 -25
- package/dist/cli/index.mjs.map +1 -1
- package/dist/images/index.d.mts +49 -126
- package/dist/images/index.d.ts +49 -126
- package/dist/images/index.js +12 -12
- package/dist/images/index.mjs +1 -5
- package/dist/index.d.mts +2 -2
- package/dist/index.d.ts +2 -2
- package/dist/index.js +510 -106
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +440 -13
- package/dist/index.mjs.map +1 -1
- package/dist/{routing-CIOFpFCB.d.mts → routing-BT0RrBLk.d.mts} +14 -1
- package/dist/{routing-CF91y6NO.d.ts → routing-wmNSxSvP.d.ts} +14 -1
- package/dist/seo/index.d.mts +37 -4
- package/dist/seo/index.d.ts +37 -4
- package/dist/seo/index.js +48 -18
- package/dist/seo/index.js.map +1 -1
- package/dist/seo/index.mjs +34 -5
- package/dist/seo/index.mjs.map +1 -1
- package/dist/seo/server.d.mts +15 -4
- package/dist/seo/server.d.ts +15 -4
- package/dist/seo/server.js +16 -16
- package/dist/seo/server.mjs +2 -2
- package/dist/{types-j8X4vUhB.d.mts → types-wf4dwNMO.d.mts} +5 -0
- package/dist/{types-j8X4vUhB.d.ts → types-wf4dwNMO.d.ts} +5 -0
- package/package.json +6 -1
- package/dist/api-QUIPJJCX.js.map +0 -1
- package/dist/api-V3BA5PMX.mjs.map +0 -1
- package/dist/chunk-FQVGK746.mjs.map +0 -1
- package/dist/chunk-JGQPAXTL.mjs.map +0 -1
- package/dist/chunk-MB3WR5KJ.mjs.map +0 -1
- package/dist/chunk-QQB4FO4Q.js.map +0 -1
- package/dist/chunk-TDK7DLCH.js.map +0 -1
- package/dist/chunk-VDI7KYME.js.map +0 -1
package/dist/index.mjs
CHANGED
|
@@ -3,24 +3,451 @@ export { AEOBlock, AEOCitedContent, AEOClaim, AEOComparison, AEODefinition, AEOE
|
|
|
3
3
|
export { CalendarView, CheckoutForm, EventCalendar, EventEmbed, EventModal, EventTile, OfferingCard, OfferingList, ProductEmbed, RegistrationForm, UpcomingEvents, createCheckoutSession, fetchNextEvent, fetchOffering, fetchOfferings, fetchProducts, fetchServices, fetchUpcomingEvents, formatDate, formatDateTime, formatPrice, getOfferingUrl, registerForEvent, useEventModal } from './chunk-DOHML47I.mjs';
|
|
4
4
|
export { SetupWizard } from './chunk-XFRPT5ZX.mjs';
|
|
5
5
|
export { clearRedirectCache, fetchRedirectRules, generateNextRedirects, handleManagedRedirects } from './chunk-VDMZZL2O.mjs';
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
import './chunk-
|
|
9
|
-
import './chunk-
|
|
10
|
-
import './chunk-
|
|
11
|
-
import './chunk-SMUFNQLM.mjs';
|
|
6
|
+
export { ManagedImage, assignImageToSlot, clearImageSlot, fetchManagedImage, fetchManagedImages, listImageFiles, uploadImage } from './chunk-CDJL2YGL.mjs';
|
|
7
|
+
import { SitemapSync } from './chunk-WPSRS352.mjs';
|
|
8
|
+
import { AnalyticsProvider } from './chunk-42EXHJTC.mjs';
|
|
9
|
+
import { EngageWidget } from './chunk-DYM5ML2V.mjs';
|
|
10
|
+
import { configureFormsApi } from './chunk-SMUFNQLM.mjs';
|
|
12
11
|
import './chunk-4XPGGLVP.mjs';
|
|
13
|
-
import
|
|
12
|
+
import React3, { createContext, useContext, useState, useRef, useCallback, useEffect, useMemo, Suspense } from 'react';
|
|
14
13
|
import { jsx, jsxs, Fragment } from 'react/jsx-runtime';
|
|
15
14
|
|
|
16
|
-
|
|
15
|
+
var SignalContext = createContext(null);
|
|
16
|
+
function useSignal() {
|
|
17
|
+
const context = useContext(SignalContext);
|
|
18
|
+
if (!context) {
|
|
19
|
+
throw new Error("useSignal must be used within a SignalBridge");
|
|
20
|
+
}
|
|
21
|
+
return context;
|
|
22
|
+
}
|
|
17
23
|
function getApiConfig() {
|
|
24
|
+
const apiUrl = typeof window !== "undefined" ? window.__SITE_KIT_API_URL__ || "https://api.uptrademedia.com" : "https://api.uptrademedia.com";
|
|
25
|
+
const apiKey = typeof window !== "undefined" ? window.__SITE_KIT_API_KEY__ : void 0;
|
|
26
|
+
return { apiUrl, apiKey };
|
|
27
|
+
}
|
|
28
|
+
function getVisitorId() {
|
|
29
|
+
if (typeof window === "undefined") return "";
|
|
30
|
+
const key = "_uptrade_vid";
|
|
31
|
+
let visitorId = localStorage.getItem(key);
|
|
32
|
+
if (!visitorId) {
|
|
33
|
+
visitorId = crypto.randomUUID();
|
|
34
|
+
localStorage.setItem(key, visitorId);
|
|
35
|
+
}
|
|
36
|
+
return visitorId;
|
|
37
|
+
}
|
|
38
|
+
function getSessionId() {
|
|
39
|
+
if (typeof window === "undefined") return "";
|
|
40
|
+
const key = "_uptrade_sid";
|
|
41
|
+
let sessionId = sessionStorage.getItem(key);
|
|
42
|
+
if (!sessionId) {
|
|
43
|
+
sessionId = crypto.randomUUID();
|
|
44
|
+
sessionStorage.setItem(key, sessionId);
|
|
45
|
+
}
|
|
46
|
+
return sessionId;
|
|
47
|
+
}
|
|
48
|
+
function getDeviceType() {
|
|
49
|
+
if (typeof window === "undefined") return "desktop";
|
|
50
|
+
const ua = navigator.userAgent;
|
|
51
|
+
if (/tablet|ipad|playbook|silk/i.test(ua)) return "tablet";
|
|
52
|
+
if (/mobile|iphone|ipod|android|blackberry|opera mini|iemobile/i.test(ua)) return "mobile";
|
|
53
|
+
return "desktop";
|
|
54
|
+
}
|
|
55
|
+
function getBrowser() {
|
|
56
|
+
if (typeof window === "undefined") return "unknown";
|
|
57
|
+
const ua = navigator.userAgent;
|
|
58
|
+
if (ua.includes("Firefox")) return "Firefox";
|
|
59
|
+
if (ua.includes("Edg")) return "Edge";
|
|
60
|
+
if (ua.includes("Chrome")) return "Chrome";
|
|
61
|
+
if (ua.includes("Safari")) return "Safari";
|
|
62
|
+
return "Other";
|
|
63
|
+
}
|
|
64
|
+
function getOS() {
|
|
65
|
+
if (typeof window === "undefined") return "unknown";
|
|
66
|
+
const ua = navigator.userAgent;
|
|
67
|
+
if (ua.includes("Windows")) return "Windows";
|
|
68
|
+
if (ua.includes("Mac")) return "macOS";
|
|
69
|
+
if (ua.includes("iPhone") || ua.includes("iPad")) return "iOS";
|
|
70
|
+
if (ua.includes("Android")) return "Android";
|
|
71
|
+
if (ua.includes("Linux")) return "Linux";
|
|
72
|
+
return "Other";
|
|
73
|
+
}
|
|
74
|
+
function SignalBridge({
|
|
75
|
+
enabled = true,
|
|
76
|
+
realtime = true,
|
|
77
|
+
experiments = true,
|
|
78
|
+
behaviorTracking = true,
|
|
79
|
+
children
|
|
80
|
+
}) {
|
|
81
|
+
const [config, setConfig] = useState(null);
|
|
82
|
+
const [loading, setLoading] = useState(true);
|
|
83
|
+
const [error, setError] = useState(null);
|
|
84
|
+
const eventSourceRef = useRef(null);
|
|
85
|
+
const eventQueueRef = useRef([]);
|
|
86
|
+
const flushTimeoutRef = useRef(null);
|
|
87
|
+
const assignmentsRef = useRef(/* @__PURE__ */ new Map());
|
|
88
|
+
const pageLoadTimeRef = useRef(Date.now());
|
|
89
|
+
const scrollDepthRef = useRef(0);
|
|
90
|
+
const clickCountRef = useRef(0);
|
|
91
|
+
const { apiUrl, apiKey } = getApiConfig();
|
|
92
|
+
const fetchConfig = useCallback(async () => {
|
|
93
|
+
if (!apiKey || !enabled) {
|
|
94
|
+
setLoading(false);
|
|
95
|
+
return;
|
|
96
|
+
}
|
|
97
|
+
try {
|
|
98
|
+
const response = await fetch(`${apiUrl}/api/public/signal/config`, {
|
|
99
|
+
headers: {
|
|
100
|
+
"x-api-key": apiKey,
|
|
101
|
+
"x-visitor-id": getVisitorId()
|
|
102
|
+
}
|
|
103
|
+
});
|
|
104
|
+
if (!response.ok) {
|
|
105
|
+
throw new Error(`Failed to fetch Signal config: ${response.statusText}`);
|
|
106
|
+
}
|
|
107
|
+
const data = await response.json();
|
|
108
|
+
setConfig(data.config);
|
|
109
|
+
setError(null);
|
|
110
|
+
if (experiments && data.config?.experiments) {
|
|
111
|
+
for (const exp of data.config.experiments) {
|
|
112
|
+
if (exp.status === "running") {
|
|
113
|
+
await loadExperimentAssignment(exp.id);
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
} catch (err) {
|
|
118
|
+
console.error("[Signal] Config fetch error:", err);
|
|
119
|
+
setError(err);
|
|
120
|
+
} finally {
|
|
121
|
+
setLoading(false);
|
|
122
|
+
}
|
|
123
|
+
}, [apiUrl, apiKey, enabled, experiments]);
|
|
124
|
+
const connectSSE = useCallback(() => {
|
|
125
|
+
if (!apiKey || !enabled || !realtime) return;
|
|
126
|
+
if (eventSourceRef.current) {
|
|
127
|
+
eventSourceRef.current.close();
|
|
128
|
+
}
|
|
129
|
+
const url = `${apiUrl}/api/public/signal/stream?key=${apiKey}`;
|
|
130
|
+
const eventSource = new EventSource(url);
|
|
131
|
+
eventSource.addEventListener("config_update", (e) => {
|
|
132
|
+
try {
|
|
133
|
+
const { config: newConfig, version } = JSON.parse(e.data);
|
|
134
|
+
setConfig((prev) => {
|
|
135
|
+
if (prev?.version !== version) {
|
|
136
|
+
console.log("[Signal] Config updated to version:", version);
|
|
137
|
+
return newConfig;
|
|
138
|
+
}
|
|
139
|
+
return prev;
|
|
140
|
+
});
|
|
141
|
+
} catch (err) {
|
|
142
|
+
console.error("[Signal] SSE parse error:", err);
|
|
143
|
+
}
|
|
144
|
+
});
|
|
145
|
+
eventSource.addEventListener("experiment_update", (e) => {
|
|
146
|
+
try {
|
|
147
|
+
const { experiment_id, action } = JSON.parse(e.data);
|
|
148
|
+
if (action === "started" || action === "updated") {
|
|
149
|
+
loadExperimentAssignment(experiment_id);
|
|
150
|
+
} else if (action === "stopped") {
|
|
151
|
+
assignmentsRef.current.delete(experiment_id);
|
|
152
|
+
}
|
|
153
|
+
} catch (err) {
|
|
154
|
+
console.error("[Signal] Experiment update error:", err);
|
|
155
|
+
}
|
|
156
|
+
});
|
|
157
|
+
eventSource.onerror = () => {
|
|
158
|
+
console.warn("[Signal] SSE connection error, reconnecting...");
|
|
159
|
+
eventSource.close();
|
|
160
|
+
setTimeout(connectSSE, 5e3);
|
|
161
|
+
};
|
|
162
|
+
eventSourceRef.current = eventSource;
|
|
163
|
+
}, [apiUrl, apiKey, enabled, realtime]);
|
|
164
|
+
const loadExperimentAssignment = useCallback(async (experimentId) => {
|
|
165
|
+
const storageKey = `_signal_exp_${experimentId}`;
|
|
166
|
+
const stored = localStorage.getItem(storageKey);
|
|
167
|
+
if (stored) {
|
|
168
|
+
try {
|
|
169
|
+
const assignment = JSON.parse(stored);
|
|
170
|
+
if (assignment.expires > Date.now()) {
|
|
171
|
+
assignmentsRef.current.set(experimentId, assignment);
|
|
172
|
+
return assignment;
|
|
173
|
+
}
|
|
174
|
+
} catch {
|
|
175
|
+
}
|
|
176
|
+
}
|
|
177
|
+
try {
|
|
178
|
+
const response = await fetch(`${apiUrl}/api/public/signal/experiment/${experimentId}`, {
|
|
179
|
+
headers: {
|
|
180
|
+
"x-api-key": apiKey,
|
|
181
|
+
"x-visitor-id": getVisitorId()
|
|
182
|
+
}
|
|
183
|
+
});
|
|
184
|
+
if (!response.ok) return null;
|
|
185
|
+
const assignment = await response.json();
|
|
186
|
+
localStorage.setItem(storageKey, JSON.stringify(assignment));
|
|
187
|
+
assignmentsRef.current.set(experimentId, assignment);
|
|
188
|
+
return assignment;
|
|
189
|
+
} catch (err) {
|
|
190
|
+
console.error("[Signal] Experiment assignment error:", err);
|
|
191
|
+
return null;
|
|
192
|
+
}
|
|
193
|
+
}, [apiUrl, apiKey]);
|
|
194
|
+
const getExperiment = useCallback((experimentId) => {
|
|
195
|
+
return assignmentsRef.current.get(experimentId) || null;
|
|
196
|
+
}, []);
|
|
197
|
+
const flushEvents = useCallback(async () => {
|
|
198
|
+
if (eventQueueRef.current.length === 0) return;
|
|
199
|
+
const events = [...eventQueueRef.current];
|
|
200
|
+
eventQueueRef.current = [];
|
|
201
|
+
try {
|
|
202
|
+
await fetch(`${apiUrl}/api/public/signal/events`, {
|
|
203
|
+
method: "POST",
|
|
204
|
+
headers: {
|
|
205
|
+
"Content-Type": "application/json",
|
|
206
|
+
"x-api-key": apiKey
|
|
207
|
+
},
|
|
208
|
+
body: JSON.stringify({
|
|
209
|
+
visitor_id: getVisitorId(),
|
|
210
|
+
session_id: getSessionId(),
|
|
211
|
+
events
|
|
212
|
+
})
|
|
213
|
+
});
|
|
214
|
+
} catch (err) {
|
|
215
|
+
eventQueueRef.current = [...events, ...eventQueueRef.current];
|
|
216
|
+
console.error("[Signal] Event flush error:", err);
|
|
217
|
+
}
|
|
218
|
+
}, [apiUrl, apiKey]);
|
|
219
|
+
const trackEvent = useCallback((event) => {
|
|
220
|
+
if (!enabled || !apiKey) return;
|
|
221
|
+
const enrichedEvent = {
|
|
222
|
+
...event,
|
|
223
|
+
page_url: window.location.href,
|
|
224
|
+
page_path: window.location.pathname,
|
|
225
|
+
referrer: document.referrer,
|
|
226
|
+
device_type: getDeviceType(),
|
|
227
|
+
browser: getBrowser(),
|
|
228
|
+
os: getOS(),
|
|
229
|
+
viewport_width: window.innerWidth,
|
|
230
|
+
viewport_height: window.innerHeight,
|
|
231
|
+
time_on_page: Date.now() - pageLoadTimeRef.current,
|
|
232
|
+
scroll_depth: scrollDepthRef.current,
|
|
233
|
+
click_count: clickCountRef.current,
|
|
234
|
+
experiments: Array.from(assignmentsRef.current.values()).map((a) => ({
|
|
235
|
+
experiment_id: a.experiment_id,
|
|
236
|
+
variant_key: a.variant_key
|
|
237
|
+
})),
|
|
238
|
+
timestamp: (/* @__PURE__ */ new Date()).toISOString()
|
|
239
|
+
};
|
|
240
|
+
eventQueueRef.current.push(enrichedEvent);
|
|
241
|
+
if (flushTimeoutRef.current) {
|
|
242
|
+
clearTimeout(flushTimeoutRef.current);
|
|
243
|
+
}
|
|
244
|
+
flushTimeoutRef.current = setTimeout(flushEvents, 1e3);
|
|
245
|
+
}, [enabled, apiKey, flushEvents]);
|
|
246
|
+
const trackOutcome = useCallback(async (outcome) => {
|
|
247
|
+
if (!enabled || !apiKey) return;
|
|
248
|
+
try {
|
|
249
|
+
await fetch(`${apiUrl}/api/public/signal/outcome`, {
|
|
250
|
+
method: "POST",
|
|
251
|
+
headers: {
|
|
252
|
+
"Content-Type": "application/json",
|
|
253
|
+
"x-api-key": apiKey
|
|
254
|
+
},
|
|
255
|
+
body: JSON.stringify({
|
|
256
|
+
...outcome,
|
|
257
|
+
visitor_id: getVisitorId(),
|
|
258
|
+
session_id: getSessionId(),
|
|
259
|
+
experiments: Array.from(assignmentsRef.current.keys()),
|
|
260
|
+
page_url: window.location.href,
|
|
261
|
+
timestamp: (/* @__PURE__ */ new Date()).toISOString()
|
|
262
|
+
})
|
|
263
|
+
});
|
|
264
|
+
} catch (err) {
|
|
265
|
+
console.error("[Signal] Outcome tracking error:", err);
|
|
266
|
+
}
|
|
267
|
+
}, [apiUrl, apiKey, enabled]);
|
|
268
|
+
useEffect(() => {
|
|
269
|
+
if (!behaviorTracking || typeof window === "undefined") return;
|
|
270
|
+
const handleScroll = () => {
|
|
271
|
+
const scrollTop = window.scrollY;
|
|
272
|
+
const docHeight = document.documentElement.scrollHeight - window.innerHeight;
|
|
273
|
+
const depth = docHeight > 0 ? Math.round(scrollTop / docHeight * 100) : 0;
|
|
274
|
+
scrollDepthRef.current = Math.max(scrollDepthRef.current, depth);
|
|
275
|
+
};
|
|
276
|
+
const handleClick = () => {
|
|
277
|
+
clickCountRef.current++;
|
|
278
|
+
};
|
|
279
|
+
window.addEventListener("scroll", handleScroll, { passive: true });
|
|
280
|
+
window.addEventListener("click", handleClick);
|
|
281
|
+
const handleVisibilityChange = () => {
|
|
282
|
+
if (document.visibilityState === "hidden") {
|
|
283
|
+
flushEvents();
|
|
284
|
+
}
|
|
285
|
+
};
|
|
286
|
+
document.addEventListener("visibilitychange", handleVisibilityChange);
|
|
287
|
+
window.addEventListener("beforeunload", flushEvents);
|
|
288
|
+
return () => {
|
|
289
|
+
window.removeEventListener("scroll", handleScroll);
|
|
290
|
+
window.removeEventListener("click", handleClick);
|
|
291
|
+
document.removeEventListener("visibilitychange", handleVisibilityChange);
|
|
292
|
+
window.removeEventListener("beforeunload", flushEvents);
|
|
293
|
+
};
|
|
294
|
+
}, [behaviorTracking, flushEvents]);
|
|
295
|
+
useEffect(() => {
|
|
296
|
+
fetchConfig();
|
|
297
|
+
}, [fetchConfig]);
|
|
298
|
+
useEffect(() => {
|
|
299
|
+
if (config && realtime) {
|
|
300
|
+
connectSSE();
|
|
301
|
+
}
|
|
302
|
+
return () => {
|
|
303
|
+
if (eventSourceRef.current) {
|
|
304
|
+
eventSourceRef.current.close();
|
|
305
|
+
}
|
|
306
|
+
};
|
|
307
|
+
}, [config, realtime, connectSSE]);
|
|
308
|
+
const contextValue = useMemo(() => ({
|
|
309
|
+
config,
|
|
310
|
+
loading,
|
|
311
|
+
error,
|
|
312
|
+
trackEvent,
|
|
313
|
+
trackOutcome,
|
|
314
|
+
getExperiment,
|
|
315
|
+
refreshConfig: fetchConfig
|
|
316
|
+
}), [config, loading, error, trackEvent, trackOutcome, getExperiment, fetchConfig]);
|
|
317
|
+
return /* @__PURE__ */ jsx(SignalContext.Provider, { value: contextValue, children });
|
|
318
|
+
}
|
|
319
|
+
function useSignalConfig() {
|
|
320
|
+
const { config } = useSignal();
|
|
321
|
+
return config;
|
|
322
|
+
}
|
|
323
|
+
function useSignalEvent() {
|
|
324
|
+
const { trackEvent } = useSignal();
|
|
325
|
+
return trackEvent;
|
|
326
|
+
}
|
|
327
|
+
function useSignalOutcome() {
|
|
328
|
+
const { trackOutcome } = useSignal();
|
|
329
|
+
return { trackOutcome };
|
|
330
|
+
}
|
|
331
|
+
function useSignalExperiment(experimentId) {
|
|
332
|
+
const { getExperiment, config } = useSignal();
|
|
333
|
+
const assignment = getExperiment(experimentId);
|
|
334
|
+
const experiment = config?.experiments?.find((e) => e.id === experimentId);
|
|
335
|
+
const isRunning = experiment?.status === "running";
|
|
336
|
+
return {
|
|
337
|
+
assignment: isRunning ? assignment : null,
|
|
338
|
+
variant: isRunning && assignment ? assignment.variant_key : null,
|
|
339
|
+
isControl: !assignment || assignment.variant_key === "control"
|
|
340
|
+
};
|
|
341
|
+
}
|
|
342
|
+
var SiteKitContext = createContext(null);
|
|
343
|
+
function useSiteKit() {
|
|
344
|
+
const context = useContext(SiteKitContext);
|
|
345
|
+
if (!context) {
|
|
346
|
+
throw new Error("useSiteKit must be used within a SiteKitProvider");
|
|
347
|
+
}
|
|
348
|
+
return context;
|
|
349
|
+
}
|
|
350
|
+
function SiteKitProvider({
|
|
351
|
+
children,
|
|
352
|
+
apiKey,
|
|
353
|
+
apiUrl,
|
|
354
|
+
signalUrl,
|
|
355
|
+
analytics,
|
|
356
|
+
engage,
|
|
357
|
+
forms,
|
|
358
|
+
signal,
|
|
359
|
+
debug = false
|
|
360
|
+
}) {
|
|
361
|
+
const finalApiUrl = apiUrl || "https://api.uptrademedia.com";
|
|
362
|
+
const finalSignalUrl = signalUrl || "https://signal.uptrademedia.com";
|
|
363
|
+
if (!apiKey) {
|
|
364
|
+
console.error("@uptrade/site-kit: No API key provided. Set NEXT_PUBLIC_UPTRADE_API_KEY environment variable.");
|
|
365
|
+
}
|
|
366
|
+
useEffect(() => {
|
|
367
|
+
if (typeof window !== "undefined") {
|
|
368
|
+
window.__SITE_KIT_API_URL__ = finalApiUrl;
|
|
369
|
+
window.__SITE_KIT_SIGNAL_URL__ = finalSignalUrl;
|
|
370
|
+
window.__SITE_KIT_API_KEY__ = apiKey;
|
|
371
|
+
window.__SITE_KIT_DEBUG__ = debug;
|
|
372
|
+
}
|
|
373
|
+
if (apiKey) {
|
|
374
|
+
configureFormsApi({
|
|
375
|
+
baseUrl: finalApiUrl,
|
|
376
|
+
apiKey
|
|
377
|
+
});
|
|
378
|
+
}
|
|
379
|
+
}, [finalApiUrl, finalSignalUrl, apiKey, debug]);
|
|
380
|
+
const contextValue = useMemo(
|
|
381
|
+
() => ({
|
|
382
|
+
apiUrl: finalApiUrl,
|
|
383
|
+
signalUrl: finalSignalUrl,
|
|
384
|
+
apiKey,
|
|
385
|
+
analytics,
|
|
386
|
+
engage,
|
|
387
|
+
forms,
|
|
388
|
+
signal,
|
|
389
|
+
debug,
|
|
390
|
+
isReady: true
|
|
391
|
+
}),
|
|
392
|
+
[finalApiUrl, finalSignalUrl, apiKey, analytics, engage, forms, signal, debug]
|
|
393
|
+
);
|
|
394
|
+
let content = /* @__PURE__ */ jsx(Fragment, { children });
|
|
395
|
+
if (signal?.enabled) {
|
|
396
|
+
content = /* @__PURE__ */ jsx(
|
|
397
|
+
SignalBridge,
|
|
398
|
+
{
|
|
399
|
+
enabled: signal.enabled,
|
|
400
|
+
realtime: signal.realtime !== false,
|
|
401
|
+
experiments: signal.experiments !== false,
|
|
402
|
+
behaviorTracking: signal.behaviorTracking !== false,
|
|
403
|
+
children: content
|
|
404
|
+
}
|
|
405
|
+
);
|
|
406
|
+
}
|
|
407
|
+
if (analytics?.enabled) {
|
|
408
|
+
content = /* @__PURE__ */ jsx(Suspense, { fallback: null, children: /* @__PURE__ */ jsx(
|
|
409
|
+
AnalyticsProvider,
|
|
410
|
+
{
|
|
411
|
+
apiUrl: finalApiUrl,
|
|
412
|
+
apiKey,
|
|
413
|
+
trackPageViews: analytics.trackPageViews !== false,
|
|
414
|
+
trackWebVitals: analytics.trackWebVitals !== false,
|
|
415
|
+
trackScrollDepth: analytics.trackScrollDepth !== false,
|
|
416
|
+
trackClicks: analytics.trackClicks !== false,
|
|
417
|
+
debug,
|
|
418
|
+
children: content
|
|
419
|
+
}
|
|
420
|
+
) });
|
|
421
|
+
}
|
|
422
|
+
if (engage?.enabled) {
|
|
423
|
+
content = /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
424
|
+
content,
|
|
425
|
+
/* @__PURE__ */ jsx(
|
|
426
|
+
EngageWidget,
|
|
427
|
+
{
|
|
428
|
+
apiUrl: finalApiUrl,
|
|
429
|
+
apiKey,
|
|
430
|
+
position: engage.position || "bottom-right",
|
|
431
|
+
chatEnabled: engage.chatEnabled !== false
|
|
432
|
+
}
|
|
433
|
+
)
|
|
434
|
+
] });
|
|
435
|
+
}
|
|
436
|
+
content = /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
437
|
+
content,
|
|
438
|
+
/* @__PURE__ */ jsx(SitemapSync, { debug })
|
|
439
|
+
] });
|
|
440
|
+
return /* @__PURE__ */ jsx(SiteKitContext.Provider, { value: contextValue, children: content });
|
|
441
|
+
}
|
|
442
|
+
|
|
443
|
+
// src/affiliates/api.ts
|
|
444
|
+
function getApiConfig2() {
|
|
18
445
|
const apiUrl = typeof window !== "undefined" ? window.__SITE_KIT_API_URL__ || "https://api.uptrademedia.com" : "https://api.uptrademedia.com";
|
|
19
446
|
const apiKey = typeof window !== "undefined" ? window.__SITE_KIT_API_KEY__ || "" : "";
|
|
20
447
|
return { apiUrl, apiKey };
|
|
21
448
|
}
|
|
22
449
|
async function apiGet(endpoint) {
|
|
23
|
-
const { apiUrl, apiKey } =
|
|
450
|
+
const { apiUrl, apiKey } = getApiConfig2();
|
|
24
451
|
if (!apiKey) {
|
|
25
452
|
console.error("[Affiliates] No API key configured");
|
|
26
453
|
return null;
|
|
@@ -49,7 +476,7 @@ async function fetchAffiliates(options = {}) {
|
|
|
49
476
|
return result?.affiliates || [];
|
|
50
477
|
}
|
|
51
478
|
function getTrackingUrl(affiliateId, offerId) {
|
|
52
|
-
const { apiUrl } =
|
|
479
|
+
const { apiUrl } = getApiConfig2();
|
|
53
480
|
return `${apiUrl}/a/${affiliateId}/${offerId}`;
|
|
54
481
|
}
|
|
55
482
|
function useAffiliates() {
|
|
@@ -210,7 +637,7 @@ function ExperimentConversion({
|
|
|
210
637
|
}
|
|
211
638
|
});
|
|
212
639
|
};
|
|
213
|
-
return
|
|
640
|
+
return React3.cloneElement(children, {
|
|
214
641
|
onClick: (e) => {
|
|
215
642
|
handleInteraction();
|
|
216
643
|
if (children.props.onClick) {
|
|
@@ -1227,7 +1654,7 @@ Let me help you with that. What would you like to do?`,
|
|
|
1227
1654
|
...styles.bubble,
|
|
1228
1655
|
...message.role === "assistant" ? styles.bubbleAssistant : styles.bubbleUser
|
|
1229
1656
|
},
|
|
1230
|
-
children: message.content.split("\n").map((line, i) => /* @__PURE__ */ jsxs(
|
|
1657
|
+
children: message.content.split("\n").map((line, i) => /* @__PURE__ */ jsxs(React3.Fragment, { children: [
|
|
1231
1658
|
line,
|
|
1232
1659
|
i < message.content.split("\n").length - 1 && /* @__PURE__ */ jsx("br", {})
|
|
1233
1660
|
] }, i))
|
|
@@ -2196,6 +2623,6 @@ function BookingWidget({
|
|
|
2196
2623
|
);
|
|
2197
2624
|
}
|
|
2198
2625
|
|
|
2199
|
-
export { AffiliateCard, AffiliatesWidget, BookingWidget, ExperimentConversion, SetupAssistant, SignalExperiment, createBooking, createSlotHold, detectTimezone, fetchAffiliates, fetchAvailability, fetchAvailableDates, fetchBookingTypeDetails, fetchBookingTypes, formatDate2 as formatBookingDate, formatTime as formatBookingTime, formatDuration, getTrackingUrl, releaseSlotHold, useAffiliates, useExperimentVariant };
|
|
2626
|
+
export { AffiliateCard, AffiliatesWidget, BookingWidget, ExperimentConversion, SetupAssistant, SignalBridge, SignalExperiment, SiteKitProvider, createBooking, createSlotHold, detectTimezone, fetchAffiliates, fetchAvailability, fetchAvailableDates, fetchBookingTypeDetails, fetchBookingTypes, formatDate2 as formatBookingDate, formatTime as formatBookingTime, formatDuration, getTrackingUrl, releaseSlotHold, useAffiliates, useExperimentVariant, useSignal, useSignalConfig, useSignalEvent, useSignalExperiment, useSignalOutcome, useSiteKit };
|
|
2200
2627
|
//# sourceMappingURL=index.mjs.map
|
|
2201
2628
|
//# sourceMappingURL=index.mjs.map
|