govuk_ab_testing 2.4.3 → 3.0.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 6a292ccc01842df0545f9ddfeec92414895271e6127c1cd9905ea30a152f3f58
4
- data.tar.gz: 75d28b74e22e0efa9137e7e033daebafd697012fd9f2f17a876fc40c4ef3e66c
3
+ metadata.gz: 2d473c839937d932bfad0e7dc33673c907f47dedffdf15d1b5bc4bd2d9c61df1
4
+ data.tar.gz: 4ba58b2b6b499b8b670fff033740d3efb8ce421a0d5f561a58bb4b028968fd36
5
5
  SHA512:
6
- metadata.gz: 0d88b6a20a1c3ffae1bc55abb2deba0cfeec443a12c8d0adad615475de3b889c3ec502bb8bdef5d49fff548cef4bc7bf56eaf826d11322d7a4a554dd8b92c9c2
7
- data.tar.gz: e7d98c27fa20cde80ea0ddfbe28be2f9274a6a668257b2cc266387e0db12b1a374b1dbecff1826cceb1bfd9e8aa38386a243c7437bae3eb1d4b31a32b9112525
6
+ metadata.gz: 2e5f893dcd4b96da54646fa5f951f7949f1d3e499cc51fe84b22b3869f281857ca74259ee927a4337a50a34dc50b6ef24460f578ed3af38c26b0c8dde0cad366
7
+ data.tar.gz: b438372d3a2a309acbe83dde157cd09a5a9f857ddf03ad28009e10cd212cb4034716b831fa87f41c301ee892329f9c5e3f47d8d23eb49dd34e2f3a9135f6b752
@@ -1,16 +1,25 @@
1
1
  on: [push, pull_request]
2
2
 
3
3
  jobs:
4
+ codeql-sast:
5
+ name: CodeQL SAST scan
6
+ uses: alphagov/govuk-infrastructure/.github/workflows/codeql-analysis.yml@main
7
+ permissions:
8
+ security-events: write
9
+
10
+ dependency-review:
11
+ name: Dependency Review scan
12
+ uses: alphagov/govuk-infrastructure/.github/workflows/dependency-review.yml@main
13
+
4
14
  # This matrix job runs the test suite against multiple Ruby versions
5
15
  test_matrix:
6
16
  strategy:
7
17
  fail-fast: false
8
18
  matrix:
9
- # Due to https://github.com/actions/runner/issues/849, we have to use quotes for '3.0'
10
- ruby: ['3.0', 3.1, 3.2]
19
+ ruby: [3.1, 3.2, 3.3]
11
20
  runs-on: ubuntu-latest
12
21
  steps:
13
- - uses: actions/checkout@v3
22
+ - uses: actions/checkout@v4
14
23
  - uses: ruby/setup-ruby@v1
15
24
  with:
16
25
  ruby-version: ${{ matrix.ruby }}
data/.ruby-version CHANGED
@@ -1 +1 @@
1
- 3.0.5
1
+ 3.1.4
data/CHANGELOG.md CHANGED
@@ -1,3 +1,10 @@
1
+ ## 3.0.0
2
+
3
+ * Drop support for Ruby 3.0. The minimum required Ruby version is now 3.1
4
+ * **BREAKING CHANGE** No longer allow a GA custom dimension to be passed
5
+ when creating a GovukAbTesting::AbTest object. The dimension parameter
6
+ needs to be removed.
7
+
1
8
  ## 2.4.3
2
9
 
3
10
  * Updated gem dependencies and development ruby version to 3.0.5
data/README.md CHANGED
@@ -18,19 +18,18 @@ And then execute:
18
18
 
19
19
  Before starting this, you'll need to:
20
20
 
21
- - [Read the documentation](https://docs.publishing.service.gov.uk/manual/ab-testing.html) for an overview on how a/b testing works on GOV.UK.
21
+ - [Read the documentation](https://docs.publishing.service.gov.uk/manual/ab-testing.html) for an overview on how a/b testing works on GOV.UK.
22
22
  - The cookie and header name in [govuk-cdn-config](https://github.com/alphagov/govuk-cdn-config/blob/master/ab_tests/ab_tests.yaml) must match the test name parameter that you pass to the Gem. The cookie name is case-sensitive.
23
23
 
24
24
  ## Usage
25
25
 
26
- ### Outline
26
+ ### Outline
27
27
 
28
28
  To enable testing in the app, your Rails app needs:
29
29
 
30
30
  1. [Some piece of logic to be A/B tested](#1-example-ab-test-logic)
31
31
  2. [A response HTTP header that tells Fastly you're doing an A/B test](#2-http-response-header-to-fastly)
32
- 3. [A HTML meta tag that will be used to measure the results, and which specifies
33
- the dimension to use in Google Analytics](#3-add-html-metatag-tags-to-your-layouts)
32
+ 3. [A HTML meta tag that will be used to measure the results in Google Analytics](#3-add-html-metatag-tags-to-your-layouts)
34
33
 
35
34
  ### 1. Example A/B test logic
36
35
 
@@ -42,7 +41,6 @@ class PartyController < ApplicationController
42
41
  def show
43
42
  ab_test = GovukAbTesting::AbTest.new(
44
43
  "your_ab_test_name",
45
- dimension: 300,
46
44
  allowed_variants: ['NoChange', 'LongTitle', 'ShortTitle'],
47
45
  control_variant: 'NoChange'
48
46
  )
@@ -63,7 +61,7 @@ end
63
61
 
64
62
  In this example, we are running a multivariate test with 3 options being
65
63
  tested: the existing version (control), and two title changes. The minimum
66
- number of variants in any test should be two.
64
+ number of variants in any test should be two.
67
65
 
68
66
  ### 2. HTTP response header to Fastly
69
67
 
@@ -148,7 +146,6 @@ As with the `minitest` version, you can also pass in the following options to
148
146
  `with_variant`:
149
147
 
150
148
  - `assert_meta_tag: false`
151
- - `dimension: <number>`
152
149
 
153
150
  #### Minitest
154
151
 
@@ -200,7 +197,7 @@ class PartyControllerTest < ActionController::TestCase
200
197
  include GovukAbTesting::MinitestHelpers
201
198
 
202
199
  should "show the original" do
203
- setup_ab_variant("your_ab_test_name", "B") # optionally pass in a analytics dimension as the third argument
200
+ setup_ab_variant("your_ab_test_name", "B")
204
201
 
205
202
  get :show
206
203
 
@@ -12,7 +12,7 @@ Gem::Specification.new do |spec|
12
12
  spec.description = "Gem to help with A/B testing on the GOV.UK platform"
13
13
  spec.homepage = "https://github.com/alphagov/govuk_ab_testing"
14
14
  spec.license = "MIT"
15
- spec.required_ruby_version = ">= 3.0"
15
+ spec.required_ruby_version = ">= 3.1"
16
16
 
17
17
  spec.files = `git ls-files -z`.split("\x0").reject do |f|
18
18
  f.match(%r{^(test|spec|features)/})
@@ -23,6 +23,6 @@ Gem::Specification.new do |spec|
23
23
 
24
24
  spec.add_development_dependency "rake"
25
25
  spec.add_development_dependency "rspec"
26
- spec.add_development_dependency "rubocop-govuk", "4.10.0"
26
+ spec.add_development_dependency "rubocop-govuk", "5.0.2"
27
27
  spec.add_development_dependency "yard"
28
28
  end
@@ -1,18 +1,15 @@
1
1
  module GovukAbTesting
2
2
  class AbTest
3
- attr_reader :ab_test_name, :dimension, :allowed_variants, :control_variant
3
+ attr_reader :ab_test_name, :allowed_variants, :control_variant
4
4
 
5
5
  alias_method :name, :ab_test_name
6
6
 
7
7
  # @param request [String] the name of the A/B test
8
- # @param dimension [Integer] the dimension registered with Google Analytics
9
- # for this specific A/B test
10
8
  # @param allowed_variants [Array] an array of Strings representing the
11
9
  # possible variants
12
10
  # @param control_variant [String] the control variant (typically 'A')
13
- def initialize(ab_test_name, dimension:, allowed_variants: %w[A B], control_variant: "A")
11
+ def initialize(ab_test_name, allowed_variants: %w[A B], control_variant: "A")
14
12
  @ab_test_name = ab_test_name
15
- @dimension = dimension
16
13
  @allowed_variants = allowed_variants
17
14
  @control_variant = control_variant
18
15
  end
@@ -20,7 +17,7 @@ module GovukAbTesting
20
17
  # @param request [ActionDispatch::Http::Headers] the `request.headers` in
21
18
  # the controller.
22
19
  def requested_variant(request_headers)
23
- RequestedVariant.new(self, request_headers, @dimension)
20
+ RequestedVariant.new(self, request_headers)
24
21
  end
25
22
 
26
23
  # Internal name of the header
@@ -6,26 +6,25 @@ module GovukAbTesting
6
6
 
7
7
  def with_variant(args)
8
8
  ab_test_name, variant = args.first
9
- dimension = args[:dimension]
10
9
 
11
- setup_ab_variant(ab_test_name, variant, dimension)
10
+ setup_ab_variant(ab_test_name, variant)
12
11
 
13
12
  yield
14
13
 
15
14
  assert_response_is_cached_by_variant(ab_test_name)
16
15
 
17
16
  unless args[:assert_meta_tag] == false
18
- assert_page_tracked_in_ab_test(ab_test_name, variant, dimension)
17
+ assert_page_tracked_in_ab_test(ab_test_name, variant)
19
18
  end
20
19
  end
21
20
 
22
- def setup_ab_variant(ab_test_name, variant, dimension = 300)
23
- ab_test = AbTest.new(ab_test_name, dimension: dimension)
21
+ def setup_ab_variant(ab_test_name, variant)
22
+ ab_test = AbTest.new(ab_test_name)
24
23
  acceptance_test_framework.set_header(ab_test.request_header, variant)
25
24
  end
26
25
 
27
26
  def assert_response_is_cached_by_variant(ab_test_name)
28
- ab_test = AbTest.new(ab_test_name, dimension: 300)
27
+ ab_test = AbTest.new(ab_test_name)
29
28
  vary_header_value = acceptance_test_framework.vary_header
30
29
 
31
30
  assert_contains_substring(
@@ -72,8 +71,8 @@ module GovukAbTesting
72
71
  )
73
72
  end
74
73
 
75
- def assert_page_tracked_in_ab_test(ab_test_name, variant, dimension)
76
- ab_test = AbTest.new(ab_test_name, dimension: dimension)
74
+ def assert_page_tracked_in_ab_test(ab_test_name, variant)
75
+ ab_test = AbTest.new(ab_test_name)
77
76
 
78
77
  ab_test_meta_tags =
79
78
  acceptance_test_framework.analytics_meta_tags_for_test(ab_test.name)
@@ -104,23 +103,6 @@ module GovukAbTesting
104
103
 
105
104
  ERROR
106
105
  )
107
-
108
- assert_not_blank(
109
- string: meta_tag.dimension,
110
- error_message: <<-ERROR,
111
- The meta tag dimension for the '#{ab_test_name}' A/B test is blank.
112
- ERROR
113
- )
114
-
115
- unless ab_test.dimension.nil?
116
- assert_is_equal(
117
- expected: ab_test.dimension.to_s,
118
- actual: meta_tag.dimension.to_s,
119
- error_message: <<-ERROR,
120
- The analytics meta tag for the '#{ab_test.name}' A/B test does not match the expected value.
121
- ERROR
122
- )
123
- end
124
106
  end
125
107
  end
126
108
  end
@@ -44,7 +44,6 @@ module GovukAbTesting
44
44
  tags.map do |tag|
45
45
  MetaTag.new(
46
46
  content: tag.attributes["content"].value,
47
- dimension: tag.attributes["data-analytics-dimension"].value,
48
47
  )
49
48
  end
50
49
  end
@@ -37,7 +37,6 @@ module GovukAbTesting
37
37
  tags.map do |tag|
38
38
  MetaTag.new(
39
39
  content: tag["content"],
40
- dimension: tag["data-analytics-dimension"],
41
40
  )
42
41
  end
43
42
  end
@@ -1,11 +1,10 @@
1
1
  module GovukAbTesting
2
2
  module AcceptanceTests
3
3
  class MetaTag
4
- attr_reader :content, :dimension
4
+ attr_reader :content
5
5
 
6
- def initialize(content:, dimension:)
6
+ def initialize(content:)
7
7
  @content = content
8
- @dimension = dimension
9
8
  end
10
9
 
11
10
  def for_ab_test?(ab_test_name)
@@ -17,7 +17,7 @@ module GovukAbTesting
17
17
  end
18
18
 
19
19
  def assert_is_empty(enumerable:, error_message:)
20
- assert_has_size(enumerable: enumerable, size: 0, error_message: error_message)
20
+ assert_has_size(enumerable:, size: 0, error_message:)
21
21
  end
22
22
 
23
23
  def assert_not_blank(string:, error_message:)
@@ -5,12 +5,9 @@ module GovukAbTesting
5
5
  # @param ab_test [AbTest] the A/B test being performed
6
6
  # @param request_headers [ActionDispatch::Http::Headers] the
7
7
  # `request.headers` in the controller.
8
- # @param dimension [Integer] the dimension registered with Google Analytics
9
- # for this specific A/B test
10
- def initialize(ab_test, request_headers, dimension)
8
+ def initialize(ab_test, request_headers)
11
9
  @ab_test = ab_test
12
10
  @request_headers = request_headers
13
- @dimension = dimension
14
11
  end
15
12
 
16
13
  # Get the bucket this user is in
@@ -66,7 +63,6 @@ module GovukAbTesting
66
63
  tag = <<~HTML
67
64
  <meta name="govuk:ab-test"
68
65
  content="#{ab_test.meta_tag_name}:#{variant_name}"
69
- data-analytics-dimension="#{@dimension}"
70
66
  data-allowed-variants="#{ab_test.allowed_variants.join(',')}">
71
67
  HTML
72
68
 
@@ -1,3 +1,3 @@
1
1
  module GovukAbTesting
2
- VERSION = "2.4.3".freeze
2
+ VERSION = "3.0.0".freeze
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: govuk_ab_testing
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.4.3
4
+ version: 3.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - GOV.UK Dev
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2023-03-21 00:00:00.000000000 Z
11
+ date: 2024-08-13 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rake
@@ -44,14 +44,14 @@ dependencies:
44
44
  requirements:
45
45
  - - '='
46
46
  - !ruby/object:Gem::Version
47
- version: 4.10.0
47
+ version: 5.0.2
48
48
  type: :development
49
49
  prerelease: false
50
50
  version_requirements: !ruby/object:Gem::Requirement
51
51
  requirements:
52
52
  - - '='
53
53
  - !ruby/object:Gem::Version
54
- version: 4.10.0
54
+ version: 5.0.2
55
55
  - !ruby/object:Gem::Dependency
56
56
  name: yard
57
57
  requirement: !ruby/object:Gem::Requirement
@@ -112,14 +112,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
112
112
  requirements:
113
113
  - - ">="
114
114
  - !ruby/object:Gem::Version
115
- version: '3.0'
115
+ version: '3.1'
116
116
  required_rubygems_version: !ruby/object:Gem::Requirement
117
117
  requirements:
118
118
  - - ">="
119
119
  - !ruby/object:Gem::Version
120
120
  version: '0'
121
121
  requirements: []
122
- rubygems_version: 3.4.9
122
+ rubygems_version: 3.5.17
123
123
  signing_key:
124
124
  specification_version: 4
125
125
  summary: Gem to help with A/B testing on the GOV.UK platform