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

Fix Medallia loading error #2173

Draft
wants to merge 4 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all 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
46 changes: 33 additions & 13 deletions src/site/assets/js/medallia/vagovstaging.js
Original file line number Diff line number Diff line change
@@ -1,18 +1,38 @@
// (function () {
// if (window.KAMPYLE_ONSITE_SDK) {
// onsiteLoaded();
// } else {
// window.addEventListener('neb_OnsiteLoaded', onsiteLoaded);
// }
// })()

// function onsiteLoaded() {
// const surveyNumber = getSurvey(window.dataLayer[1].environment, window.location.pathname);
// var neb_status = KAMPYLE_ONSITE_SDK.loadForm(surveyNumber);
// if (neb_status === true) {
// console.log(`survey number ${surveyNumber} has loaded`)
// }
// }
(function () {
if (window.KAMPYLE_ONSITE_SDK) {
onsiteLoaded();
} else {
window.addEventListener('neb_OnsiteLoaded', onsiteLoaded);
}
})()
const handleOnsiteLoaded = () => {
const surveyNumber = getSurvey(window.dataLayer[1].environment, window.location.pathname);
const nebStatus = KAMPYLE_ONSITE_SDK.loadForm(surveyNumber);
if (nebStatus) {
console.log(`Survey number ${surveyNumber} has loaded`);
}
};

function onsiteLoaded() {
const surveyNumber = getSurvey(window.dataLayer[1].environment, window.location.pathname);
var neb_status = KAMPYLE_ONSITE_SDK.loadForm(surveyNumber);
if (neb_status === true) {
console.log(`survey number ${surveyNumber} has loaded`)
}
}
const init = () => {
if (window.KAMPYLE_ONSITE_SDK) {
handleOnsiteLoaded();
} else {
window.addEventListener('neb_OnsiteLoaded', handleOnsiteLoaded);
console.warn('KAMPYLE_ONSITE_SDK not available at initialization.');
}
};

document.addEventListener('DOMContentLoaded', init);
})();

const SURVEY_NUMBERS = {
DEFAULT_STAGING_SURVEY: 11,
Expand Down
8 changes: 4 additions & 4 deletions src/site/includes/survey-tools.html
Original file line number Diff line number Diff line change
Expand Up @@ -28,12 +28,12 @@
window.vaSurvey = 'mcenter';
</script>
{% endif %}
<script defer type="text/javascript" nonce="**CSP_NONCE**"
src="https://resource.digital.voice.va.gov/wdcvoice/5/onsite/embed.js" async>
</script>

<script type="text/javascript" nonce="**CSP_NONCE**">
<script defer type="text/javascript" nonce="**CSP_NONCE**">
{% include "src/site/assets/js/medallia/vagovstaging.js" %}
</script>

<script defer type="text/javascript" nonce="**CSP_NONCE**"
src="https://resource.digital.voice.va.gov/wdcvoice/5/onsite/embed.js" async>
</script>
{% endif %}
Loading