fix: [REV-2608] don't stop page processing on invalid cookie data (#29904)
This commit is contained in:
@@ -28,7 +28,18 @@ export class Currency { // eslint-disable-line import/prefer-default-export
|
||||
}
|
||||
|
||||
getCountry() {
|
||||
this.countryL10nData = JSON.parse($.cookie('edx-price-l10n'));
|
||||
try {
|
||||
this.countryL10nData = JSON.parse($.cookie('edx-price-l10n'));
|
||||
} catch (e) {
|
||||
if (e instanceof SyntaxError) {
|
||||
// If cookie isn't proper JSON, log but continue. This will show the purchase experience
|
||||
// in a non-local currency but will not prevent the user from interacting with the page.
|
||||
console.error(e);
|
||||
console.error("Ignoring malformed 'edx-price-l10n' cookie.");
|
||||
} else {
|
||||
throw e;
|
||||
}
|
||||
}
|
||||
if (this.countryL10nData) {
|
||||
window.analytics.track('edx.bi.user.track_selection.local_currency_cookie_set');
|
||||
this.setPrice();
|
||||
|
||||
Reference in New Issue
Block a user