excilys/androidannotations — Issue #15: Extensions for Google Analytics
Author: pyricau
Created: 2012-01-06 10:47:47+00:00
State: open

It may be interesting to allow users to write less code when using Google Analytics SDK for Android (http://code.google.com/mobile/analytics/docs/android/ )

The dedicated annotations should not compile if the SDK jar is not available at compile time.

Ideas :

The UA account value should be set in the AndroidManifest.xml as a custom variable, and we should check it's there at compile time.

The activity should be annotated with `@Analytics` The default would be a tracker with a dispatch interval of twenty.

the tracker would automatically track a page view ( `tracker.trackPageView("/testApplicationHomeScreen");`) when onCreate is called, and destroy would automatically be called in onDestroy.

This behavior may be disable using annotations attribute :

```
@Analytics(trackPageView = false, destroy = false)
public class MyActivity {
```

The tracker may be injected in the activity (if @Analytics is set at the top), using `@Tracker` on a field that has the Tracker type.

We could also track some events on demand. For example, creating a new `@Track` annotation :

```
@Track // Maybe some annotation parameters ?
@Click
void myButtonClicked() {
```

Custom vars may also be set using annotations (maybe sub annotations for `@Analytics`)

Automatic dispatching could be disabled using `@Analytics(autoDispatch=false)`.

But then, we should check that the tracker is injected, otherwise it means that the tracking events will never be dispatched.