本文整理汇总了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));
}
}
}
示例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);
}
}
示例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)
);
}