From ee8b1295d24ffde25ee18351efdcee0f76af0eca Mon Sep 17 00:00:00 2001 From: Tim Downey Date: Fri, 12 Apr 2024 10:04:33 -0600 Subject: [PATCH] Remove Google Analytics and upgrade Ruby to 3.2 (#78) * Remove Google Analytics * Bump Ruby version to 3.3 - Remove explicit stack version from manifest, this shouldn't be necessary since cflinuxfs4 is now the default and supported by this app * Bump Ruby Version in Github Action * Use Ruby 3.2 - This Ruby version has more support in our dev envs and aligns with capi-release --- .github/workflows/test.yml | 2 +- .ruby-version | 1 + Gemfile | 3 +-- Gemfile.lock | 4 +--- claw.rb | 26 -------------------------- claw_test.rb | 2 -- manifest-oss-dev.yml | 3 --- manifest-oss.yml | 3 --- manifest-pivotal-dev.yml | 3 --- manifest-pivotal.yml | 3 --- 10 files changed, 4 insertions(+), 46 deletions(-) create mode 100644 .ruby-version diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index f5d328d..3afce46 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -22,7 +22,7 @@ jobs: runs-on: ubuntu-latest strategy: matrix: - ruby-version: ['2.6'] + ruby-version: ['3.2'] steps: - uses: actions/checkout@v3 diff --git a/.ruby-version b/.ruby-version new file mode 100644 index 0000000..06eda28 --- /dev/null +++ b/.ruby-version @@ -0,0 +1 @@ +3.2.3 \ No newline at end of file diff --git a/Gemfile b/Gemfile index 7197586..86e7f4f 100644 --- a/Gemfile +++ b/Gemfile @@ -1,9 +1,8 @@ # frozen_string_literal: true -ruby '~>2.6' +ruby '~>3.2' source 'http://rubygems.org' -gem 'gabba' gem 'rake' gem 'semantic' gem 'sinatra' diff --git a/Gemfile.lock b/Gemfile.lock index cc28e47..5e02273 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -1,7 +1,6 @@ GEM remote: http://rubygems.org/ specs: - gabba (1.0.1) kgio (2.11.4) mustermann (3.0.0) ruby2_keywords (~> 0.0.1) @@ -31,7 +30,6 @@ PLATFORMS ruby DEPENDENCIES - gabba rack-test rake semantic @@ -40,7 +38,7 @@ DEPENDENCIES unicorn RUBY VERSION - ruby 2.6.8p205 + ruby 3.3.0p0 BUNDLED WITH 2.1.4 diff --git a/claw.rb b/claw.rb index 71a1b20..10de10f 100644 --- a/claw.rb +++ b/claw.rb @@ -1,7 +1,6 @@ # frozen_string_literal: true require 'sinatra' -require 'gabba' require 'semantic' require 'json' @@ -69,11 +68,6 @@ RPM_REPO = 'https://cf-cli-dev.s3.amazonaws.com/cf-cli-rpm-repo' end -unless ENV.key?('GA_TRACKING_ID') && ENV.key?('GA_DOMAIN') - puts 'Expected a Google Analytics env vars but they were not set' - exit 1 -end - unless ENV.key?('GPG_KEY') puts 'Expected a GPG_KEY env var but it was not set' exit 1 @@ -95,17 +89,6 @@ end class Claw < Sinatra::Base - before do - @google_analytics = Gabba::Gabba.new(ENV['GA_TRACKING_ID'], ENV['GA_DOMAIN'], request.user_agent) - accept_language = request.env['HTTP_ACCEPT_LANGUAGE'] - @google_analytics.utmul = accept_language if accept_language - - @google_analytics.set_custom_var(1, 'ip', request.ip, 3) - @google_analytics.set_custom_var(2, 'source', params['source'], 3) - @google_analytics.set_custom_var(3, 'referer', request.referer, 3) - @google_analytics.set_custom_var(4, 'host', request.host, 3) - end - get '/ping' do 'pong' end @@ -117,48 +100,40 @@ class Claw < Sinatra::Base get '/edge' do redirect_link = get_edge_redirect_link(params['version'], params['arch']) - @google_analytics.page_view('edge', "edge/#{params['arch']}") redirect redirect_link, 302 end get '/stable' do redirect_url = get_stable_redirect_link(params['version'], params['release']) - @google_analytics.page_view('stable', "stable/#{params['release']}/#{params['version']}") redirect redirect_url, 302 end get '/homebrew' do - @google_analytics.set_custom_var(2, 'source', 'homebrew', 3) unless AVAILABLE_VERSIONS.include?(params['version']) halt 412, "Invalid version, please select one of the following versions: #{AVAILABLE_VERSIONS.join(', ')}" end - @google_analytics.page_view('stable', "stable/#{params['arch']}-binary/#{params['version']}") redirect get_versioned_release_link(params['version'], release_to_filename("#{params['arch']}-binary", params['version'])), 302 end get '/debian/dists/*' do page = File.join('dists', params['splat'].first) - @google_analytics.page_view('debian', page) redirect File.join(APT_REPO, page), 302 end get '/fedora/cloudfoundry-cli.repo' do - @google_analytics.page_view('fedora', 'cloudfoundry-cli.repo') redirect File.join(RPM_REPO, 'cloudfoundry-cli.repo'), 302 end get '/fedora/repodata/*' do page = File.join('repodata', params['splat'].first) - @google_analytics.page_view('fedora', page) redirect File.join(RPM_REPO, page), 302 end get '/debian/pool/*' do page = File.join('pool', params['splat'].first) - @google_analytics.page_view('debian', page) filename = page.split('/').last version = get_version_from_filename(filename) @@ -172,7 +147,6 @@ class Claw < Sinatra::Base get '/fedora/releases/*' do page = File.join('releases', params['splat'].first) - @google_analytics.page_view('fedora', page) filename = page.split('/').last version = get_version_from_filename(filename) diff --git a/claw_test.rb b/claw_test.rb index 85895d1..c6affad 100644 --- a/claw_test.rb +++ b/claw_test.rb @@ -1,8 +1,6 @@ # frozen_string_literal: true ENV['RACK_ENV'] = 'test' -ENV['GA_TRACKING_ID'] = 'dummy_id' -ENV['GA_DOMAIN'] = 'dummy.domain.example.com' ENV['GPG_KEY'] = 'dummy-key' ENV['AVAILABLE_VERSIONS'] = '["6.12.4", "6.13.0", "7.0.0-beta.24", "8.0.0", "8.0.1"]' ENV['CURRENT_MAJOR_VERSION'] = 'v7' diff --git a/manifest-oss-dev.yml b/manifest-oss-dev.yml index 88b37ed..b052c59 100644 --- a/manifest-oss-dev.yml +++ b/manifest-oss-dev.yml @@ -3,13 +3,10 @@ applications: - name: claw-dev buildpack: ruby_buildpack instances: 2 - stack: cflinuxfs3 env: AVAILABLE_VERSIONS: ((AVAILABLE_VERSIONS)) CURRENT_MAJOR_VERSION: v7 ENVIRONMENT: dev - GA_DOMAIN: pivotal.io - GA_TRACKING_ID: UA-52116311-1 GPG_KEY: | -----BEGIN PGP PUBLIC KEY BLOCK----- diff --git a/manifest-oss.yml b/manifest-oss.yml index 6ff3f13..9b9c631 100644 --- a/manifest-oss.yml +++ b/manifest-oss.yml @@ -3,13 +3,10 @@ applications: - name: claw buildpack: ruby_buildpack instances: 2 - stack: cflinuxfs3 env: AVAILABLE_VERSIONS: ((AVAILABLE_VERSIONS)) CURRENT_MAJOR_VERSION: v6 ENVIRONMENT: prod - GA_DOMAIN: pivotal.io - GA_TRACKING_ID: UA-52116311-1 GPG_KEY: | -----BEGIN PGP PUBLIC KEY BLOCK----- diff --git a/manifest-pivotal-dev.yml b/manifest-pivotal-dev.yml index 88b37ed..b052c59 100644 --- a/manifest-pivotal-dev.yml +++ b/manifest-pivotal-dev.yml @@ -3,13 +3,10 @@ applications: - name: claw-dev buildpack: ruby_buildpack instances: 2 - stack: cflinuxfs3 env: AVAILABLE_VERSIONS: ((AVAILABLE_VERSIONS)) CURRENT_MAJOR_VERSION: v7 ENVIRONMENT: dev - GA_DOMAIN: pivotal.io - GA_TRACKING_ID: UA-52116311-1 GPG_KEY: | -----BEGIN PGP PUBLIC KEY BLOCK----- diff --git a/manifest-pivotal.yml b/manifest-pivotal.yml index 9a5a8ef..44ce06a 100644 --- a/manifest-pivotal.yml +++ b/manifest-pivotal.yml @@ -3,13 +3,10 @@ applications: - name: claw buildpack: ruby_buildpack instances: 2 - stack: cflinuxfs3 env: AVAILABLE_VERSIONS: ((AVAILABLE_VERSIONS)) CURRENT_MAJOR_VERSION: v6 ENVIRONMENT: prod - GA_DOMAIN: pivotal.io - GA_TRACKING_ID: UA-52116311-1 GPG_KEY: | -----BEGIN PGP PUBLIC KEY BLOCK-----