本文整理汇总了Java中io.sentry.event.UserBuilder类的典型用法代码示例。如果您正苦于以下问题:Java UserBuilder类的具体用法?Java UserBuilder怎么用?Java UserBuilder使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
UserBuilder类属于io.sentry.event包,在下文中一共展示了UserBuilder类的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: initSentryOnCurrentThread
import io.sentry.event.UserBuilder; //导入依赖的package包/类
public static void initSentryOnCurrentThread() {
Sentry.init("https://2eb0fc30f86a4871a85755ecdde11679:[email protected]/252970");
Sentry.getContext().setUser(new UserBuilder().setUsername("RoboTricker").build());
Sentry.getContext().addTag("thread", Thread.currentThread().getName());
Sentry.getContext().addTag("version", TransportPipes.instance.getDescription().getVersion());
Thread.setDefaultUncaughtExceptionHandler(new UncaughtExceptionHandler() {
@Override
public void uncaughtException(Thread t, Throwable e) {
Sentry.capture(e);
}
});
}
示例2: getUserBuilder
import io.sentry.event.UserBuilder; //导入依赖的package包/类
@NonNull
private UserBuilder getUserBuilder(ReadableMap user) {
UserBuilder userBuilder = new UserBuilder();
if (user.hasKey("email")) {
userBuilder.setEmail(user.getString("email"));
}
if (user.hasKey("userID")) {
userBuilder.setId(user.getString("userID"));
} else if (user.hasKey("userId")) {
userBuilder.setId(user.getString("userId"));
} else if (user.hasKey("id")) {
userBuilder.setId(user.getString("id"));
}
if (user.hasKey("username")) {
userBuilder.setUsername(user.getString("username"));
}
if (user.hasKey("extra")) {
userBuilder.setData(((ReadableNativeMap)user.getMap("extra")).toHashMap());
}
return userBuilder;
}
示例3: initClient
import io.sentry.event.UserBuilder; //导入依赖的package包/类
@PostConstruct
private void initClient() {
if (isSentryEnabled) {
LOGGER.info("Enabling Sentry for errors/crashes reporting");
// initialize sentry
Sentry.init();
// configure user for sentry
User sentryUser = new UserBuilder().setUsername(appName).build();
Sentry.getContext().setUser(sentryUser);
// add additional information to sentry
Sentry.getContext().addTag("tagName", appVersion);
} else {
LOGGER.info("Sentry is not enabled by properties, so crashes/errors are not reporting on it");
}
}
示例4: setUser
import io.sentry.event.UserBuilder; //导入依赖的package包/类
@ReactMethod
public void setUser(ReadableMap user) {
UserBuilder userBuilder = getUserBuilder(user);
User builtUser = userBuilder.build();
if (builtUser.getId() != null) {
Sentry.setUser(builtUser);
}
}