本文整理汇总了Java中org.piwik.sdk.extra.TrackHelper类的典型用法代码示例。如果您正苦于以下问题:Java TrackHelper类的具体用法?Java TrackHelper怎么用?Java TrackHelper使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
TrackHelper类属于org.piwik.sdk.extra包,在下文中一共展示了TrackHelper类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: onSqliteError
import org.piwik.sdk.extra.TrackHelper; //导入依赖的package包/类
private void onSqliteError(SQLiteException e) {
if (
e instanceof SQLiteBindOrColumnIndexOutOfRangeException ||
e instanceof SQLiteConstraintException ||
e instanceof SQLiteDatabaseCorruptException ||
e instanceof SQLiteDatatypeMismatchException
) {
// If a migration did not go well, the best we can do is drop the database and re-create
// it from scratch. This is hackish but should allow more or less graceful recoveries.
TrackHelper.track().event("Office", "cache.db.error").name("critical").value(1f).with(tracker);
Log.e(TAG, "Critical database error. Droping + Re-creating", e);
close();
ctx.deleteDatabase(DB_NAME);
} else {
// Generic error. Close + re-open
Log.e(TAG, "Datable "+e.getClass().getName()+". Closing + re-opening", e);
TrackHelper.track().event("Office", "cache.db.error").name(e.getClass().getName()).value(1f).with(tracker);
close();
}
}
示例2: loadLecture
import org.piwik.sdk.extra.TrackHelper; //导入依赖的package包/类
public boolean loadLecture(LecturesController.WHAT what) {
if (what == null) {
return false;
}
whatwhen.what = what;
whatwhen.position = 0; // on what change, move to 1st
whatwhen.anchor = null;
whatwhen_previous = whatwhen.copy();
// Track
Breadcrumbs.record(new BreadcrumbBuilder().setMessage("Set office "+whatwhen.toUrlName()).build());
TrackHelper.track().event("OfficeActivity", "action.select-office").name("show").value(1f).with(tracker);
// Load
this.loadLecture(whatwhen);
return true;
}
示例3: do_manual_sync
import org.piwik.sdk.extra.TrackHelper; //导入依赖的package包/类
public boolean do_manual_sync(String reason) {
Breadcrumbs.record(new BreadcrumbBuilder().setMessage("Starting "+reason+" sync ").build());
if (mAccount == null) {
Log.w(TAG, "Failed to run manual sync: we have no account...");
TrackHelper.track().event("OfficeActivity", "sync."+reason).name("no-account").value(1f).with(tracker);
return false;
}
// Pass the settings flags by inserting them in a bundle
Bundle settingsBundle = new Bundle();
settingsBundle.putBoolean(ContentResolver.SYNC_EXTRAS_MANUAL, true);
settingsBundle.putBoolean(ContentResolver.SYNC_EXTRAS_EXPEDITED, true);
// start sync
ContentResolver.requestSync(mAccount, AUTHORITY, settingsBundle);
TrackHelper.track().event("OfficeActivity", "sync."+reason).name("start").value(1f).with(tracker);
// done
return true;
}
示例4: onApplyOptimalSyncSettings
import org.piwik.sdk.extra.TrackHelper; //导入依赖的package包/类
public boolean onApplyOptimalSyncSettings() {
SharedPreferences.Editor editor = settings.edit();
// Reset sync settings
editor.putString(SyncPrefActivity.KEY_PREF_SYNC_DUREE, "mois");
editor.putString(SyncPrefActivity.KEY_PREF_SYNC_LECTURES, "messe-offices");
editor.putBoolean(SyncPrefActivity.KEY_PREF_SYNC_WIFI_ONLY, false);
// Reset test settings
editor.putString(SyncPrefActivity.KEY_PREF_PARTICIPATE_SERVER, "");
editor.putBoolean(SyncPrefActivity.KEY_PREF_PARTICIPATE_BETA, false);
editor.putBoolean(SyncPrefActivity.KEY_PREF_PARTICIPATE_NOCACHE, false);
// Make sure sync is enabled on device
ContentResolver.setMasterSyncAutomatically(true);
ContentResolver.setSyncAutomatically(mAccount, AUTHORITY, true);
editor.apply();
Breadcrumbs.record(new BreadcrumbBuilder().setMessage("Apply optimal sync settings").build());
TrackHelper.track().event("OfficeActivity", "action.apply-optimal-sync-settings").name("error").value(1f).with(tracker);
onRefresh("applied-settings");
return true;
}
示例5: testSetNewSessionRaceCondition
import org.piwik.sdk.extra.TrackHelper; //导入依赖的package包/类
@Test
public void testSetNewSessionRaceCondition() throws Exception {
for (int retry = 0; retry < 5; retry++) {
final List<TrackMe> trackMes = Collections.synchronizedList(new ArrayList<TrackMe>());
doAnswer(invocation -> {
trackMes.add(invocation.getArgument(0));
return null;
}).when(mDispatcher).submit(any(TrackMe.class));
final Tracker tracker = new Tracker(mPiwik, mTrackerConfig);
tracker.setDispatchInterval(0);
int count = 20;
for (int i = 0; i < count; i++) {
new Thread(() -> {
TestHelper.sleep(10);
TrackHelper.track().screen("Test").with(tracker);
}).start();
}
TestHelper.sleep(500);
assertEquals(count, trackMes.size());
int found = 0;
for (TrackMe trackMe : trackMes) {
if (trackMe.get(QueryParams.SESSION_START) != null) found++;
}
assertEquals(1, found);
}
}
示例6: testFirstVisitTimeStamp
import org.piwik.sdk.extra.TrackHelper; //导入依赖的package包/类
@Test
public void testFirstVisitTimeStamp() throws Exception {
assertEquals(-1, mTracker.getPreferences().getLong(Tracker.PREF_KEY_TRACKER_FIRSTVISIT, -1));
TrackHelper.track().event("TestCategory", "TestAction").with(mTracker);
verify(mDispatcher).submit(mCaptor.capture());
TrackMe trackMe1 = mCaptor.getValue();
TestHelper.sleep(10);
// make sure we are tracking in seconds
assertTrue(Math.abs((System.currentTimeMillis() / 1000) - Long.parseLong(trackMe1.get(FIRST_VISIT_TIMESTAMP))) < 2);
mTracker = new Tracker(mPiwik, mTrackerConfig);
TrackHelper.track().event("TestCategory", "TestAction").with(mTracker);
verify(mDispatcher, times(2)).submit(mCaptor.capture());
TrackMe trackMe2 = mCaptor.getValue();
assertEquals(Long.parseLong(trackMe1.get(FIRST_VISIT_TIMESTAMP)), Long.parseLong(trackMe2.get(FIRST_VISIT_TIMESTAMP)));
assertEquals(mTracker.getPreferences().getLong(Tracker.PREF_KEY_TRACKER_FIRSTVISIT, -1), Long.parseLong(trackMe1.get(FIRST_VISIT_TIMESTAMP)));
}
示例7: testTotalVisitCount
import org.piwik.sdk.extra.TrackHelper; //导入依赖的package包/类
@Test
public void testTotalVisitCount() throws Exception {
assertEquals(-1, mTracker.getPreferences().getInt(Tracker.PREF_KEY_TRACKER_VISITCOUNT, -1));
assertNull(mTracker.getDefaultTrackMe().get(QueryParams.TOTAL_NUMBER_OF_VISITS));
TrackHelper.track().event("TestCategory", "TestAction").with(mTracker);
verify(mDispatcher).submit(mCaptor.capture());
assertEquals(1, Integer.parseInt(mCaptor.getValue().get(QueryParams.TOTAL_NUMBER_OF_VISITS)));
mTracker = new Tracker(mPiwik, mTrackerConfig);
assertEquals(1, mTracker.getPreferences().getLong(Tracker.PREF_KEY_TRACKER_VISITCOUNT, -1));
assertNull(mTracker.getDefaultTrackMe().get(QueryParams.TOTAL_NUMBER_OF_VISITS));
TrackHelper.track().event("TestCategory", "TestAction").with(mTracker);
verify(mDispatcher, times(2)).submit(mCaptor.capture());
assertEquals(2, Integer.parseInt(mCaptor.getValue().get(QueryParams.TOTAL_NUMBER_OF_VISITS)));
assertEquals(2, mTracker.getPreferences().getLong(Tracker.PREF_KEY_TRACKER_VISITCOUNT, -1));
}
示例8: testPreviousVisits
import org.piwik.sdk.extra.TrackHelper; //导入依赖的package包/类
@Test
public void testPreviousVisits() throws Exception {
final List<Long> previousVisitTimes = new ArrayList<>();
for (int i = 0; i < 5; i++) {
TrackHelper.track().event("TestCategory", "TestAction").with(mTracker);
String previousVisit = mTracker.getDefaultTrackMe().get(QueryParams.PREVIOUS_VISIT_TIMESTAMP);
if (previousVisit != null)
previousVisitTimes.add(Long.parseLong(previousVisit));
TestHelper.sleep(1010);
}
assertFalse(previousVisitTimes.contains(0L));
Long lastTime = 0L;
for (Long time : previousVisitTimes) {
assertTrue(lastTime < time);
lastTime = time;
}
}
示例9: initPiwik
import org.piwik.sdk.extra.TrackHelper; //导入依赖的package包/类
private void initPiwik() {
// Print debug output when working on an app.
Timber.plant(new Timber.DebugTree());
// When working on an app we don't want to skew tracking results.
// getPiwik().setDryRun(BuildConfig.DEBUG);
// If you want to set a specific userID other than the random UUID token, do it NOW to ensure all future actions use that token.
// Changing it later will track new events as belonging to a different user.
// String userEmail = ....preferences....getString
// getTracker().setUserId(userEmail);
// Track this app install, this will only trigger once per app version.
// i.e. "http://com.piwik.demo:1/185DECB5CFE28FDB2F45887022D668B4"
TrackHelper.track().download().identifier(new DownloadTracker.Extra.ApkChecksum(this)).with(getTracker());
// Alternative:
// i.e. "http://com.piwik.demo:1/com.android.vending"
// getTracker().download();
}
示例10: trackView
import org.piwik.sdk.extra.TrackHelper; //导入依赖的package包/类
private void trackView(String status) {
long dayDelta = ww.when.dayBetween(new GregorianCalendar());
TrackHelper.track()
.screen("/office/" + ww.what.urlName())
.title("/office/" + ww.what.urlName())
.dimension(LecturesApplication.STATS_DIM_SOURCE, statLectureSource)
.dimension(LecturesApplication.STATS_DIM_STATUS, status)
.dimension(LecturesApplication.STATS_DIM_DAY_DELTA, Integer.toString((int) dayDelta))
.dimension(LecturesApplication.STATS_DIM_DAY_NAME, ww.when.dayName())
.with(tracker);
}
示例11: initPiwik
import org.piwik.sdk.extra.TrackHelper; //导入依赖的package包/类
private void initPiwik() {
// Track this app install, this will only trigger once per app version.
Tracker tracker = getTracker();
TrackHelper.track().download().identifier(new DownloadTracker.Extra.ApkChecksum(this)).with(tracker);
tracker.setOptOut(!settings.getBoolean(KEY_PREF_PARTICIPATE_STATISTICS, true));
// tracker.setDispatchInterval(1);
Log.i(TAG, "Piwik setup complete. OptOut status: "+tracker.isOptOut());
}
示例12: trackDownloadEvent
import org.piwik.sdk.extra.TrackHelper; //导入依赖的package包/类
private void trackDownloadEvent(String errorName) {
// Push event
float deltaTime = (System.nanoTime() - startTime) / 1000;
long dayDelta = when.dayBetween(new GregorianCalendar());
// Disable success reporting, this is too noisy
if (!errorName.equals("success")) {
TrackHelper.track().event("Office", "download." + errorName).name(what.urlName() + "." + dayDelta).value(deltaTime).with(tracker);
}
}
示例13: onRefresh
import org.piwik.sdk.extra.TrackHelper; //导入依赖的package包/类
public boolean onRefresh(String reason) {
whatwhen.useCache = false;
whatwhen.anchor = null;
if (mViewPager != null) {
whatwhen.position = mViewPager.getCurrentItem();
} else {
whatwhen.position = 0;
}
this.whatwhen_previous = null;
Breadcrumbs.record(new BreadcrumbBuilder().setMessage("Refresh "+whatwhen.toUrlName()).build());
TrackHelper.track().event("OfficeActivity", "action.refresh."+reason).name(whatwhen.toTrackerName()).value(1f).with(tracker);
loadLecture(whatwhen);
return true;
}
示例14: onCalendar
import org.piwik.sdk.extra.TrackHelper; //导入依赖的package包/类
public boolean onCalendar() {
Bundle args = new Bundle();
args.putLong("time", whatwhen.when.getTimeInMillis());
DatePickerFragment calendarDialog = new DatePickerFragment();
calendarDialog.setListener(this);
calendarDialog.setArguments(args);
calendarDialog.show(activity.getSupportFragmentManager(), "datePicker");
Breadcrumbs.record(new BreadcrumbBuilder().setMessage("Show Calendar").build());
TrackHelper.track().event("OfficeActivity", "action.calendar").name("show").value(1f).with(tracker);
return true;
}
示例15: onAbout
import org.piwik.sdk.extra.TrackHelper; //导入依赖的package包/类
public boolean onAbout() {
AboutDialogFragment aboutDialog = new AboutDialogFragment();
aboutDialog.show(getSupportFragmentManager(), "aboutDialog");
Breadcrumbs.record(new BreadcrumbBuilder().setMessage("Show About dialog").build());
TrackHelper.track().event("OfficeActivity", "action.about").name("show").value(1f).with(tracker);
return true;
}