← Back to Pull requests

fix: habilitar Vercel Web Analytics antes do smoke test #66

Closed
unknown closed this pull request without merging on Sep 29, 2026 11:19 UTC
View on GitHub
unknown unknown commented on Sep 28, 2026 12:35 UTC
Author

O que muda

Adiciona um step no job release do release.yml que habilita o Vercel Web Analytics via API antes de rodar o smoke test.

Por que

O smoke test (scripts/smoke-deployment.mjs) verifica /_vercel/insights/script.js com código 200. Esse endpoint é servido pela infraestrutura da Vercel somente se Web Analytics estiver habilitado para o projeto. Sem isso, a Vercel retorna 404 mesmo que o componente <Analytics /> esteja corretamente montado no React.

Causa confirmada: projeto prj_LVKX7uhs1VhTjDDznD7KinvjgHXU não tinha analytics habilitado → edge da Vercel retornava 404 → smoke falhava.

O que foi verificado

  • @vercel/analytics v2.0.1 usa /_vercel/insights/script.js em produção (confirmado via unpkg)

  • vercel.json já exclui _vercel/ do catch-all rewrite (sem interferência do app)

  • <Analytics debug={false} /> está corretamente montado em src/App.tsx

  • POST /v8/projects/{id}/analytics é idempotente: HTTP 409 = já habilitado = ok

  • VERCEL_TOKEN já disponível no job via secrets.VERCEL_TOKEN
  • Step adicionado

    Posição: depois do deploy, antes do smoke test.

    - name: Enable Vercel Web Analytics for this project
      env:
        VERCEL_TOKEN: ${{ secrets.VERCEL_TOKEN }}
      run: |
        http_code=$(curl -sf -X POST \
          "https://api.vercel.com/v8/projects/${VERCEL_PROJECT_ID}/analytics?teamId=${VERCEL_ORG_ID}" \
          -H "Authorization: Bearer ${VERCEL_TOKEN}" \
          -H "Content-Type: application/json" \
          -d '{}' \
          -w "%{http_code}" -o /dev/null 2>&1 || true)
        echo "Analytics enable response: ${http_code}"
        [ "$http_code" = "200" ] || [ "$http_code" = "409" ] || { echo "::error::Falha ao habilitar analytics (${http_code})"; exit 1; }
    

    ---

    Aguardando revisão — CI change (regra 8). Não fazer merge sem aprovação.

    🤖 Generated with Claude Code

    https://claude.ai/code/session_01GQxrAY7qGqbQGi7HxbR6cB

    <!-- This is an auto-generated description by cubic. -->
    ---

    Summary by cubic


    O workflow de release agora habilita o Vercel Web Analytics antes do smoke test, que falhava com 404 porque /_vercel/insights/script.js só é servido com analytics ativo. O rebase em main também incorporou o fluxo de deploy com candidato, smoke pré-promoção e rollback automático.

  • Analytics habilitado via POST /v1/projects/{id}/analytics; HTTP 409 (já habilitado) é tratado como sucesso.

  • O deploy cria um candidato não promovido (--skip-domain), o smoke roda nele e a promoção só acontece se ele passar; o domínio público recebe novo smoke após a promoção.

  • Em falha pós-promoção, o workflow promove de volta o deployment anterior.

  • Novo job authorize-main bloqueia releases manuais a partir de branches ou tags.
  • Refactors

  • set -euo pipefail restaurado para que redirecionamentos não mascarem falhas.

  • Upload de evidências inclui candidate-deployment.json, promotion.log e rollback.log.
  • <sup>Written for commit c6769c86107bab285a4ea20879725bf0d0d025f6. Summary will update on new commits.</sup>

    <a href="https://cubic.dev/pr/adm01-debug/Promo_Brindes_V1/pull/66?utm_source=github" target="_blank" rel="noopener noreferrer" data-no-image-dialog="true"><picture><source media="(prefers-color-scheme: dark)" srcset="https://www.cubic.dev/buttons/review-in-cubic-dark.svg"><source media="(prefers-color-scheme: light)" srcset="https://www.cubic.dev/buttons/review-in-cubic-light.svg"><img alt="Review in cubic" src="https://www.cubic.dev/buttons/review-in-cubic-dark.svg"></picture></a>

    <!-- End of auto-generated description by cubic. -->

    Diff: 448 lines (+336 / -112) across 5 files Reviewer: adm01-debug Review duration: 1364m
    All Vouch review confidence checks passed
    Residual risk 0.18 = Change Risk (0.45) × (1 − Review Confidence (0.60)). Review depth and reviewer attention state are adequate.
    Model 1 · Change Risk (XGBoost)
    Score: 0.45 · 448 lines diff across 5 files
    0.45
    Model 2 · Review Depth (DistilBERT)
    Depth Score: 0.17 · 1 substantive comment(s)
    0.17
    Model 3 · Review Timing & Attention
    Session adequacy: 100% · Reviewer familiarity: 35%
    60%
    Bedrock Claude 3 · Risk Narration
    (disconnected)
    Groq
    Groq Risk Narration
    AWS Bedrock is currently disconnected. Generate high-confidence PR triage narration on-demand using Groq.
    Model 1 · Change Risk Attribution
    SHAP Weights
    Diff Size diff_size
    0.365
    Shallow Review Depth shallow_review_depth
    0.289
    Real PR Conversation Timeline
    1 comments
    "Review active on #66"
    general weight: 0.35
    Reviewers
    Assignees
    Unassigned
    Labels
    risk: low confidence: 60.5% reviewed
    Vouch Risk Breakdown
    AI-powered review risk analysis
    Change Risk
    Change Risk · Model 1 (XGBoost)
    Predicted defect probability (0.00–1.00) based on diff churn, modified sensitive files, and author risk history.
    Score: 45.4% (MEDIUM) · Higher = larger blast radius
    45.4%
    Review Confidence
    Review Confidence · Models 2 & 3
    Scrutiny score (0.00–1.00) combining DistilBERT semantic review depth with reviewer familiarity and session dwell time.
    Score: 60.5% · Lower = rushed or shallow review
    60.5%
    Residual Risk
    Residual Risk · Core Equation
    Residual = Change × (1 − Confidence)
    Unmitigated risk surviving review. ≥ 0.65 triggers an automated re-queue to protect production.
    Score: 17.9% · Safe to merge
    17.9%