@constructor-io/constructorio-client-javascript 2.65.0 → 2.66.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/README.md +1 -1
- package/lib/modules/quizzes.js +1 -1
- package/lib/modules/tracker.js +498 -0
- package/lib/types/index.d.ts +9 -0
- package/lib/types/quizzes.d.ts +7 -1
- package/lib/types/tracker.d.ts +67 -1
- package/lib/version.js +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -21,7 +21,7 @@ Alternatively, a bundled version consisting of a single JavaScript file is publi
|
|
|
21
21
|
|
|
22
22
|
## 2. Retrieve an API key
|
|
23
23
|
|
|
24
|
-
You can find this in your [Constructor.io dashboard](https://constructor.io/dashboard). Contact sales if you'd like to sign up, or support if you believe your company already has an account.
|
|
24
|
+
You can find this in your [Constructor.io dashboard](https://app.constructor.io/dashboard). Contact sales if you'd like to sign up, or support if you believe your company already has an account.
|
|
25
25
|
|
|
26
26
|
## 3. Implement the Client
|
|
27
27
|
|
package/lib/modules/quizzes.js
CHANGED
|
@@ -75,7 +75,7 @@ function createQuizUrl(quizId, parameters, options, path) {
|
|
|
75
75
|
if (answers && answers.length) {
|
|
76
76
|
answersParamString = "&".concat(helpers.stringify({
|
|
77
77
|
a: answers.map(function (ans) {
|
|
78
|
-
return (0, _toConsumableArray2["default"])(ans).join(',');
|
|
78
|
+
return (0, _toConsumableArray2["default"])(ans.map(encodeURIComponent)).join(',');
|
|
79
79
|
})
|
|
80
80
|
}));
|
|
81
81
|
}
|
package/lib/modules/tracker.js
CHANGED
|
@@ -2601,6 +2601,504 @@ var Tracker = /*#__PURE__*/function () {
|
|
|
2601
2601
|
return new Error('parameters is a required parameter of type object');
|
|
2602
2602
|
}
|
|
2603
2603
|
|
|
2604
|
+
/**
|
|
2605
|
+
* Send product insights agent view events
|
|
2606
|
+
*
|
|
2607
|
+
* @function trackProductInsightsAgentViews
|
|
2608
|
+
* @param {object} parameters - Additional parameters to be sent with request
|
|
2609
|
+
* @param {array.<{question: string}>} parameters.questions - List of pre-defined questions shown to the user
|
|
2610
|
+
* @param {string} parameters.itemId - Product id whose page we are on
|
|
2611
|
+
* @param {string} parameters.itemName - Product name whose page we are on
|
|
2612
|
+
* @param {array.<{start: string | undefined,
|
|
2613
|
+
* end: string | undefined}>} parameters.viewTimespans - List of timestamp pairs in ISO_8601 format
|
|
2614
|
+
* @param {string} [parameters.variationId] - Variation id whose page we are on
|
|
2615
|
+
* @param {string} [parameters.section] - The section name for the item Ex. "Products"
|
|
2616
|
+
* @param {object} [networkParameters] - Parameters relevant to the network request
|
|
2617
|
+
* @param {number} [networkParameters.timeout] - Request timeout (in milliseconds)
|
|
2618
|
+
* @returns {(true|Error)}
|
|
2619
|
+
* @description The product insights agent element appeared in the visible part of the page
|
|
2620
|
+
* @example
|
|
2621
|
+
* constructorio.tracker.trackProductInsightsAgentViews({
|
|
2622
|
+
* {
|
|
2623
|
+
* 'itemId': '1',
|
|
2624
|
+
* 'itemName': 'item1',
|
|
2625
|
+
* 'variationId': '2',
|
|
2626
|
+
* 'questions': [
|
|
2627
|
+
* { question: 'Why choose this?' },
|
|
2628
|
+
* { question: 'How is this product made?' },
|
|
2629
|
+
* { question: 'What are the dimensions of this product?' }
|
|
2630
|
+
* ],
|
|
2631
|
+
* 'viewTimespans': [
|
|
2632
|
+
* {
|
|
2633
|
+
* 'start': '2025-05-19T14:30:00+02:00',
|
|
2634
|
+
* 'end': '2025-05-19T14:30:05+02:00'
|
|
2635
|
+
* },
|
|
2636
|
+
* {
|
|
2637
|
+
* 'start': '2025-05-19T14:30:10+02:00',
|
|
2638
|
+
* 'end': '2025-05-19T14:30:15+02:00'
|
|
2639
|
+
* }
|
|
2640
|
+
* ]
|
|
2641
|
+
* },
|
|
2642
|
+
* );
|
|
2643
|
+
*/
|
|
2644
|
+
}, {
|
|
2645
|
+
key: "trackProductInsightsAgentViews",
|
|
2646
|
+
value: function trackProductInsightsAgentViews(parameters) {
|
|
2647
|
+
var networkParameters = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
|
2648
|
+
// Ensure parameters are provided (required)
|
|
2649
|
+
if (parameters && (0, _typeof2["default"])(parameters) === 'object' && !Array.isArray(parameters)) {
|
|
2650
|
+
var baseUrl = "".concat(this.options.serviceUrl, "/v2/behavioral_action/product_insights_agent_views?");
|
|
2651
|
+
var section = parameters.section,
|
|
2652
|
+
questions = parameters.questions,
|
|
2653
|
+
itemId = parameters.itemId,
|
|
2654
|
+
itemName = parameters.itemName,
|
|
2655
|
+
variationId = parameters.variationId,
|
|
2656
|
+
viewTimespans = parameters.viewTimespans;
|
|
2657
|
+
var queryParams = {};
|
|
2658
|
+
var bodyParams = {
|
|
2659
|
+
questions: questions,
|
|
2660
|
+
item_id: itemId,
|
|
2661
|
+
item_name: itemName,
|
|
2662
|
+
variation_id: variationId,
|
|
2663
|
+
view_timespans: viewTimespans
|
|
2664
|
+
};
|
|
2665
|
+
if (section) {
|
|
2666
|
+
queryParams.section = section;
|
|
2667
|
+
}
|
|
2668
|
+
var requestURL = "".concat(baseUrl).concat(applyParamsAsString(queryParams, this.options));
|
|
2669
|
+
var requestMethod = 'POST';
|
|
2670
|
+
var requestBody = applyParams(bodyParams, _objectSpread(_objectSpread({}, this.options), {}, {
|
|
2671
|
+
requestMethod: requestMethod
|
|
2672
|
+
}));
|
|
2673
|
+
this.requests.queue(requestURL, requestMethod, requestBody, networkParameters);
|
|
2674
|
+
this.requests.send();
|
|
2675
|
+
return true;
|
|
2676
|
+
}
|
|
2677
|
+
this.requests.send();
|
|
2678
|
+
return new Error('parameters is a required parameter of type object');
|
|
2679
|
+
}
|
|
2680
|
+
|
|
2681
|
+
/**
|
|
2682
|
+
* Send product insights agent view event
|
|
2683
|
+
*
|
|
2684
|
+
* @function trackProductInsightsAgentView
|
|
2685
|
+
* @param {object} parameters - Additional parameters to be sent with request
|
|
2686
|
+
* @param {array.<{question: string}>} parameters.questions - List of pre-defined questions shown to the user
|
|
2687
|
+
* @param {string} parameters.itemId - Product id whose page we are on
|
|
2688
|
+
* @param {string} parameters.itemName - Product name whose page we are on
|
|
2689
|
+
* @param {string} [parameters.variationId] - Variation id whose page we are on
|
|
2690
|
+
* @param {string} [parameters.section] - The section name for the item Ex. "Products"
|
|
2691
|
+
* @param {object} [networkParameters] - Parameters relevant to the network request
|
|
2692
|
+
* @param {number} [networkParameters.timeout] - Request timeout (in milliseconds)
|
|
2693
|
+
* @returns {(true|Error)}
|
|
2694
|
+
* @description The product insights agent element appeared in the visible part of the page
|
|
2695
|
+
* @example
|
|
2696
|
+
* constructorio.tracker.trackProductInsightsAgentView({
|
|
2697
|
+
* {
|
|
2698
|
+
* 'itemId': '1',
|
|
2699
|
+
* 'itemName': 'item1',
|
|
2700
|
+
* 'variationId': '2',
|
|
2701
|
+
* 'questions': [
|
|
2702
|
+
* { question: 'Why choose this?' },
|
|
2703
|
+
* { question: 'How is this product made?' },
|
|
2704
|
+
* { question: 'What are the dimensions of this product?' }
|
|
2705
|
+
* ],
|
|
2706
|
+
* },
|
|
2707
|
+
* );
|
|
2708
|
+
*/
|
|
2709
|
+
}, {
|
|
2710
|
+
key: "trackProductInsightsAgentView",
|
|
2711
|
+
value: function trackProductInsightsAgentView(parameters) {
|
|
2712
|
+
var networkParameters = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
|
2713
|
+
// Ensure parameters are provided (required)
|
|
2714
|
+
if (parameters && (0, _typeof2["default"])(parameters) === 'object' && !Array.isArray(parameters)) {
|
|
2715
|
+
var baseUrl = "".concat(this.options.serviceUrl, "/v2/behavioral_action/product_insights_agent_view?");
|
|
2716
|
+
var section = parameters.section,
|
|
2717
|
+
questions = parameters.questions,
|
|
2718
|
+
itemId = parameters.itemId,
|
|
2719
|
+
itemName = parameters.itemName,
|
|
2720
|
+
variationId = parameters.variationId;
|
|
2721
|
+
var queryParams = {};
|
|
2722
|
+
var bodyParams = {
|
|
2723
|
+
questions: questions,
|
|
2724
|
+
item_id: itemId,
|
|
2725
|
+
item_name: itemName,
|
|
2726
|
+
variation_id: variationId
|
|
2727
|
+
};
|
|
2728
|
+
if (section) {
|
|
2729
|
+
queryParams.section = section;
|
|
2730
|
+
}
|
|
2731
|
+
var requestURL = "".concat(baseUrl).concat(applyParamsAsString(queryParams, this.options));
|
|
2732
|
+
var requestMethod = 'POST';
|
|
2733
|
+
var requestBody = applyParams(bodyParams, _objectSpread(_objectSpread({}, this.options), {}, {
|
|
2734
|
+
requestMethod: requestMethod
|
|
2735
|
+
}));
|
|
2736
|
+
this.requests.queue(requestURL, requestMethod, requestBody, networkParameters);
|
|
2737
|
+
this.requests.send();
|
|
2738
|
+
return true;
|
|
2739
|
+
}
|
|
2740
|
+
this.requests.send();
|
|
2741
|
+
return new Error('parameters is a required parameter of type object');
|
|
2742
|
+
}
|
|
2743
|
+
|
|
2744
|
+
/**
|
|
2745
|
+
* Send product insights agent out of view event
|
|
2746
|
+
*
|
|
2747
|
+
* @function trackProductInsightsAgentOutOfView
|
|
2748
|
+
* @param {object} parameters - Additional parameters to be sent with request
|
|
2749
|
+
* @param {string} parameters.itemId - Product id whose page we are on
|
|
2750
|
+
* @param {string} parameters.itemName - Product name whose page we are on
|
|
2751
|
+
* @param {string} [parameters.variationId] - Variation id whose page we are on
|
|
2752
|
+
* @param {string} [parameters.section] - The section name for the item Ex. "Products"
|
|
2753
|
+
* @param {object} [networkParameters] - Parameters relevant to the network request
|
|
2754
|
+
* @param {number} [networkParameters.timeout] - Request timeout (in milliseconds)
|
|
2755
|
+
* @returns {(true|Error)}
|
|
2756
|
+
* @description The product insights agent element disappeared from the visible part of the page
|
|
2757
|
+
* @example
|
|
2758
|
+
* constructorio.tracker.trackProductInsightsAgentOutOfView({
|
|
2759
|
+
* {
|
|
2760
|
+
* 'itemId': '1',
|
|
2761
|
+
* 'itemName': 'item1',
|
|
2762
|
+
* 'variationId': '2',
|
|
2763
|
+
* },
|
|
2764
|
+
* );
|
|
2765
|
+
*/
|
|
2766
|
+
}, {
|
|
2767
|
+
key: "trackProductInsightsAgentOutOfView",
|
|
2768
|
+
value: function trackProductInsightsAgentOutOfView(parameters) {
|
|
2769
|
+
var networkParameters = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
|
2770
|
+
// Ensure parameters are provided (required)
|
|
2771
|
+
if (parameters && (0, _typeof2["default"])(parameters) === 'object' && !Array.isArray(parameters)) {
|
|
2772
|
+
var baseUrl = "".concat(this.options.serviceUrl, "/v2/behavioral_action/product_insights_agent_out_of_view?");
|
|
2773
|
+
var section = parameters.section,
|
|
2774
|
+
itemId = parameters.itemId,
|
|
2775
|
+
itemName = parameters.itemName,
|
|
2776
|
+
variationId = parameters.variationId;
|
|
2777
|
+
var queryParams = {};
|
|
2778
|
+
var bodyParams = {
|
|
2779
|
+
item_id: itemId,
|
|
2780
|
+
item_name: itemName,
|
|
2781
|
+
variation_id: variationId
|
|
2782
|
+
};
|
|
2783
|
+
if (section) {
|
|
2784
|
+
queryParams.section = section;
|
|
2785
|
+
}
|
|
2786
|
+
var requestURL = "".concat(baseUrl).concat(applyParamsAsString(queryParams, this.options));
|
|
2787
|
+
var requestMethod = 'POST';
|
|
2788
|
+
var requestBody = applyParams(bodyParams, _objectSpread(_objectSpread({}, this.options), {}, {
|
|
2789
|
+
requestMethod: requestMethod
|
|
2790
|
+
}));
|
|
2791
|
+
this.requests.queue(requestURL, requestMethod, requestBody, networkParameters);
|
|
2792
|
+
this.requests.send();
|
|
2793
|
+
return true;
|
|
2794
|
+
}
|
|
2795
|
+
this.requests.send();
|
|
2796
|
+
return new Error('parameters is a required parameter of type object');
|
|
2797
|
+
}
|
|
2798
|
+
|
|
2799
|
+
/**
|
|
2800
|
+
* Send product insights agent input focus event
|
|
2801
|
+
*
|
|
2802
|
+
* @function trackProductInsightsAgentFocus
|
|
2803
|
+
* @param {object} parameters - Additional parameters to be sent with request
|
|
2804
|
+
* @param {string} parameters.itemId - Product id whose page we are on
|
|
2805
|
+
* @param {string} parameters.itemName - Product name whose page we are on
|
|
2806
|
+
* @param {string} [parameters.variationId] - Variation id whose page we are on
|
|
2807
|
+
* @param {string} [parameters.section] - The section name for the item Ex. "Products"
|
|
2808
|
+
* @param {object} [networkParameters] - Parameters relevant to the network request
|
|
2809
|
+
* @param {number} [networkParameters.timeout] - Request timeout (in milliseconds)
|
|
2810
|
+
* @returns {(true|Error)}
|
|
2811
|
+
* @description User focused on the product insights agent input element
|
|
2812
|
+
* @example
|
|
2813
|
+
* constructorio.tracker.trackProductInsightsAgentFocus({
|
|
2814
|
+
* {
|
|
2815
|
+
* 'itemId': '1',
|
|
2816
|
+
* 'itemName': 'item1',
|
|
2817
|
+
* 'variationId': '2',
|
|
2818
|
+
* },
|
|
2819
|
+
* );
|
|
2820
|
+
*/
|
|
2821
|
+
}, {
|
|
2822
|
+
key: "trackProductInsightsAgentFocus",
|
|
2823
|
+
value: function trackProductInsightsAgentFocus(parameters) {
|
|
2824
|
+
var networkParameters = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
|
2825
|
+
// Ensure parameters are provided (required)
|
|
2826
|
+
if (parameters && (0, _typeof2["default"])(parameters) === 'object' && !Array.isArray(parameters)) {
|
|
2827
|
+
var baseUrl = "".concat(this.options.serviceUrl, "/v2/behavioral_action/product_insights_agent_focus?");
|
|
2828
|
+
var section = parameters.section,
|
|
2829
|
+
itemId = parameters.itemId,
|
|
2830
|
+
itemName = parameters.itemName,
|
|
2831
|
+
variationId = parameters.variationId;
|
|
2832
|
+
var queryParams = {};
|
|
2833
|
+
var bodyParams = {
|
|
2834
|
+
item_id: itemId,
|
|
2835
|
+
item_name: itemName,
|
|
2836
|
+
variation_id: variationId
|
|
2837
|
+
};
|
|
2838
|
+
if (section) {
|
|
2839
|
+
queryParams.section = section;
|
|
2840
|
+
}
|
|
2841
|
+
var requestURL = "".concat(baseUrl).concat(applyParamsAsString(queryParams, this.options));
|
|
2842
|
+
var requestMethod = 'POST';
|
|
2843
|
+
var requestBody = applyParams(bodyParams, _objectSpread(_objectSpread({}, this.options), {}, {
|
|
2844
|
+
requestMethod: requestMethod
|
|
2845
|
+
}));
|
|
2846
|
+
this.requests.queue(requestURL, requestMethod, requestBody, networkParameters);
|
|
2847
|
+
this.requests.send();
|
|
2848
|
+
return true;
|
|
2849
|
+
}
|
|
2850
|
+
this.requests.send();
|
|
2851
|
+
return new Error('parameters is a required parameter of type object');
|
|
2852
|
+
}
|
|
2853
|
+
|
|
2854
|
+
/**
|
|
2855
|
+
* Send product insights agent question click event
|
|
2856
|
+
*
|
|
2857
|
+
* @function trackProductInsightsAgentQuestionClick
|
|
2858
|
+
* @param {object} parameters - Additional parameters to be sent with request
|
|
2859
|
+
* @param {string} parameters.itemId - Product id whose page we are on
|
|
2860
|
+
* @param {string} parameters.itemName - Product name whose page we are on
|
|
2861
|
+
* @param {string} parameters.question - Question a user clicked on
|
|
2862
|
+
* @param {string} [parameters.variationId] - Variation id whose page we are on
|
|
2863
|
+
* @param {string} [parameters.section] - The section name for the item Ex. "Products"
|
|
2864
|
+
* @param {object} [networkParameters] - Parameters relevant to the network request
|
|
2865
|
+
* @param {number} [networkParameters.timeout] - Request timeout (in milliseconds)
|
|
2866
|
+
* @returns {(true|Error)}
|
|
2867
|
+
* @description User clicked on a question within the product insights agent
|
|
2868
|
+
* @example
|
|
2869
|
+
* constructorio.tracker.trackProductInsightsAgentQuestionClick({
|
|
2870
|
+
* {
|
|
2871
|
+
* 'itemId': '1',
|
|
2872
|
+
* 'itemName': 'item1',
|
|
2873
|
+
* 'variationId': '2',
|
|
2874
|
+
* 'question': 'Why choose this?'
|
|
2875
|
+
* },
|
|
2876
|
+
* );
|
|
2877
|
+
*/
|
|
2878
|
+
}, {
|
|
2879
|
+
key: "trackProductInsightsAgentQuestionClick",
|
|
2880
|
+
value: function trackProductInsightsAgentQuestionClick(parameters) {
|
|
2881
|
+
var networkParameters = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
|
2882
|
+
// Ensure parameters are provided (required)
|
|
2883
|
+
if (parameters && (0, _typeof2["default"])(parameters) === 'object' && !Array.isArray(parameters)) {
|
|
2884
|
+
var baseUrl = "".concat(this.options.serviceUrl, "/v2/behavioral_action/product_insights_agent_question_click?");
|
|
2885
|
+
var section = parameters.section,
|
|
2886
|
+
itemId = parameters.itemId,
|
|
2887
|
+
itemName = parameters.itemName,
|
|
2888
|
+
variationId = parameters.variationId,
|
|
2889
|
+
question = parameters.question;
|
|
2890
|
+
var queryParams = {};
|
|
2891
|
+
var bodyParams = {
|
|
2892
|
+
item_id: itemId,
|
|
2893
|
+
item_name: itemName,
|
|
2894
|
+
variation_id: variationId,
|
|
2895
|
+
question: question
|
|
2896
|
+
};
|
|
2897
|
+
if (section) {
|
|
2898
|
+
queryParams.section = section;
|
|
2899
|
+
}
|
|
2900
|
+
var requestURL = "".concat(baseUrl).concat(applyParamsAsString(queryParams, this.options));
|
|
2901
|
+
var requestMethod = 'POST';
|
|
2902
|
+
var requestBody = applyParams(bodyParams, _objectSpread(_objectSpread({}, this.options), {}, {
|
|
2903
|
+
requestMethod: requestMethod
|
|
2904
|
+
}));
|
|
2905
|
+
this.requests.queue(requestURL, requestMethod, requestBody, networkParameters);
|
|
2906
|
+
this.requests.send();
|
|
2907
|
+
return true;
|
|
2908
|
+
}
|
|
2909
|
+
this.requests.send();
|
|
2910
|
+
return new Error('parameters is a required parameter of type object');
|
|
2911
|
+
}
|
|
2912
|
+
|
|
2913
|
+
/**
|
|
2914
|
+
* Send product insights agent question submit event
|
|
2915
|
+
*
|
|
2916
|
+
* @function trackProductInsightsAgentQuestionSubmit
|
|
2917
|
+
* @param {object} parameters - Additional parameters to be sent with request
|
|
2918
|
+
* @param {string} parameters.itemId - Product id whose page we are on
|
|
2919
|
+
* @param {string} parameters.itemName - Product name whose page we are on
|
|
2920
|
+
* @param {string} parameters.question - Question a user submitted
|
|
2921
|
+
* @param {string} [parameters.variationId] - Variation id whose page we are on
|
|
2922
|
+
* @param {string} [parameters.section] - The section name for the item Ex. "Products"
|
|
2923
|
+
* @param {object} [networkParameters] - Parameters relevant to the network request
|
|
2924
|
+
* @param {number} [networkParameters.timeout] - Request timeout (in milliseconds)
|
|
2925
|
+
* @returns {(true|Error)}
|
|
2926
|
+
* @description User submitted a question to the product insights agent
|
|
2927
|
+
* @example
|
|
2928
|
+
* constructorio.tracker.trackProductInsightsAgentQuestionSubmit({
|
|
2929
|
+
* {
|
|
2930
|
+
* 'itemId': '1',
|
|
2931
|
+
* 'itemName': 'item1',
|
|
2932
|
+
* 'variationId': '2',
|
|
2933
|
+
* 'question': 'Tell me some key highlights about this item?'
|
|
2934
|
+
* },
|
|
2935
|
+
* );
|
|
2936
|
+
*/
|
|
2937
|
+
}, {
|
|
2938
|
+
key: "trackProductInsightsAgentQuestionSubmit",
|
|
2939
|
+
value: function trackProductInsightsAgentQuestionSubmit(parameters) {
|
|
2940
|
+
var networkParameters = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
|
2941
|
+
// Ensure parameters are provided (required)
|
|
2942
|
+
if (parameters && (0, _typeof2["default"])(parameters) === 'object' && !Array.isArray(parameters)) {
|
|
2943
|
+
var baseUrl = "".concat(this.options.serviceUrl, "/v2/behavioral_action/product_insights_agent_question_submit?");
|
|
2944
|
+
var section = parameters.section,
|
|
2945
|
+
itemId = parameters.itemId,
|
|
2946
|
+
itemName = parameters.itemName,
|
|
2947
|
+
variationId = parameters.variationId,
|
|
2948
|
+
question = parameters.question;
|
|
2949
|
+
var queryParams = {};
|
|
2950
|
+
var bodyParams = {
|
|
2951
|
+
item_id: itemId,
|
|
2952
|
+
item_name: itemName,
|
|
2953
|
+
variation_id: variationId,
|
|
2954
|
+
question: question
|
|
2955
|
+
};
|
|
2956
|
+
if (section) {
|
|
2957
|
+
queryParams.section = section;
|
|
2958
|
+
}
|
|
2959
|
+
var requestURL = "".concat(baseUrl).concat(applyParamsAsString(queryParams, this.options));
|
|
2960
|
+
var requestMethod = 'POST';
|
|
2961
|
+
var requestBody = applyParams(bodyParams, _objectSpread(_objectSpread({}, this.options), {}, {
|
|
2962
|
+
requestMethod: requestMethod
|
|
2963
|
+
}));
|
|
2964
|
+
this.requests.queue(requestURL, requestMethod, requestBody, networkParameters);
|
|
2965
|
+
this.requests.send();
|
|
2966
|
+
return true;
|
|
2967
|
+
}
|
|
2968
|
+
this.requests.send();
|
|
2969
|
+
return new Error('parameters is a required parameter of type object');
|
|
2970
|
+
}
|
|
2971
|
+
|
|
2972
|
+
/**
|
|
2973
|
+
* Send product insights agent answer view event
|
|
2974
|
+
*
|
|
2975
|
+
* @function trackProductInsightsAgentAnswerView
|
|
2976
|
+
* @param {object} parameters - Additional parameters to be sent with request
|
|
2977
|
+
* @param {string} parameters.itemId - Product id whose page we are on
|
|
2978
|
+
* @param {string} parameters.itemName - Product name whose page we are on
|
|
2979
|
+
* @param {string} parameters.question - Question a user submitted
|
|
2980
|
+
* @param {string} parameters.answerText - Answer text of the question
|
|
2981
|
+
* @param {string} [parameters.qnaResultId] - Answer result id returned
|
|
2982
|
+
* @param {string} [parameters.variationId] - Variation id whose page we are on
|
|
2983
|
+
* @param {string} [parameters.section] - The section name for the item Ex. "Products"
|
|
2984
|
+
* @param {object} [networkParameters] - Parameters relevant to the network request
|
|
2985
|
+
* @param {number} [networkParameters.timeout] - Request timeout (in milliseconds)
|
|
2986
|
+
* @returns {(true|Error)}
|
|
2987
|
+
* @description User viewed the answer provided by the product insights agent
|
|
2988
|
+
* @example
|
|
2989
|
+
* constructorio.tracker.trackProductInsightsAgentAnswerView({
|
|
2990
|
+
* {
|
|
2991
|
+
* 'itemId': '1',
|
|
2992
|
+
* 'itemName': 'item1',
|
|
2993
|
+
* 'variationId': '2',
|
|
2994
|
+
* 'question': 'Why choose this?',
|
|
2995
|
+
* 'answerText': 'This product is awesome!',
|
|
2996
|
+
* 'qnaResultId': '0daf0015-fc29-4727-9140-8d5313a1902c',
|
|
2997
|
+
* },
|
|
2998
|
+
* );
|
|
2999
|
+
*/
|
|
3000
|
+
}, {
|
|
3001
|
+
key: "trackProductInsightsAgentAnswerView",
|
|
3002
|
+
value: function trackProductInsightsAgentAnswerView(parameters) {
|
|
3003
|
+
var networkParameters = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
|
3004
|
+
// Ensure parameters are provided (required)
|
|
3005
|
+
if (parameters && (0, _typeof2["default"])(parameters) === 'object' && !Array.isArray(parameters)) {
|
|
3006
|
+
var baseUrl = "".concat(this.options.serviceUrl, "/v2/behavioral_action/product_insights_agent_answer_view?");
|
|
3007
|
+
var section = parameters.section,
|
|
3008
|
+
itemId = parameters.itemId,
|
|
3009
|
+
itemName = parameters.itemName,
|
|
3010
|
+
variationId = parameters.variationId,
|
|
3011
|
+
question = parameters.question,
|
|
3012
|
+
answerText = parameters.answerText,
|
|
3013
|
+
qnaResultId = parameters.qnaResultId;
|
|
3014
|
+
var queryParams = {};
|
|
3015
|
+
var bodyParams = {
|
|
3016
|
+
item_id: itemId,
|
|
3017
|
+
item_name: itemName,
|
|
3018
|
+
variation_id: variationId,
|
|
3019
|
+
question: question,
|
|
3020
|
+
answer_text: answerText,
|
|
3021
|
+
qna_result_id: qnaResultId
|
|
3022
|
+
};
|
|
3023
|
+
if (section) {
|
|
3024
|
+
queryParams.section = section;
|
|
3025
|
+
}
|
|
3026
|
+
var requestURL = "".concat(baseUrl).concat(applyParamsAsString(queryParams, this.options));
|
|
3027
|
+
var requestMethod = 'POST';
|
|
3028
|
+
var requestBody = applyParams(bodyParams, _objectSpread(_objectSpread({}, this.options), {}, {
|
|
3029
|
+
requestMethod: requestMethod
|
|
3030
|
+
}));
|
|
3031
|
+
this.requests.queue(requestURL, requestMethod, requestBody, networkParameters);
|
|
3032
|
+
this.requests.send();
|
|
3033
|
+
return true;
|
|
3034
|
+
}
|
|
3035
|
+
this.requests.send();
|
|
3036
|
+
return new Error('parameters is a required parameter of type object');
|
|
3037
|
+
}
|
|
3038
|
+
|
|
3039
|
+
/**
|
|
3040
|
+
* Send product insights agent answer feedback event
|
|
3041
|
+
*
|
|
3042
|
+
* @function trackProductInsightsAgentAnswerFeedback
|
|
3043
|
+
* @param {object} parameters - Additional parameters to be sent with request
|
|
3044
|
+
* @param {string} parameters.itemId - Product id whose page we are on
|
|
3045
|
+
* @param {string} parameters.itemName - Product name whose page we are on
|
|
3046
|
+
* @param {string} parameters.feedbackLabel - Feedback value: either "thumbs_up" or "thumbs_down"
|
|
3047
|
+
* @param {string} [parameters.qnaResultId] - Answer result id returned
|
|
3048
|
+
* @param {string} [parameters.variationId] - Variation id whose page we are on
|
|
3049
|
+
* @param {string} [parameters.section] - The section name for the item Ex. "Products"
|
|
3050
|
+
* @param {object} [networkParameters] - Parameters relevant to the network request
|
|
3051
|
+
* @param {number} [networkParameters.timeout] - Request timeout (in milliseconds)
|
|
3052
|
+
* @returns {(true|Error)}
|
|
3053
|
+
* @description A user provided feedback on an answers usefulness
|
|
3054
|
+
* @example
|
|
3055
|
+
* constructorio.tracker.trackProductInsightsAgentAnswerFeedback({
|
|
3056
|
+
* {
|
|
3057
|
+
* 'itemId': '1',
|
|
3058
|
+
* 'itemName': 'item1',
|
|
3059
|
+
* 'variationId': '2',
|
|
3060
|
+
* 'feedbackLabel': 'thumbs_up',
|
|
3061
|
+
* 'qnaResultId': '0daf0015-fc29-4727-9140-8d5313a1902c',
|
|
3062
|
+
* },
|
|
3063
|
+
* );
|
|
3064
|
+
*/
|
|
3065
|
+
}, {
|
|
3066
|
+
key: "trackProductInsightsAgentAnswerFeedback",
|
|
3067
|
+
value: function trackProductInsightsAgentAnswerFeedback(parameters) {
|
|
3068
|
+
var networkParameters = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
|
3069
|
+
// Ensure parameters are provided (required)
|
|
3070
|
+
if (parameters && (0, _typeof2["default"])(parameters) === 'object' && !Array.isArray(parameters)) {
|
|
3071
|
+
var baseUrl = "".concat(this.options.serviceUrl, "/v2/behavioral_action/product_insights_agent_answer_feedback?");
|
|
3072
|
+
var section = parameters.section,
|
|
3073
|
+
itemId = parameters.itemId,
|
|
3074
|
+
itemName = parameters.itemName,
|
|
3075
|
+
variationId = parameters.variationId,
|
|
3076
|
+
feedbackLabel = parameters.feedbackLabel,
|
|
3077
|
+
qnaResultId = parameters.qnaResultId;
|
|
3078
|
+
var queryParams = {};
|
|
3079
|
+
var bodyParams = {
|
|
3080
|
+
item_id: itemId,
|
|
3081
|
+
item_name: itemName,
|
|
3082
|
+
variation_id: variationId,
|
|
3083
|
+
feedback_label: feedbackLabel,
|
|
3084
|
+
qna_result_id: qnaResultId
|
|
3085
|
+
};
|
|
3086
|
+
if (section) {
|
|
3087
|
+
queryParams.section = section;
|
|
3088
|
+
}
|
|
3089
|
+
var requestURL = "".concat(baseUrl).concat(applyParamsAsString(queryParams, this.options));
|
|
3090
|
+
var requestMethod = 'POST';
|
|
3091
|
+
var requestBody = applyParams(bodyParams, _objectSpread(_objectSpread({}, this.options), {}, {
|
|
3092
|
+
requestMethod: requestMethod
|
|
3093
|
+
}));
|
|
3094
|
+
this.requests.queue(requestURL, requestMethod, requestBody, networkParameters);
|
|
3095
|
+
this.requests.send();
|
|
3096
|
+
return true;
|
|
3097
|
+
}
|
|
3098
|
+
this.requests.send();
|
|
3099
|
+
return new Error('parameters is a required parameter of type object');
|
|
3100
|
+
}
|
|
3101
|
+
|
|
2604
3102
|
/**
|
|
2605
3103
|
* Subscribe to success or error messages emitted by tracking requests
|
|
2606
3104
|
*
|
package/lib/types/index.d.ts
CHANGED
|
@@ -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
|
+
}
|
package/lib/types/quizzes.d.ts
CHANGED
|
@@ -115,7 +115,7 @@ export interface QuizResultData extends Record<string, any> {
|
|
|
115
115
|
variations: Record<string, any>[];
|
|
116
116
|
}
|
|
117
117
|
|
|
118
|
-
export type Question = SelectQuestion | OpenQuestion | CoverQuestion;
|
|
118
|
+
export type Question = SelectQuestion | FilterValueQuestion | OpenQuestion | CoverQuestion;
|
|
119
119
|
|
|
120
120
|
export interface BaseQuestion extends Record<string, any> {
|
|
121
121
|
id: number;
|
|
@@ -125,6 +125,12 @@ export interface BaseQuestion extends Record<string, any> {
|
|
|
125
125
|
images?: Nullable<QuestionImages>;
|
|
126
126
|
}
|
|
127
127
|
|
|
128
|
+
export interface FilterValueQuestion extends BaseQuestion {
|
|
129
|
+
type: 'single_filter_value' |'multiple_filter_values';
|
|
130
|
+
filter_name: string;
|
|
131
|
+
options: QuestionOption[];
|
|
132
|
+
}
|
|
133
|
+
|
|
128
134
|
export interface SelectQuestion extends BaseQuestion {
|
|
129
135
|
type: 'single' | 'multiple';
|
|
130
136
|
options: QuestionOption[];
|
package/lib/types/tracker.d.ts
CHANGED
|
@@ -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
|
}
|
package/lib/version.js
CHANGED