root / src / com / rackspacecloud / android / GaActivity.java @ 0edf6b39
History | View | Annotate | Download (2.6 kB)
1 |
package com.rackspacecloud.android; |
---|---|
2 |
|
3 |
import com.google.android.apps.analytics.GoogleAnalyticsTracker; |
4 |
|
5 |
import android.app.Activity; |
6 |
import android.os.Build; |
7 |
import android.os.Bundle; |
8 |
import android.util.Log; |
9 |
|
10 |
public class GaActivity extends Activity { |
11 |
|
12 |
protected static final String CATEGORY_FILE = "file"; |
13 |
protected static final String CATEGORY_SERVER = "server"; |
14 |
protected static final String CATEGORY_CONTAINER = "containers"; |
15 |
protected static final String CATEGORY_LOAD_BALANCER = "load_balancer"; |
16 |
|
17 |
protected static final String PAGE_ROOT = "/Root"; |
18 |
protected static final String PAGE_SERVERS = "/Servers"; |
19 |
protected static final String PAGE_SERVER = "/Server"; |
20 |
protected static final String PAGE_CONTAINERS = "/Containers"; |
21 |
protected static final String PAGE_FOLDER = "/Folder"; |
22 |
protected static final String PAGE_STORAGE_OBJECT = "/StorageObject"; |
23 |
protected static final String PAGE_ADD_SERVER = "/AddServer"; |
24 |
protected static final String PAGE_CONTACT = "/ContactInformation"; |
25 |
protected static final String PAGE_ADD_CONTAINER = "/AddContainer"; |
26 |
|
27 |
protected static final String EVENT_CREATE = "created"; |
28 |
protected static final String EVENT_DELETE = "deleted"; |
29 |
protected static final String EVENT_PING = "pinged"; |
30 |
protected static final String EVENT_REBOOT = "reboot"; |
31 |
protected static final String EVENT_BACKUP = "backup_schedule_changed"; |
32 |
protected static final String EVENT_RESIZE = "resized"; |
33 |
protected static final String EVENT_PASSWORD = "password_changed"; |
34 |
protected static final String EVENT_UPDATED = "updated"; |
35 |
protected static final String EVENT_REBUILD = "rebuilt"; |
36 |
protected static final String EVENT_RENAME = "renamed"; |
37 |
|
38 |
private GoogleAnalyticsTracker tracker;
|
39 |
|
40 |
@Override
|
41 |
public void onCreate(Bundle savedInstanceState) { |
42 |
super.onCreate(savedInstanceState);
|
43 |
startTracker(); |
44 |
} |
45 |
|
46 |
public void startTracker(){ |
47 |
if(!"google_sdk".equals(Build.PRODUCT) && !"sdk".equals(Build.PRODUCT)){ |
48 |
Log.d("tracker", "Creating Tracker"); |
49 |
tracker = GoogleAnalyticsTracker.getInstance(); |
50 |
tracker.start(Preferences.WEB_PROPERTY_ID, 20, this); |
51 |
} |
52 |
else{
|
53 |
Log.d("tracker", "Not Creating Tracker"); |
54 |
} |
55 |
} |
56 |
|
57 |
public void trackPageView(String page){ |
58 |
if(tracker != null){ |
59 |
Log.d("tracker", "Tracking pageview: " + page); |
60 |
tracker.trackPageView(page); |
61 |
} |
62 |
} |
63 |
|
64 |
@Override
|
65 |
protected void onDestroy(){ |
66 |
super.onDestroy();
|
67 |
if(tracker != null){ |
68 |
tracker.stop(); |
69 |
} |
70 |
} |
71 |
|
72 |
public void trackEvent(String category, String action, String label, int value){ |
73 |
if(tracker != null){ |
74 |
Log.d("tracker", "Tracking event: " + category + " " + action); |
75 |
tracker.trackEvent(category, action, label, value); |
76 |
} |
77 |
} |
78 |
} |