mixpanel / mixpanel-java

Other
49 stars 37 forks source link

added encodeDataString method to MixpanelAPI class #29

Closed tksmd closed 8 years ago

tksmd commented 8 years ago

I'd like to build Pixel based event tracking URL for my app but both tracking endpoint URL and encoding function in MixpanelAPI class aren't available from outside.

I don't want to implement same function in my app and in this PR, I did

This enables to create subclass like this

public class MixpanelAPIExt extends MixpanelAPI{

    public String pixcelTrackingURL(JSONObject message, boolean useIpAddress) {
        String dataParam = encodeDataString(message.toString());
        StringBuilder buf = new StringBuilder();
        buf.append(this.mEventsEndpoint).append("/");
        buf.append("?data=").append(dataParam);
        buf.append("&ip=").append((useIpAddress) ? 1 : 0);
        buf.append("&img=1");
        return buf.toString();
    }

It's just small refactoring and I think this does not affect existing client applications of this library.

patedit commented 8 years ago

Thanks a lot @tksmd ! :)

tksmd commented 8 years ago

Thank you for your prompt merge!