本文整理了Java中com.segment.analytics.Analytics.track()
方法的一些代码示例,展示了Analytics.track()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Analytics.track()
方法的具体详情如下:
包路径:com.segment.analytics.Analytics
类名称:Analytics
方法名:track
暂无
代码示例来源:origin: segmentio/analytics-android
/** @see #track(String, Properties, Options) */
public void track(@NonNull String event) {
track(event, null, null);
}
代码示例来源:origin: segmentio/analytics-android
/** @see #track(String, Properties, Options) */
public void track(@NonNull String event, @Nullable Properties properties) {
track(event, properties, null);
}
代码示例来源:origin: segmentio/analytics-android
@OnClick(R.id.action_track_a)
void onButtonAClicked() {
Analytics.with(this).track("Button A Clicked");
}
代码示例来源:origin: segmentio/analytics-android
@OnClick(R.id.action_track_b)
void onButtonBClicked() {
Analytics.with(this).track("Button B Clicked");
}
代码示例来源:origin: f2prateek/device-frame-generator
@OnClick(R.id.tv_device_name) public void openDevicePage() {
Properties properties = new Properties();
device.into(properties);
analytics.track("Clicked Device Website", properties);
Intent i = new Intent(Intent.ACTION_VIEW);
i.setData(Uri.parse(device.url()));
startActivity(i);
}
代码示例来源:origin: segmentio/analytics-android
@Test
public void invalidTrack() {
try {
analytics.track(null);
} catch (IllegalArgumentException e) {
assertThat(e).hasMessage("event must not be null or empty.");
}
try {
analytics.track(" ");
} catch (IllegalArgumentException e) {
assertThat(e).hasMessage("event must not be null or empty.");
}
}
代码示例来源:origin: segmentio/analytics-android
@Test
public void optOutDisablesEvents() throws IOException {
analytics.optOut(true);
analytics.track("foo");
verifyNoMoreInteractions(integration);
}
代码示例来源: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: 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 trackingPlanDisablesEvent() throws IOException {
analytics.projectSettings =
ProjectSettings.create(
Cartographer.INSTANCE.fromJson(
"{\n"
+ " \"integrations\": {\n"
+ " \"test\": {\n"
+ " \"foo\": \"bar\"\n"
+ " }\n"
+ " },\n"
+ " \"plan\": {\n"
+ " \"track\": {\n"
+ " \"foo\": {\n"
+ " \"enabled\": false\n"
+ " }\n"
+ " }\n"
+ " }\n"
+ "}"));
analytics.track("foo");
verifyNoMoreInteractions(integration);
}
代码示例来源: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: f2prateek/device-frame-generator
@Override protected void onHandleIntent(Intent intent) {
Dart.inject(this, intent.getExtras());
Properties properties = new Properties();
device.into(properties);
analytics.track("Generating Frame", properties);
generator = new DeviceFrameGenerator(this, this, device, shadowEnabledPreference.get(),
glareEnabledPreference.get(), colorBackgroundEnabledPreference.get(),
blurBackgroundEnabledPreference.get(), backgroundColorOptionPreference.get(),
customBackgroundColorPreference.get(), backgroundPaddingPercentagePreference.get(),
backgroundBlurRadiusPreference.get());
}
代码示例来源:origin: segmentio/analytics-android
@Test
public void optionsCustomContext() {
analytics.track("foo", null, new Options().putContext("from_tests", true));
verify(integration)
.track(
argThat(
new NoDescriptionMatcher<TrackPayload>() {
@Override
protected boolean matchesSafely(TrackPayload payload) {
return payload.context().get("from_tests") == Boolean.TRUE;
}
}));
}
代码示例来源:origin: segmentio/analytics-android
@Test
public void track() {
analytics.track("wrote tests", new Properties().putUrl("github.com"));
verify(integration)
.track(
argThat(
new NoDescriptionMatcher<TrackPayload>() {
@Override
protected boolean matchesSafely(TrackPayload payload) {
return payload.event().equals("wrote tests")
&& //
payload.properties().url().equals("github.com");
}
}));
}
代码示例来源:origin: segmentio/analytics-android
@Test
public void trackingPlanDisabledEventCannotBeOverriddenByOptions() throws IOException {
analytics.projectSettings =
ProjectSettings.create(
Cartographer.INSTANCE.fromJson(
"{\n"
+ " \"integrations\": {\n"
+ " \"test\": {\n"
+ " \"foo\": \"bar\"\n"
+ " }\n"
+ " },\n"
+ " \"plan\": {\n"
+ " \"track\": {\n"
+ " \"foo\": {\n"
+ " \"enabled\": false\n"
+ " }\n"
+ " }\n"
+ " }\n"
+ "}"));
analytics.track("foo", null, new Options().setIntegration("test", true));
verifyNoMoreInteractions(integration);
}
代码示例来源: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);
}
内容来源于网络,如有侵权,请联系作者删除!