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

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

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

Analytics.identify介绍

暂无

代码示例

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

/** @see #identify(String, Traits, Options) */
public void identify(@NonNull Traits traits) {
 identify(null, traits, null);
}

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

/** @see #identify(String, Traits, Options) */
public void identify(@NonNull String userId) {
 identify(userId, null, null);
}

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

@OnClick(R.id.action_identify)
void onIdentifyButtonClicked() {
 String id = userId.getText().toString();
 if (isNullOrEmpty(id)) {
  Toast.makeText(this, R.string.id_required, Toast.LENGTH_LONG).show();
 } else {
  Analytics.with(this).identify(id);
 }
}

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

@Test
public void invalidIdentify() {
 try {
  analytics.identify(null, null, null);
 } catch (IllegalArgumentException e) {
  assertThat(e).hasMessage("Either userId or some traits must be provided.");
 }
}

代码示例来源:origin: f2prateek/device-frame-generator

public void updateShadowSetting(boolean newSettingEnabled) {
 analytics.track("Shadow " + (newSettingEnabled ? "Enabled" : "Disabled"));
 analytics.identify(new Traits().putValue("shadow_enabled", newSettingEnabled));
 updatePreference(newSettingEnabled, shadowEnabled, getString(R.string.shadow_enabled),
   getString(R.string.shadow_disabled));
}

代码示例来源:origin: f2prateek/device-frame-generator

public void updateGlareSetting(boolean newSettingEnabled) {
 analytics.track("Glare " + (newSettingEnabled ? "Enabled" : "Disabled"));
 analytics.identify(new Traits().putValue("glare_enabled", newSettingEnabled));
 updatePreference(newSettingEnabled, glareEnabled, getString(R.string.glare_enabled),
   getString(R.string.glare_disabled));
}

代码示例来源:origin: f2prateek/device-frame-generator

@Subscribe public void onDefaultDeviceUpdated(Events.DefaultDeviceUpdated event) {
 Ln.d("Device updated to %s", event.newDevice.name());
 Properties properties = new Properties();
 event.newDevice.into(properties);
 analytics.track("Updated Default Device", properties);
 Traits traits = new Traits();
 event.newDevice.into(traits);
 analytics.identify(traits);
 Snackbar.make(pager, getString(R.string.saved_as_default_message, event.newDevice.name()),
   Snackbar.LENGTH_LONG).show();
 // This might be from the application class, so update the position as well
 // the application class runs it on the main thread currently, so this more for a
 // future improvement
 pager.setCurrentItem(pagerAdapter.getDeviceIndex(event.newDevice));
 invalidateOptionsMenu();
}

代码示例来源:origin: f2prateek/device-frame-generator

public void updateBlurBackgroundSetting(boolean newSettingEnabled) {
 analytics.track("Blur Background " + (newSettingEnabled ? "Enabled" : "Disabled"));
 analytics.identify(new Traits().putValue("blur_background_enabled", newSettingEnabled));
 updatePreference(newSettingEnabled, blurBackgroundEnabled,
   getString(R.string.blur_background_enabled), getString(R.string.blur_background_disabled));
 if (newSettingEnabled && colorBackgroundEnabled.get()) {
  // Both blur and color background cannot be enabled together
  updateColorBackgroundSetting(false);
 }
}

代码示例来源:origin: f2prateek/device-frame-generator

public void updateColorBackgroundSetting(boolean newSettingEnabled) {
 analytics.track("Color Background " + (newSettingEnabled ? "Enabled" : "Disabled"));
 analytics.identify(new Traits().putValue("color_background_enabled", newSettingEnabled));
 updatePreference(newSettingEnabled, colorBackgroundEnabled,
   getString(R.string.color_background_enabled),
   getString(R.string.color_background_disabled));
 if (newSettingEnabled && blurBackgroundEnabled.get()) {
  // Both blur and color background cannot be enabled together
  updateBlurBackgroundSetting(false);
 }
}

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

@Test
 public void middlewareCanTransform() throws Exception {
  final AtomicReference<BasePayload> payloadRef = new AtomicReference<>();
  Analytics analytics =
    builder
      .middleware(
        new Middleware() {
         @Override
         public void intercept(Chain chain) {
          chain.proceed(chain.payload().toBuilder().messageId("override").build());
         }
        })
      .middleware(
        new Middleware() {
         @Override
         public void intercept(Chain chain) {
          BasePayload payload = chain.payload();
          payloadRef.set(payload);
          chain.proceed(payload);
         }
        })
      .build();

  analytics.identify("prateek");
  assertThat(payloadRef.get().messageId()).isEqualTo("override");
 }
}

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

@Test
public void identify() {
 analytics.identify("prateek", new Traits().putUsername("f2prateek"), null);
 verify(integration)
   .identify(
     argThat(
       new NoDescriptionMatcher<IdentifyPayload>() {
        @Override
        protected boolean matchesSafely(IdentifyPayload item) {
         return item.userId().equals("prateek")
           && item.traits().username().equals("f2prateek");
        }
       }));
}

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

@Test
public void identifyUpdatesCache() {
 analytics.identify("foo", new Traits().putValue("bar", "qaz"), null);
 assertThat(traits)
   .contains(MapEntry.entry("userId", "foo"))
   .contains(MapEntry.entry("bar", "qaz"));
 assertThat(analyticsContext.traits())
   .contains(MapEntry.entry("userId", "foo"))
   .contains(MapEntry.entry("bar", "qaz"));
 verify(traitsCache).set(traits);
 verify(integration)
   .identify(
     argThat(
       new NoDescriptionMatcher<IdentifyPayload>() {
        @Override
        protected boolean matchesSafely(IdentifyPayload item) {
         // Exercises a bug where payloads didn't pick up userId in identify correctly.
         // https://github.com/segmentio/analytics-android/issues/169
         return item.userId().equals("foo");
        }
       }));
}

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

@Test
public void optionsDisableIntegrations() {
 analytics.screen("foo", "bar", null, new Options().setIntegration("test", false));
 analytics.track("foo", null, new Options().setIntegration("test", false));
 analytics.group("foo", null, new Options().setIntegration("test", false));
 analytics.identify("foo", null, new Options().setIntegration("test", false));
 analytics.alias("foo", new Options().setIntegration("test", false));
 analytics.screen(
   "foo", "bar", null, new Options().setIntegration(Options.ALL_INTEGRATIONS_KEY, false));
 analytics.track("foo", null, new Options().setIntegration(Options.ALL_INTEGRATIONS_KEY, false));
 analytics.group("foo", null, new Options().setIntegration(Options.ALL_INTEGRATIONS_KEY, false));
 analytics.identify(
   "foo", null, new Options().setIntegration(Options.ALL_INTEGRATIONS_KEY, false));
 analytics.alias("foo", new Options().setIntegration(Options.ALL_INTEGRATIONS_KEY, false));
 verifyNoMoreInteractions(integration);
}

相关文章