SanaAI Source
The SanaAI source extracts insight reports from Sana’s learning platform using the query-based reporting API.
Installation
Section titled “Installation”The SanaAI source ships with the core package; no extra is needed.
pip install bizonQuick Start
Section titled “Quick Start”name: sana-pipeline
source: name: sana_ai stream: insight_report domain: your-company query: "SELECT * FROM users WHERE active = true" authentication: type: oauth params: token_refresh_endpoint: https://your-company.sana.ai/api/token client_id: ${env://SANA_CLIENT_ID} client_secret: ${env://SANA_CLIENT_SECRET} grant_type: client_credentials access_token_name: accessToken expires_in_name: expiresIn response_field_path: data scopes: - read - write
destination: name: bigquery config: project_id: my-project dataset_id: learning gcs_buffer_bucket: my-bucketAvailable Streams
Section titled “Available Streams”| Stream | Description | Incremental |
|---|---|---|
insight_report | Query-based insight reports | No |
Configuration
Section titled “Configuration”Source Configuration
Section titled “Source Configuration”| Field | Type | Required | Description |
|---|---|---|---|
domain | string | Yes | Sana instance domain (e.g., company for company.sana.ai) |
query | string | Yes | SQL-like query for the insight report |
report_job_max_wait_seconds | int | No | Fail if the report job hasn’t succeeded after this many seconds (default 600) |
http | object | No | HTTP policy (default: (10, 60) timeout, retries on 429/5xx) |
Authentication
Section titled “Authentication”SanaAI uses OAuth2 client credentials. Sana’s token endpoint returns accessToken / expiresIn under data, hence the extra params:
source: name: sana_ai stream: insight_report domain: your-company query: "SELECT * FROM users" authentication: type: oauth params: token_refresh_endpoint: https://your-company.sana.ai/api/token client_id: ${env://SANA_CLIENT_ID} client_secret: ${env://SANA_CLIENT_SECRET} grant_type: client_credentials access_token_name: accessToken expires_in_name: expiresIn response_field_path: data scopes: - read - writeTo get OAuth credentials:
- Contact your Sana administrator
- Request API access with OAuth credentials
- You’ll receive a
client_idandclient_secret
How It Works
Section titled “How It Works”The SanaAI source uses an asynchronous job pattern:
- Create Job: Submits a query to create an insight report job
- Poll Status: Polls the job status every 3 seconds until it succeeds
- Download Results: Downloads the CSV results when ready
- Parse Data: Parses CSV into records
The run fails with a SanaReportJobError if the job reports failed, or if it is still pending after report_job_max_wait_seconds. Raise the limit for reports that take longer than 10 minutes to generate.
Example Configuration
Section titled “Example Configuration”User Activity Report
Section titled “User Activity Report”name: sana-user-activity
source: name: sana_ai stream: insight_report domain: acme-corp query: | SELECT user_id, email, course_completions, last_activity_date FROM user_activity WHERE last_activity_date >= '2024-01-01' authentication: type: oauth params: token_refresh_endpoint: https://acme-corp.sana.ai/api/token client_id: ${env://SANA_CLIENT_ID} client_secret: ${env://SANA_CLIENT_SECRET} grant_type: client_credentials access_token_name: accessToken expires_in_name: expiresIn response_field_path: data scopes: - read - write
destination: name: bigquery config: project_id: my-project dataset_id: learning dataset_location: US gcs_buffer_bucket: my-staging-bucketQuery Syntax
Section titled “Query Syntax”The query field accepts Sana’s insight query syntax. Consult your Sana documentation for available tables and fields.
Example queries:
-- All usersSELECT * FROM users
-- Active users with completionsSELECT user_id, email, course_completionsFROM usersWHERE active = true
-- Course progressSELECT course_id, user_id, progress, completed_atFROM course_progressWHERE completed_at IS NOT NULLData Structure
Section titled “Data Structure”Records are returned as CSV rows converted to dictionaries. The schema depends on your query’s SELECT columns.
Example record for SELECT user_id, email, name FROM users:
| Field | Description |
|---|---|
user_id | User ID |
email | User email |
name | User name |
Transforms
Section titled “Transforms”Process insight data:
transforms: - label: normalize-fields python: | data = { 'user_id': data.get('user_id'), 'email': data.get('email', '').lower(), 'name': data.get('name'), 'is_active': data.get('active', '').lower() == 'true' }Next Steps
Section titled “Next Steps”- Sources Overview - Learn about source connectors
- Authentication - Configure OAuth
- Transforms - Transform extracted data