debian-mirror-gitlab/app/assets/javascripts/surveys/merge_request_experience/index.js
2022-08-13 15:12:31 +05:30

23 lines
740 B
JavaScript

import { Tracker } from '~/tracking/tracker';
const MR_SURVEY_WAIT_DURATION = 10000;
const broadcastNotificationVisible = () => {
// We don't want to clutter up the UI by displaying the survey when broadcast message(s)
// are visible as well.
return Boolean(document.querySelector('.broadcast-notification-message'));
};
export const initMrExperienceSurvey = () => {
if (!gon.features?.mrExperienceSurvey) return;
if (!gon.current_user_id) return;
if (!Tracker.enabled()) return;
if (broadcastNotificationVisible()) return;
setTimeout(() => {
// eslint-disable-next-line promise/catch-or-return
import('./app').then(({ startMrSurveyApp }) => {
startMrSurveyApp();
});
}, MR_SURVEY_WAIT_DURATION);
};