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


Java TrackMessage類代碼示例

本文整理匯總了Java中com.segment.analytics.messages.TrackMessage的典型用法代碼示例。如果您正苦於以下問題:Java TrackMessage類的具體用法?Java TrackMessage怎麽用?Java TrackMessage使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


TrackMessage類屬於com.segment.analytics.messages包,在下文中一共展示了TrackMessage類的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: trackEventWithProperties

import com.segment.analytics.messages.TrackMessage; //導入依賴的package包/類
/**
 * Makes an analytics call telling Segment what custom-named event has happened. Custom parameters provided
 * are also included in the call.
 *
 * @param eventName             Name of the event that's being recorded
 * @param keyForPropertiesMap   Key to the property being attached to the event that's being called
 * @param valueForPropertiesMap Value of the property being attached to the event that's being called
 */
private void trackEventWithProperties(@NonNull String eventName, String keyForPropertiesMap,
                                      String valueForPropertiesMap, boolean loggedIn) {
  if (isAnalyticsEnabled()) {

    if (keyForPropertiesMap == null || valueForPropertiesMap == null) {
      analytics.enqueue(TrackMessage.builder(eventName)
        .userId(loggedIn ? MAPBOX_USERNAME : "not logged in"));
    }
    if (keyForPropertiesMap != null && valueForPropertiesMap != null) {
      Map<String, String> properties = new HashMap<>();
      properties.put(keyForPropertiesMap, valueForPropertiesMap);
      analytics.enqueue(TrackMessage.builder(eventName).userId(loggedIn ? MAPBOX_USERNAME : "not logged in")
        .properties(properties));
    }
  }
}
 
開發者ID:mapbox,項目名稱:mapbox-android-demo,代碼行數:25,代碼來源:AnalyticsTracker.java

示例2: postTrackingMessage

import com.segment.analytics.messages.TrackMessage; //導入依賴的package包/類
@Override
protected void postTrackingMessage(final String userId,
                                   final UUID projectileId,
                                   final String githubRepo,
                                   final String openshiftProjectName,
                                   final String mission,
                                   final String runtime) {
    if (analytics != null) {
        // Create properties
        final Map<String, String> props = new HashMap<>();
        props.put(KEY_GITHUB_REPO, githubRepo);
        props.put(KEY_OPENSHIFT_PROJECT_NAME, openshiftProjectName);
        props.put(KEY_MISSION, mission);
        props.put(KEY_RUNTIME, runtime);

        // Create message
        final MessageBuilder message = TrackMessage.builder(NAME_EVENT_LAUNCH).
                messageId(projectileId).
                userId(userId).
                properties(props);

        // Send to analytics engine
        analytics.enqueue(message);

        log.finest(() -> "Queued tracking message for: " +
                "userId: " + userId + ", " +
                "projectileId: " + projectileId + ", " +
                "githubRepo: " + githubRepo + ", " +
                "openshiftProjectName: " + openshiftProjectName + ", " +
                "mission: " + mission + ", " +
                "runtime: " + runtime);
    }
}
 
開發者ID:fabric8-launcher,項目名稱:launcher-backend,代碼行數:34,代碼來源:SegmentAnalyticsProvider.java

示例3: openedAppForFirstTime

import com.segment.analytics.messages.TrackMessage; //導入依賴的package包/類
/**
 * Gets and adds device information to analytics call. Ideally, this method is called
 * when app is opened for the first time or if shared preferences is cleared.
 **/

public void openedAppForFirstTime(boolean isTablet, boolean loggedIn) {
  Map<String, String> properties = new HashMap<>();
  properties.put("email", getSharedPreferences(appContext)
    .getString(StringConstants.EMAIL_KEY, "not logged in"));
  properties.put("model", Build.MODEL);
  properties.put("brand", Build.BRAND);
  properties.put("product", Build.PRODUCT);
  properties.put("manufacturer", Build.MANUFACTURER);
  properties.put("device", Build.DEVICE);
  properties.put("tags", Build.TAGS);
  properties.put("iso3 language", Locale.getDefault().getISO3Language());
  properties.put("language", Locale.getDefault().getLanguage());
  properties.put("iso3 country", Locale.getDefault().getISO3Country());
  properties.put("country", Locale.getDefault().getCountry());
  properties.put("display country", Locale.getDefault().getDisplayCountry());
  properties.put("display name", Locale.getDefault().getDisplayName());
  properties.put("display language", Locale.getDefault().getDisplayLanguage());
  if (deviceIsWearable) {
    properties.put("size", IS_WEARABLE_VALUE);
  } else {
    properties.put("size", isTablet ? IS_TABLET_MAP_VALUE : IS_PHONE_MAP_VALUE);
  }
  analytics.enqueue(TrackMessage.builder("New install")
    .userId(loggedIn ? MAPBOX_USERNAME : "not logged in")
    .properties(properties)
  );
}
 
開發者ID:mapbox,項目名稱:mapbox-android-demo,代碼行數:33,代碼來源:AnalyticsTracker.java


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