@constructor-io/constructorio-client-javascript 2.65.1 → 2.66.1

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.
@@ -14,6 +14,7 @@ function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t =
14
14
  var EventEmitter = require('../utils/events');
15
15
  var helpers = require('../utils/helpers');
16
16
  var RequestQueue = require('../utils/request-queue');
17
+ var MAX_URL_LENGTH = 2048;
17
18
  function applyParams(parameters, options) {
18
19
  var apiKey = options.apiKey,
19
20
  version = options.version,
@@ -271,7 +272,7 @@ var Tracker = /*#__PURE__*/function () {
271
272
  bodyParams.analytics_tags = analyticsTags;
272
273
  }
273
274
  if (url) {
274
- bodyParams.url = url;
275
+ bodyParams.url = helpers.truncateString(url, MAX_URL_LENGTH);
275
276
  }
276
277
  var requestURL = "".concat(requestUrlPath).concat(applyParamsAsString(queryParams, this.options));
277
278
  var requestMethod = 'POST';
@@ -724,7 +725,7 @@ var Tracker = /*#__PURE__*/function () {
724
725
  sort_order: sortOrder,
725
726
  sort_by: sortBy,
726
727
  selected_filters: selectedFilters,
727
- url: url,
728
+ url: helpers.truncateString(url, MAX_URL_LENGTH),
728
729
  section: section,
729
730
  analytics_tags: analyticsTags
730
731
  };
@@ -1240,7 +1241,7 @@ var Tracker = /*#__PURE__*/function () {
1240
1241
  bodyParams.section = 'Products';
1241
1242
  }
1242
1243
  if (url) {
1243
- bodyParams.url = url;
1244
+ bodyParams.url = helpers.truncateString(url, MAX_URL_LENGTH);
1244
1245
  }
1245
1246
  if (podId) {
1246
1247
  bodyParams.pod_id = podId;
@@ -1494,7 +1495,7 @@ var Tracker = /*#__PURE__*/function () {
1494
1495
  bodyParams.selected_filters = selectedFilters;
1495
1496
  }
1496
1497
  if (url) {
1497
- bodyParams.url = url;
1498
+ bodyParams.url = helpers.truncateString(url, MAX_URL_LENGTH);
1498
1499
  }
1499
1500
  if (sortOrder) {
1500
1501
  bodyParams.sort_order = sortOrder;
@@ -1926,7 +1927,7 @@ var Tracker = /*#__PURE__*/function () {
1926
1927
  bodyParams.quiz_id = quizId;
1927
1928
  bodyParams.quiz_version_id = quizVersionId;
1928
1929
  bodyParams.quiz_session_id = quizSessionId;
1929
- bodyParams.url = url;
1930
+ bodyParams.url = helpers.truncateString(url, MAX_URL_LENGTH);
1930
1931
  if (!helpers.isNil(section)) {
1931
1932
  if (typeof section !== 'string') {
1932
1933
  return new Error('"section" must be a string');
@@ -2601,6 +2602,504 @@ var Tracker = /*#__PURE__*/function () {
2601
2602
  return new Error('parameters is a required parameter of type object');
2602
2603
  }
2603
2604
 
2605
+ /**
2606
+ * Send product insights agent view events
2607
+ *
2608
+ * @function trackProductInsightsAgentViews
2609
+ * @param {object} parameters - Additional parameters to be sent with request
2610
+ * @param {array.<{question: string}>} parameters.questions - List of pre-defined questions shown to the user
2611
+ * @param {string} parameters.itemId - Product id whose page we are on
2612
+ * @param {string} parameters.itemName - Product name whose page we are on
2613
+ * @param {array.<{start: string | undefined,
2614
+ * end: string | undefined}>} parameters.viewTimespans - List of timestamp pairs in ISO_8601 format
2615
+ * @param {string} [parameters.variationId] - Variation id whose page we are on
2616
+ * @param {string} [parameters.section] - The section name for the item Ex. "Products"
2617
+ * @param {object} [networkParameters] - Parameters relevant to the network request
2618
+ * @param {number} [networkParameters.timeout] - Request timeout (in milliseconds)
2619
+ * @returns {(true|Error)}
2620
+ * @description The product insights agent element appeared in the visible part of the page
2621
+ * @example
2622
+ * constructorio.tracker.trackProductInsightsAgentViews({
2623
+ * {
2624
+ * 'itemId': '1',
2625
+ * 'itemName': 'item1',
2626
+ * 'variationId': '2',
2627
+ * 'questions': [
2628
+ * { question: 'Why choose this?' },
2629
+ * { question: 'How is this product made?' },
2630
+ * { question: 'What are the dimensions of this product?' }
2631
+ * ],
2632
+ * 'viewTimespans': [
2633
+ * {
2634
+ * 'start': '2025-05-19T14:30:00+02:00',
2635
+ * 'end': '2025-05-19T14:30:05+02:00'
2636
+ * },
2637
+ * {
2638
+ * 'start': '2025-05-19T14:30:10+02:00',
2639
+ * 'end': '2025-05-19T14:30:15+02:00'
2640
+ * }
2641
+ * ]
2642
+ * },
2643
+ * );
2644
+ */
2645
+ }, {
2646
+ key: "trackProductInsightsAgentViews",
2647
+ value: function trackProductInsightsAgentViews(parameters) {
2648
+ var networkParameters = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
2649
+ // Ensure parameters are provided (required)
2650
+ if (parameters && (0, _typeof2["default"])(parameters) === 'object' && !Array.isArray(parameters)) {
2651
+ var baseUrl = "".concat(this.options.serviceUrl, "/v2/behavioral_action/product_insights_agent_views?");
2652
+ var section = parameters.section,
2653
+ questions = parameters.questions,
2654
+ itemId = parameters.itemId,
2655
+ itemName = parameters.itemName,
2656
+ variationId = parameters.variationId,
2657
+ viewTimespans = parameters.viewTimespans;
2658
+ var queryParams = {};
2659
+ var bodyParams = {
2660
+ questions: questions,
2661
+ item_id: itemId,
2662
+ item_name: itemName,
2663
+ variation_id: variationId,
2664
+ view_timespans: viewTimespans
2665
+ };
2666
+ if (section) {
2667
+ queryParams.section = section;
2668
+ }
2669
+ var requestURL = "".concat(baseUrl).concat(applyParamsAsString(queryParams, this.options));
2670
+ var requestMethod = 'POST';
2671
+ var requestBody = applyParams(bodyParams, _objectSpread(_objectSpread({}, this.options), {}, {
2672
+ requestMethod: requestMethod
2673
+ }));
2674
+ this.requests.queue(requestURL, requestMethod, requestBody, networkParameters);
2675
+ this.requests.send();
2676
+ return true;
2677
+ }
2678
+ this.requests.send();
2679
+ return new Error('parameters is a required parameter of type object');
2680
+ }
2681
+
2682
+ /**
2683
+ * Send product insights agent view event
2684
+ *
2685
+ * @function trackProductInsightsAgentView
2686
+ * @param {object} parameters - Additional parameters to be sent with request
2687
+ * @param {array.<{question: string}>} parameters.questions - List of pre-defined questions shown to the user
2688
+ * @param {string} parameters.itemId - Product id whose page we are on
2689
+ * @param {string} parameters.itemName - Product name whose page we are on
2690
+ * @param {string} [parameters.variationId] - Variation id whose page we are on
2691
+ * @param {string} [parameters.section] - The section name for the item Ex. "Products"
2692
+ * @param {object} [networkParameters] - Parameters relevant to the network request
2693
+ * @param {number} [networkParameters.timeout] - Request timeout (in milliseconds)
2694
+ * @returns {(true|Error)}
2695
+ * @description The product insights agent element appeared in the visible part of the page
2696
+ * @example
2697
+ * constructorio.tracker.trackProductInsightsAgentView({
2698
+ * {
2699
+ * 'itemId': '1',
2700
+ * 'itemName': 'item1',
2701
+ * 'variationId': '2',
2702
+ * 'questions': [
2703
+ * { question: 'Why choose this?' },
2704
+ * { question: 'How is this product made?' },
2705
+ * { question: 'What are the dimensions of this product?' }
2706
+ * ],
2707
+ * },
2708
+ * );
2709
+ */
2710
+ }, {
2711
+ key: "trackProductInsightsAgentView",
2712
+ value: function trackProductInsightsAgentView(parameters) {
2713
+ var networkParameters = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
2714
+ // Ensure parameters are provided (required)
2715
+ if (parameters && (0, _typeof2["default"])(parameters) === 'object' && !Array.isArray(parameters)) {
2716
+ var baseUrl = "".concat(this.options.serviceUrl, "/v2/behavioral_action/product_insights_agent_view?");
2717
+ var section = parameters.section,
2718
+ questions = parameters.questions,
2719
+ itemId = parameters.itemId,
2720
+ itemName = parameters.itemName,
2721
+ variationId = parameters.variationId;
2722
+ var queryParams = {};
2723
+ var bodyParams = {
2724
+ questions: questions,
2725
+ item_id: itemId,
2726
+ item_name: itemName,
2727
+ variation_id: variationId
2728
+ };
2729
+ if (section) {
2730
+ queryParams.section = section;
2731
+ }
2732
+ var requestURL = "".concat(baseUrl).concat(applyParamsAsString(queryParams, this.options));
2733
+ var requestMethod = 'POST';
2734
+ var requestBody = applyParams(bodyParams, _objectSpread(_objectSpread({}, this.options), {}, {
2735
+ requestMethod: requestMethod
2736
+ }));
2737
+ this.requests.queue(requestURL, requestMethod, requestBody, networkParameters);
2738
+ this.requests.send();
2739
+ return true;
2740
+ }
2741
+ this.requests.send();
2742
+ return new Error('parameters is a required parameter of type object');
2743
+ }
2744
+
2745
+ /**
2746
+ * Send product insights agent out of view event
2747
+ *
2748
+ * @function trackProductInsightsAgentOutOfView
2749
+ * @param {object} parameters - Additional parameters to be sent with request
2750
+ * @param {string} parameters.itemId - Product id whose page we are on
2751
+ * @param {string} parameters.itemName - Product name whose page we are on
2752
+ * @param {string} [parameters.variationId] - Variation id whose page we are on
2753
+ * @param {string} [parameters.section] - The section name for the item Ex. "Products"
2754
+ * @param {object} [networkParameters] - Parameters relevant to the network request
2755
+ * @param {number} [networkParameters.timeout] - Request timeout (in milliseconds)
2756
+ * @returns {(true|Error)}
2757
+ * @description The product insights agent element disappeared from the visible part of the page
2758
+ * @example
2759
+ * constructorio.tracker.trackProductInsightsAgentOutOfView({
2760
+ * {
2761
+ * 'itemId': '1',
2762
+ * 'itemName': 'item1',
2763
+ * 'variationId': '2',
2764
+ * },
2765
+ * );
2766
+ */
2767
+ }, {
2768
+ key: "trackProductInsightsAgentOutOfView",
2769
+ value: function trackProductInsightsAgentOutOfView(parameters) {
2770
+ var networkParameters = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
2771
+ // Ensure parameters are provided (required)
2772
+ if (parameters && (0, _typeof2["default"])(parameters) === 'object' && !Array.isArray(parameters)) {
2773
+ var baseUrl = "".concat(this.options.serviceUrl, "/v2/behavioral_action/product_insights_agent_out_of_view?");
2774
+ var section = parameters.section,
2775
+ itemId = parameters.itemId,
2776
+ itemName = parameters.itemName,
2777
+ variationId = parameters.variationId;
2778
+ var queryParams = {};
2779
+ var bodyParams = {
2780
+ item_id: itemId,
2781
+ item_name: itemName,
2782
+ variation_id: variationId
2783
+ };
2784
+ if (section) {
2785
+ queryParams.section = section;
2786
+ }
2787
+ var requestURL = "".concat(baseUrl).concat(applyParamsAsString(queryParams, this.options));
2788
+ var requestMethod = 'POST';
2789
+ var requestBody = applyParams(bodyParams, _objectSpread(_objectSpread({}, this.options), {}, {
2790
+ requestMethod: requestMethod
2791
+ }));
2792
+ this.requests.queue(requestURL, requestMethod, requestBody, networkParameters);
2793
+ this.requests.send();
2794
+ return true;
2795
+ }
2796
+ this.requests.send();
2797
+ return new Error('parameters is a required parameter of type object');
2798
+ }
2799
+
2800
+ /**
2801
+ * Send product insights agent input focus event
2802
+ *
2803
+ * @function trackProductInsightsAgentFocus
2804
+ * @param {object} parameters - Additional parameters to be sent with request
2805
+ * @param {string} parameters.itemId - Product id whose page we are on
2806
+ * @param {string} parameters.itemName - Product name whose page we are on
2807
+ * @param {string} [parameters.variationId] - Variation id whose page we are on
2808
+ * @param {string} [parameters.section] - The section name for the item Ex. "Products"
2809
+ * @param {object} [networkParameters] - Parameters relevant to the network request
2810
+ * @param {number} [networkParameters.timeout] - Request timeout (in milliseconds)
2811
+ * @returns {(true|Error)}
2812
+ * @description User focused on the product insights agent input element
2813
+ * @example
2814
+ * constructorio.tracker.trackProductInsightsAgentFocus({
2815
+ * {
2816
+ * 'itemId': '1',
2817
+ * 'itemName': 'item1',
2818
+ * 'variationId': '2',
2819
+ * },
2820
+ * );
2821
+ */
2822
+ }, {
2823
+ key: "trackProductInsightsAgentFocus",
2824
+ value: function trackProductInsightsAgentFocus(parameters) {
2825
+ var networkParameters = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
2826
+ // Ensure parameters are provided (required)
2827
+ if (parameters && (0, _typeof2["default"])(parameters) === 'object' && !Array.isArray(parameters)) {
2828
+ var baseUrl = "".concat(this.options.serviceUrl, "/v2/behavioral_action/product_insights_agent_focus?");
2829
+ var section = parameters.section,
2830
+ itemId = parameters.itemId,
2831
+ itemName = parameters.itemName,
2832
+ variationId = parameters.variationId;
2833
+ var queryParams = {};
2834
+ var bodyParams = {
2835
+ item_id: itemId,
2836
+ item_name: itemName,
2837
+ variation_id: variationId
2838
+ };
2839
+ if (section) {
2840
+ queryParams.section = section;
2841
+ }
2842
+ var requestURL = "".concat(baseUrl).concat(applyParamsAsString(queryParams, this.options));
2843
+ var requestMethod = 'POST';
2844
+ var requestBody = applyParams(bodyParams, _objectSpread(_objectSpread({}, this.options), {}, {
2845
+ requestMethod: requestMethod
2846
+ }));
2847
+ this.requests.queue(requestURL, requestMethod, requestBody, networkParameters);
2848
+ this.requests.send();
2849
+ return true;
2850
+ }
2851
+ this.requests.send();
2852
+ return new Error('parameters is a required parameter of type object');
2853
+ }
2854
+
2855
+ /**
2856
+ * Send product insights agent question click event
2857
+ *
2858
+ * @function trackProductInsightsAgentQuestionClick
2859
+ * @param {object} parameters - Additional parameters to be sent with request
2860
+ * @param {string} parameters.itemId - Product id whose page we are on
2861
+ * @param {string} parameters.itemName - Product name whose page we are on
2862
+ * @param {string} parameters.question - Question a user clicked on
2863
+ * @param {string} [parameters.variationId] - Variation id whose page we are on
2864
+ * @param {string} [parameters.section] - The section name for the item Ex. "Products"
2865
+ * @param {object} [networkParameters] - Parameters relevant to the network request
2866
+ * @param {number} [networkParameters.timeout] - Request timeout (in milliseconds)
2867
+ * @returns {(true|Error)}
2868
+ * @description User clicked on a question within the product insights agent
2869
+ * @example
2870
+ * constructorio.tracker.trackProductInsightsAgentQuestionClick({
2871
+ * {
2872
+ * 'itemId': '1',
2873
+ * 'itemName': 'item1',
2874
+ * 'variationId': '2',
2875
+ * 'question': 'Why choose this?'
2876
+ * },
2877
+ * );
2878
+ */
2879
+ }, {
2880
+ key: "trackProductInsightsAgentQuestionClick",
2881
+ value: function trackProductInsightsAgentQuestionClick(parameters) {
2882
+ var networkParameters = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
2883
+ // Ensure parameters are provided (required)
2884
+ if (parameters && (0, _typeof2["default"])(parameters) === 'object' && !Array.isArray(parameters)) {
2885
+ var baseUrl = "".concat(this.options.serviceUrl, "/v2/behavioral_action/product_insights_agent_question_click?");
2886
+ var section = parameters.section,
2887
+ itemId = parameters.itemId,
2888
+ itemName = parameters.itemName,
2889
+ variationId = parameters.variationId,
2890
+ question = parameters.question;
2891
+ var queryParams = {};
2892
+ var bodyParams = {
2893
+ item_id: itemId,
2894
+ item_name: itemName,
2895
+ variation_id: variationId,
2896
+ question: question
2897
+ };
2898
+ if (section) {
2899
+ queryParams.section = section;
2900
+ }
2901
+ var requestURL = "".concat(baseUrl).concat(applyParamsAsString(queryParams, this.options));
2902
+ var requestMethod = 'POST';
2903
+ var requestBody = applyParams(bodyParams, _objectSpread(_objectSpread({}, this.options), {}, {
2904
+ requestMethod: requestMethod
2905
+ }));
2906
+ this.requests.queue(requestURL, requestMethod, requestBody, networkParameters);
2907
+ this.requests.send();
2908
+ return true;
2909
+ }
2910
+ this.requests.send();
2911
+ return new Error('parameters is a required parameter of type object');
2912
+ }
2913
+
2914
+ /**
2915
+ * Send product insights agent question submit event
2916
+ *
2917
+ * @function trackProductInsightsAgentQuestionSubmit
2918
+ * @param {object} parameters - Additional parameters to be sent with request
2919
+ * @param {string} parameters.itemId - Product id whose page we are on
2920
+ * @param {string} parameters.itemName - Product name whose page we are on
2921
+ * @param {string} parameters.question - Question a user submitted
2922
+ * @param {string} [parameters.variationId] - Variation id whose page we are on
2923
+ * @param {string} [parameters.section] - The section name for the item Ex. "Products"
2924
+ * @param {object} [networkParameters] - Parameters relevant to the network request
2925
+ * @param {number} [networkParameters.timeout] - Request timeout (in milliseconds)
2926
+ * @returns {(true|Error)}
2927
+ * @description User submitted a question to the product insights agent
2928
+ * @example
2929
+ * constructorio.tracker.trackProductInsightsAgentQuestionSubmit({
2930
+ * {
2931
+ * 'itemId': '1',
2932
+ * 'itemName': 'item1',
2933
+ * 'variationId': '2',
2934
+ * 'question': 'Tell me some key highlights about this item?'
2935
+ * },
2936
+ * );
2937
+ */
2938
+ }, {
2939
+ key: "trackProductInsightsAgentQuestionSubmit",
2940
+ value: function trackProductInsightsAgentQuestionSubmit(parameters) {
2941
+ var networkParameters = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
2942
+ // Ensure parameters are provided (required)
2943
+ if (parameters && (0, _typeof2["default"])(parameters) === 'object' && !Array.isArray(parameters)) {
2944
+ var baseUrl = "".concat(this.options.serviceUrl, "/v2/behavioral_action/product_insights_agent_question_submit?");
2945
+ var section = parameters.section,
2946
+ itemId = parameters.itemId,
2947
+ itemName = parameters.itemName,
2948
+ variationId = parameters.variationId,
2949
+ question = parameters.question;
2950
+ var queryParams = {};
2951
+ var bodyParams = {
2952
+ item_id: itemId,
2953
+ item_name: itemName,
2954
+ variation_id: variationId,
2955
+ question: question
2956
+ };
2957
+ if (section) {
2958
+ queryParams.section = section;
2959
+ }
2960
+ var requestURL = "".concat(baseUrl).concat(applyParamsAsString(queryParams, this.options));
2961
+ var requestMethod = 'POST';
2962
+ var requestBody = applyParams(bodyParams, _objectSpread(_objectSpread({}, this.options), {}, {
2963
+ requestMethod: requestMethod
2964
+ }));
2965
+ this.requests.queue(requestURL, requestMethod, requestBody, networkParameters);
2966
+ this.requests.send();
2967
+ return true;
2968
+ }
2969
+ this.requests.send();
2970
+ return new Error('parameters is a required parameter of type object');
2971
+ }
2972
+
2973
+ /**
2974
+ * Send product insights agent answer view event
2975
+ *
2976
+ * @function trackProductInsightsAgentAnswerView
2977
+ * @param {object} parameters - Additional parameters to be sent with request
2978
+ * @param {string} parameters.itemId - Product id whose page we are on
2979
+ * @param {string} parameters.itemName - Product name whose page we are on
2980
+ * @param {string} parameters.question - Question a user submitted
2981
+ * @param {string} parameters.answerText - Answer text of the question
2982
+ * @param {string} [parameters.qnaResultId] - Answer result id returned
2983
+ * @param {string} [parameters.variationId] - Variation id whose page we are on
2984
+ * @param {string} [parameters.section] - The section name for the item Ex. "Products"
2985
+ * @param {object} [networkParameters] - Parameters relevant to the network request
2986
+ * @param {number} [networkParameters.timeout] - Request timeout (in milliseconds)
2987
+ * @returns {(true|Error)}
2988
+ * @description User viewed the answer provided by the product insights agent
2989
+ * @example
2990
+ * constructorio.tracker.trackProductInsightsAgentAnswerView({
2991
+ * {
2992
+ * 'itemId': '1',
2993
+ * 'itemName': 'item1',
2994
+ * 'variationId': '2',
2995
+ * 'question': 'Why choose this?',
2996
+ * 'answerText': 'This product is awesome!',
2997
+ * 'qnaResultId': '0daf0015-fc29-4727-9140-8d5313a1902c',
2998
+ * },
2999
+ * );
3000
+ */
3001
+ }, {
3002
+ key: "trackProductInsightsAgentAnswerView",
3003
+ value: function trackProductInsightsAgentAnswerView(parameters) {
3004
+ var networkParameters = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
3005
+ // Ensure parameters are provided (required)
3006
+ if (parameters && (0, _typeof2["default"])(parameters) === 'object' && !Array.isArray(parameters)) {
3007
+ var baseUrl = "".concat(this.options.serviceUrl, "/v2/behavioral_action/product_insights_agent_answer_view?");
3008
+ var section = parameters.section,
3009
+ itemId = parameters.itemId,
3010
+ itemName = parameters.itemName,
3011
+ variationId = parameters.variationId,
3012
+ question = parameters.question,
3013
+ answerText = parameters.answerText,
3014
+ qnaResultId = parameters.qnaResultId;
3015
+ var queryParams = {};
3016
+ var bodyParams = {
3017
+ item_id: itemId,
3018
+ item_name: itemName,
3019
+ variation_id: variationId,
3020
+ question: question,
3021
+ answer_text: answerText,
3022
+ qna_result_id: qnaResultId
3023
+ };
3024
+ if (section) {
3025
+ queryParams.section = section;
3026
+ }
3027
+ var requestURL = "".concat(baseUrl).concat(applyParamsAsString(queryParams, this.options));
3028
+ var requestMethod = 'POST';
3029
+ var requestBody = applyParams(bodyParams, _objectSpread(_objectSpread({}, this.options), {}, {
3030
+ requestMethod: requestMethod
3031
+ }));
3032
+ this.requests.queue(requestURL, requestMethod, requestBody, networkParameters);
3033
+ this.requests.send();
3034
+ return true;
3035
+ }
3036
+ this.requests.send();
3037
+ return new Error('parameters is a required parameter of type object');
3038
+ }
3039
+
3040
+ /**
3041
+ * Send product insights agent answer feedback event
3042
+ *
3043
+ * @function trackProductInsightsAgentAnswerFeedback
3044
+ * @param {object} parameters - Additional parameters to be sent with request
3045
+ * @param {string} parameters.itemId - Product id whose page we are on
3046
+ * @param {string} parameters.itemName - Product name whose page we are on
3047
+ * @param {string} parameters.feedbackLabel - Feedback value: either "thumbs_up" or "thumbs_down"
3048
+ * @param {string} [parameters.qnaResultId] - Answer result id returned
3049
+ * @param {string} [parameters.variationId] - Variation id whose page we are on
3050
+ * @param {string} [parameters.section] - The section name for the item Ex. "Products"
3051
+ * @param {object} [networkParameters] - Parameters relevant to the network request
3052
+ * @param {number} [networkParameters.timeout] - Request timeout (in milliseconds)
3053
+ * @returns {(true|Error)}
3054
+ * @description A user provided feedback on an answers usefulness
3055
+ * @example
3056
+ * constructorio.tracker.trackProductInsightsAgentAnswerFeedback({
3057
+ * {
3058
+ * 'itemId': '1',
3059
+ * 'itemName': 'item1',
3060
+ * 'variationId': '2',
3061
+ * 'feedbackLabel': 'thumbs_up',
3062
+ * 'qnaResultId': '0daf0015-fc29-4727-9140-8d5313a1902c',
3063
+ * },
3064
+ * );
3065
+ */
3066
+ }, {
3067
+ key: "trackProductInsightsAgentAnswerFeedback",
3068
+ value: function trackProductInsightsAgentAnswerFeedback(parameters) {
3069
+ var networkParameters = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
3070
+ // Ensure parameters are provided (required)
3071
+ if (parameters && (0, _typeof2["default"])(parameters) === 'object' && !Array.isArray(parameters)) {
3072
+ var baseUrl = "".concat(this.options.serviceUrl, "/v2/behavioral_action/product_insights_agent_answer_feedback?");
3073
+ var section = parameters.section,
3074
+ itemId = parameters.itemId,
3075
+ itemName = parameters.itemName,
3076
+ variationId = parameters.variationId,
3077
+ feedbackLabel = parameters.feedbackLabel,
3078
+ qnaResultId = parameters.qnaResultId;
3079
+ var queryParams = {};
3080
+ var bodyParams = {
3081
+ item_id: itemId,
3082
+ item_name: itemName,
3083
+ variation_id: variationId,
3084
+ feedback_label: feedbackLabel,
3085
+ qna_result_id: qnaResultId
3086
+ };
3087
+ if (section) {
3088
+ queryParams.section = section;
3089
+ }
3090
+ var requestURL = "".concat(baseUrl).concat(applyParamsAsString(queryParams, this.options));
3091
+ var requestMethod = 'POST';
3092
+ var requestBody = applyParams(bodyParams, _objectSpread(_objectSpread({}, this.options), {}, {
3093
+ requestMethod: requestMethod
3094
+ }));
3095
+ this.requests.queue(requestURL, requestMethod, requestBody, networkParameters);
3096
+ this.requests.send();
3097
+ return true;
3098
+ }
3099
+ this.requests.send();
3100
+ return new Error('parameters is a required parameter of type object');
3101
+ }
3102
+
2604
3103
  /**
2605
3104
  * Subscribe to success or error messages emitted by tracking requests
2606
3105
  *
@@ -246,3 +246,12 @@ export interface ItemTracked {
246
246
  export interface ItemTrackedPurchase extends ItemTracked {
247
247
  count?: number;
248
248
  }
249
+
250
+ export interface Question {
251
+ question: string;
252
+ }
253
+
254
+ export interface TimeSpan {
255
+ start: string;
256
+ end: string;
257
+ }
@@ -1,5 +1,5 @@
1
1
  import EventEmitter = require('events');
2
- import { ConstructorClientOptions, ItemTracked, ItemTrackedPurchase, NetworkParameters } from '.';
2
+ import { ConstructorClientOptions, ItemTracked, ItemTrackedPurchase, Question, TimeSpan, NetworkParameters } from '.';
3
3
  import RequestQueue = require('../utils/request-queue');
4
4
 
5
5
  export default Tracker;
@@ -331,5 +331,71 @@ declare class Tracker {
331
331
  networkParameters?: NetworkParameters
332
332
  ): true | Error;
333
333
 
334
+ trackProductInsightsAgentViews(parameters: {
335
+ questions: Question[];
336
+ itemId: string;
337
+ itemName: string;
338
+ viewTimespans: TimeSpan[];
339
+ variationId?: string;
340
+ section?: string;
341
+ }, networkParameters?: NetworkParameters): true | Error;
342
+
343
+ trackProductInsightsAgentView(parameters: {
344
+ questions: Question[];
345
+ itemId: string;
346
+ itemName: string;
347
+ variationId?: string;
348
+ section?: string;
349
+ }, networkParameters?: NetworkParameters): true | Error;
350
+
351
+ trackProductInsightsAgentOutOfView(parameters: {
352
+ itemId: string;
353
+ itemName: string;
354
+ variationId?: string;
355
+ section?: string;
356
+ }, networkParameters?: NetworkParameters): true | Error;
357
+
358
+ trackProductInsightsAgentFocus(parameters: {
359
+ itemId: string;
360
+ itemName: string;
361
+ variationId?: string;
362
+ section?: string;
363
+ }, networkParameters?: NetworkParameters): true | Error;
364
+
365
+ trackProductInsightsAgentQuestionClick(parameters: {
366
+ itemId: string;
367
+ itemName: string;
368
+ question: string;
369
+ variationId?: string;
370
+ section?: string;
371
+ }, networkParameters?: NetworkParameters): true | Error;
372
+
373
+ trackProductInsightsAgentQuestionSubmit(parameters: {
374
+ itemId: string;
375
+ itemName: string;
376
+ question: string;
377
+ variationId?: string;
378
+ section?: string;
379
+ }, networkParameters?: NetworkParameters): true | Error;
380
+
381
+ trackProductInsightsAgentAnswerView(parameters: {
382
+ itemId: string;
383
+ itemName: string;
384
+ question: string;
385
+ answerText: string;
386
+ qnaResultId?: string;
387
+ variationId?: string;
388
+ section?: string;
389
+ }, networkParameters?: NetworkParameters): true | Error;
390
+
391
+ trackProductInsightsAgentAnswerFeedback(parameters: {
392
+ itemId: string;
393
+ itemName: string;
394
+ feedbackLabel: string;
395
+ qnaResultId?: string;
396
+ variationId?: string;
397
+ section?: string;
398
+ }, networkParameters?: NetworkParameters): true | Error;
399
+
334
400
  on(messageType: string, callback: Function): true | Error;
335
401
  }
@@ -261,6 +261,9 @@ var utils = {
261
261
  return urlWithHttps;
262
262
  }
263
263
  return url;
264
+ },
265
+ truncateString: function truncateString(string, maxLength) {
266
+ return string.slice(0, maxLength);
264
267
  }
265
268
  };
266
269
  module.exports = utils;
package/lib/version.js CHANGED
@@ -4,5 +4,5 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports["default"] = void 0;
7
- var _default = '2.65.1';
7
+ var _default = '2.66.1';
8
8
  exports["default"] = _default;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@constructor-io/constructorio-client-javascript",
3
- "version": "2.65.1",
3
+ "version": "2.66.1",
4
4
  "description": "Constructor.io JavaScript client",
5
5
  "main": "lib/constructorio.js",
6
6
  "types": "lib/types/index.d.ts",