1 /*
2 * Copyright (c) 2012-present Sonatype, Inc. All rights reserved.
3 *
4 * This program is licensed to you under the Apache License Version 2.0,
5 * and you may not use this file except in compliance with the Apache License Version 2.0.
6 * You may obtain a copy of the Apache License Version 2.0 at http://www.apache.org/licenses/LICENSE-2.0.
7 *
8 * Unless required by applicable law or agreed to in writing,
9 * software distributed under the Apache License Version 2.0 is distributed on an
10 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11 * See the Apache License Version 2.0 for the specific language governing permissions and limitations there under.
12 */
13 package org.sonatype.install4j.ga;
14
15 import com.dmurph.tracking.JGoogleAnalyticsTracker;
16
17 /**
18 * Support for Google Analytics tracking actions.
19 *
20 * @see TrackerFactory
21 * @since 1.0
22 */
23 public abstract class GoogleAnalyticsActionSupport
24 extends ActionSupport
25 {
26 private static final TrackerFactory factory = new TrackerFactory();
27
28 private static final boolean disabled = getFlag(GoogleAnalyticsActionSupport.class, "disable");
29
30 private String trackingCode;
31
32 public GoogleAnalyticsActionSupport() {
33 this.reportFailure = false; // do not show users failure details
34 }
35
36 public String getTrackingCode() {
37 return trackingCode;
38 }
39
40 public void setTrackingCode(final String trackingCode) {
41 this.trackingCode = trackingCode;
42 }
43
44 public static TrackerFactory getFactory() {
45 return factory;
46 }
47
48 public static boolean isDisabled() {
49 return disabled;
50 }
51
52 protected JGoogleAnalyticsTracker getTracker() {
53 return factory.get(getTrackingCode());
54 }
55 }