@constructor-io/constructorio-node 4.7.5 → 4.9.0
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/package.json
CHANGED
|
@@ -38,7 +38,7 @@ function createRecommendationsUrl(podId, parameters, userParameters, options) {
|
|
|
38
38
|
}
|
|
39
39
|
|
|
40
40
|
if (parameters) {
|
|
41
|
-
const { numResults, itemIds, section, term, filters, variationsMap } = parameters;
|
|
41
|
+
const { numResults, itemIds, section, term, filters, variationsMap, hiddenFields } = parameters;
|
|
42
42
|
|
|
43
43
|
// Pull num results number from parameters
|
|
44
44
|
if (!helpers.isNil(numResults)) {
|
|
@@ -65,6 +65,15 @@ function createRecommendationsUrl(podId, parameters, userParameters, options) {
|
|
|
65
65
|
queryParams.filters = filters;
|
|
66
66
|
}
|
|
67
67
|
|
|
68
|
+
// Pull hidden fields from parameters
|
|
69
|
+
if (hiddenFields) {
|
|
70
|
+
if (queryParams.fmt_options) {
|
|
71
|
+
queryParams.fmt_options.hidden_fields = hiddenFields;
|
|
72
|
+
} else {
|
|
73
|
+
queryParams.fmt_options = { hidden_fields: hiddenFields };
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
|
|
68
77
|
// Pull variations map from parameters
|
|
69
78
|
if (variationsMap) {
|
|
70
79
|
queryParams.variations_map = JSON.stringify(variationsMap);
|
|
@@ -102,6 +111,7 @@ class Recommendations {
|
|
|
102
111
|
* @param {string} [parameters.term] - The term to use to refine results (strategy specific)
|
|
103
112
|
* @param {object} [parameters.filters] - Key / value mapping of filters used to refine results
|
|
104
113
|
* @param {object} [parameters.variationsMap] - The variations map object to aggregate variations. Please refer to https://docs.constructor.io/rest_api/variations_mapping for details
|
|
114
|
+
* @param {string[]} [parameters.hiddenFields] - Hidden metadata fields to return
|
|
105
115
|
* @param {object} [userParameters] - Parameters relevant to the user request
|
|
106
116
|
* @param {number} [userParameters.sessionId] - Session ID, utilized to personalize results
|
|
107
117
|
* @param {string} [userParameters.clientId] - Client ID, utilized to personalize results
|
package/src/modules/tracker.js
CHANGED
|
@@ -277,6 +277,7 @@ class Tracker {
|
|
|
277
277
|
* @param {string} parameters.itemId - Product item unique identifier
|
|
278
278
|
* @param {string} parameters.url - Current page URL
|
|
279
279
|
* @param {string} [parameters.variationId] - Product item variation unique identifier
|
|
280
|
+
* @param {object} [parameters.analyticsTags] - Pass additional analytics data
|
|
280
281
|
* @param {object} userParameters - Parameters relevant to the user request
|
|
281
282
|
* @param {number} userParameters.sessionId - Session ID, utilized to personalize results
|
|
282
283
|
* @param {string} userParameters.clientId - Client ID, utilized to personalize results
|
|
@@ -317,6 +318,7 @@ class Tracker {
|
|
|
317
318
|
itemId = item_id || customerId,
|
|
318
319
|
variationId = variation_id,
|
|
319
320
|
url,
|
|
321
|
+
analyticsTags,
|
|
320
322
|
} = parameters;
|
|
321
323
|
|
|
322
324
|
// Ensure support for both item_name and name as parameters
|
|
@@ -337,6 +339,10 @@ class Tracker {
|
|
|
337
339
|
bodyParams.url = url;
|
|
338
340
|
}
|
|
339
341
|
|
|
342
|
+
if (analyticsTags) {
|
|
343
|
+
bodyParams.analytics_tags = analyticsTags;
|
|
344
|
+
}
|
|
345
|
+
|
|
340
346
|
const requestUrl = `${requestPath}${applyParamsAsString({}, userParameters, this.options)}`;
|
|
341
347
|
const requestMethod = 'POST';
|
|
342
348
|
const requestBody = applyParams(bodyParams, userParameters, { ...this.options, requestMethod });
|
|
@@ -759,6 +765,7 @@ class Tracker {
|
|
|
759
765
|
* @param {boolean} [parameters.isCustomType] - Specify if type is custom conversion type
|
|
760
766
|
* @param {string} [parameters.displayName] - Display name for the custom conversion type
|
|
761
767
|
* @param {string} [parameters.section] - Index section
|
|
768
|
+
* @param {object} [parameters.analyticsTags] - Pass additional analytics data
|
|
762
769
|
* @param {object} userParameters - Parameters relevant to the user request
|
|
763
770
|
* @param {number} userParameters.sessionId - Session ID, utilized to personalize results
|
|
764
771
|
* @param {string} userParameters.clientId - Client ID, utilized to personalize results
|
|
@@ -818,6 +825,7 @@ class Tracker {
|
|
|
818
825
|
type,
|
|
819
826
|
is_custom_type,
|
|
820
827
|
isCustomType = is_custom_type,
|
|
828
|
+
analyticsTags,
|
|
821
829
|
} = parameters;
|
|
822
830
|
|
|
823
831
|
// Ensure support for both item_id and customer_id as parameters
|
|
@@ -859,6 +867,10 @@ class Tracker {
|
|
|
859
867
|
bodyParams.display_name = displayName;
|
|
860
868
|
}
|
|
861
869
|
|
|
870
|
+
if (analyticsTags) {
|
|
871
|
+
bodyParams.analytics_tags = analyticsTags;
|
|
872
|
+
}
|
|
873
|
+
|
|
862
874
|
const requestUrl = `${requestPath}${applyParamsAsString(queryParams, userParameters, this.options)}`;
|
|
863
875
|
const requestMethod = 'POST';
|
|
864
876
|
const requestBody = applyParams(bodyParams, userParameters, { ...this.options, requestMethod });
|
|
@@ -887,6 +899,7 @@ class Tracker {
|
|
|
887
899
|
* @param {number} parameters.revenue - The subtotal (excluding taxes, shipping, etc.) of the entire order
|
|
888
900
|
* @param {string} [parameters.orderId] - Unique order identifier
|
|
889
901
|
* @param {string} [parameters.section] - Index section
|
|
902
|
+
* @param {object} [parameters.analyticsTags] - Pass additional analytics data
|
|
890
903
|
* @param {object} userParameters - Parameters relevant to the user request
|
|
891
904
|
* @param {number} userParameters.sessionId - Session ID, utilized to personalize results
|
|
892
905
|
* @param {string} userParameters.clientId - Client ID, utilized to personalize results
|
|
@@ -931,6 +944,7 @@ class Tracker {
|
|
|
931
944
|
order_id,
|
|
932
945
|
orderId = order_id,
|
|
933
946
|
section,
|
|
947
|
+
analyticsTags,
|
|
934
948
|
} = parameters;
|
|
935
949
|
|
|
936
950
|
if (orderId) {
|
|
@@ -945,6 +959,10 @@ class Tracker {
|
|
|
945
959
|
bodyParams.revenue = revenue;
|
|
946
960
|
}
|
|
947
961
|
|
|
962
|
+
if (analyticsTags) {
|
|
963
|
+
bodyParams.analytics_tags = analyticsTags;
|
|
964
|
+
}
|
|
965
|
+
|
|
948
966
|
if (section) {
|
|
949
967
|
queryParams.section = section;
|
|
950
968
|
} else {
|
|
@@ -983,6 +1001,7 @@ class Tracker {
|
|
|
983
1001
|
* @param {number} [parameters.resultPage] - Page number of results
|
|
984
1002
|
* @param {string} [parameters.resultId] - Recommendation result identifier (returned in response from Constructor)
|
|
985
1003
|
* @param {string} [parameters.section="Products"] - Results section
|
|
1004
|
+
* @param {object} [parameters.analyticsTags] - Pass additional analytics data
|
|
986
1005
|
* @param {object} userParameters - Parameters relevant to the user request
|
|
987
1006
|
* @param {number} userParameters.sessionId - Session ID, utilized to personalize results
|
|
988
1007
|
* @param {string} userParameters.clientId - Client ID, utilized to personalize results
|
|
@@ -1037,6 +1056,7 @@ class Tracker {
|
|
|
1037
1056
|
num_results_viewed,
|
|
1038
1057
|
numResultsViewed = num_results_viewed,
|
|
1039
1058
|
items,
|
|
1059
|
+
analyticsTags,
|
|
1040
1060
|
} = parameters;
|
|
1041
1061
|
|
|
1042
1062
|
if (!helpers.isNil(resultCount)) {
|
|
@@ -1073,6 +1093,10 @@ class Tracker {
|
|
|
1073
1093
|
bodyParams.items = items.slice(0, 100).map((item) => helpers.toSnakeCaseKeys(item, false));
|
|
1074
1094
|
}
|
|
1075
1095
|
|
|
1096
|
+
if (analyticsTags) {
|
|
1097
|
+
bodyParams.analytics_tags = analyticsTags;
|
|
1098
|
+
}
|
|
1099
|
+
|
|
1076
1100
|
const requestUrl = `${requestPath}${applyParamsAsString({}, userParameters, this.options)}`;
|
|
1077
1101
|
const requestMethod = 'POST';
|
|
1078
1102
|
const requestBody = applyParams(bodyParams, userParameters, { ...this.options, requestMethod });
|
|
@@ -1108,6 +1132,7 @@ class Tracker {
|
|
|
1108
1132
|
* @param {number} [parameters.resultPage] - Page number of results
|
|
1109
1133
|
* @param {number} [parameters.resultPositionOnPage] - Position of result on page
|
|
1110
1134
|
* @param {number} [parameters.numResultsPerPage] - Number of results on page
|
|
1135
|
+
* @param {object} [parameters.analyticsTags] - Pass additional analytics data
|
|
1111
1136
|
* @param {object} userParameters - Parameters relevant to the user request
|
|
1112
1137
|
* @param {number} userParameters.sessionId - Session ID, utilized to personalize results
|
|
1113
1138
|
* @param {string} userParameters.clientId - Client ID, utilized to personalize results
|
|
@@ -1172,6 +1197,7 @@ class Tracker {
|
|
|
1172
1197
|
itemId = item_id,
|
|
1173
1198
|
item_name,
|
|
1174
1199
|
itemName = item_name,
|
|
1200
|
+
analyticsTags,
|
|
1175
1201
|
} = parameters;
|
|
1176
1202
|
|
|
1177
1203
|
if (variationId) {
|
|
@@ -1220,6 +1246,10 @@ class Tracker {
|
|
|
1220
1246
|
bodyParams.item_name = itemName;
|
|
1221
1247
|
}
|
|
1222
1248
|
|
|
1249
|
+
if (analyticsTags) {
|
|
1250
|
+
bodyParams.analytics_tags = analyticsTags;
|
|
1251
|
+
}
|
|
1252
|
+
|
|
1223
1253
|
const requestUrl = `${requestPath}${applyParamsAsString({}, userParameters, this.options)}`;
|
|
1224
1254
|
const requestMethod = 'POST';
|
|
1225
1255
|
const requestBody = applyParams(bodyParams, userParameters, { ...this.options, requestMethod });
|
|
@@ -1255,6 +1285,7 @@ class Tracker {
|
|
|
1255
1285
|
* @param {object} [parameters.selectedFilters] - Selected filters
|
|
1256
1286
|
* @param {string} [parameters.sortOrder] - Sort order ('ascending' or 'descending')
|
|
1257
1287
|
* @param {string} [parameters.sortBy] - Sorting method
|
|
1288
|
+
* @param {object} [parameters.analyticsTags] - Pass additional analytics data
|
|
1258
1289
|
* @param {object} userParameters - Parameters relevant to the user request
|
|
1259
1290
|
* @param {number} userParameters.sessionId - Session ID, utilized to personalize results
|
|
1260
1291
|
* @param {string} userParameters.clientId - Client ID, utilized to personalize results
|
|
@@ -1318,6 +1349,7 @@ class Tracker {
|
|
|
1318
1349
|
filter_value,
|
|
1319
1350
|
filterValue = filter_value,
|
|
1320
1351
|
items,
|
|
1352
|
+
analyticsTags,
|
|
1321
1353
|
} = parameters;
|
|
1322
1354
|
|
|
1323
1355
|
if (section) {
|
|
@@ -1366,6 +1398,10 @@ class Tracker {
|
|
|
1366
1398
|
bodyParams.items = items.slice(0, 100).map((item) => helpers.toSnakeCaseKeys(item, false));
|
|
1367
1399
|
}
|
|
1368
1400
|
|
|
1401
|
+
if (analyticsTags) {
|
|
1402
|
+
bodyParams.analytics_tags = analyticsTags;
|
|
1403
|
+
}
|
|
1404
|
+
|
|
1369
1405
|
const requestUrl = `${requestPath}${applyParamsAsString({}, userParameters, this.options)}`;
|
|
1370
1406
|
const requestMethod = 'POST';
|
|
1371
1407
|
const requestBody = applyParams(bodyParams, userParameters, { ...this.options, requestMethod });
|
|
@@ -1401,6 +1437,7 @@ class Tracker {
|
|
|
1401
1437
|
* @param {number} [parameters.resultPositionOnPage] - Position of clicked item
|
|
1402
1438
|
* @param {number} [parameters.numResultsPerPage] - Number of results shown
|
|
1403
1439
|
* @param {object} [parameters.selectedFilters] - Selected filters
|
|
1440
|
+
* @param {object} [parameters.analyticsTags] - Pass additional analytics data
|
|
1404
1441
|
* @param {object} userParameters - Parameters relevant to the user request
|
|
1405
1442
|
* @param {number} userParameters.sessionId - Session ID, utilized to personalize results
|
|
1406
1443
|
* @param {string} userParameters.clientId - Client ID, utilized to personalize results
|
|
@@ -1466,6 +1503,7 @@ class Tracker {
|
|
|
1466
1503
|
filterValue = filter_value,
|
|
1467
1504
|
item_id,
|
|
1468
1505
|
itemId = item_id,
|
|
1506
|
+
analyticsTags,
|
|
1469
1507
|
} = parameters;
|
|
1470
1508
|
|
|
1471
1509
|
if (section) {
|
|
@@ -1514,6 +1552,10 @@ class Tracker {
|
|
|
1514
1552
|
bodyParams.item_id = itemId;
|
|
1515
1553
|
}
|
|
1516
1554
|
|
|
1555
|
+
if (analyticsTags) {
|
|
1556
|
+
bodyParams.analytics_tags = analyticsTags;
|
|
1557
|
+
}
|
|
1558
|
+
|
|
1517
1559
|
const requestUrl = `${requestPath}${applyParamsAsString({}, userParameters, this.options)}`;
|
|
1518
1560
|
const requestMethod = 'POST';
|
|
1519
1561
|
const requestBody = applyParams(bodyParams, userParameters, { ...this.options, requestMethod });
|
|
@@ -1542,6 +1584,7 @@ class Tracker {
|
|
|
1542
1584
|
* @param {string} [parameters.itemName] - Product item name
|
|
1543
1585
|
* @param {string} [parameters.variationId] - Product item variation unique identifier
|
|
1544
1586
|
* @param {string} [parameters.section="Products"] - Index section
|
|
1587
|
+
* @param {object} [parameters.analyticsTags] - Pass additional analytics data
|
|
1545
1588
|
* @param {object} [userParameters] - Parameters relevant to the user request
|
|
1546
1589
|
* @param {number} userParameters.sessionId - Session ID, utilized to personalize results
|
|
1547
1590
|
* @param {string} userParameters.clientId - Client ID, utilized to personalize results
|
|
@@ -1586,6 +1629,7 @@ class Tracker {
|
|
|
1586
1629
|
variation_id,
|
|
1587
1630
|
variationId = variation_id,
|
|
1588
1631
|
section,
|
|
1632
|
+
analyticsTags,
|
|
1589
1633
|
} = parameters;
|
|
1590
1634
|
|
|
1591
1635
|
bodyParams.section = section || 'Products';
|
|
@@ -1599,6 +1643,10 @@ class Tracker {
|
|
|
1599
1643
|
bodyParams.variation_id = variationId;
|
|
1600
1644
|
}
|
|
1601
1645
|
|
|
1646
|
+
if (analyticsTags) {
|
|
1647
|
+
bodyParams.analytics_tags = analyticsTags;
|
|
1648
|
+
}
|
|
1649
|
+
|
|
1602
1650
|
const requestUrl = `${requestPath}${applyParamsAsString({}, userParameters, this.options)}`;
|
|
1603
1651
|
const requestMethod = 'POST';
|
|
1604
1652
|
const requestBody = applyParams(bodyParams, userParameters, { ...this.options, requestMethod });
|
package/src/types/tracker.d.ts
CHANGED
|
@@ -39,6 +39,7 @@ declare class Tracker {
|
|
|
39
39
|
itemId: string;
|
|
40
40
|
url: string;
|
|
41
41
|
variationId?: string;
|
|
42
|
+
analyticsTags?: Record<string, string>;
|
|
42
43
|
},
|
|
43
44
|
userParameters?: TrackerUserParameters,
|
|
44
45
|
networkParameters?: NetworkParameters
|
|
@@ -104,6 +105,7 @@ declare class Tracker {
|
|
|
104
105
|
displayName?: string;
|
|
105
106
|
resultId?: string;
|
|
106
107
|
section?: string;
|
|
108
|
+
analyticsTags?: Record<string, string>;
|
|
107
109
|
},
|
|
108
110
|
userParameters?: TrackerUserParameters,
|
|
109
111
|
networkParameters?: NetworkParameters
|
|
@@ -115,6 +117,7 @@ declare class Tracker {
|
|
|
115
117
|
revenue: number;
|
|
116
118
|
orderId?: string;
|
|
117
119
|
section?: string;
|
|
120
|
+
analyticsTags?: Record<string, string>;
|
|
118
121
|
},
|
|
119
122
|
userParameters?: TrackerUserParameters,
|
|
120
123
|
networkParameters?: NetworkParameters
|
|
@@ -130,6 +133,7 @@ declare class Tracker {
|
|
|
130
133
|
resultPage?: number;
|
|
131
134
|
resultId?: string;
|
|
132
135
|
section?: string;
|
|
136
|
+
analyticsTags?: Record<string, string>;
|
|
133
137
|
},
|
|
134
138
|
userParameters?: TrackerUserParameters,
|
|
135
139
|
networkParameters?: NetworkParameters
|
|
@@ -148,6 +152,7 @@ declare class Tracker {
|
|
|
148
152
|
resultPage?: number;
|
|
149
153
|
resultPositionOnPage?: number;
|
|
150
154
|
numResultsPerPage?: number;
|
|
155
|
+
analyticsTags?: Record<string, string>;
|
|
151
156
|
},
|
|
152
157
|
userParameters?: TrackerUserParameters,
|
|
153
158
|
networkParameters?: NetworkParameters
|
|
@@ -166,6 +171,7 @@ declare class Tracker {
|
|
|
166
171
|
sortOrder?: string;
|
|
167
172
|
sortBy?: string;
|
|
168
173
|
items: ItemTracked[];
|
|
174
|
+
analyticsTags?: Record<string, string>;
|
|
169
175
|
},
|
|
170
176
|
userParameters?: TrackerUserParameters,
|
|
171
177
|
networkParameters?: NetworkParameters
|
|
@@ -184,6 +190,7 @@ declare class Tracker {
|
|
|
184
190
|
resultPositionOnPage?: number;
|
|
185
191
|
numResultsPerPage?: number;
|
|
186
192
|
selectedFilters?: object;
|
|
193
|
+
analyticsTags?: Record<string, string>;
|
|
187
194
|
},
|
|
188
195
|
userParameters?: TrackerUserParameters,
|
|
189
196
|
networkParameters?: NetworkParameters
|
|
@@ -195,6 +202,7 @@ declare class Tracker {
|
|
|
195
202
|
itemName?: string;
|
|
196
203
|
variationId?: string;
|
|
197
204
|
section?: string;
|
|
205
|
+
analyticsTags?: Record<string, string>;
|
|
198
206
|
},
|
|
199
207
|
userParameters?: TrackerUserParameters,
|
|
200
208
|
networkParameters?: NetworkParameters
|