@constructor-io/constructorio-client-javascript 2.35.11 → 2.35.13
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/lib/modules/tracker.js +747 -530
- package/lib/types/autocomplete.d.ts +2 -1
- package/lib/types/browse.d.ts +3 -1
- package/lib/types/index.d.ts +14 -0
- package/lib/types/quizzes.d.ts +1 -1
- package/lib/types/recommendations.d.ts +2 -2
- package/lib/types/search.d.ts +3 -1
- package/lib/types/tracker.d.ts +83 -83
- package/lib/utils/helpers.js +14 -0
- package/package.json +1 -1
|
@@ -4,6 +4,7 @@ import {
|
|
|
4
4
|
NetworkParameters,
|
|
5
5
|
RequestFeature,
|
|
6
6
|
RequestFeatureVariant,
|
|
7
|
+
VariationsMap,
|
|
7
8
|
} from '.';
|
|
8
9
|
import EventDispatcher from './event-dispatcher';
|
|
9
10
|
|
|
@@ -14,7 +15,7 @@ export interface IAutocompleteParameters {
|
|
|
14
15
|
filters?: Record<string, any>;
|
|
15
16
|
resultsPerSection?: Record<string, number>;
|
|
16
17
|
hiddenFields?: string[];
|
|
17
|
-
variationsMap?:
|
|
18
|
+
variationsMap?: VariationsMap;
|
|
18
19
|
}
|
|
19
20
|
|
|
20
21
|
declare class Autocomplete {
|
package/lib/types/browse.d.ts
CHANGED
|
@@ -11,6 +11,7 @@ import {
|
|
|
11
11
|
RequestFeatureVariant,
|
|
12
12
|
ResultSources,
|
|
13
13
|
SortOption,
|
|
14
|
+
VariationsMap,
|
|
14
15
|
} from '.';
|
|
15
16
|
import EventDispatcher from './event-dispatcher';
|
|
16
17
|
|
|
@@ -28,7 +29,7 @@ export interface IBrowseParameters {
|
|
|
28
29
|
preFilterExpression?: FilterExpression;
|
|
29
30
|
hiddenFields?: string[];
|
|
30
31
|
hiddenFacets?: string[];
|
|
31
|
-
variationsMap?:
|
|
32
|
+
variationsMap?: VariationsMap;
|
|
32
33
|
qsParam?: Record<string, any>;
|
|
33
34
|
}
|
|
34
35
|
|
|
@@ -121,6 +122,7 @@ export interface BrowseResultData extends Record<string, any> {
|
|
|
121
122
|
is_slotted: false;
|
|
122
123
|
labels: Record<string, any>;
|
|
123
124
|
variations: Record<string, any>[];
|
|
125
|
+
variations_map: Record<string, any> | Record<string, any>[];
|
|
124
126
|
}
|
|
125
127
|
|
|
126
128
|
export interface BrowseRequestType extends Record<string, any> {
|
package/lib/types/index.d.ts
CHANGED
|
@@ -204,3 +204,17 @@ export interface SearchSuggestion extends Item {
|
|
|
204
204
|
total_num_results?: number
|
|
205
205
|
} & ItemData;
|
|
206
206
|
}
|
|
207
|
+
|
|
208
|
+
export interface VariationsMap {
|
|
209
|
+
group_by: Array<{
|
|
210
|
+
name: string,
|
|
211
|
+
field: string
|
|
212
|
+
}>;
|
|
213
|
+
values: {
|
|
214
|
+
[key: string]: {
|
|
215
|
+
aggregation: 'first' | 'min' | 'max' | 'all',
|
|
216
|
+
field: string
|
|
217
|
+
},
|
|
218
|
+
},
|
|
219
|
+
dtype: 'array' | 'object'
|
|
220
|
+
}
|
package/lib/types/quizzes.d.ts
CHANGED
|
@@ -114,7 +114,7 @@ export interface SelectQuestion extends BaseQuestion {
|
|
|
114
114
|
|
|
115
115
|
export interface OpenQuestion extends BaseQuestion {
|
|
116
116
|
type: 'open'
|
|
117
|
-
|
|
117
|
+
input_placeholder?: Nullable<string>;
|
|
118
118
|
}
|
|
119
119
|
|
|
120
120
|
export interface CoverQuestion extends BaseQuestion {
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { ConstructorClientOptions, NetworkParameters } from '.';
|
|
1
|
+
import { ConstructorClientOptions, NetworkParameters, VariationsMap } from '.';
|
|
2
2
|
import EventDispatcher from './event-dispatcher';
|
|
3
3
|
|
|
4
4
|
export default Recommendations;
|
|
@@ -9,7 +9,7 @@ export interface RecommendationsParameters {
|
|
|
9
9
|
section?: string;
|
|
10
10
|
term?: string;
|
|
11
11
|
filters?: Record<string, any>;
|
|
12
|
-
variationsMap?:
|
|
12
|
+
variationsMap?: VariationsMap;
|
|
13
13
|
hiddenFields?: string[];
|
|
14
14
|
}
|
|
15
15
|
|
package/lib/types/search.d.ts
CHANGED
|
@@ -10,6 +10,7 @@ import {
|
|
|
10
10
|
RequestFeatureVariant,
|
|
11
11
|
ResultSources,
|
|
12
12
|
SortOption,
|
|
13
|
+
VariationsMap,
|
|
13
14
|
} from '.';
|
|
14
15
|
import EventDispatcher from './event-dispatcher';
|
|
15
16
|
|
|
@@ -27,7 +28,7 @@ export interface SearchParameters {
|
|
|
27
28
|
preFilterExpression?: FilterExpression;
|
|
28
29
|
hiddenFields?: string[];
|
|
29
30
|
hiddenFacets?: string[];
|
|
30
|
-
variationsMap?:
|
|
31
|
+
variationsMap?: VariationsMap;
|
|
31
32
|
qsParam?: Record<string, any>;
|
|
32
33
|
}
|
|
33
34
|
declare class Search {
|
|
@@ -95,6 +96,7 @@ export interface Result extends Record<string, any> {
|
|
|
95
96
|
is_slotted: false;
|
|
96
97
|
labels: Record<string, any>;
|
|
97
98
|
variations: Record<string, any>[];
|
|
99
|
+
variations_map: Record<string, any> | Record<string, any>[];
|
|
98
100
|
}
|
|
99
101
|
|
|
100
102
|
export interface Redirect extends Record<string, any> {
|
package/lib/types/tracker.d.ts
CHANGED
|
@@ -19,9 +19,9 @@ declare class Tracker {
|
|
|
19
19
|
|
|
20
20
|
trackItemDetailLoad(
|
|
21
21
|
parameters: {
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
22
|
+
itemName: string;
|
|
23
|
+
itemId: string;
|
|
24
|
+
variationId?: string;
|
|
25
25
|
},
|
|
26
26
|
networkParameters?: NetworkParameters
|
|
27
27
|
): true | Error;
|
|
@@ -29,11 +29,11 @@ declare class Tracker {
|
|
|
29
29
|
trackAutocompleteSelect(
|
|
30
30
|
term: string,
|
|
31
31
|
parameters: {
|
|
32
|
-
|
|
32
|
+
originalQuery: string;
|
|
33
33
|
section: string;
|
|
34
34
|
tr?: string;
|
|
35
|
-
|
|
36
|
-
|
|
35
|
+
groupId?: string;
|
|
36
|
+
displayName?: string;
|
|
37
37
|
},
|
|
38
38
|
networkParameters?: NetworkParameters
|
|
39
39
|
): true | Error;
|
|
@@ -41,9 +41,9 @@ declare class Tracker {
|
|
|
41
41
|
trackSearchSubmit(
|
|
42
42
|
term: string,
|
|
43
43
|
parameters: {
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
44
|
+
originalQuery: string;
|
|
45
|
+
groupId?: string;
|
|
46
|
+
displayName?: string;
|
|
47
47
|
},
|
|
48
48
|
networkParameters?: NetworkParameters
|
|
49
49
|
): true | Error;
|
|
@@ -51,8 +51,8 @@ declare class Tracker {
|
|
|
51
51
|
trackSearchResultsLoaded(
|
|
52
52
|
term: string,
|
|
53
53
|
parameters: {
|
|
54
|
-
|
|
55
|
-
|
|
54
|
+
numResults: number;
|
|
55
|
+
itemIds?: string[];
|
|
56
56
|
},
|
|
57
57
|
networkParameters?: NetworkParameters
|
|
58
58
|
): true | Error;
|
|
@@ -60,11 +60,11 @@ declare class Tracker {
|
|
|
60
60
|
trackSearchResultClick(
|
|
61
61
|
term: string,
|
|
62
62
|
parameters: {
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
63
|
+
itemName: string;
|
|
64
|
+
itemId: string;
|
|
65
|
+
variationId?: string;
|
|
66
|
+
resultId?: string;
|
|
67
|
+
itemIsConvertible?: string;
|
|
68
68
|
section?: string;
|
|
69
69
|
},
|
|
70
70
|
networkParameters?: NetworkParameters
|
|
@@ -73,14 +73,14 @@ declare class Tracker {
|
|
|
73
73
|
trackConversion(
|
|
74
74
|
term?: string,
|
|
75
75
|
parameters: {
|
|
76
|
-
|
|
76
|
+
itemId: string;
|
|
77
77
|
revenue?: number;
|
|
78
|
-
|
|
79
|
-
|
|
78
|
+
itemName?: string;
|
|
79
|
+
variationId?: string;
|
|
80
80
|
type?: string;
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
81
|
+
isCustomType?: boolean;
|
|
82
|
+
displayName?: string;
|
|
83
|
+
resultId?: string;
|
|
84
84
|
section?: string;
|
|
85
85
|
},
|
|
86
86
|
networkParameters?: NetworkParameters
|
|
@@ -90,7 +90,7 @@ declare class Tracker {
|
|
|
90
90
|
parameters: {
|
|
91
91
|
items: object[];
|
|
92
92
|
revenue: number;
|
|
93
|
-
|
|
93
|
+
orderId?: string;
|
|
94
94
|
section?: string;
|
|
95
95
|
},
|
|
96
96
|
networkParameters?: NetworkParameters
|
|
@@ -99,12 +99,12 @@ declare class Tracker {
|
|
|
99
99
|
trackRecommendationView(
|
|
100
100
|
parameters: {
|
|
101
101
|
url: string;
|
|
102
|
-
|
|
103
|
-
|
|
102
|
+
podId: string;
|
|
103
|
+
numResultsViewed: number;
|
|
104
104
|
items?: object[];
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
105
|
+
resultCount?: number;
|
|
106
|
+
resultPage?: number;
|
|
107
|
+
resultId?: string;
|
|
108
108
|
section?: string;
|
|
109
109
|
},
|
|
110
110
|
networkParameters?: NetworkParameters
|
|
@@ -112,17 +112,17 @@ declare class Tracker {
|
|
|
112
112
|
|
|
113
113
|
trackRecommendationClick(
|
|
114
114
|
parameters: {
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
115
|
+
podId: string;
|
|
116
|
+
strategyId: string;
|
|
117
|
+
itemId: string;
|
|
118
|
+
itemName: string;
|
|
119
|
+
variationId?: string;
|
|
120
120
|
section?: string;
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
121
|
+
resultId?: string;
|
|
122
|
+
resultCount?: number;
|
|
123
|
+
resultPage?: number;
|
|
124
|
+
resultPositionOnPage?: number;
|
|
125
|
+
numResultsPerPage?: number;
|
|
126
126
|
},
|
|
127
127
|
networkParameters?: NetworkParameters
|
|
128
128
|
): true | Error;
|
|
@@ -130,15 +130,15 @@ declare class Tracker {
|
|
|
130
130
|
trackBrowseResultsLoaded(
|
|
131
131
|
parameters: {
|
|
132
132
|
url: string;
|
|
133
|
-
|
|
134
|
-
|
|
133
|
+
filterName: string;
|
|
134
|
+
filterValue: string;
|
|
135
135
|
section?: string;
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
136
|
+
resultCount?: number;
|
|
137
|
+
resultPage?: number;
|
|
138
|
+
resultId?: string;
|
|
139
|
+
selectedFilters?: object;
|
|
140
|
+
sortOrder?: string;
|
|
141
|
+
sortBy?: string;
|
|
142
142
|
items?: object[];
|
|
143
143
|
},
|
|
144
144
|
networkParameters?: NetworkParameters
|
|
@@ -146,26 +146,26 @@ declare class Tracker {
|
|
|
146
146
|
|
|
147
147
|
trackBrowseResultClick(
|
|
148
148
|
parameters: {
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
149
|
+
filterName: string;
|
|
150
|
+
filterValue: string;
|
|
151
|
+
itemId: string;
|
|
152
152
|
section?: string;
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
153
|
+
variationId?: string;
|
|
154
|
+
resultId?: string;
|
|
155
|
+
resultCount?: number;
|
|
156
|
+
resultPage?: number;
|
|
157
|
+
resultPositionOnPage?: number;
|
|
158
|
+
numResultsPerPage?: number;
|
|
159
|
+
selectedFilters?: object;
|
|
160
160
|
},
|
|
161
161
|
networkParameters?: NetworkParameters
|
|
162
162
|
): true | Error;
|
|
163
163
|
|
|
164
164
|
trackGenericResultClick(
|
|
165
165
|
parameters: {
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
166
|
+
itemId: string;
|
|
167
|
+
itemName?: string;
|
|
168
|
+
variationId?: string;
|
|
169
169
|
section?: string;
|
|
170
170
|
},
|
|
171
171
|
networkParameters?: NetworkParameters
|
|
@@ -173,48 +173,48 @@ declare class Tracker {
|
|
|
173
173
|
|
|
174
174
|
trackQuizResultsLoaded(
|
|
175
175
|
parameters: {
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
176
|
+
quizId: string;
|
|
177
|
+
quizVersionId: string;
|
|
178
|
+
quizSessionId: string;
|
|
179
179
|
url: string;
|
|
180
180
|
section?: string;
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
181
|
+
resultCount?: number;
|
|
182
|
+
resultPage?: number;
|
|
183
|
+
resultId?: string;
|
|
184
184
|
},
|
|
185
185
|
networkParameters?: NetworkParameters
|
|
186
186
|
): true | Error;
|
|
187
187
|
|
|
188
188
|
trackQuizResultClick(
|
|
189
189
|
parameters: {
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
190
|
+
quizId: string;
|
|
191
|
+
quizVersionId: string;
|
|
192
|
+
quizSessionId: string;
|
|
193
|
+
itemId?: string;
|
|
194
|
+
itemName?: string;
|
|
195
195
|
section?: string;
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
196
|
+
resultCount?: number;
|
|
197
|
+
resultPage?: number;
|
|
198
|
+
resultId?: string;
|
|
199
|
+
resultPositionOnPage?: number;
|
|
200
|
+
numResultsPerPage?: number;
|
|
201
201
|
},
|
|
202
202
|
networkParameters?: NetworkParameters
|
|
203
203
|
): true | Error;
|
|
204
204
|
|
|
205
205
|
trackQuizConversion(
|
|
206
206
|
parameters: {
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
207
|
+
quizId: string;
|
|
208
|
+
quizVersionId: string;
|
|
209
|
+
quizSessionId: string;
|
|
210
|
+
itemId?: string;
|
|
211
|
+
itemName?: string;
|
|
212
212
|
section?: string;
|
|
213
|
-
|
|
213
|
+
variationId?: string;
|
|
214
214
|
revenue?: string;
|
|
215
215
|
type?: string;
|
|
216
|
-
|
|
217
|
-
|
|
216
|
+
isCustomType?: boolean;
|
|
217
|
+
displayName?: string;
|
|
218
218
|
},
|
|
219
219
|
networkParameters?: NetworkParameters
|
|
220
220
|
): true | Error;
|
package/lib/utils/helpers.js
CHANGED
|
@@ -183,6 +183,20 @@ var utils = {
|
|
|
183
183
|
}
|
|
184
184
|
});
|
|
185
185
|
return allValues.join('&');
|
|
186
|
+
},
|
|
187
|
+
toSnakeCase: function toSnakeCase(camelCasedStr) {
|
|
188
|
+
return camelCasedStr.replace(/[A-Z]/g, function (prefix) {
|
|
189
|
+
return "_".concat(prefix.toLowerCase());
|
|
190
|
+
});
|
|
191
|
+
},
|
|
192
|
+
toSnakeCaseKeys: function toSnakeCaseKeys(camelCasedObj) {
|
|
193
|
+
var toRecurse = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
|
|
194
|
+
var snakeCasedObj = {};
|
|
195
|
+
Object.keys(camelCasedObj).forEach(function (key) {
|
|
196
|
+
var newKey = utils.toSnakeCase(key);
|
|
197
|
+
snakeCasedObj[newKey] = toRecurse && (0, _typeof2["default"])(camelCasedObj[key]) === 'object' && !Array.isArray(camelCasedObj[key]) ? utils.toSnakeCaseKeys(camelCasedObj[key], toRecurse) : camelCasedObj[key];
|
|
198
|
+
});
|
|
199
|
+
return snakeCasedObj;
|
|
186
200
|
}
|
|
187
201
|
};
|
|
188
202
|
module.exports = utils;
|
package/package.json
CHANGED