Skip to content

SanaAI Source

The SanaAI source extracts insight reports from Sana’s learning platform using the query-based reporting API.

Terminal window
pip install bizon[sana_ai]
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-bucket
StreamDescriptionIncremental
insight_reportQuery-based insight reportsNo
FieldTypeRequiredDescription
domainstringYesSana instance domain (e.g., company for company.sana.ai)
querystringYesSQL-like query for the insight report

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/token

To get OAuth credentials:

  1. Contact your Sana administrator
  2. Request API access with OAuth credentials
  3. You’ll receive a client_id and client_secret

The SanaAI source uses an asynchronous job pattern:

  1. Create Job: Submits a query to create an insight report job
  2. Poll Status: Polls the job status until completion
  3. Download Results: Downloads the CSV results when ready
  4. Parse Data: Parses CSV into records

This pattern handles large reports that may take time to generate.

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-bucket

The query field accepts Sana’s insight query syntax. Consult your Sana documentation for available tables and fields.

Example queries:

-- All users
SELECT * FROM users
-- Active users with completions
SELECT user_id, email, course_completions
FROM users
WHERE active = true
-- Course progress
SELECT course_id, user_id, progress, completed_at
FROM course_progress
WHERE completed_at IS NOT NULL

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:

FieldDescription
user_idUser ID
emailUser email
nameUser name

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'
}