init: async()

in src/js/popup/popup.js [1017:1057]


        init: async () => {
          const survey = popup.panel.survey;
          const surveyButtons = survey.select.surveyButtons();
          const { premium } = await browser.storage.local.get("premium");
          const tier = premium ? "premium" : "free";

          // loop through all satisfaction buttons
          surveyButtons.forEach(async (button) => {
            // check if button is disabled
            if (button.hasAttribute("disabled")) {
              // do nothing and exit early
              return;
            }

            // button is not disabled, add event listener
            button.addEventListener("click", async (e) => {
              e.preventDefault();

              const satisfaction = ["very dissatisfied", "dissatisfied", "neutral", "satisfied", "very satisfied"];
              const satisfactionLevel = e.target.dataset.satisfaction;

               // reset all buttons
               survey.utils.resetSurveyButtons();

              // user has chosen a satisfaction level
              // mark button as selected
              e.target.classList.add("is-selected");

              sendRelayEvent("CSAT Survey", "submitted", satisfaction[satisfactionLevel]); 
              
              // show success message
              survey.utils.showSurveySuccessMessage();

              // set correct survey link based on tier and satisfaction level
              survey.utils.setExternalSurveyLink(tier, satisfactionLevel);

              // show external survey link
              survey.utils.showSurveyExternalLink();
            });
          });
        },