diff --git a/app/kubernetes/views/deploy/deployController.js b/app/kubernetes/views/deploy/deployController.js index dab47d228..da57d7f33 100644 --- a/app/kubernetes/views/deploy/deployController.js +++ b/app/kubernetes/views/deploy/deployController.js @@ -8,11 +8,11 @@ import { KubernetesDeployManifestTypes, KubernetesDeployBuildMethods, Kubernetes import { buildOption } from '@/portainer/components/box-selector'; class KubernetesDeployController { /* @ngInject */ - constructor($async, $state, $window, $analytics, ModalService, Notifications, EndpointProvider, KubernetesResourcePoolService, StackService, WebhookHelper) { + constructor($async, $state, $window, Authentication, ModalService, Notifications, EndpointProvider, KubernetesResourcePoolService, StackService, WebhookHelper) { this.$async = $async; this.$state = $state; this.$window = $window; - this.$analytics = $analytics; + this.Authentication = Authentication; this.ModalService = ModalService; this.Notifications = Notifications; this.EndpointProvider = EndpointProvider; @@ -72,6 +72,7 @@ class KubernetesDeployController { type: buildLabel(this.state.BuildMethod), format: formatLabel(this.state.DeployType), role: roleLabel(this.Authentication.isAdmin()), + 'automatic-updates': automaticUpdatesLabel(this.formValues.RepositoryAutomaticUpdates, this.formValues.RepositoryMechanism), }; if (this.state.BuildMethod === KubernetesDeployBuildMethods.GIT) { @@ -80,6 +81,17 @@ class KubernetesDeployController { return { metadata }; + function automaticUpdatesLabel(repositoryAutomaticUpdates, repositoryMechanism) { + switch (repositoryAutomaticUpdates && repositoryMechanism) { + case RepositoryMechanismTypes.INTERVAL: + return 'polling'; + case RepositoryMechanismTypes.WEBHOOK: + return 'webhook'; + default: + return 'off'; + } + } + function roleLabel(isAdmin) { if (isAdmin) { return 'admin'; diff --git a/app/portainer/components/forms/kubernetes-redeploy-app-git-form/kubernetes-redeploy-app-git-form.controller.js b/app/portainer/components/forms/kubernetes-redeploy-app-git-form/kubernetes-redeploy-app-git-form.controller.js index f5acc0e3f..da4a27f7f 100644 --- a/app/portainer/components/forms/kubernetes-redeploy-app-git-form/kubernetes-redeploy-app-git-form.controller.js +++ b/app/portainer/components/forms/kubernetes-redeploy-app-git-form/kubernetes-redeploy-app-git-form.controller.js @@ -2,7 +2,7 @@ import uuidv4 from 'uuid/v4'; import { RepositoryMechanismTypes } from 'Kubernetes/models/deploy'; class KubernetesRedeployAppGitFormController { /* @ngInject */ - constructor($async, $state, $analytics, StackService, ModalService, Notifications, WebhookHelper) { + constructor($async, $state, StackService, ModalService, Notifications, WebhookHelper) { this.$async = $async; this.$state = $state; this.StackService = StackService; @@ -46,23 +46,28 @@ class KubernetesRedeployAppGitFormController { }; } + buildAnalyticsProperties() { + const metadata = { + 'automatic-updates': automaticUpdatesLabel(this.formValues.AutoUpdate.RepositoryAutomaticUpdates, this.formValues.AutoUpdate.RepositoryMechanism), + }; + + return { metadata }; + + function automaticUpdatesLabel(repositoryAutomaticUpdates, repositoryMechanism) { + switch (repositoryAutomaticUpdates && repositoryMechanism) { + case RepositoryMechanismTypes.INTERVAL: + return 'polling'; + case RepositoryMechanismTypes.WEBHOOK: + return 'webhook'; + default: + return 'off'; + } + } + } + async pullAndRedeployApplication() { return this.$async(async () => { try { - //Analytics - const metadata = {}; - - if (this.formValues.AutoUpdate.RepositoryAutomaticUpdates) { - if (this.formValues.AutoUpdate.RepositoryMechanism === `Interval`) { - metadata['automatic-updates'] = 'polling'; - } else if (this.formValues.AutoUpdate.RepositoryMechanism === `Webhook`) { - metadata['automatic-updates'] = 'webhook'; - } - } else { - metadata['automatic-updates'] = 'off'; - } - this.$analytics.eventTrack('kubernetes-application-edit', { category: 'kubernetes', metadata: metadata }); - const confirmed = await this.ModalService.confirmAsync({ title: 'Are you sure?', message: 'Any changes to this application will be overriden by the definition in git and may cause a service interruption. Do you wish to continue?', diff --git a/app/portainer/components/forms/kubernetes-redeploy-app-git-form/kubernetes-redeploy-app-git-form.html b/app/portainer/components/forms/kubernetes-redeploy-app-git-form/kubernetes-redeploy-app-git-form.html index c41905ace..7fca0e4ef 100644 --- a/app/portainer/components/forms/kubernetes-redeploy-app-git-form/kubernetes-redeploy-app-git-form.html +++ b/app/portainer/components/forms/kubernetes-redeploy-app-git-form/kubernetes-redeploy-app-git-form.html @@ -53,6 +53,10 @@ ng-disabled="$ctrl.isSubmitButtonDisabled() || !$ctrl.redeployGitForm.$valid" style="margin-top: 7px; margin-left: 0;" button-spinner="$ctrl.state.saveGitSettingsInProgress" + analytics-on + analytics-category="kubernetes" + analytics-event="kubernetes-application-edit" + analytics-properties="$ctrl.buildAnalyticsProperties()" > Save settings In progress...