Merge lp:~openerp-dev/openobject-addons/7.0-mail_web_analytics-vta into lp:openobject-addons/7.0

Proposed by Victor Tabuenca (OpenERP)
Status: Work in progress
Proposed branch: lp:~openerp-dev/openobject-addons/7.0-mail_web_analytics-vta
Merge into: lp:openobject-addons/7.0
Diff against target: 161 lines (+142/-0)
3 files modified
web_analytics_mail/__init__.py (+24/-0)
web_analytics_mail/__openerp__.py (+34/-0)
web_analytics_mail/static/src/js/web_analytics_mail.js (+84/-0)
To merge this branch: bzr merge lp:~openerp-dev/openobject-addons/7.0-mail_web_analytics-vta
Reviewer Review Type Date Requested Status
Martin Trigaux (OpenERP) (community) Needs Fixing
Review via email: mp+143111@code.launchpad.net

Description of the change

Added Google Analytics tracking capabilities to mail module

To post a comment you must log in.
Revision history for this message
Martin Trigaux (OpenERP) (mat-openerp) wrote :

Could you resubmit this branch for trunk instead ? This
Related to the code :
- should be in autoinstall (?)
- instead of your dictionary in mail_actions, why don't you use the classname as key (eg: 'oe_read': 'Done') ? It will simplify your code
- why using once 'click' and once 'mousedown' ?

review: Needs Fixing

Unmerged revisions

8555. By vta <email address hidden>

[MERGE] Latest trunk

8554. By vta <email address hidden>

[FIX] Call super inside overriden methods, -_-U

8553. By vta <email address hidden>

[ADD] Added new module to track relevant events of mail module in GA

8552. By vta <email address hidden>

[MERGE] Latest trunk

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== added directory 'web_analytics_mail'
2=== added file 'web_analytics_mail/__init__.py'
3--- web_analytics_mail/__init__.py 1970-01-01 00:00:00 +0000
4+++ web_analytics_mail/__init__.py 2013-01-14 14:11:21 +0000
5@@ -0,0 +1,24 @@
6+# -*- coding: utf-8 -*-
7+##############################################################################
8+#
9+# OpenERP, Open Source Management Solution
10+# Copyright (C) 2009-Today OpenERP SA (<http://www.openerp.com>).
11+#
12+# This program is free software: you can redistribute it and/or modify
13+# it under the terms of the GNU Affero General Public License as
14+# published by the Free Software Foundation, either version 3 of the
15+# License, or (at your option) any later version.
16+#
17+# This program is distributed in the hope that it will be useful,
18+# but WITHOUT ANY WARRANTY; without even the implied warranty of
19+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20+# GNU Affero General Public License for more details.
21+#
22+# You should have received a copy of the GNU Affero General Public License
23+# along with this program. If not, see <http://www.gnu.org/licenses/>.
24+#
25+##############################################################################
26+
27+
28+
29+# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
30
31=== added file 'web_analytics_mail/__openerp__.py'
32--- web_analytics_mail/__openerp__.py 1970-01-01 00:00:00 +0000
33+++ web_analytics_mail/__openerp__.py 2013-01-14 14:11:21 +0000
34@@ -0,0 +1,34 @@
35+# -*- coding: utf-8 -*-
36+##############################################################################
37+#
38+# OpenERP, Open Source Management Solution
39+# Copyright (C) 2010-Today OpenERP S.A. (<http://www.openerp.com>).
40+#
41+# This program is free software: you can redistribute it and/or modify
42+# it under the terms of the GNU Affero General Public License as
43+# published by the Free Software Foundation, either version 3 of the
44+# License, or (at your option) any later version.
45+#
46+# This program is distributed in the hope that it will be useful,
47+# but WITHOUT ANY WARRANTY; without even the implied warranty of
48+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
49+# GNU Affero General Public License for more details.
50+#
51+# You should have received a copy of the GNU Affero General Public License
52+# along with this program. If not, see <http://www.gnu.org/licenses/>.
53+#
54+##############################################################################
55+
56+{
57+ 'name': 'Google Analytics for Mail',
58+ 'version': '1.0',
59+ 'description': """""",
60+ 'author': 'OpenERP SA',
61+ 'website': 'http://www.openerp.com',
62+ 'depends': ['mail', 'web_analytics'],
63+ 'installable': True,
64+ 'js': [
65+ 'static/src/js/web_analytics_mail.js',
66+ ],
67+}
68+# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
69
70=== added directory 'web_analytics_mail/static'
71=== added directory 'web_analytics_mail/static/src'
72=== added directory 'web_analytics_mail/static/src/js'
73=== added file 'web_analytics_mail/static/src/js/web_analytics_mail.js'
74--- web_analytics_mail/static/src/js/web_analytics_mail.js 1970-01-01 00:00:00 +0000
75+++ web_analytics_mail/static/src/js/web_analytics_mail.js 2013-01-14 14:11:21 +0000
76@@ -0,0 +1,84 @@
77+openerp.web_analytics_mail = function(instance) {
78+
79+ instance.web_analytics.Tracker.include({
80+ include_tracker: function() {
81+ this._super();
82+
83+ instance.mail.Widget.include({
84+ bind_events: function() {
85+ var self = this;
86+ this._super();
87+ var mail_actions = [
88+ {'classname': '.oe_read', 'action': 'Done'},
89+ {'classname': '.oe_reply', 'action': 'Reply'},
90+ {'classname': '.oe_star ', 'action': 'Mark as Todo'},
91+ {'classname': '.oe_msg_vote', 'action': 'Like/Unlike'},
92+ {'classname': '.oe_post', 'action': 'Post'},
93+ {'classname': '.oe_full', 'action': 'Open Composer'},
94+ {'classname': '.oe_unread', 'action': 'Move to Inbox'},
95+ {'classname': '.oe_add', 'action': 'Add Attachment'},
96+ ];
97+ var classes = ('' + _.map(mail_actions, function(mail_action) {
98+ return mail_action.classname;
99+ })).replace(/,/g, ', ');
100+
101+ this.$el.on('mousedown', classes, function (e) {
102+ var category;
103+ if (self.action.tag === 'mail.wall') {
104+ category = self.action.tag;
105+ } else {
106+ category = self.context.default_model;
107+ }
108+
109+ var action = _.filter(mail_actions, function(mail_action) {
110+ return e.currentTarget.className.indexOf(mail_action.classname.replace(/\./g, '')) > -1;
111+ })[0].action;
112+
113+ var url = instance.web_analytics.generateUrl({'object': category, 'action': action});
114+
115+ instance.webclient.tracker._push_event({
116+ 'category': category,
117+ 'action': action,
118+ 'label': url,
119+ 'noninteraction': true,
120+ });
121+ });
122+ },
123+ });
124+
125+ instance.mail_followers.Followers.include({
126+ bind_events: function() {
127+ var self = this;
128+ this._super();
129+ var follower_actions = [
130+ {'classname': '.oe_follower', 'action': 'Follow/Unfollow'},
131+ {'classname': '.oe_invite', 'action': 'Add others'},
132+ {'classname': '.oe_remove_follower', 'action': 'Remove Follower'},
133+ ];
134+
135+ var classes = ('' + _.map(follower_actions, function(follower_action) {
136+ return follower_action.classname;
137+ })).replace(/,/g, ', ');
138+
139+ this.$el.on('click', classes, function (e) {
140+ var category = self.view.model;
141+
142+ var action = _.filter(follower_actions, function(follower_action) {
143+ return e.currentTarget.className.indexOf(follower_action.classname.replace(/\./g, '')) > -1;
144+ })[0].action;
145+
146+ var url = instance.web_analytics.generateUrl({'object': category, 'action': action});
147+
148+ instance.webclient.tracker._push_event({
149+ 'category': category,
150+ 'action': action,
151+ 'label': url,
152+ 'noninteraction': true,
153+ });
154+ });
155+ },
156+ });
157+ },
158+ });
159+
160+};
161\ No newline at end of file