Android 版 Google Analytics 存在问题:“调度程序认为已完成,但有 543 个失败事件”

发布于 2024-08-25 19:42:36 字数 2831 浏览 6 评论 0原文

有人知道如何解决这个问题吗?

    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.AbstractHttpClientConnection.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

特别是最后一行解释了为什么丢失了这么多数据,因为调度程序认为已完成,但有 543 个事件未调度...

该应用程序具有良好的互联网连接,并且到达时没有问题应用程序服务器端 API。

我在分析中看到过去几天的许多启动和点击事件都丢失了,即使我知道流量是正常的,因为我可以看到服务器 API 的统计数据。

在分析报告中,我看到每天的报告不足。因此,问题似乎正在蔓延/蔓延到使用此应用程序的所有设备。

我想知道为什么谷歌不在他们的邮件组中回答这个问题 - 有几个人抱怨这个......好吧,好吧......

但是,我仍然不确定是否有什么我可以做的来解决它。如果我无能为力修复它,我想它坏了就不是我的错了。但我有一种感觉,因为上次部署到 Android 市场时问题变得更加严重。

还有其他人有使用 Android 版 Google Analytics 的经验吗?

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.AbstractHttpClientConnection.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 ?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

笔落惊风雨 2024-09-01 19:42:36

该问题与 trackEvent 和 trackPageView 标签中的空格有关。

1) 从所有 trackEventtrackPageView 调用中删除所有空格(或转义它们)。

2) 清除 google_analytics.db events 表(至少 lable 列中包含空格的所有行)



要通过代码清除事件行,您可以使用以下代码:

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);
    }
}

并在启动时将其添加到您的活动中。

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

    }

当您卸载并安装应用程序时,事件表将被删除,但这可能并不总是首选解决方案。

因此,如果第 1) 点和第 2) 点没有得到解决,您的 Google Analytics 代码将永远死掉……

感谢 Jason 和 Stig B 帮助调试

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

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文