Titanium JIRA Archive
Titanium SDK/CLI (TIMOB)

[TIMOB-23966] Android: Unable to send a feature event with a number as the data objects key

GitHub Issuen/a
TypeBug
PriorityCritical
StatusClosed
ResolutionFixed
Resolution Date2016-10-07T10:57:42.000+0000
Affected Version/sRelease 6.0.0, Release 5.5.1
Fix Version/sRelease 6.0.0
ComponentsAndroid
Labelsparity, qe-6.0.0
ReporterEwan Harris
AssigneeGary Mathews
Created2016-09-29T11:41:54.000+0000
Updated2016-10-13T18:10:13.000+0000

Description

Description

When sending a feature event on Android, if a key in the data object is a number an error will be thrown. The code works find on iOS and Windows
[WARN]  W/System.err: java.lang.ClassCastException: java.lang.Integer cannot be cast to java.lang.String
[WARN]  W/System.err:   at org.appcelerator.titanium.util.TiConvert.toJSON(TiConvert.java:723)
[WARN]  W/System.err:   at ti.modules.titanium.analytics.AnalyticsModule.featureEvent(AnalyticsModule.java:98)
[WARN]  W/System.err:   at org.appcelerator.kroll.runtime.v8.V8Function.nativeInvoke(Native Method)
[WARN]  W/System.err:   at org.appcelerator.kroll.runtime.v8.V8Function.callSync(V8Function.java:57)
[WARN]  W/System.err:   at org.appcelerator.kroll.runtime.v8.V8Function.call(V8Function.java:43)
[WARN]  W/System.err:   at ti.modules.titanium.TitaniumModule$Timer.run(TitaniumModule.java:147)
[WARN]  W/System.err:   at android.os.Handler.handleCallback(Handler.java:739)
[WARN]  W/System.err:   at android.os.Handler.dispatchMessage(Handler.java:95)
[WARN]  W/System.err:   at android.os.Looper.loop(Looper.java:145)
[WARN]  W/System.err:   at android.app.ActivityThread.main(ActivityThread.java:5938)
[WARN]  W/System.err:   at java.lang.reflect.Method.invoke(Native Method)
[WARN]  W/System.err:   at java.lang.reflect.Method.invoke(Method.java:372)
[WARN]  W/System.err:   at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1400)
[WARN]  W/System.err:   at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1195)
var data = {'1':'d'}
var result = Ti.Analytics.featureEvent('levels', data);

Steps to reproduce

Add the above code to an existing app.js

Build for android

Actual result

An error will be thrown

Expected result

No error should be thrown

Comments

  1. Gary Mathews 2016-10-03

    master: https://github.com/appcelerator/titanium_mobile/pull/8459 6_0_X: https://github.com/appcelerator/titanium_mobile/pull/8460
  2. Lokesh Choudhary 2016-10-13

    Verified the fix. Feature event with a number as a data object key is sent successfully. Closing. Environment: Appc Studio : 4.8.0.201610060953 Ti SDK : 6.0.0.v20161013072802, 6.1.0.v20161012092744 Ti CLI : 5.0.10 Alloy : 1.9.2 MAC El Capitan : 10.11.6 Appc NPM : 4.2.8-7 Appc CLI : 6.0.0-57 Node: 4.6.0 Nexus 6 - Android 6.0.1

JSON Source