Subversion Repositories eFlore/Applications.cel

Rev

Rev 2845 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
2844 mathias 1
package org.tela_botanica.client.util;
2
 
3
import org.tela_botanica.client.modeles.objets.Configuration;
4
import org.tela_botanica.client.util.Util;
5
 
6
public class Analytics {
7
 
8
	/**
9
	 * Envoie une notification à Google Analytics, comme quoi la page "url" a été visitée;
10
	 * passer par pageVisitee() pour s'assurer qu'on est bien en prod
11
	 *
12
	 * @param url adresse ou surnom de la page visitée
13
	 */
14
	public static native void pageVisiteeNatif(String url) /*-{
15
		if (url == "") {
16
			url = $wnd.location.href;
17
		}
18
		$wnd.ga('send', 'pageview', url);
19
	}-*/;
20
 
21
	/**
22
	 * Proxy pour evenementNatif() qui n'envoie l'événement que si on est en prod
23
	 */
24
	public static void pageVisitee(String url) {
25
		if (Configuration.isProd()) {
2845 mathias 26
			//Util.LogVersFirebug("Page vue: " + url);
2844 mathias 27
			Analytics.pageVisiteeNatif(url);
28
		} else {
29
 
30
		}
31
	}
32
 
33
	public static void pageVisitee() {
34
		pageVisitee("");
35
	}
36
 
37
	/**
38
	 * Envoie une notification à Google Analytics, comme quoi l'événement "action" a été déclenché
39
	 * sur la ressource "categorie" - passer par evenement() pour s'assurer qu'on
40
	 * est bien en prod
41
	 *
42
	 * @param categorie - la ressource sur laquelle l'utilisateur a agi
43
	 * @param action - ce que l'utilisateur a fait avec cette ressource
44
	 * @param label - un bout de JSON avec des détails
45
	 * @param nombre - nombre d'actions à enregistrer
46
	 */
47
	public static native void evenementNatif(String categorie, String action, String label, int nombre) /*-{
48
		$wnd.ga('send', 'event', categorie, action, label, nombre);
49
	}-*/;
50
 
51
	/**
52
	 * Proxy pour evenementNatif() qui n'envoie l'événement que si on est en prod
53
	 */
54
	public static void evenement(String categorie, String action, String label, int nombre) {
55
		if (Configuration.isProd()) {
2845 mathias 56
			//Util.LogVersFirebug("Evenement: " + categorie + ", " + action + ", " + label + ", " + nombre);
2844 mathias 57
			Analytics.evenementNatif(categorie, action, label, nombre);
58
		}
59
	}
60
 
61
	public static void evenement(String categorie, String action, String label) {
62
		Analytics.evenement(categorie, action, label, 1);
63
	}
64
 
65
	public static void evenement(String categorie, String action) {
66
		Analytics.evenement(categorie, action, "", 1);
67
	}
68
}