@constructor-io/constructorio-client-javascript 2.69.2 → 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.
@@ -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,
@@ -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
  *
@@ -47,6 +47,7 @@ export interface ConstructorClientOptions {
47
47
  serviceUrl?: string;
48
48
  quizzesServiceUrl?: string;
49
49
  agentServiceUrl?: string;
50
+ mediaServiceUrl?: string;
50
51
  assistantServiceUrl?: string;
51
52
  sessionId?: number;
52
53
  clientId?: string;
@@ -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
@@ -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.69.2';
7
+ var _default = exports["default"] = '2.70.0';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@constructor-io/constructorio-client-javascript",
3
- "version": "2.69.2",
3
+ "version": "2.70.0",
4
4
  "description": "Constructor.io JavaScript client",
5
5
  "main": "lib/constructorio.js",
6
6
  "types": "lib/types/index.d.ts",