mod-build 4.0.59-beta.9 → 4.0.60-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
CHANGED
|
@@ -1,12 +1,16 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## 4.0.60
|
|
4
|
+
|
|
5
|
+
- Applying merging of default trade questions and default form config on all the `steps` objects found.
|
|
6
|
+
|
|
3
7
|
## 4.0.59
|
|
4
8
|
|
|
5
|
-
-
|
|
9
|
+
- Added jacuzzi in the sites that should have tcpa below the cta.
|
|
6
10
|
|
|
7
11
|
## 4.0.58
|
|
8
12
|
|
|
9
|
-
- Upgraded to new
|
|
13
|
+
- Upgraded to new VWO smart code.
|
|
10
14
|
|
|
11
15
|
## 4.0.57
|
|
12
16
|
|
package/package.json
CHANGED
package/src/scripts/utils.js
CHANGED
|
@@ -45,6 +45,7 @@ function handlebarsX(expression, context) {
|
|
|
45
45
|
}
|
|
46
46
|
|
|
47
47
|
const tradesWithTcpaAboveCta = ['HOME_SECURITY'];
|
|
48
|
+
const sitesWithTcpaBelowCta = ['go.jacuzzi.com'];
|
|
48
49
|
|
|
49
50
|
export const handlebarsHelpers = [
|
|
50
51
|
// Run any js line
|
|
@@ -192,7 +193,8 @@ export const handlebarsHelpers = [
|
|
|
192
193
|
return false;
|
|
193
194
|
}
|
|
194
195
|
const trade = page.primary_trade.replace(/\s+/g, '_').toUpperCase();
|
|
195
|
-
|
|
196
|
+
const site = page.website_name?.toLowerCase();
|
|
197
|
+
return (tradesWithTcpaAboveCta.includes(trade) || page.isBranded) && !sitesWithTcpaBelowCta.includes(site);
|
|
196
198
|
}
|
|
197
199
|
},
|
|
198
200
|
{
|
|
@@ -202,7 +204,8 @@ export const handlebarsHelpers = [
|
|
|
202
204
|
return false;
|
|
203
205
|
}
|
|
204
206
|
const trade = page.primary_trade.replace(/\s+/g, '_').toUpperCase();
|
|
205
|
-
|
|
207
|
+
const site = page.website_name?.toLowerCase();
|
|
208
|
+
return (!tradesWithTcpaAboveCta.includes(trade) && !page.isBranded) || sitesWithTcpaBelowCta.includes(site);
|
|
206
209
|
}
|
|
207
210
|
}
|
|
208
211
|
]
|
|
@@ -2,8 +2,7 @@
|
|
|
2
2
|
window.VWO = window.VWO || [];
|
|
3
3
|
window.VWO.push(['onEventReceive', 'vA', function (data) {
|
|
4
4
|
var experimentId = data[1];
|
|
5
|
-
var variationId =
|
|
6
|
-
// add sentry log if variationId is NaN?
|
|
5
|
+
var variationId = data[2];
|
|
7
6
|
var variationName = _vwo_exp[experimentId].comb_n[variationId];
|
|
8
7
|
if (typeof(_vwo_exp[experimentId].comb_n[variationId]) !== 'undefined' && ['VISUAL_AB', 'VISUAL', 'SPLIT_URL','SURVEY'].indexOf(_vwo_exp[experimentId].type) > -1) {
|
|
9
8
|
window._vwo_campaignData = {
|
|
@@ -11,12 +10,6 @@
|
|
|
11
10
|
n: variationName
|
|
12
11
|
}
|
|
13
12
|
}
|
|
14
|
-
if (variationId !== 1 && window.addVwoTestAttribute) {
|
|
15
|
-
// Control is assigned variation ID 1 - variations receive incremented IDs starting from 2
|
|
16
|
-
const actualVariationId = variationId - 1;
|
|
17
|
-
const vwoTestAttrValue = `${experimentId}-${actualVariationId}`;
|
|
18
|
-
document.body.setAttribute('data-vwo-test', vwoTestAttrValue);
|
|
19
|
-
}
|
|
20
13
|
}
|
|
21
14
|
}]);
|
|
22
15
|
|
|
@@ -3,6 +3,173 @@ import merge from 'lodash.merge';
|
|
|
3
3
|
import axios from 'axios';
|
|
4
4
|
import { defaultSettings } from '../src/data/config.js';
|
|
5
5
|
|
|
6
|
+
function applyDefaultTradeConfigOnSteps(config, steps) {
|
|
7
|
+
if (!config || typeof config !== 'object') return;
|
|
8
|
+
|
|
9
|
+
if (data.steps && typeof data.steps === 'object' && data.steps.items) {
|
|
10
|
+
mergeDefaultTradeQuestions(config, steps);
|
|
11
|
+
}
|
|
12
|
+
// Recursively go through all object properties
|
|
13
|
+
for (const key in data) {
|
|
14
|
+
if (data.hasOwnProperty(key)) {
|
|
15
|
+
const value = data[key];
|
|
16
|
+
if (typeof value === 'object' && value !== null) {
|
|
17
|
+
applyDefaultTradeConfigOnSteps(value, steps);
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
function mergeDefaultTradeQuestions(config, steps) {
|
|
24
|
+
if (!config || !config.steps || !config.steps.items || !Array.isArray(config.steps.items)) {
|
|
25
|
+
return;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
config.steps.items.forEach((item) => {
|
|
29
|
+
const stepName = item.attributes.data['step-name'];
|
|
30
|
+
if (steps[stepName]) {
|
|
31
|
+
if (!item.stepContent) {
|
|
32
|
+
item.stepContent = {};
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
if (!item.stepContent.fields) {
|
|
36
|
+
item.stepContent.fields = [];
|
|
37
|
+
}
|
|
38
|
+
const defaultStepFields = steps[stepName].fields;
|
|
39
|
+
let defaultStepOptions = [];
|
|
40
|
+
let defaultQuestionLegend = {};
|
|
41
|
+
defaultStepFields.forEach((defaultField) => {
|
|
42
|
+
defaultStepOptions = defaultField.options;
|
|
43
|
+
defaultQuestionLegend = defaultField.legend;
|
|
44
|
+
});
|
|
45
|
+
|
|
46
|
+
item.stepContent.fields.forEach((field) => {
|
|
47
|
+
if (field.legend) {
|
|
48
|
+
field.legend = merge(defaultQuestionLegend, field.legend);
|
|
49
|
+
} else {
|
|
50
|
+
field.legend = defaultQuestionLegend;
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
if (field && field.remove) {
|
|
54
|
+
if (field.remove.includes('all')) {
|
|
55
|
+
defaultStepOptions = [];
|
|
56
|
+
} else {
|
|
57
|
+
defaultStepOptions = defaultStepOptions.filter((_, i) => !field.remove.includes(i));
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
if (field.fieldType === 'radio') {
|
|
62
|
+
if (!field.errorMessage) {
|
|
63
|
+
field.errorMessage = 'Professionals need this info to generate a quote.';
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
if (field.options && Array.isArray(field.options) && field.options.length) {
|
|
67
|
+
field.options.forEach((option) => {
|
|
68
|
+
if (typeof option.update === 'number') {
|
|
69
|
+
if (option.attributes && option.attributes.checked === false) {
|
|
70
|
+
delete option.attributes.checked;
|
|
71
|
+
delete defaultStepOptions[option.update].attributes.checked;
|
|
72
|
+
}
|
|
73
|
+
merge(defaultStepOptions[option.update], option);
|
|
74
|
+
} else {
|
|
75
|
+
if (typeof option.insertAt === 'number') {
|
|
76
|
+
defaultStepOptions.splice(option.insertAt, 0, option);
|
|
77
|
+
} else {
|
|
78
|
+
defaultStepOptions.push(option);
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
});
|
|
82
|
+
}
|
|
83
|
+
field.options = defaultStepOptions;
|
|
84
|
+
} else {
|
|
85
|
+
if (field && Array.isArray(field) && field.length) {
|
|
86
|
+
if (typeof field.update === 'number') {
|
|
87
|
+
merge(defaultStepFields[field.update], field);
|
|
88
|
+
} else {
|
|
89
|
+
if (typeof field.insertAt === 'number') {
|
|
90
|
+
defaultStepFields.splice(field.insertAt, 0, field);
|
|
91
|
+
} else {
|
|
92
|
+
defaultStepFields.push(field);
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
field = defaultStepFields;
|
|
98
|
+
}
|
|
99
|
+
});
|
|
100
|
+
|
|
101
|
+
// extra question block
|
|
102
|
+
if (item.stepContent.extraQuestionBlock) {
|
|
103
|
+
if (!item.stepContent.extraQuestionBlock.fields) {
|
|
104
|
+
item.stepContent.extraQuestionBlock.fields = [];
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
const defaultExtraQuestionFields = steps[stepName].extraQuestionBlock.fields;
|
|
108
|
+
let defaultExtraQuestionOptions = [];
|
|
109
|
+
let defaultExtraQuestionLegend = {};
|
|
110
|
+
defaultExtraQuestionFields.forEach((defaultExtraQuestionField) => {
|
|
111
|
+
defaultExtraQuestionOptions = defaultExtraQuestionField.options;
|
|
112
|
+
defaultExtraQuestionLegend = defaultExtraQuestionField.legend;
|
|
113
|
+
});
|
|
114
|
+
item.stepContent.extraQuestionBlock.fields.forEach((field) => {
|
|
115
|
+
|
|
116
|
+
if (field.legend) {
|
|
117
|
+
field.legend = merge(defaultExtraQuestionLegend, field.legend);
|
|
118
|
+
} else {
|
|
119
|
+
field.legend = defaultExtraQuestionLegend;
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
if (field && field.remove) {
|
|
123
|
+
if (field.remove.includes('all')) {
|
|
124
|
+
defaultExtraQuestionOptions = [];
|
|
125
|
+
} else {
|
|
126
|
+
defaultExtraQuestionOptions = defaultExtraQuestionOptions.filter((_, i) => !field.remove.includes(i));
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
if (field.fieldType === 'radio') {
|
|
131
|
+
if (!field.errorMessage) {
|
|
132
|
+
field.errorMessage = 'Professionals need this info to generate a quote.';
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
if (field.options && Array.isArray(field.options) && field.options.length) {
|
|
136
|
+
field.options.forEach((option, optionIndex) => {
|
|
137
|
+
if (typeof option.update === 'number') {
|
|
138
|
+
if (option.attributes && option.attributes.checked === false) {
|
|
139
|
+
delete option.attributes.checked;
|
|
140
|
+
delete defaultStepOptions[option.update].attributes.checked;
|
|
141
|
+
}
|
|
142
|
+
merge(defaultExtraQuestionOptions[option.update], option);
|
|
143
|
+
} else {
|
|
144
|
+
if (typeof option.insertAt === 'number') {
|
|
145
|
+
defaultExtraQuestionOptions.splice(option.insertAt, 0, option);
|
|
146
|
+
} else {
|
|
147
|
+
defaultExtraQuestionOptions.push(option);
|
|
148
|
+
}
|
|
149
|
+
}
|
|
150
|
+
});
|
|
151
|
+
}
|
|
152
|
+
field.options = defaultExtraQuestionOptions;
|
|
153
|
+
} else {
|
|
154
|
+
if (field && Array.isArray(field) && field.length) {
|
|
155
|
+
if (typeof field.update === 'number') {
|
|
156
|
+
merge(defaultExtraQuestionFields[field.update], field);
|
|
157
|
+
} else {
|
|
158
|
+
if (typeof field.insertAt === 'number') {
|
|
159
|
+
defaultExtraQuestionFields.splice(field.insertAt, 0, field);
|
|
160
|
+
} else {
|
|
161
|
+
defaultExtraQuestionFields.push(field);
|
|
162
|
+
}
|
|
163
|
+
}
|
|
164
|
+
}
|
|
165
|
+
field = defaultExtraQuestionFields;
|
|
166
|
+
}
|
|
167
|
+
});
|
|
168
|
+
}
|
|
169
|
+
}
|
|
170
|
+
});
|
|
171
|
+
}
|
|
172
|
+
|
|
6
173
|
export default async function(config) {
|
|
7
174
|
if (config.useStepsConfig) {
|
|
8
175
|
console.log('Starting get-default-trade-questions...');
|
|
@@ -35,149 +202,7 @@ export default async function(config) {
|
|
|
35
202
|
steps.OwnHome = commonQuestions.OwnHome;
|
|
36
203
|
steps.BuyTimeframe = commonQuestions.BuyTimeframe;
|
|
37
204
|
|
|
38
|
-
config
|
|
39
|
-
const stepName = item.attributes.data['step-name'];
|
|
40
|
-
if (steps[stepName]) {
|
|
41
|
-
if (!item.stepContent) {
|
|
42
|
-
item.stepContent = {};
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
if (!item.stepContent.fields) {
|
|
46
|
-
item.stepContent.fields = [];
|
|
47
|
-
}
|
|
48
|
-
const defaultStepFields = steps[stepName].fields;
|
|
49
|
-
let defaultStepOptions = [];
|
|
50
|
-
let defaultQuestionLegend = {};
|
|
51
|
-
defaultStepFields.forEach((defaultField) => {
|
|
52
|
-
defaultStepOptions = defaultField.options;
|
|
53
|
-
defaultQuestionLegend = defaultField.legend;
|
|
54
|
-
});
|
|
55
|
-
|
|
56
|
-
item.stepContent.fields.forEach((field) => {
|
|
57
|
-
if (field.legend) {
|
|
58
|
-
field.legend = merge(defaultQuestionLegend, field.legend);
|
|
59
|
-
} else {
|
|
60
|
-
field.legend = defaultQuestionLegend;
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
if (field && field.remove) {
|
|
64
|
-
if (field.remove.includes('all')) {
|
|
65
|
-
defaultStepOptions = [];
|
|
66
|
-
} else {
|
|
67
|
-
defaultStepOptions = defaultStepOptions.filter((_, i) => !field.remove.includes(i));
|
|
68
|
-
}
|
|
69
|
-
}
|
|
70
|
-
|
|
71
|
-
if (field.fieldType === 'radio') {
|
|
72
|
-
if (!field.errorMessage) {
|
|
73
|
-
field.errorMessage = 'Professionals need this info to generate a quote.';
|
|
74
|
-
}
|
|
75
|
-
|
|
76
|
-
if (field.options && Array.isArray(field.options) && field.options.length) {
|
|
77
|
-
field.options.forEach((option) => {
|
|
78
|
-
if (typeof option.update === 'number') {
|
|
79
|
-
if (option.attributes && option.attributes.checked === false) {
|
|
80
|
-
delete option.attributes.checked;
|
|
81
|
-
delete defaultStepOptions[option.update].attributes.checked;
|
|
82
|
-
}
|
|
83
|
-
merge(defaultStepOptions[option.update], option);
|
|
84
|
-
} else {
|
|
85
|
-
if (typeof option.insertAt === 'number') {
|
|
86
|
-
defaultStepOptions.splice(option.insertAt, 0, option);
|
|
87
|
-
} else {
|
|
88
|
-
defaultStepOptions.push(option);
|
|
89
|
-
}
|
|
90
|
-
}
|
|
91
|
-
});
|
|
92
|
-
}
|
|
93
|
-
field.options = defaultStepOptions;
|
|
94
|
-
} else {
|
|
95
|
-
if (field && Array.isArray(field) && field.length) {
|
|
96
|
-
if (typeof field.update === 'number') {
|
|
97
|
-
merge(defaultStepFields[field.update], field);
|
|
98
|
-
} else {
|
|
99
|
-
if (typeof field.insertAt === 'number') {
|
|
100
|
-
defaultStepFields.splice(field.insertAt, 0, field);
|
|
101
|
-
} else {
|
|
102
|
-
defaultStepFields.push(field);
|
|
103
|
-
}
|
|
104
|
-
}
|
|
105
|
-
}
|
|
106
|
-
|
|
107
|
-
field = defaultStepFields;
|
|
108
|
-
}
|
|
109
|
-
});
|
|
110
|
-
|
|
111
|
-
// extra question block
|
|
112
|
-
if (item.stepContent.extraQuestionBlock) {
|
|
113
|
-
if (!item.stepContent.extraQuestionBlock.fields) {
|
|
114
|
-
item.stepContent.extraQuestionBlock.fields = [];
|
|
115
|
-
}
|
|
116
|
-
|
|
117
|
-
const defaultExtraQuestionFields = steps[stepName].extraQuestionBlock.fields;
|
|
118
|
-
let defaultExtraQuestionOptions = [];
|
|
119
|
-
let defaultExtraQuestionLegend = {};
|
|
120
|
-
defaultExtraQuestionFields.forEach((defaultExtraQuestionField) => {
|
|
121
|
-
defaultExtraQuestionOptions = defaultExtraQuestionField.options;
|
|
122
|
-
defaultExtraQuestionLegend = defaultExtraQuestionField.legend;
|
|
123
|
-
});
|
|
124
|
-
item.stepContent.extraQuestionBlock.fields.forEach((field) => {
|
|
125
|
-
|
|
126
|
-
if (field.legend) {
|
|
127
|
-
field.legend = merge(defaultExtraQuestionLegend, field.legend);
|
|
128
|
-
} else {
|
|
129
|
-
field.legend = defaultExtraQuestionLegend;
|
|
130
|
-
}
|
|
131
|
-
|
|
132
|
-
if (field && field.remove) {
|
|
133
|
-
if (field.remove.includes('all')) {
|
|
134
|
-
defaultExtraQuestionOptions = [];
|
|
135
|
-
} else {
|
|
136
|
-
defaultExtraQuestionOptions = defaultExtraQuestionOptions.filter((_, i) => !field.remove.includes(i));
|
|
137
|
-
}
|
|
138
|
-
}
|
|
139
|
-
|
|
140
|
-
if (field.fieldType === 'radio') {
|
|
141
|
-
if (!field.errorMessage) {
|
|
142
|
-
field.errorMessage = 'Professionals need this info to generate a quote.';
|
|
143
|
-
}
|
|
144
|
-
|
|
145
|
-
if (field.options && Array.isArray(field.options) && field.options.length) {
|
|
146
|
-
field.options.forEach((option, optionIndex) => {
|
|
147
|
-
if (typeof option.update === 'number') {
|
|
148
|
-
if (option.attributes && option.attributes.checked === false) {
|
|
149
|
-
delete option.attributes.checked;
|
|
150
|
-
delete defaultStepOptions[option.update].attributes.checked;
|
|
151
|
-
}
|
|
152
|
-
merge(defaultExtraQuestionOptions[option.update], option);
|
|
153
|
-
} else {
|
|
154
|
-
if (typeof option.insertAt === 'number') {
|
|
155
|
-
defaultExtraQuestionOptions.splice(option.insertAt, 0, option);
|
|
156
|
-
} else {
|
|
157
|
-
defaultExtraQuestionOptions.push(option);
|
|
158
|
-
}
|
|
159
|
-
}
|
|
160
|
-
});
|
|
161
|
-
}
|
|
162
|
-
field.options = defaultExtraQuestionOptions;
|
|
163
|
-
} else {
|
|
164
|
-
if (field && Array.isArray(field) && field.length) {
|
|
165
|
-
if (typeof field.update === 'number') {
|
|
166
|
-
merge(defaultExtraQuestionFields[field.update], field);
|
|
167
|
-
} else {
|
|
168
|
-
if (typeof field.insertAt === 'number') {
|
|
169
|
-
defaultExtraQuestionFields.splice(field.insertAt, 0, field);
|
|
170
|
-
} else {
|
|
171
|
-
defaultExtraQuestionFields.push(field);
|
|
172
|
-
}
|
|
173
|
-
}
|
|
174
|
-
}
|
|
175
|
-
field = defaultExtraQuestionFields;
|
|
176
|
-
}
|
|
177
|
-
});
|
|
178
|
-
}
|
|
179
|
-
}
|
|
180
|
-
});
|
|
205
|
+
applyDefaultTradeConfigOnSteps(config, steps);
|
|
181
206
|
resolve();
|
|
182
207
|
})
|
|
183
208
|
.catch(error => {
|
package/tasks/templates.js
CHANGED
|
@@ -15,7 +15,26 @@ responseInterceptor(axiosInstance);
|
|
|
15
15
|
responseInterceptor(tcpaAxiosInstance);
|
|
16
16
|
responseInterceptor(consentCaptureAxiosInstance);
|
|
17
17
|
|
|
18
|
-
function
|
|
18
|
+
async function applyDefaultConfigOnSteps(defaultConfig, data, parentConfig) {
|
|
19
|
+
if (!data || typeof data !== 'object') return;
|
|
20
|
+
|
|
21
|
+
// If "steps" is an object, merge its config
|
|
22
|
+
if (data.steps && typeof data.steps === 'object') {
|
|
23
|
+
data.steps = await mergeDefaultFormFieldConfig(defaultConfig, data, parentConfig);
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
// Recursively go through all object properties
|
|
27
|
+
for (const key in data) {
|
|
28
|
+
if (data.hasOwnProperty(key)) {
|
|
29
|
+
const value = data[key];
|
|
30
|
+
if (typeof value === 'object' && value !== null) {
|
|
31
|
+
await applyDefaultConfigOnSteps(defaultConfig, value, parentConfig);
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
function mergeDefaultFormFieldConfig(defaultConfig, config, parentConfig) {
|
|
19
38
|
const { steps } = config;
|
|
20
39
|
|
|
21
40
|
if (!steps.items) {
|
|
@@ -23,7 +42,7 @@ function mergeDefaultFormFieldConfig(defaultConfig, config) {
|
|
|
23
42
|
return steps;
|
|
24
43
|
}
|
|
25
44
|
|
|
26
|
-
if (
|
|
45
|
+
if (parentConfig.useAccessibleConfig) {
|
|
27
46
|
steps.items.forEach(item => {
|
|
28
47
|
if (item.stepContent.fields) {
|
|
29
48
|
item.stepContent.fields = item.stepContent.fields.map(field => {
|
|
@@ -60,9 +79,7 @@ const getDefaultFormFieldConfig = async (config, folder = 'accessible-components
|
|
|
60
79
|
throw new Error(`${resp.status}: Error while fetching ${folder}/defaultFormFieldConfig.json`);
|
|
61
80
|
}
|
|
62
81
|
const defaultConfig = resp.data;
|
|
63
|
-
|
|
64
|
-
config.steps = await mergeDefaultFormFieldConfig(defaultConfig, config);
|
|
65
|
-
}
|
|
82
|
+
applyDefaultConfigOnSteps(defaultConfig, config, config);
|
|
66
83
|
resolve();
|
|
67
84
|
}).catch(error => {
|
|
68
85
|
console.error(error);
|