matomo-org / matomo-sdk-android

SDK for Android to measure your apps with Matomo. Works on Android phones, tablets, Fire TV sticks, and more!
BSD 3-Clause "New" or "Revised" License
393 stars 164 forks source link

Protocol Application Domain #217

Closed berger89 closed 5 years ago

berger89 commented 6 years ago

Is it possible to change the protocol? For example to use "rest://example/id/..."? When I set.setApplicationDomain("rest://"), an http: is always prefixed...

d4rken commented 6 years ago

You would use setApplicationDomain with a domain name not just a protocol, i.e. either some.domain.com or https://some.domain.com.

Either way it looks like the code requires the tracked URL to use either ftp, http or https. https://github.com/matomo-org/piwik-sdk-android/blob/a3c0a4189f58ec88199bf54b74f5bf84a722edba/piwik-sdk/src/main/java/org/piwik/sdk/Tracker.java#L445

While we could change that I think there were some server-side requirements when I last checked, as in, if we don't use one of those protocols, the server does not track the visit/event. @mattab Am I right?

@berger89 Can you elaborate on your use-case for this?

mattab commented 6 years ago

@d4rken on the server side AFAIK our check is this one: https://github.com/matomo-org/matomo/blob/3e524abc661d401c55ec8b3439a0125eae0f088d/core/UrlHelper.php#L135-L137

ie. return preg_match('~^(([[:alpha:]][[:alnum:]+.-]*)?:)?//(.*)$~D', $url, $matches) !== 0 so we accept URLs with any protocol.

berger89 commented 6 years ago

@d4rken The problem is that in the method setApplicationDomain the getApplicationBaseURL is called, in which the parameter baseurl/mApplicationDomain is prefixed with an http.

https://github.com/matomo-org/piwik-sdk-android/blob/a3c0a4189f58ec88199bf54b74f5bf84a722edba/piwik-sdk/src/main/java/org/piwik/sdk/Tracker.java#L363

https://github.com/matomo-org/piwik-sdk-android/blob/a3c0a4189f58ec88199bf54b74f5bf84a722edba/piwik-sdk/src/main/java/org/piwik/sdk/Tracker.java#L507