mod-build 3.7.8 → 3.7.9-beta.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +4 -0
- package/gulp-tasks/templates.js +55 -9
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
package/gulp-tasks/templates.js
CHANGED
|
@@ -320,16 +320,62 @@ module.exports = function(gulp, gulpPlugins, siteSettings, siteData) {
|
|
|
320
320
|
};
|
|
321
321
|
|
|
322
322
|
var getConsentCaptureLanguage = async function() {
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
323
|
+
const requestPromise = (url) => {
|
|
324
|
+
return new Promise((resolve, reject) => {
|
|
325
|
+
request(url, (error, xhr, response) => {
|
|
326
|
+
if (error) {
|
|
327
|
+
reject(error);
|
|
328
|
+
} else {
|
|
329
|
+
resolve({ xhr, response });
|
|
330
|
+
}
|
|
331
|
+
});
|
|
331
332
|
});
|
|
332
|
-
}
|
|
333
|
+
};
|
|
334
|
+
|
|
335
|
+
try {
|
|
336
|
+
const tcpaJson = `https://${siteSettings.nodeEnv}/quote/resources/mod-site/consent-capture/tcpa.json`;
|
|
337
|
+
const { xhr: tcpaXhr, response: tcpaResponse } = await requestPromise(tcpaJson);
|
|
338
|
+
|
|
339
|
+
if (tcpaXhr.statusCode !== 200) {
|
|
340
|
+
throw new Error(`${tcpaXhr.statusCode}: Error while fetching tcpa.json`);
|
|
341
|
+
}
|
|
342
|
+
|
|
343
|
+
let brandedDisplayName = '';
|
|
344
|
+
const responseJson = JSON.parse(tcpaResponse),
|
|
345
|
+
consentCaptureObject = responseJson;
|
|
346
|
+
|
|
347
|
+
const brandedSiteIdentifiers = `https://${siteSettings.nodeEnv}/quote/resources/mod-site/data/branded-site-identifiers.json`;
|
|
348
|
+
const { xhr: brandedXhr, response: brandedResponse } = await requestPromise(brandedSiteIdentifiers);
|
|
349
|
+
|
|
350
|
+
if (brandedXhr.statusCode !== 200) {
|
|
351
|
+
throw new Error(`${brandedXhr.statusCode}: Error while fetching branded-site-identifiers.json`);
|
|
352
|
+
}
|
|
353
|
+
|
|
354
|
+
const brandedResponseJson = JSON.parse(brandedResponse);
|
|
355
|
+
|
|
356
|
+
if (templatesData.isBranded) {
|
|
357
|
+
const websiteName = templatesData.website_name;
|
|
358
|
+
if (brandedResponseJson[websiteName] && brandedResponseJson[websiteName].vendorPublicIdentifier) {
|
|
359
|
+
const vendorPublicIdentifier = brandedResponseJson[websiteName].vendorPublicIdentifier,
|
|
360
|
+
apiDomain = 'https://form-service-hs.qnst.com/',
|
|
361
|
+
apiUrl = `${apiDomain}utils/vendor-display-name?vendorKeys=${vendorPublicIdentifier}`;
|
|
362
|
+
|
|
363
|
+
const { xhr: displayNameXhr, response: displayNameResponse } = await requestPromise(apiUrl);
|
|
364
|
+
|
|
365
|
+
if (displayNameXhr.statusCode !== 200) {
|
|
366
|
+
throw new Error(`${displayNameXhr.statusCode}: Error while getting branded display name from HS Form Service`);
|
|
367
|
+
}
|
|
368
|
+
|
|
369
|
+
const displayNameResponseJson = JSON.parse(displayNameResponse);
|
|
370
|
+
brandedDisplayName = displayNameResponseJson.data[vendorPublicIdentifier];
|
|
371
|
+
consentCaptureObject.brandedConsentCapture.tcpaStart = responseJson.brandedConsentCapture.tcpaStart.replace(/<span data-branded-consent><\/span>/g, `<span data-branded-consent>${brandedDisplayName}</span>`);
|
|
372
|
+
}
|
|
373
|
+
}
|
|
374
|
+
|
|
375
|
+
Object.assign(templatesData, consentCaptureObject);
|
|
376
|
+
} catch (error) {
|
|
377
|
+
console.error('Error fetching data:', error);
|
|
378
|
+
}
|
|
333
379
|
};
|
|
334
380
|
|
|
335
381
|
return async function() {
|