Skip to content

added encodeDataString method to MixpanelAPI class #29

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

Merged
merged 1 commit into from
Apr 21, 2016

Conversation

tksmd
Copy link
Contributor

@tksmd tksmd commented Apr 20, 2016

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

  • extract the encoding functionality from sendData method
  • make the method and endpoint URL properties protected

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.

- extracted the functionality from sendData method
- made it protected so that subclass can use it
@patedit
Copy link
Contributor

patedit commented Apr 21, 2016

Thanks a lot @tksmd ! :)

@patedit patedit merged commit b64086b into mixpanel:master Apr 21, 2016
@tksmd
Copy link
Contributor Author

tksmd commented Apr 22, 2016

Thank you for your prompt merge!

@tksmd tksmd deleted the extract-encode-method branch April 22, 2016 10:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants