mod-build 3.7.8 → 3.7.9-beta.2

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 CHANGED
@@ -1,5 +1,9 @@
1
1
  # Changelog
2
2
 
3
+ ## 3.7.9
4
+
5
+ - Updated `isBranded` sites to grab the display name from HS Form Service API to add to the `brandedConsentLanguage`.
6
+
3
7
  ## 3.7.8
4
8
 
5
9
  - removed race condition from grab-cdn task.
@@ -320,16 +320,64 @@ module.exports = function(gulp, gulpPlugins, siteSettings, siteData) {
320
320
  };
321
321
 
322
322
  var getConsentCaptureLanguage = async function() {
323
- await new Promise(function(resolve) {
324
- request(`https://${siteSettings.nodeEnv}/quote/resources/mod-site/consent-capture/tcpa.json`, async function(_err, xhr, response) {
325
- if (xhr.statusCode !== 200) {
326
- throw new Error(`${xhr.statusCode}: Error while fetching Consent Capture Language`);
327
- }
328
- const consentCapture = await JSON.parse(response);
329
- Object.assign(templatesData, consentCapture);
330
- resolve();
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 tcpaContent = `https://${siteSettings.nodeEnv}/quote/resources/mod-site/consent-capture/tcpa.json`;
337
+ const { xhr: tcpaXhr, response: tcpaResponse } = await requestPromise(tcpaContent);
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
+ consentCaptureObject.consentCapturePrivacyAndTerms = consentCaptureObject.consentCapturePrivacyAndTerms.replace(/\/resources/g, `${pathSubdirectory ? pathSubdirectory : '/'}resources`);
348
+
349
+ const brandedSiteIdentifiers = `https://${siteSettings.nodeEnv}/quote/resources/mod-site/data/branded-site-identifiers.json`;
350
+ const { xhr: brandedXhr, response: brandedResponse } = await requestPromise(brandedSiteIdentifiers);
351
+
352
+ if (brandedXhr.statusCode !== 200) {
353
+ throw new Error(`${brandedXhr.statusCode}: Error while fetching branded-site-identifiers.json`);
354
+ }
355
+
356
+ const brandedResponseJson = JSON.parse(brandedResponse);
357
+
358
+ if (templatesData.isBranded) {
359
+ const websiteName = templatesData.website_name;
360
+ if (brandedResponseJson[websiteName] && brandedResponseJson[websiteName].vendorPublicIdentifier) {
361
+ const vendorPublicIdentifier = brandedResponseJson[websiteName].vendorPublicIdentifier,
362
+ apiDomain = 'https://form-service-hs.qnst.com/',
363
+ apiUrl = `${apiDomain}utils/vendor-display-name?vendorKeys=${vendorPublicIdentifier}`;
364
+
365
+ const { xhr: displayNameXhr, response: displayNameResponse } = await requestPromise(apiUrl);
366
+
367
+ if (displayNameXhr.statusCode !== 200) {
368
+ throw new Error(`${displayNameXhr.statusCode}: Error while getting branded display name from HS Form Service`);
369
+ }
370
+
371
+ const displayNameResponseJson = JSON.parse(displayNameResponse);
372
+ brandedDisplayName = displayNameResponseJson.data[vendorPublicIdentifier];
373
+ consentCaptureObject.brandedConsentCapture.tcpaStart = responseJson.brandedConsentCapture.tcpaStart.replace(/<span data-branded-consent><\/span>/g, `<span data-branded-consent>${brandedDisplayName}</span>`);
374
+ }
375
+ }
376
+
377
+ Object.assign(templatesData, consentCaptureObject);
378
+ } catch (error) {
379
+ console.error('Error fetching data:', error);
380
+ }
333
381
  };
334
382
 
335
383
  return async function() {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "mod-build",
3
- "version": "3.7.8",
3
+ "version": "3.7.9-beta.2",
4
4
  "description": "Share components for S3 sites.",
5
5
  "scripts": {
6
6
  "test": "echo \"Error: no test specified\" && exit 1",