@depup/base44__sdk 0.8.22-depup.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/LICENSE +21 -0
- package/README.md +32 -0
- package/changes.json +14 -0
- package/dist/client.d.ts +96 -0
- package/dist/client.js +375 -0
- package/dist/client.types.d.ts +144 -0
- package/dist/client.types.js +1 -0
- package/dist/index.d.ts +16 -0
- package/dist/index.js +5 -0
- package/dist/modules/agents.d.ts +2 -0
- package/dist/modules/agents.js +77 -0
- package/dist/modules/agents.types.d.ts +377 -0
- package/dist/modules/agents.types.js +1 -0
- package/dist/modules/analytics.d.ts +20 -0
- package/dist/modules/analytics.js +277 -0
- package/dist/modules/analytics.types.d.ts +122 -0
- package/dist/modules/analytics.types.js +1 -0
- package/dist/modules/app-logs.d.ts +11 -0
- package/dist/modules/app-logs.js +27 -0
- package/dist/modules/app-logs.types.d.ts +46 -0
- package/dist/modules/app-logs.types.js +1 -0
- package/dist/modules/app.types.d.ts +142 -0
- package/dist/modules/app.types.js +1 -0
- package/dist/modules/auth.d.ts +13 -0
- package/dist/modules/auth.js +180 -0
- package/dist/modules/auth.types.d.ts +481 -0
- package/dist/modules/auth.types.js +1 -0
- package/dist/modules/connectors.d.ts +20 -0
- package/dist/modules/connectors.js +71 -0
- package/dist/modules/connectors.types.d.ts +296 -0
- package/dist/modules/connectors.types.js +1 -0
- package/dist/modules/custom-integrations.d.ts +11 -0
- package/dist/modules/custom-integrations.js +32 -0
- package/dist/modules/custom-integrations.types.d.ts +89 -0
- package/dist/modules/custom-integrations.types.js +1 -0
- package/dist/modules/entities.d.ts +20 -0
- package/dist/modules/entities.js +149 -0
- package/dist/modules/entities.types.d.ts +552 -0
- package/dist/modules/entities.types.js +1 -0
- package/dist/modules/functions.d.ts +12 -0
- package/dist/modules/functions.js +79 -0
- package/dist/modules/functions.types.d.ts +103 -0
- package/dist/modules/functions.types.js +1 -0
- package/dist/modules/integrations.d.ts +11 -0
- package/dist/modules/integrations.js +77 -0
- package/dist/modules/integrations.types.d.ts +413 -0
- package/dist/modules/integrations.types.js +1 -0
- package/dist/modules/sso.d.ts +12 -0
- package/dist/modules/sso.js +23 -0
- package/dist/modules/sso.types.d.ts +44 -0
- package/dist/modules/sso.types.js +1 -0
- package/dist/modules/types.d.ts +4 -0
- package/dist/modules/types.js +4 -0
- package/dist/modules/users.d.ts +16 -0
- package/dist/modules/users.js +23 -0
- package/dist/types.d.ts +72 -0
- package/dist/types.js +1 -0
- package/dist/utils/auth-utils.d.ts +117 -0
- package/dist/utils/auth-utils.js +189 -0
- package/dist/utils/auth-utils.types.d.ts +146 -0
- package/dist/utils/auth-utils.types.js +1 -0
- package/dist/utils/axios-client.d.ts +100 -0
- package/dist/utils/axios-client.js +193 -0
- package/dist/utils/axios-client.types.d.ts +28 -0
- package/dist/utils/axios-client.types.js +1 -0
- package/dist/utils/common.d.ts +3 -0
- package/dist/utils/common.js +6 -0
- package/dist/utils/sharedInstance.d.ts +1 -0
- package/dist/utils/sharedInstance.js +15 -0
- package/dist/utils/socket-utils.d.ts +47 -0
- package/dist/utils/socket-utils.js +115 -0
- package/package.json +87 -0
|
@@ -0,0 +1,277 @@
|
|
|
1
|
+
import { getSharedInstance } from "../utils/sharedInstance.js";
|
|
2
|
+
import { generateUuid } from "../utils/common.js";
|
|
3
|
+
export const USER_HEARTBEAT_EVENT_NAME = "__user_heartbeat_event__";
|
|
4
|
+
export const ANALYTICS_INITIALIZATION_EVENT_NAME = "__initialization_event__";
|
|
5
|
+
export const ANALYTICS_SESSION_DURATION_EVENT_NAME = "__session_duration_event__";
|
|
6
|
+
export const ANALYTICS_CONFIG_ENABLE_URL_PARAM_KEY = "analytics-enable";
|
|
7
|
+
export const ANALYTICS_SESSION_ID_LOCAL_STORAGE_KEY = "base44_analytics_session_id";
|
|
8
|
+
const defaultConfiguration = {
|
|
9
|
+
// default to enabled //
|
|
10
|
+
enabled: true,
|
|
11
|
+
maxQueueSize: 1000,
|
|
12
|
+
throttleTime: 1000,
|
|
13
|
+
batchSize: 30,
|
|
14
|
+
heartBeatInterval: 60 * 1000,
|
|
15
|
+
};
|
|
16
|
+
///////////////////////////////////////////////
|
|
17
|
+
//// shared queue for analytics events ////
|
|
18
|
+
///////////////////////////////////////////////
|
|
19
|
+
const ANALYTICS_SHARED_STATE_NAME = "analytics";
|
|
20
|
+
// shared state//
|
|
21
|
+
const analyticsSharedState = getSharedInstance(ANALYTICS_SHARED_STATE_NAME, () => ({
|
|
22
|
+
requestsQueue: [],
|
|
23
|
+
isProcessing: false,
|
|
24
|
+
isHeartBeatProcessing: false,
|
|
25
|
+
wasInitializationTracked: false,
|
|
26
|
+
sessionContext: null,
|
|
27
|
+
sessionStartTime: null,
|
|
28
|
+
config: {
|
|
29
|
+
...defaultConfiguration,
|
|
30
|
+
...getAnalyticsConfigFromUrlParams(),
|
|
31
|
+
},
|
|
32
|
+
}));
|
|
33
|
+
export const createAnalyticsModule = ({ axiosClient, serverUrl, appId, userAuthModule, }) => {
|
|
34
|
+
var _a;
|
|
35
|
+
// prevent overflow of events //
|
|
36
|
+
const { maxQueueSize, throttleTime, batchSize } = analyticsSharedState.config;
|
|
37
|
+
if (!((_a = analyticsSharedState.config) === null || _a === void 0 ? void 0 : _a.enabled)) {
|
|
38
|
+
return {
|
|
39
|
+
track: () => { },
|
|
40
|
+
cleanup: () => { },
|
|
41
|
+
};
|
|
42
|
+
}
|
|
43
|
+
let clearHeartBeatProcessor = undefined;
|
|
44
|
+
const trackBatchUrl = `${serverUrl}/api/apps/${appId}/analytics/track/batch`;
|
|
45
|
+
const batchRequestFallback = async (events) => {
|
|
46
|
+
await axiosClient.request({
|
|
47
|
+
method: "POST",
|
|
48
|
+
url: `/apps/${appId}/analytics/track/batch`,
|
|
49
|
+
data: { events },
|
|
50
|
+
});
|
|
51
|
+
};
|
|
52
|
+
// currently disabled, until fully tested //
|
|
53
|
+
const beaconRequest = (events) => {
|
|
54
|
+
try {
|
|
55
|
+
const beaconPayload = JSON.stringify({ events });
|
|
56
|
+
const blob = new Blob([beaconPayload], { type: "application/json" });
|
|
57
|
+
return (typeof navigator === "undefined" ||
|
|
58
|
+
beaconPayload.length > 60000 ||
|
|
59
|
+
!navigator.sendBeacon(trackBatchUrl, blob));
|
|
60
|
+
}
|
|
61
|
+
catch (_a) {
|
|
62
|
+
return false;
|
|
63
|
+
}
|
|
64
|
+
};
|
|
65
|
+
const flush = async (eventsData, options = {}) => {
|
|
66
|
+
if (eventsData.length === 0)
|
|
67
|
+
return;
|
|
68
|
+
const sessionContext_ = await getSessionContext(userAuthModule);
|
|
69
|
+
const events = eventsData.map(transformEventDataToApiRequestData(sessionContext_));
|
|
70
|
+
try {
|
|
71
|
+
if (!options.isBeacon || !beaconRequest(events)) {
|
|
72
|
+
await batchRequestFallback(events);
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
catch (_a) {
|
|
76
|
+
// do nothing
|
|
77
|
+
}
|
|
78
|
+
};
|
|
79
|
+
const startProcessing = () => {
|
|
80
|
+
startAnalyticsProcessor(flush, {
|
|
81
|
+
throttleTime,
|
|
82
|
+
batchSize,
|
|
83
|
+
});
|
|
84
|
+
};
|
|
85
|
+
const track = (params) => {
|
|
86
|
+
if (analyticsSharedState.requestsQueue.length >= maxQueueSize) {
|
|
87
|
+
return;
|
|
88
|
+
}
|
|
89
|
+
const intrinsicData = getEventIntrinsicData();
|
|
90
|
+
analyticsSharedState.requestsQueue.push({
|
|
91
|
+
...params,
|
|
92
|
+
...intrinsicData,
|
|
93
|
+
});
|
|
94
|
+
startProcessing();
|
|
95
|
+
};
|
|
96
|
+
const onDocVisible = () => {
|
|
97
|
+
startAnalyticsProcessor(flush, {
|
|
98
|
+
throttleTime,
|
|
99
|
+
batchSize,
|
|
100
|
+
});
|
|
101
|
+
clearHeartBeatProcessor = startHeartBeatProcessor(track);
|
|
102
|
+
setSessionDurationTimerStart();
|
|
103
|
+
};
|
|
104
|
+
const onDocHidden = () => {
|
|
105
|
+
stopAnalyticsProcessor();
|
|
106
|
+
clearHeartBeatProcessor === null || clearHeartBeatProcessor === void 0 ? void 0 : clearHeartBeatProcessor();
|
|
107
|
+
trackSessionDurationEvent(track);
|
|
108
|
+
// flush entire queue on visibility change and hope for the best //
|
|
109
|
+
const eventsData = analyticsSharedState.requestsQueue.splice(0);
|
|
110
|
+
flush(eventsData, { isBeacon: true });
|
|
111
|
+
};
|
|
112
|
+
const onVisibilityChange = () => {
|
|
113
|
+
if (typeof window === "undefined")
|
|
114
|
+
return;
|
|
115
|
+
if (document.visibilityState === "hidden") {
|
|
116
|
+
onDocHidden();
|
|
117
|
+
}
|
|
118
|
+
else if (document.visibilityState === "visible") {
|
|
119
|
+
onDocVisible();
|
|
120
|
+
}
|
|
121
|
+
};
|
|
122
|
+
const cleanup = () => {
|
|
123
|
+
stopAnalyticsProcessor();
|
|
124
|
+
clearHeartBeatProcessor === null || clearHeartBeatProcessor === void 0 ? void 0 : clearHeartBeatProcessor();
|
|
125
|
+
if (typeof window !== "undefined") {
|
|
126
|
+
window.removeEventListener("visibilitychange", onVisibilityChange);
|
|
127
|
+
}
|
|
128
|
+
};
|
|
129
|
+
// start the flusing process ///
|
|
130
|
+
startProcessing();
|
|
131
|
+
// start the heart beat processor //
|
|
132
|
+
clearHeartBeatProcessor = startHeartBeatProcessor(track);
|
|
133
|
+
// track the referrer event //
|
|
134
|
+
trackInitializationEvent(track);
|
|
135
|
+
// start the visibility change listener //
|
|
136
|
+
if (typeof window !== "undefined") {
|
|
137
|
+
window.addEventListener("visibilitychange", onVisibilityChange);
|
|
138
|
+
}
|
|
139
|
+
return {
|
|
140
|
+
track,
|
|
141
|
+
cleanup,
|
|
142
|
+
};
|
|
143
|
+
};
|
|
144
|
+
function stopAnalyticsProcessor() {
|
|
145
|
+
analyticsSharedState.isProcessing = false;
|
|
146
|
+
}
|
|
147
|
+
async function startAnalyticsProcessor(handleTrack, options) {
|
|
148
|
+
if (analyticsSharedState.isProcessing) {
|
|
149
|
+
// only one instance of the analytics processor can be running at a time //
|
|
150
|
+
return;
|
|
151
|
+
}
|
|
152
|
+
analyticsSharedState.isProcessing = true;
|
|
153
|
+
const { throttleTime = 1000, batchSize = 30 } = options !== null && options !== void 0 ? options : {};
|
|
154
|
+
while (analyticsSharedState.isProcessing &&
|
|
155
|
+
analyticsSharedState.requestsQueue.length > 0) {
|
|
156
|
+
const requests = analyticsSharedState.requestsQueue.splice(0, batchSize);
|
|
157
|
+
requests.length && (await handleTrack(requests));
|
|
158
|
+
await new Promise((resolve) => setTimeout(resolve, throttleTime));
|
|
159
|
+
}
|
|
160
|
+
analyticsSharedState.isProcessing = false;
|
|
161
|
+
}
|
|
162
|
+
function startHeartBeatProcessor(track) {
|
|
163
|
+
var _a;
|
|
164
|
+
if (analyticsSharedState.isHeartBeatProcessing ||
|
|
165
|
+
((_a = analyticsSharedState.config.heartBeatInterval) !== null && _a !== void 0 ? _a : 0) < 10) {
|
|
166
|
+
return () => { };
|
|
167
|
+
}
|
|
168
|
+
analyticsSharedState.isHeartBeatProcessing = true;
|
|
169
|
+
const interval = setInterval(() => {
|
|
170
|
+
track({ eventName: USER_HEARTBEAT_EVENT_NAME });
|
|
171
|
+
}, analyticsSharedState.config.heartBeatInterval);
|
|
172
|
+
return () => {
|
|
173
|
+
clearInterval(interval);
|
|
174
|
+
analyticsSharedState.isHeartBeatProcessing = false;
|
|
175
|
+
};
|
|
176
|
+
}
|
|
177
|
+
function trackInitializationEvent(track) {
|
|
178
|
+
if (typeof window === "undefined" ||
|
|
179
|
+
analyticsSharedState.wasInitializationTracked) {
|
|
180
|
+
return;
|
|
181
|
+
}
|
|
182
|
+
analyticsSharedState.wasInitializationTracked = true;
|
|
183
|
+
track({
|
|
184
|
+
eventName: ANALYTICS_INITIALIZATION_EVENT_NAME,
|
|
185
|
+
properties: {
|
|
186
|
+
referrer: document === null || document === void 0 ? void 0 : document.referrer,
|
|
187
|
+
},
|
|
188
|
+
});
|
|
189
|
+
}
|
|
190
|
+
function setSessionDurationTimerStart() {
|
|
191
|
+
if (typeof window === "undefined" ||
|
|
192
|
+
analyticsSharedState.sessionStartTime !== null) {
|
|
193
|
+
return;
|
|
194
|
+
}
|
|
195
|
+
analyticsSharedState.sessionStartTime = new Date().toISOString();
|
|
196
|
+
}
|
|
197
|
+
function trackSessionDurationEvent(track) {
|
|
198
|
+
if (typeof window === "undefined" ||
|
|
199
|
+
analyticsSharedState.sessionStartTime === null)
|
|
200
|
+
return;
|
|
201
|
+
const sessionDuration = new Date().getTime() -
|
|
202
|
+
new Date(analyticsSharedState.sessionStartTime).getTime();
|
|
203
|
+
analyticsSharedState.sessionStartTime = null;
|
|
204
|
+
track({
|
|
205
|
+
eventName: ANALYTICS_SESSION_DURATION_EVENT_NAME,
|
|
206
|
+
properties: { sessionDuration },
|
|
207
|
+
});
|
|
208
|
+
}
|
|
209
|
+
function getEventIntrinsicData() {
|
|
210
|
+
return {
|
|
211
|
+
timestamp: new Date().toISOString(),
|
|
212
|
+
pageUrl: typeof window !== "undefined" ? window.location.pathname : null,
|
|
213
|
+
};
|
|
214
|
+
}
|
|
215
|
+
function transformEventDataToApiRequestData(sessionContext) {
|
|
216
|
+
return (eventData) => ({
|
|
217
|
+
event_name: eventData.eventName,
|
|
218
|
+
properties: eventData.properties,
|
|
219
|
+
timestamp: eventData.timestamp,
|
|
220
|
+
page_url: eventData.pageUrl,
|
|
221
|
+
...sessionContext,
|
|
222
|
+
});
|
|
223
|
+
}
|
|
224
|
+
let sessionContextPromise = null;
|
|
225
|
+
async function getSessionContext(userAuthModule) {
|
|
226
|
+
if (!analyticsSharedState.sessionContext) {
|
|
227
|
+
if (!sessionContextPromise) {
|
|
228
|
+
const sessionId = getAnalyticsSessionId();
|
|
229
|
+
sessionContextPromise = userAuthModule
|
|
230
|
+
.me()
|
|
231
|
+
.then((user) => ({
|
|
232
|
+
user_id: user.id,
|
|
233
|
+
session_id: sessionId,
|
|
234
|
+
}))
|
|
235
|
+
.catch(() => ({
|
|
236
|
+
user_id: null,
|
|
237
|
+
session_id: sessionId,
|
|
238
|
+
}));
|
|
239
|
+
}
|
|
240
|
+
analyticsSharedState.sessionContext = await sessionContextPromise;
|
|
241
|
+
}
|
|
242
|
+
return analyticsSharedState.sessionContext;
|
|
243
|
+
}
|
|
244
|
+
export function getAnalyticsConfigFromUrlParams() {
|
|
245
|
+
if (typeof window === "undefined")
|
|
246
|
+
return undefined;
|
|
247
|
+
const urlParams = new URLSearchParams(window.location.search);
|
|
248
|
+
const analyticsEnable = urlParams.get(ANALYTICS_CONFIG_ENABLE_URL_PARAM_KEY);
|
|
249
|
+
// if the url param is not set, return undefined //
|
|
250
|
+
if (analyticsEnable == null || !analyticsEnable.length)
|
|
251
|
+
return undefined;
|
|
252
|
+
// remove the url param from the url //
|
|
253
|
+
const newUrlParams = new URLSearchParams(window.location.search);
|
|
254
|
+
newUrlParams.delete(ANALYTICS_CONFIG_ENABLE_URL_PARAM_KEY);
|
|
255
|
+
const newUrl = window.location.pathname +
|
|
256
|
+
(newUrlParams.toString() ? "?" + newUrlParams.toString() : "");
|
|
257
|
+
window.history.replaceState({}, "", newUrl);
|
|
258
|
+
// return the config object //
|
|
259
|
+
return { enabled: analyticsEnable === "true" };
|
|
260
|
+
}
|
|
261
|
+
export function getAnalyticsSessionId() {
|
|
262
|
+
if (typeof window === "undefined") {
|
|
263
|
+
return generateUuid();
|
|
264
|
+
}
|
|
265
|
+
try {
|
|
266
|
+
const sessionId = localStorage.getItem(ANALYTICS_SESSION_ID_LOCAL_STORAGE_KEY);
|
|
267
|
+
if (!sessionId) {
|
|
268
|
+
const newSessionId = generateUuid();
|
|
269
|
+
localStorage.setItem(ANALYTICS_SESSION_ID_LOCAL_STORAGE_KEY, newSessionId);
|
|
270
|
+
return newSessionId;
|
|
271
|
+
}
|
|
272
|
+
return sessionId;
|
|
273
|
+
}
|
|
274
|
+
catch (_a) {
|
|
275
|
+
return generateUuid();
|
|
276
|
+
}
|
|
277
|
+
}
|
|
@@ -0,0 +1,122 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Properties for analytics events.
|
|
3
|
+
*
|
|
4
|
+
* Key-value pairs with additional event data. Values can be strings, numbers, booleans, or null.
|
|
5
|
+
*/
|
|
6
|
+
export type TrackEventProperties = {
|
|
7
|
+
[key: string]: string | number | boolean | null | undefined;
|
|
8
|
+
};
|
|
9
|
+
/**
|
|
10
|
+
* Parameters for tracking an analytics event.
|
|
11
|
+
*/
|
|
12
|
+
export type TrackEventParams = {
|
|
13
|
+
/**
|
|
14
|
+
* Name of the event to track.
|
|
15
|
+
*
|
|
16
|
+
* Use descriptive names like `button_click`, `form_submit`, or `purchase_completed`.
|
|
17
|
+
*/
|
|
18
|
+
eventName: string;
|
|
19
|
+
/**
|
|
20
|
+
* Optional key-value pairs with additional event data.
|
|
21
|
+
*
|
|
22
|
+
* Values can be strings, numbers, booleans, or null.
|
|
23
|
+
*
|
|
24
|
+
* @example
|
|
25
|
+
* ```typescript
|
|
26
|
+
* base44.analytics.track({
|
|
27
|
+
* eventName: 'add_to_cart',
|
|
28
|
+
* properties: {
|
|
29
|
+
* product_id: 'prod_123',
|
|
30
|
+
* price: 29.99,
|
|
31
|
+
* quantity: 2
|
|
32
|
+
* }
|
|
33
|
+
* });
|
|
34
|
+
* ```
|
|
35
|
+
*/
|
|
36
|
+
properties?: TrackEventProperties;
|
|
37
|
+
};
|
|
38
|
+
export type TrackEventIntrinsicData = {
|
|
39
|
+
timestamp: string;
|
|
40
|
+
pageUrl?: string | null;
|
|
41
|
+
};
|
|
42
|
+
export type TrackEventData = {
|
|
43
|
+
properties?: TrackEventProperties;
|
|
44
|
+
eventName: string;
|
|
45
|
+
} & TrackEventIntrinsicData;
|
|
46
|
+
export type SessionContext = {
|
|
47
|
+
user_id?: string | null;
|
|
48
|
+
session_id?: string | null;
|
|
49
|
+
};
|
|
50
|
+
export type AnalyticsApiRequestData = {
|
|
51
|
+
event_name: string;
|
|
52
|
+
properties?: TrackEventProperties;
|
|
53
|
+
timestamp?: string;
|
|
54
|
+
page_url?: string | null;
|
|
55
|
+
} & SessionContext;
|
|
56
|
+
export type AnalyticsApiBatchRequest = {
|
|
57
|
+
method: "POST";
|
|
58
|
+
url: `/apps/${string}/analytics/track/batch`;
|
|
59
|
+
data: {
|
|
60
|
+
events: AnalyticsApiRequestData[];
|
|
61
|
+
};
|
|
62
|
+
};
|
|
63
|
+
export type AnalyticsModuleOptions = {
|
|
64
|
+
enabled?: boolean;
|
|
65
|
+
maxQueueSize?: number;
|
|
66
|
+
throttleTime?: number;
|
|
67
|
+
batchSize?: number;
|
|
68
|
+
heartBeatInterval?: number;
|
|
69
|
+
};
|
|
70
|
+
/**
|
|
71
|
+
* Analytics module for tracking custom events in your app.
|
|
72
|
+
*
|
|
73
|
+
* Use this module to track specific user actions. Track things like button clicks, form submissions, purchases, and feature usage.
|
|
74
|
+
*
|
|
75
|
+
* <Note> Analytics events tracked with this module appear as custom event cards in the [Analytics dashboard](/documentation/performance-and-seo/app-analytics).</Note>
|
|
76
|
+
*
|
|
77
|
+
* ## Best Practices
|
|
78
|
+
*
|
|
79
|
+
* When tracking events:
|
|
80
|
+
*
|
|
81
|
+
* - Choose clear, descriptive event names in snake_case like `signup_button_click` or `purchase_completed` rather than generic names like `click`.
|
|
82
|
+
* - Include relevant context in your properties such as identifiers like `product_id`, measurements like `price`, and flags like `is_first_purchase`.
|
|
83
|
+
*
|
|
84
|
+
* ## Authentication Modes
|
|
85
|
+
*
|
|
86
|
+
* This module is only available in user authentication mode (`base44.analytics`).
|
|
87
|
+
*/
|
|
88
|
+
export interface AnalyticsModule {
|
|
89
|
+
/**
|
|
90
|
+
* Tracks a custom event that appears as a card in your Analytics dashboard.
|
|
91
|
+
*
|
|
92
|
+
* Each unique event name becomes its own card showing total count and trends over time. This method returns immediately and events are sent in batches in the background.
|
|
93
|
+
*
|
|
94
|
+
* @param params - Event parameters.
|
|
95
|
+
* @param params.eventName - Name of the event. This becomes the card title in your dashboard. Use descriptive names like `'signup_button_click'` or `'purchase_completed'`.
|
|
96
|
+
* @param params.properties - Optional data to attach to the event. You can filter and analyze events by these properties in the dashboard.
|
|
97
|
+
*
|
|
98
|
+
* @example Track a button click
|
|
99
|
+
* ```typescript
|
|
100
|
+
* // Track a button click
|
|
101
|
+
* base44.analytics.track({
|
|
102
|
+
* eventName: 'signup_button_click'
|
|
103
|
+
* });
|
|
104
|
+
* ```
|
|
105
|
+
*
|
|
106
|
+
* @example Track with properties
|
|
107
|
+
* ```typescript
|
|
108
|
+
* // Track with properties
|
|
109
|
+
* base44.analytics.track({
|
|
110
|
+
* eventName: 'add_to_cart',
|
|
111
|
+
* properties: {
|
|
112
|
+
* product_id: 'prod_123',
|
|
113
|
+
* product_name: 'Premium Widget',
|
|
114
|
+
* price: 29.99,
|
|
115
|
+
* quantity: 2,
|
|
116
|
+
* is_first_purchase: true
|
|
117
|
+
* }
|
|
118
|
+
* });
|
|
119
|
+
* ```
|
|
120
|
+
*/
|
|
121
|
+
track(params: TrackEventParams): void;
|
|
122
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { AxiosInstance } from "axios";
|
|
2
|
+
import { AppLogsModule } from "./app-logs.types";
|
|
3
|
+
/**
|
|
4
|
+
* Creates the app logs module for the Base44 SDK.
|
|
5
|
+
*
|
|
6
|
+
* @param axios - Axios instance
|
|
7
|
+
* @param appId - Application ID
|
|
8
|
+
* @returns App logs module with methods for tracking and analyzing app usage
|
|
9
|
+
* @internal
|
|
10
|
+
*/
|
|
11
|
+
export declare function createAppLogsModule(axios: AxiosInstance, appId: string): AppLogsModule;
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Creates the app logs module for the Base44 SDK.
|
|
3
|
+
*
|
|
4
|
+
* @param axios - Axios instance
|
|
5
|
+
* @param appId - Application ID
|
|
6
|
+
* @returns App logs module with methods for tracking and analyzing app usage
|
|
7
|
+
* @internal
|
|
8
|
+
*/
|
|
9
|
+
export function createAppLogsModule(axios, appId) {
|
|
10
|
+
const baseURL = `/app-logs/${appId}`;
|
|
11
|
+
return {
|
|
12
|
+
// Log user activity in the app
|
|
13
|
+
async logUserInApp(pageName) {
|
|
14
|
+
await axios.post(`${baseURL}/log-user-in-app/${pageName}`);
|
|
15
|
+
},
|
|
16
|
+
// Fetch app logs with optional parameters
|
|
17
|
+
async fetchLogs(params = {}) {
|
|
18
|
+
const response = await axios.get(baseURL, { params });
|
|
19
|
+
return response;
|
|
20
|
+
},
|
|
21
|
+
// Get app statistics
|
|
22
|
+
async getStats(params = {}) {
|
|
23
|
+
const response = await axios.get(`${baseURL}/stats`, { params });
|
|
24
|
+
return response;
|
|
25
|
+
},
|
|
26
|
+
};
|
|
27
|
+
}
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* App Logs module for tracking and analyzing app usage.
|
|
3
|
+
*
|
|
4
|
+
* This module provides a method to log user activity. The logs are reflected in the Analytics page in the app dashboard.
|
|
5
|
+
*
|
|
6
|
+
* ## Authentication Modes
|
|
7
|
+
*
|
|
8
|
+
* This module is available to use with a client in all authentication modes.
|
|
9
|
+
*/
|
|
10
|
+
export interface AppLogsModule {
|
|
11
|
+
/**
|
|
12
|
+
* Log user activity in the app.
|
|
13
|
+
*
|
|
14
|
+
* Records when a user visits a specific page or section of the app. Useful for tracking user navigation patterns and popular features. The logs are reflected in the Analytics page in the app dashboard.
|
|
15
|
+
*
|
|
16
|
+
* The specified page name doesn't have to be the name of an actual page in the app, it can be any string you want to use to track the activity.
|
|
17
|
+
*
|
|
18
|
+
* @param pageName - Name of the page or section being visited.
|
|
19
|
+
* @returns Promise that resolves when the log is recorded.
|
|
20
|
+
*
|
|
21
|
+
* @example
|
|
22
|
+
* ```typescript
|
|
23
|
+
* // Log page visit or feature usage
|
|
24
|
+
* await base44.appLogs.logUserInApp('home');
|
|
25
|
+
* await base44.appLogs.logUserInApp('features-section');
|
|
26
|
+
* await base44.appLogs.logUserInApp('button-click');
|
|
27
|
+
* ```
|
|
28
|
+
*/
|
|
29
|
+
logUserInApp(pageName: string): Promise<void>;
|
|
30
|
+
/**
|
|
31
|
+
* Fetch app logs with optional parameters.
|
|
32
|
+
*
|
|
33
|
+
* @param params - Optional query parameters for filtering logs.
|
|
34
|
+
* @returns Promise resolving to the logs data.
|
|
35
|
+
* @internal
|
|
36
|
+
*/
|
|
37
|
+
fetchLogs(params?: Record<string, any>): Promise<any>;
|
|
38
|
+
/**
|
|
39
|
+
* Get app statistics.
|
|
40
|
+
*
|
|
41
|
+
* @param params - Optional query parameters for filtering stats.
|
|
42
|
+
* @returns Promise resolving to the stats data.
|
|
43
|
+
* @internal
|
|
44
|
+
*/
|
|
45
|
+
getStats(params?: Record<string, any>): Promise<any>;
|
|
46
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,142 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @internal
|
|
3
|
+
*/
|
|
4
|
+
export interface AppMessageContent {
|
|
5
|
+
content?: string;
|
|
6
|
+
file_urls?: string[];
|
|
7
|
+
custom_context?: unknown;
|
|
8
|
+
additional_message_params?: Record<string, unknown>;
|
|
9
|
+
[key: string]: unknown;
|
|
10
|
+
}
|
|
11
|
+
/**
|
|
12
|
+
* @internal
|
|
13
|
+
*/
|
|
14
|
+
export interface AppConversationMessage extends AppMessageContent {
|
|
15
|
+
id?: string | null;
|
|
16
|
+
role?: "user" | "assistant" | string;
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
* @internal
|
|
20
|
+
*/
|
|
21
|
+
export interface AppConversationLike {
|
|
22
|
+
id?: string | null;
|
|
23
|
+
messages?: AppMessageContent[] | null;
|
|
24
|
+
model?: string;
|
|
25
|
+
functions_fail_silently?: boolean;
|
|
26
|
+
}
|
|
27
|
+
/**
|
|
28
|
+
* @internal
|
|
29
|
+
*/
|
|
30
|
+
export interface DenoProjectLike {
|
|
31
|
+
project_id: string;
|
|
32
|
+
project_name: string;
|
|
33
|
+
app_id: string;
|
|
34
|
+
deployment_name_to_info: Record<string, {
|
|
35
|
+
id: string;
|
|
36
|
+
code: string;
|
|
37
|
+
}>;
|
|
38
|
+
}
|
|
39
|
+
/**
|
|
40
|
+
* @internal
|
|
41
|
+
*/
|
|
42
|
+
export interface AppLike {
|
|
43
|
+
id?: string;
|
|
44
|
+
conversation?: AppConversationLike | null;
|
|
45
|
+
app_stage?: "pending" | "product_flows" | "ready" | string;
|
|
46
|
+
created_date?: string;
|
|
47
|
+
updated_date?: string;
|
|
48
|
+
created_by?: string;
|
|
49
|
+
organization_id?: string;
|
|
50
|
+
name?: string;
|
|
51
|
+
user_description?: string;
|
|
52
|
+
entities?: Record<string, any>;
|
|
53
|
+
additional_user_data_schema?: any;
|
|
54
|
+
pages?: {
|
|
55
|
+
[key: string]: string;
|
|
56
|
+
};
|
|
57
|
+
components: {
|
|
58
|
+
[key: string]: any;
|
|
59
|
+
};
|
|
60
|
+
layout?: string;
|
|
61
|
+
globals_css?: string;
|
|
62
|
+
agents?: Record<string, any>;
|
|
63
|
+
logo_url?: string;
|
|
64
|
+
slug?: string;
|
|
65
|
+
public_settings?: "private_with_login" | "public_with_login" | "public_without_login" | "workspace_with_login" | string;
|
|
66
|
+
is_blocked?: boolean;
|
|
67
|
+
github_repo_url?: string;
|
|
68
|
+
main_page?: string;
|
|
69
|
+
installable_integrations?: any;
|
|
70
|
+
backend_project?: DenoProjectLike;
|
|
71
|
+
last_deployed_at?: string;
|
|
72
|
+
is_remixable?: boolean;
|
|
73
|
+
remixed_from_app_id?: string;
|
|
74
|
+
hide_entity_created_by?: boolean;
|
|
75
|
+
platform_version?: number;
|
|
76
|
+
enable_username_password?: boolean;
|
|
77
|
+
auth_config?: AuthConfigLike;
|
|
78
|
+
status?: {
|
|
79
|
+
state?: string;
|
|
80
|
+
details?: any;
|
|
81
|
+
last_updated_date?: string;
|
|
82
|
+
};
|
|
83
|
+
custom_instructions?: any;
|
|
84
|
+
frozen_files?: string[];
|
|
85
|
+
deep_coding_mode?: boolean;
|
|
86
|
+
needs_to_add_diff?: boolean;
|
|
87
|
+
installed_integration_context_items?: any[];
|
|
88
|
+
model?: string;
|
|
89
|
+
is_starred?: boolean;
|
|
90
|
+
agents_enabled?: boolean;
|
|
91
|
+
categories?: string[];
|
|
92
|
+
functions?: any;
|
|
93
|
+
function_names?: string[];
|
|
94
|
+
user_entity?: UserEntityLike;
|
|
95
|
+
app_code_hash?: string;
|
|
96
|
+
has_backend_functions_enabled?: boolean;
|
|
97
|
+
}
|
|
98
|
+
/**
|
|
99
|
+
* @internal
|
|
100
|
+
*/
|
|
101
|
+
export interface UserLike {
|
|
102
|
+
id?: string | null;
|
|
103
|
+
}
|
|
104
|
+
/**
|
|
105
|
+
* @internal
|
|
106
|
+
*/
|
|
107
|
+
export interface UserEntityLike {
|
|
108
|
+
type: string;
|
|
109
|
+
name: string;
|
|
110
|
+
title?: string;
|
|
111
|
+
properties?: {
|
|
112
|
+
role?: {
|
|
113
|
+
type?: string;
|
|
114
|
+
description?: string;
|
|
115
|
+
enum?: ("admin" | "user" | string)[];
|
|
116
|
+
};
|
|
117
|
+
email?: {
|
|
118
|
+
type?: string;
|
|
119
|
+
description?: string;
|
|
120
|
+
};
|
|
121
|
+
full_name?: {
|
|
122
|
+
type?: string;
|
|
123
|
+
description?: string;
|
|
124
|
+
};
|
|
125
|
+
};
|
|
126
|
+
required: string[];
|
|
127
|
+
}
|
|
128
|
+
/**
|
|
129
|
+
* @internal
|
|
130
|
+
*/
|
|
131
|
+
export interface AuthConfigLike {
|
|
132
|
+
enable_username_password?: boolean;
|
|
133
|
+
enable_google_login?: boolean;
|
|
134
|
+
enable_microsoft_login?: boolean;
|
|
135
|
+
enable_facebook_login?: boolean;
|
|
136
|
+
sso_provider_name?: string;
|
|
137
|
+
enable_sso_login?: boolean;
|
|
138
|
+
}
|
|
139
|
+
/**
|
|
140
|
+
* @internal
|
|
141
|
+
*/
|
|
142
|
+
export type LoginInfoResponse = Pick<AppLike, "id" | "name" | "slug" | "logo_url" | "user_description" | "updated_date" | "created_date" | "auth_config" | "platform_version">;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { AxiosInstance } from "axios";
|
|
2
|
+
import { AuthModule, AuthModuleOptions } from "./auth.types";
|
|
3
|
+
/**
|
|
4
|
+
* Creates the auth module for the Base44 SDK.
|
|
5
|
+
*
|
|
6
|
+
* @param axios - Axios instance for API requests
|
|
7
|
+
* @param functionsAxiosClient - Axios instance for functions API requests
|
|
8
|
+
* @param appId - Application ID
|
|
9
|
+
* @param options - Configuration options including server URLs
|
|
10
|
+
* @returns Auth module with authentication and user management methods
|
|
11
|
+
* @internal
|
|
12
|
+
*/
|
|
13
|
+
export declare function createAuthModule(axios: AxiosInstance, functionsAxiosClient: AxiosInstance, appId: string, options: AuthModuleOptions): AuthModule;
|