[FIX] Fixed naming, the account used in ga, and the controller.

bzr revid: vta@openerp.com-20121023151549-atepg5qan70xhmiq
This commit is contained in:
vta vta@openerp.com 2012-10-23 17:15:49 +02:00
parent 4f16b71910
commit 7d15ab44f4
6 changed files with 28 additions and 21 deletions

View File

@ -32,7 +32,6 @@ Collects web application usage with Google Analytics.
'author': 'OpenERP SA', 'author': 'OpenERP SA',
'website': 'http://openerp.com', 'website': 'http://openerp.com',
'depends': ['web'], 'depends': ['web'],
'icon': '/web_analytics/static/src/img/icon128.png',
'data': [], 'data': [],
'installable': True, 'installable': True,
'active': False, 'active': False,

View File

@ -11,16 +11,18 @@ class web_analytics(openerpweb.Controller):
# This controllers redirects virtual urls of the form /web_analytics/MODEL/VIEW # This controllers redirects virtual urls of the form /web_analytics/MODEL/VIEW
# as provided to google by the analytics modules to a real url that openerp can # as provided to google by the analytics modules to a real url that openerp can
# understand of the form /web/webclient/home/#model=MODEL&view_type=VIEW # understand of the form /#model=MODEL&view_type=VIEW
# So that the user can click openerp urls inside google analytics. # So that the user can click openerp urls inside google analytics.
_cp_path = "/web_analytics"
@openerpweb.httprequest @openerpweb.httprequest
def redirect(self,req): def redirect(self, req):
url = req.httprequest.base_url url = req.httprequest.base_url
suburl = url.split('/') suburl = url.split('/')
suburl = suburl[suburl.index('redirect')+1:] suburl = suburl[suburl.index('redirect')+1:]
rurl = "/web/webclient/home/#" rurl = "/#"
if len(suburl) >=1 and suburl[0]: if len(suburl) >=1 and suburl[0]:
rurl += "model="+str(suburl[0]) rurl += "model="+str(suburl[0])
if len(suburl) >=2 and suburl[1]: if len(suburl) >=2 and suburl[1]:

View File

Before

Width:  |  Height:  |  Size: 11 KiB

After

Width:  |  Height:  |  Size: 11 KiB

View File

@ -13,20 +13,21 @@ openerp.web_analytics = function(instance) {
* web_client.do_push_state() method which is responsible of changing the openerp current url * web_client.do_push_state() method which is responsible of changing the openerp current url
*/ */
if (instance.webclient) { if (instance.webclient) {
//_gaq.push(['_setAccount', 'UA-25293939-2']); // fva@openerp.com localhost // _gaq.push(['_setAccount', 'UA-25293939-2']); // fva@openerp.com localhost
_gaq.push(['_setAccount', 'UA-28648768-1']); // fva@openerp.com runbot // _gaq.push(['_setAccount', 'UA-28648768-1']); // fva@openerp.com runbot
//_gaq.push(['_setAccount', 'UA-28648768-1']); // fva@openerp.com // _gaq.push(['_setAccount', 'UA-28648768-1']); // fva@openerp.com
//_gaq.push(['_setAccount', 'UA-7333765-1']); // fp@openerp.com // _gaq.push(['_setAccount', 'UA-7333765-1']); // fp@openerp.com
//_gaq.push(['_setAccount', 'UA-7333765-1']); // fp@openerp.com // _gaq.push(['_setAccount', 'UA-7333765-1']); // fp@openerp.com
_gaq.push(['_setDomainName', '.openerp.com']); // _gaq.push(['_setDomainName', '.openerp.com']);
_gaq.push(['_setAccount', 'UA-35793871-1']); // vta@openerp.com localhost
_gaq.push(['setDomainName', 'none']);
_gaq.push(['_trackPageview']); _gaq.push(['_trackPageview']);
var connection = this.sessions.session0.connection; // var connection = instance.session.connection;
_gaq.push(['_setCustomVar',1,'Paying User',String(connection.openerp_entreprise),1]); _gaq.push(['_setCustomVar', 1, 'Normal User', String(instance.session.uid === 1), 1]);
_gaq.push(['_setCustomVar',2,'Admin User',String(connection.uid == 1),1]); _gaq.push(['_setCustomVar', 2, 'Admin User', String(instance.session.uid === 1), 1]);
// Google Analytics Code snippet // Google Analytics Code snippet
(function() { (function() {
@ -36,15 +37,20 @@ openerp.web_analytics = function(instance) {
ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js'; ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
var s = document.getElementsByTagName('script')[0]; var s = document.getElementsByTagName('script')[0];
s.parentNode.insertBefore(ga,s); s.parentNode.insertBefore(ga,s);
}) (); })();
instance.webclient.do_push_state.add(function(state) { var self = this;
instance.webclient.on('state_pushed', self, function(state) {
var model_whitelist = {'sale.order':'', 'purchase.order':'', 'crm.lead':''};
var view_type_blacklist = {'default':''};
var model = state["model"] || "no_model"; var model = state["model"] || "no_model";
var view_type = state["view_type"] || "default"; var view_type = state["view_type"] || "default";
var vurl = "web_analytics/redirect/"+ model + "/" + view_type if ((model in model_whitelist) && !(view_type in view_type_blacklist)) {
console.log(vurl); var vurl = "web_analytics/redirect/"+ model + "/" + view_type
_gaq.push(['_trackPageview',vurl]); console.log(vurl);
_gaq.push(['_trackPageview',vurl]);
}
}); });
} }
};
};