[CLD-6430] Remove telemetry check from true_up_review (#26073)

* Remove telemetry check from true_up_review

* Fix bug

* Fix linter

* fix tests
Этот коммит содержится в:
Nick Misasi
2024-02-21 09:50:47 -05:00
коммит произвёл GitHub
родитель 521844fed5
Коммит 01e1eebc07
4 изменённых файлов: 26 добавлений и 13 удалений

Просмотреть файл

@@ -351,10 +351,8 @@ func requestTrueUpReview(c *Context, w http.ResponseWriter, r *http.Request) {
return return
} }
// True-up is only enabled when telemetry is disabled. // Only report the true up review to CWS if the connection is available.
// When telemetry is enabled, we already have all the data necessary for true-up reviews to be completed. if err := c.App.Cloud().CheckCWSConnection(c.AppContext.Session().UserId); err == nil {
telemetryEnabled := c.App.Config().LogSettings.EnableDiagnostics
if telemetryEnabled != nil && !*telemetryEnabled {
err = c.App.Cloud().SubmitTrueUpReview(c.AppContext.Session().UserId, profileMap) err = c.App.Cloud().SubmitTrueUpReview(c.AppContext.Session().UserId, profileMap)
if err != nil { if err != nil {
c.Err = model.NewAppError("requestTrueUpReview", "api.license.true_up_review.failed_to_submit", nil, err.Error(), http.StatusInternalServerError) c.Err = model.NewAppError("requestTrueUpReview", "api.license.true_up_review.failed_to_submit", nil, err.Error(), http.StatusInternalServerError)

Просмотреть файл

@@ -486,6 +486,7 @@ func TestRequestTrueUpReview(t *testing.T) {
cloud := mocks.CloudInterface{} cloud := mocks.CloudInterface{}
cloud.Mock.On("SubmitTrueUpReview", mock.Anything, mock.Anything).Return(nil) cloud.Mock.On("SubmitTrueUpReview", mock.Anything, mock.Anything).Return(nil)
cloud.Mock.On("CheckCWSConnection", mock.Anything).Return(nil)
cloudImpl := th.App.Srv().Cloud cloudImpl := th.App.Srv().Cloud
defer func() { defer func() {

Просмотреть файл

@@ -25,7 +25,7 @@ describe('TrueUpReview', () => {
IsLicensed: 'true', IsLicensed: 'true',
}), }),
config: { config: {
EnableDiagnostics: 'false', EnableDiagnostics: 'true',
}, },
}, },
users: { users: {
@@ -55,13 +55,31 @@ describe('TrueUpReview', () => {
}, },
}; };
it('regular self hosted license in the true up window sees content', () => {
it('regular self hosted license (NOT air-gapped) in the true up window sees content', () => {
jest.spyOn(useCWSAvailabilityCheckAll, 'default').mockImplementation(() => useCWSAvailabilityCheckAll.CSWAvailabilityCheckTypes.Available); jest.spyOn(useCWSAvailabilityCheckAll, 'default').mockImplementation(() => useCWSAvailabilityCheckAll.CSWAvailabilityCheckTypes.Available);
renderWithContext(<TrueUpReview/>, showsTrueUpReviewState); renderWithContext(<TrueUpReview/>, showsTrueUpReviewState);
screen.getByText('Share to Mattermost'); screen.getByText('Share to Mattermost');
}); });
it('regular self hosted license thats air gapped sees download button only', () => {
jest.spyOn(useCWSAvailabilityCheckAll, 'default').mockImplementation(() => useCWSAvailabilityCheckAll.CSWAvailabilityCheckTypes.Unavailable);
renderWithContext(<TrueUpReview/>, showsTrueUpReviewState);
screen.getByText('Download Data');
expect(screen.queryByText('Share to Mattermost')).not.toBeInTheDocument();
});
it('displays the panel regardless of the config value for EnableDiagnostic', () => {
const store = JSON.parse(JSON.stringify(showsTrueUpReviewState));
store.entities.general.config.EnableDiagnostics = 'false';
jest.spyOn(useCWSAvailabilityCheckAll, 'default').mockImplementation(() => useCWSAvailabilityCheckAll.CSWAvailabilityCheckTypes.Available);
renderWithContext(<TrueUpReview/>, store);
screen.getByText('Share to Mattermost');
});
it('gov sku self-hosted license does not see true up content', () => { it('gov sku self-hosted license does not see true up content', () => {
const store = JSON.parse(JSON.stringify(showsTrueUpReviewState)); const store = JSON.parse(JSON.stringify(showsTrueUpReviewState));
store.entities.general.license.IsGovSku = 'true'; store.entities.general.license.IsGovSku = 'true';

Просмотреть файл

@@ -10,7 +10,7 @@ import {useDispatch, useSelector} from 'react-redux';
import type {GlobalState} from '@mattermost/types/store'; import type {GlobalState} from '@mattermost/types/store';
import {isCurrentLicenseCloud} from 'mattermost-redux/selectors/entities/cloud'; import {isCurrentLicenseCloud} from 'mattermost-redux/selectors/entities/cloud';
import {getConfig, getLicense} from 'mattermost-redux/selectors/entities/general'; import {getLicense} from 'mattermost-redux/selectors/entities/general';
import { import {
getSelfHostedErrors, getSelfHostedErrors,
getTrueUpReviewProfile as trueUpReviewProfileSelector, getTrueUpReviewProfile as trueUpReviewProfileSelector,
@@ -50,7 +50,6 @@ const TrueUpReview: React.FC = () => {
// * are not on starter/free // * are not on starter/free
// * are not a government sku // * are not a government sku
const licenseIsTrueUpEligible = isLicensed && !isCloud && !isStarter && !isGovSku; const licenseIsTrueUpEligible = isLicensed && !isCloud && !isStarter && !isGovSku;
const telemetryEnabled = useSelector(getConfig).EnableDiagnostics === 'true';
const trueUpReviewError = useSelector((state: GlobalState) => { const trueUpReviewError = useSelector((state: GlobalState) => {
const errors = getSelfHostedErrors(state); const errors = getSelfHostedErrors(state);
return Boolean(errors.trueUpReview); return Boolean(errors.trueUpReview);
@@ -70,7 +69,7 @@ const TrueUpReview: React.FC = () => {
return; return;
} }
if (reviewProfile.getRequestState === 'OK' && isAirGapped && !trueUpReviewError && reviewProfile.content.length > 0) { if (reviewProfile.getRequestState === 'OK' && !reviewStatus.complete && isAirGapped && !trueUpReviewError && reviewProfile.content.length > 0) {
// Create the bundle as a blob containing base64 encoded json data and assign it to a link element. // Create the bundle as a blob containing base64 encoded json data and assign it to a link element.
const blob = new Blob([reviewProfile.content], {type: 'application/text'}); const blob = new Blob([reviewProfile.content], {type: 'application/text'});
const href = URL.createObjectURL(blob); const href = URL.createObjectURL(blob);
@@ -85,6 +84,7 @@ const TrueUpReview: React.FC = () => {
// Remove link and revoke object url to avoid memory leaks. // Remove link and revoke object url to avoid memory leaks.
document.body.removeChild(link); document.body.removeChild(link);
URL.revokeObjectURL(href); URL.revokeObjectURL(href);
dispatch(getTrueUpReviewStatus());
} }
}, [isAirGapped, reviewProfile, reviewProfile.getRequestState, trueUpReviewError]); }, [isAirGapped, reviewProfile, reviewProfile.getRequestState, trueUpReviewError]);
@@ -221,10 +221,6 @@ const TrueUpReview: React.FC = () => {
return null; return null;
} }
if (telemetryEnabled) {
return null;
}
pageVisited(TELEMETRY_CATEGORIES.TRUE_UP_REVIEW, 'pageview_true_up_review'); pageVisited(TELEMETRY_CATEGORIES.TRUE_UP_REVIEW, 'pageview_true_up_review');
return ( return (