Matomo for acad flavor

This commit is contained in:
Thomas 2020-12-14 16:41:29 +01:00
parent 9a2eb6cd49
commit 1f2ecd591d
8 changed files with 153 additions and 4 deletions

View File

@ -38,6 +38,7 @@ android {
checkReleaseBuilds false checkReleaseBuilds false
abortOnError false abortOnError false
} }
//boolean full_instances if set to false means TubeAcad
productFlavors { productFlavors {
fdroid_acad { fdroid_acad {
applicationId "app.fedilab.fedilabtube" applicationId "app.fedilab.fedilabtube"
@ -111,21 +112,27 @@ android {
sourceSets { sourceSets {
fdroid_acad { fdroid_acad {
res.srcDirs = ['src/main/res', 'src/acad/res'] res.srcDirs = ['src/main/res', 'src/acad/res']
java.srcDirs = ['src/main/java', 'src/acad/java']
} }
google_acad { google_acad {
res.srcDirs = ['src/main/res', 'src/acad/res'] res.srcDirs = ['src/main/res', 'src/acad/res']
java.srcDirs = ['src/main/java', 'src/acad/java']
} }
fdroid_full { fdroid_full {
res.srcDirs = ['src/main/res', 'src/full/res'] res.srcDirs = ['src/main/res', 'src/full/res']
java.srcDirs = ['src/main/java', 'src/full/java']
} }
google_full { google_full {
res.srcDirs = ['src/main/res', 'src/full/res'] res.srcDirs = ['src/main/res', 'src/full/res']
java.srcDirs = ['src/main/java', 'src/full/java']
} }
queermotion { queermotion {
res.srcDirs = ['src/main/res', 'src/queermotion/res'] res.srcDirs = ['src/main/res', 'src/queermotion/res']
java.srcDirs = ['src/main/java', 'src/full/java']
} }
bittube { bittube {
res.srcDirs = ['src/main/res', 'src/bittube/res'] res.srcDirs = ['src/main/res', 'src/bittube/res']
java.srcDirs = ['src/main/java', 'src/full/java']
} }
} }
} }
@ -189,4 +196,8 @@ dependencies {
implementation 'org.slf4j:slf4j-simple:1.7.30' implementation 'org.slf4j:slf4j-simple:1.7.30'
fdroid_acadImplementation 'org.matomo.sdk:tracker:4.1.2'
google_acadImplementation 'org.matomo.sdk:tracker:4.1.2'
} }

View File

@ -0,0 +1,32 @@
package app.fedilab.fedilabtube;
/* Copyright 2020 Thomas Schneider
*
* This file is a part of TubeLab
*
* This program is free software; you can redistribute it and/or modify it under the terms of the
* GNU General Public License as published by the Free Software Foundation; either version 3 of the
* License, or (at your option) any later version.
*
* TubeLab is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even
* the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
* Public License for more details.
*
* You should have received a copy of the GNU General Public License along with TubeLab; if not,
* see <http://www.gnu.org/licenses>. */
import org.matomo.sdk.Matomo;
import org.matomo.sdk.Tracker;
import org.matomo.sdk.TrackerBuilder;
public class FedilabTube extends BaseFedilabTube {
private Tracker mMatomoTracker;
public synchronized Tracker getTracker() {
if (mMatomoTracker != null) return mMatomoTracker;
mMatomoTracker = TrackerBuilder.createDefault("https://wa.phm.education.gouv.fr/snp/", 11).build(Matomo.getInstance(this));
return mMatomoTracker;
}
}

View File

@ -0,0 +1,47 @@
package app.fedilab.fedilabtube;
/* Copyright 2020 Thomas Schneider
*
* This file is a part of TubeLab
*
* This program is free software; you can redistribute it and/or modify it under the terms of the
* GNU General Public License as published by the Free Software Foundation; either version 3 of the
* License, or (at your option) any later version.
*
* TubeLab is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even
* the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
* Public License for more details.
*
* You should have received a copy of the GNU General Public License along with TubeLab; if not,
* see <http://www.gnu.org/licenses>. */
import android.app.Activity;
import android.content.Context;
import org.matomo.sdk.Tracker;
import org.matomo.sdk.extra.TrackHelper;
public class Matomo {
public static void sendScreen(Context _mcontext, String path, String title) {
Tracker tracker = ((FedilabTube) ((Activity) _mcontext).getApplication()).getTracker();
TrackHelper.track().screen(path).title(title).with(tracker);
}
public static void sendEvent(Context _mcontext, String category, String action, String label, float value) {
Tracker tracker = ((FedilabTube) ((Activity) _mcontext).getApplication()).getTracker();
TrackHelper.track().event(category, action).name(label).value(value).with(tracker);
}
public static void sendValue(Context _mcontext, String path, int index, String dimensionValue) {
Tracker tracker = ((FedilabTube) ((Activity) _mcontext).getApplication()).getTracker();
TrackHelper.track().screen(path).dimension(index, dimensionValue).with(tracker);
}
public static void trackInstall(Context _mcontext) {
Tracker tracker = ((FedilabTube) ((Activity) _mcontext).getApplication()).getTracker();
TrackHelper.track().download().with(tracker);
}
}

View File

@ -0,0 +1,22 @@
package app.fedilab.fedilabtube;
/* Copyright 2020 Thomas Schneider
*
* This file is a part of TubeLab
*
* This program is free software; you can redistribute it and/or modify it under the terms of the
* GNU General Public License as published by the Free Software Foundation; either version 3 of the
* License, or (at your option) any later version.
*
* TubeLab is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even
* the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
* Public License for more details.
*
* You should have received a copy of the GNU General Public License along with TubeLab; if not,
* see <http://www.gnu.org/licenses>. */
public class FedilabTube extends BaseFedilabTube {
public void getTracker() {}
}

View File

@ -0,0 +1,33 @@
package app.fedilab.fedilabtube;
/* Copyright 2020 Thomas Schneider
*
* This file is a part of TubeLab
*
* This program is free software; you can redistribute it and/or modify it under the terms of the
* GNU General Public License as published by the Free Software Foundation; either version 3 of the
* License, or (at your option) any later version.
*
* TubeLab is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even
* the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
* Public License for more details.
*
* You should have received a copy of the GNU General Public License along with TubeLab; if not,
* see <http://www.gnu.org/licenses>. */
import android.app.Activity;
import android.content.Context;
public class Matomo {
public static void sendScreen(Context _mcontext, String path, String title) {}
public static void sendEvent(Context _mcontext, String category, String action, String label, float value) {}
public static void sendValue(Context _mcontext, String path, int index, String dimensionValue) {}
public static void trackInstall(Context _mcontext) {}
}

View File

@ -35,7 +35,7 @@ import app.fedilab.fedilabtube.helper.ThemeHelper;
import app.fedilab.fedilabtube.services.GlobalUploadObserver; import app.fedilab.fedilabtube.services.GlobalUploadObserver;
import app.fedilab.fedilabtube.worker.WorkHelper; import app.fedilab.fedilabtube.worker.WorkHelper;
public class FedilabTube extends MultiDexApplication { public class BaseFedilabTube extends MultiDexApplication {
static String UPLOAD_CHANNEL_ID = "upload_info_peertube"; static String UPLOAD_CHANNEL_ID = "upload_info_peertube";
@ -48,12 +48,12 @@ public class FedilabTube extends MultiDexApplication {
Configuration myConfig = new Configuration.Builder() Configuration myConfig = new Configuration.Builder()
.setMinimumLoggingLevel(android.util.Log.INFO) .setMinimumLoggingLevel(android.util.Log.INFO)
.build(); .build();
WorkManager.initialize(FedilabTube.this, myConfig); WorkManager.initialize(BaseFedilabTube.this, myConfig);
if (interval >= 15) { if (interval >= 15) {
WorkHelper.fetchNotifications(this, interval); WorkHelper.fetchNotifications(this, interval);
} }
createNotificationChannel(); createNotificationChannel();
UploadServiceConfig.initialize(FedilabTube.this, UPLOAD_CHANNEL_ID, true); UploadServiceConfig.initialize(BaseFedilabTube.this, UPLOAD_CHANNEL_ID, true);
new GlobalRequestObserver(this, new GlobalUploadObserver()); new GlobalRequestObserver(this, new GlobalUploadObserver());
} }
@ -63,7 +63,7 @@ public class FedilabTube extends MultiDexApplication {
protected void attachBaseContext(Context base) { protected void attachBaseContext(Context base) {
super.attachBaseContext(base); super.attachBaseContext(base);
MultiDex.install(FedilabTube.this); MultiDex.install(BaseFedilabTube.this);
SharedPreferences sharedpreferences = getSharedPreferences(Helper.APP_PREFS, Context.MODE_PRIVATE); SharedPreferences sharedpreferences = getSharedPreferences(Helper.APP_PREFS, Context.MODE_PRIVATE);
int themePref = sharedpreferences.getInt(Helper.SET_THEME, Helper.DEFAULT_MODE); int themePref = sharedpreferences.getInt(Helper.SET_THEME, Helper.DEFAULT_MODE);
ThemeHelper.switchTo(themePref); ThemeHelper.switchTo(themePref);

View File

@ -486,6 +486,7 @@ public class PeertubeActivity extends AppCompatActivity implements CommentListAd
return; return;
} }
peertube = apiResponse.getPeertubes().get(0); peertube = apiResponse.getPeertubes().get(0);
Matomo.sendScreen(PeertubeActivity.this, "video", peertube.getOriginUrl());
if (peertube.isNsfw()) { if (peertube.isNsfw()) {
binding.videoSensitive.setVisibility(View.VISIBLE); binding.videoSensitive.setVisibility(View.VISIBLE);
} else { } else {

View File

@ -43,6 +43,7 @@ import java.util.Map;
import app.fedilab.fedilabtube.BuildConfig; import app.fedilab.fedilabtube.BuildConfig;
import app.fedilab.fedilabtube.MainActivity; import app.fedilab.fedilabtube.MainActivity;
import app.fedilab.fedilabtube.Matomo;
import app.fedilab.fedilabtube.R; import app.fedilab.fedilabtube.R;
import app.fedilab.fedilabtube.client.APIResponse; import app.fedilab.fedilabtube.client.APIResponse;
import app.fedilab.fedilabtube.client.RetrofitPeertubeAPI; import app.fedilab.fedilabtube.client.RetrofitPeertubeAPI;
@ -127,6 +128,8 @@ public class DisplayVideosFragment extends Fragment implements AccountsHorizonta
startDate = bundle.getString("startDate", null); startDate = bundle.getString("startDate", null);
endDate = bundle.getString("endDate", null); endDate = bundle.getString("endDate", null);
} }
Matomo.sendScreen(getContext(), "timeline", String.valueOf(type));
if (channel != null) { if (channel != null) {
channelId = channel.getAcct(); channelId = channel.getAcct();
} else if (account != null) { } else if (account != null) {