Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

## [Unreleased]

### Added
- [EE] Add Ask chat usage metrics to analytics dashboard [#736](https://github.com/sourcebot-dev/sourcebot/pull/736)

## [4.10.9] - 2026-01-14

### Changed
Expand Down
1 change: 1 addition & 0 deletions docs/docs/configuration/audit-logs.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,7 @@ curl --request GET '$SOURCEBOT_URL/api/ee/audit' \
| `user.performed_code_search` | `user` | `org` |
| `user.performed_find_references` | `user` | `org` |
| `user.performed_goto_definition` | `user` | `org` |
| `user.created_ask_chat` | `user` | `org` |
| `user.jit_provisioning_failed` | `user` | `org` |
| `user.jit_provisioned` | `user` | `org` |
| `user.join_request_creation_failed` | `user` | `org` |
Expand Down
13 changes: 2 additions & 11 deletions docs/docs/features/analytics.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -31,21 +31,12 @@ This dashboard is backed by [audit log](/docs/configuration/audit-logs) events.
Tracks the number of unique users who performed any Sourcebot operation within each time period. This metric helps you understand team adoption
and engagement with Sourcebot.

![DAU Chart](/images/dau_chart.png)

### Code Searches
Counts the number of code search operations performed by your team.

![Code Search Chart](/images/code_search_chart.png)

### Code Navigation
Tracks "Go to Definition" and "Find All References" navigation actions. Navigation actions help developers quickly move
between code locations and understand code relationships.

![Code Nav Chart](/images/code_nav_chart.png)

## Cost Savings Calculator

The analytics dashboard includes a built-in cost savings calculator that helps you quantify the ROI of using Sourcebot.

![Cost Savings Chart](/images/cost_savings_chart.png)
### Ask Chats
Tracks the number of new Ask chat sessions created by your team.
Binary file modified docs/images/analytics_demo.mp4
Binary file not shown.
Binary file removed docs/images/code_nav_chart.png
Binary file not shown.
Binary file removed docs/images/code_search_chart.png
Binary file not shown.
Binary file removed docs/images/dau_chart.png
Binary file not shown.
34 changes: 33 additions & 1 deletion packages/db/tools/scripts/inject-audit-data.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,8 @@ export const injectAuditData: Script = {
const actions = [
'user.performed_code_search',
'user.performed_find_references',
'user.performed_goto_definition'
'user.performed_goto_definition',
'user.created_ask_chat'
];

// Generate data for the last 90 days
Expand Down Expand Up @@ -119,6 +120,37 @@ export const injectAuditData: Script = {
}
});
}

// Generate Ask chat sessions (0-2 per day on weekdays, 0-1 on weekends)
const askChats = isWeekend
? Math.floor(Math.random() * 2) // 0-1 on weekends
: Math.floor(Math.random() * 3); // 0-2 on weekdays

// Create Ask chat records
for (let i = 0; i < askChats; i++) {
const timestamp = new Date(currentDate);
if (isWeekend) {
timestamp.setHours(9 + Math.floor(Math.random() * 12));
timestamp.setMinutes(Math.floor(Math.random() * 60));
} else {
timestamp.setHours(9 + Math.floor(Math.random() * 9));
timestamp.setMinutes(Math.floor(Math.random() * 60));
}
timestamp.setSeconds(Math.floor(Math.random() * 60));

await prisma.audit.create({
data: {
timestamp,
action: 'user.created_ask_chat',
actorId: userId,
actorType: 'user',
targetId: orgId.toString(),
targetType: 'org',
sourcebotVersion: '1.0.0',
orgId
}
});
}
}
}

Expand Down
5 changes: 4 additions & 1 deletion packages/web/src/ee/features/analytics/actions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,8 @@ export const getAnalytics = async (domain: string, apiKey: string | undefined =
AND action IN (
'user.performed_code_search',
'user.performed_find_references',
'user.performed_goto_definition'
'user.performed_goto_definition',
'user.created_ask_chat'
)
),

Expand Down Expand Up @@ -77,6 +78,7 @@ export const getAnalytics = async (domain: string, apiKey: string | undefined =
END AS bucket,
COUNT(*) FILTER (WHERE c.action = 'user.performed_code_search') AS code_searches,
COUNT(*) FILTER (WHERE c.action IN ('user.performed_find_references', 'user.performed_goto_definition')) AS navigations,
COUNT(*) FILTER (WHERE c.action = 'user.created_ask_chat') AS ask_chats,
COUNT(DISTINCT c."actorId") AS active_users
FROM core c
JOIN LATERAL (
Expand All @@ -90,6 +92,7 @@ export const getAnalytics = async (domain: string, apiKey: string | undefined =
b.bucket,
COALESCE(a.code_searches, 0)::int AS code_searches,
COALESCE(a.navigations, 0)::int AS navigations,
COALESCE(a.ask_chats, 0)::int AS ask_chats,
COALESCE(a.active_users, 0)::int AS active_users
FROM buckets b
LEFT JOIN aggregated a
Expand Down
Loading