coveo.analytics 2.30.27 → 2.30.36
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/browser.mjs +49 -7
- package/dist/coveoua.browser.js +1 -1
- package/dist/coveoua.browser.js.map +1 -1
- package/dist/coveoua.debug.js +49 -7
- 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/utils.d.ts +1 -0
- package/dist/definitions/insight/insightClient.d.ts +2 -1
- package/dist/definitions/searchPage/searchPageEvents.d.ts +19 -14
- package/dist/definitions/version.d.ts +1 -1
- package/dist/library.cjs +49 -7
- package/dist/library.es.js +49 -7
- package/dist/library.js +49 -7
- package/dist/library.mjs +49 -7
- package/dist/react-native.es.js +49 -7
- package/package.json +1 -1
- package/src/client/analytics.spec.ts +9 -6
- package/src/client/analytics.ts +5 -9
- package/src/client/utils.spec.ts +113 -0
- package/src/client/utils.ts +65 -0
- package/src/insight/insightClient.spec.ts +20 -0
- package/src/insight/insightClient.ts +8 -0
- package/src/searchPage/searchPageEvents.ts +21 -14
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { AnalyticsClient, ClientOptions } from '../client/analytics';
|
|
2
2
|
import { SearchEventRequest } from '../events';
|
|
3
|
-
import { DocumentIdentifier, FacetStateMetadata, GeneratedAnswerBaseMeta, GeneratedAnswerCitationMeta, GeneratedAnswerFeedbackMeta, GeneratedAnswerFeedbackMetaV2, GeneratedAnswerRephraseMeta, GeneratedAnswerSourceHoverMeta, GeneratedAnswerStreamEndMeta, PartialDocumentInformation, SearchPageEvents, SmartSnippetDocumentIdentifier, SmartSnippetFeedbackReason, SmartSnippetLinkMeta, SmartSnippetSuggestionMeta } from '../searchPage/searchPageEvents';
|
|
3
|
+
import { DocumentIdentifier, FacetStateMetadata, GeneratedAnswerBaseMeta, GeneratedAnswerCitationMeta, GeneratedAnswerFeedbackMeta, GeneratedAnswerFeedbackMetaV2, GeneratedAnswerRephraseMeta, GeneratedAnswerSourceHoverMeta, GeneratedAnswerStreamEndMeta, PartialDocumentInformation, SearchPageEvents, SmartSnippetDocumentIdentifier, SmartSnippetFeedbackReason, SmartSnippetLinkMeta, SmartSnippetSuggestionMeta, TriggerNotifyMetadata } from '../searchPage/searchPageEvents';
|
|
4
4
|
import { ExpandToFullUIMetadata, InsightEvents, InsightFacetMetadata, InsightInterfaceChangeMetadata, InsightStaticFilterToggleValueMetadata, InsightFacetRangeMetadata, InsightCategoryFacetMetadata, CaseMetadata, InsightFacetSortMeta, InsightFacetBaseMeta, InsightQueryErrorMeta, InsightPagerMetadata, InsightResultsSortMetadata, UserActionsDocumentMetadata, UserActionsPageViewMetadata, CreateArticleMetadata } from './insightEvents';
|
|
5
5
|
export interface InsightClientProvider {
|
|
6
6
|
getSearchEventRequestPayload: () => Omit<SearchEventRequest, 'actionCause' | 'searchQueryUid'>;
|
|
@@ -94,6 +94,7 @@ export declare class CoveoInsightClient {
|
|
|
94
94
|
logClickEvent(event: SearchPageEvents, info: PartialDocumentInformation, identifier: DocumentIdentifier, metadata?: Record<string, any>): Promise<void | import("../events").ClickEventResponse>;
|
|
95
95
|
logShowMoreFoldedResults(info: PartialDocumentInformation, identifier: DocumentIdentifier, metadata?: CaseMetadata): Promise<void | import("../events").ClickEventResponse>;
|
|
96
96
|
logShowLessFoldedResults(metadata?: CaseMetadata): Promise<void | import("../events").CustomEventResponse>;
|
|
97
|
+
logTriggerNotify(triggerNotifyMetadata: TriggerNotifyMetadata, metadata?: CaseMetadata): Promise<void | import("../events").CustomEventResponse>;
|
|
97
98
|
private getBaseCustomEventRequest;
|
|
98
99
|
private getBaseSearchEventRequest;
|
|
99
100
|
private getBaseEventRequest;
|
|
@@ -194,32 +194,37 @@ export interface SmartSnippetDocumentIdentifier {
|
|
|
194
194
|
contentIdValue: string;
|
|
195
195
|
}
|
|
196
196
|
export type PartialDocumentInformation = Omit<DocumentInformation, 'actionCause' | 'searchQueryUid'>;
|
|
197
|
-
|
|
197
|
+
interface AnswerGeneratedWithAnswerAPI {
|
|
198
|
+
answerAPIStreamId: string;
|
|
199
|
+
generativeQuestionAnsweringId?: never;
|
|
200
|
+
}
|
|
201
|
+
interface AnswerGeneratedWithSearchAPI {
|
|
202
|
+
answerAPIStreamId?: never;
|
|
198
203
|
generativeQuestionAnsweringId: string;
|
|
199
204
|
}
|
|
200
|
-
export
|
|
205
|
+
export type GeneratedAnswerBaseMeta = AnswerGeneratedWithAnswerAPI | AnswerGeneratedWithSearchAPI;
|
|
206
|
+
export type GeneratedAnswerStreamEndMeta = GeneratedAnswerBaseMeta & {
|
|
201
207
|
answerGenerated: boolean;
|
|
202
208
|
answerTextIsEmpty?: boolean;
|
|
203
|
-
}
|
|
204
|
-
export
|
|
205
|
-
generativeQuestionAnsweringId: string;
|
|
209
|
+
};
|
|
210
|
+
export type GeneratedAnswerCitationMeta = GeneratedAnswerBaseMeta & {
|
|
206
211
|
permanentId: string;
|
|
207
212
|
citationId: string;
|
|
208
|
-
}
|
|
213
|
+
};
|
|
209
214
|
export type GeneratedAnswerFeedbackReason = 'irrelevant' | 'notAccurate' | 'outOfDate' | 'harmful' | 'other';
|
|
210
215
|
export type GeneratedAnswerRephraseFormat = 'step' | 'bullet' | 'concise' | 'default';
|
|
211
|
-
export
|
|
216
|
+
export type GeneratedAnswerSourceHoverMeta = GeneratedAnswerCitationMeta & {
|
|
212
217
|
citationHoverTimeMs: number;
|
|
213
|
-
}
|
|
214
|
-
export
|
|
218
|
+
};
|
|
219
|
+
export type GeneratedAnswerRephraseMeta = GeneratedAnswerBaseMeta & {
|
|
215
220
|
rephraseFormat: GeneratedAnswerRephraseFormat;
|
|
216
|
-
}
|
|
217
|
-
export
|
|
221
|
+
};
|
|
222
|
+
export type GeneratedAnswerFeedbackMeta = GeneratedAnswerBaseMeta & {
|
|
218
223
|
reason: GeneratedAnswerFeedbackReason;
|
|
219
224
|
details?: string;
|
|
220
|
-
}
|
|
225
|
+
};
|
|
221
226
|
export type GeneratedAnswerFeedbackReasonOption = 'yes' | 'unknown' | 'no';
|
|
222
|
-
export
|
|
227
|
+
export type GeneratedAnswerFeedbackMetaV2 = GeneratedAnswerBaseMeta & {
|
|
223
228
|
helpful: boolean;
|
|
224
229
|
readable: GeneratedAnswerFeedbackReasonOption;
|
|
225
230
|
documented: GeneratedAnswerFeedbackReasonOption;
|
|
@@ -227,5 +232,5 @@ export interface GeneratedAnswerFeedbackMetaV2 extends GeneratedAnswerBaseMeta {
|
|
|
227
232
|
hallucinationFree: GeneratedAnswerFeedbackReasonOption;
|
|
228
233
|
details?: string;
|
|
229
234
|
documentUrl?: string;
|
|
230
|
-
}
|
|
235
|
+
};
|
|
231
236
|
export {};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const libVersion = "2.30.
|
|
1
|
+
export declare const libVersion = "2.30.36";
|
package/dist/library.cjs
CHANGED
|
@@ -731,7 +731,7 @@ function sha1(bytes) {
|
|
|
731
731
|
const v5 = v35('v5', 0x50, sha1);
|
|
732
732
|
var uuidv5 = v5;
|
|
733
733
|
|
|
734
|
-
var libVersion = "2.30.
|
|
734
|
+
var libVersion = "2.30.36" ;
|
|
735
735
|
|
|
736
736
|
var getFormattedLocation = function (location) {
|
|
737
737
|
return "".concat(location.protocol, "//").concat(location.hostname).concat(location.pathname.indexOf('/') === 0 ? location.pathname : "/".concat(location.pathname)).concat(location.search);
|
|
@@ -957,6 +957,48 @@ function isObject(o) {
|
|
|
957
957
|
function coerceToNumber(input) {
|
|
958
958
|
return typeof input === 'string' && input != '' && !Number.isNaN(+input) ? +input : input;
|
|
959
959
|
}
|
|
960
|
+
var UTF8_HIGH_BIT = 128;
|
|
961
|
+
var UTF8_HEADER_2 = 192;
|
|
962
|
+
var UTF8_HEADER_3 = 224;
|
|
963
|
+
var UTF8_HEADER_4 = 240;
|
|
964
|
+
function utf8ByteCountFromFirstByte(firstByte) {
|
|
965
|
+
if ((firstByte & 248) === UTF8_HEADER_4) {
|
|
966
|
+
return 4;
|
|
967
|
+
}
|
|
968
|
+
if ((firstByte & UTF8_HEADER_4) === UTF8_HEADER_3) {
|
|
969
|
+
return 3;
|
|
970
|
+
}
|
|
971
|
+
if ((firstByte & UTF8_HEADER_3) === UTF8_HEADER_2) {
|
|
972
|
+
return 2;
|
|
973
|
+
}
|
|
974
|
+
return 1;
|
|
975
|
+
}
|
|
976
|
+
function truncateUrl(input, limit) {
|
|
977
|
+
if (limit < 0 || input.length <= limit) {
|
|
978
|
+
return input;
|
|
979
|
+
}
|
|
980
|
+
var end = input.indexOf('%', limit - 2);
|
|
981
|
+
if (end < 0 || end > limit) {
|
|
982
|
+
end = limit;
|
|
983
|
+
}
|
|
984
|
+
else {
|
|
985
|
+
limit = end;
|
|
986
|
+
}
|
|
987
|
+
while (end > 2 && input.charAt(end - 3) == '%') {
|
|
988
|
+
var peekByte = Number.parseInt(input.substring(end - 2, end), 16);
|
|
989
|
+
if ((peekByte & UTF8_HIGH_BIT) != UTF8_HIGH_BIT) {
|
|
990
|
+
break;
|
|
991
|
+
}
|
|
992
|
+
end -= 3;
|
|
993
|
+
if ((peekByte & UTF8_HEADER_2) != UTF8_HIGH_BIT) {
|
|
994
|
+
if (limit - end >= utf8ByteCountFromFirstByte(peekByte) * 3) {
|
|
995
|
+
end = limit;
|
|
996
|
+
}
|
|
997
|
+
break;
|
|
998
|
+
}
|
|
999
|
+
}
|
|
1000
|
+
return input.substring(0, end);
|
|
1001
|
+
}
|
|
960
1002
|
|
|
961
1003
|
var ticketKeysMapping = {
|
|
962
1004
|
id: 'svc_ticket_id',
|
|
@@ -83680,10 +83722,10 @@ var CoveoAnalyticsClient = (function () {
|
|
|
83680
83722
|
eventType == exports.EventType.click ||
|
|
83681
83723
|
eventType == exports.EventType.search ||
|
|
83682
83724
|
eventType == exports.EventType.custom) {
|
|
83683
|
-
rest.originLevel3 = this.limit(rest.originLevel3,
|
|
83725
|
+
rest.originLevel3 = this.limit(rest.originLevel3, 1024);
|
|
83684
83726
|
}
|
|
83685
83727
|
if (eventType == exports.EventType.view) {
|
|
83686
|
-
rest.location = this.limit(rest.location,
|
|
83728
|
+
rest.location = this.limit(rest.location, 1024);
|
|
83687
83729
|
}
|
|
83688
83730
|
if (eventType == 'pageview' || eventType == 'event') {
|
|
83689
83731
|
rest.referrer = this.limit(rest.referrer, 2048);
|
|
@@ -83720,10 +83762,7 @@ var CoveoAnalyticsClient = (function () {
|
|
|
83720
83762
|
return rest;
|
|
83721
83763
|
};
|
|
83722
83764
|
CoveoAnalyticsClient.prototype.limit = function (input, length) {
|
|
83723
|
-
|
|
83724
|
-
return input;
|
|
83725
|
-
}
|
|
83726
|
-
return input.substring(0, length);
|
|
83765
|
+
return typeof input === 'string' ? truncateUrl(input, length) : input;
|
|
83727
83766
|
};
|
|
83728
83767
|
Object.defineProperty(CoveoAnalyticsClient.prototype, "baseUrl", {
|
|
83729
83768
|
get: function () {
|
|
@@ -86297,6 +86336,9 @@ var CoveoInsightClient = (function () {
|
|
|
86297
86336
|
});
|
|
86298
86337
|
});
|
|
86299
86338
|
};
|
|
86339
|
+
CoveoInsightClient.prototype.logTriggerNotify = function (triggerNotifyMetadata, metadata) {
|
|
86340
|
+
return this.logCustomEvent(exports.SearchPageEvents.triggerNotify, metadata ? __assign(__assign({}, generateMetadataToSend(metadata, false)), triggerNotifyMetadata) : triggerNotifyMetadata);
|
|
86341
|
+
};
|
|
86300
86342
|
CoveoInsightClient.prototype.getBaseCustomEventRequest = function (metadata) {
|
|
86301
86343
|
return __awaiter(this, void 0, void 0, function () {
|
|
86302
86344
|
var _a;
|
package/dist/library.es.js
CHANGED
|
@@ -596,7 +596,7 @@ function sha1(bytes) {
|
|
|
596
596
|
const v5 = v35('v5', 0x50, sha1);
|
|
597
597
|
var uuidv5 = v5;
|
|
598
598
|
|
|
599
|
-
const libVersion = "2.30.
|
|
599
|
+
const libVersion = "2.30.36" ;
|
|
600
600
|
|
|
601
601
|
const getFormattedLocation = (location) => `${location.protocol}//${location.hostname}${location.pathname.indexOf('/') === 0 ? location.pathname : `/${location.pathname}`}${location.search}`;
|
|
602
602
|
|
|
@@ -792,6 +792,48 @@ const keysOf = Object.keys;
|
|
|
792
792
|
function isObject(o) {
|
|
793
793
|
return o !== null && typeof o === 'object' && !Array.isArray(o);
|
|
794
794
|
}
|
|
795
|
+
const UTF8_HIGH_BIT = 128;
|
|
796
|
+
const UTF8_HEADER_2 = 192;
|
|
797
|
+
const UTF8_HEADER_3 = 224;
|
|
798
|
+
const UTF8_HEADER_4 = 240;
|
|
799
|
+
function utf8ByteCountFromFirstByte(firstByte) {
|
|
800
|
+
if ((firstByte & 248) === UTF8_HEADER_4) {
|
|
801
|
+
return 4;
|
|
802
|
+
}
|
|
803
|
+
if ((firstByte & UTF8_HEADER_4) === UTF8_HEADER_3) {
|
|
804
|
+
return 3;
|
|
805
|
+
}
|
|
806
|
+
if ((firstByte & UTF8_HEADER_3) === UTF8_HEADER_2) {
|
|
807
|
+
return 2;
|
|
808
|
+
}
|
|
809
|
+
return 1;
|
|
810
|
+
}
|
|
811
|
+
function truncateUrl(input, limit) {
|
|
812
|
+
if (limit < 0 || input.length <= limit) {
|
|
813
|
+
return input;
|
|
814
|
+
}
|
|
815
|
+
let end = input.indexOf('%', limit - 2);
|
|
816
|
+
if (end < 0 || end > limit) {
|
|
817
|
+
end = limit;
|
|
818
|
+
}
|
|
819
|
+
else {
|
|
820
|
+
limit = end;
|
|
821
|
+
}
|
|
822
|
+
while (end > 2 && input.charAt(end - 3) == '%') {
|
|
823
|
+
const peekByte = Number.parseInt(input.substring(end - 2, end), 16);
|
|
824
|
+
if ((peekByte & UTF8_HIGH_BIT) != UTF8_HIGH_BIT) {
|
|
825
|
+
break;
|
|
826
|
+
}
|
|
827
|
+
end -= 3;
|
|
828
|
+
if ((peekByte & UTF8_HEADER_2) != UTF8_HIGH_BIT) {
|
|
829
|
+
if (limit - end >= utf8ByteCountFromFirstByte(peekByte) * 3) {
|
|
830
|
+
end = limit;
|
|
831
|
+
}
|
|
832
|
+
break;
|
|
833
|
+
}
|
|
834
|
+
}
|
|
835
|
+
return input.substring(0, end);
|
|
836
|
+
}
|
|
795
837
|
|
|
796
838
|
const ticketKeysMapping = {
|
|
797
839
|
id: 'svc_ticket_id',
|
|
@@ -1635,10 +1677,10 @@ class CoveoAnalyticsClient {
|
|
|
1635
1677
|
eventType == EventType.click ||
|
|
1636
1678
|
eventType == EventType.search ||
|
|
1637
1679
|
eventType == EventType.custom) {
|
|
1638
|
-
rest.originLevel3 = this.limit(rest.originLevel3,
|
|
1680
|
+
rest.originLevel3 = this.limit(rest.originLevel3, 1024);
|
|
1639
1681
|
}
|
|
1640
1682
|
if (eventType == EventType.view) {
|
|
1641
|
-
rest.location = this.limit(rest.location,
|
|
1683
|
+
rest.location = this.limit(rest.location, 1024);
|
|
1642
1684
|
}
|
|
1643
1685
|
if (eventType == 'pageview' || eventType == 'event') {
|
|
1644
1686
|
rest.referrer = this.limit(rest.referrer, 2048);
|
|
@@ -1675,10 +1717,7 @@ class CoveoAnalyticsClient {
|
|
|
1675
1717
|
return rest;
|
|
1676
1718
|
}
|
|
1677
1719
|
limit(input, length) {
|
|
1678
|
-
|
|
1679
|
-
return input;
|
|
1680
|
-
}
|
|
1681
|
-
return input.substring(0, length);
|
|
1720
|
+
return typeof input === 'string' ? truncateUrl(input, length) : input;
|
|
1682
1721
|
}
|
|
1683
1722
|
get baseUrl() {
|
|
1684
1723
|
return buildBaseUrl(this.options.endpoint, this.options.version, this.options.isCustomEndpoint);
|
|
@@ -3264,6 +3303,9 @@ class CoveoInsightClient {
|
|
|
3264
3303
|
return this.logCustomEvent(SearchPageEvents.showLessFoldedResults, metadata ? generateMetadataToSend(metadata, false) : undefined);
|
|
3265
3304
|
});
|
|
3266
3305
|
}
|
|
3306
|
+
logTriggerNotify(triggerNotifyMetadata, metadata) {
|
|
3307
|
+
return this.logCustomEvent(SearchPageEvents.triggerNotify, metadata ? Object.assign(Object.assign({}, generateMetadataToSend(metadata, false)), triggerNotifyMetadata) : triggerNotifyMetadata);
|
|
3308
|
+
}
|
|
3267
3309
|
getBaseCustomEventRequest(metadata) {
|
|
3268
3310
|
return __awaiter(this, void 0, void 0, function* () {
|
|
3269
3311
|
return Object.assign(Object.assign({}, (yield this.getBaseEventRequest(metadata))), { lastSearchQueryUid: this.provider.getSearchUID() });
|
package/dist/library.js
CHANGED
|
@@ -731,7 +731,7 @@ function sha1(bytes) {
|
|
|
731
731
|
const v5 = v35('v5', 0x50, sha1);
|
|
732
732
|
var uuidv5 = v5;
|
|
733
733
|
|
|
734
|
-
var libVersion = "2.30.
|
|
734
|
+
var libVersion = "2.30.36" ;
|
|
735
735
|
|
|
736
736
|
var getFormattedLocation = function (location) {
|
|
737
737
|
return "".concat(location.protocol, "//").concat(location.hostname).concat(location.pathname.indexOf('/') === 0 ? location.pathname : "/".concat(location.pathname)).concat(location.search);
|
|
@@ -957,6 +957,48 @@ function isObject(o) {
|
|
|
957
957
|
function coerceToNumber(input) {
|
|
958
958
|
return typeof input === 'string' && input != '' && !Number.isNaN(+input) ? +input : input;
|
|
959
959
|
}
|
|
960
|
+
var UTF8_HIGH_BIT = 128;
|
|
961
|
+
var UTF8_HEADER_2 = 192;
|
|
962
|
+
var UTF8_HEADER_3 = 224;
|
|
963
|
+
var UTF8_HEADER_4 = 240;
|
|
964
|
+
function utf8ByteCountFromFirstByte(firstByte) {
|
|
965
|
+
if ((firstByte & 248) === UTF8_HEADER_4) {
|
|
966
|
+
return 4;
|
|
967
|
+
}
|
|
968
|
+
if ((firstByte & UTF8_HEADER_4) === UTF8_HEADER_3) {
|
|
969
|
+
return 3;
|
|
970
|
+
}
|
|
971
|
+
if ((firstByte & UTF8_HEADER_3) === UTF8_HEADER_2) {
|
|
972
|
+
return 2;
|
|
973
|
+
}
|
|
974
|
+
return 1;
|
|
975
|
+
}
|
|
976
|
+
function truncateUrl(input, limit) {
|
|
977
|
+
if (limit < 0 || input.length <= limit) {
|
|
978
|
+
return input;
|
|
979
|
+
}
|
|
980
|
+
var end = input.indexOf('%', limit - 2);
|
|
981
|
+
if (end < 0 || end > limit) {
|
|
982
|
+
end = limit;
|
|
983
|
+
}
|
|
984
|
+
else {
|
|
985
|
+
limit = end;
|
|
986
|
+
}
|
|
987
|
+
while (end > 2 && input.charAt(end - 3) == '%') {
|
|
988
|
+
var peekByte = Number.parseInt(input.substring(end - 2, end), 16);
|
|
989
|
+
if ((peekByte & UTF8_HIGH_BIT) != UTF8_HIGH_BIT) {
|
|
990
|
+
break;
|
|
991
|
+
}
|
|
992
|
+
end -= 3;
|
|
993
|
+
if ((peekByte & UTF8_HEADER_2) != UTF8_HIGH_BIT) {
|
|
994
|
+
if (limit - end >= utf8ByteCountFromFirstByte(peekByte) * 3) {
|
|
995
|
+
end = limit;
|
|
996
|
+
}
|
|
997
|
+
break;
|
|
998
|
+
}
|
|
999
|
+
}
|
|
1000
|
+
return input.substring(0, end);
|
|
1001
|
+
}
|
|
960
1002
|
|
|
961
1003
|
var ticketKeysMapping = {
|
|
962
1004
|
id: 'svc_ticket_id',
|
|
@@ -83680,10 +83722,10 @@ var CoveoAnalyticsClient = (function () {
|
|
|
83680
83722
|
eventType == exports.EventType.click ||
|
|
83681
83723
|
eventType == exports.EventType.search ||
|
|
83682
83724
|
eventType == exports.EventType.custom) {
|
|
83683
|
-
rest.originLevel3 = this.limit(rest.originLevel3,
|
|
83725
|
+
rest.originLevel3 = this.limit(rest.originLevel3, 1024);
|
|
83684
83726
|
}
|
|
83685
83727
|
if (eventType == exports.EventType.view) {
|
|
83686
|
-
rest.location = this.limit(rest.location,
|
|
83728
|
+
rest.location = this.limit(rest.location, 1024);
|
|
83687
83729
|
}
|
|
83688
83730
|
if (eventType == 'pageview' || eventType == 'event') {
|
|
83689
83731
|
rest.referrer = this.limit(rest.referrer, 2048);
|
|
@@ -83720,10 +83762,7 @@ var CoveoAnalyticsClient = (function () {
|
|
|
83720
83762
|
return rest;
|
|
83721
83763
|
};
|
|
83722
83764
|
CoveoAnalyticsClient.prototype.limit = function (input, length) {
|
|
83723
|
-
|
|
83724
|
-
return input;
|
|
83725
|
-
}
|
|
83726
|
-
return input.substring(0, length);
|
|
83765
|
+
return typeof input === 'string' ? truncateUrl(input, length) : input;
|
|
83727
83766
|
};
|
|
83728
83767
|
Object.defineProperty(CoveoAnalyticsClient.prototype, "baseUrl", {
|
|
83729
83768
|
get: function () {
|
|
@@ -86297,6 +86336,9 @@ var CoveoInsightClient = (function () {
|
|
|
86297
86336
|
});
|
|
86298
86337
|
});
|
|
86299
86338
|
};
|
|
86339
|
+
CoveoInsightClient.prototype.logTriggerNotify = function (triggerNotifyMetadata, metadata) {
|
|
86340
|
+
return this.logCustomEvent(exports.SearchPageEvents.triggerNotify, metadata ? __assign(__assign({}, generateMetadataToSend(metadata, false)), triggerNotifyMetadata) : triggerNotifyMetadata);
|
|
86341
|
+
};
|
|
86300
86342
|
CoveoInsightClient.prototype.getBaseCustomEventRequest = function (metadata) {
|
|
86301
86343
|
return __awaiter(this, void 0, void 0, function () {
|
|
86302
86344
|
var _a;
|
package/dist/library.mjs
CHANGED
|
@@ -729,7 +729,7 @@ function sha1(bytes) {
|
|
|
729
729
|
const v5 = v35('v5', 0x50, sha1);
|
|
730
730
|
var uuidv5 = v5;
|
|
731
731
|
|
|
732
|
-
var libVersion = "2.30.
|
|
732
|
+
var libVersion = "2.30.36" ;
|
|
733
733
|
|
|
734
734
|
var getFormattedLocation = function (location) {
|
|
735
735
|
return "".concat(location.protocol, "//").concat(location.hostname).concat(location.pathname.indexOf('/') === 0 ? location.pathname : "/".concat(location.pathname)).concat(location.search);
|
|
@@ -955,6 +955,48 @@ function isObject(o) {
|
|
|
955
955
|
function coerceToNumber(input) {
|
|
956
956
|
return typeof input === 'string' && input != '' && !Number.isNaN(+input) ? +input : input;
|
|
957
957
|
}
|
|
958
|
+
var UTF8_HIGH_BIT = 128;
|
|
959
|
+
var UTF8_HEADER_2 = 192;
|
|
960
|
+
var UTF8_HEADER_3 = 224;
|
|
961
|
+
var UTF8_HEADER_4 = 240;
|
|
962
|
+
function utf8ByteCountFromFirstByte(firstByte) {
|
|
963
|
+
if ((firstByte & 248) === UTF8_HEADER_4) {
|
|
964
|
+
return 4;
|
|
965
|
+
}
|
|
966
|
+
if ((firstByte & UTF8_HEADER_4) === UTF8_HEADER_3) {
|
|
967
|
+
return 3;
|
|
968
|
+
}
|
|
969
|
+
if ((firstByte & UTF8_HEADER_3) === UTF8_HEADER_2) {
|
|
970
|
+
return 2;
|
|
971
|
+
}
|
|
972
|
+
return 1;
|
|
973
|
+
}
|
|
974
|
+
function truncateUrl(input, limit) {
|
|
975
|
+
if (limit < 0 || input.length <= limit) {
|
|
976
|
+
return input;
|
|
977
|
+
}
|
|
978
|
+
var end = input.indexOf('%', limit - 2);
|
|
979
|
+
if (end < 0 || end > limit) {
|
|
980
|
+
end = limit;
|
|
981
|
+
}
|
|
982
|
+
else {
|
|
983
|
+
limit = end;
|
|
984
|
+
}
|
|
985
|
+
while (end > 2 && input.charAt(end - 3) == '%') {
|
|
986
|
+
var peekByte = Number.parseInt(input.substring(end - 2, end), 16);
|
|
987
|
+
if ((peekByte & UTF8_HIGH_BIT) != UTF8_HIGH_BIT) {
|
|
988
|
+
break;
|
|
989
|
+
}
|
|
990
|
+
end -= 3;
|
|
991
|
+
if ((peekByte & UTF8_HEADER_2) != UTF8_HIGH_BIT) {
|
|
992
|
+
if (limit - end >= utf8ByteCountFromFirstByte(peekByte) * 3) {
|
|
993
|
+
end = limit;
|
|
994
|
+
}
|
|
995
|
+
break;
|
|
996
|
+
}
|
|
997
|
+
}
|
|
998
|
+
return input.substring(0, end);
|
|
999
|
+
}
|
|
958
1000
|
|
|
959
1001
|
var ticketKeysMapping = {
|
|
960
1002
|
id: 'svc_ticket_id',
|
|
@@ -83678,10 +83720,10 @@ var CoveoAnalyticsClient = (function () {
|
|
|
83678
83720
|
eventType == EventType.click ||
|
|
83679
83721
|
eventType == EventType.search ||
|
|
83680
83722
|
eventType == EventType.custom) {
|
|
83681
|
-
rest.originLevel3 = this.limit(rest.originLevel3,
|
|
83723
|
+
rest.originLevel3 = this.limit(rest.originLevel3, 1024);
|
|
83682
83724
|
}
|
|
83683
83725
|
if (eventType == EventType.view) {
|
|
83684
|
-
rest.location = this.limit(rest.location,
|
|
83726
|
+
rest.location = this.limit(rest.location, 1024);
|
|
83685
83727
|
}
|
|
83686
83728
|
if (eventType == 'pageview' || eventType == 'event') {
|
|
83687
83729
|
rest.referrer = this.limit(rest.referrer, 2048);
|
|
@@ -83718,10 +83760,7 @@ var CoveoAnalyticsClient = (function () {
|
|
|
83718
83760
|
return rest;
|
|
83719
83761
|
};
|
|
83720
83762
|
CoveoAnalyticsClient.prototype.limit = function (input, length) {
|
|
83721
|
-
|
|
83722
|
-
return input;
|
|
83723
|
-
}
|
|
83724
|
-
return input.substring(0, length);
|
|
83763
|
+
return typeof input === 'string' ? truncateUrl(input, length) : input;
|
|
83725
83764
|
};
|
|
83726
83765
|
Object.defineProperty(CoveoAnalyticsClient.prototype, "baseUrl", {
|
|
83727
83766
|
get: function () {
|
|
@@ -86295,6 +86334,9 @@ var CoveoInsightClient = (function () {
|
|
|
86295
86334
|
});
|
|
86296
86335
|
});
|
|
86297
86336
|
};
|
|
86337
|
+
CoveoInsightClient.prototype.logTriggerNotify = function (triggerNotifyMetadata, metadata) {
|
|
86338
|
+
return this.logCustomEvent(SearchPageEvents.triggerNotify, metadata ? __assign(__assign({}, generateMetadataToSend(metadata, false)), triggerNotifyMetadata) : triggerNotifyMetadata);
|
|
86339
|
+
};
|
|
86298
86340
|
CoveoInsightClient.prototype.getBaseCustomEventRequest = function (metadata) {
|
|
86299
86341
|
return __awaiter(this, void 0, void 0, function () {
|
|
86300
86342
|
var _a;
|
package/dist/react-native.es.js
CHANGED
|
@@ -665,7 +665,7 @@ const addPageViewToHistory = (pageViewValue) => __awaiter(void 0, void 0, void 0
|
|
|
665
665
|
yield store.addElementAsync(historyElement);
|
|
666
666
|
});
|
|
667
667
|
|
|
668
|
-
const libVersion = "2.30.
|
|
668
|
+
const libVersion = "2.30.36" ;
|
|
669
669
|
|
|
670
670
|
const getFormattedLocation = (location) => `${location.protocol}//${location.hostname}${location.pathname.indexOf('/') === 0 ? location.pathname : `/${location.pathname}`}${location.search}`;
|
|
671
671
|
|
|
@@ -861,6 +861,48 @@ const keysOf = Object.keys;
|
|
|
861
861
|
function isObject(o) {
|
|
862
862
|
return o !== null && typeof o === 'object' && !Array.isArray(o);
|
|
863
863
|
}
|
|
864
|
+
const UTF8_HIGH_BIT = 128;
|
|
865
|
+
const UTF8_HEADER_2 = 192;
|
|
866
|
+
const UTF8_HEADER_3 = 224;
|
|
867
|
+
const UTF8_HEADER_4 = 240;
|
|
868
|
+
function utf8ByteCountFromFirstByte(firstByte) {
|
|
869
|
+
if ((firstByte & 248) === UTF8_HEADER_4) {
|
|
870
|
+
return 4;
|
|
871
|
+
}
|
|
872
|
+
if ((firstByte & UTF8_HEADER_4) === UTF8_HEADER_3) {
|
|
873
|
+
return 3;
|
|
874
|
+
}
|
|
875
|
+
if ((firstByte & UTF8_HEADER_3) === UTF8_HEADER_2) {
|
|
876
|
+
return 2;
|
|
877
|
+
}
|
|
878
|
+
return 1;
|
|
879
|
+
}
|
|
880
|
+
function truncateUrl(input, limit) {
|
|
881
|
+
if (limit < 0 || input.length <= limit) {
|
|
882
|
+
return input;
|
|
883
|
+
}
|
|
884
|
+
let end = input.indexOf('%', limit - 2);
|
|
885
|
+
if (end < 0 || end > limit) {
|
|
886
|
+
end = limit;
|
|
887
|
+
}
|
|
888
|
+
else {
|
|
889
|
+
limit = end;
|
|
890
|
+
}
|
|
891
|
+
while (end > 2 && input.charAt(end - 3) == '%') {
|
|
892
|
+
const peekByte = Number.parseInt(input.substring(end - 2, end), 16);
|
|
893
|
+
if ((peekByte & UTF8_HIGH_BIT) != UTF8_HIGH_BIT) {
|
|
894
|
+
break;
|
|
895
|
+
}
|
|
896
|
+
end -= 3;
|
|
897
|
+
if ((peekByte & UTF8_HEADER_2) != UTF8_HIGH_BIT) {
|
|
898
|
+
if (limit - end >= utf8ByteCountFromFirstByte(peekByte) * 3) {
|
|
899
|
+
end = limit;
|
|
900
|
+
}
|
|
901
|
+
break;
|
|
902
|
+
}
|
|
903
|
+
}
|
|
904
|
+
return input.substring(0, end);
|
|
905
|
+
}
|
|
864
906
|
|
|
865
907
|
const ticketKeysMapping = {
|
|
866
908
|
id: 'svc_ticket_id',
|
|
@@ -1636,10 +1678,10 @@ class CoveoAnalyticsClient {
|
|
|
1636
1678
|
eventType == EventType.click ||
|
|
1637
1679
|
eventType == EventType.search ||
|
|
1638
1680
|
eventType == EventType.custom) {
|
|
1639
|
-
rest.originLevel3 = this.limit(rest.originLevel3,
|
|
1681
|
+
rest.originLevel3 = this.limit(rest.originLevel3, 1024);
|
|
1640
1682
|
}
|
|
1641
1683
|
if (eventType == EventType.view) {
|
|
1642
|
-
rest.location = this.limit(rest.location,
|
|
1684
|
+
rest.location = this.limit(rest.location, 1024);
|
|
1643
1685
|
}
|
|
1644
1686
|
if (eventType == 'pageview' || eventType == 'event') {
|
|
1645
1687
|
rest.referrer = this.limit(rest.referrer, 2048);
|
|
@@ -1676,10 +1718,7 @@ class CoveoAnalyticsClient {
|
|
|
1676
1718
|
return rest;
|
|
1677
1719
|
}
|
|
1678
1720
|
limit(input, length) {
|
|
1679
|
-
|
|
1680
|
-
return input;
|
|
1681
|
-
}
|
|
1682
|
-
return input.substring(0, length);
|
|
1721
|
+
return typeof input === 'string' ? truncateUrl(input, length) : input;
|
|
1683
1722
|
}
|
|
1684
1723
|
get baseUrl() {
|
|
1685
1724
|
return buildBaseUrl(this.options.endpoint, this.options.version, this.options.isCustomEndpoint);
|
|
@@ -3285,6 +3324,9 @@ class CoveoInsightClient {
|
|
|
3285
3324
|
return this.logCustomEvent(SearchPageEvents.showLessFoldedResults, metadata ? generateMetadataToSend(metadata, false) : undefined);
|
|
3286
3325
|
});
|
|
3287
3326
|
}
|
|
3327
|
+
logTriggerNotify(triggerNotifyMetadata, metadata) {
|
|
3328
|
+
return this.logCustomEvent(SearchPageEvents.triggerNotify, metadata ? Object.assign(Object.assign({}, generateMetadataToSend(metadata, false)), triggerNotifyMetadata) : triggerNotifyMetadata);
|
|
3329
|
+
}
|
|
3288
3330
|
getBaseCustomEventRequest(metadata) {
|
|
3289
3331
|
return __awaiter(this, void 0, void 0, function* () {
|
|
3290
3332
|
return Object.assign(Object.assign({}, (yield this.getBaseEventRequest(metadata))), { lastSearchQueryUid: this.provider.getSearchUID() });
|
package/package.json
CHANGED
|
@@ -15,7 +15,6 @@ import {BrowserRuntime, NoopRuntime} from './runtimeEnvironment';
|
|
|
15
15
|
import * as doNotTrack from '../donottrack';
|
|
16
16
|
import {Cookie} from '../cookieutils';
|
|
17
17
|
import {CoveoLinkParam} from '../plugins/link';
|
|
18
|
-
import {NoopAnalytics} from './noopAnalytics';
|
|
19
18
|
|
|
20
19
|
const aVisitorId = '123';
|
|
21
20
|
jest.mock('uuid', () => ({
|
|
@@ -279,9 +278,11 @@ describe('Analytics', () => {
|
|
|
279
278
|
});
|
|
280
279
|
});
|
|
281
280
|
|
|
282
|
-
describe('should truncate the maxlength for URL parameters at
|
|
283
|
-
const desiredMax: number =
|
|
284
|
-
|
|
281
|
+
describe('should truncate the maxlength for URL parameters at 1024 characters for ua events', () => {
|
|
282
|
+
const desiredMax: number = 1024;
|
|
283
|
+
// Craft the URL so the truncation point falls in the %20 sequence
|
|
284
|
+
const longUrl: string = 'http://coveo.com/?q=' + 'a'.repeat(desiredMax - 22) + '%20b';
|
|
285
|
+
const expectedTruncatedLength = longUrl.lastIndexOf('%', desiredMax);
|
|
285
286
|
expect(longUrl.length).toBeGreaterThan(desiredMax);
|
|
286
287
|
async function testEventType(type: EventType, url: string) {
|
|
287
288
|
mockFetchRequestForEventType(type);
|
|
@@ -290,8 +291,10 @@ describe('Analytics', () => {
|
|
|
290
291
|
originLevel3: url,
|
|
291
292
|
});
|
|
292
293
|
const [body] = getParsedBodyCalls();
|
|
293
|
-
if (type == EventType.view)
|
|
294
|
-
|
|
294
|
+
if (type == EventType.view) {
|
|
295
|
+
expect(body.location).toHaveLength(expectedTruncatedLength);
|
|
296
|
+
}
|
|
297
|
+
expect(body.originLevel3).toHaveLength(expectedTruncatedLength);
|
|
295
298
|
}
|
|
296
299
|
it('for view events', () => testEventType(EventType.view, longUrl));
|
|
297
300
|
it('for click events', () => testEventType(EventType.click, longUrl));
|
package/src/client/analytics.ts
CHANGED
|
@@ -35,8 +35,7 @@ import HistoryStore from '../history';
|
|
|
35
35
|
import {isApiKey} from './token';
|
|
36
36
|
import {isReactNative, ReactNativeRuntimeWarning} from '../react-native/react-native-utils';
|
|
37
37
|
import {doNotTrack} from '../donottrack';
|
|
38
|
-
import {
|
|
39
|
-
import {isObject} from './utils';
|
|
38
|
+
import {isObject, truncateUrl} from './utils';
|
|
40
39
|
|
|
41
40
|
export const Version = 'v15';
|
|
42
41
|
|
|
@@ -607,10 +606,10 @@ export class CoveoAnalyticsClient implements AnalyticsClient, VisitorIdProvider
|
|
|
607
606
|
eventType == EventType.search ||
|
|
608
607
|
eventType == EventType.custom
|
|
609
608
|
) {
|
|
610
|
-
rest.originLevel3 = this.limit(rest.originLevel3,
|
|
609
|
+
rest.originLevel3 = this.limit(rest.originLevel3, 1024);
|
|
611
610
|
}
|
|
612
611
|
if (eventType == EventType.view) {
|
|
613
|
-
rest.location = this.limit(rest.location,
|
|
612
|
+
rest.location = this.limit(rest.location, 1024);
|
|
614
613
|
}
|
|
615
614
|
if (eventType == 'pageview' || eventType == 'event') {
|
|
616
615
|
rest.referrer = this.limit(rest.referrer, 2048);
|
|
@@ -651,11 +650,8 @@ export class CoveoAnalyticsClient implements AnalyticsClient, VisitorIdProvider
|
|
|
651
650
|
return rest;
|
|
652
651
|
}
|
|
653
652
|
|
|
654
|
-
private limit(input:
|
|
655
|
-
|
|
656
|
-
return input;
|
|
657
|
-
}
|
|
658
|
-
return input.substring(0, length);
|
|
653
|
+
private limit<T>(input: T, length: number): T {
|
|
654
|
+
return typeof input === 'string' ? (truncateUrl(input, length) as T) : input;
|
|
659
655
|
}
|
|
660
656
|
|
|
661
657
|
private get baseUrl(): string {
|