开发者

Problem with Google Analytics for Android : "Dispatcher thinks it finished, but there were 543 failed events" [closed]

This question is unlikely to help any future visitors; it is only relevant to a small geographic area, a specific moment in time, or an extraordinarily narrow situation that is not generally applicable to the worldwide audience of the internet. For help making this question more broadly applicable, visit the help center. Closed 12 years ago.

Anyone know how to solve this problem?

    03-23 13:03:20.585: WARN/googleanalytics(3430): Problem with socket or streams.
03-23 13:03:20.585: WARN/googleanalytics(3430): java.net.SocketException: Broken pipe
03-23 13:03:20.585: WARN/googleanalytics(3430):     at org.apache.harmony.luni.platform.OSNetworkSystem.sendStreamImpl(Native Method)
03-23 13:03:20.585: WARN/googleanalytics(3430):     at org.apache.harmony.luni.platform.OSNetworkSystem.sendStream(OSNetworkSystem.java:498)
03-23 13:03:20.585: WARN/googleanalytics(3430):     at org.apache.harmony.luni.net.PlainSocketImpl.write(PlainSocketImpl.java:585)
03-23 13:03:20.585: WARN/googleanalytics(3430):     at org.apache.harmony.luni.net.SocketOutputStream.write(SocketOutputStream.java:59)
03-23 13:03:20.585: WARN/googleanalytics(3430):     at org.apache.http.impl.io.AbstractSessionOutputBuffer.flushBuffer(AbstractSessionOutputBuffer.java:87)
03-23 13:03:20.585: WARN/googleanalytics(3430):     at org.apache.http.impl.io.AbstractSessionOutputBuffer.flush(AbstractSessionOutputBuffer.java:94)
03-23 13:03:20.585: WARN/googleanalytics(3430):     at org.apache.http.impl.AbstractHttpClientConnection.doFlush(AbstractHttpClientConnection.java:168)
03-23 13:03:20.585: WARN/googleanalytics(3430):     at org.apache.http.impl.AbstractHttpClient开发者_开发知识库Connection.flush(AbstractHttpClientConnection.java:173)
03-23 13:03:20.585: WARN/googleanalytics(3430):     at com.google.android.apps.analytics.PipelinedRequester.sendRequests(Unknown Source)
03-23 13:03:20.585: WARN/googleanalytics(3430):     at com.google.android.apps.analytics.NetworkDispatcher$DispatcherThread$AsyncDispatchTask.dispatchSomePendingEvents(Unknown Source)
03-23 13:03:20.585: WARN/googleanalytics(3430):     at com.google.android.apps.analytics.NetworkDispatcher$DispatcherThread$AsyncDispatchTask.run(Unknown Source)
03-23 13:03:20.585: WARN/googleanalytics(3430):     at android.os.Handler.handleCallback(Handler.java:587)
03-23 13:03:20.585: WARN/googleanalytics(3430):     at android.os.Handler.dispatchMessage(Handler.java:92)
03-23 13:03:20.585: WARN/googleanalytics(3430):     at android.os.Looper.loop(Looper.java:123)
03-23 13:03:20.585: WARN/googleanalytics(3430):     at 

android.os.HandlerThread.run(HandlerThread.java:60)
03-23 13:03:21.088: WARN/googleanalytics(3430): Dispatcher thinks it finished, but there were 543 failed events

Specially the last line explain why there is lost so much data, as the dispatcher thinks it is done, but have 543 events not dispatched...

The application have a good internet connection and there is no problem reaching the app server-side api.

I see in analytics that lots of startups and click-events the past few days are lost, even I know the traffic is normal since i can see statistics from the the server api.

In the analytics reports I see a day by day under-reporting. So the problems seems to be spreading/growing to all the devices using this application.

Im wondering why google does not answer this in their mail-groups - several people have complained about this...well, well...

But, I'm still not sure if there is anything I can do to fix it or not. If there is nothing I can do to fix it, I guess its not my fault that it got broken. But i got a feeling it is, since the problem got dramatically worse on the last deploy to Android market.

Anyone else with experience on Google Analytics for android ?


The problem is related with whitespaces in trackEvent and trackPageView labels.

1) Remove all whitespaces (or escape them) from all trackEvent and trackPageView calls.

2) Clear the google_analytics.db events table (at least all rows having lable column containing a whitespace)

. . .

To clear the events rows by code you can use the following code:

import android.content.Context;
import android.database.SQLException;
import android.database.sqlite.SQLiteDatabase;
import android.database.sqlite.SQLiteOpenHelper;

public class AnalyticsDB extends SQLiteOpenHelper {

    // The Android's default system path of your application database.
    private static String DB_PATH = "/data/data/<YOUR_PACKAGENAME>/databases/";

    private static String DB_NAME = "google_analytics";

    private SQLiteDatabase myDataBase;

    /**
     * Constructor Takes and keeps a reference of the passed context in order to
     * access to the application assets and resources.
     * 
     * @param context
     */
    public AnalyticsDB(Context context) {
        super(context, DB_NAME, null, 1);
    }

    public void openDataBase() throws SQLException {

        // Open the database
        String myPath = DB_PATH + DB_NAME + ".db";
        myDataBase = SQLiteDatabase.openDatabase(myPath, null, SQLiteDatabase.OPEN_READWRITE);

    }

    @Override
    public synchronized void close() {

        if (myDataBase != null) myDataBase.close();

        super.close();

    }

    @Override
    public void onCreate(SQLiteDatabase db) {

    }

    @Override
    public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {

    }

    public int deleteEvents() {
        return myDataBase.delete("events", "label LIKE '% %'", null);
    }
}

and add it to your activity at startup

   public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);

            AnalyticsDB myDbHelper = new AnalyticsDB(context);

            try {
                myDbHelper.openDataBase();
                int deleted = myDbHelper.deleteEvents();
                myDbHelper.close();
            }
            catch (SQLException sqle) {
                throw sqle;
            }
            finally{
                myDbHelper.close();
            }

    }

The events table will be deleted when you uninstall and installs the app, but this is probably not always the preferred solution.

So, if point 1) and 2) is not fixed, your Google Analytics code will be dead meat --- forever...

Kudos to Jason and Stig B for helping out debugging

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜