@constructor-io/constructorio-ui-pia 2.7.0 → 2.8.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.
@@ -13,8 +13,7 @@ class MockConstructorIOClient {
13
13
  this.recommendations = cioClient.recommendations;
14
14
  this.tracker = cioClient.tracker;
15
15
  this.quizzes = cioClient.quizzes;
16
- // Use the mock agent instead of the one from the client
17
- this.agent = new agent_1.default(this.options);
16
+ this.agent = new agent_1.default(Object.assign(Object.assign({}, this.options), { clientId: options.clientId, sessionId: options.sessionId }));
18
17
  }
19
18
  }
20
19
  exports.default = MockConstructorIOClient;
@@ -3,7 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  const tslib_1 = require("tslib");
4
4
  // Create URL for PIA API
5
5
  function createAgentUrl({ itemId, threadId, variationId, question, isStreaming = false, options, parameters = {}, }) {
6
- const { apiKey, agentServiceUrl } = options;
6
+ const { apiKey, agentServiceUrl, clientId, sessionId, userId, segments, version } = options;
7
7
  if (!agentServiceUrl)
8
8
  throw new Error('Agent service URL is required');
9
9
  let baseUrl = `${agentServiceUrl}/v1/item_questions`;
@@ -22,6 +22,21 @@ function createAgentUrl({ itemId, threadId, variationId, question, isStreaming =
22
22
  if (variationId) {
23
23
  url.searchParams.append('variation_id', variationId);
24
24
  }
25
+ if (clientId) {
26
+ url.searchParams.append('i', clientId);
27
+ }
28
+ if (sessionId != null) {
29
+ url.searchParams.append('s', String(sessionId));
30
+ }
31
+ if (userId) {
32
+ url.searchParams.append('ui', userId);
33
+ }
34
+ if (version) {
35
+ url.searchParams.append('c', version);
36
+ }
37
+ if (segments === null || segments === void 0 ? void 0 : segments.length) {
38
+ segments.forEach((segment) => url.searchParams.append('us', segment));
39
+ }
25
40
  // Any additional parameters
26
41
  Object.entries(parameters).forEach(([key, value]) => {
27
42
  if (value !== undefined) {
@@ -1,3 +1,3 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.default = '2.7.0';
3
+ exports.default = '2.8.0';
@@ -28,8 +28,11 @@ class MockConstructorIOClient {
28
28
  this.recommendations = cioClient.recommendations;
29
29
  this.tracker = cioClient.tracker;
30
30
  this.quizzes = cioClient.quizzes;
31
- // Use the mock agent instead of the one from the client
32
- this.agent = new MockAgent(this.options);
31
+ this.agent = new MockAgent({
32
+ ...this.options,
33
+ clientId: options.clientId,
34
+ sessionId: options.sessionId,
35
+ });
33
36
  }
34
37
  }
35
38
  export default MockConstructorIOClient;
@@ -1,6 +1,6 @@
1
1
  // Create URL for PIA API
2
2
  function createAgentUrl({ itemId, threadId, variationId, question, isStreaming = false, options, parameters = {}, }) {
3
- const { apiKey, agentServiceUrl } = options;
3
+ const { apiKey, agentServiceUrl, clientId, sessionId, userId, segments, version } = options;
4
4
  if (!agentServiceUrl)
5
5
  throw new Error('Agent service URL is required');
6
6
  let baseUrl = `${agentServiceUrl}/v1/item_questions`;
@@ -19,6 +19,21 @@ function createAgentUrl({ itemId, threadId, variationId, question, isStreaming =
19
19
  if (variationId) {
20
20
  url.searchParams.append('variation_id', variationId);
21
21
  }
22
+ if (clientId) {
23
+ url.searchParams.append('i', clientId);
24
+ }
25
+ if (sessionId != null) {
26
+ url.searchParams.append('s', String(sessionId));
27
+ }
28
+ if (userId) {
29
+ url.searchParams.append('ui', userId);
30
+ }
31
+ if (version) {
32
+ url.searchParams.append('c', version);
33
+ }
34
+ if (segments?.length) {
35
+ segments.forEach((segment) => url.searchParams.append('us', segment));
36
+ }
22
37
  // Any additional parameters
23
38
  Object.entries(parameters).forEach(([key, value]) => {
24
39
  if (value !== undefined) {
@@ -1 +1 @@
1
- export default '2.7.0';
1
+ export default '2.8.0';
@@ -1,2 +1,2 @@
1
- declare const _default: "2.7.0";
1
+ declare const _default: "2.8.0";
2
2
  export default _default;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@constructor-io/constructorio-ui-pia",
3
- "version": "2.7.0",
3
+ "version": "2.8.0",
4
4
  "description": "Constructor.io AI Product Insights Agent UI library for web applications",
5
5
  "author": "Constructor.io Corporation",
6
6
  "license": "MIT",