nsdevaraj / gaforflash

Automatically exported from code.google.com/p/gaforflash
Apache License 2.0
1 stars 0 forks source link

IdleTimer error #95

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
if you initialize GATracker very early in your app (eg. before the stage ref to 
be accessible)
you will obtain an error from the IdleTimer

TypeError: Error #1009: Cannot access a property or method of a null object 
reference.
    at com.google.analytics.core::Buffer/_clearUTMB()[/work/Google/gaforflash/gaforflash-trunk/src/com/google/analytics/core/Buffer.as:101]
    at com.google.analytics.core::Buffer/resetCurrentSession()[/work/Google/gaforflash/gaforflash-trunk/src/com/google/analytics/core/Buffer.as:771]
    at com.google.analytics.core::IdleTimer/endSession()[/work/Google/gaforflash/gaforflash-trunk/src/com/google/analytics/core/IdleTimer.as:121]
    at flash.events::EventDispatcher/dispatchEventFunction()
    at flash.events::EventDispatcher/dispatchEvent()
    at flash.utils::Timer/tick()

Original issue reported on code.google.com by zwetan on 23 Feb 2012 at 12:27

GoogleCodeExporter commented 9 years ago
the way the IdleTimer is implemented is far from ideal

todo
 - create a new IdleTimer from scratch
 - provide options/hooks to control it

some scenarios:

1) you have an AIR app which need to end the current tracking session when it 
goes "idle"

in this case the IdleTimer of gaforflash should be able to be controlled from 
the AIR app
to have the idle/non-idle cycle in sync

2) for a mobile app you can be in the situation to lose the focus and run in 
the background

this is not really being "idle", this is being "paused" and should require a 
"resume"
when gaining again the focus

3) for a desktop app (especially with multiscreens) your app can also "lose the 
focus"

the user does not close the app but is just focusing on another screen
this could also require a "pause" and "resume" mecanism

but we could also consider each "lost of focus" as "closing the app"

the point is the user of the gaforflash lib need to be able to control
those behaviours with some config/options/etc.

Original comment by zwetan on 23 Feb 2012 at 12:41

GoogleCodeExporter commented 9 years ago
note: a quick workaround is to create the instance of GATracker and inititalize 
it
when the ADDED_TO_STAGE event is received

the problem:

you create the instance
----
            GATracker.autobuild = false;
            tracker = new GATracker( this, "UA-ID-000" );
            tracker.mode = TrackerMode.AS3;
            tracker.config.sessionTimeout = 60;
            tracker.config.conversionTimeout = 180;
----

and after you receive ADDED_TO_STAGE
you initialize the lib
----
            GATracker(tracker).build();
----

between the two
by the time the ADDED_TO_STAGE event is fired
(if your app do a lot of inititalization)
that's where the IdleTimer can occurs

the workaround:

but if you do both after you receive ADDED_TO_STAGE
----
            GATracker.autobuild = false;
            tracker = new GATracker( this, "UA-ID-000" );
            tracker.mode = TrackerMode.AS3;
            tracker.config.sessionTimeout = 60;
            tracker.config.conversionTimeout = 180;
            GATracker(tracker).build();
----

no room for error as the stage reference is there

why it should not happen:
"autobuild = false" should allow to delay the initialization of the lib early
(eg. way before ADDED_TO_STAGE occurs)

Original comment by zwetan on 23 Feb 2012 at 12:55

GoogleCodeExporter commented 9 years ago
the IdleTimer will be completely removed for the following different reasons

 - as of now, the IdleTimer listen the Stage for MouseEvent.MOUSE_MOVE events
    if you use gaforflash for mobile and other app using touch/gesture
    the "idle timer" would still kick which is bad

- it is preferable to give the control of a "timer" to the user instead of 
trying
   to deal with all different case from within the library

Original comment by zwetan on 14 Apr 2012 at 9:28

GoogleCodeExporter commented 9 years ago

Original comment by zwetan on 30 Apr 2012 at 9:57