use of com.redhat.devtools.intellij.telemetry.core.service.TelemetryMessageBuilder.ActionMessage in project intellij-redhat-telemetry by redhat-developer.
the class TelemetryMessageBuilderTest method error_should_set_error_property.
@Test
public void error_should_set_error_property() {
// given
ActionMessage message = builder.action("the simpsons");
String error = "nuclear plant emergency";
// when
message.error(error);
// then
assertThat(message.getError()).isEqualTo(error);
}
use of com.redhat.devtools.intellij.telemetry.core.service.TelemetryMessageBuilder.ActionMessage in project intellij-redhat-telemetry by redhat-developer.
the class TelemetryMessageBuilderTest method send_should_send_message_via_service_facade.
@Test
public void send_should_send_message_via_service_facade() {
// given
ActionMessage message = builder.action("gargamel");
// when
message.send();
// then
verify(serviceFacadeMock).send(any(TelemetryEvent.class));
}
use of com.redhat.devtools.intellij.telemetry.core.service.TelemetryMessageBuilder.ActionMessage in project intellij-redhat-telemetry by redhat-developer.
the class TelemetryMessageBuilderTest method send_should_send_event_with_given_type_name_and_properties.
@Test
public void send_should_send_event_with_given_type_name_and_properties() {
// given
String name = "gargamel";
String key1 = "the lovliest";
String value1 = "smurfette";
String key2 = "the smallest";
String value2 = "baby smurf";
ActionMessage message = builder.action(name).property(key1, value1).property(key2, value2);
ArgumentCaptor<TelemetryEvent> eventArgument = ArgumentCaptor.forClass(TelemetryEvent.class);
// when
message.send();
// then
verify(serviceFacadeMock).send(eventArgument.capture());
TelemetryEvent event = eventArgument.getValue();
assertThat(event.getType()).isEqualTo(ACTION);
assertThat(event.getName()).isEqualTo(name);
assertThat(event.getProperties()).containsEntry(key1, value1);
assertThat(event.getProperties()).containsEntry(key2, value2);
}
use of com.redhat.devtools.intellij.telemetry.core.service.TelemetryMessageBuilder.ActionMessage in project intellij-tekton by redhat-developer.
the class DeployHelper method saveOnCluster.
public static boolean saveOnCluster(Project project, String namespace, String yaml, String confirmationMessage, boolean updateLabels, boolean skipConfirmatioDialog) throws IOException {
ActionMessage telemetry = TelemetryService.instance().action(NAME_PREFIX_CRUD + "save to cluster");
GenericResource resource = getResource(yaml, telemetry);
Tkn tknCli = TreeHelper.getTkn(project);
if (tknCli == null) {
telemetry.error("tkn not found").send();
return false;
}
if (namespace.isEmpty()) {
namespace = tknCli.getNamespace();
}
if (confirmationMessage.isEmpty()) {
confirmationMessage = getDefaultConfirmationMessage(resource.getName(), resource.getKind());
}
if (!skipConfirmatioDialog && !isSaveConfirmed(confirmationMessage)) {
telemetry.result(VALUE_ABORTED).send();
return false;
}
try {
String resourceNamespace = CRDHelper.isClusterScopedResource(resource.getKind()) ? "" : namespace;
Pair<String, Boolean> saveResult = doSave(resourceNamespace, yaml, updateLabels, resource, tknCli);
telemetry.property(PROP_RESOURCE_CRUD, (saveResult.getSecond() ? VALUE_RESOURCE_CRUD_CREATE : VALUE_RESOURCE_CRUD_UPDATE)).send();
} catch (KubernetesClientException e) {
String errorMsg = createErrorMessage(resource, e);
telemetry.error(anonymizeResource(resource.getName(), namespace, errorMsg)).send();
logger.warn(errorMsg, e);
// give a visual notification to user if an error occurs during saving
throw new IOException(errorMsg, e);
}
return true;
}
use of com.redhat.devtools.intellij.telemetry.core.service.TelemetryMessageBuilder.ActionMessage in project intellij-tekton by redhat-developer.
the class CancelAction method actionPerformed.
@Override
public void actionPerformed(AnActionEvent anActionEvent, TreePath path, Object selected, Tkn tkncli) {
ActionMessage telemetry = TelemetryService.instance().action(NAME_PREFIX_START_STOP + "cancel");
ExecHelper.submit(() -> {
ParentableNode element = getElement(selected);
String namespace = element.getNamespace();
try {
if (element instanceof PipelineRunNode) {
tkncli.cancelPipelineRun(namespace, element.getName());
telemetry.property(TelemetryService.PROP_RESOURCE_KIND, Constants.KIND_PIPELINERUN).send();
} else if (element instanceof TaskRunNode) {
tkncli.cancelTaskRun(namespace, element.getName());
telemetry.property(TelemetryService.PROP_RESOURCE_KIND, Constants.KIND_TASKRUN).send();
}
} catch (IOException e) {
telemetry.error(anonymizeResource(element.getName(), namespace, e.getMessage())).send();
Notification notification = new Notification(NOTIFICATION_ID, "Error", element.getName() + " in namespace " + namespace + " failed to cancel\n" + e.getLocalizedMessage(), NotificationType.ERROR);
Notifications.Bus.notify(notification);
logger.warn("Error: " + e.getLocalizedMessage(), e);
}
});
}
Aggregations