1
2
3
4
5
6
7
8
9
10
11
12
13 package org.sonatype.install4j.ga;
14
15 import com.install4j.api.context.Context;
16
17
18
19
20
21
22 public class TrackEventAction
23 extends GoogleAnalyticsActionSupport
24 {
25 private String category;
26
27 private String action;
28
29 private String label;
30
31 private Integer value;
32
33 public String getCategory() {
34 return category;
35 }
36
37 public void setCategory(final String category) {
38 this.category = category;
39 }
40
41 public String getAction() {
42 return action;
43 }
44
45 public void setAction(final String action) {
46 this.action = action;
47 }
48
49 public String getLabel() {
50 return label;
51 }
52
53 public void setLabel(final String label) {
54 this.label = label;
55 }
56
57 public Integer getValue() {
58 return value;
59 }
60
61 public void setValue(final Integer value) {
62 this.value = value;
63 }
64
65 @Override
66 protected boolean execute(final Context context) throws Exception {
67 if (isDisabled()) {
68 log.debug("Tracking disabled; ignoring event: {}", action);
69 }
70 else {
71 trackEvent(context);
72 }
73 return true;
74 }
75
76 private void trackEvent(final Context context) throws Exception {
77 log.debug("Tracking event: {}", action);
78 getTracker().trackEvent(category, action, label, value);
79 }
80 }