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
1=== modified file 'django_project/config/main.cfg'
2--- django_project/config/main.cfg 2011-09-15 11:25:35 +0000
3+++ django_project/config/main.cfg 2012-01-06 14:43:36 +0000
4@@ -95,7 +95,7 @@
5 default_distro = natty
6
7 [google]
8-google_analytics_id = UA-1018242-24
9+google_analytics_id = UA-1018242-36
10
11 [rnr]
12 rnr_service_root = http://reviews.ubuntu.com/reviews/api/1.0
13
14=== modified file 'fabtasks/bootstrap.py'
15--- fabtasks/bootstrap.py 2011-11-17 15:58:00 +0000
16+++ fabtasks/bootstrap.py 2012-01-06 14:43:36 +0000
17@@ -58,18 +58,31 @@
18 _symlink(filename, 'virtualenv/lib/python2.%s/site-packages/%s' %
19 (minor, basename))
20
21- _symlink_libs([
22- '/usr/lib/pymodules/python2.%s/gtk-2.0' % minor,
23- '/usr/lib/pymodules/python2.%s/cairo' % minor,
24- ])
25+ gtk_dir_preoneiric = '/usr/lib/pymodules/python2.%s/gtk-2.0' % minor
26+ gtk_dir_oneiric = '/usr/lib/python2.%s/dist-packages/gtk-2.0' % minor
27+ if os.path.exists(gtk_dir_preoneiric):
28+ # Ubuntu Lucid / Maverick / Natty setup
29+ _symlink_libs([
30+ gtk_dir_preoneiric,
31+ '/usr/lib/pymodules/python2.%s/cairo' % minor,
32+ ])
33+ else:
34+ # Ubuntu Oneiric setup
35+ _symlink_libs([
36+ gtk_dir_oneiric,
37+ '/usr/lib/python2.%s/dist-packages/cairo' % minor,
38+ ])
39+
40 pth_file_prenatty = '/usr/lib/pymodules/python2.%s/pygtk.pth' % minor
41 pth_file_natty = '/usr/share/pyshared/pygtk.pth'
42 if os.path.exists(pth_file_prenatty):
43+ # Ubuntu Lucid / Maveric setup
44 _symlink_libs([
45 pth_file_prenatty,
46 '/usr/lib/pymodules/python2.%s/pygtk.py' % minor,
47 ])
48 elif os.path.exists(pth_file_natty):
49+ # Ubuntu Natty / Oneiric setup
50 _symlink_libs([
51 pth_file_natty,
52 '/usr/lib/pymodules/python2.%s/cairo' % minor,
53
54=== modified file 'src/webcatalog/context_processors.py'
55--- src/webcatalog/context_processors.py 2011-09-12 13:37:24 +0000
56+++ src/webcatalog/context_processors.py 2012-01-06 14:43:36 +0000
57@@ -23,6 +23,8 @@
58 """Adds the google analytics id to the context if it's present."""
59 return {
60 'google_analytics_id': getattr(settings, 'GOOGLE_ANALYTICS_ID', None),
61+ 'secondary_google_analytics_id':
62+ getattr(settings, 'SECONDARY_GOOGLE_ANALYTICS_ID', None),
63 }
64
65
66
67=== modified file 'src/webcatalog/schema.py'
68--- src/webcatalog/schema.py 2011-09-15 11:25:35 +0000
69+++ src/webcatalog/schema.py 2012-01-06 14:43:36 +0000
70@@ -63,6 +63,7 @@
71
72 google = ConfigSection()
73 google.google_analytics_id = StringConfigOption()
74+ google.secondary_google_analytics_id = StringConfigOption()
75
76 logging = ConfigSection()
77 logging.webapp_logging_config = StringConfigOption()
78
79=== modified file 'src/webcatalog/templates/light/index.1col.html'
80--- src/webcatalog/templates/light/index.1col.html 2011-04-12 13:16:43 +0000
81+++ src/webcatalog/templates/light/index.1col.html 2012-01-06 14:43:36 +0000
82@@ -141,12 +141,20 @@
83 <p>&copy; 2010, 2011 Canonical Ltd. Ubuntu and Canonical are registered trademarks of Canonical Ltd.</p>
84 </div>
85 </div>
86+
87 {% if google_analytics_id %}
88 <script type="text/javascript">
89
90 var _gaq = _gaq || [];
91 _gaq.push(['_setAccount', '{{ google_analytics_id }}']);
92+ _gaq.push(['_setDomainName', '.ubuntu.com']);
93 _gaq.push(['_trackPageview']);
94+ {% if secondary_google_analytics_id %}
95+ /* save to www.ubuntu.com (http://www.ubuntu.com) profile */
96+ _gaq.push(['b._setAccount', '{{ secondary_google_analytics_id }}']);
97+ _gaq.push(['b._setDomainName', '.ubuntu.com (http://ubuntu.com)']);
98+ _gaq.push(['b._trackPageview']);
99+ {% endif %}
100
101 (function() {
102 var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
103
104=== modified file 'src/webcatalog/tests/__init__.py'
105--- src/webcatalog/tests/__init__.py 2011-09-12 13:37:24 +0000
106+++ src/webcatalog/tests/__init__.py 2012-01-06 14:43:36 +0000
107@@ -18,6 +18,7 @@
108 """Import various view, model and other tests for django's default runner."""
109 from .test_api import *
110 from .test_commands import *
111+from .test_context_processors import *
112 from .test_department_filters import *
113 from .test_forms import *
114 from .test_handlers import *
115
116=== added file 'src/webcatalog/tests/test_context_processors.py'
117--- src/webcatalog/tests/test_context_processors.py 1970-01-01 00:00:00 +0000
118+++ src/webcatalog/tests/test_context_processors.py 2012-01-06 14:43:36 +0000
119@@ -0,0 +1,41 @@
120+# -*- coding: utf-8 -*-
121+# This file is part of the Apps Directory
122+# Copyright (C) 2011 Canonical Ltd.
123+#
124+# This program is free software: you can redistribute it and/or modify
125+# it under the terms of the GNU Affero General Public License as
126+# published by the Free Software Foundation, either version 3 of the
127+# License, or (at your option) any later version.
128+#
129+# This program is distributed in the hope that it will be useful,
130+# but WITHOUT ANY WARRANTY; without even the implied warranty of
131+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
132+# GNU Affero General Public License for more details.
133+#
134+# You should have received a copy of the GNU Affero General Public License
135+# along with this program. If not, see <http://www.gnu.org/licenses/>.
136+
137+"""Apps Directory context processor tests."""
138+
139+from __future__ import absolute_import
140+
141+__metaclass__ = type
142+__all__ = [
143+ 'GoogleAnalyticsTestCase',
144+ ]
145+
146+from django.core.urlresolvers import reverse
147+from django.test import TestCase
148+
149+from webcatalog.tests.helpers import patch_settings
150+
151+
152+class GoogleAnalyticsTestCase(TestCase):
153+ def test_configured_analytics_ids_show_up(self):
154+ with patch_settings(GOOGLE_ANALYTICS_ID='foo',
155+ SECONDARY_GOOGLE_ANALYTICS_ID='bar'):
156+ response = self.client.get(reverse('wc-index'))
157+ snippets = ["_gaq.push(['_setAccount', 'foo'])",
158+ "_gaq.push(['b._setAccount', 'bar'])"]
159+ for snippet in snippets:
160+ self.assertContains(response, snippet)

Subscribers

People subscribed via source and target branches