-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #3224 from alphagov/ga4-refactor
Refactor GA4 code
- Loading branch information
Showing
24 changed files
with
213 additions
and
133 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
class FacetsIterator | ||
delegate :select, :any?, to: :@facets | ||
|
||
def initialize(facets) | ||
@facets = facets | ||
@facets_with_ga4_section = @facets.select(&:has_ga4_section?) | ||
end | ||
|
||
def each_with_index_and_count | ||
@facets.each do |facet| | ||
yield facet, @facets_with_ga4_section.index(facet), @facets_with_ga4_section.count | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -45,6 +45,10 @@ def query_params | |
{ key => date_values } | ||
end | ||
|
||
def ga4_section | ||
name | ||
end | ||
|
||
private | ||
|
||
def value_fragments | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -72,6 +72,10 @@ def closed_on_load_mobile? | |
open_on_load? | ||
end | ||
|
||
def ga4_section | ||
name | ||
end | ||
|
||
private | ||
|
||
def value_fragments | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -37,6 +37,10 @@ def allowed_values | |
@filter_hashes | ||
end | ||
|
||
def ga4_section | ||
"" | ||
end | ||
|
||
private | ||
|
||
attr_reader :filter_hashes | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -43,6 +43,10 @@ def query_params | |
} | ||
end | ||
|
||
def ga4_section | ||
"Topic" | ||
end | ||
|
||
private | ||
|
||
def value_fragments | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,4 +6,8 @@ def allowed_values | |
def to_partial_path | ||
"option_select_facet" | ||
end | ||
|
||
def ga4_section | ||
name | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,21 @@ | ||
<span data-ga4-change-category="update-filter text"> | ||
<%= | ||
render "components/date_filter", { | ||
<%= render "components/date_filter", { | ||
name: date_facet.name, | ||
key: date_facet.key, | ||
from_value: date_facet.user_supplied_from_date, | ||
to_value: date_facet.user_supplied_to_date, | ||
aria_controls_id: "js-search-results-info", | ||
date_errors_to: date_facet.error_message_to(@search_query), | ||
date_errors_from: date_facet.error_message_from(@search_query) | ||
date_errors_from: date_facet.error_message_from(@search_query), | ||
data_attributes: { "ga4-filter-parent": date_facet.ga4_section, "ga4-index": { index_section: index + 1, index_section_count: count } }, | ||
button_data_attributes: { | ||
ga4_expandable: "", | ||
ga4_event: { | ||
event_name: 'select_content', | ||
type: 'finder', | ||
section: date_facet.name, | ||
index: { index_section: index + 1, index_section_count: count } | ||
} | ||
} | ||
} %> | ||
</span> |
Oops, something went wrong.