Merge lp:~elachuni/ubuntu-webcatalog/more-analytics into lp:ubuntu-webcatalog

Proposed by Anthony Lenton
Status: Merged
Approved by: Michael Nelson
Approved revision: 61
Merged at revision: 59
Proposed branch: lp:~elachuni/ubuntu-webcatalog/more-analytics
Merge into: lp:ubuntu-webcatalog
Diff against target: 160 lines (+71/-5)
7 files modified
django_project/config/main.cfg (+1/-1)
fabtasks/bootstrap.py (+17/-4)
src/webcatalog/context_processors.py (+2/-0)
src/webcatalog/schema.py (+1/-0)
src/webcatalog/templates/light/index.1col.html (+8/-0)
src/webcatalog/tests/__init__.py (+1/-0)
src/webcatalog/tests/test_context_processors.py (+41/-0)
To merge this branch: bzr merge lp:~elachuni/ubuntu-webcatalog/more-analytics
Reviewer Review Type Date Requested Status
Michael Nelson (community) Approve
Review via email: mp+87758@code.launchpad.net

Commit message

Added a secondary Google Analytics ID

Description of the change

Overview
========
This branch adds a secondary Google Analytics ID, to aggregate information with the general Ubuntu.com stats

Details
=======
A pretty straight forward change, via a setting and a context processor like the original google analytics id was added.

While I was there, I sorted out the bootstrap fab task on Oneiric.

To post a comment you must log in.
Revision history for this message
Michael Nelson (michael.nelson) wrote :

14:43 < achuni> noodles: if you have a while, could you have a look? https://code.launchpad.net/~elachuni/ubuntu-webcatalog/more-analytics/+merge/87758
14:44 < noodles> Sure thing
14:46 < noodles> achuni: is that a real ga-id on line 9? Does that mean our dev servers will be contributing to analytics? (not something you changed, but just worth asking :-)
14:47 < achuni> noodles: -36 is the staging id, so yep. Before, -24 meant that yes our dev server was contributing to analytics
14:48 < achuni> noodles: it should be ok to leave -36 in for dev, as we use the same id for all staging services nobody really takes those seriously
14:49 < noodles> achuni: sweet
14:50 < noodles> achuni: have you tested the bootstrap on lucid? (I can do so on my canonistack lucid instance, if not)
14:50 < achuni> noodles: not with the latest changes, nope, if you could that would be great
14:54 < noodles> achuni: bootstrapped fine on lucid with all tests passing.
14:54 < achuni> neat
14:54 < achuni> txs noodles
14:56 < noodles> achuni: the code+test look great - I assume it doesn't add significantly to the page load time? Might be worth a quick test using any web-dev tools. Anyway, approving.
14:57 < achuni> noodles: it doesn't add a noticeable wait to the page load, and we've got that code in place on sca/devportal already
14:57 < noodles> Great.

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'django_project/config/main.cfg'
--- django_project/config/main.cfg 2011-09-15 11:25:35 +0000
+++ django_project/config/main.cfg 2012-01-06 14:43:36 +0000
@@ -95,7 +95,7 @@
95default_distro = natty95default_distro = natty
9696
97[google]97[google]
98google_analytics_id = UA-1018242-2498google_analytics_id = UA-1018242-36
9999
100[rnr]100[rnr]
101rnr_service_root = http://reviews.ubuntu.com/reviews/api/1.0101rnr_service_root = http://reviews.ubuntu.com/reviews/api/1.0
102102
=== modified file 'fabtasks/bootstrap.py'
--- fabtasks/bootstrap.py 2011-11-17 15:58:00 +0000
+++ fabtasks/bootstrap.py 2012-01-06 14:43:36 +0000
@@ -58,18 +58,31 @@
58 _symlink(filename, 'virtualenv/lib/python2.%s/site-packages/%s' %58 _symlink(filename, 'virtualenv/lib/python2.%s/site-packages/%s' %
59 (minor, basename))59 (minor, basename))
6060
61 _symlink_libs([61 gtk_dir_preoneiric = '/usr/lib/pymodules/python2.%s/gtk-2.0' % minor
62 '/usr/lib/pymodules/python2.%s/gtk-2.0' % minor,62 gtk_dir_oneiric = '/usr/lib/python2.%s/dist-packages/gtk-2.0' % minor
63 '/usr/lib/pymodules/python2.%s/cairo' % minor,63 if os.path.exists(gtk_dir_preoneiric):
64 ])64 # Ubuntu Lucid / Maverick / Natty setup
65 _symlink_libs([
66 gtk_dir_preoneiric,
67 '/usr/lib/pymodules/python2.%s/cairo' % minor,
68 ])
69 else:
70 # Ubuntu Oneiric setup
71 _symlink_libs([
72 gtk_dir_oneiric,
73 '/usr/lib/python2.%s/dist-packages/cairo' % minor,
74 ])
75
65 pth_file_prenatty = '/usr/lib/pymodules/python2.%s/pygtk.pth' % minor76 pth_file_prenatty = '/usr/lib/pymodules/python2.%s/pygtk.pth' % minor
66 pth_file_natty = '/usr/share/pyshared/pygtk.pth'77 pth_file_natty = '/usr/share/pyshared/pygtk.pth'
67 if os.path.exists(pth_file_prenatty):78 if os.path.exists(pth_file_prenatty):
79 # Ubuntu Lucid / Maveric setup
68 _symlink_libs([80 _symlink_libs([
69 pth_file_prenatty,81 pth_file_prenatty,
70 '/usr/lib/pymodules/python2.%s/pygtk.py' % minor,82 '/usr/lib/pymodules/python2.%s/pygtk.py' % minor,
71 ])83 ])
72 elif os.path.exists(pth_file_natty):84 elif os.path.exists(pth_file_natty):
85 # Ubuntu Natty / Oneiric setup
73 _symlink_libs([86 _symlink_libs([
74 pth_file_natty,87 pth_file_natty,
75 '/usr/lib/pymodules/python2.%s/cairo' % minor,88 '/usr/lib/pymodules/python2.%s/cairo' % minor,
7689
=== modified file 'src/webcatalog/context_processors.py'
--- src/webcatalog/context_processors.py 2011-09-12 13:37:24 +0000
+++ src/webcatalog/context_processors.py 2012-01-06 14:43:36 +0000
@@ -23,6 +23,8 @@
23 """Adds the google analytics id to the context if it's present."""23 """Adds the google analytics id to the context if it's present."""
24 return {24 return {
25 'google_analytics_id': getattr(settings, 'GOOGLE_ANALYTICS_ID', None),25 'google_analytics_id': getattr(settings, 'GOOGLE_ANALYTICS_ID', None),
26 'secondary_google_analytics_id':
27 getattr(settings, 'SECONDARY_GOOGLE_ANALYTICS_ID', None),
26 }28 }
2729
2830
2931
=== modified file 'src/webcatalog/schema.py'
--- src/webcatalog/schema.py 2011-09-15 11:25:35 +0000
+++ src/webcatalog/schema.py 2012-01-06 14:43:36 +0000
@@ -63,6 +63,7 @@
6363
64 google = ConfigSection()64 google = ConfigSection()
65 google.google_analytics_id = StringConfigOption()65 google.google_analytics_id = StringConfigOption()
66 google.secondary_google_analytics_id = StringConfigOption()
6667
67 logging = ConfigSection()68 logging = ConfigSection()
68 logging.webapp_logging_config = StringConfigOption()69 logging.webapp_logging_config = StringConfigOption()
6970
=== modified file 'src/webcatalog/templates/light/index.1col.html'
--- src/webcatalog/templates/light/index.1col.html 2011-04-12 13:16:43 +0000
+++ src/webcatalog/templates/light/index.1col.html 2012-01-06 14:43:36 +0000
@@ -141,12 +141,20 @@
141 <p>&copy; 2010, 2011 Canonical Ltd. Ubuntu and Canonical are registered trademarks of Canonical Ltd.</p>141 <p>&copy; 2010, 2011 Canonical Ltd. Ubuntu and Canonical are registered trademarks of Canonical Ltd.</p>
142 </div>142 </div>
143 </div>143 </div>
144
144 {% if google_analytics_id %}145 {% if google_analytics_id %}
145 <script type="text/javascript">146 <script type="text/javascript">
146147
147 var _gaq = _gaq || [];148 var _gaq = _gaq || [];
148 _gaq.push(['_setAccount', '{{ google_analytics_id }}']);149 _gaq.push(['_setAccount', '{{ google_analytics_id }}']);
150 _gaq.push(['_setDomainName', '.ubuntu.com']);
149 _gaq.push(['_trackPageview']);151 _gaq.push(['_trackPageview']);
152 {% if secondary_google_analytics_id %}
153 /* save to www.ubuntu.com (http://www.ubuntu.com) profile */
154 _gaq.push(['b._setAccount', '{{ secondary_google_analytics_id }}']);
155 _gaq.push(['b._setDomainName', '.ubuntu.com (http://ubuntu.com)']);
156 _gaq.push(['b._trackPageview']);
157 {% endif %}
150158
151 (function() {159 (function() {
152 var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;160 var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
153161
=== modified file 'src/webcatalog/tests/__init__.py'
--- src/webcatalog/tests/__init__.py 2011-09-12 13:37:24 +0000
+++ src/webcatalog/tests/__init__.py 2012-01-06 14:43:36 +0000
@@ -18,6 +18,7 @@
18"""Import various view, model and other tests for django's default runner."""18"""Import various view, model and other tests for django's default runner."""
19from .test_api import *19from .test_api import *
20from .test_commands import *20from .test_commands import *
21from .test_context_processors import *
21from .test_department_filters import *22from .test_department_filters import *
22from .test_forms import *23from .test_forms import *
23from .test_handlers import *24from .test_handlers import *
2425
=== added file 'src/webcatalog/tests/test_context_processors.py'
--- src/webcatalog/tests/test_context_processors.py 1970-01-01 00:00:00 +0000
+++ src/webcatalog/tests/test_context_processors.py 2012-01-06 14:43:36 +0000
@@ -0,0 +1,41 @@
1# -*- coding: utf-8 -*-
2# This file is part of the Apps Directory
3# Copyright (C) 2011 Canonical Ltd.
4#
5# This program is free software: you can redistribute it and/or modify
6# it under the terms of the GNU Affero General Public License as
7# published by the Free Software Foundation, either version 3 of the
8# License, or (at your option) any later version.
9#
10# This program is distributed in the hope that it will be useful,
11# but WITHOUT ANY WARRANTY; without even the implied warranty of
12# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13# GNU Affero General Public License for more details.
14#
15# You should have received a copy of the GNU Affero General Public License
16# along with this program. If not, see <http://www.gnu.org/licenses/>.
17
18"""Apps Directory context processor tests."""
19
20from __future__ import absolute_import
21
22__metaclass__ = type
23__all__ = [
24 'GoogleAnalyticsTestCase',
25 ]
26
27from django.core.urlresolvers import reverse
28from django.test import TestCase
29
30from webcatalog.tests.helpers import patch_settings
31
32
33class GoogleAnalyticsTestCase(TestCase):
34 def test_configured_analytics_ids_show_up(self):
35 with patch_settings(GOOGLE_ANALYTICS_ID='foo',
36 SECONDARY_GOOGLE_ANALYTICS_ID='bar'):
37 response = self.client.get(reverse('wc-index'))
38 snippets = ["_gaq.push(['_setAccount', 'foo'])",
39 "_gaq.push(['b._setAccount', 'bar'])"]
40 for snippet in snippets:
41 self.assertContains(response, snippet)

Subscribers

People subscribed via source and target branches