com.segment.analytics.Analytics.flush()方法的使用及代码示例

x33g5p2x  于2022-01-17 转载在 其他  
字(3.3k)|赞(0)|评价(0)|浏览(146)

本文整理了Java中com.segment.analytics.Analytics.flush()方法的一些代码示例,展示了Analytics.flush()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Analytics.flush()方法的具体详情如下:
包路径:com.segment.analytics.Analytics
类名称:Analytics
方法名:flush

Analytics.flush介绍

[英]Asynchronously flushes all messages in the queue to the server, and tells bundled integrations to do the same.
[中]异步地将队列中的所有消息刷新到服务器,并通知捆绑集成执行相同的操作。

代码示例

代码示例来源:origin: segmentio/analytics-android

@OnClick(R.id.action_flush)
void onFlushButtonClicked() {
 Analytics.with(this).flush();
}

代码示例来源:origin: segmentio/analytics-android

@Test
public void flush() {
 analytics.flush();
 verify(integration).flush();
}

代码示例来源:origin: segmentio/analytics-java

public static void main(String... args) throws Exception {
 final BlockingFlush blockingFlush = BlockingFlush.create();
 // https://segment.com/segment-engineering/sources/test-java/debugger
 final Analytics analytics =
   Analytics.builder("xemyw6oe3n")
     .plugin(blockingFlush.plugin())
     .plugin(new LoggingPlugin())
     .client(createClient())
     .build();
 final String userId = System.getProperty("user.name");
 final String anonymousId = UUID.randomUUID().toString();
 final AtomicInteger count = new AtomicInteger();
 for (int i = 0; i < 10; i++) {
  for (int j = 0; j < 10; j++) {
   Map<String, Object> properties = new LinkedHashMap<>();
   properties.put("count", count.incrementAndGet());
   analytics.enqueue(
     TrackMessage.builder("Java Test")
       .properties(properties)
       .anonymousId(anonymousId)
       .userId(userId));
  }
 }
 analytics.flush();
 blockingFlush.block();
 analytics.shutdown();
}

代码示例来源:origin: segmentio/analytics-android

@Test
public void screen() {
 final String uuid = UUID.randomUUID().toString();
 analytics.screen("Home", new Properties().putValue("id", uuid));
 analytics.flush();
 assertMessageReceivedByWebhook(uuid);
}

代码示例来源:origin: segmentio/analytics-android

@Test
public void identify() throws Exception {
 final String uuid = UUID.randomUUID().toString();
 analytics.group("prateek", new Traits().putValue("id", uuid));
 analytics.flush();
 assertMessageReceivedByWebhook(uuid);
}

代码示例来源:origin: segmentio/analytics-android

@Test
public void shutdown() {
 assertThat(analytics.shutdown).isFalse();
 analytics.shutdown();
 verify(application).unregisterActivityLifecycleCallbacks(analytics.activityLifecycleCallback);
 verify(stats).shutdown();
 verify(networkExecutor).shutdown();
 assertThat(analytics.shutdown).isTrue();
 try {
  analytics.track("foo");
  fail("Enqueuing a message after shutdown should throw.");
 } catch (IllegalStateException e) {
  assertThat(e).hasMessage("Cannot enqueue messages after client is shutdown.");
 }
 try {
  analytics.flush();
  fail("Enqueuing a message after shutdown should throw.");
 } catch (IllegalStateException e) {
  assertThat(e).hasMessage("Cannot enqueue messages after client is shutdown.");
 }
}

代码示例来源:origin: segmentio/analytics-android

@Test
public void track() {
 final String uuid = UUID.randomUUID().toString();
 analytics.track("Simple Track", new Properties().putValue("id", uuid));
 analytics.flush();
 assertMessageReceivedByWebhook(uuid);
}

代码示例来源:origin: segmentio/analytics-android

@Test
public void group() {
 final String uuid = UUID.randomUUID().toString();
 analytics.group("segment", new Traits().putValue("id", uuid));
 analytics.flush();
 assertMessageReceivedByWebhook(uuid);
}

相关文章