extract ga code and setup
This commit is contained in:
parent
8061e57814
commit
0322e1a3c8
|
@ -3,10 +3,8 @@ require 'travis/location'
|
|||
Ember.Route.reopen
|
||||
enter: (router) ->
|
||||
@_super(router)
|
||||
if @get('isLeafRoute')
|
||||
path = @absoluteRoute(router)
|
||||
if window.location.origin == 'https://travis-ci.org'
|
||||
_gaq.push(['_trackPageview', path]);
|
||||
if @get('isLeafRoute') && !window.location.host.match(/^staging\.|^localhost/)
|
||||
_gaq.push(['_trackPageview', @absoluteRoute(router)])
|
||||
|
||||
defaultRoute = Ember.Route.extend
|
||||
route: '/'
|
||||
|
|
|
@ -33,6 +33,7 @@ Storage = Em.Object.extend
|
|||
config:
|
||||
api_endpoint: $('meta[rel="travis.api_endpoint"]').attr('href')
|
||||
pusher_key: $('meta[name="travis.pusher_key"]').attr('value')
|
||||
ga_code: $('meta[name="travis.ga_code"]').attr('value')
|
||||
|
||||
CONFIG_KEYS: ['rvm', 'gemfile', 'env', 'jdk', 'otp_release', 'php', 'node_js', 'perl', 'python', 'scala', 'compiler']
|
||||
|
||||
|
@ -110,3 +111,4 @@ require 'ext/i18n'
|
|||
require 'travis/ajax'
|
||||
require 'app'
|
||||
|
||||
setupGoogleAnalytics()
|
||||
|
|
9
assets/scripts/vendor/ga.js
vendored
Normal file
9
assets/scripts/vendor/ga.js
vendored
Normal file
|
@ -0,0 +1,9 @@
|
|||
var setupGoogleAnalytics = function() {
|
||||
var _gaq = _gaq || [];
|
||||
_gaq.push(['_setAccount', Travis.config.ga_code]);
|
||||
_gaq.push(['_trackPageview']);
|
||||
|
||||
var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
|
||||
ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
|
||||
var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
|
||||
}
|
|
@ -29,5 +29,6 @@ run Travis::Web::App.new(
|
|||
environment: ENV['RACK_ENV'] || 'development',
|
||||
api_endpoint: ENV['API_ENDPOINT'],
|
||||
pusher_key: ENV['PUSHER_KEY'],
|
||||
ga_code: ENV['GA_CODE'],
|
||||
root: File.expand_path('../public', __FILE__)
|
||||
)
|
||||
|
|
|
@ -4,6 +4,7 @@
|
|||
<meta charset="UTF-8">
|
||||
<meta rel="travis.api_endpoint" href="https://api.travis-ci.org">
|
||||
<meta name="travis.pusher_key" value="5df8ac576dcccf4fd076">
|
||||
<meta name="travis.ga_code" value="UA-24868285-1">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<title>Travis CI - Free Hosted Continuous Integration Platform for the Open Source Community</title>
|
||||
<link rel="dns-prefetch" href="//api.travis-ci.org">
|
||||
|
@ -19,17 +20,5 @@
|
|||
</script>
|
||||
</head>
|
||||
<body id="home"></body>
|
||||
|
||||
<script type="text/javascript">
|
||||
var _gaq = _gaq || [];
|
||||
_gaq.push(['_setAccount', 'UA-24868285-1']);
|
||||
_gaq.push(['_trackPageview']);
|
||||
|
||||
(function() {
|
||||
var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
|
||||
ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
|
||||
var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
|
||||
})();
|
||||
</script>
|
||||
</html>
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user