Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update/deactivation survey event #15

Merged
merged 5 commits into from
Jun 18, 2024
Merged
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 10 additions & 12 deletions static/js/deactivation-survey.js
Original file line number Diff line number Diff line change
Expand Up @@ -183,20 +183,19 @@

const submitSurvey = async ( skipped = false ) => {
isSubmitting();
let surveyInput = skipped ? '(Skipped)' : '(No Input)';

let surveyInput = 'No input';
if ( ! skipped ) {
const inputValue = document.getElementById(
'nfd-deactivation-survey__input'
).value;
if ( inputValue.length > 0 ) {
surveyInput = inputValue;
}
const input = document.getElementById(
'nfd-deactivation-survey__input'
).value;
if ( input.length > 0 ) {
surveyInput = input;
}

// Send event
const send = await sendEvent( surveyInput );
deactivatePlugin();
return await sendEvent( surveyInput ).then( () => {
deactivatePlugin();
} );
};

const sendEvent = async ( surveyInput ) => {
Expand All @@ -213,7 +212,7 @@
eventData.abTestPluginHome = getABTestPluginHome();
}

await fetch( runtimeData.eventsEndpoint, {
return await fetch( runtimeData.eventsEndpoint, {
method: 'POST',
headers: {
'Content-Type': 'application/json',
Expand All @@ -224,7 +223,6 @@
data: eventData,
} ),
} );
return true;
};

const getABTestPluginHome = () => {
Expand Down
Loading