diff --git a/scripts/mintlify-post-processing/file-processing/file-processing.js b/scripts/mintlify-post-processing/file-processing/file-processing.js index 67f7cbd..06de994 100755 --- a/scripts/mintlify-post-processing/file-processing/file-processing.js +++ b/scripts/mintlify-post-processing/file-processing/file-processing.js @@ -35,6 +35,7 @@ const PANELS_ENABLED = process.env.MINTLIFY_INCLUDE_PANELS === "true"; const MODULE_RENAMES = { AgentsModule: "agents", + AnalyticsModule: "analytics", AppLogsModule: "app-logs", AuthModule: "auth", ConnectorsModule: "connectors", diff --git a/scripts/mintlify-post-processing/types-to-expose.json b/scripts/mintlify-post-processing/types-to-expose.json index 49e790d..3bbdb35 100644 --- a/scripts/mintlify-post-processing/types-to-expose.json +++ b/scripts/mintlify-post-processing/types-to-expose.json @@ -1,5 +1,6 @@ [ "AgentsModule", + "AnalyticsModule", "AppLogsModule", "AuthModule", "ConnectorsModule", diff --git a/src/client.types.ts b/src/client.types.ts index e115cdb..d5a83df 100644 --- a/src/client.types.ts +++ b/src/client.types.ts @@ -77,23 +77,20 @@ export interface CreateClientConfig { * Provides access to all SDK modules for interacting with the app. */ export interface Base44Client { - /** {@link EntitiesModule | Entities module} for CRUD operations on your data models. */ - entities: EntitiesModule; - /** {@link IntegrationsModule | Integrations module} for calling pre-built integration endpoints. */ - integrations: IntegrationsModule; - /** {@link AuthModule | Auth module} for user authentication and management. */ - auth: AuthModule; - /** {@link FunctionsModule | Functions module} for invoking custom backend functions. */ - functions: FunctionsModule; /** {@link AgentsModule | Agents module} for managing AI agent conversations. */ agents: AgentsModule; + /** {@link AnalyticsModule | Analytics module} for tracking custom events in your app. */ + analytics: AnalyticsModule; /** {@link AppLogsModule | App logs module} for tracking app usage. */ appLogs: AppLogsModule; - /** - * {@link AnalyticsModule | Analytics module} for tracking app usage. - * @internal - */ - analytics: AnalyticsModule; + /** {@link AuthModule | Auth module} for user authentication and management. */ + auth: AuthModule; + /** {@link EntitiesModule | Entities module} for CRUD operations on your data models. */ + entities: EntitiesModule; + /** {@link FunctionsModule | Functions module} for invoking custom backend functions. */ + functions: FunctionsModule; + /** {@link IntegrationsModule | Integrations module} for calling pre-built integration endpoints. */ + integrations: IntegrationsModule; /** Cleanup function to disconnect WebSocket connections. Call when you're done with the client. */ cleanup: () => void; @@ -120,22 +117,22 @@ export interface Base44Client { * @throws {Error} When accessed without providing a serviceToken during client creation */ readonly asServiceRole: { + /** {@link AgentsModule | Agents module} with elevated permissions. */ + agents: AgentsModule; + /** {@link AppLogsModule | App logs module} with elevated permissions. */ + appLogs: AppLogsModule; + /** {@link ConnectorsModule | Connectors module} for OAuth token retrieval. */ + connectors: ConnectorsModule; /** {@link EntitiesModule | Entities module} with elevated permissions. */ entities: EntitiesModule; + /** {@link FunctionsModule | Functions module} with elevated permissions. */ + functions: FunctionsModule; /** {@link IntegrationsModule | Integrations module} with elevated permissions. */ integrations: IntegrationsModule; /** {@link SsoModule | SSO module} for generating SSO tokens. * @internal */ sso: SsoModule; - /** {@link ConnectorsModule | Connectors module} for OAuth token retrieval. */ - connectors: ConnectorsModule; - /** {@link FunctionsModule | Functions module} with elevated permissions. */ - functions: FunctionsModule; - /** {@link AgentsModule | Agents module} with elevated permissions. */ - agents: AgentsModule; - /** {@link AppLogsModule | App logs module} with elevated permissions. */ - appLogs: AppLogsModule; /** Cleanup function to disconnect WebSocket connections. */ cleanup: () => void; }; diff --git a/src/modules/analytics.types.ts b/src/modules/analytics.types.ts index e0f29e3..46bb486 100644 --- a/src/modules/analytics.types.ts +++ b/src/modules/analytics.types.ts @@ -1,9 +1,39 @@ +/** + * Properties for analytics events. + * + * Key-value pairs with additional event data. Values can be strings, numbers, booleans, or null. + */ export type TrackEventProperties = { [key: string]: string | number | boolean | null | undefined; }; +/** + * Parameters for tracking an analytics event. + */ export type TrackEventParams = { + /** + * Name of the event to track. + * + * Use descriptive names like `button_click`, `form_submit`, or `purchase_completed`. + */ eventName: string; + /** + * Optional key-value pairs with additional event data. + * + * Values can be strings, numbers, booleans, or null. + * + * @example + * ```typescript + * base44.analytics.track({ + * eventName: 'add_to_cart', + * properties: { + * product_id: 'prod_123', + * price: 29.99, + * quantity: 2 + * } + * }); + * ``` + */ properties?: TrackEventProperties; }; @@ -47,8 +77,51 @@ export type AnalyticsModuleOptions = { }; /** - * @internal + * Analytics module for tracking custom events in your app. + * + * Use this module to track specific user actions. Track things like button clicks, form submissions, purchases, and feature usage. + * + * Analytics events tracked with this module appear as custom event cards in the [Analytics dashboard](/documentation/performance-and-seo/app-analytics). + * + * When tracking events: + * + * - Choose clear, descriptive event names in snake_case like `signup_button_click` or `purchase_completed` rather than generic names like `click`. + * - Include relevant context in your properties such as identifiers like `product_id`, measurements like `price`, and flags like `is_first_purchase`. + * + * This module is only available in user authentication mode (`base44.analytics`). */ -export type AnalyticsModule = { - track: (params: TrackEventParams) => void; -}; +export interface AnalyticsModule { + /** + * Tracks a custom event that appears as a card in your Analytics dashboard. + * + * 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. + * + * @param params - Event parameters. + * @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'`. + * @param params.properties - Optional data to attach to the event. You can filter and analyze events by these properties in the dashboard. + * + * @example Track a button click + * ```typescript + * // Track a button click + * base44.analytics.track({ + * eventName: 'signup_button_click' + * }); + * ``` + * + * @example Track with properties + * ```typescript + * // Track with properties + * base44.analytics.track({ + * eventName: 'add_to_cart', + * properties: { + * product_id: 'prod_123', + * product_name: 'Premium Widget', + * price: 29.99, + * quantity: 2, + * is_first_purchase: true + * } + * }); + * ``` + */ + track(params: TrackEventParams): void; +} diff --git a/src/modules/auth.types.ts b/src/modules/auth.types.ts index 8795693..1390535 100644 --- a/src/modules/auth.types.ts +++ b/src/modules/auth.types.ts @@ -190,6 +190,7 @@ export interface AuthModule { * * Initiates OAuth/SSO login flow with providers like Google, Microsoft, etc. Requires a browser environment and can't be used in the backend. * + * @internal * @param provider - Name of the supported authentication provider (e.g., 'google', 'microsoft'). * @param fromUrl - URL to redirect to after successful authentication. Defaults to '/'. *