@constructor-io/constructorio-client-javascript 2.69.1 → 2.70.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/lib/constructorio.js +3 -0
- package/lib/modules/tracker.js +57 -0
- package/lib/types/index.d.ts +1 -0
- package/lib/types/tracker.d.ts +7 -0
- package/lib/version.js +1 -1
- package/package.json +1 -1
package/lib/constructorio.js
CHANGED
|
@@ -43,6 +43,7 @@ var ConstructorIO = /*#__PURE__*/function () {
|
|
|
43
43
|
* @param {string} [parameters.serviceUrl='https://ac.cnstrc.com'] - API URL endpoint
|
|
44
44
|
* @param {string} [parameters.quizzesServiceUrl='https://quizzes.cnstrc.com'] - Quizzes API URL endpoint
|
|
45
45
|
* @param {string} [parameters.agentServiceUrl='https://agent.cnstrc.com'] - AI Shopping Agent API URL endpoint
|
|
46
|
+
* @param {string} [parameters.mediaServiceUrl='https://media-cnstrc.com'] - Media API URL endpoint
|
|
46
47
|
* @param {string} [parameters.assistantServiceUrl='https://assistant.cnstrc.com'] - AI Shopping Assistant API URL endpoint @deprecated This parameter is deprecated and will be removed in a future version. Use parameters.agentServiceUrl instead.
|
|
47
48
|
* @param {array} [parameters.segments] - User segments
|
|
48
49
|
* @param {object} [parameters.testCells] - User test cells
|
|
@@ -78,6 +79,7 @@ var ConstructorIO = /*#__PURE__*/function () {
|
|
|
78
79
|
quizzesServiceUrl = options.quizzesServiceUrl,
|
|
79
80
|
agentServiceUrl = options.agentServiceUrl,
|
|
80
81
|
assistantServiceUrl = options.assistantServiceUrl,
|
|
82
|
+
mediaServiceUrl = options.mediaServiceUrl,
|
|
81
83
|
segments = options.segments,
|
|
82
84
|
testCells = options.testCells,
|
|
83
85
|
clientId = options.clientId,
|
|
@@ -122,6 +124,7 @@ var ConstructorIO = /*#__PURE__*/function () {
|
|
|
122
124
|
quizzesServiceUrl: quizzesServiceUrl && quizzesServiceUrl.replace(/\/$/, '') || 'https://quizzes.cnstrc.com',
|
|
123
125
|
agentServiceUrl: agentServiceUrl && agentServiceUrl.replace(/\/$/, '') || 'https://agent.cnstrc.com',
|
|
124
126
|
assistantServiceUrl: assistantServiceUrl && assistantServiceUrl.replace(/\/$/, '') || 'https://assistant.cnstrc.com',
|
|
127
|
+
mediaServiceUrl: mediaServiceUrl && mediaServiceUrl.replace(/\/$/, '') || 'https://media-cnstrc.com',
|
|
125
128
|
sessionId: sessionId || session_id,
|
|
126
129
|
clientId: clientId || client_id,
|
|
127
130
|
userId: userId,
|
package/lib/modules/tracker.js
CHANGED
|
@@ -1281,6 +1281,63 @@ var Tracker = /*#__PURE__*/function () {
|
|
|
1281
1281
|
return new Error('parameters are required of type object');
|
|
1282
1282
|
}
|
|
1283
1283
|
|
|
1284
|
+
/**
|
|
1285
|
+
* Send media impression view event to API
|
|
1286
|
+
*
|
|
1287
|
+
* @function trackMediaImpressionView
|
|
1288
|
+
* @param {object} parameters - Additional parameters to be sent with request
|
|
1289
|
+
* @param {string} parameters.bannerAdId - Banner ad identifier
|
|
1290
|
+
* @param {string} parameters.placementId - Placement identifier
|
|
1291
|
+
* @param {object} [parameters.analyticsTags] - Pass additional analytics data
|
|
1292
|
+
* @param {object} [networkParameters] - Parameters relevant to the network request
|
|
1293
|
+
* @param {number} [networkParameters.timeout] - Request timeout (in milliseconds)
|
|
1294
|
+
* @returns {(true|Error)}
|
|
1295
|
+
* @description User viewed a media banner
|
|
1296
|
+
* @example
|
|
1297
|
+
* constructorio.tracker.trackMediaImpressionView(
|
|
1298
|
+
* {
|
|
1299
|
+
* bannerAdId: 'banner_ad_id',
|
|
1300
|
+
* placementId: 'placement_id',
|
|
1301
|
+
* },
|
|
1302
|
+
* );
|
|
1303
|
+
*/
|
|
1304
|
+
}, {
|
|
1305
|
+
key: "trackMediaImpressionView",
|
|
1306
|
+
value: function trackMediaImpressionView(parameters) {
|
|
1307
|
+
var networkParameters = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
|
1308
|
+
// Ensure parameters are provided (required)
|
|
1309
|
+
if (parameters && (0, _typeof2["default"])(parameters) === 'object' && !Array.isArray(parameters)) {
|
|
1310
|
+
var baseUrl = new URL(this.options.mediaServiceUrl);
|
|
1311
|
+
if (!baseUrl.hostname.startsWith('behavior')) {
|
|
1312
|
+
baseUrl.hostname = "behavior.".concat(baseUrl.hostname);
|
|
1313
|
+
}
|
|
1314
|
+
var requestPath = "".concat(baseUrl.toString(), "v2/ad_behavioral_action/display_ad_view?");
|
|
1315
|
+
var bodyParams = {};
|
|
1316
|
+
var bannerAdId = parameters.bannerAdId,
|
|
1317
|
+
placementId = parameters.placementId,
|
|
1318
|
+
analyticsTags = parameters.analyticsTags;
|
|
1319
|
+
if (!helpers.isNil(bannerAdId)) {
|
|
1320
|
+
bodyParams.banner_ad_id = bannerAdId;
|
|
1321
|
+
}
|
|
1322
|
+
if (!helpers.isNil(placementId)) {
|
|
1323
|
+
bodyParams.placement_id = placementId;
|
|
1324
|
+
}
|
|
1325
|
+
if (!helpers.isNil(analyticsTags)) {
|
|
1326
|
+
bodyParams.analytics_tags = analyticsTags;
|
|
1327
|
+
}
|
|
1328
|
+
var requestURL = "".concat(requestPath).concat(applyParamsAsString({}, this.options));
|
|
1329
|
+
var requestMethod = 'POST';
|
|
1330
|
+
var requestBody = applyParams(bodyParams, _objectSpread(_objectSpread({}, this.options), {}, {
|
|
1331
|
+
requestMethod: requestMethod
|
|
1332
|
+
}));
|
|
1333
|
+
this.requests.queue(requestURL, requestMethod, requestBody, networkParameters);
|
|
1334
|
+
this.requests.send();
|
|
1335
|
+
return true;
|
|
1336
|
+
}
|
|
1337
|
+
this.requests.send();
|
|
1338
|
+
return new Error('parameters are required of type object');
|
|
1339
|
+
}
|
|
1340
|
+
|
|
1284
1341
|
/**
|
|
1285
1342
|
* Send recommendation click event to API
|
|
1286
1343
|
*
|
package/lib/types/index.d.ts
CHANGED
package/lib/types/tracker.d.ts
CHANGED
|
@@ -437,5 +437,12 @@ declare class Tracker {
|
|
|
437
437
|
networkParameters?: NetworkParameters
|
|
438
438
|
): true | Error;
|
|
439
439
|
|
|
440
|
+
trackMediaImpressionView(parameters: {
|
|
441
|
+
bannerAdId: string;
|
|
442
|
+
placementId: string;
|
|
443
|
+
analyticsTags?: Record<string, string>;
|
|
444
|
+
}, networkParameters?: NetworkParameters
|
|
445
|
+
): true | Error;
|
|
446
|
+
|
|
440
447
|
on(messageType: string, callback: Function): true | Error;
|
|
441
448
|
}
|
package/lib/version.js
CHANGED