@constructor-io/constructorio-client-javascript 2.73.0 → 2.74.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.
@@ -1315,10 +1315,7 @@ var Tracker = /*#__PURE__*/function () {
1315
1315
  var networkParameters = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
1316
1316
  // Ensure parameters are provided (required)
1317
1317
  if (parameters && (0, _typeof2["default"])(parameters) === 'object' && !Array.isArray(parameters)) {
1318
- var baseUrl = new URL(this.options.mediaServiceUrl);
1319
- if (!baseUrl.hostname.startsWith('behavior')) {
1320
- baseUrl.hostname = "behavior.".concat(baseUrl.hostname);
1321
- }
1318
+ var baseUrl = helpers.getBehaviorUrl(this.options.mediaServiceUrl);
1322
1319
  var requestPath = "".concat(baseUrl.toString(), "v2/ad_behavioral_action/display_ad_view?");
1323
1320
  var bodyParams = {};
1324
1321
  var bannerAdId = parameters.bannerAdId,
@@ -1346,6 +1343,60 @@ var Tracker = /*#__PURE__*/function () {
1346
1343
  return new Error('parameters are required of type object');
1347
1344
  }
1348
1345
 
1346
+ /**
1347
+ * Send media impression click event to API
1348
+ *
1349
+ * @function trackMediaImpressionClick
1350
+ * @param {object} parameters - Additional parameters to be sent with request
1351
+ * @param {string} parameters.bannerAdId - Banner ad identifier
1352
+ * @param {string} parameters.placementId - Placement identifier
1353
+ * @param {object} [parameters.analyticsTags] - Pass additional analytics data
1354
+ * @param {object} [networkParameters] - Parameters relevant to the network request
1355
+ * @param {number} [networkParameters.timeout] - Request timeout (in milliseconds)
1356
+ * @returns {(true|Error)}
1357
+ * @description User clicked a media banner
1358
+ * @example
1359
+ * constructorio.tracker.trackMediaImpressionClick(
1360
+ * {
1361
+ * bannerAdId: 'banner_ad_id',
1362
+ * placementId: 'placement_id',
1363
+ * },
1364
+ * );
1365
+ */
1366
+ }, {
1367
+ key: "trackMediaImpressionClick",
1368
+ value: function trackMediaImpressionClick(parameters) {
1369
+ var networkParameters = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
1370
+ // Ensure required parameters are provided
1371
+ if (parameters && (0, _typeof2["default"])(parameters) === 'object' && !Array.isArray(parameters)) {
1372
+ var baseUrl = helpers.getBehaviorUrl(this.options.mediaServiceUrl);
1373
+ var requestPath = "".concat(baseUrl.toString(), "v2/ad_behavioral_action/display_ad_click?");
1374
+ var bodyParams = {};
1375
+ var bannerAdId = parameters.bannerAdId,
1376
+ placementId = parameters.placementId,
1377
+ analyticsTags = parameters.analyticsTags;
1378
+ if (!helpers.isNil(bannerAdId)) {
1379
+ bodyParams.banner_ad_id = bannerAdId;
1380
+ }
1381
+ if (!helpers.isNil(placementId)) {
1382
+ bodyParams.placement_id = placementId;
1383
+ }
1384
+ if (!helpers.isNil(analyticsTags)) {
1385
+ bodyParams.analytics_tags = analyticsTags;
1386
+ }
1387
+ var requestURL = "".concat(requestPath).concat(applyParamsAsString({}, this.options));
1388
+ var requestMethod = 'POST';
1389
+ var requestBody = applyParams(bodyParams, _objectSpread(_objectSpread({}, this.options), {}, {
1390
+ requestMethod: requestMethod
1391
+ }));
1392
+ this.requests.queue(requestURL, requestMethod, requestBody, networkParameters);
1393
+ this.requests.send();
1394
+ return true;
1395
+ }
1396
+ this.requests.send();
1397
+ return new Error('parameters are required of type object');
1398
+ }
1399
+
1349
1400
  /**
1350
1401
  * Send recommendation click event to API
1351
1402
  *
@@ -127,7 +127,7 @@ export interface QuizResultData extends Record<string, any> {
127
127
  variations: Record<string, any>[];
128
128
  }
129
129
 
130
- export type Question = SelectQuestion | FilterValueQuestion | OpenQuestion | CoverQuestion;
130
+ export type Question = SelectQuestion | FilterValueQuestion | OpenQuestion | CoverQuestion | FreeFormQuestion;
131
131
 
132
132
  export interface BaseQuestion extends Record<string, any> {
133
133
  id: number;
@@ -158,6 +158,11 @@ export interface CoverQuestion extends BaseQuestion {
158
158
  type: 'cover';
159
159
  }
160
160
 
161
+ export interface FreeFormQuestion extends BaseQuestion {
162
+ type: 'free_form';
163
+ input_placeholder?: Nullable<string>;
164
+ }
165
+
161
166
  export interface QuizResult extends Record<string, any> {
162
167
  filter_expression: Record<string, any>;
163
168
  results_url: string;
@@ -444,5 +444,12 @@ declare class Tracker {
444
444
  }, networkParameters?: NetworkParameters
445
445
  ): true | Error;
446
446
 
447
+ trackMediaImpressionClick(parameters: {
448
+ bannerAdId: string;
449
+ placementId: string;
450
+ analyticsTags?: Record<string, string>;
451
+ }, networkParameters?: NetworkParameters
452
+ ): true | Error;
453
+
447
454
  on(messageType: string, callback: Function): true | Error;
448
455
  }
@@ -338,6 +338,13 @@ var utils = {
338
338
  },
339
339
  truncateString: function truncateString(string, maxLength) {
340
340
  return string.slice(0, maxLength);
341
+ },
342
+ getBehaviorUrl: function getBehaviorUrl(mediaServiceUrl) {
343
+ var baseUrl = new URL(mediaServiceUrl);
344
+ if (!baseUrl.hostname.startsWith('behavior')) {
345
+ baseUrl.hostname = "behavior.".concat(baseUrl.hostname);
346
+ }
347
+ return baseUrl;
341
348
  }
342
349
  };
343
350
  module.exports = utils;
package/lib/version.js CHANGED
@@ -4,4 +4,4 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports["default"] = void 0;
7
- var _default = exports["default"] = '2.73.0';
7
+ var _default = exports["default"] = '2.74.0';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@constructor-io/constructorio-client-javascript",
3
- "version": "2.73.0",
3
+ "version": "2.74.0",
4
4
  "description": "Constructor.io JavaScript client",
5
5
  "main": "lib/constructorio.js",
6
6
  "types": "lib/types/index.d.ts",