Skip to content

Commit

Permalink
Inject device parameters for session stitching on every request.
Browse files Browse the repository at this point in the history
Fixes #309
Superseeds #310
  • Loading branch information
d4rken committed Aug 2, 2021
1 parent 4a044df commit 7291d74
Showing 1 changed file with 6 additions and 11 deletions.
17 changes: 6 additions & 11 deletions tracker/src/main/java/org/matomo/sdk/Tracker.java
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,10 @@

import android.content.SharedPreferences;

import androidx.annotation.Nullable;
import androidx.annotation.VisibleForTesting;

import org.matomo.sdk.dispatcher.DispatchMode;
import org.matomo.sdk.dispatcher.Dispatcher;
import org.matomo.sdk.dispatcher.Packet;
import org.matomo.sdk.tools.DeviceHelper;
import org.matomo.sdk.tools.Objects;

import java.text.SimpleDateFormat;
import java.util.Date;
Expand All @@ -27,6 +23,8 @@
import java.util.UUID;
import java.util.regex.Pattern;

import androidx.annotation.Nullable;
import androidx.annotation.VisibleForTesting;
import timber.log.Timber;


Expand Down Expand Up @@ -426,6 +424,10 @@ private void injectBaseParams(TrackMe trackMe) {
trackMe.trySet(QueryParams.VISITOR_ID, mDefaultTrackMe.get(QueryParams.VISITOR_ID));
trackMe.trySet(QueryParams.USER_ID, mDefaultTrackMe.get(QueryParams.USER_ID));

trackMe.trySet(QueryParams.SCREEN_RESOLUTION, mDefaultTrackMe.get(QueryParams.SCREEN_RESOLUTION));
trackMe.trySet(QueryParams.USER_AGENT, mDefaultTrackMe.get(QueryParams.USER_AGENT));
trackMe.trySet(QueryParams.LANGUAGE, mDefaultTrackMe.get(QueryParams.LANGUAGE));

String urlPath = trackMe.get(QueryParams.URL_PATH);
if (urlPath == null) {
urlPath = mDefaultTrackMe.get(QueryParams.URL_PATH);
Expand All @@ -442,13 +444,6 @@ private void injectBaseParams(TrackMe trackMe) {
// https://github.com/matomo-org/matomo-sdk-android/issues/92
mDefaultTrackMe.set(QueryParams.URL_PATH, urlPath);
trackMe.set(QueryParams.URL_PATH, urlPath);

if (mLastEvent == null || !Objects.equals(trackMe.get(QueryParams.USER_ID), mLastEvent.get(QueryParams.USER_ID))) {
// https://github.com/matomo-org/matomo-sdk-android/issues/209
trackMe.trySet(QueryParams.SCREEN_RESOLUTION, mDefaultTrackMe.get(QueryParams.SCREEN_RESOLUTION));
trackMe.trySet(QueryParams.USER_AGENT, mDefaultTrackMe.get(QueryParams.USER_AGENT));
trackMe.trySet(QueryParams.LANGUAGE, mDefaultTrackMe.get(QueryParams.LANGUAGE));
}
}

public Tracker track(TrackMe trackMe) {
Expand Down

0 comments on commit 7291d74

Please sign in to comment.