mirror of
https://github.com/mattermost/mattermost.git
synced 2025-02-25 18:55:24 -06:00
[CLD-6430] Remove telemetry check from true_up_review (#26073)
* Remove telemetry check from true_up_review * Fix bug * Fix linter * fix tests
This commit is contained in:
parent
521844fed5
commit
01e1eebc07
@ -351,10 +351,8 @@ func requestTrueUpReview(c *Context, w http.ResponseWriter, r *http.Request) {
|
||||
return
|
||||
}
|
||||
|
||||
// True-up is only enabled when telemetry is disabled.
|
||||
// When telemetry is enabled, we already have all the data necessary for true-up reviews to be completed.
|
||||
telemetryEnabled := c.App.Config().LogSettings.EnableDiagnostics
|
||||
if telemetryEnabled != nil && !*telemetryEnabled {
|
||||
// Only report the true up review to CWS if the connection is available.
|
||||
if err := c.App.Cloud().CheckCWSConnection(c.AppContext.Session().UserId); err == nil {
|
||||
err = c.App.Cloud().SubmitTrueUpReview(c.AppContext.Session().UserId, profileMap)
|
||||
if err != nil {
|
||||
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.Mock.On("SubmitTrueUpReview", mock.Anything, mock.Anything).Return(nil)
|
||||
cloud.Mock.On("CheckCWSConnection", mock.Anything).Return(nil)
|
||||
|
||||
cloudImpl := th.App.Srv().Cloud
|
||||
defer func() {
|
||||
|
@ -25,7 +25,7 @@ describe('TrueUpReview', () => {
|
||||
IsLicensed: 'true',
|
||||
}),
|
||||
config: {
|
||||
EnableDiagnostics: 'false',
|
||||
EnableDiagnostics: 'true',
|
||||
},
|
||||
},
|
||||
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);
|
||||
|
||||
renderWithContext(<TrueUpReview/>, showsTrueUpReviewState);
|
||||
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', () => {
|
||||
const store = JSON.parse(JSON.stringify(showsTrueUpReviewState));
|
||||
store.entities.general.license.IsGovSku = 'true';
|
||||
|
@ -10,7 +10,7 @@ import {useDispatch, useSelector} from 'react-redux';
|
||||
import type {GlobalState} from '@mattermost/types/store';
|
||||
|
||||
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 {
|
||||
getSelfHostedErrors,
|
||||
getTrueUpReviewProfile as trueUpReviewProfileSelector,
|
||||
@ -50,7 +50,6 @@ const TrueUpReview: React.FC = () => {
|
||||
// * are not on starter/free
|
||||
// * are not a government sku
|
||||
const licenseIsTrueUpEligible = isLicensed && !isCloud && !isStarter && !isGovSku;
|
||||
const telemetryEnabled = useSelector(getConfig).EnableDiagnostics === 'true';
|
||||
const trueUpReviewError = useSelector((state: GlobalState) => {
|
||||
const errors = getSelfHostedErrors(state);
|
||||
return Boolean(errors.trueUpReview);
|
||||
@ -70,7 +69,7 @@ const TrueUpReview: React.FC = () => {
|
||||
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.
|
||||
const blob = new Blob([reviewProfile.content], {type: 'application/text'});
|
||||
const href = URL.createObjectURL(blob);
|
||||
@ -85,6 +84,7 @@ const TrueUpReview: React.FC = () => {
|
||||
// Remove link and revoke object url to avoid memory leaks.
|
||||
document.body.removeChild(link);
|
||||
URL.revokeObjectURL(href);
|
||||
dispatch(getTrueUpReviewStatus());
|
||||
}
|
||||
}, [isAirGapped, reviewProfile, reviewProfile.getRequestState, trueUpReviewError]);
|
||||
|
||||
@ -221,10 +221,6 @@ const TrueUpReview: React.FC = () => {
|
||||
return null;
|
||||
}
|
||||
|
||||
if (telemetryEnabled) {
|
||||
return null;
|
||||
}
|
||||
|
||||
pageVisited(TELEMETRY_CATEGORIES.TRUE_UP_REVIEW, 'pageview_true_up_review');
|
||||
|
||||
return (
|
||||
|
Loading…
Reference in New Issue
Block a user