Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions src/client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 = {
Expand Down Expand Up @@ -116,6 +117,7 @@ export function createClient(config: {
serverUrl,
token,
}),
appLogs: createAppLogsModule(axiosClient, appId),
cleanup: () => {
socket.disconnect();
},
Expand All @@ -133,6 +135,7 @@ export function createClient(config: {
serverUrl,
token,
}),
appLogs: createAppLogsModule(serviceRoleAxiosClient, appId),
cleanup: () => {
socket.disconnect();
},
Expand Down
43 changes: 43 additions & 0 deletions src/modules/app-logs.ts
Original file line number Diff line number Diff line change
@@ -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<void>}
*/
async logUserInApp(pageName: string): Promise<void> {
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<any>} App logs data
*/
async fetchLogs(params: Record<string, any> = {}): Promise<any> {
const response = await axios.get(baseURL, { params });
return response;
},

/**
* Get app statistics
* @param {Object} params - Query parameters for filtering stats
* @returns {Promise<any>} App statistics
*/
async getStats(params: Record<string, any> = {}): Promise<any> {
const response = await axios.get(`${baseURL}/stats`, { params });
return response;
},
};
}