mirror of
https://github.com/strapi/strapi.git
synced 2025-11-02 02:44:55 +00:00
feat(admin): allows users to disable NPS in strapi config. (#18287)
This commit is contained in:
parent
017f329378
commit
f9f70e25b5
@ -14,4 +14,7 @@ module.exports = ({ env }) => ({
|
||||
salt: env('TRANSFER_TOKEN_SALT', 'example-salt'),
|
||||
},
|
||||
},
|
||||
flags: {
|
||||
nps: env.bool('FLAG_NPS', true),
|
||||
},
|
||||
});
|
||||
|
||||
@ -10,4 +10,7 @@ export default ({ env }) => ({
|
||||
salt: env('TRANSFER_TOKEN_SALT', 'example-salt'),
|
||||
},
|
||||
},
|
||||
flags: {
|
||||
nps: env.bool('FLAG_NPS', true),
|
||||
},
|
||||
});
|
||||
|
||||
@ -11,4 +11,7 @@ module.exports = ({ env }) => ({
|
||||
salt: env('TRANSFER_TOKEN_SALT', 'example-salt'),
|
||||
},
|
||||
},
|
||||
flags: {
|
||||
nps: env.bool('FLAG_NPS', true),
|
||||
},
|
||||
});
|
||||
|
||||
5
packages/admin-test-utils/custom.d.ts
vendored
5
packages/admin-test-utils/custom.d.ts
vendored
@ -1,4 +1,4 @@
|
||||
export {};
|
||||
export { };
|
||||
|
||||
declare global {
|
||||
interface Window {
|
||||
@ -11,6 +11,9 @@ declare global {
|
||||
};
|
||||
projectType: string;
|
||||
telemetryDisabled: boolean;
|
||||
flags: {
|
||||
nps: boolean
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
@ -65,6 +65,9 @@ window.strapi = {
|
||||
},
|
||||
projectType: 'Community',
|
||||
telemetryDisabled: true,
|
||||
flags: {
|
||||
nps: true
|
||||
}
|
||||
};
|
||||
|
||||
/* -------------------------------------------------------------------------------------------------
|
||||
|
||||
@ -71,17 +71,23 @@ const checkIfShouldShowSurvey = (settings) => {
|
||||
const { enabled, lastResponseDate, firstDismissalDate, lastDismissalDate } = settings;
|
||||
|
||||
// This function goes through all the cases where we'd want to not show the survey:
|
||||
// 1. If the survey is disabled, abort mission, don't bother checking the other settings.
|
||||
// 2. If the user has already responded to the survey, check if enough time has passed since the last response.
|
||||
// 3. If the user has dismissed the survey twice or more before, check if enough time has passed since the last dismissal.
|
||||
// 4. If the user has only dismissed the survey once before, check if enough time has passed since the first dismissal.
|
||||
// 1. If the survey is disabled by strapi, abort mission, don't bother checking the other settings.
|
||||
// 2. If the survey is disabled by user, abort mission, don't bother checking the other settings.
|
||||
// 3. If the user has already responded to the survey, check if enough time has passed since the last response.
|
||||
// 4. If the user has dismissed the survey twice or more before, check if enough time has passed since the last dismissal.
|
||||
// 5. If the user has only dismissed the survey once before, check if enough time has passed since the first dismissal.
|
||||
// If none of these cases check out, then we show the survey.
|
||||
// Note that submitting a response resets the dismissal counts.
|
||||
// Checks 3 and 4 should not be reversed, since the first dismissal will also exist if the user has dismissed the survey twice or more before.
|
||||
// Checks 4 and 5 should not be reversed, since the first dismissal will also exist if the user has dismissed the survey twice or more before.
|
||||
|
||||
// For users who had created an account before the NPS feature was introduced,
|
||||
// we assume that they would have enabled the NPS feature if they had the chance.
|
||||
|
||||
// Global strapi disable for NSP.
|
||||
if (window.strapi.flags.nps === false) {
|
||||
return false
|
||||
}
|
||||
|
||||
// User chose not to enable the NPS feature when signing up
|
||||
if (enabled === false) {
|
||||
return false;
|
||||
|
||||
@ -23,6 +23,9 @@ window.strapi = {
|
||||
REVIEW_WORKFLOWS: 'review-workflows',
|
||||
},
|
||||
projectType: 'Community',
|
||||
flags: {
|
||||
nps: false
|
||||
},
|
||||
};
|
||||
|
||||
const customConfig = appCustomisations;
|
||||
@ -41,16 +44,16 @@ const run = async () => {
|
||||
try {
|
||||
const {
|
||||
data: {
|
||||
data: { isEE, features },
|
||||
data: { isEE, features, flags },
|
||||
},
|
||||
} = await get('/admin/project-type');
|
||||
|
||||
window.strapi.isEE = isEE;
|
||||
window.strapi.flags = flags;
|
||||
window.strapi.features = {
|
||||
...window.strapi.features,
|
||||
isEnabled: (featureName) => features.some((feature) => feature.name === featureName),
|
||||
};
|
||||
|
||||
window.strapi.projectType = isEE ? 'Enterprise' : 'Community';
|
||||
} catch (err) {
|
||||
console.error(err);
|
||||
|
||||
@ -26,11 +26,12 @@ module.exports = {
|
||||
// When removing this we need to update the /admin/src/index.js file
|
||||
// where we set the strapi.window.isEE value
|
||||
async getProjectType() {
|
||||
const flags = strapi.config.get('admin.flags', {});
|
||||
// FIXME
|
||||
try {
|
||||
return { data: { isEE: strapi.EE, features: ee.features.list() } };
|
||||
return { data: { isEE: strapi.EE, features: ee.features.list(), flags } };
|
||||
} catch (err) {
|
||||
return { data: { isEE: false, features: [] } };
|
||||
return { data: { isEE: false, features: [], flags } };
|
||||
}
|
||||
},
|
||||
|
||||
|
||||
@ -10,4 +10,7 @@ module.exports = ({ env }) => ({
|
||||
salt: env('TRANSFER_TOKEN_SALT'),
|
||||
},
|
||||
},
|
||||
flags: {
|
||||
nps: env.bool('FLAG_NPS', true),
|
||||
},
|
||||
});
|
||||
|
||||
@ -10,4 +10,7 @@ export default ({ env }) => ({
|
||||
salt: env('TRANSFER_TOKEN_SALT'),
|
||||
},
|
||||
},
|
||||
flags: {
|
||||
nps: env.bool('FLAG_NPS', true),
|
||||
},
|
||||
});
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user