In this article
Overview
Pensero connects to Gemini Code Assist to make AI-assisted work visible at team and company level. AI usage on its own is not the goal. Pensero aligns Gemini usage with real delivery signals so teams can understand when AI increases output and when it adds defects or rework.
What Pensero Reads from Gemini Code Assist
Pensero ingests Gemini Code Assist analytics only. It does not access source code. Data is retrieved from your Google Cloud project via the Cloud Monitoring API and includes:
Estimated AI-assisted lines of code
Total lines added and removed
Coding sessions and commit activity
User identifiers
Timestamps for AI events
Pensero aligns these insights with Git contribution data to ensure accurate calculations.
How We Calculate AI Usage
Pensero estimates AI adoption using a directional proxy, not exact code authorship attribution.
AI usage % = Accepted AI-suggested lines ÷ Total committed lines
Important clarifications:
This metric is designed to track adoption trends over time, not to audit individual lines of code.
Different AI tools report usage differently. Pensero focuses on a consistent, comparable signal.
The goal is to understand how AI affects delivery and quality, not to maximize the percentage.
Where to find this data in Pensero
Where you’ll see this in Pensero
Gemini usage appears as a directional signal across:
Charts: AI usage trend over time
Teams: Adoption by team, compared with delivery and quality
People: Adoption by contributor (use for coaching, not ranking)
Locations: Adoption patterns by region, when applicable
Choose your setup path
Pensero supports two connection methods for Gemini Code Assist.
| OAuth | Service account |
Best for | Small teams, quick setup | Enterprise, automation |
Auth | Google login (browser) | JSON key file |
Session expiry | Needs trusted app config | No re-auth required |
Requires | Google Workspace admin | GCP IAM permissions |
Choose OAuth if you want the fastest path and are comfortable configuring Pensero as a trusted app in Google Workspace Admin.
Choose service account if you want a stable long-lived connection that doesn't depend on user sessions.
Before you start (both methods)
- Pensero Admin access
- A GCP project with Gemini Code Assist enabled
- Cloud Monitoring API active on that project
- Permission to authorise access for your Google Workspace org
Only GCP projects with both Gemini Code Assist and the Cloud Monitoring API enabled will appear in the project dropdown during OAuth setup.
Connect Gemini Code Assist via OAuth
Step 1 — Open the integration
Go to Integrations in the Pensero sidebar. Find Gemini Code Assist, click the Connect dropdown, and select OAuth.
Step 2 — Authorise with Google
You'll be redirected to a Google login screen. Sign in and grant Pensero access to your Google Cloud project.
Step 3 — Select your GCP project
Pick the project from the dropdown and click Connect.
If the dropdown is empty, check that the Cloud Monitoring API is enabled in the Google Cloud Console.
Step 4 — Confirm
Pensero begins syncing automatically. Check status under Integrations → Gemini → Sync Log.
Connect Gemini Code Assist via service account
Service account is recommended for enterprise setups. It uses a long-lived JSON key and avoids OAuth token expiry issues.
There are two ways to get set up:
Automated script - Pensero provides a script that configures your GCP project in one step. It enables the required APIs, turns on metadata logging, and sets up IAM roles automatically. Find it under Integrations → Gemini Code Assist → Connect → Service account → Automated setup script
Manual setup - follow the step-by-step instructions below if you prefer to configure each part yourself or need more control over the GCP settings.
Part 1 — Configure your GCP project
1. Confirm billing is enabled
Billing must be active on your GCP project before you can enable APIs.
2. Enable required APIs
In the Google Cloud Console, enable:
cloudaicompanion.googleapis.com— Gemini Code Assistmonitoring.googleapis.com— Cloud Monitoringlogging.googleapis.com— Cloud Logging
3. Enable metadata logging
Run this command, replacing YOUR_PROJECT with your GCP project ID:
curl -s -X PATCH -H "Authorization: Bearer $(gcloud auth print-access-token)" -H "Content-Type: application/json" -d '{ "logMetadata": true }' "https://cloudaicompanion.googleapis.com/v1/projects/YOUR_PROJECT/locations/global/loggingSettings/YOUR_PROJECT?updateMask=logMetadata"4. Create a service account
Go to IAM & Admin → Service Accounts and create a new account (or use an existing one).
5. Grant IAM roles
Assign the service account:
roles/monitoring.viewerroles/logging.viewer
Or create a custom role with these permissions:
monitoring.metricDescriptors.listmonitoring.timeSeries.listlogging.logEntries.list
6. Download a JSON key
In the service account, go to Keys → Add Key → Create new key → JSON. Save the file securely.
7. Grant developer access
Assign roles/cloudaicompanion.user to any developer whose Gemini usage should be tracked.
Part 2 — Connect in Pensero
1. Open the integration
Go to Integrations, find Gemini Code Assist, click Connect, and select Service account.
2. Paste your JSON key
Open the key file and paste the full contents into the Service account JSON key field. Include the outer { } braces — don't modify the JSON.
3. Enter your GCP Project ID
Enter the Project ID (not the display name) of the GCP project where Gemini Code Assist is enabled. To find it: open the Google Cloud Console, click the project selector in the top bar, and look at the ID column.
4. Click Connect
Pensero validates your credentials and starts syncing.
Developer IDE setup for Gemini Code Assist
This step is only required if you connected through a service account.
Each developer needs to point their IDE at the correct GCP project ID so Gemini usage is attributed to the right project in Pensero.
JetBrains (IntelliJ, PyCharm, WebStorm, etc.)
Open Settings —
File → Settingson Windows/Linux, orIntelliJ IDEA → Settingson macOSGo to Tools → Gemini
Under Google Cloud project, enter your GCP Project ID
Click Apply, then OK
VS Code
Open Settings —
File → Preferences → Settingsor pressCmd/Ctrl + ,Search for Gemini Cloud project
Enter the same Project ID used in your Pensero integration
How to find your Project ID
Go to console.cloud.google.com
Click the project selector in the top navigation bar
Look at the ID column in the resource picker
Troubleshooting
Fixing "Error Fetching Gemini Usage"
This error typically appears 16–24 hours after OAuth setup. You may see Sync Failures with the error: "Error fetching Gemini usage for range [date] to [date].
It means Google Workspace is expiring the OAuth token because Pensero isn't marked as a trusted app.
Step 1 — Exempt trusted apps in session control
You need Super Admin access to complete this.
Confirm Require reauthentication is selected
Check Exempt Trusted Apps
Save
This tells Google Workspace to skip reauthentication for trusted apps — which Pensero will become once you complete Step 2.
Step 2 — Mark Pensero as trusted
Find Pensero in the list
Set trust status to Trusted
Save
Once saved, Pensero is exempt from reauthentication and syncs resume automatically at the next scheduled run.






