Calling javascript function with arguments using JSNI

Posted by jav_000 on Stack Overflow See other posts from Stack Overflow or by jav_000
Published on 2012-10-20T03:24:01Z Indexed on 2012/10/20 11:01 UTC
Read the original article Hit count: 226

Filed under:
|
|
|

I'm trying to integrate Mixpanel with GWT, but I have problems calling an event with a property and one value.

My function to track an simple event (without values):

 public native void trackEvent(String eventName)/*-{
        $wnd.mixpanel.track(eventName);
    }-*/;

It works.

But when I want to add some properties and values, it doesn't work properly:

public native void trackComplexEvent(String eventName, String property, 
            String value)/*-{
    $wnd.mixpanel.track(eventName, {property:value});

}-*/;

I have 2 problems with this:

1) Mixpanel says the property name is: "property"(yes, the name of the variable that I'm passing, not the value).

2) Mixpanel says the value is:undefined

An example from mixpanel web is:

mixpanel.track("Video Play", {"age": 13, "gender": "male"});

So, I guess the problem is I'm doing a wrong call or with wrong type of arguments.

© Stack Overflow or respective owner

Related posts about JavaScript

Related posts about gwt