當前位置: 首頁>>代碼示例>>Java>>正文


Java TrackHelper類代碼示例

本文整理匯總了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();
    }
}
 
開發者ID:HackMyChurch,項目名稱:aelf-dailyreadings,代碼行數:21,代碼來源:AelfCacheHelper.java

示例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;
}
 
開發者ID:HackMyChurch,項目名稱:aelf-dailyreadings,代碼行數:19,代碼來源:SectionOfficesFragment.java

示例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;
}
 
開發者ID:HackMyChurch,項目名稱:aelf-dailyreadings,代碼行數:22,代碼來源:LecturesActivity.java

示例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;
}
 
開發者ID:HackMyChurch,項目名稱:aelf-dailyreadings,代碼行數:27,代碼來源:LecturesActivity.java

示例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);
    }
}
 
開發者ID:matomo-org,項目名稱:piwik-sdk-android,代碼行數:27,代碼來源:TrackerTest.java

示例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)));
}
 
開發者ID:matomo-org,項目名稱:piwik-sdk-android,代碼行數:19,代碼來源:TrackerTest.java

示例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));
}
 
開發者ID:matomo-org,項目名稱:piwik-sdk-android,代碼行數:18,代碼來源:TrackerTest.java

示例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;
    }
}
 
開發者ID:matomo-org,項目名稱:piwik-sdk-android,代碼行數:21,代碼來源:TrackerTest.java

示例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();
    }
 
開發者ID:matomo-org,項目名稱:piwik-sdk-android,代碼行數:20,代碼來源:DemoApp.java

示例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);
}
 
開發者ID:HackMyChurch,項目名稱:aelf-dailyreadings,代碼行數:13,代碼來源:DownloadXmlTask.java

示例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());
}
 
開發者ID:HackMyChurch,項目名稱:aelf-dailyreadings,代碼行數:10,代碼來源:LecturesApplication.java

示例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);
    }
}
 
開發者ID:HackMyChurch,項目名稱:aelf-dailyreadings,代碼行數:11,代碼來源:LectureFuture.java

示例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;
}
 
開發者ID:HackMyChurch,項目名稱:aelf-dailyreadings,代碼行數:15,代碼來源:SectionOfficesFragment.java

示例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;
}
 
開發者ID:HackMyChurch,項目名稱:aelf-dailyreadings,代碼行數:15,代碼來源:SectionOfficesFragment.java

示例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;
}
 
開發者ID:HackMyChurch,項目名稱:aelf-dailyreadings,代碼行數:8,代碼來源:LecturesActivity.java


注:本文中的org.piwik.sdk.extra.TrackHelper類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。