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

Custom variable value in table overwrites when a new event is logged. #138

Closed santimendon closed 7 years ago

santimendon commented 7 years ago

Say I have 3 custom variables A,B and C. Currently: -When first event is logged: Table adds a row valA, valB, valC

-When second event with the same user is logged with a new value for param B Table is updating same row with valA, new valB, valC

Required: Table should add a new row with valA, new valB, valC

Is it possible with tracker method to set a scope where a new row gets created for a new value of a certain custom variable?

Code Snippet:

Tracker tracker= Piwik.getInstance(this).newTracker(Constants.PIWIK_TRACKING_URL, 3);
tracker = setPiwikCustomVariables(tracker, mPiwikEventsObject);
TrackHelper.track().screen("/" + mLabel).title(mAction).with(tracker);

private static Tracker setPiwikCustomVariables(Tracker tracker, Object mCustomDtoObject) {
            PiwikCollectionAppEventsDTO mCollectionAppDTO = (PiwikCollectionAppEventsDTO) mCustomDtoObject;
            tracker.setVisitCustomVariable(1, mCollectionAppDTO.CUSTOM_VARIABLE_APP_VERSION, mCollectionAppDTO.getAppVersion());
            tracker.setVisitCustomVariable(2, mCollectionAppDTO.CUSTOM_VARIABLE_IMEI_NUMBER, mCollectionAppDTO.getImeiNumber());
            tracker.setVisitCustomVariable(3, mCollectionAppDTO.CUSTOM_VARIABLE_AGENT_MOBILE_NUMBER, mCollectionAppDTO.getAgentMobileNumber());

        //tracker.setDispatchInterval(-1);
        // tracker.setDispatchInterval(0);
        //tracker.dispatch();
        return tracker;
    }

Version: compile 'org.piwik.sdk:piwik-sdk:1.0.2'

OS: Android all versions

dotsbb commented 7 years ago

@santimendon You're using visit scoped custom variables. Please consider this one instead.

d4rken commented 7 years ago

@santimendon I'm not sure what you are trying to achieve. Do you want to assign a new variable to the same slot, if so please consult the Piwik documentation, this would not be related to the Android SDK.

If you are looking for code that automatically increases the custom variable count, if new data is presented, then this doesn't exist. I'm also now sure how it would work because the amount of allowed variables would be hard coded in the server.

As there is no activity on this, I'm closing it. Just reopen if this is still a current topic.