coveo.analytics 2.26.4 → 2.26.6
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/dist/coveoua.browser.js +1 -1
- package/dist/coveoua.browser.js.map +1 -1
- package/dist/coveoua.debug.js +68 -4
- package/dist/coveoua.debug.js.map +1 -1
- package/dist/coveoua.js +1 -1
- package/dist/coveoua.js.map +1 -1
- package/dist/definitions/client/analytics.d.ts +1 -0
- package/dist/definitions/insight/insightClient.d.ts +14 -1
- package/dist/definitions/version.d.ts +1 -1
- package/dist/library.es.js +68 -4
- package/dist/library.js +68 -4
- package/dist/react-native.es.js +68 -4
- package/package.json +1 -1
- package/src/caseAssist/caseAssistClient.spec.ts +4 -4
- package/src/client/analytics.spec.ts +36 -1
- package/src/client/analytics.ts +27 -3
- package/src/coveoua/simpleanalytics.spec.ts +43 -17
- package/src/donottrack.spec.ts +4 -4
- package/src/insight/insightClient.spec.ts +274 -6
- package/src/insight/insightClient.ts +134 -0
- package/src/searchPage/searchPageClient.spec.ts +9 -10
|
@@ -110,6 +110,7 @@ export declare class CoveoAnalyticsClient implements AnalyticsClient, VisitorIdP
|
|
|
110
110
|
private lowercaseKeys;
|
|
111
111
|
private validateParams;
|
|
112
112
|
private ensureAnonymousUserWhenUsingApiKey;
|
|
113
|
+
private limit;
|
|
113
114
|
private get baseUrl();
|
|
114
115
|
}
|
|
115
116
|
export default CoveoAnalyticsClient;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { AnalyticsClient, ClientOptions } from '../client/analytics';
|
|
2
2
|
import { SearchEventRequest } from '../events';
|
|
3
|
-
import { DocumentIdentifier, FacetStateMetadata, PartialDocumentInformation, SearchPageEvents } from '../searchPage/searchPageEvents';
|
|
3
|
+
import { DocumentIdentifier, FacetStateMetadata, PartialDocumentInformation, SearchPageEvents, SmartSnippetDocumentIdentifier, SmartSnippetFeedbackReason, SmartSnippetLinkMeta, SmartSnippetSuggestionMeta } from '../searchPage/searchPageEvents';
|
|
4
4
|
import { ExpandToFullUIMetadata, InsightEvents, InsightFacetMetadata, InsightInterfaceChangeMetadata, InsightStaticFilterToggleValueMetadata, InsightFacetRangeMetadata, InsightCategoryFacetMetadata, CaseMetadata, InsightFacetSortMeta, InsightFacetBaseMeta, InsightQueryErrorMeta, InsightPagerMetadata, InsightResultsSortMetadata, UserActionsDocumentMetadata, UserActionsPageViewMetadata } from './insightEvents';
|
|
5
5
|
export interface InsightClientProvider {
|
|
6
6
|
getSearchEventRequestPayload: () => Omit<SearchEventRequest, 'actionCause' | 'searchQueryUid'>;
|
|
@@ -57,6 +57,19 @@ export declare class CoveoInsightClient {
|
|
|
57
57
|
logDocumentQuickview(info: PartialDocumentInformation, identifier: DocumentIdentifier, caseMetadata?: CaseMetadata): Promise<void | import("../events").ClickEventResponse>;
|
|
58
58
|
logCaseAttach(info: PartialDocumentInformation, identifier: DocumentIdentifier, caseMetadata?: CaseMetadata): Promise<void | import("../events").ClickEventResponse>;
|
|
59
59
|
logCaseDetach(resultUriHash: string, metadata?: CaseMetadata): Promise<void | import("../events").CustomEventResponse>;
|
|
60
|
+
logLikeSmartSnippet(metadata?: CaseMetadata): Promise<void | import("../events").CustomEventResponse>;
|
|
61
|
+
logDislikeSmartSnippet(metadata?: CaseMetadata): Promise<void | import("../events").CustomEventResponse>;
|
|
62
|
+
logExpandSmartSnippet(metadata?: CaseMetadata): Promise<void | import("../events").CustomEventResponse>;
|
|
63
|
+
logCollapseSmartSnippet(metadata?: CaseMetadata): Promise<void | import("../events").CustomEventResponse>;
|
|
64
|
+
logOpenSmartSnippetFeedbackModal(metadata?: CaseMetadata): Promise<void | import("../events").CustomEventResponse>;
|
|
65
|
+
logCloseSmartSnippetFeedbackModal(metadata?: CaseMetadata): Promise<void | import("../events").CustomEventResponse>;
|
|
66
|
+
logSmartSnippetFeedbackReason(reason: SmartSnippetFeedbackReason, details?: string, metadata?: CaseMetadata): Promise<void | import("../events").CustomEventResponse>;
|
|
67
|
+
logExpandSmartSnippetSuggestion(snippet: SmartSnippetSuggestionMeta | SmartSnippetDocumentIdentifier, metadata?: CaseMetadata): Promise<void | import("../events").CustomEventResponse>;
|
|
68
|
+
logCollapseSmartSnippetSuggestion(snippet: SmartSnippetSuggestionMeta | SmartSnippetDocumentIdentifier, metadata?: CaseMetadata): Promise<void | import("../events").CustomEventResponse>;
|
|
69
|
+
logOpenSmartSnippetSource(info: PartialDocumentInformation, identifier: DocumentIdentifier, metadata?: CaseMetadata): Promise<void | import("../events").ClickEventResponse>;
|
|
70
|
+
logOpenSmartSnippetSuggestionSource(info: PartialDocumentInformation, snippet: SmartSnippetSuggestionMeta, metadata?: CaseMetadata): Promise<void | import("../events").ClickEventResponse>;
|
|
71
|
+
logOpenSmartSnippetInlineLink(info: PartialDocumentInformation, identifierAndLink: DocumentIdentifier & SmartSnippetLinkMeta, metadata?: CaseMetadata): Promise<void | import("../events").ClickEventResponse>;
|
|
72
|
+
logOpenSmartSnippetSuggestionInlineLink(info: PartialDocumentInformation, snippetAndLink: SmartSnippetSuggestionMeta & SmartSnippetLinkMeta, metadata?: CaseMetadata): Promise<void | import("../events").ClickEventResponse>;
|
|
60
73
|
logCustomEvent(event: SearchPageEvents | InsightEvents, metadata?: Record<string, any>): Promise<void | import("../events").CustomEventResponse>;
|
|
61
74
|
logSearchEvent(event: SearchPageEvents | InsightEvents, metadata?: Record<string, any>): Promise<void | import("../events").SearchEventResponse>;
|
|
62
75
|
logClickEvent(event: SearchPageEvents, info: PartialDocumentInformation, identifier: DocumentIdentifier, metadata?: Record<string, any>): Promise<void | import("../events").ClickEventResponse>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const libVersion = "2.26.
|
|
1
|
+
export declare const libVersion = "2.26.6";
|
package/dist/library.es.js
CHANGED
|
@@ -593,7 +593,7 @@ function sha1(bytes) {
|
|
|
593
593
|
const v5 = v35('v5', 0x50, sha1);
|
|
594
594
|
var uuidv5 = v5;
|
|
595
595
|
|
|
596
|
-
const libVersion = "2.26.
|
|
596
|
+
const libVersion = "2.26.6" ;
|
|
597
597
|
|
|
598
598
|
const getFormattedLocation = (location) => `${location.protocol}//${location.hostname}${location.pathname.indexOf('/') === 0 ? location.pathname : `/${location.pathname}`}${location.search}`;
|
|
599
599
|
|
|
@@ -1377,7 +1377,7 @@ class CoveoAnalyticsClient {
|
|
|
1377
1377
|
return __awaiter(this, void 0, void 0, function* () {
|
|
1378
1378
|
const { usesMeasurementProtocol = false } = this.eventTypeMapping[eventType] || {};
|
|
1379
1379
|
const cleanPayloadStep = (currentPayload) => this.removeEmptyPayloadValues(currentPayload, eventType);
|
|
1380
|
-
const validateParams = (currentPayload) => this.validateParams(currentPayload);
|
|
1380
|
+
const validateParams = (currentPayload) => this.validateParams(currentPayload, eventType);
|
|
1381
1381
|
const processMeasurementProtocolConversionStep = (currentPayload) => usesMeasurementProtocol ? convertKeysToMeasurementProtocol(currentPayload) : currentPayload;
|
|
1382
1382
|
const removeUnknownParameters = (currentPayload) => usesMeasurementProtocol ? this.removeUnknownParameters(currentPayload) : currentPayload;
|
|
1383
1383
|
const processCustomParameters = (currentPayload) => usesMeasurementProtocol
|
|
@@ -1579,13 +1579,27 @@ class CoveoAnalyticsClient {
|
|
|
1579
1579
|
});
|
|
1580
1580
|
return result;
|
|
1581
1581
|
}
|
|
1582
|
-
validateParams(payload) {
|
|
1582
|
+
validateParams(payload, eventType) {
|
|
1583
1583
|
const { anonymizeIp } = payload, rest = __rest(payload, ["anonymizeIp"]);
|
|
1584
1584
|
if (anonymizeIp !== undefined) {
|
|
1585
1585
|
if (['0', 'false', 'undefined', 'null', '{}', '[]', ''].indexOf(`${anonymizeIp}`.toLowerCase()) == -1) {
|
|
1586
|
-
rest
|
|
1586
|
+
rest.anonymizeIp = 1;
|
|
1587
1587
|
}
|
|
1588
1588
|
}
|
|
1589
|
+
if (eventType == EventType.view ||
|
|
1590
|
+
eventType == EventType.click ||
|
|
1591
|
+
eventType == EventType.search ||
|
|
1592
|
+
eventType == EventType.custom) {
|
|
1593
|
+
rest.originLevel3 = this.limit(rest.originLevel3, 128);
|
|
1594
|
+
}
|
|
1595
|
+
if (eventType == EventType.view) {
|
|
1596
|
+
rest.location = this.limit(rest.location, 128);
|
|
1597
|
+
}
|
|
1598
|
+
if (eventType == 'pageview' || eventType == 'event') {
|
|
1599
|
+
rest.referrer = this.limit(rest.referrer, 2048);
|
|
1600
|
+
rest.location = this.limit(rest.location, 2048);
|
|
1601
|
+
rest.page = this.limit(rest.page, 2048);
|
|
1602
|
+
}
|
|
1589
1603
|
return rest;
|
|
1590
1604
|
}
|
|
1591
1605
|
ensureAnonymousUserWhenUsingApiKey(payload) {
|
|
@@ -1598,6 +1612,12 @@ class CoveoAnalyticsClient {
|
|
|
1598
1612
|
return payload;
|
|
1599
1613
|
}
|
|
1600
1614
|
}
|
|
1615
|
+
limit(input, length) {
|
|
1616
|
+
if (typeof input !== 'string') {
|
|
1617
|
+
return input;
|
|
1618
|
+
}
|
|
1619
|
+
return input.substring(0, length);
|
|
1620
|
+
}
|
|
1601
1621
|
get baseUrl() {
|
|
1602
1622
|
return buildBaseUrl(this.options.endpoint, this.options.version);
|
|
1603
1623
|
}
|
|
@@ -2894,6 +2914,50 @@ class CoveoInsightClient {
|
|
|
2894
2914
|
logCaseDetach(resultUriHash, metadata) {
|
|
2895
2915
|
return this.logCustomEvent(SearchPageEvents.caseDetach, metadata ? Object.assign(Object.assign({}, generateMetadataToSend(metadata, false)), { resultUriHash }) : { resultUriHash });
|
|
2896
2916
|
}
|
|
2917
|
+
logLikeSmartSnippet(metadata) {
|
|
2918
|
+
return this.logCustomEvent(SearchPageEvents.likeSmartSnippet, metadata ? generateMetadataToSend(metadata, false) : undefined);
|
|
2919
|
+
}
|
|
2920
|
+
logDislikeSmartSnippet(metadata) {
|
|
2921
|
+
return this.logCustomEvent(SearchPageEvents.dislikeSmartSnippet, metadata ? generateMetadataToSend(metadata, false) : undefined);
|
|
2922
|
+
}
|
|
2923
|
+
logExpandSmartSnippet(metadata) {
|
|
2924
|
+
return this.logCustomEvent(SearchPageEvents.expandSmartSnippet, metadata ? generateMetadataToSend(metadata, false) : undefined);
|
|
2925
|
+
}
|
|
2926
|
+
logCollapseSmartSnippet(metadata) {
|
|
2927
|
+
return this.logCustomEvent(SearchPageEvents.collapseSmartSnippet, metadata ? generateMetadataToSend(metadata, false) : undefined);
|
|
2928
|
+
}
|
|
2929
|
+
logOpenSmartSnippetFeedbackModal(metadata) {
|
|
2930
|
+
return this.logCustomEvent(SearchPageEvents.openSmartSnippetFeedbackModal, metadata ? generateMetadataToSend(metadata, false) : undefined);
|
|
2931
|
+
}
|
|
2932
|
+
logCloseSmartSnippetFeedbackModal(metadata) {
|
|
2933
|
+
return this.logCustomEvent(SearchPageEvents.closeSmartSnippetFeedbackModal, metadata ? generateMetadataToSend(metadata, false) : undefined);
|
|
2934
|
+
}
|
|
2935
|
+
logSmartSnippetFeedbackReason(reason, details, metadata) {
|
|
2936
|
+
return this.logCustomEvent(SearchPageEvents.sendSmartSnippetReason, metadata ? Object.assign(Object.assign({}, generateMetadataToSend(metadata, false)), { reason, details }) : { reason, details });
|
|
2937
|
+
}
|
|
2938
|
+
logExpandSmartSnippetSuggestion(snippet, metadata) {
|
|
2939
|
+
const snippetMetadata = 'documentId' in snippet ? snippet : { documentId: snippet };
|
|
2940
|
+
return this.logCustomEvent(SearchPageEvents.expandSmartSnippetSuggestion, metadata ? Object.assign(Object.assign({}, generateMetadataToSend(metadata, false)), snippetMetadata) : snippetMetadata);
|
|
2941
|
+
}
|
|
2942
|
+
logCollapseSmartSnippetSuggestion(snippet, metadata) {
|
|
2943
|
+
const snippetMetadata = 'documentId' in snippet ? snippet : { documentId: snippet };
|
|
2944
|
+
return this.logCustomEvent(SearchPageEvents.collapseSmartSnippetSuggestion, metadata ? Object.assign(Object.assign({}, generateMetadataToSend(metadata, false)), snippetMetadata) : snippetMetadata);
|
|
2945
|
+
}
|
|
2946
|
+
logOpenSmartSnippetSource(info, identifier, metadata) {
|
|
2947
|
+
return this.logClickEvent(SearchPageEvents.openSmartSnippetSource, info, identifier, metadata ? generateMetadataToSend(metadata, false) : undefined);
|
|
2948
|
+
}
|
|
2949
|
+
logOpenSmartSnippetSuggestionSource(info, snippet, metadata) {
|
|
2950
|
+
return this.logClickEvent(SearchPageEvents.openSmartSnippetSuggestionSource, info, { contentIDKey: snippet.documentId.contentIdKey, contentIDValue: snippet.documentId.contentIdValue }, metadata ? Object.assign(Object.assign({}, generateMetadataToSend(metadata, false)), snippet) : snippet);
|
|
2951
|
+
}
|
|
2952
|
+
logOpenSmartSnippetInlineLink(info, identifierAndLink, metadata) {
|
|
2953
|
+
return this.logClickEvent(SearchPageEvents.openSmartSnippetInlineLink, info, { contentIDKey: identifierAndLink.contentIDKey, contentIDValue: identifierAndLink.contentIDValue }, metadata ? Object.assign(Object.assign({}, generateMetadataToSend(metadata, false)), identifierAndLink) : identifierAndLink);
|
|
2954
|
+
}
|
|
2955
|
+
logOpenSmartSnippetSuggestionInlineLink(info, snippetAndLink, metadata) {
|
|
2956
|
+
return this.logClickEvent(SearchPageEvents.openSmartSnippetSuggestionInlineLink, info, {
|
|
2957
|
+
contentIDKey: snippetAndLink.documentId.contentIdKey,
|
|
2958
|
+
contentIDValue: snippetAndLink.documentId.contentIdValue,
|
|
2959
|
+
}, metadata ? Object.assign(Object.assign({}, generateMetadataToSend(metadata, false)), snippetAndLink) : snippetAndLink);
|
|
2960
|
+
}
|
|
2897
2961
|
logCustomEvent(event, metadata) {
|
|
2898
2962
|
return __awaiter(this, void 0, void 0, function* () {
|
|
2899
2963
|
const customData = Object.assign(Object.assign({}, this.provider.getBaseMetadata()), metadata);
|
package/dist/library.js
CHANGED
|
@@ -740,7 +740,7 @@ function sha1(bytes) {
|
|
|
740
740
|
const v5 = v35('v5', 0x50, sha1);
|
|
741
741
|
var uuidv5 = v5;
|
|
742
742
|
|
|
743
|
-
var libVersion = "2.26.
|
|
743
|
+
var libVersion = "2.26.6" ;
|
|
744
744
|
|
|
745
745
|
var getFormattedLocation = function (location) {
|
|
746
746
|
return location.protocol + "//" + location.hostname + (location.pathname.indexOf('/') === 0 ? location.pathname : "/" + location.pathname) + location.search;
|
|
@@ -83306,7 +83306,7 @@ var CoveoAnalyticsClient = (function () {
|
|
|
83306
83306
|
cleanPayloadStep = function (currentPayload) {
|
|
83307
83307
|
return _this.removeEmptyPayloadValues(currentPayload, eventType);
|
|
83308
83308
|
};
|
|
83309
|
-
validateParams = function (currentPayload) { return _this.validateParams(currentPayload); };
|
|
83309
|
+
validateParams = function (currentPayload) { return _this.validateParams(currentPayload, eventType); };
|
|
83310
83310
|
processMeasurementProtocolConversionStep = function (currentPayload) {
|
|
83311
83311
|
return usesMeasurementProtocol ? convertKeysToMeasurementProtocol(currentPayload) : currentPayload;
|
|
83312
83312
|
};
|
|
@@ -83617,13 +83617,27 @@ var CoveoAnalyticsClient = (function () {
|
|
|
83617
83617
|
});
|
|
83618
83618
|
return result;
|
|
83619
83619
|
};
|
|
83620
|
-
CoveoAnalyticsClient.prototype.validateParams = function (payload) {
|
|
83620
|
+
CoveoAnalyticsClient.prototype.validateParams = function (payload, eventType) {
|
|
83621
83621
|
var anonymizeIp = payload.anonymizeIp, rest = __rest(payload, ["anonymizeIp"]);
|
|
83622
83622
|
if (anonymizeIp !== undefined) {
|
|
83623
83623
|
if (['0', 'false', 'undefined', 'null', '{}', '[]', ''].indexOf(("" + anonymizeIp).toLowerCase()) == -1) {
|
|
83624
|
-
rest
|
|
83624
|
+
rest.anonymizeIp = 1;
|
|
83625
83625
|
}
|
|
83626
83626
|
}
|
|
83627
|
+
if (eventType == EventType.view ||
|
|
83628
|
+
eventType == EventType.click ||
|
|
83629
|
+
eventType == EventType.search ||
|
|
83630
|
+
eventType == EventType.custom) {
|
|
83631
|
+
rest.originLevel3 = this.limit(rest.originLevel3, 128);
|
|
83632
|
+
}
|
|
83633
|
+
if (eventType == EventType.view) {
|
|
83634
|
+
rest.location = this.limit(rest.location, 128);
|
|
83635
|
+
}
|
|
83636
|
+
if (eventType == 'pageview' || eventType == 'event') {
|
|
83637
|
+
rest.referrer = this.limit(rest.referrer, 2048);
|
|
83638
|
+
rest.location = this.limit(rest.location, 2048);
|
|
83639
|
+
rest.page = this.limit(rest.page, 2048);
|
|
83640
|
+
}
|
|
83627
83641
|
return rest;
|
|
83628
83642
|
};
|
|
83629
83643
|
CoveoAnalyticsClient.prototype.ensureAnonymousUserWhenUsingApiKey = function (payload) {
|
|
@@ -83636,6 +83650,12 @@ var CoveoAnalyticsClient = (function () {
|
|
|
83636
83650
|
return payload;
|
|
83637
83651
|
}
|
|
83638
83652
|
};
|
|
83653
|
+
CoveoAnalyticsClient.prototype.limit = function (input, length) {
|
|
83654
|
+
if (typeof input !== 'string') {
|
|
83655
|
+
return input;
|
|
83656
|
+
}
|
|
83657
|
+
return input.substring(0, length);
|
|
83658
|
+
};
|
|
83639
83659
|
Object.defineProperty(CoveoAnalyticsClient.prototype, "baseUrl", {
|
|
83640
83660
|
get: function () {
|
|
83641
83661
|
return buildBaseUrl(this.options.endpoint, this.options.version);
|
|
@@ -85797,6 +85817,50 @@ var CoveoInsightClient = (function () {
|
|
|
85797
85817
|
CoveoInsightClient.prototype.logCaseDetach = function (resultUriHash, metadata) {
|
|
85798
85818
|
return this.logCustomEvent(SearchPageEvents.caseDetach, metadata ? __assign(__assign({}, generateMetadataToSend(metadata, false)), { resultUriHash: resultUriHash }) : { resultUriHash: resultUriHash });
|
|
85799
85819
|
};
|
|
85820
|
+
CoveoInsightClient.prototype.logLikeSmartSnippet = function (metadata) {
|
|
85821
|
+
return this.logCustomEvent(SearchPageEvents.likeSmartSnippet, metadata ? generateMetadataToSend(metadata, false) : undefined);
|
|
85822
|
+
};
|
|
85823
|
+
CoveoInsightClient.prototype.logDislikeSmartSnippet = function (metadata) {
|
|
85824
|
+
return this.logCustomEvent(SearchPageEvents.dislikeSmartSnippet, metadata ? generateMetadataToSend(metadata, false) : undefined);
|
|
85825
|
+
};
|
|
85826
|
+
CoveoInsightClient.prototype.logExpandSmartSnippet = function (metadata) {
|
|
85827
|
+
return this.logCustomEvent(SearchPageEvents.expandSmartSnippet, metadata ? generateMetadataToSend(metadata, false) : undefined);
|
|
85828
|
+
};
|
|
85829
|
+
CoveoInsightClient.prototype.logCollapseSmartSnippet = function (metadata) {
|
|
85830
|
+
return this.logCustomEvent(SearchPageEvents.collapseSmartSnippet, metadata ? generateMetadataToSend(metadata, false) : undefined);
|
|
85831
|
+
};
|
|
85832
|
+
CoveoInsightClient.prototype.logOpenSmartSnippetFeedbackModal = function (metadata) {
|
|
85833
|
+
return this.logCustomEvent(SearchPageEvents.openSmartSnippetFeedbackModal, metadata ? generateMetadataToSend(metadata, false) : undefined);
|
|
85834
|
+
};
|
|
85835
|
+
CoveoInsightClient.prototype.logCloseSmartSnippetFeedbackModal = function (metadata) {
|
|
85836
|
+
return this.logCustomEvent(SearchPageEvents.closeSmartSnippetFeedbackModal, metadata ? generateMetadataToSend(metadata, false) : undefined);
|
|
85837
|
+
};
|
|
85838
|
+
CoveoInsightClient.prototype.logSmartSnippetFeedbackReason = function (reason, details, metadata) {
|
|
85839
|
+
return this.logCustomEvent(SearchPageEvents.sendSmartSnippetReason, metadata ? __assign(__assign({}, generateMetadataToSend(metadata, false)), { reason: reason, details: details }) : { reason: reason, details: details });
|
|
85840
|
+
};
|
|
85841
|
+
CoveoInsightClient.prototype.logExpandSmartSnippetSuggestion = function (snippet, metadata) {
|
|
85842
|
+
var snippetMetadata = 'documentId' in snippet ? snippet : { documentId: snippet };
|
|
85843
|
+
return this.logCustomEvent(SearchPageEvents.expandSmartSnippetSuggestion, metadata ? __assign(__assign({}, generateMetadataToSend(metadata, false)), snippetMetadata) : snippetMetadata);
|
|
85844
|
+
};
|
|
85845
|
+
CoveoInsightClient.prototype.logCollapseSmartSnippetSuggestion = function (snippet, metadata) {
|
|
85846
|
+
var snippetMetadata = 'documentId' in snippet ? snippet : { documentId: snippet };
|
|
85847
|
+
return this.logCustomEvent(SearchPageEvents.collapseSmartSnippetSuggestion, metadata ? __assign(__assign({}, generateMetadataToSend(metadata, false)), snippetMetadata) : snippetMetadata);
|
|
85848
|
+
};
|
|
85849
|
+
CoveoInsightClient.prototype.logOpenSmartSnippetSource = function (info, identifier, metadata) {
|
|
85850
|
+
return this.logClickEvent(SearchPageEvents.openSmartSnippetSource, info, identifier, metadata ? generateMetadataToSend(metadata, false) : undefined);
|
|
85851
|
+
};
|
|
85852
|
+
CoveoInsightClient.prototype.logOpenSmartSnippetSuggestionSource = function (info, snippet, metadata) {
|
|
85853
|
+
return this.logClickEvent(SearchPageEvents.openSmartSnippetSuggestionSource, info, { contentIDKey: snippet.documentId.contentIdKey, contentIDValue: snippet.documentId.contentIdValue }, metadata ? __assign(__assign({}, generateMetadataToSend(metadata, false)), snippet) : snippet);
|
|
85854
|
+
};
|
|
85855
|
+
CoveoInsightClient.prototype.logOpenSmartSnippetInlineLink = function (info, identifierAndLink, metadata) {
|
|
85856
|
+
return this.logClickEvent(SearchPageEvents.openSmartSnippetInlineLink, info, { contentIDKey: identifierAndLink.contentIDKey, contentIDValue: identifierAndLink.contentIDValue }, metadata ? __assign(__assign({}, generateMetadataToSend(metadata, false)), identifierAndLink) : identifierAndLink);
|
|
85857
|
+
};
|
|
85858
|
+
CoveoInsightClient.prototype.logOpenSmartSnippetSuggestionInlineLink = function (info, snippetAndLink, metadata) {
|
|
85859
|
+
return this.logClickEvent(SearchPageEvents.openSmartSnippetSuggestionInlineLink, info, {
|
|
85860
|
+
contentIDKey: snippetAndLink.documentId.contentIdKey,
|
|
85861
|
+
contentIDValue: snippetAndLink.documentId.contentIdValue,
|
|
85862
|
+
}, metadata ? __assign(__assign({}, generateMetadataToSend(metadata, false)), snippetAndLink) : snippetAndLink);
|
|
85863
|
+
};
|
|
85800
85864
|
CoveoInsightClient.prototype.logCustomEvent = function (event, metadata) {
|
|
85801
85865
|
return __awaiter(this, void 0, void 0, function () {
|
|
85802
85866
|
var customData, payload, _a;
|
package/dist/react-native.es.js
CHANGED
|
@@ -655,7 +655,7 @@ const addPageViewToHistory = (pageViewValue) => __awaiter(void 0, void 0, void 0
|
|
|
655
655
|
yield store.addElementAsync(historyElement);
|
|
656
656
|
});
|
|
657
657
|
|
|
658
|
-
const libVersion = "2.26.
|
|
658
|
+
const libVersion = "2.26.6" ;
|
|
659
659
|
|
|
660
660
|
const getFormattedLocation = (location) => `${location.protocol}//${location.hostname}${location.pathname.indexOf('/') === 0 ? location.pathname : `/${location.pathname}`}${location.search}`;
|
|
661
661
|
|
|
@@ -1378,7 +1378,7 @@ class CoveoAnalyticsClient {
|
|
|
1378
1378
|
return __awaiter(this, void 0, void 0, function* () {
|
|
1379
1379
|
const { usesMeasurementProtocol = false } = this.eventTypeMapping[eventType] || {};
|
|
1380
1380
|
const cleanPayloadStep = (currentPayload) => this.removeEmptyPayloadValues(currentPayload, eventType);
|
|
1381
|
-
const validateParams = (currentPayload) => this.validateParams(currentPayload);
|
|
1381
|
+
const validateParams = (currentPayload) => this.validateParams(currentPayload, eventType);
|
|
1382
1382
|
const processMeasurementProtocolConversionStep = (currentPayload) => usesMeasurementProtocol ? convertKeysToMeasurementProtocol(currentPayload) : currentPayload;
|
|
1383
1383
|
const removeUnknownParameters = (currentPayload) => usesMeasurementProtocol ? this.removeUnknownParameters(currentPayload) : currentPayload;
|
|
1384
1384
|
const processCustomParameters = (currentPayload) => usesMeasurementProtocol
|
|
@@ -1580,13 +1580,27 @@ class CoveoAnalyticsClient {
|
|
|
1580
1580
|
});
|
|
1581
1581
|
return result;
|
|
1582
1582
|
}
|
|
1583
|
-
validateParams(payload) {
|
|
1583
|
+
validateParams(payload, eventType) {
|
|
1584
1584
|
const { anonymizeIp } = payload, rest = __rest(payload, ["anonymizeIp"]);
|
|
1585
1585
|
if (anonymizeIp !== undefined) {
|
|
1586
1586
|
if (['0', 'false', 'undefined', 'null', '{}', '[]', ''].indexOf(`${anonymizeIp}`.toLowerCase()) == -1) {
|
|
1587
|
-
rest
|
|
1587
|
+
rest.anonymizeIp = 1;
|
|
1588
1588
|
}
|
|
1589
1589
|
}
|
|
1590
|
+
if (eventType == EventType.view ||
|
|
1591
|
+
eventType == EventType.click ||
|
|
1592
|
+
eventType == EventType.search ||
|
|
1593
|
+
eventType == EventType.custom) {
|
|
1594
|
+
rest.originLevel3 = this.limit(rest.originLevel3, 128);
|
|
1595
|
+
}
|
|
1596
|
+
if (eventType == EventType.view) {
|
|
1597
|
+
rest.location = this.limit(rest.location, 128);
|
|
1598
|
+
}
|
|
1599
|
+
if (eventType == 'pageview' || eventType == 'event') {
|
|
1600
|
+
rest.referrer = this.limit(rest.referrer, 2048);
|
|
1601
|
+
rest.location = this.limit(rest.location, 2048);
|
|
1602
|
+
rest.page = this.limit(rest.page, 2048);
|
|
1603
|
+
}
|
|
1590
1604
|
return rest;
|
|
1591
1605
|
}
|
|
1592
1606
|
ensureAnonymousUserWhenUsingApiKey(payload) {
|
|
@@ -1599,6 +1613,12 @@ class CoveoAnalyticsClient {
|
|
|
1599
1613
|
return payload;
|
|
1600
1614
|
}
|
|
1601
1615
|
}
|
|
1616
|
+
limit(input, length) {
|
|
1617
|
+
if (typeof input !== 'string') {
|
|
1618
|
+
return input;
|
|
1619
|
+
}
|
|
1620
|
+
return input.substring(0, length);
|
|
1621
|
+
}
|
|
1602
1622
|
get baseUrl() {
|
|
1603
1623
|
return buildBaseUrl(this.options.endpoint, this.options.version);
|
|
1604
1624
|
}
|
|
@@ -2912,6 +2932,50 @@ class CoveoInsightClient {
|
|
|
2912
2932
|
logCaseDetach(resultUriHash, metadata) {
|
|
2913
2933
|
return this.logCustomEvent(SearchPageEvents.caseDetach, metadata ? Object.assign(Object.assign({}, generateMetadataToSend(metadata, false)), { resultUriHash }) : { resultUriHash });
|
|
2914
2934
|
}
|
|
2935
|
+
logLikeSmartSnippet(metadata) {
|
|
2936
|
+
return this.logCustomEvent(SearchPageEvents.likeSmartSnippet, metadata ? generateMetadataToSend(metadata, false) : undefined);
|
|
2937
|
+
}
|
|
2938
|
+
logDislikeSmartSnippet(metadata) {
|
|
2939
|
+
return this.logCustomEvent(SearchPageEvents.dislikeSmartSnippet, metadata ? generateMetadataToSend(metadata, false) : undefined);
|
|
2940
|
+
}
|
|
2941
|
+
logExpandSmartSnippet(metadata) {
|
|
2942
|
+
return this.logCustomEvent(SearchPageEvents.expandSmartSnippet, metadata ? generateMetadataToSend(metadata, false) : undefined);
|
|
2943
|
+
}
|
|
2944
|
+
logCollapseSmartSnippet(metadata) {
|
|
2945
|
+
return this.logCustomEvent(SearchPageEvents.collapseSmartSnippet, metadata ? generateMetadataToSend(metadata, false) : undefined);
|
|
2946
|
+
}
|
|
2947
|
+
logOpenSmartSnippetFeedbackModal(metadata) {
|
|
2948
|
+
return this.logCustomEvent(SearchPageEvents.openSmartSnippetFeedbackModal, metadata ? generateMetadataToSend(metadata, false) : undefined);
|
|
2949
|
+
}
|
|
2950
|
+
logCloseSmartSnippetFeedbackModal(metadata) {
|
|
2951
|
+
return this.logCustomEvent(SearchPageEvents.closeSmartSnippetFeedbackModal, metadata ? generateMetadataToSend(metadata, false) : undefined);
|
|
2952
|
+
}
|
|
2953
|
+
logSmartSnippetFeedbackReason(reason, details, metadata) {
|
|
2954
|
+
return this.logCustomEvent(SearchPageEvents.sendSmartSnippetReason, metadata ? Object.assign(Object.assign({}, generateMetadataToSend(metadata, false)), { reason, details }) : { reason, details });
|
|
2955
|
+
}
|
|
2956
|
+
logExpandSmartSnippetSuggestion(snippet, metadata) {
|
|
2957
|
+
const snippetMetadata = 'documentId' in snippet ? snippet : { documentId: snippet };
|
|
2958
|
+
return this.logCustomEvent(SearchPageEvents.expandSmartSnippetSuggestion, metadata ? Object.assign(Object.assign({}, generateMetadataToSend(metadata, false)), snippetMetadata) : snippetMetadata);
|
|
2959
|
+
}
|
|
2960
|
+
logCollapseSmartSnippetSuggestion(snippet, metadata) {
|
|
2961
|
+
const snippetMetadata = 'documentId' in snippet ? snippet : { documentId: snippet };
|
|
2962
|
+
return this.logCustomEvent(SearchPageEvents.collapseSmartSnippetSuggestion, metadata ? Object.assign(Object.assign({}, generateMetadataToSend(metadata, false)), snippetMetadata) : snippetMetadata);
|
|
2963
|
+
}
|
|
2964
|
+
logOpenSmartSnippetSource(info, identifier, metadata) {
|
|
2965
|
+
return this.logClickEvent(SearchPageEvents.openSmartSnippetSource, info, identifier, metadata ? generateMetadataToSend(metadata, false) : undefined);
|
|
2966
|
+
}
|
|
2967
|
+
logOpenSmartSnippetSuggestionSource(info, snippet, metadata) {
|
|
2968
|
+
return this.logClickEvent(SearchPageEvents.openSmartSnippetSuggestionSource, info, { contentIDKey: snippet.documentId.contentIdKey, contentIDValue: snippet.documentId.contentIdValue }, metadata ? Object.assign(Object.assign({}, generateMetadataToSend(metadata, false)), snippet) : snippet);
|
|
2969
|
+
}
|
|
2970
|
+
logOpenSmartSnippetInlineLink(info, identifierAndLink, metadata) {
|
|
2971
|
+
return this.logClickEvent(SearchPageEvents.openSmartSnippetInlineLink, info, { contentIDKey: identifierAndLink.contentIDKey, contentIDValue: identifierAndLink.contentIDValue }, metadata ? Object.assign(Object.assign({}, generateMetadataToSend(metadata, false)), identifierAndLink) : identifierAndLink);
|
|
2972
|
+
}
|
|
2973
|
+
logOpenSmartSnippetSuggestionInlineLink(info, snippetAndLink, metadata) {
|
|
2974
|
+
return this.logClickEvent(SearchPageEvents.openSmartSnippetSuggestionInlineLink, info, {
|
|
2975
|
+
contentIDKey: snippetAndLink.documentId.contentIdKey,
|
|
2976
|
+
contentIDValue: snippetAndLink.documentId.contentIdValue,
|
|
2977
|
+
}, metadata ? Object.assign(Object.assign({}, generateMetadataToSend(metadata, false)), snippetAndLink) : snippetAndLink);
|
|
2978
|
+
}
|
|
2915
2979
|
logCustomEvent(event, metadata) {
|
|
2916
2980
|
return __awaiter(this, void 0, void 0, function* () {
|
|
2917
2981
|
const customData = Object.assign(Object.assign({}, this.provider.getBaseMetadata()), metadata);
|
package/package.json
CHANGED
|
@@ -6,7 +6,7 @@ import {
|
|
|
6
6
|
DocumentSuggestion,
|
|
7
7
|
FieldSuggestion,
|
|
8
8
|
} from './caseAssistActions';
|
|
9
|
-
import {mockFetch} from '../../tests/fetchMock';
|
|
9
|
+
import {mockFetch, lastCallBody} from '../../tests/fetchMock';
|
|
10
10
|
import {TicketProperties} from '../plugins/svc';
|
|
11
11
|
const {fetchMock, fetchMockBeforeEach} = mockFetch();
|
|
12
12
|
import doNotTrack from '../donottrack';
|
|
@@ -90,8 +90,8 @@ describe('CaseAssistClient', () => {
|
|
|
90
90
|
};
|
|
91
91
|
|
|
92
92
|
const expectMatchPayload = (actionName: CaseAssistActions, actionData: Object, ticket: TicketProperties) => {
|
|
93
|
-
const
|
|
94
|
-
const content = JSON.parse(body
|
|
93
|
+
const body: string = lastCallBody(fetchMock);
|
|
94
|
+
const content = JSON.parse(body);
|
|
95
95
|
|
|
96
96
|
expectMatchActionPayload(content, actionName, actionData);
|
|
97
97
|
expectMatchTicketPayload(content, ticket);
|
|
@@ -125,7 +125,7 @@ describe('CaseAssistClient', () => {
|
|
|
125
125
|
if (typeof propValue !== 'undefined') {
|
|
126
126
|
if (typeof propValue === 'object') {
|
|
127
127
|
expect(content).toHaveProperty(propName);
|
|
128
|
-
expect(content[propName]).toMatchObject(propValue);
|
|
128
|
+
expect(content[propName]).toMatchObject(propValue as object);
|
|
129
129
|
} else {
|
|
130
130
|
expect(content).toHaveProperty(propName, propValue);
|
|
131
131
|
}
|
|
@@ -7,7 +7,6 @@ import {mockFetch} from '../../tests/fetchMock';
|
|
|
7
7
|
import {BrowserRuntime} from './runtimeEnvironment';
|
|
8
8
|
import * as doNotTrack from '../donottrack';
|
|
9
9
|
import {Cookie} from '../cookieutils';
|
|
10
|
-
import {v4 as uuidv4} from 'uuid';
|
|
11
10
|
import {CoveoLinkParam} from '../plugins/link';
|
|
12
11
|
|
|
13
12
|
const aVisitorId = '123';
|
|
@@ -144,6 +143,42 @@ describe('Analytics', () => {
|
|
|
144
143
|
});
|
|
145
144
|
});
|
|
146
145
|
|
|
146
|
+
describe('should truncate the maxlength for URL parameters at 128 characters for ua events', () => {
|
|
147
|
+
const desiredMax: number = 128;
|
|
148
|
+
const longUrl: string = 'http://coveo.com/?q=' + 'a'.repeat(desiredMax);
|
|
149
|
+
expect(longUrl.length).toBeGreaterThan(desiredMax);
|
|
150
|
+
async function testEventType(type: EventType, url: string) {
|
|
151
|
+
mockFetchRequestForEventType(type);
|
|
152
|
+
await client.sendEvent(type, {
|
|
153
|
+
location: type == EventType.view ? url : undefined,
|
|
154
|
+
originLevel3: url,
|
|
155
|
+
});
|
|
156
|
+
const [body] = getParsedBodyCalls();
|
|
157
|
+
if (type == EventType.view) expect(body.location.length).toBeLessThanOrEqual(desiredMax);
|
|
158
|
+
expect(body.originLevel3.length).toBeLessThanOrEqual(desiredMax);
|
|
159
|
+
}
|
|
160
|
+
it('for view events', () => testEventType(EventType.view, longUrl));
|
|
161
|
+
it('for click events', () => testEventType(EventType.click, longUrl));
|
|
162
|
+
it('for search events', () => testEventType(EventType.search, longUrl));
|
|
163
|
+
it('for custom events', () => testEventType(EventType.custom, longUrl));
|
|
164
|
+
});
|
|
165
|
+
|
|
166
|
+
describe('url truncation is null safe', () => {
|
|
167
|
+
async function testAttributeTruncation(url: any) {
|
|
168
|
+
mockFetchRequestForEventType(EventType.view);
|
|
169
|
+
await client.sendEvent(EventType.view, {
|
|
170
|
+
location: url,
|
|
171
|
+
originLevel3: url,
|
|
172
|
+
});
|
|
173
|
+
const [body] = getParsedBodyCalls();
|
|
174
|
+
expect(body.location).toBe(url == null ? undefined : url);
|
|
175
|
+
expect(body.originLevel3).toBe(url == null ? undefined : url);
|
|
176
|
+
}
|
|
177
|
+
it('for undefined urls', () => testAttributeTruncation(undefined));
|
|
178
|
+
it('for null urls', () => testAttributeTruncation(null));
|
|
179
|
+
it('for non-string urls', () => testAttributeTruncation(12345));
|
|
180
|
+
});
|
|
181
|
+
|
|
147
182
|
it('should not remove #queryText for search events even if empty', async () => {
|
|
148
183
|
mockFetchRequestForEventType(EventType.search);
|
|
149
184
|
await client.sendEvent(EventType.search, {
|
package/src/client/analytics.ts
CHANGED
|
@@ -337,7 +337,7 @@ export class CoveoAnalyticsClient implements AnalyticsClient, VisitorIdProvider
|
|
|
337
337
|
|
|
338
338
|
const cleanPayloadStep: ProcessPayloadStep = (currentPayload) =>
|
|
339
339
|
this.removeEmptyPayloadValues(currentPayload, eventType);
|
|
340
|
-
const validateParams: ProcessPayloadStep = (currentPayload) => this.validateParams(currentPayload);
|
|
340
|
+
const validateParams: ProcessPayloadStep = (currentPayload) => this.validateParams(currentPayload, eventType);
|
|
341
341
|
const processMeasurementProtocolConversionStep: ProcessPayloadStep = (currentPayload) =>
|
|
342
342
|
usesMeasurementProtocol ? convertKeysToMeasurementProtocol(currentPayload) : currentPayload;
|
|
343
343
|
const removeUnknownParameters: ProcessPayloadStep = (currentPayload) =>
|
|
@@ -577,13 +577,30 @@ export class CoveoAnalyticsClient implements AnalyticsClient, VisitorIdProvider
|
|
|
577
577
|
return result;
|
|
578
578
|
}
|
|
579
579
|
|
|
580
|
-
private validateParams(payload: IRequestPayload): IRequestPayload {
|
|
580
|
+
private validateParams(payload: IRequestPayload, eventType: EventType | string): IRequestPayload {
|
|
581
581
|
const {anonymizeIp, ...rest} = payload;
|
|
582
582
|
if (anonymizeIp !== undefined) {
|
|
583
583
|
if (['0', 'false', 'undefined', 'null', '{}', '[]', ''].indexOf(`${anonymizeIp}`.toLowerCase()) == -1) {
|
|
584
|
-
rest
|
|
584
|
+
rest.anonymizeIp = 1;
|
|
585
585
|
}
|
|
586
586
|
}
|
|
587
|
+
|
|
588
|
+
if (
|
|
589
|
+
eventType == EventType.view ||
|
|
590
|
+
eventType == EventType.click ||
|
|
591
|
+
eventType == EventType.search ||
|
|
592
|
+
eventType == EventType.custom
|
|
593
|
+
) {
|
|
594
|
+
rest.originLevel3 = this.limit(rest.originLevel3, 128);
|
|
595
|
+
}
|
|
596
|
+
if (eventType == EventType.view) {
|
|
597
|
+
rest.location = this.limit(rest.location, 128);
|
|
598
|
+
}
|
|
599
|
+
if (eventType == 'pageview' || eventType == 'event') {
|
|
600
|
+
rest.referrer = this.limit(rest.referrer, 2048);
|
|
601
|
+
rest.location = this.limit(rest.location, 2048);
|
|
602
|
+
rest.page = this.limit(rest.page, 2048);
|
|
603
|
+
}
|
|
587
604
|
return rest;
|
|
588
605
|
}
|
|
589
606
|
|
|
@@ -597,6 +614,13 @@ export class CoveoAnalyticsClient implements AnalyticsClient, VisitorIdProvider
|
|
|
597
614
|
}
|
|
598
615
|
}
|
|
599
616
|
|
|
617
|
+
private limit(input: string, length: number): string | undefined | null {
|
|
618
|
+
if (typeof input !== 'string') {
|
|
619
|
+
return input;
|
|
620
|
+
}
|
|
621
|
+
return input.substring(0, length);
|
|
622
|
+
}
|
|
623
|
+
|
|
600
624
|
private get baseUrl(): string {
|
|
601
625
|
return buildBaseUrl(this.options.endpoint, this.options.version);
|
|
602
626
|
}
|