From 0f9fb9bc16fb565949db1b62c2528be4155f747f Mon Sep 17 00:00:00 2001 From: Noemi <45180344+unflxw@users.noreply.github.com> Date: Wed, 31 May 2023 12:15:26 +0200 Subject: [PATCH 1/4] Use fake revision if none given When using this to test sourcemap behavior, you want to see a different revision uploaded each time, but you don't actually care what the revision name _is_, and having to set it manually to a different value in each run is mildly inconvenient. If no revision value is given, generate something that looks like a Git commit SHA with a "-fake" prefix, and use that as a revision. --- Rakefile | 6 +++++- support/helpers.rb | 4 ++++ 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/Rakefile b/Rakefile index 6cee504..c2a37df 100644 --- a/Rakefile +++ b/Rakefile @@ -13,7 +13,11 @@ namespace :app do # Check if we have all input @frontend_key = @keys["frontend_key"] or raise "No frontend key set in keys.yml" @push_key = @keys["push_key"] or raise "No push key set in keys.yml" - @revision = ENV["revision"] or raise "No revision set in env" + @revision = ENV["revision"] + if @revision.nil? + @revision = demo_revision + puts "No revision set in env; using demo revision #{@revision.inspect}" + end # Use uris from keys.yml, or the default production ones @uri = @keys["uri"] || "https://appsignal-endpoint.net/collect" @sourcemap_uri = @keys["sourcemaps_uri"] || "https://appsignal.com/api/sourcemaps" diff --git a/support/helpers.rb b/support/helpers.rb index a064175..d62d68d 100644 --- a/support/helpers.rb +++ b/support/helpers.rb @@ -57,6 +57,10 @@ def get_keys YAML.load_file("keys.yml") end +def demo_revision + "0123456789abcdef".chars.sample(7).join + "-demo" +end + def render_erb(file, binding) ERB.new(File.read(file)).result(binding) end From 25a3fda948ddcf3d939064a10ae8181cca145fd8 Mon Sep 17 00:00:00 2001 From: Noemi <45180344+unflxw@users.noreply.github.com> Date: Wed, 31 May 2023 13:47:48 +0200 Subject: [PATCH 2/4] Add `appsignal` to the global object This allows one to easily verify that it's configured correctly and to manually trigger sending errors. --- support/helpers.rb | 2 +- support/templates/appsignal.js.erb | 6 +++++- support/templates/appsignal.ts.erb | 17 +++++++++++++++++ 3 files changed, 23 insertions(+), 2 deletions(-) create mode 100644 support/templates/appsignal.ts.erb diff --git a/support/helpers.rb b/support/helpers.rb index d62d68d..6f45bdb 100644 --- a/support/helpers.rb +++ b/support/helpers.rb @@ -77,7 +77,7 @@ def write_appsignal_config(app, frontend_key, revision, uri) end File.write( "frameworks/#{app}/src/#{filename}", - render_erb("support/templates/appsignal.js.erb", binding) + render_erb("support/templates/#{filename}.erb", binding) ) end diff --git a/support/templates/appsignal.js.erb b/support/templates/appsignal.js.erb index 671d8db..63d1091 100644 --- a/support/templates/appsignal.js.erb +++ b/support/templates/appsignal.js.erb @@ -2,8 +2,12 @@ import Appsignal from "@appsignal/javascript"; -export default new Appsignal({ +const appsignal = new Appsignal({ key: "<%= @frontend_key %>", revision: "<%= @revision %>", uri: "<%= @uri %>" }); + +export default appsignal; + +globalThis.appsignal = appsignal; diff --git a/support/templates/appsignal.ts.erb b/support/templates/appsignal.ts.erb new file mode 100644 index 0000000..0ff96ba --- /dev/null +++ b/support/templates/appsignal.ts.erb @@ -0,0 +1,17 @@ +// This file is autogenerated when running rake app:run + +import Appsignal from "@appsignal/javascript"; + +const appsignal = new Appsignal({ + key: "<%= @frontend_key %>", + revision: "<%= @revision %>", + uri: "<%= @uri %>" +}); + +export default appsignal; + +declare global { + var appsignal: Appsignal +} + +globalThis.appsignal = appsignal; From eda6e0e8708f2fd117843f0088400ef3b65b1fe6 Mon Sep 17 00:00:00 2001 From: Noemi <45180344+unflxw@users.noreply.github.com> Date: Wed, 31 May 2023 14:04:41 +0200 Subject: [PATCH 3/4] Improve README Move automated tests dependencies (geckodriver) to the automated tests section. Clarify that `yarn` must be installed. Clarify that the Node.js version must be Node 16, using a `.tool-versions` file to set it automatically for `asdf` users. --- .tool-versions | 1 + README.md | 25 +++++++++++++++++++++---- 2 files changed, 22 insertions(+), 4 deletions(-) create mode 100644 .tool-versions diff --git a/.tool-versions b/.tool-versions new file mode 100644 index 0000000..ba4cc25 --- /dev/null +++ b/.tool-versions @@ -0,0 +1 @@ +nodejs 16.13.1 diff --git a/README.md b/README.md index 41f6534..eda2978 100644 --- a/README.md +++ b/README.md @@ -6,11 +6,18 @@ This repository contains a set of frontend apps to test with. ## Setup -Make sure you have have a working local Node.js install. -Install geckodriver and install the bundle: +Make sure you have have a working local Node.js install. The +Node.js version should match the one in the `.tool-versions` file. + +The `yarn` package manager should be globally installed: + +``` +npm i -g yarn +``` + +Install the dependencies with bundle: ``` -brew install geckodriver bundle install ``` @@ -54,7 +61,17 @@ Then navigate to http://localhost:5001 to trigger an error. ## Running tests -Run `bundle exec rspec` to run an integration test on all test setups. +To run the tests, you must have `geckodriver` installed: + +``` +brew install geckodriver +``` + +To run an integration test on all test setups: + +``` +bundle exec rspec +``` ## Adding a new app From bdab33f6595a7889a9c77ec65b35492b3620fb7a Mon Sep 17 00:00:00 2001 From: Noemi <45180344+unflxw@users.noreply.github.com> Date: Wed, 31 May 2023 14:14:02 +0200 Subject: [PATCH 4/4] Remove Angular analytics prompt An annoying prompt about analytics blocks the test run until it is answered. Disable it. --- frameworks/angular/14/angular.json | 3 +++ 1 file changed, 3 insertions(+) diff --git a/frameworks/angular/14/angular.json b/frameworks/angular/14/angular.json index a899e5c..fa5f850 100644 --- a/frameworks/angular/14/angular.json +++ b/frameworks/angular/14/angular.json @@ -98,5 +98,8 @@ } } } + }, + "cli": { + "analytics": false } }