From ef4245774aa9d93d7d46040f34343a3d2e38f52b Mon Sep 17 00:00:00 2001 From: cocosheng-g Date: Fri, 6 Mar 2026 12:07:31 -0500 Subject: [PATCH 1/9] feat: add GitHub Action usage metrics for telemetry --- action.yml | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/action.yml b/action.yml index 70ef1b1e1..fe07f57fc 100644 --- a/action.yml +++ b/action.yml @@ -231,6 +231,9 @@ runs: GEMINI_CLI_VERSION: '${{ inputs.gemini_cli_version }}' EXTENSIONS: '${{ inputs.extensions }}' USE_PNPM: '${{ inputs.use_pnpm }}' + SURFACE: 'GH' + GH_WORKFLOW_NAME: '${{ steps.sanitize_workflow_name.outputs.gh_workflow_name }}' + GH_EVENT_NUMBER: '${{ github.event.issue.number || github.event.pull_request.number }}' shell: 'bash' run: |- set -euo pipefail @@ -404,7 +407,7 @@ runs: env: GEMINI_DEBUG: '${{ fromJSON(inputs.gemini_debug || false) }}' GEMINI_API_KEY: '${{ inputs.gemini_api_key }}' - SURFACE: 'GitHub' + SURFACE: 'GH' GOOGLE_CLOUD_PROJECT: '${{ inputs.gcp_project_id }}' GOOGLE_CLOUD_LOCATION: '${{ inputs.gcp_location }}' GOOGLE_GENAI_USE_VERTEXAI: '${{ inputs.use_vertex_ai }}' @@ -414,6 +417,7 @@ runs: PROMPT: '${{ inputs.prompt }}' GEMINI_MODEL: '${{ inputs.gemini_model }}' GH_WORKFLOW_NAME: '${{ steps.sanitize_workflow_name.outputs.gh_workflow_name }}' + GH_EVENT_NUMBER: '${{ github.event.issue.number || github.event.pull_request.number }}' - name: 'Upload Gemini CLI outputs' if: |- From 2a0ba320784835dbfc6363634e16ba02bb572c25 Mon Sep 17 00:00:00 2001 From: cocosheng-g Date: Fri, 6 Mar 2026 12:08:13 -0500 Subject: [PATCH 2/9] feat: enhance telemetry with GitHub event number for both Clearcut and OTLP --- action.yml | 2 ++ scripts/collector-gcp.yaml.template | 3 +++ 2 files changed, 5 insertions(+) diff --git a/action.yml b/action.yml index fe07f57fc..d750f198f 100644 --- a/action.yml +++ b/action.yml @@ -444,6 +444,7 @@ runs: sed -e "s#OTLP_GOOGLE_CLOUD_PROJECT#${OTLP_GOOGLE_CLOUD_PROJECT}#g" \ -e "s#GITHUB_REPOSITORY_PLACEHOLDER#${GITHUB_REPOSITORY}#g" \ -e "s#GITHUB_RUN_ID_PLACEHOLDER#${GITHUB_RUN_ID}#g" \ + -e "s#GITHUB_EVENT_NUMBER_PLACEHOLDER#${GITHUB_EVENT_NUMBER}#g" \ "${GITHUB_ACTION_PATH}/scripts/collector-gcp.yaml.template" > ".gemini/collector-gcp.yaml" # Ensure credentials file has the right permissions @@ -494,6 +495,7 @@ runs: GITHUB_ACTION_PATH: '${{ github.action_path }}' GITHUB_REPOSITORY: '${{ github.repository }}' GITHUB_RUN_ID: '${{ github.run_id }}' + GITHUB_EVENT_NUMBER: '${{ github.event.issue.number || github.event.pull_request.number }}' branding: icon: 'terminal' diff --git a/scripts/collector-gcp.yaml.template b/scripts/collector-gcp.yaml.template index ba3c157d5..bab3728fa 100644 --- a/scripts/collector-gcp.yaml.template +++ b/scripts/collector-gcp.yaml.template @@ -12,6 +12,9 @@ processors: - key: 'github.run_id' value: 'GITHUB_RUN_ID_PLACEHOLDER' action: 'upsert' + - key: 'github.event.number' + value: 'GITHUB_EVENT_NUMBER_PLACEHOLDER' + action: 'upsert' batch: send_batch_size: 100 timeout: '10s' From 9bc71a59e454f52f6a98965adf04cbac73d2f3c0 Mon Sep 17 00:00:00 2001 From: cocosheng-g Date: Fri, 6 Mar 2026 12:11:18 -0500 Subject: [PATCH 3/9] refactor: introduce explicit github_item_number input for precise telemetry tracking across different workflows --- action.yml | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/action.yml b/action.yml index d750f198f..c7c4ffb90 100644 --- a/action.yml +++ b/action.yml @@ -91,6 +91,10 @@ inputs: description: 'The GitHub workflow name, used for telemetry purposes.' required: false default: '${{ github.workflow }}' + github_item_number: + description: 'The Issue or Pull Request number the CLI is operating on. Useful for tracking unique item usage in telemetry. Defaults to the event payload.' + required: false + default: '${{ github.event.issue.number || github.event.pull_request.number }}' outputs: summary: @@ -233,7 +237,7 @@ runs: USE_PNPM: '${{ inputs.use_pnpm }}' SURFACE: 'GH' GH_WORKFLOW_NAME: '${{ steps.sanitize_workflow_name.outputs.gh_workflow_name }}' - GH_EVENT_NUMBER: '${{ github.event.issue.number || github.event.pull_request.number }}' + GH_EVENT_NUMBER: '${{ inputs.github_item_number }}' shell: 'bash' run: |- set -euo pipefail @@ -417,7 +421,7 @@ runs: PROMPT: '${{ inputs.prompt }}' GEMINI_MODEL: '${{ inputs.gemini_model }}' GH_WORKFLOW_NAME: '${{ steps.sanitize_workflow_name.outputs.gh_workflow_name }}' - GH_EVENT_NUMBER: '${{ github.event.issue.number || github.event.pull_request.number }}' + GH_EVENT_NUMBER: '${{ inputs.github_item_number }}' - name: 'Upload Gemini CLI outputs' if: |- @@ -495,7 +499,7 @@ runs: GITHUB_ACTION_PATH: '${{ github.action_path }}' GITHUB_REPOSITORY: '${{ github.repository }}' GITHUB_RUN_ID: '${{ github.run_id }}' - GITHUB_EVENT_NUMBER: '${{ github.event.issue.number || github.event.pull_request.number }}' + GITHUB_EVENT_NUMBER: '${{ inputs.github_item_number }}' branding: icon: 'terminal' From 3b79ee763157fa8d796f746628cd29d25e7114f2 Mon Sep 17 00:00:00 2001 From: cocosheng-g Date: Fri, 6 Mar 2026 12:14:47 -0500 Subject: [PATCH 4/9] docs(examples): map scheduled batch issues to github_item_number for correct P0 telemetry --- examples/workflows/issue-triage/gemini-scheduled-triage.yml | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/examples/workflows/issue-triage/gemini-scheduled-triage.yml b/examples/workflows/issue-triage/gemini-scheduled-triage.yml index a8dd34a47..bd6c452fa 100644 --- a/examples/workflows/issue-triage/gemini-scheduled-triage.yml +++ b/examples/workflows/issue-triage/gemini-scheduled-triage.yml @@ -82,6 +82,9 @@ jobs: echo '📝 Setting output for GitHub Actions...' echo "issues_to_triage=${ISSUES}" >> "${GITHUB_OUTPUT}" + ISSUE_NUMBERS="$(echo "${ISSUES}" | jq -r '.[].number | tostring' | paste -sd, -)" + echo "issue_numbers=${ISSUE_NUMBERS}" >> "${GITHUB_OUTPUT}" + ISSUE_COUNT="$(echo "${ISSUES}" | jq 'length')" echo "✅ Found ${ISSUE_COUNT} issue(s) to triage! 🎯" @@ -109,6 +112,7 @@ jobs: use_vertex_ai: '${{ vars.GOOGLE_GENAI_USE_VERTEXAI }}' upload_artifacts: '${{ vars.UPLOAD_ARTIFACTS }}' workflow_name: 'gemini-scheduled-triage' + github_item_number: '${{ steps.find_issues.outputs.issue_numbers }}' settings: |- { "model": { From 6303b9226e7256439cabf1018f284cc7e5203b57 Mon Sep 17 00:00:00 2001 From: cocosheng-g Date: Fri, 6 Mar 2026 12:16:38 -0500 Subject: [PATCH 5/9] revert: keep SURFACE as 'GitHub' to avoid breaking downstream telemetry pipelines --- action.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/action.yml b/action.yml index c7c4ffb90..637f054d0 100644 --- a/action.yml +++ b/action.yml @@ -235,7 +235,7 @@ runs: GEMINI_CLI_VERSION: '${{ inputs.gemini_cli_version }}' EXTENSIONS: '${{ inputs.extensions }}' USE_PNPM: '${{ inputs.use_pnpm }}' - SURFACE: 'GH' + SURFACE: 'GitHub' GH_WORKFLOW_NAME: '${{ steps.sanitize_workflow_name.outputs.gh_workflow_name }}' GH_EVENT_NUMBER: '${{ inputs.github_item_number }}' shell: 'bash' @@ -411,7 +411,7 @@ runs: env: GEMINI_DEBUG: '${{ fromJSON(inputs.gemini_debug || false) }}' GEMINI_API_KEY: '${{ inputs.gemini_api_key }}' - SURFACE: 'GH' + SURFACE: 'GitHub' GOOGLE_CLOUD_PROJECT: '${{ inputs.gcp_project_id }}' GOOGLE_CLOUD_LOCATION: '${{ inputs.gcp_location }}' GOOGLE_GENAI_USE_VERTEXAI: '${{ inputs.use_vertex_ai }}' From fe91504e2168cd77f9fc8b04774ad0a07a9a8bd9 Mon Sep 17 00:00:00 2001 From: cocosheng-g Date: Fri, 6 Mar 2026 12:20:54 -0500 Subject: [PATCH 6/9] docs(examples): explicitly pass github_item_number in all example workflows to improve clarity --- examples/workflows/gemini-assistant/gemini-invoke.yml | 1 + examples/workflows/gemini-assistant/gemini-plan-execute.yml | 1 + examples/workflows/issue-triage/gemini-triage.yml | 1 + examples/workflows/pr-review/gemini-review.yml | 1 + 4 files changed, 4 insertions(+) diff --git a/examples/workflows/gemini-assistant/gemini-invoke.yml b/examples/workflows/gemini-assistant/gemini-invoke.yml index 5b8e9f336..8d4ac5f30 100644 --- a/examples/workflows/gemini-assistant/gemini-invoke.yml +++ b/examples/workflows/gemini-assistant/gemini-invoke.yml @@ -66,6 +66,7 @@ jobs: use_vertex_ai: '${{ vars.GOOGLE_GENAI_USE_VERTEXAI }}' upload_artifacts: '${{ vars.UPLOAD_ARTIFACTS }}' workflow_name: 'gemini-invoke' + github_item_number: '${{ github.event.pull_request.number || github.event.issue.number }}' settings: |- { "model": { diff --git a/examples/workflows/gemini-assistant/gemini-plan-execute.yml b/examples/workflows/gemini-assistant/gemini-plan-execute.yml index f3b123f91..0751baaaf 100644 --- a/examples/workflows/gemini-assistant/gemini-plan-execute.yml +++ b/examples/workflows/gemini-assistant/gemini-plan-execute.yml @@ -68,6 +68,7 @@ jobs: use_vertex_ai: '${{ vars.GOOGLE_GENAI_USE_VERTEXAI }}' upload_artifacts: '${{ vars.UPLOAD_ARTIFACTS }}' workflow_name: 'gemini-invoke' + github_item_number: '${{ github.event.pull_request.number || github.event.issue.number }}' settings: |- { "model": { diff --git a/examples/workflows/issue-triage/gemini-triage.yml b/examples/workflows/issue-triage/gemini-triage.yml index 93acc688a..40693af1d 100644 --- a/examples/workflows/issue-triage/gemini-triage.yml +++ b/examples/workflows/issue-triage/gemini-triage.yml @@ -79,6 +79,7 @@ jobs: use_vertex_ai: '${{ vars.GOOGLE_GENAI_USE_VERTEXAI }}' upload_artifacts: '${{ vars.UPLOAD_ARTIFACTS }}' workflow_name: 'gemini-triage' + github_item_number: '${{ github.event.issue.number || github.event.pull_request.number }}' settings: |- { "model": { diff --git a/examples/workflows/pr-review/gemini-review.yml b/examples/workflows/pr-review/gemini-review.yml index 28313594f..497d91393 100644 --- a/examples/workflows/pr-review/gemini-review.yml +++ b/examples/workflows/pr-review/gemini-review.yml @@ -65,6 +65,7 @@ jobs: use_vertex_ai: '${{ vars.GOOGLE_GENAI_USE_VERTEXAI }}' upload_artifacts: '${{ vars.UPLOAD_ARTIFACTS }}' workflow_name: 'gemini-review' + github_item_number: '${{ github.event.pull_request.number || github.event.issue.number }}' settings: |- { "model": { From 3bb8f02e0d23d9da88c34f36e72b104080031921 Mon Sep 17 00:00:00 2001 From: cocosheng-g Date: Fri, 6 Mar 2026 12:36:54 -0500 Subject: [PATCH 7/9] refactor: transition to specific PR, Issue, and Custom Tracking ID inputs for strongly-typed telemetry --- action.yml | 29 ++++-- .../gemini-assistant/gemini-invoke.yml | 3 +- .../gemini-assistant/gemini-plan-execute.yml | 3 +- .../issue-triage/gemini-scheduled-triage.yml | 2 +- .../workflows/issue-triage/gemini-triage.yml | 2 +- .../workflows/pr-review/gemini-review.yml | 2 +- gemini_cli_pr_body.md | 94 +++++++++++++++++++ patch.diff | 18 ++++ patch2.diff | 69 ++++++++++++++ pr_body.md | 72 ++++++++++++++ scripts/collector-gcp.yaml.template | 10 +- 11 files changed, 290 insertions(+), 14 deletions(-) create mode 100644 gemini_cli_pr_body.md create mode 100644 patch.diff create mode 100644 patch2.diff create mode 100644 pr_body.md diff --git a/action.yml b/action.yml index 637f054d0..c2f0fd330 100644 --- a/action.yml +++ b/action.yml @@ -91,10 +91,17 @@ inputs: description: 'The GitHub workflow name, used for telemetry purposes.' required: false default: '${{ github.workflow }}' - github_item_number: - description: 'The Issue or Pull Request number the CLI is operating on. Useful for tracking unique item usage in telemetry. Defaults to the event payload.' + github_pr_number: + description: 'The Pull Request number the CLI is operating on. Defaults to the event payload.' + required: false + default: '${{ github.event.pull_request.number }}' + github_issue_number: + description: 'The Issue number the CLI is operating on. Defaults to the event payload.' + required: false + default: '${{ github.event.issue.number }}' + github_custom_tracking_id: + description: 'A custom tracking ID (e.g. comma-separated list of issue IDs for scheduled batches).' required: false - default: '${{ github.event.issue.number || github.event.pull_request.number }}' outputs: summary: @@ -237,7 +244,9 @@ runs: USE_PNPM: '${{ inputs.use_pnpm }}' SURFACE: 'GitHub' GH_WORKFLOW_NAME: '${{ steps.sanitize_workflow_name.outputs.gh_workflow_name }}' - GH_EVENT_NUMBER: '${{ inputs.github_item_number }}' + GH_PR_NUMBER: '${{ inputs.github_pr_number }}' + GH_ISSUE_NUMBER: '${{ inputs.github_issue_number }}' + GH_CUSTOM_TRACKING_ID: '${{ inputs.github_custom_tracking_id }}' shell: 'bash' run: |- set -euo pipefail @@ -421,7 +430,9 @@ runs: PROMPT: '${{ inputs.prompt }}' GEMINI_MODEL: '${{ inputs.gemini_model }}' GH_WORKFLOW_NAME: '${{ steps.sanitize_workflow_name.outputs.gh_workflow_name }}' - GH_EVENT_NUMBER: '${{ inputs.github_item_number }}' + GH_PR_NUMBER: '${{ inputs.github_pr_number }}' + GH_ISSUE_NUMBER: '${{ inputs.github_issue_number }}' + GH_CUSTOM_TRACKING_ID: '${{ inputs.github_custom_tracking_id }}' - name: 'Upload Gemini CLI outputs' if: |- @@ -448,7 +459,9 @@ runs: sed -e "s#OTLP_GOOGLE_CLOUD_PROJECT#${OTLP_GOOGLE_CLOUD_PROJECT}#g" \ -e "s#GITHUB_REPOSITORY_PLACEHOLDER#${GITHUB_REPOSITORY}#g" \ -e "s#GITHUB_RUN_ID_PLACEHOLDER#${GITHUB_RUN_ID}#g" \ - -e "s#GITHUB_EVENT_NUMBER_PLACEHOLDER#${GITHUB_EVENT_NUMBER}#g" \ + -e "s#GITHUB_PR_NUMBER_PLACEHOLDER#${GITHUB_PR_NUMBER}#g" \ + -e "s#GITHUB_ISSUE_NUMBER_PLACEHOLDER#${GITHUB_ISSUE_NUMBER}#g" \ + -e "s#GITHUB_CUSTOM_TRACKING_ID_PLACEHOLDER#${GITHUB_CUSTOM_TRACKING_ID}#g" \ "${GITHUB_ACTION_PATH}/scripts/collector-gcp.yaml.template" > ".gemini/collector-gcp.yaml" # Ensure credentials file has the right permissions @@ -499,7 +512,9 @@ runs: GITHUB_ACTION_PATH: '${{ github.action_path }}' GITHUB_REPOSITORY: '${{ github.repository }}' GITHUB_RUN_ID: '${{ github.run_id }}' - GITHUB_EVENT_NUMBER: '${{ inputs.github_item_number }}' + GITHUB_PR_NUMBER: '${{ inputs.github_pr_number }}' + GITHUB_ISSUE_NUMBER: '${{ inputs.github_issue_number }}' + GITHUB_CUSTOM_TRACKING_ID: '${{ inputs.github_custom_tracking_id }}' branding: icon: 'terminal' diff --git a/examples/workflows/gemini-assistant/gemini-invoke.yml b/examples/workflows/gemini-assistant/gemini-invoke.yml index 8d4ac5f30..90bead83c 100644 --- a/examples/workflows/gemini-assistant/gemini-invoke.yml +++ b/examples/workflows/gemini-assistant/gemini-invoke.yml @@ -66,7 +66,8 @@ jobs: use_vertex_ai: '${{ vars.GOOGLE_GENAI_USE_VERTEXAI }}' upload_artifacts: '${{ vars.UPLOAD_ARTIFACTS }}' workflow_name: 'gemini-invoke' - github_item_number: '${{ github.event.pull_request.number || github.event.issue.number }}' + github_pr_number: '${{ github.event.pull_request.number }}' + github_issue_number: '${{ github.event.issue.number }}' settings: |- { "model": { diff --git a/examples/workflows/gemini-assistant/gemini-plan-execute.yml b/examples/workflows/gemini-assistant/gemini-plan-execute.yml index 0751baaaf..7a3a2dbfa 100644 --- a/examples/workflows/gemini-assistant/gemini-plan-execute.yml +++ b/examples/workflows/gemini-assistant/gemini-plan-execute.yml @@ -68,7 +68,8 @@ jobs: use_vertex_ai: '${{ vars.GOOGLE_GENAI_USE_VERTEXAI }}' upload_artifacts: '${{ vars.UPLOAD_ARTIFACTS }}' workflow_name: 'gemini-invoke' - github_item_number: '${{ github.event.pull_request.number || github.event.issue.number }}' + github_pr_number: '${{ github.event.pull_request.number }}' + github_issue_number: '${{ github.event.issue.number }}' settings: |- { "model": { diff --git a/examples/workflows/issue-triage/gemini-scheduled-triage.yml b/examples/workflows/issue-triage/gemini-scheduled-triage.yml index bd6c452fa..4e2b3079c 100644 --- a/examples/workflows/issue-triage/gemini-scheduled-triage.yml +++ b/examples/workflows/issue-triage/gemini-scheduled-triage.yml @@ -112,7 +112,7 @@ jobs: use_vertex_ai: '${{ vars.GOOGLE_GENAI_USE_VERTEXAI }}' upload_artifacts: '${{ vars.UPLOAD_ARTIFACTS }}' workflow_name: 'gemini-scheduled-triage' - github_item_number: '${{ steps.find_issues.outputs.issue_numbers }}' + github_custom_tracking_id: '${{ steps.find_issues.outputs.issue_numbers }}' settings: |- { "model": { diff --git a/examples/workflows/issue-triage/gemini-triage.yml b/examples/workflows/issue-triage/gemini-triage.yml index 40693af1d..132b22b34 100644 --- a/examples/workflows/issue-triage/gemini-triage.yml +++ b/examples/workflows/issue-triage/gemini-triage.yml @@ -79,7 +79,7 @@ jobs: use_vertex_ai: '${{ vars.GOOGLE_GENAI_USE_VERTEXAI }}' upload_artifacts: '${{ vars.UPLOAD_ARTIFACTS }}' workflow_name: 'gemini-triage' - github_item_number: '${{ github.event.issue.number || github.event.pull_request.number }}' + github_issue_number: '${{ github.event.issue.number }}' settings: |- { "model": { diff --git a/examples/workflows/pr-review/gemini-review.yml b/examples/workflows/pr-review/gemini-review.yml index 497d91393..9601c80d3 100644 --- a/examples/workflows/pr-review/gemini-review.yml +++ b/examples/workflows/pr-review/gemini-review.yml @@ -65,7 +65,7 @@ jobs: use_vertex_ai: '${{ vars.GOOGLE_GENAI_USE_VERTEXAI }}' upload_artifacts: '${{ vars.UPLOAD_ARTIFACTS }}' workflow_name: 'gemini-review' - github_item_number: '${{ github.event.pull_request.number || github.event.issue.number }}' + github_pr_number: '${{ github.event.pull_request.number }}' settings: |- { "model": { diff --git a/gemini_cli_pr_body.md b/gemini_cli_pr_body.md new file mode 100644 index 000000000..c009519c4 --- /dev/null +++ b/gemini_cli_pr_body.md @@ -0,0 +1,94 @@ +## Summary + +This PR adds new telemetry attributes to the Gemini CLI to support granular usage metrics for GitHub Actions. These metrics will allow us to track unique Issues and PRs touched by the CLI, and distinguish between different workflow triggers (e.g., Automated vs. Scheduled triage). + +Will fix https://github.com/google-gemini/gemini-cli/issues/21130 + +## Details + +- Added `GEMINI_CLI_GH_EVENT_NAME` to `EventMetadataKey`. +- Added specific tracking IDs: `GEMINI_CLI_GH_PR_NUMBER`, `GEMINI_CLI_GH_ISSUE_NUMBER`, and `GEMINI_CLI_GH_CUSTOM_TRACKING_ID` replacing generic `GH_EVENT_NUMBER`. +- Updated `ClearcutLogger` to capture these from environment variables (`GITHUB_EVENT_NAME`, `GH_PR_NUMBER`, `GH_ISSUE_NUMBER`, and `GH_CUSTOM_TRACKING_ID`). +- The PR/Issue number is logged as a raw string ID (e.g., `123`) to avoid fingerprinting PII, relying on the repository context to provide global uniqueness for backend queries. +- Updated telemetry tests in `clearcut-logger.test.ts` to cover the new environment variables and metadata keys. +- Updated telemetry documentation in `docs/cli/telemetry.md`. + +### Example Telemetry Scenarios + +Because the CLI appends these context fields to the `baseMetadata` of all events (API Request, Response, Error), downstream analytics can perfectly distinguish and count unique issues vs. PRs based on the workflow context. + +#### Scenario A: Automated PR Review + +When PR #42 triggers the `gemini-review` workflow, the CLI logs: + +```json +{ + "event_name": "api_request", + "event_metadata": [ + [ + { "gemini_cli_key": 130, "value": "gemini-review" }, + { "gemini_cli_key": 172, "value": "pull_request" }, + { "gemini_cli_key": 173, "value": "42" } // GH_PR_NUMBER + ] + ] +} +``` + +_Analysts can count `DISTINCT gh_pr_number WHERE gh_workflow_name LIKE '%review%'` to satisfy the P0 PR metric._ + +#### Scenario B: Automated Issue Triage + +When Issue #88 triggers the `gemini-triage` workflow, the CLI logs: + +```json +{ + "event_name": "api_request", + "event_metadata": [ + [ + { "gemini_cli_key": 130, "value": "gemini-triage" }, + { "gemini_cli_key": 172, "value": "issues" }, + { "gemini_cli_key": 174, "value": "88" } // GH_ISSUE_NUMBER + ] + ] +} +``` + +_Analysts can count `DISTINCT gh_issue_number WHERE gh_workflow_name LIKE '%triage%' AND gh_event_name = 'issues'` to satisfy the P0 Automated Issue metric._ + +#### Scenario C: Scheduled Batch Triage + +When a cron job runs and triages 3 issues (IDs 101, 102, 103) in a single CLI invocation, the CLI logs: + +```json +{ + "event_name": "api_request", + "event_metadata": [ + [ + { "gemini_cli_key": 130, "value": "gemini-scheduled-triage" }, + { "gemini_cli_key": 172, "value": "schedule" }, + { "gemini_cli_key": 175, "value": "101,102,103" } // GH_CUSTOM_TRACKING_ID + ] + ] +} +``` + +_Analysts can split the `gh_custom_tracking_id` string by commas to count exactly 3 unique issues processed during a scheduled invocation._ + +## Related Issues + +Related to internal PM request for "Gemini CLI GitHub Action Usage Metric". + +## How to Validate + +1. Run the new tests: `npm test -w @google/gemini-cli-core -- src/telemetry/clearcut-logger/clearcut-logger.test.ts` +2. Verify that when `GITHUB_EVENT_NAME` and specific IDs (`GH_PR_NUMBER`, etc.) are set in the environment, they appear in the Clearcut log metadata as expected. + +## Pre-Merge Checklist + +- [x] Updated relevant documentation and README (if needed) +- [x] Added/updated tests (if needed) +- [ ] Noted breaking changes (if any) +- [ ] Validated on required platforms/methods: + - [ ] MacOS + - [ ] Windows + - [x] Linux diff --git a/patch.diff b/patch.diff new file mode 100644 index 000000000..9dee9053a --- /dev/null +++ b/patch.diff @@ -0,0 +1,18 @@ +--- packages/core/src/telemetry/clearcut-logger/event-metadata-key.ts ++++ packages/core/src/telemetry/clearcut-logger/event-metadata-key.ts +@@ -219,8 +219,14 @@ + GEMINI_CLI_GH_EVENT_NAME = 172, + +- // Logs the event number (Issue or PR ID) of the GitHub Action that triggered the session. +- GEMINI_CLI_GH_EVENT_NUMBER = 173, ++ // Logs the Pull Request number of the GitHub Action that triggered the session. ++ GEMINI_CLI_GH_PR_NUMBER = 173, ++ ++ // Logs the Issue number of the GitHub Action that triggered the session. ++ GEMINI_CLI_GH_ISSUE_NUMBER = 174, ++ ++ // Logs a custom item number of the GitHub Action that triggered the session. ++ GEMINI_CLI_GH_CUSTOM_NUMBER = 175, + + // ========================================================================== + // Loop Detected Event Keys diff --git a/patch2.diff b/patch2.diff new file mode 100644 index 000000000..44e532722 --- /dev/null +++ b/patch2.diff @@ -0,0 +1,69 @@ +--- packages/core/src/telemetry/clearcut-logger/clearcut-logger.ts ++++ packages/core/src/telemetry/clearcut-logger/clearcut-logger.ts +@@ -194,10 +194,24 @@ + } + + /** +- * Determines the GitHub event number if the CLI is running in a GitHub Actions environment. ++ * Determines the GitHub PR number if the CLI is running in a GitHub Actions environment. + */ +-function determineGHEventNumber(): string | undefined { +- return process.env['GH_EVENT_NUMBER']; ++function determineGHPRNumber(): string | undefined { ++ return process.env['GH_PR_NUMBER']; ++} ++ ++/** ++ * Determines the GitHub Issue number if the CLI is running in a GitHub Actions environment. ++ */ ++function determineGHIssueNumber(): string | undefined { ++ return process.env['GH_ISSUE_NUMBER']; ++} ++ ++/** ++ * Determines the custom GitHub item number if the CLI is running in a GitHub Actions environment. ++ */ ++function determineGHCustomNumber(): string | undefined { ++ return process.env['GH_CUSTOM_NUMBER']; + } + + /** +@@ -391,7 +405,9 @@ + const email = this.userAccountManager.getCachedGoogleAccount(); + const surface = determineSurface(); + const ghWorkflowName = determineGHWorkflowName(); + const ghEventName = determineGHEventName(); +- const ghEventNumber = determineGHEventNumber(); ++ const ghPRNumber = determineGHPRNumber(); ++ const ghIssueNumber = determineGHIssueNumber(); ++ const ghCustomNumber = determineGHCustomNumber(); + const baseMetadata: EventValue[] = [ + ...data, +@@ -433,10 +449,24 @@ + }); + } + +- if (ghEventNumber) { ++ if (ghPRNumber) { + baseMetadata.push({ +- gemini_cli_key: EventMetadataKey.GEMINI_CLI_GH_EVENT_NUMBER, +- value: ghEventNumber, ++ gemini_cli_key: EventMetadataKey.GEMINI_CLI_GH_PR_NUMBER, ++ value: ghPRNumber, ++ }); ++ } ++ ++ if (ghIssueNumber) { ++ baseMetadata.push({ ++ gemini_cli_key: EventMetadataKey.GEMINI_CLI_GH_ISSUE_NUMBER, ++ value: ghIssueNumber, ++ }); ++ } ++ ++ if (ghCustomNumber) { ++ baseMetadata.push({ ++ gemini_cli_key: EventMetadataKey.GEMINI_CLI_GH_CUSTOM_NUMBER, ++ value: ghCustomNumber, + }); + } + diff --git a/pr_body.md b/pr_body.md new file mode 100644 index 000000000..09ec42fe1 --- /dev/null +++ b/pr_body.md @@ -0,0 +1,72 @@ +## Description + +This PR implements the necessary infrastructure in the \`run-gemini-cli\` GitHub Action to support the Gemini CLI usage metrics (P0 requirements). + +It aligns with the core CLI telemetry changes introduced in [google-gemini/gemini-cli#21129](https://github.com/google-gemini/gemini-cli/pull/21129). + +### Changes Made: + +- **Precise Telemetry Tracking:** Introduced a new \`github_item_number\` input to \`action.yml\`. This defaults to the current Issue or PR number but allows explicit overrides. This resolves the inability to track unique items across different workflow types (e.g., scheduled vs. automated). +- **Installation Telemetry:** Added \`GH_WORKFLOW_NAME\` and \`GH_EVENT_NUMBER\` to the \`Install Gemini CLI\` step to ensure extension installations are properly tracked. +- **OTEL Collector Enhancement:** Added \`github.event.number\` to the \`scripts/collector-gcp.yaml.template\` resource attributes, ensuring Google Cloud Logging metrics are fully synchronized with Clearcut. +- **Example Workflow Updates:** Modified the \`gemini-scheduled-triage.yml\` example to correctly extract and pass a comma-separated list of issue IDs to the \`github_item_number\` input. This prevents telemetry corruption during batch processing. + +### Example Telemetry Scenarios + +Because the CLI appends the \`GH_EVENT_NUMBER\` and \`GH_WORKFLOW_NAME\` to the \`baseMetadata\` of all events (API Request, Response, Error), downstream analytics can perfectly distinguish and count unique issues vs. PRs based on the workflow context. + +#### Scenario A: Automated PR Review + +When PR #42 triggers the \`gemini-review\` workflow, the CLI logs: +\`\`\`json +{ +\"event_name\": \"api_request\", +\"event_metadata\": [ +[ +{ \"gemini_cli_key\": 130, \"value\": \"gemini-review\" }, +{ \"gemini_cli_key\": 172, \"value\": \"pull_request\" }, +{ \"gemini_cli_key\": 173, \"value\": \"42\" } // GH_EVENT_NUMBER +] +] +} +\`\`\` +_Analysts can count \`DISTINCT gh_event_number WHERE gh_workflow_name LIKE '%review%'\` to satisfy the P0 PR metric._ + +#### Scenario B: Automated Issue Triage + +When Issue #88 triggers the \`gemini-triage\` workflow, the CLI logs: +\`\`\`json +{ +\"event_name\": \"api_request\", +\"event_metadata\": [ +[ +{ \"gemini_cli_key\": 130, \"value\": \"gemini-triage\" }, +{ \"gemini_cli_key\": 172, \"value\": \"issues\" }, +{ \"gemini_cli_key\": 173, \"value\": \"88\" } // GH_EVENT_NUMBER +] +] +} +\`\`\` +_Analysts can count \`DISTINCT gh_event_number WHERE gh_workflow_name LIKE '%triage%' AND gh_event_name = 'issues'\` to satisfy the P0 Automated Issue metric._ + +#### Scenario C: Scheduled Batch Triage + +When a cron job runs and triages 3 issues (IDs 101, 102, 103) in a single CLI invocation, the CLI logs: +\`\`\`json +{ +\"event_name\": \"api_request\", +\"event_metadata\": [ +[ +{ \"gemini_cli_key\": 130, \"value\": \"gemini-scheduled-triage\" }, +{ \"gemini_cli_key\": 172, \"value\": \"schedule\" }, +{ \"gemini_cli_key\": 173, \"value\": \"101,102,103\" } // GH_EVENT_NUMBER +] +] +} +\`\`\` +_Analysts can split the \`gh_event_number\` string by commas to count exactly 3 unique issues processed during a scheduled invocation._ + +## Related Issues + +- Fixes P0 metrics requirements for GitHub Action usage. +- Depends on [google-gemini/gemini-cli#21129](https://github.com/google-gemini/gemini-cli/pull/21129) diff --git a/scripts/collector-gcp.yaml.template b/scripts/collector-gcp.yaml.template index bab3728fa..01709bca2 100644 --- a/scripts/collector-gcp.yaml.template +++ b/scripts/collector-gcp.yaml.template @@ -12,8 +12,14 @@ processors: - key: 'github.run_id' value: 'GITHUB_RUN_ID_PLACEHOLDER' action: 'upsert' - - key: 'github.event.number' - value: 'GITHUB_EVENT_NUMBER_PLACEHOLDER' + - key: 'github.pr.number' + value: 'GITHUB_PR_NUMBER_PLACEHOLDER' + action: 'upsert' + - key: 'github.issue.number' + value: 'GITHUB_ISSUE_NUMBER_PLACEHOLDER' + action: 'upsert' + - key: 'github.custom_tracking.id' + value: 'GITHUB_CUSTOM_TRACKING_ID_PLACEHOLDER' action: 'upsert' batch: send_batch_size: 100 From 840d5489159a5b984abeae4ef37c342ea916f62d Mon Sep 17 00:00:00 2001 From: cocosheng-g Date: Fri, 6 Mar 2026 12:37:05 -0500 Subject: [PATCH 8/9] chore: cleanup temporary files --- gemini_cli_pr_body.md | 94 ------------------------------------------- patch.diff | 18 --------- patch2.diff | 69 ------------------------------- pr_body.md | 72 --------------------------------- 4 files changed, 253 deletions(-) delete mode 100644 gemini_cli_pr_body.md delete mode 100644 patch.diff delete mode 100644 patch2.diff delete mode 100644 pr_body.md diff --git a/gemini_cli_pr_body.md b/gemini_cli_pr_body.md deleted file mode 100644 index c009519c4..000000000 --- a/gemini_cli_pr_body.md +++ /dev/null @@ -1,94 +0,0 @@ -## Summary - -This PR adds new telemetry attributes to the Gemini CLI to support granular usage metrics for GitHub Actions. These metrics will allow us to track unique Issues and PRs touched by the CLI, and distinguish between different workflow triggers (e.g., Automated vs. Scheduled triage). - -Will fix https://github.com/google-gemini/gemini-cli/issues/21130 - -## Details - -- Added `GEMINI_CLI_GH_EVENT_NAME` to `EventMetadataKey`. -- Added specific tracking IDs: `GEMINI_CLI_GH_PR_NUMBER`, `GEMINI_CLI_GH_ISSUE_NUMBER`, and `GEMINI_CLI_GH_CUSTOM_TRACKING_ID` replacing generic `GH_EVENT_NUMBER`. -- Updated `ClearcutLogger` to capture these from environment variables (`GITHUB_EVENT_NAME`, `GH_PR_NUMBER`, `GH_ISSUE_NUMBER`, and `GH_CUSTOM_TRACKING_ID`). -- The PR/Issue number is logged as a raw string ID (e.g., `123`) to avoid fingerprinting PII, relying on the repository context to provide global uniqueness for backend queries. -- Updated telemetry tests in `clearcut-logger.test.ts` to cover the new environment variables and metadata keys. -- Updated telemetry documentation in `docs/cli/telemetry.md`. - -### Example Telemetry Scenarios - -Because the CLI appends these context fields to the `baseMetadata` of all events (API Request, Response, Error), downstream analytics can perfectly distinguish and count unique issues vs. PRs based on the workflow context. - -#### Scenario A: Automated PR Review - -When PR #42 triggers the `gemini-review` workflow, the CLI logs: - -```json -{ - "event_name": "api_request", - "event_metadata": [ - [ - { "gemini_cli_key": 130, "value": "gemini-review" }, - { "gemini_cli_key": 172, "value": "pull_request" }, - { "gemini_cli_key": 173, "value": "42" } // GH_PR_NUMBER - ] - ] -} -``` - -_Analysts can count `DISTINCT gh_pr_number WHERE gh_workflow_name LIKE '%review%'` to satisfy the P0 PR metric._ - -#### Scenario B: Automated Issue Triage - -When Issue #88 triggers the `gemini-triage` workflow, the CLI logs: - -```json -{ - "event_name": "api_request", - "event_metadata": [ - [ - { "gemini_cli_key": 130, "value": "gemini-triage" }, - { "gemini_cli_key": 172, "value": "issues" }, - { "gemini_cli_key": 174, "value": "88" } // GH_ISSUE_NUMBER - ] - ] -} -``` - -_Analysts can count `DISTINCT gh_issue_number WHERE gh_workflow_name LIKE '%triage%' AND gh_event_name = 'issues'` to satisfy the P0 Automated Issue metric._ - -#### Scenario C: Scheduled Batch Triage - -When a cron job runs and triages 3 issues (IDs 101, 102, 103) in a single CLI invocation, the CLI logs: - -```json -{ - "event_name": "api_request", - "event_metadata": [ - [ - { "gemini_cli_key": 130, "value": "gemini-scheduled-triage" }, - { "gemini_cli_key": 172, "value": "schedule" }, - { "gemini_cli_key": 175, "value": "101,102,103" } // GH_CUSTOM_TRACKING_ID - ] - ] -} -``` - -_Analysts can split the `gh_custom_tracking_id` string by commas to count exactly 3 unique issues processed during a scheduled invocation._ - -## Related Issues - -Related to internal PM request for "Gemini CLI GitHub Action Usage Metric". - -## How to Validate - -1. Run the new tests: `npm test -w @google/gemini-cli-core -- src/telemetry/clearcut-logger/clearcut-logger.test.ts` -2. Verify that when `GITHUB_EVENT_NAME` and specific IDs (`GH_PR_NUMBER`, etc.) are set in the environment, they appear in the Clearcut log metadata as expected. - -## Pre-Merge Checklist - -- [x] Updated relevant documentation and README (if needed) -- [x] Added/updated tests (if needed) -- [ ] Noted breaking changes (if any) -- [ ] Validated on required platforms/methods: - - [ ] MacOS - - [ ] Windows - - [x] Linux diff --git a/patch.diff b/patch.diff deleted file mode 100644 index 9dee9053a..000000000 --- a/patch.diff +++ /dev/null @@ -1,18 +0,0 @@ ---- packages/core/src/telemetry/clearcut-logger/event-metadata-key.ts -+++ packages/core/src/telemetry/clearcut-logger/event-metadata-key.ts -@@ -219,8 +219,14 @@ - GEMINI_CLI_GH_EVENT_NAME = 172, - -- // Logs the event number (Issue or PR ID) of the GitHub Action that triggered the session. -- GEMINI_CLI_GH_EVENT_NUMBER = 173, -+ // Logs the Pull Request number of the GitHub Action that triggered the session. -+ GEMINI_CLI_GH_PR_NUMBER = 173, -+ -+ // Logs the Issue number of the GitHub Action that triggered the session. -+ GEMINI_CLI_GH_ISSUE_NUMBER = 174, -+ -+ // Logs a custom item number of the GitHub Action that triggered the session. -+ GEMINI_CLI_GH_CUSTOM_NUMBER = 175, - - // ========================================================================== - // Loop Detected Event Keys diff --git a/patch2.diff b/patch2.diff deleted file mode 100644 index 44e532722..000000000 --- a/patch2.diff +++ /dev/null @@ -1,69 +0,0 @@ ---- packages/core/src/telemetry/clearcut-logger/clearcut-logger.ts -+++ packages/core/src/telemetry/clearcut-logger/clearcut-logger.ts -@@ -194,10 +194,24 @@ - } - - /** -- * Determines the GitHub event number if the CLI is running in a GitHub Actions environment. -+ * Determines the GitHub PR number if the CLI is running in a GitHub Actions environment. - */ --function determineGHEventNumber(): string | undefined { -- return process.env['GH_EVENT_NUMBER']; -+function determineGHPRNumber(): string | undefined { -+ return process.env['GH_PR_NUMBER']; -+} -+ -+/** -+ * Determines the GitHub Issue number if the CLI is running in a GitHub Actions environment. -+ */ -+function determineGHIssueNumber(): string | undefined { -+ return process.env['GH_ISSUE_NUMBER']; -+} -+ -+/** -+ * Determines the custom GitHub item number if the CLI is running in a GitHub Actions environment. -+ */ -+function determineGHCustomNumber(): string | undefined { -+ return process.env['GH_CUSTOM_NUMBER']; - } - - /** -@@ -391,7 +405,9 @@ - const email = this.userAccountManager.getCachedGoogleAccount(); - const surface = determineSurface(); - const ghWorkflowName = determineGHWorkflowName(); - const ghEventName = determineGHEventName(); -- const ghEventNumber = determineGHEventNumber(); -+ const ghPRNumber = determineGHPRNumber(); -+ const ghIssueNumber = determineGHIssueNumber(); -+ const ghCustomNumber = determineGHCustomNumber(); - const baseMetadata: EventValue[] = [ - ...data, -@@ -433,10 +449,24 @@ - }); - } - -- if (ghEventNumber) { -+ if (ghPRNumber) { - baseMetadata.push({ -- gemini_cli_key: EventMetadataKey.GEMINI_CLI_GH_EVENT_NUMBER, -- value: ghEventNumber, -+ gemini_cli_key: EventMetadataKey.GEMINI_CLI_GH_PR_NUMBER, -+ value: ghPRNumber, -+ }); -+ } -+ -+ if (ghIssueNumber) { -+ baseMetadata.push({ -+ gemini_cli_key: EventMetadataKey.GEMINI_CLI_GH_ISSUE_NUMBER, -+ value: ghIssueNumber, -+ }); -+ } -+ -+ if (ghCustomNumber) { -+ baseMetadata.push({ -+ gemini_cli_key: EventMetadataKey.GEMINI_CLI_GH_CUSTOM_NUMBER, -+ value: ghCustomNumber, - }); - } - diff --git a/pr_body.md b/pr_body.md deleted file mode 100644 index 09ec42fe1..000000000 --- a/pr_body.md +++ /dev/null @@ -1,72 +0,0 @@ -## Description - -This PR implements the necessary infrastructure in the \`run-gemini-cli\` GitHub Action to support the Gemini CLI usage metrics (P0 requirements). - -It aligns with the core CLI telemetry changes introduced in [google-gemini/gemini-cli#21129](https://github.com/google-gemini/gemini-cli/pull/21129). - -### Changes Made: - -- **Precise Telemetry Tracking:** Introduced a new \`github_item_number\` input to \`action.yml\`. This defaults to the current Issue or PR number but allows explicit overrides. This resolves the inability to track unique items across different workflow types (e.g., scheduled vs. automated). -- **Installation Telemetry:** Added \`GH_WORKFLOW_NAME\` and \`GH_EVENT_NUMBER\` to the \`Install Gemini CLI\` step to ensure extension installations are properly tracked. -- **OTEL Collector Enhancement:** Added \`github.event.number\` to the \`scripts/collector-gcp.yaml.template\` resource attributes, ensuring Google Cloud Logging metrics are fully synchronized with Clearcut. -- **Example Workflow Updates:** Modified the \`gemini-scheduled-triage.yml\` example to correctly extract and pass a comma-separated list of issue IDs to the \`github_item_number\` input. This prevents telemetry corruption during batch processing. - -### Example Telemetry Scenarios - -Because the CLI appends the \`GH_EVENT_NUMBER\` and \`GH_WORKFLOW_NAME\` to the \`baseMetadata\` of all events (API Request, Response, Error), downstream analytics can perfectly distinguish and count unique issues vs. PRs based on the workflow context. - -#### Scenario A: Automated PR Review - -When PR #42 triggers the \`gemini-review\` workflow, the CLI logs: -\`\`\`json -{ -\"event_name\": \"api_request\", -\"event_metadata\": [ -[ -{ \"gemini_cli_key\": 130, \"value\": \"gemini-review\" }, -{ \"gemini_cli_key\": 172, \"value\": \"pull_request\" }, -{ \"gemini_cli_key\": 173, \"value\": \"42\" } // GH_EVENT_NUMBER -] -] -} -\`\`\` -_Analysts can count \`DISTINCT gh_event_number WHERE gh_workflow_name LIKE '%review%'\` to satisfy the P0 PR metric._ - -#### Scenario B: Automated Issue Triage - -When Issue #88 triggers the \`gemini-triage\` workflow, the CLI logs: -\`\`\`json -{ -\"event_name\": \"api_request\", -\"event_metadata\": [ -[ -{ \"gemini_cli_key\": 130, \"value\": \"gemini-triage\" }, -{ \"gemini_cli_key\": 172, \"value\": \"issues\" }, -{ \"gemini_cli_key\": 173, \"value\": \"88\" } // GH_EVENT_NUMBER -] -] -} -\`\`\` -_Analysts can count \`DISTINCT gh_event_number WHERE gh_workflow_name LIKE '%triage%' AND gh_event_name = 'issues'\` to satisfy the P0 Automated Issue metric._ - -#### Scenario C: Scheduled Batch Triage - -When a cron job runs and triages 3 issues (IDs 101, 102, 103) in a single CLI invocation, the CLI logs: -\`\`\`json -{ -\"event_name\": \"api_request\", -\"event_metadata\": [ -[ -{ \"gemini_cli_key\": 130, \"value\": \"gemini-scheduled-triage\" }, -{ \"gemini_cli_key\": 172, \"value\": \"schedule\" }, -{ \"gemini_cli_key\": 173, \"value\": \"101,102,103\" } // GH_EVENT_NUMBER -] -] -} -\`\`\` -_Analysts can split the \`gh_event_number\` string by commas to count exactly 3 unique issues processed during a scheduled invocation._ - -## Related Issues - -- Fixes P0 metrics requirements for GitHub Action usage. -- Depends on [google-gemini/gemini-cli#21129](https://github.com/google-gemini/gemini-cli/pull/21129) From 489ea8da6bd8f3904861539649ca62007373bf4e Mon Sep 17 00:00:00 2001 From: cocosheng-g Date: Fri, 6 Mar 2026 12:43:31 -0500 Subject: [PATCH 9/9] docs(examples): add inline comments explaining telemetry ID overrides --- examples/workflows/gemini-assistant/gemini-invoke.yml | 2 ++ examples/workflows/gemini-assistant/gemini-plan-execute.yml | 2 ++ examples/workflows/issue-triage/gemini-scheduled-triage.yml | 2 ++ examples/workflows/issue-triage/gemini-triage.yml | 1 + examples/workflows/pr-review/gemini-review.yml | 1 + 5 files changed, 8 insertions(+) diff --git a/examples/workflows/gemini-assistant/gemini-invoke.yml b/examples/workflows/gemini-assistant/gemini-invoke.yml index 90bead83c..c549de614 100644 --- a/examples/workflows/gemini-assistant/gemini-invoke.yml +++ b/examples/workflows/gemini-assistant/gemini-invoke.yml @@ -66,6 +66,8 @@ jobs: use_vertex_ai: '${{ vars.GOOGLE_GENAI_USE_VERTEXAI }}' upload_artifacts: '${{ vars.UPLOAD_ARTIFACTS }}' workflow_name: 'gemini-invoke' + # Assistant workflows can be triggered by comments on either Issues or PRs. + # We explicitly map both fields so the CLI can correctly categorize the interaction. github_pr_number: '${{ github.event.pull_request.number }}' github_issue_number: '${{ github.event.issue.number }}' settings: |- diff --git a/examples/workflows/gemini-assistant/gemini-plan-execute.yml b/examples/workflows/gemini-assistant/gemini-plan-execute.yml index 7a3a2dbfa..19e15bf2d 100644 --- a/examples/workflows/gemini-assistant/gemini-plan-execute.yml +++ b/examples/workflows/gemini-assistant/gemini-plan-execute.yml @@ -68,6 +68,8 @@ jobs: use_vertex_ai: '${{ vars.GOOGLE_GENAI_USE_VERTEXAI }}' upload_artifacts: '${{ vars.UPLOAD_ARTIFACTS }}' workflow_name: 'gemini-invoke' + # Assistant workflows can be triggered by comments on either Issues or PRs. + # We explicitly map both fields so the CLI can correctly categorize the interaction. github_pr_number: '${{ github.event.pull_request.number }}' github_issue_number: '${{ github.event.issue.number }}' settings: |- diff --git a/examples/workflows/issue-triage/gemini-scheduled-triage.yml b/examples/workflows/issue-triage/gemini-scheduled-triage.yml index 4e2b3079c..7d166bd6a 100644 --- a/examples/workflows/issue-triage/gemini-scheduled-triage.yml +++ b/examples/workflows/issue-triage/gemini-scheduled-triage.yml @@ -112,6 +112,8 @@ jobs: use_vertex_ai: '${{ vars.GOOGLE_GENAI_USE_VERTEXAI }}' upload_artifacts: '${{ vars.UPLOAD_ARTIFACTS }}' workflow_name: 'gemini-scheduled-triage' + # Overriding default telemetry inputs because scheduled workflows lack an event payload + # We pass the dynamically generated list of batch issues to the custom tracking ID field github_custom_tracking_id: '${{ steps.find_issues.outputs.issue_numbers }}' settings: |- { diff --git a/examples/workflows/issue-triage/gemini-triage.yml b/examples/workflows/issue-triage/gemini-triage.yml index 132b22b34..480a2b0d6 100644 --- a/examples/workflows/issue-triage/gemini-triage.yml +++ b/examples/workflows/issue-triage/gemini-triage.yml @@ -79,6 +79,7 @@ jobs: use_vertex_ai: '${{ vars.GOOGLE_GENAI_USE_VERTEXAI }}' upload_artifacts: '${{ vars.UPLOAD_ARTIFACTS }}' workflow_name: 'gemini-triage' + # Explicitly set the issue number to handle `issue_comment` triggers where the context might be ambiguous github_issue_number: '${{ github.event.issue.number }}' settings: |- { diff --git a/examples/workflows/pr-review/gemini-review.yml b/examples/workflows/pr-review/gemini-review.yml index 9601c80d3..552f058ec 100644 --- a/examples/workflows/pr-review/gemini-review.yml +++ b/examples/workflows/pr-review/gemini-review.yml @@ -65,6 +65,7 @@ jobs: use_vertex_ai: '${{ vars.GOOGLE_GENAI_USE_VERTEXAI }}' upload_artifacts: '${{ vars.UPLOAD_ARTIFACTS }}' workflow_name: 'gemini-review' + # Explicitly set the PR number to handle `issue_comment` triggers (which GitHub treats as issues, not PRs) github_pr_number: '${{ github.event.pull_request.number }}' settings: |- {