diff --git a/awx/ui/client/src/configuration/forms/system-form/sub-forms/system-misc.form.js b/awx/ui/client/src/configuration/forms/system-form/sub-forms/system-misc.form.js index e15713ee39..db475c8267 100644 --- a/awx/ui/client/src/configuration/forms/system-form/sub-forms/system-misc.form.js +++ b/awx/ui/client/src/configuration/forms/system-form/sub-forms/system-misc.form.js @@ -58,6 +58,8 @@ export default ['i18n', function(i18n) { CUSTOM_VENV_PATHS: { type: 'textarea', reset: 'CUSTOM_VENV_PATHS' + INSIGHTS_DATA_ENABLED: { + type: 'toggleSwitch' } }, diff --git a/awx/ui/client/src/license/license.block.less b/awx/ui/client/src/license/license.block.less index 0625568fff..08a6c624a6 100644 --- a/awx/ui/client/src/license/license.block.less +++ b/awx/ui/client/src/license/license.block.less @@ -140,6 +140,11 @@ margin-bottom: 20px; } -.License-detailsGroup--withSeparator { - border-top: 1px solid @default-icon-hov; +.License-analyticsCheckbox { + padding-top: 5px; +} + +.License-analyticsCheckboxGroup { + padding: 10px 0; + font-weight: bold; } diff --git a/awx/ui/client/src/license/license.controller.js b/awx/ui/client/src/license/license.controller.js index 39e211c4f5..ae7e5d3655 100644 --- a/awx/ui/client/src/license/license.controller.js +++ b/awx/ui/client/src/license/license.controller.js @@ -9,9 +9,9 @@ import {N_} from "../i18n"; export default ['Wait', '$state', '$scope', '$rootScope', 'ProcessErrors', 'CheckLicense', 'moment','$window', - 'ConfigService', 'FeaturesService', 'pendoService', 'i18n', 'config', + 'ConfigService', 'FeaturesService', 'pendoService', 'insightsEnablementService', 'i18n', 'config', function(Wait, $state, $scope, $rootScope, ProcessErrors, CheckLicense, moment, - $window, ConfigService, FeaturesService, pendoService, i18n, config) { + $window, ConfigService, FeaturesService, pendoService, insightsEnablementService, i18n, config) { const calcDaysRemaining = function(seconds) { // calculate the number of days remaining on the license @@ -54,7 +54,8 @@ export default $scope.valid = CheckLicense.valid($scope.license.license_info); $scope.compliant = $scope.license.license_info.compliant; $scope.newLicense = { - pendo: true + pendo: true, + insights: true }; }; @@ -114,6 +115,13 @@ export default } else { pendoService.updatePendoTrackingState('off'); } + + if ($scope.newLicense.insights) { + insightsEnablementService.updateInsightsTrackingState(true); + } else { + insightsEnablementService.updateInsightsTrackingState(false); + } + $state.go('dashboard', { licenseMissing: false }); diff --git a/awx/ui/client/src/license/license.partial.html b/awx/ui/client/src/license/license.partial.html index f97ea9e1c8..86be0f9284 100644 --- a/awx/ui/client/src/license/license.partial.html +++ b/awx/ui/client/src/license/license.partial.html @@ -115,25 +115,38 @@
{{ license.eula }}
-
+
-
-
- +
+ Tracking and Analytics +
+
+ + By default, Tower collects and transmits analytics data on Tower usage to Red Hat. You can uncheck these boxes to disable sending data to these services: + +
+
+ + Pendo +
+
+ + Insights +
+ + For more information about track and analytics, see + + this Tower documentation page + . + +
diff --git a/awx/ui/client/src/login/authenticationServices/insightsEnablement.service.js b/awx/ui/client/src/login/authenticationServices/insightsEnablement.service.js new file mode 100644 index 0000000000..8993c9d969 --- /dev/null +++ b/awx/ui/client/src/login/authenticationServices/insightsEnablement.service.js @@ -0,0 +1,27 @@ +/************************************************* +* Copyright (c) 2015 Ansible, Inc. +* +* All Rights Reserved +*************************************************/ + + +export default ['$rootScope', 'Rest', 'GetBasePath', 'ProcessErrors', + function ($rootScope, Rest, GetBasePath, ProcessErrors) { + return { + updateInsightsTrackingState: function(tracking_type) { + if (tracking_type === true || tracking_type === false) { + Rest.setUrl(`${GetBasePath('settings')}system`); + Rest.patch({ INSIGHTS_DATA_ENABLED: tracking_type }) + .catch(function ({data, status}) { + ProcessErrors($rootScope, data, status, null, { + hdr: 'Error!', + msg: 'Failed to patch INSIGHTS_DATA_ENABLED in settings: ' + + status }); + }); + } else { + throw new Error(`Can't update insights data enabled in settings to + "${tracking_type}"`); + } + } + }; + }]; diff --git a/awx/ui/client/src/login/authenticationServices/main.js b/awx/ui/client/src/login/authenticationServices/main.js index 11bb998710..373ecdbd07 100644 --- a/awx/ui/client/src/login/authenticationServices/main.js +++ b/awx/ui/client/src/login/authenticationServices/main.js @@ -8,10 +8,12 @@ import authenticationService from './authentication.service'; import isAdmin from './isAdmin.factory'; import timer from './timer.factory'; import pendoService from './pendo.service'; +import insightsEnablementService from './insightsEnablement.service'; export default angular.module('authentication', []) .factory('Authorization', authenticationService) .factory('IsAdmin', isAdmin) .factory('Timer', timer) - .service('pendoService', pendoService); + .service('pendoService', pendoService) + .service('insightsEnablementService', insightsEnablementService);