当前位置: 首页>>代码示例>>Java>>正文


Java HitBuilders.ExceptionBuilder方法代码示例

本文整理汇总了Java中com.google.android.gms.analytics.HitBuilders.ExceptionBuilder方法的典型用法代码示例。如果您正苦于以下问题:Java HitBuilders.ExceptionBuilder方法的具体用法?Java HitBuilders.ExceptionBuilder怎么用?Java HitBuilders.ExceptionBuilder使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在com.google.android.gms.analytics.HitBuilders的用法示例。


在下文中一共展示了HitBuilders.ExceptionBuilder方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: logGoogleAnalyticsEvent

import com.google.android.gms.analytics.HitBuilders; //导入方法依赖的package包/类
private void logGoogleAnalyticsEvent(AnalyticsEvent event)
{
	if (event instanceof ContentViewEvent)
	{
		HitBuilders.ScreenViewBuilder screenViewBuilder = new HitBuilders.ScreenViewBuilder();
		// add any custom attributes already set on the event
		screenViewBuilder.setAll(stringifyAttributesMap(event.getAttributes()));

		synchronized (this.tracker)
		{
			// Set the screen name and send a screen view.
			this.tracker.setScreenName(String.valueOf(event.getAttribute(ContentViewEvent.CONTENT_NAME)));
			this.tracker.send(screenViewBuilder.build());
		}
	}
	else if (event instanceof ErrorEvent)
	{
		ErrorEvent errorEvent = (ErrorEvent) event;
		// Build and send exception.
		HitBuilders.ExceptionBuilder exceptionBuilder = new HitBuilders.ExceptionBuilder()
				.setDescription(errorEvent.message())
				.setFatal(false);

		// Add any custom attributes that are attached to the event
		exceptionBuilder.setAll(stringifyAttributesMap(errorEvent.getAttributes()));

		this.tracker.send(exceptionBuilder.build());
	}
	else
	{
		// Build and send an Event.
		HitBuilders.EventBuilder eventBuilder = new HitBuilders.EventBuilder()
				.setCategory("User Event")
				.setAction(event.name());

		// Add any custom attributes that are attached to the event
		eventBuilder.setAll(stringifyAttributesMap(event.getAttributes()));

		this.tracker.send(eventBuilder.build());
	}
}
 
开发者ID:busybusy,项目名称:AnalyticsKit-Android,代码行数:42,代码来源:GoogleAnalyticsProvider.java


注:本文中的com.google.android.gms.analytics.HitBuilders.ExceptionBuilder方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。