diff --git a/src/client.ts b/src/client.ts index 8f7d675..28e8b2d 100644 --- a/src/client.ts +++ b/src/client.ts @@ -6,6 +6,7 @@ import { createSsoModule } from "./modules/sso.js"; import { getAccessToken } from "./utils/auth-utils.js"; import { createFunctionsModule } from "./modules/functions.js"; import { createAgentsModule } from "./modules/agents.js"; +import { createAppLogsModule } from "./modules/app-logs.js"; import { RoomsSocket, RoomsSocketConfig } from "./utils/socket-utils.js"; export type CreateClientOptions = { @@ -116,6 +117,7 @@ export function createClient(config: { serverUrl, token, }), + appLogs: createAppLogsModule(axiosClient, appId), cleanup: () => { socket.disconnect(); }, @@ -133,6 +135,7 @@ export function createClient(config: { serverUrl, token, }), + appLogs: createAppLogsModule(serviceRoleAxiosClient, appId), cleanup: () => { socket.disconnect(); }, diff --git a/src/modules/app-logs.ts b/src/modules/app-logs.ts new file mode 100644 index 0000000..b461cb9 --- /dev/null +++ b/src/modules/app-logs.ts @@ -0,0 +1,43 @@ +import { AxiosInstance } from "axios"; + +/** + * Creates the app logs module for the Base44 SDK + * @param {AxiosInstance} axios - Axios instance + * @param {string} appId - Application ID + * @returns {Object} App logs module + */ +export function createAppLogsModule(axios: AxiosInstance, appId: string) { + const baseURL = `/app-logs/${appId}`; + + return { + /** + * Log user activity in the app + * @param {string} pageName - Name of the page being visited + * @returns {Promise} + */ + async logUserInApp(pageName: string): Promise { + await axios.post(`${baseURL}/log-user-in-app/${pageName}`); + }, + + /** + * Fetch app logs with optional parameters + * @param {Object} params - Query parameters for filtering logs + * @returns {Promise} App logs data + */ + async fetchLogs(params: Record = {}): Promise { + const response = await axios.get(baseURL, { params }); + return response; + }, + + /** + * Get app statistics + * @param {Object} params - Query parameters for filtering stats + * @returns {Promise} App statistics + */ + async getStats(params: Record = {}): Promise { + const response = await axios.get(`${baseURL}/stats`, { params }); + return response; + }, + }; +} +