0

I am having major issues getting Worklight Analytics custom events working (WL v6.1).

For my environment, I'm on the latest 6.1.0.1 (0718). We have installed Analytics on an AWS instance for development and I'm pointing to it via worklight.properties. The operational analytics dashboard is accessible and is showing correct basic analytics data.

I have problems across mobileWeb (using this for dev only), iPhone, and Android environments.

mobileWeb: analytics queue size increases forever and never triggers a send. I ran through the code in firebug and it appears to use the deprecated WL.Client.isConnected() method which always returns false for mobileWeb. So I hacked this to return true and was able to get mobileWeb working properly: queue is flushed after 10 messages and the result can be viewed in the Analytics console server log. This confirms that the analytics server is configured properly at least.

iPhone simulator: attempts to send after 10 messages have been queued. However I get a 400 from IHS on the analytics server. I have tried increasing the log level but was unable to produce anything more:

<wl_server_ip> - - [11/Aug/2014:13:12:42 -0400] "POST /iwap/v1/events/_bulk HTTP/1.1" 400 335

Android emulator: I see a TeaLeaf exception when the analytics send is called (after queuing 10 messages):

08-11 13:32:16.970: E/UICAndroid(1748): TL Library Error: url:http://<analytics_ip>:80/iwap/v1/events/_bulk stream errorjava.util.zip.DataFormatException: stream error
08-11 13:32:16.970: E/UICAndroid(1748):     at java.util.zip.Deflater.deflateImpl(Native Method)
08-11 13:32:16.970: E/UICAndroid(1748):     at java.util.zip.Deflater.deflateImpl(Deflater.java:241)
08-11 13:32:16.970: E/UICAndroid(1748):     at java.util.zip.Deflater.deflate(Deflater.java:232)
08-11 13:32:16.970: E/UICAndroid(1748):     at java.util.zip.DeflaterOutputStream.flush(DeflaterOutputStream.java:193)
08-11 13:32:16.970: E/UICAndroid(1748):     at com.tl.uic.util.HTTPUtil.createEntity(HTTPUtil.java:93)
08-11 13:32:16.970: E/UICAndroid(1748):     at com.tl.uic.util.HTTPUtil.sendPost(HTTPUtil.java:181)
08-11 13:32:16.970: E/UICAndroid(1748):     at com.tl.uic.util.HTTPUtil.sendHttpPost(HTTPUtil.java:115)
08-11 13:32:16.970: E/UICAndroid(1748):     at com.tl.uic.util.PostTask.sendMessageFormat(PostTask.java:72)
08-11 13:32:16.970: E/UICAndroid(1748):     at com.tl.uic.util.PostTask.doInBackground(PostTask.java:28)
08-11 13:32:16.970: E/UICAndroid(1748):     at com.tl.uic.util.PostTask.doInBackground(PostTask.java:1)
08-11 13:32:16.970: E/UICAndroid(1748):     at android.os.AsyncTask$2.call(AsyncTask.java:288)
08-11 13:32:16.970: E/UICAndroid(1748):     at java.util.concurrent.FutureTask.run(FutureTask.java:237)
08-11 13:32:16.970: E/UICAndroid(1748):     at android.os.AsyncTask$SerialExecutor$1.run(AsyncTask.java:231)
08-11 13:32:16.970: E/UICAndroid(1748):     at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1112)
08-11 13:32:16.970: E/UICAndroid(1748):     at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:587)
08-11 13:32:16.970: E/UICAndroid(1748):     at java.lang.Thread.run(Thread.java:841)

Here's the very basic analytics call, essentially a cut/paste from the WL 6.1 InfoCenter:

function doBetterAnalyticsWork(i) {
        WL.Analytics.log({hello: 'world ' + i}, 'test-analytics')
        .always(function(wasQueueFlushed, errObj){
            if (wasQueueFlushed) {
                WL.Logger.debug('The queue was flushed');
            } else {
                WL.Logger.debug('The queue was NOT flushed');
            }
            if (typeof errObj === 'object') {
                WL.Logger.error('Error trying to flush the queue', errObj);
            }
        });
        WL.Logger.debug('WL.Analytics.state(): ' + JSON.stringify(WL.Analytics.state()));
    }

I iterate over this 10 times in a for loop in order to trigger the analytics send. Incidentally, I never get the "The queue was flushed" message but it seems to at least attempt a send on iPhone/Android.

Any help would be much appreciated. I can provide more info as-needed.

4

2 回答 2

0

编辑:

在我第二次查看后,我看到了另一个问题:

TL 库错误:url:http://:80/iwap/v1/events/_bulk 流错误java.util.zip.DataFormatException:流错误

- - [11/Aug/2014:13:12:42 -0400]“POST /iwap/v1/events/_bulk HTTP/1.1”400 335

您的客户是否将数据直接发送到“/iwap/v1/events/_bulk”?客户端数据不应该直接进入分析服务器。它必须通过 Worklight 服务器,然后 Worklight 服务器会将其转发到分析服务器。您是否已将客户端代码配置为指向“/iwap/v1/events/_bulk”?如果您删除此配置,它应该默认指向指向 Worklight 服务器的正确位置。

原来的:

在 Worklight 6.1 中,Worklight 在后台使用 Tealeaf 来收集和发送分析数据。当分析数据循环发送到 Tealeaf 时,由于某种原因它失败了。不要在循环中进行调用,而是尝试使用按钮手动调用 WL.Analytics.log。

于 2014-08-12T15:22:30.553 回答
0

mobileWeb:我将跟进避免使用 WL.Client.isConnected 的必要性

iOS:jnortey 是正确的;客户端不应该知道分析服务器的 URL。如果在某个时候,您在 TLFConfigurableItems.plist 文件中有地址,运行了您的应用程序,然后将 TLFConfigurableItems.plist 中的值替换为 @USE_WORKLIGHT_DEFAULT@,则旧的硬编码值可能已保留,您应该卸载/重新安装应用程序或清除所有数据,然后重试。

Android:与 iOS 相同的故事。如果 TLFConfigurableItems.properties 文件与硬编码值一起使用,则该值已保留,您需要卸载/重新安装应用程序,或清除所有数据并重试。

另外,您正在测试什么版本的Android? Kitkat 更改了 DeflaterOutputStream 行为,如果您在 finish() 之后调用 flush(),则会引发异常。您拥有的 Tealeaf 库版本可能正是这样做的,因此您需要 Android 上更新的固定版本的 Tealeaf 库来适应 Android 的 DeflaterOutputStream 行为的变化。

于 2014-08-18T12:57:05.323 回答