use of com.redhat.devtools.intellij.telemetry.core.service.TelemetryMessageBuilder.ActionMessage in project intellij-tekton by redhat-developer.
the class CreateTaskRunTemplateAction method actionPerformed.
@Override
public void actionPerformed(AnActionEvent anActionEvent, TreePath path, Object selected, Tkn tkncli) {
ActionMessage telemetry = TelemetryService.instance().action(NAME_PREFIX_CRUD + "create task run");
ParentableNode element = getElement(selected);
String namespace = element.getNamespace();
ExecHelper.submit(() -> {
Notification notification;
TaskConfigurationModel model;
try {
model = getModel(element, namespace, tkncli);
} catch (IOException e) {
String errorMessage = "Failed to create TaskRun templace from " + element.getName() + " in namespace " + namespace + "An error occurred while retrieving information.\n" + e.getLocalizedMessage();
telemetry.error(anonymizeResource(element.getName(), namespace, errorMessage)).send();
UIHelper.executeInUI(() -> {
Messages.showErrorDialog(errorMessage, "Error");
});
logger.warn("Error: " + e.getLocalizedMessage(), e);
return;
}
if (!model.isValid()) {
String errorMessage = "Failed to create a TaskRun templace from " + element.getName() + " in namespace " + namespace + ". The task is not valid.";
telemetry.error(anonymizeResource(element.getName(), namespace, errorMessage)).send();
UIHelper.executeInUI(() -> Messages.showErrorDialog(errorMessage, "Error"));
return;
}
try {
String contentTask = new YAMLMapper().writeValueAsString(YAMLBuilder.createTaskRun(model));
openEditor(anActionEvent.getProject(), namespace, telemetry, model, contentTask);
} catch (IOException e) {
String errorMessage = "Failed to create TaskRun templace from" + element.getName() + " in namespace " + namespace + " \n" + e.getLocalizedMessage();
telemetry.error(anonymizeResource(element.getName(), namespace, errorMessage)).send();
notification = new Notification(NOTIFICATION_ID, "Error", errorMessage, NotificationType.ERROR);
Notifications.Bus.notify(notification);
logger.warn(errorMessage, e);
}
});
}
use of com.redhat.devtools.intellij.telemetry.core.service.TelemetryMessageBuilder.ActionMessage in project intellij-tekton by redhat-developer.
the class CreateResourceAction method actionPerformed.
@Override
public void actionPerformed(AnActionEvent anActionEvent, TreePath path, Object selected, Tkn tkncli) {
ActionMessage telemetry = TelemetryService.instance().action(NAME_PREFIX_CRUD + "create resource");
ResourcesNode item = getElement(selected);
String namespace = item.getParent().getName();
String content = getSnippet("Tekton: PipelineResource");
if (Strings.isNullOrEmpty(content)) {
telemetry.error("snippet content empty").send();
} else {
String name = namespace + "-newresource.yaml";
try {
VirtualFileHelper.createAndOpenVirtualFile(anActionEvent.getProject(), namespace, name, content, KIND_RESOURCES, item);
telemetry.success().send();
} catch (IOException e) {
telemetry.error(anonymizeResource(name, namespace, e.getMessage())).send();
logger.warn("Could not create resource: " + e.getLocalizedMessage(), e);
}
}
}
use of com.redhat.devtools.intellij.telemetry.core.service.TelemetryMessageBuilder.ActionMessage in project intellij-tekton by redhat-developer.
the class CreateTaskAction method actionPerformed.
@Override
public void actionPerformed(AnActionEvent anActionEvent, TreePath path, Object selected, Tkn tkncli) {
ActionMessage telemetry = TelemetryService.instance().action(NAME_PREFIX_CRUD + "create task").property(PROP_RESOURCE_KIND, KIND_TASK);
TasksNode item = getElement(selected);
String namespace = item.getParent().getName();
String content = getSnippet("Tekton: Task");
if (Strings.isNullOrEmpty(content)) {
telemetry.error("snippet content empty").send();
} else {
String name = namespace + "-newtask.yaml";
try {
VirtualFileHelper.createAndOpenVirtualFile(anActionEvent.getProject(), namespace, name, content, KIND_TASKS, item);
telemetry.send();
} catch (IOException e) {
telemetry.error(anonymizeResource(name, namespace, e.getMessage())).send();
logger.warn(e.getLocalizedMessage(), e);
}
}
}
use of com.redhat.devtools.intellij.telemetry.core.service.TelemetryMessageBuilder.ActionMessage in project intellij-tekton by redhat-developer.
the class CreateConditionAction method actionPerformed.
@Override
public void actionPerformed(AnActionEvent anActionEvent, TreePath path, Object selected, Tkn tkncli) {
ActionMessage telemetry = TelemetryService.instance().action(NAME_PREFIX_CRUD + "create condition").property(PROP_RESOURCE_KIND, KIND_CONDITION);
ConditionsNode item = getElement(selected);
String namespace = item.getParent().getName();
String content = getSnippet("Tekton: Condition");
if (Strings.isNullOrEmpty(content)) {
telemetry.error("snippet content empty.").send();
} else {
String name = namespace + "-newcondition.yaml";
try {
VirtualFileHelper.createAndOpenVirtualFile(anActionEvent.getProject(), namespace, name, content, KIND_CONDITIONS, item);
telemetry.send();
} catch (IOException e) {
telemetry.error(anonymizeResource(name, namespace, e.getMessage())).send();
logger.warn("Could not create condition: " + e.getLocalizedMessage(), e);
}
}
}
use of com.redhat.devtools.intellij.telemetry.core.service.TelemetryMessageBuilder.ActionMessage in project intellij-redhat-telemetry by redhat-developer.
the class TelemetryMessageBuilderTest method property_should_ignore_property_with_null_value.
@Test
public void property_should_ignore_property_with_null_value() {
// given
ActionMessage message = builder.action("smurfette");
int beforeAdding = message.properties().size();
// when
message.property("likes", null);
// then
assertThat(message.properties().size()).isEqualTo(beforeAdding);
}
Aggregations