SanaAI Source
The SanaAI source extracts insight reports from Sana’s learning platform using the query-based reporting API.
Installation
Section titled “Installation”pip install bizon[sana_ai]Quick 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: client_id: your-client-id client_secret: BIZON_ENV_SANA_SECRET token_url: https://your-company.sana.ai/oauth/token
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 |
Authentication
Section titled “Authentication”SanaAI uses OAuth2 authentication:
source: name: sana_ai stream: insight_report domain: your-company query: "SELECT * FROM users" authentication: type: oauth params: client_id: your-client-id client_secret: BIZON_ENV_SANA_SECRET token_url: https://your-company.sana.ai/oauth/tokenTo 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 until completion
- Download Results: Downloads the CSV results when ready
- Parse Data: Parses CSV into records
This pattern handles large reports that may take time 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: client_id: your-client-id client_secret: BIZON_ENV_SANA_SECRET token_url: https://acme-corp.sana.ai/oauth/token
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