Export to GitHub

gaforflash - issue #95

IdleTimer error


Posted on Feb 23, 2012 by Happy Monkey

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()

Comment #1

Posted on Feb 23, 2012 by Happy Monkey

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.

Comment #2

Posted on Feb 23, 2012 by Happy Monkey

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)

Comment #3

Posted on Apr 14, 2012 by Happy Monkey

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

Comment #4

Posted on Apr 30, 2012 by Happy Monkey

(No comment was entered for this change.)

Status: Fixed

Labels:
Type-Defect Priority-High Milestone-Release1.1