File tree Expand file tree Collapse file tree
lib/polish_open_source_rank/web/presentation
spec/polish_open_source_rank/web Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1010
1111 window . gtag ( "js" , new Date ( ) ) ;
1212 window . gtag ( "config" , measurementId ) ;
13-
14- const script = document . createElement ( "script" ) ;
15- script . async = true ;
16- script . src = `https://www.googletagmanager.com/gtag/js?id=${ encodeURIComponent ( measurementId ) } ` ;
17- document . head . appendChild ( script ) ;
1813} ) ( ) ;
Original file line number Diff line number Diff line change 4747 </ script >
4848 < script defer src ="<%= h asset_path ( '/js/navigation.js' ) %> "> </ script >
4949 <% if google_analytics_measurement_id %>
50- < script defer src ="<%= h asset_path ( '/js/google_analytics.js' ) %> "> </ script >
50+ < script src ="<%= h asset_path ( '/js/google_analytics.js' ) %> "> </ script >
51+ < script async src ="<%= h google_analytics_script_url %> "> </ script >
5152 <% end %>
5253 </ head >
5354 < body >
Original file line number Diff line number Diff line change @@ -37,6 +37,10 @@ def google_analytics_measurement_id
3737 measurement_id . empty? ? nil : measurement_id
3838 end
3939
40+ def google_analytics_script_url
41+ "https://www.googletagmanager.com/gtag/js?#{ Rack ::Utils . build_query ( id : google_analytics_measurement_id ) } "
42+ end
43+
4044 def number ( value )
4145 value . to_i . to_s . reverse . gsub ( /(\d {3})(?=\d )/ , '\1 ' ) . reverse
4246 end
Original file line number Diff line number Diff line change @@ -155,6 +155,9 @@ def user(_access_token)
155155 '<meta name="google-analytics-measurement-id" content="G-ABC123DEF4">'
156156 )
157157 expect ( with_analytics . body ) . to include ( '/js/google_analytics.js' )
158+ expect ( with_analytics . body ) . to include (
159+ '<script async src="https://www.googletagmanager.com/gtag/js?id=G-ABC123DEF4"></script>'
160+ )
158161 end
159162
160163 it 'redirects legacy latest ranking routes to canonical section paths' , :aggregate_failures do
You can’t perform that action at this time.
0 commit comments