/* generated using openapi-typescript-codegen -- do not edit */ /* istanbul ignore file */ /* tslint:disable */ /* eslint-disable */ import type { AccessTimesHeatmap } from '../models/AccessTimesHeatmap'; import type { BaseFinanceResponse } from '../models/BaseFinanceResponse'; import type { ContentDetailsResponse } from '../models/ContentDetailsResponse'; import type { ContentResponse } from '../models/ContentResponse'; import type { ConversationDetailResponse } from '../models/ConversationDetailResponse'; import type { ConversationListResponse } from '../models/ConversationListResponse'; import type { CurrentUsersResponse } from '../models/CurrentUsersResponse'; import type { FinanceDetailsResponse } from '../models/FinanceDetailsResponse'; import type { InvoiceReportResponse } from '../models/InvoiceReportResponse'; import type { LearnerAnalyticsResponse } from '../models/LearnerAnalyticsResponse'; import type { LearnerListResponse } from '../models/LearnerListResponse'; import type { RatingsOvertime } from '../models/RatingsOvertime'; import type { SessionsChart } from '../models/SessionsChart'; import type { TopicDetails } from '../models/TopicDetails'; import type { TopicsOverview } from '../models/TopicsOverview'; import type { UserDetail } from '../models/UserDetail'; import type { CancelablePromise } from '../core/CancelablePromise'; import { OpenAPI } from '../core/OpenAPI'; import { request as __request } from '../core/request'; export class AnalyticsService { /** * Get Content Analytics * * Retrieve aggregated analytics for catalog content (courses, programs, pathways, skills). * * Returns both summary statistics and paginated list of content items with individual analytics. * When a platform_key is provided, results are filtered to show only content consumed by * learners associated with that platform. * * **RBAC Requirements:** * - Requires: Analytics Viewer role (Ibl.Analytics/Core/read) or Tenant Admin role (Ibl.*) * * **Metrics supported:** * - `course` or `courses`: Course analytics with time spent * - `program` or `programs`: Program analytics * - `pathway` or `pathways`: Pathway analytics * - `skill` or `skills`: Skill analytics * * **Platform Filtering:** * - Without platform_key: Shows global analytics across all platforms * - With platform_key: Shows analytics filtered by platform learners only * * **Time Spent Analytics:** * - Platform-level: Total time spent across all content and average per learner * - Course-level: Total time spent per course and average per enrolled learner * - Time values are provided in seconds for precision * - Overtime: Time series data showing platform time spent over last 7 days (courses only, and include_overtime=true) * * **External Content:** * - Content not owned by the requesting platform but used by its learners is marked as "external" * - External content has limited metadata exposure for privacy * * @returns ContentResponse * @throws ApiError */ public static getContentAnalytics({ metric, dateFilter = 'today', endDate, granularity = 'hour', includeOvertime = false, limit = 20, mentorUniqueId, page = 1, platformKey, search, sortBy = 'name', startDate, usergroupIds, }: { /** * The type of content to retrieve (course, program, pathway, skill) * * * `course` - course * * `courses` - courses * * `program` - program * * `programs` - programs * * `pathway` - pathway * * `pathways` - pathways * * `skill` - skill * * `skills` - skills */ metric: 'course' | 'courses' | 'program' | 'programs' | 'pathway' | 'pathways' | 'skill' | 'skills', /** * * `today` - Today only * * `7d` - Last 7 days * * `30d` - Last 30 days * * `90d` - Last 90 days * * `all_time` - All time * * `custom` - Custom date range */ dateFilter?: 'today' | '7d' | '30d' | '90d' | 'all_time' | 'custom', endDate?: string, /** * * `day` - day * * `hour` - hour * * `week` - week * * `month` - month */ granularity?: 'day' | 'hour' | 'week' | 'month', /** * Include time spent over time data */ includeOvertime?: boolean, /** * Number of items per page (max 100) */ limit?: number, mentorUniqueId?: string, /** * Page number for pagination */ page?: number, /** * Optional platform key to filter results by platform */ platformKey?: string | null, /** * Filter results by name/slug (case-insensitive substring match) */ search?: string, /** * Sort order for results. 'active_enrollments' is only supported for course, program, and pathway metrics; it is ignored for skill. * * * `name` - Name (default) * * `active_enrollments` - Active enrollments (descending) */ sortBy?: 'name' | 'active_enrollments', startDate?: string, /** * Optional list of usergroup IDs to filter results */ usergroupIds?: Array | null, }): CancelablePromise { return __request(OpenAPI, { method: 'GET', url: '/api/analytics/content/', query: { 'date_filter': dateFilter, 'end_date': endDate, 'granularity': granularity, 'include_overtime': includeOvertime, 'limit': limit, 'mentor_unique_id': mentorUniqueId, 'metric': metric, 'page': page, 'platform_key': platformKey, 'search': search, 'sort_by': sortBy, 'start_date': startDate, 'usergroup_ids': usergroupIds, }, }); } /** * Get Content Details * Retrieve detailed analytics for a specific content item including summary statistics, learner-level data, and optional time series information. * @returns ContentDetailsResponse * @throws ApiError */ public static getContentDetails({ contentId, metric, dateFilter = 'today', endDate, limit = 10, mentorUniqueId, page = 1, platformKey, search, startDate, timeMetric, usergroupIds, }: { contentId: string, /** * Content type to fetch (course, program, pathway, skill) * * * `course` - course * * `courses` - courses * * `program` - program * * `programs` - programs * * `pathway` - pathway * * `pathways` - pathways * * `skill` - skill * * `skills` - skills */ metric: 'course' | 'courses' | 'program' | 'programs' | 'pathway' | 'pathways' | 'skill' | 'skills', /** * * `today` - Today only * * `7d` - Last 7 days * * `30d` - Last 30 days * * `90d` - Last 90 days * * `all_time` - All time * * `custom` - Custom date range */ dateFilter?: 'today' | '7d' | '30d' | '90d' | 'all_time' | 'custom', endDate?: string, /** * Number of learner records per page */ limit?: number, mentorUniqueId?: string, page?: number, platformKey?: string, search?: string, startDate?: string, /** * Optional time series metric (enrollments, completions, ratings, time_spent) */ timeMetric?: string | null, /** * Optional list of usergroup IDs to filter results */ usergroupIds?: Array | null, }): CancelablePromise { return __request(OpenAPI, { method: 'GET', url: '/api/analytics/content/details/{content_id}/', path: { 'content_id': contentId, }, query: { 'date_filter': dateFilter, 'end_date': endDate, 'limit': limit, 'mentor_unique_id': mentorUniqueId, 'metric': metric, 'page': page, 'platform_key': platformKey, 'search': search, 'start_date': startDate, 'time_metric': timeMetric, 'usergroup_ids': usergroupIds, }, }); } /** * Financial Analytics API - Get comprehensive cost metrics with comparison analysis. * * This endpoint provides period-based cost analysis (not cumulative) with support for: * - Multiple time granularities and metrics * - Cross-dimensional filtering * - Percentage change vs comparison periods * - Forward-filled time series * * **Examples:** * * **Basic Weekly Costs:** * ``` * GET /api/analytics/financial/?metric=weekly_costs&comparison_days=10 * ``` * * **Platform & Mentor Filtered:** * ``` * # Get total costs for a specific platform and agent * GET /api/analytics/financial/?metric=total_costs&platform_key=web-app&mentor_unique_id=mentor-123&comparison_days=14 * ``` * * **Monthly Costs by Provider:** * ``` * GET /api/analytics/financial/?metric=monthly_costs&provider=openai&granularity=month&comparison_days=30 * ``` * * **Daily Costs for Specific User:** * ``` * GET /api/analytics/financial/?metric=total_costs&username=user-456&granularity=day&start_date=2025-01-15&end_date=2025-01-21&comparison_days=7 * ``` * * * **Response Structure:** * ```json * { * "metric": "weekly_costs", * "value": 12.47, * "percentage_change": 8.5, * "overtime": [ * {"date": "2025-01-06", "value": 2.89}, * {"date": "2025-01-13", "value": 3.12} * ], * "period_info": { * "start_date": "2025-01-01", * "end_date": "2025-01-31", * "period_days": 31 * }, * "comparison_info": { * "previous_period_value": 11.50, * ... * } * } * ``` * @returns BaseFinanceResponse Successful financial metrics response with period-based cost data * @throws ApiError */ public static analyticsFinancialRetrieve({ metric, comparisonDays, dateFilter = 'today', endDate, fillMethod = 'zero', granularity = 'day', llmModel, mentorUniqueId, platformKey, provider, showOvertime = true, startDate, usergroupIds, username, }: { /** * Type of financial metric to retrieve * * * `total_costs` - Total costs for selected timeframe * * `weekly_costs` - Costs for current/selected week * * `monthly_costs` - Costs for current/selected month */ metric: 'total_costs' | 'weekly_costs' | 'monthly_costs', /** * Number of days for comparison period to calculate percentage change (e.g., 10 for 10-day comparison) */ comparisonDays?: number, /** * * `today` - Today only * * `7d` - Last 7 days * * `30d` - Last 30 days * * `90d` - Last 90 days * * `all_time` - All time * * `custom` - Custom date range */ dateFilter?: 'today' | '7d' | '30d' | '90d' | 'all_time' | 'custom', endDate?: string, /** * Method for filling missing time periods in overtime data * * * `zero` - Fill missing periods with zero * * `previous` - Fill missing periods with previous value */ fillMethod?: 'zero' | 'previous', /** * Time granularity for overtime series data * * * `day` - Daily data points * * `week` - Weekly data points * * `month` - Monthly data points */ granularity?: 'day' | 'week' | 'month', /** * Filter by specific LLM model (e.g., gpt-4o, claude-3-5-sonnet) */ llmModel?: string, mentorUniqueId?: string, platformKey?: string, /** * Filter by AI provider * * * `openai` - OpenAI * * `anthropic` - Anthropic * * `azure` - Azure * * `google` - Google * * `meta` - Meta * * `other` - Other */ provider?: 'openai' | 'anthropic' | 'azure' | 'google' | 'meta' | 'other', /** * Whether to include overtime series data in response */ showOvertime?: boolean, startDate?: string, /** * Optional list of usergroup IDs to filter results */ usergroupIds?: Array | null, /** * Filter by specific username - returns costs for this user only */ username?: string, }): CancelablePromise { return __request(OpenAPI, { method: 'GET', url: '/api/analytics/financial/', query: { 'comparison_days': comparisonDays, 'date_filter': dateFilter, 'end_date': endDate, 'fill_method': fillMethod, 'granularity': granularity, 'llm_model': llmModel, 'mentor_unique_id': mentorUniqueId, 'metric': metric, 'platform_key': platformKey, 'provider': provider, 'show_overtime': showOvertime, 'start_date': startDate, 'usergroup_ids': usergroupIds, 'username': username, }, errors: { 400: `Bad Request - Invalid query parameters`, 403: `Forbidden - Insufficient permissions`, 500: `Internal Server Error`, }, }); } /** * Financial Details Analytics API – paginated cost tables with flexible grouping. * * This endpoint returns tabular cost metrics aggregated by the dimension * specified via the `group_by` query parameter. One or more KPI columns * can be requested through the comma-separated `metrics` list while * typical filters (date range, provider, platform_key, user, etc.) narrow the * dataset. Results are paginated with `page` / `limit`. * * **Required query parameters** * - group_by – provider | llm_model | username | mentor | platform * - metrics – csv list of KPI names, e.g. total_cost, sessions * * **Shared optional filters** * - start_date, end_date – ISO yyyy-mm-dd (ignored when all_time=true) * - platform_key – tenant isolation * - mentor_unique_id – filter to one agent * - username – filter to a learner * - provider / llm_model – filter to LLM provider / model * - all_time – true → lifetime totals * - page (default 1), limit (default 50) * * **Examples** * -------- * 1. Cost by provider for the last week * ``` * GET /api/v2/analytics/financial/details? * group_by=provider& * metrics=total_cost& * start_date=2025-01-01& * end_date=2025-01-07& * page=1&limit=10 * ``` * * 2. Lifetime cost per user with extra KPIs * ``` * GET /api/v2/analytics/financial/details? * group_by=username& * metrics=total_cost,sessions& * all_time=true&page=1&limit=50 * ``` * 3. Cost by LLM model with tenant filter * ``` * GET /api/v2/analytics/financial/details? * group_by=llm_model& * metrics=total_cost& * platform_key=web-app& * start_date=2025-01-01&end_date=2025-01-31 * ``` * Response structure * ------------------- * ``` * { * "page": 1, * "limit": 10, * "total_pages": 1, * "total_records": 3, * "rows": [ * {"provider": "openai", "total_cost": "2.50000"}, * {"provider": "anthropic", "total_cost": "1.00000"}, * {"provider": "azure", "total_cost": "0.50000"} * ], * "metrics": [ * { * "name": "total_cost", * "unit": "$", * "description": "Cost for this entity in period" * } * ], * "total_cost": "4.00000" // optional grand-total when available * } * `` * @returns FinanceDetailsResponse * @throws ApiError */ public static analyticsFinancialDetailsRetrieve({ groupBy, dateFilter = 'today', endDate, limit = 20, llmModel, mentorUniqueId, metrics = 'total_cost', page = 1, platformKey, provider, search, startDate, usergroupIds, username, }: { /** * Dimension to group by * * * `provider` - Group by provider * * `llm_model` - Group by LLM model * * `username` - Group by username * * `mentor` - Group by agent * * `platform` - Group by platform * * `action` - Group by actions */ groupBy: 'provider' | 'llm_model' | 'username' | 'mentor' | 'platform' | 'action', /** * * `today` - Today only * * `7d` - Last 7 days * * `30d` - Last 30 days * * `90d` - Last 90 days * * `all_time` - All time * * `custom` - Custom date range */ dateFilter?: 'today' | '7d' | '30d' | '90d' | 'all_time' | 'custom', endDate?: string, limit?: number, llmModel?: string, mentorUniqueId?: string, /** * Comma-separated list of metrics (e.g. total_cost,sessions, last_active) */ metrics?: string, page?: number, platformKey?: string, provider?: string, search?: string, startDate?: string, /** * Optional list of usergroup IDs to filter results */ usergroupIds?: Array | null, username?: string, }): CancelablePromise { return __request(OpenAPI, { method: 'GET', url: '/api/analytics/financial/details/', query: { 'date_filter': dateFilter, 'end_date': endDate, 'group_by': groupBy, 'limit': limit, 'llm_model': llmModel, 'mentor_unique_id': mentorUniqueId, 'metrics': metrics, 'page': page, 'platform_key': platformKey, 'provider': provider, 'search': search, 'start_date': startDate, 'usergroup_ids': usergroupIds, 'username': username, }, errors: { 400: `Bad Request – invalid query params`, 500: `Internal Server Error`, }, }); } /** * Flexible Invoice Report API – Billing summary with username and platform filtering. * * This endpoint generates invoice reports with flexible filtering options: * - Platform admins can view their platform's data and filter by username within their platform * - Super admins can view any combination of username/platform or global summaries * * **Key Features:** * - Flexible filtering by username and/or platform_key * - Essential metrics: total cost, sessions, usage period * - Provider breakdown (OpenAI, Anthropic, etc.) * - Top agents/actions by cost * - Clean, invoice-ready format * * **Query Parameters:** * - username: Filter by specific username (optional) * - platform_key: Filter by platform (optional, but required for platform admins) * - start_date, end_date: billing period (defaults to last 30 days) * - include_breakdown: show provider/agent details (default: true) * * **Permission Logic:** * - Platform admins: Must include platform_key matching their permission scope * - Super admins: Can use any combination of filters or none (global summary) * * **Examples:** * ``` * # Platform admin viewing their platform * GET /api/analytics/financial/invoice?platform_key=web-app * * # Platform admin viewing specific user in their platform * GET /api/analytics/financial/invoice?platform_key=web-app&username=john.doe * * # Super admin viewing specific user across all platforms * GET /api/analytics/financial/invoice?username=john.doe * * # Super admin viewing global summary * GET /api/analytics/financial/invoice * ``` * * **Response Structure:** * ```json * { * "entity": { * "type": "user|platform|global", * "username": "john.doe", * "platform_key": "web-app", * "platform_name": "Web Application", * "display_name": "John Doe on Web Application" * }, * "billing_period": { * "start_date": "2025-01-01", * "end_date": "2025-01-31", * "days": 31 * }, * "summary": { * "total_cost": 245.750, * "total_sessions": 1250, * "active_users": 85, * "cost_per_session": 0.196 * }, * "breakdown": { * "by_provider": [...], * "by_mentor": [...], * "by_action": [...] * } * } * ``` * @returns InvoiceReportResponse * @throws ApiError */ public static analyticsFinancialInvoiceRetrieve({ endDate, includeBreakdown = true, platformKey, startDate, usergroupIds, username, }: { /** * End date for billing period (defaults to today) */ endDate?: string, /** * Whether to include provider and agent breakdown */ includeBreakdown?: boolean, /** * Platform key to filter by (optional, required for platform admins) */ platformKey?: string, /** * Start date for billing period (defaults to 30 days ago) */ startDate?: string, /** * Optional list of usergroup IDs to filter results */ usergroupIds?: Array | null, /** * Username to generate invoice for (optional) */ username?: string, }): CancelablePromise { return __request(OpenAPI, { method: 'GET', url: '/api/analytics/financial/invoice/', query: { 'end_date': endDate, 'include_breakdown': includeBreakdown, 'platform_key': platformKey, 'start_date': startDate, 'usergroup_ids': usergroupIds, 'username': username, }, errors: { 400: `Bad Request – invalid parameters`, 403: `Forbidden – insufficient permissions`, 404: `No data found`, 500: `Internal Server Error`, }, }); } /** * Unified API endpoint for learner analytics. * * This endpoint provides either: * 1. Cross-platform summary (when only username is provided) * 2. Platform-specific detailed data (when username + platform_key are provided) * * Query params: * - username (required): Username of the learner * - platform_key (optional): Platform key for platform-specific data * - page (optional): Page number (default: 1) * - limit (optional): Records per page (default: 20, max: 100) * * Returns: * - If platform_key provided: Detailed platform metrics * - If no platform_key: Cross-platform summary with pagination * @returns LearnerAnalyticsResponse * @throws ApiError */ public static analyticsLearnersRetrieve({ dateFilter = 'today', endDate, granularity = 'hour', limit = 20, mentorUniqueId, overtime = false, page = 1, platformKey, startDate, usergroupIds, username, }: { /** * * `today` - Today only * * `7d` - Last 7 days * * `30d` - Last 30 days * * `90d` - Last 90 days * * `all_time` - All time * * `custom` - Custom date range */ dateFilter?: 'today' | '7d' | '30d' | '90d' | 'all_time' | 'custom', endDate?: string, /** * * `day` - day * * `hour` - hour * * `week` - week * * `month` - month */ granularity?: 'day' | 'hour' | 'week' | 'month', /** * Number of records per page (default: 20, max: 100) */ limit?: number, mentorUniqueId?: string, /** * Include overtime metrics for the user in the platform (default: false) */ overtime?: boolean, /** * Page number (default: 1) */ page?: number, /** * Optional platform key - if provided, returns platform-specific detailed data */ platformKey?: string, startDate?: string, /** * Optional list of usergroup IDs to filter results */ usergroupIds?: Array | null, /** * Username of the learner to get analytics for. Defaults to self if not provided. */ username?: string, }): CancelablePromise { return __request(OpenAPI, { method: 'GET', url: '/api/analytics/learners/', query: { 'date_filter': dateFilter, 'end_date': endDate, 'granularity': granularity, 'limit': limit, 'mentor_unique_id': mentorUniqueId, 'overtime': overtime, 'page': page, 'platform_key': platformKey, 'start_date': startDate, 'usergroup_ids': usergroupIds, 'username': username, }, }); } /** * * Retrieve a paginated list of learners for a specific platform with their comprehensive * metrics from the UserPlatformSummary materialized view. This endpoint is accessible only * to platform administrators and supports search, sorting, and pagination. * * @returns LearnerListResponse Paginated list of learners with their metrics * @throws ApiError */ public static analyticsLearnersListRetrieve({ platformKey, dateFilter = 'today', endDate, granularity = 'hour', limit = 20, mentorUniqueId, page = 1, search, sortBy = 'last_activity', sortOrder = 'desc', startDate, usergroupIds, }: { /** * Platform key to filter learners by platform */ platformKey: string, /** * * `today` - Today only * * `7d` - Last 7 days * * `30d` - Last 30 days * * `90d` - Last 90 days * * `all_time` - All time * * `custom` - Custom date range */ dateFilter?: 'today' | '7d' | '30d' | '90d' | 'all_time' | 'custom', endDate?: string, /** * * `day` - day * * `hour` - hour * * `week` - week * * `month` - month */ granularity?: 'day' | 'hour' | 'week' | 'month', /** * Number of learners per page (default: 20, max: 100) */ limit?: number, mentorUniqueId?: string, /** * Page number for pagination (default: 1) */ page?: number, /** * Search term to filter learners by username, email, or name */ search?: string, /** * Field to sort learners by (default: last_activity) * * * `username` - Username * * `name` - Name * * `last_activity` - Last Activity * * `total_points` - Total Points * * `total_time_spent_seconds` - Time Spent * * `total_enrollments` - Enrollments * * `total_skills_count` - Skills Count */ sortBy?: 'username' | 'name' | 'last_activity' | 'total_points' | 'total_time_spent_seconds' | 'total_enrollments' | 'total_skills_count', /** * Sort order (default: desc) * * * `asc` - Ascending * * `desc` - Descending */ sortOrder?: 'asc' | 'desc', startDate?: string, /** * Optional list of usergroup IDs to filter results */ usergroupIds?: Array | null, }): CancelablePromise { return __request(OpenAPI, { method: 'GET', url: '/api/analytics/learners/list/', query: { 'date_filter': dateFilter, 'end_date': endDate, 'granularity': granularity, 'limit': limit, 'mentor_unique_id': mentorUniqueId, 'page': page, 'platform_key': platformKey, 'search': search, 'sort_by': sortBy, 'sort_order': sortOrder, 'start_date': startDate, 'usergroup_ids': usergroupIds, }, errors: { 400: `Bad Request - Invalid parameters supplied`, 403: `Forbidden - Platform admin access required`, 500: `Unexpected error`, }, }); } /** * Conversation list endpoint for analytics. * * Query params (all optional unless specified by permissions): * - platform_key: filter by platform * - mentor_unique_id: filter by mentor * - page: page number (default 1) * - limit: page size (default 20, max 100) * - search: search in user name and first user message * - min_messages, max_messages: message_count range * - sentiment: positive|negative|neutral * - topic: topic name contains * - start_date, end_date: date filter on conversation date * * Returns: summary totals, results list (paginated), and pagination metadata. * @returns ConversationListResponse * @throws ApiError */ public static analyticsMessagesRetrieve({ endDate, limit = 20, maxMessages, mentorUniqueId, minMessages, page = 1, platformKey, search, sentiment, startDate, topic, usergroupIds, }: { endDate?: string, limit?: number, maxMessages?: number, mentorUniqueId?: string, minMessages?: number, page?: number, platformKey?: string, search?: string, /** * * `positive` - positive * * `negative` - negative * * `neutral` - neutral */ sentiment?: 'positive' | 'negative' | 'neutral', startDate?: string, topic?: string, /** * Optional list of usergroup IDs to filter results */ usergroupIds?: Array | null, }): CancelablePromise { return __request(OpenAPI, { method: 'GET', url: '/api/analytics/messages/', query: { 'end_date': endDate, 'limit': limit, 'max_messages': maxMessages, 'mentor_unique_id': mentorUniqueId, 'min_messages': minMessages, 'page': page, 'platform_key': platformKey, 'search': search, 'sentiment': sentiment, 'start_date': startDate, 'topic': topic, 'usergroup_ids': usergroupIds, }, }); } /** * Conversation detail endpoint for analytics. * * Query params: * - session_id (required): UUID of the session to fetch * - platform_key, mentor_unique_id (optional): further scope * - start_date, end_date (optional): date filter on message timestamps * * Returns: summary metadata from conversation_list MV, and a list of * human/ai message pairs in chronological order. * @returns ConversationDetailResponse * @throws ApiError */ public static analyticsMessagesDetailsRetrieve({ sessionId, endDate, mentorUniqueId, platformKey, startDate, usergroupIds, }: { sessionId: string, endDate?: string, mentorUniqueId?: string, platformKey?: string, startDate?: string, /** * Optional list of usergroup IDs to filter results */ usergroupIds?: Array | null, }): CancelablePromise { return __request(OpenAPI, { method: 'GET', url: '/api/analytics/messages/details/', query: { 'end_date': endDate, 'mentor_unique_id': mentorUniqueId, 'platform_key': platformKey, 'session_id': sessionId, 'start_date': startDate, 'usergroup_ids': usergroupIds, }, }); } /** * Ratings overtime endpoint. * * Query params: * - metric: only 'ratings' is supported (default) * - platform_key, mentor_unique_id: optional filters * - granularity: 'day' (default) or 'hour' (hour only for today) * - start_date, end_date: optional date range; defaults applied if not provided * * Returns: { metric: 'ratings', points: [{date, value}, ...] } * @returns RatingsOvertime * @throws ApiError */ public static analyticsRatingsRetrieve({ dateFilter = 'today', endDate, granularity = 'hour', mentorUniqueId, metric = 'ratings', platformKey, startDate, usergroupIds, }: { /** * * `today` - Today only * * `7d` - Last 7 days * * `30d` - Last 30 days * * `90d` - Last 90 days * * `all_time` - All time * * `custom` - Custom date range */ dateFilter?: 'today' | '7d' | '30d' | '90d' | 'all_time' | 'custom', endDate?: string, /** * * `day` - day * * `hour` - hour * * `week` - week * * `month` - month */ granularity?: 'day' | 'hour' | 'week' | 'month', mentorUniqueId?: string, /** * * `ratings` - Ratings over time */ metric?: 'ratings', platformKey?: string, startDate?: string, /** * Optional list of usergroup IDs to filter results */ usergroupIds?: Array | null, }): CancelablePromise { return __request(OpenAPI, { method: 'GET', url: '/api/analytics/ratings/', query: { 'date_filter': dateFilter, 'end_date': endDate, 'granularity': granularity, 'mentor_unique_id': mentorUniqueId, 'metric': metric, 'platform_key': platformKey, 'start_date': startDate, 'usergroup_ids': usergroupIds, }, }); } /** * Mixin for RBAC validation for mentor analytics views. * * Mentor analytics endpoints enforce RBAC in two phases: * 1. Endpoint authorization (_perform_mentor_analytics_validation): * - Aggregate (no mentor_unique_id): requires * "Ibl.Analytics/CanViewAnalytics/action" on /platforms/{pk}/ AND * "Ibl.Analytics/Mentors/read" on /platforms/{pk}/mentors/. * - Per-mentor (mentor_unique_id provided): requires * "Ibl.Analytics/CanViewMentorAnalytics/action" on * /platforms/{pk}/mentors/{mentor_id}/. The mentor-owner bypass * (is_owner) applies via the MENTOR_OWNER well-known role. * 2. Row-level filter (_get_accessible_user_ids_for_mentor_analytics): * - Enumerates accessible users under * /platforms/{pk}/mentors/{mentor_id}/users/ using * "Ibl.Analytics/Mentors/read". Grants on the mentor resource itself * cascade to its users (full mentor access). Usergroup authorization * is resolved at platform-level (/platforms/{pk}/usergroups/) — * mentor-level grants do NOT cascade to usergroup access. * * Special case - Mentor owner unfiltered access: * If the requesting user owns the mentor AND no usergroup_ids are * specified, returns None (no filtering) — the analytics query layer is * already scoped to the mentor. With usergroup_ids provided, the owner * falls through to normal RBAC filtering and still needs explicit access * (ownership or grant) to the requested groups. * * Note: Mentor analytics APIs work with platform_key (from query params). * @returns SessionsChart * @throws ApiError */ public static analyticsSessionsRetrieve({ dateFilter = 'today', endDate, granularity = 'hour', mentorUniqueId, metric = 'sessions', platformKey, startDate, usergroupIds, }: { /** * * `today` - Today only * * `7d` - Last 7 days * * `30d` - Last 30 days * * `90d` - Last 90 days * * `all_time` - All time * * `custom` - Custom date range */ dateFilter?: 'today' | '7d' | '30d' | '90d' | 'all_time' | 'custom', endDate?: string, /** * * `day` - day * * `hour` - hour * * `week` - week * * `month` - month */ granularity?: 'day' | 'hour' | 'week' | 'month', mentorUniqueId?: string, /** * * `sessions` - Sessions over time * * `headline` - Headline metrics for sessions (avg messages per session, avg rating) */ metric?: 'sessions' | 'headline', platformKey?: string, startDate?: string, /** * Optional list of usergroup IDs to filter results */ usergroupIds?: Array | null, }): CancelablePromise { return __request(OpenAPI, { method: 'GET', url: '/api/analytics/sessions/', query: { 'date_filter': dateFilter, 'end_date': endDate, 'granularity': granularity, 'mentor_unique_id': mentorUniqueId, 'metric': metric, 'platform_key': platformKey, 'start_date': startDate, 'usergroup_ids': usergroupIds, }, }); } /** * * Time Analytics API - User activity patterns by time of day and day of week. * * Provides heatmap data showing when users are most active, useful for: * - Understanding peak usage times * - Capacity planning and resource allocation * - User behavior analysis * - Support scheduling optimization * * **Key Features:** * - Day of week patterns (0=Sunday through 6=Saturday) * - Hour of day activity levels (0-23) * - Flexible date range filtering * - Platform and agent-specific filtering * - Message count aggregation * * **Data Structure:** * - `day_of_week`: 0-6 (Sunday-Saturday) * - `hour`: 0-23 (24-hour format) * - `value`: Message count for that time slot * * @returns AccessTimesHeatmap Access times heatmap data with day/hour patterns * @throws ApiError */ public static analyticsTimeRetrieve({ dateFilter = 'today', endDate, granularity = 'hour', mentorUniqueId, platformKey, startDate, usergroupIds, }: { /** * * `today` - Today only * * `7d` - Last 7 days * * `30d` - Last 30 days * * `90d` - Last 90 days * * `all_time` - All time * * `custom` - Custom date range */ dateFilter?: 'today' | '7d' | '30d' | '90d' | 'all_time' | 'custom', endDate?: string, /** * * `day` - day * * `hour` - hour * * `week` - week * * `month` - month */ granularity?: 'day' | 'hour' | 'week' | 'month', mentorUniqueId?: string, platformKey?: string, startDate?: string, /** * Optional list of usergroup IDs to filter results */ usergroupIds?: Array | null, }): CancelablePromise { return __request(OpenAPI, { method: 'GET', url: '/api/analytics/time/', query: { 'date_filter': dateFilter, 'end_date': endDate, 'granularity': granularity, 'mentor_unique_id': mentorUniqueId, 'platform_key': platformKey, 'start_date': startDate, 'usergroup_ids': usergroupIds, }, errors: { 400: `Bad Request - Invalid parameters`, 403: `Forbidden - Insufficient permissions`, 500: `Internal Server Error`, }, }); } /** * Returns topics overview analytics for a given platform and agent. * * Permission Required: * - Platform Admin * - Ibl.Analytics/Mentors/read * @returns TopicsOverview * @throws ApiError */ public static analyticsTopicsRetrieve({ dateFilter = 'today', endDate, granularity = 'hour', mentorUniqueId, metric = 'overview', platformKey, startDate, usergroupIds, }: { /** * * `today` - Today only * * `7d` - Last 7 days * * `30d` - Last 30 days * * `90d` - Last 90 days * * `all_time` - All time * * `custom` - Custom date range */ dateFilter?: 'today' | '7d' | '30d' | '90d' | 'all_time' | 'custom', endDate?: string, /** * * `day` - day * * `hour` - hour * * `week` - week * * `month` - month */ granularity?: 'day' | 'hour' | 'week' | 'month', mentorUniqueId?: string, /** * * `overview` - Overall topic metrics * * `sessions` - Sessions over time * * `ratings` - Ratings over time * * `highlighted` - Highlighted topics */ metric?: 'overview' | 'sessions' | 'ratings' | 'highlighted', platformKey?: string, startDate?: string, /** * Optional list of usergroup IDs to filter results */ usergroupIds?: Array | null, }): CancelablePromise { return __request(OpenAPI, { method: 'GET', url: '/api/analytics/topics/', query: { 'date_filter': dateFilter, 'end_date': endDate, 'granularity': granularity, 'mentor_unique_id': mentorUniqueId, 'metric': metric, 'platform_key': platformKey, 'start_date': startDate, 'usergroup_ids': usergroupIds, }, }); } /** * Returns topic details Analytics for a given platform and agent. * * Permission Required: * - Platform Admin * - Ibl.Analytics/Mentors/read * @returns TopicDetails * @throws ApiError */ public static analyticsTopicsDetailsRetrieve({ dateFilter = 'today', endDate, limit = 20, mentorUniqueId, page = 1, platformKey, search, startDate, usergroupIds, }: { /** * * `today` - Today only * * `7d` - Last 7 days * * `30d` - Last 30 days * * `90d` - Last 90 days * * `all_time` - All time * * `custom` - Custom date range */ dateFilter?: 'today' | '7d' | '30d' | '90d' | 'all_time' | 'custom', endDate?: string, limit?: number, mentorUniqueId?: string, page?: number, platformKey?: string, /** * Search by topic name */ search?: string, startDate?: string, /** * Optional list of usergroup IDs to filter results */ usergroupIds?: Array | null, }): CancelablePromise { return __request(OpenAPI, { method: 'GET', url: '/api/analytics/topics/details/', query: { 'date_filter': dateFilter, 'end_date': endDate, 'limit': limit, 'mentor_unique_id': mentorUniqueId, 'page': page, 'platform_key': platformKey, 'search': search, 'start_date': startDate, 'usergroup_ids': usergroupIds, }, }); } /** * * User Analytics API - Comprehensive user activity metrics and trends. * * Provides real-time and historical user analytics including: * - Currently active users (last hour) * - Active users over time periods (7d, 30d, 90d) * - Registered user counts and growth * - Time series charts with customizable granularity * * **Key Features:** * - Real-time active user counting * - Percentage change calculations vs previous periods * - Flexible date filtering and granularity * - Platform and agent-specific filtering * - Forward-filled time series data * * **Supported Metrics:** * - `currently_active`: Users active in last hour * - `active_users`: Unique users in specified period * - `registered_users`: Total and new user counts * * @returns CurrentUsersResponse User analytics metrics with comparison data * @throws ApiError */ public static analyticsUsersRetrieve({ metric, dateFilter = 'today', endDate, granularity = 'hour', mentorUniqueId, platformKey, startDate, usergroupIds, }: { /** * * `currently_active` - Users logged in right now * * `active_users` - Active users in a period * * `registered_users` - Registered users * * `active_users_last_30d` - Active users in the last 30 days */ metric: 'currently_active' | 'active_users' | 'registered_users' | 'active_users_last_30d', /** * * `today` - Today only * * `7d` - Last 7 days * * `30d` - Last 30 days * * `90d` - Last 90 days * * `all_time` - All time * * `custom` - Custom date range */ dateFilter?: 'today' | '7d' | '30d' | '90d' | 'all_time' | 'custom', endDate?: string, /** * * `day` - day * * `hour` - hour * * `week` - week * * `month` - month */ granularity?: 'day' | 'hour' | 'week' | 'month', mentorUniqueId?: string, platformKey?: string, startDate?: string, /** * Optional list of usergroup IDs to filter results */ usergroupIds?: Array | null, }): CancelablePromise { return __request(OpenAPI, { method: 'GET', url: '/api/analytics/users/', query: { 'date_filter': dateFilter, 'end_date': endDate, 'granularity': granularity, 'mentor_unique_id': mentorUniqueId, 'metric': metric, 'platform_key': platformKey, 'start_date': startDate, 'usergroup_ids': usergroupIds, }, errors: { 400: `Bad Request - Invalid parameters`, 403: `Forbidden - Insufficient permissions`, 500: `Internal Server Error`, }, }); } /** * * User Details API - Comprehensive user activity details with search and filtering. * * Provides detailed user information including: * - User contact information (username, email, full name) * - Activity metrics (message count, last activity) * - Search functionality across multiple fields * - Flexible date range filtering * - CSV export capability * * **Key Features:** * - Full-text search across username, email, name, and user ID * - Date range filtering for activity periods * - Platform and agent-specific filtering * - Comprehensive pagination with metadata * - CSV export for data analysis * - User aggregation across platforms/agents * * **Search Capabilities:** * - Username matching * - Email address matching * - Full name search * - User ID lookup * - Partial string matching (case-insensitive) * * **Export Options:** * - JSON response (default) * - CSV export (?export=csv) * - Includes all user fields in export * * @returns UserDetail Paginated user details with activity metrics * @throws ApiError */ public static analyticsUsersDetailsRetrieve({ dateFilter = 'today', endDate, limit = 20, mentorUniqueId, page = 1, platformKey, search, startDate, usergroupIds, }: { /** * * `today` - Today only * * `7d` - Last 7 days * * `30d` - Last 30 days * * `90d` - Last 90 days * * `all_time` - All time * * `custom` - Custom date range */ dateFilter?: 'today' | '7d' | '30d' | '90d' | 'all_time' | 'custom', endDate?: string, limit?: number, mentorUniqueId?: string, page?: number, platformKey?: string, /** * Search by email, full name, or user ID */ search?: string, startDate?: string, /** * Optional list of usergroup IDs to filter results */ usergroupIds?: Array | null, }): CancelablePromise { return __request(OpenAPI, { method: 'GET', url: '/api/analytics/users/details/', query: { 'date_filter': dateFilter, 'end_date': endDate, 'limit': limit, 'mentor_unique_id': mentorUniqueId, 'page': page, 'platform_key': platformKey, 'search': search, 'start_date': startDate, 'usergroup_ids': usergroupIds, }, errors: { 400: `Bad Request - Invalid parameters`, 403: `Forbidden - Insufficient permissions`, 500: `Internal Server Error`, }, }); } }