mirror of
https://github.com/portainer/portainer.git
synced 2025-08-02 12:25:22 +02:00
feat(analytics): track existing features (#5448) [EE-1076]
This commit is contained in:
parent
b8e6c5ea91
commit
4ffee27a4b
25 changed files with 361 additions and 55 deletions
|
@ -299,6 +299,11 @@
|
|||
ng-click="ctrl.configure()"
|
||||
ng-disabled="ctrl.state.actionInProgress || !kubernetesClusterSetupForm.$valid || !ctrl.hasValidStorageConfiguration()"
|
||||
button-spinner="ctrl.state.actionInProgress"
|
||||
analytics-on
|
||||
analytics-if="ctrl.restrictDefaultToggledOn()"
|
||||
analytics-category="kubernetes"
|
||||
analytics-event="kubernetes-configure"
|
||||
analytics-properties="{ metadata: { restrictAccessToDefaultNamespace: ctrl.formValues.RestrictDefaultNamespace } }"
|
||||
>
|
||||
<span ng-hide="ctrl.state.actionInProgress">Save configuration</span>
|
||||
<span ng-show="ctrl.state.actionInProgress">Saving configuration...</span>
|
||||
|
|
|
@ -237,6 +237,10 @@ class KubernetesConfigureController {
|
|||
}
|
||||
/* #endregion */
|
||||
|
||||
restrictDefaultToggledOn() {
|
||||
return this.formValues.RestrictDefaultNamespace && !this.oldFormValues.RestrictDefaultNamespace;
|
||||
}
|
||||
|
||||
/* #region ON INIT */
|
||||
async onInit() {
|
||||
this.state = {
|
||||
|
@ -287,6 +291,8 @@ class KubernetesConfigureController {
|
|||
ic.NeedsDeletion = false;
|
||||
return ic;
|
||||
});
|
||||
|
||||
this.oldFormValues = Object.assign({}, this.formValues);
|
||||
} catch (err) {
|
||||
this.Notifications.error('Failure', err, 'Unable to retrieve endpoint configuration');
|
||||
} finally {
|
||||
|
|
|
@ -151,6 +151,10 @@
|
|||
ng-click="ctrl.deploy()"
|
||||
button-spinner="ctrl.state.actionInProgress"
|
||||
data-cy="k8sAppDeploy-deployButton"
|
||||
analytics-on
|
||||
analytics-category="kubernetes"
|
||||
analytics-event="kubernetes-application-advanced-deployment"
|
||||
analytics-properties="ctrl.buildAnalyticsProperties()"
|
||||
>
|
||||
<span ng-hide="ctrl.state.actionInProgress">Deploy</span>
|
||||
<span ng-show="ctrl.state.actionInProgress">Deployment in progress...</span>
|
||||
|
|
|
@ -7,10 +7,11 @@ import { KubernetesDeployManifestTypes, KubernetesDeployBuildMethods, Kubernetes
|
|||
import { buildOption } from '@/portainer/components/box-selector';
|
||||
class KubernetesDeployController {
|
||||
/* @ngInject */
|
||||
constructor($async, $state, $window, CustomTemplateService, ModalService, Notifications, EndpointProvider, KubernetesResourcePoolService, StackService) {
|
||||
constructor($async, $state, $window, Authentication, CustomTemplateService, ModalService, Notifications, EndpointProvider, KubernetesResourcePoolService, StackService) {
|
||||
this.$async = $async;
|
||||
this.$state = $state;
|
||||
this.$window = $window;
|
||||
this.Authentication = Authentication;
|
||||
this.CustomTemplateService = CustomTemplateService;
|
||||
this.ModalService = ModalService;
|
||||
this.Notifications = Notifications;
|
||||
|
@ -52,6 +53,47 @@ class KubernetesDeployController {
|
|||
this.onChangeFormValues = this.onChangeFormValues.bind(this);
|
||||
this.onRepoUrlChange = this.onRepoUrlChange.bind(this);
|
||||
this.onRepoRefChange = this.onRepoRefChange.bind(this);
|
||||
this.buildAnalyticsProperties = this.buildAnalyticsProperties.bind(this);
|
||||
}
|
||||
|
||||
buildAnalyticsProperties() {
|
||||
const metadata = {
|
||||
type: buildLabel(this.state.BuildMethod),
|
||||
format: formatLabel(this.state.DeployType),
|
||||
role: roleLabel(this.Authentication.isAdmin()),
|
||||
};
|
||||
|
||||
if (this.state.BuildMethod === KubernetesDeployBuildMethods.GIT) {
|
||||
metadata.auth = this.formValues.RepositoryAuthentication;
|
||||
}
|
||||
|
||||
return { metadata };
|
||||
|
||||
function roleLabel(isAdmin) {
|
||||
if (isAdmin) {
|
||||
return 'admin';
|
||||
}
|
||||
|
||||
return 'standard';
|
||||
}
|
||||
|
||||
function buildLabel(buildMethod) {
|
||||
switch (buildMethod) {
|
||||
case KubernetesDeployBuildMethods.GIT:
|
||||
return 'git';
|
||||
case KubernetesDeployBuildMethods.WEB_EDITOR:
|
||||
return 'web-editor';
|
||||
}
|
||||
}
|
||||
|
||||
function formatLabel(format) {
|
||||
switch (format) {
|
||||
case KubernetesDeployManifestTypes.COMPOSE:
|
||||
return 'compose';
|
||||
case KubernetesDeployManifestTypes.KUBERNETES:
|
||||
return 'manifest';
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
disableDeploy() {
|
||||
|
@ -59,11 +101,13 @@ class KubernetesDeployController {
|
|||
this.state.BuildMethod === KubernetesDeployBuildMethods.GIT &&
|
||||
(!this.formValues.RepositoryURL ||
|
||||
!this.formValues.FilePathInRepository ||
|
||||
(this.formValues.RepositoryAuthentication && (!this.formValues.RepositoryUsername || !this.formValues.RepositoryPassword))) && _.isEmpty(this.formValues.Namespace);
|
||||
const isWebEditorInvalid = this.state.BuildMethod === KubernetesDeployBuildMethods.WEB_EDITOR && _.isEmpty(this.formValues.EditorContent) && _.isEmpty(this.formValues.Namespace);
|
||||
(this.formValues.RepositoryAuthentication && (!this.formValues.RepositoryUsername || !this.formValues.RepositoryPassword))) &&
|
||||
_.isEmpty(this.formValues.Namespace);
|
||||
const isWebEditorInvalid =
|
||||
this.state.BuildMethod === KubernetesDeployBuildMethods.WEB_EDITOR && _.isEmpty(this.formValues.EditorContent) && _.isEmpty(this.formValues.Namespace);
|
||||
const isURLFormInvalid = this.state.BuildMethod == KubernetesDeployBuildMethods.WEB_EDITOR.URL && _.isEmpty(this.formValues.ManifestURL);
|
||||
|
||||
return isGitFormInvalid || isWebEditorInvalid || isURLFormInvalid || this.state.actionInProgress;
|
||||
return isGitFormInvalid || isWebEditorInvalid || isURLFormInvalid || this.state.actionInProgress;
|
||||
}
|
||||
|
||||
onChangeFormValues(values) {
|
||||
|
@ -127,7 +171,7 @@ class KubernetesDeployController {
|
|||
case KubernetesDeployBuildMethods.CUSTOM_TEMPLATE:
|
||||
method = KubernetesDeployRequestMethods.STRING;
|
||||
composeFormat = false;
|
||||
break;
|
||||
break;
|
||||
case this.BuildMethods.URL:
|
||||
method = KubernetesDeployRequestMethods.URL;
|
||||
break;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue