Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Android crashes when you pass an object to logEvent #5

Closed
AndrewJack opened this issue Mar 27, 2017 · 3 comments
Closed

Android crashes when you pass an object to logEvent #5

AndrewJack opened this issue Mar 27, 2017 · 3 comments

Comments

@AndrewJack
Copy link

AndrewJack commented Mar 27, 2017

When calling Taplytics.logEvent('anEvent', 0, { name: 'anObject' }) on Android you see the following crash.

The docs and the ios implmentation suggest passing an object to this method. However the android implementation expects a string which it then converts into a JSONObject.
https://github.com/taplytics/taplytics-react-native/blob/master/android/src/main/java/com/taplytics/react/TaplyticsReactModule.java#L141

This method should use the ReadableMap which would allow us to pass an object from javascript.
https://github.com/facebook/react-native/blob/master/ReactAndroid/src/main/java/com/facebook/react/bridge/ReadableMap.java

Crash

com.facebook.react.bridge.NativeArgumentsParseException: TypeError: expected dynamic type `string', but had type `object' (constructing arguments for Taplytics.logEvent at argument index 2)
                                                                         at com.facebook.react.bridge.BaseJavaModule$JavaMethod.invoke(BaseJavaModule.java:313)
                                                                         at com.facebook.react.cxxbridge.JavaModuleWrapper.invoke(JavaModuleWrapper.java:158)
                                                                         at com.facebook.react.bridge.queue.NativeRunnable.run(Native Method)
                                                                         at android.os.Handler.handleCallback(Handler.java:751)
                                                                         at android.os.Handler.dispatchMessage(Handler.java:95)
                                                                         at com.facebook.react.bridge.queue.MessageQueueThreadHandler.dispatchMessage(MessageQueueThreadHandler.java:31)
                                                                         at android.os.Looper.loop(Looper.java:154)
                                                                         at com.facebook.react.bridge.queue.MessageQueueThreadImpl$3.run(MessageQueueThreadImpl.java:196)
                                                                         at java.lang.Thread.run(Thread.java:761)
                                                                      Caused by: com.facebook.react.bridge.UnexpectedNativeTypeException: TypeError: expected dynamic type `string', but had type `object'
                                                                         at com.facebook.react.bridge.ReadableNativeArray.getString(Native Method)
                                                                         at com.facebook.react.bridge.BaseJavaModule$5.extractArgument(BaseJavaModule.java:106)
                                                                         at com.facebook.react.bridge.BaseJavaModule$5.extractArgument(BaseJavaModule.java:102)
                                                                         at com.facebook.react.bridge.BaseJavaModule$JavaMethod.invoke(BaseJavaModule.java:305)
                                                                         at com.facebook.react.cxxbridge.JavaModuleWrapper.invoke(JavaModuleWrapper.java:158) 
                                                                         at com.facebook.react.bridge.queue.NativeRunnable.run(Native Method) 
                                                                         at android.os.Handler.handleCallback(Handler.java:751) 
                                                                         at android.os.Handler.dispatchMessage(Handler.java:95) 
                                                                         at com.facebook.react.bridge.queue.MessageQueueThreadHandler.dispatchMessage(MessageQueueThreadHandler.java:31) 
                                                                         at android.os.Looper.loop(Looper.java:154) 
                                                                         at com.facebook.react.bridge.queue.MessageQueueThreadImpl$3.run(MessageQueueThreadImpl.java:196) 
                                                                         at java.lang.Thread.run(Thread.java:761) 
@AndrewJack AndrewJack changed the title Android crashes when you send an object to log event Android crashes when you send an object to logEvent Mar 27, 2017
@AndrewJack AndrewJack changed the title Android crashes when you send an object to logEvent Android crashes when you pass an object to logEvent Mar 27, 2017
@AndrewJack
Copy link
Author

logRevenue is likely to have this issue too.

@AndrewJack
Copy link
Author

AndrewJack commented Mar 27, 2017

I guess it's missing something like this

Taplytics.setUserAttributes = (attributes) => {
  Taplytics._setUserAttributes(JSON.stringify(attributes))
}

https://github.com/taplytics/taplytics-react-native/blob/master/index.js#L63

@VicV
Copy link
Contributor

VicV commented Mar 27, 2017

Hey @AndrewJack

Sorry to be so slow on this one.

1.0.11 fixes this.

@VicV VicV closed this as completed Mar 27, 2017
hamzahayat added a commit that referenced this issue Apr 23, 2021
* Added prettier config and formatted files

* Formatted MD files

* Removed unused constant

* Ran prettier --write

* Added new line to prettierignore

* Added singleQuote rule

* Added traillingComma rule
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

2 participants