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
388 stars 162 forks source link

PIWIK in my android app its not working #194

Closed koteswaradk closed 6 years ago

koteswaradk commented 6 years ago

i am trying to implement PIWIK in my android app its not working. can any one let me know how can i use this. is i am done any wrong implementation. i am referring this link:https://www.diycode.cc/projects/piwik/piwik-sdk-android

d4rken commented 6 years ago

Provide more information. "its not working" is a pretty shitty error description.

Try using the latest version and have a look at the example app.

koteswaradk commented 6 years ago

Here is what i done in my project. public class MyApplication extends Application { private Tracker mPiwikTracker;

public synchronized Tracker getTracker() {
    if (mPiwikTracker != null) {
        return mPiwikTracker;
    }

    try {
        mPiwikTracker = Piwik.getInstance(this).newTracker("https://mydomain.net/myapp", 30);
    } catch (MalformedURLException e) {
        Log.w(Tracker.LOGGER_TAG, "url is malformed", e);
        return null;
    }

    return mpiwikTracker;
}

}

In my Activity: Tracker tracker = ((JunAppApplication) TrackHelper.track().screen("/"+getClass().getSimpleName()).title("NavSelector").with(tracker); Link added in the URL location of project created is: https://mydomain.net/myapp Project created id is 30 which is added in the configuration above. I am added application name in the manifest also i am nat able to get the data in the Piwik dashboard of my project i created.

any wrong i am doing please let me now.

d4rken commented 6 years ago

Enable logging and check the logfile on your Android device whether the data is getting transmitted.

Note that there is a delay unless you force the transmission to happen directly.

koteswaradk commented 6 years ago

boss i am new to this i have added log but it is not giving any error.

On Tue, Feb 20, 2018 at 4:23 PM, Matthias Urhahn notifications@github.com wrote:

Enable logging and check the logfile on your Android device whether the data is getting transmitted.

Note that there is a delay unless you force the transmission to happen directly.

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/matomo-org/piwik-sdk-android/issues/194#issuecomment-366940392, or mute the thread https://github.com/notifications/unsubscribe-auth/AQcfN09k-MbCkiXAdDhxgx9yo-kvztCxks5tWqQogaJpZM4SLZBt .

koteswaradk commented 6 years ago

how can i check that data is transmitting. please help

koteswaradk commented 6 years ago

hi any one please help me in my problem

d4rken commented 6 years ago

You can enable logging by including timber in your project: https://github.com/JakeWharton/timber

The library will then start printing debug information into logcat.

You could also set breakpoints inside library code to see at which point you are stuck.

Btw: Don't spam.

koteswaradk commented 6 years ago

if i am using Web view and if i hit the link then results are showing. through the library of android is not working if i use the sample code also its not working.

koteswaradk commented 6 years ago

i am getting this error is the problem with page or where do i need to fix it D/PIWIK:Tracker: Event added to the queue: org.piwik.sdk.TrackMe@903bdb5 D/PIWIK:EventDiskCache: Cache check took 0ms D/PIWIK:EventDiskCache: Uncaching of 0 events took 0ms D/PIWIK:EventCache: Switched state to ONLINE, uncached 0 events from disk. D/PIWIK:Dispatcher: Drained 1 events. D/PIWIK:DefaultPacketSender: status code 404 D/PIWIK:Dispatcher: Unsuccesful assuming OFFLINE, requeuing events. D/PIWIK:Dispatcher: Dispatched 0 events. D/PIWIK:EventDiskCache: Cache check took 0ms D/PIWIK:EventDiskCache: Uncaching of 0 events took 0ms D/PIWIK:EventCache: Switched state to ONLINE, uncached 0 events from disk. D/PIWIK:Dispatcher: Drained 1 events. D/PIWIK:DefaultPacketSender: status code 404

koteswaradk commented 6 years ago

Event added to the queue: org.piwik.sdk.TrackMe@f9ea4b3 D/PIWIK:EventDiskCache: Cache check took 0ms D/PIWIK:EventDiskCache: Uncaching of 0 events took 0ms D/PIWIK:EventCache: Switched state to ONLINE, uncached 0 events from disk. D/PIWIK:Dispatcher: Drained 1 events. D/PIWIK:DefaultPacketSender: status code 400 D/PIWIK:Dispatcher: Unsuccesful assuming OFFLINE, requeuing events. Dispatched 0 events.

d4rken commented 6 years ago

Is your tracker URL / ID correct?

koteswaradk commented 6 years ago

yes some times it gives D/PIWIK:EventCache: Switched state to ONLINE, uncached 0 events from disk. D/PIWIK:Dispatcher: Drained 1 events. D/PIWIK:DefaultPacketSender: status code 204 D/PIWIK:Dispatcher: Dispatched 1 events. D/PIWIK:EventDiskCache: Cache check took 0ms in my activity findViewById(R.id.text).setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) {

            Tracker tracker = ((MyApplication) getApplication()).getTracker();

            TrackHelper.track().screen(getClass().getSimpleName()).title("Test Sample").with(tracker);

          }

} and in may MyApplication

public class MyApplication extends Application{ //private Tracker tracker; private Tracker mPiwikTracker;

public synchronized Tracker getTracker() {

    if (mPiwikTracker != null){

        return mPiwikTracker;
    }

    if (mPiwikTracker == null) {
        handleSSLHandshake();
        mPiwikTracker = Piwik.getInstance(this).newTracker(new TrackerConfig("https://domain.subdomain.net/piwik", 30, "Mobile App")).setDispatchInterval(10000);
        return mPiwikTracker;
    }

    return mPiwikTracker;
}
@Override
public void onCreate() {
    super.onCreate();
    StrictMode.setVmPolicy(new StrictMode.VmPolicy.Builder()
            .detectAll()
            .penaltyLog()
            .build());
    Timber.plant(new Timber.DebugTree());
}

} this i am doing if is there any mistake i have done please help me

koteswaradk commented 6 years ago

do i need to add any other url

koteswaradk commented 6 years ago

now it is giving me 204 error

NishantJiffle commented 6 years ago

@koteswaradk I'm also facing the same problem. Did you get any solution?

d4rken commented 6 years ago

now it is giving me 204 error

204 (and 200) are both OK status codes.

https://github.com/matomo-org/piwik-sdk-android/blob/ae3007a91e20894caab892f36a7001d7eb7187a5/piwik-sdk/src/main/java/org/piwik/sdk/dispatcher/DefaultPacketSender.java#L80

It currently looks like your issue is server side.

d4rken commented 6 years ago

Closing due to inactivity.