coveo.analytics 2.19.14 → 2.20.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/coveoua.browser.js +1 -1
- package/dist/coveoua.browser.js.map +1 -1
- package/dist/coveoua.js +1 -1
- package/dist/coveoua.js.map +1 -1
- package/dist/definitions/searchPage/searchPageClient.d.ts +1 -0
- package/dist/definitions/searchPage/searchPageEvents.d.ts +1 -0
- package/dist/library.es.js +7 -3
- package/dist/library.js +7 -3
- package/package.json +2 -2
- package/src/caseAssist/caseAssistClient.spec.ts +19 -2
- package/src/caseAssist/caseAssistClient.ts +2 -1
- package/src/searchPage/searchPageClient.spec.ts +28 -1
- package/src/searchPage/searchPageClient.ts +12 -2
- package/src/searchPage/searchPageEvents.ts +4 -0
|
@@ -81,6 +81,7 @@ export declare class CoveoSearchPageClient {
|
|
|
81
81
|
logShowMoreSmartSnippetSuggestion(snippet: SmartSnippetSuggestionMeta): Promise<void | import("../events").CustomEventResponse>;
|
|
82
82
|
logShowLessSmartSnippetSuggestion(snippet: SmartSnippetSuggestionMeta): Promise<void | import("../events").CustomEventResponse>;
|
|
83
83
|
logOpenSmartSnippetSource(info: PartialDocumentInformation, identifier: DocumentIdentifier): Promise<void | import("../events").ClickEventResponse>;
|
|
84
|
+
logOpenSmartSnippetSuggestionSource(info: PartialDocumentInformation, snippet: SmartSnippetSuggestionMeta): Promise<void | import("../events").ClickEventResponse>;
|
|
84
85
|
logRecentQueryClick(): Promise<void | import("../events").SearchEventResponse>;
|
|
85
86
|
logClearRecentQueries(): Promise<void | import("../events").CustomEventResponse>;
|
|
86
87
|
logRecentResultClick(info: PartialDocumentInformation, identifier: DocumentIdentifier): Promise<void | import("../events").CustomEventResponse>;
|
|
@@ -56,6 +56,7 @@ export declare enum SearchPageEvents {
|
|
|
56
56
|
showMoreSmartSnippetSuggestion = "showMoreSmartSnippetSuggestion",
|
|
57
57
|
showLessSmartSnippetSuggestion = "showLessSmartSnippetSuggestion",
|
|
58
58
|
openSmartSnippetSource = "openSmartSnippetSource",
|
|
59
|
+
openSmartSnippetSuggestionSource = "openSmartSnippetSuggestionSource",
|
|
59
60
|
recentQueryClick = "recentQueriesClick",
|
|
60
61
|
clearRecentQueries = "clearRecentQueries",
|
|
61
62
|
recentResultClick = "recentResultClick",
|
package/dist/library.es.js
CHANGED
|
@@ -1114,6 +1114,7 @@ var SearchPageEvents;
|
|
|
1114
1114
|
SearchPageEvents["showMoreSmartSnippetSuggestion"] = "showMoreSmartSnippetSuggestion";
|
|
1115
1115
|
SearchPageEvents["showLessSmartSnippetSuggestion"] = "showLessSmartSnippetSuggestion";
|
|
1116
1116
|
SearchPageEvents["openSmartSnippetSource"] = "openSmartSnippetSource";
|
|
1117
|
+
SearchPageEvents["openSmartSnippetSuggestionSource"] = "openSmartSnippetSuggestionSource";
|
|
1117
1118
|
SearchPageEvents["recentQueryClick"] = "recentQueriesClick";
|
|
1118
1119
|
SearchPageEvents["clearRecentQueries"] = "clearRecentQueries";
|
|
1119
1120
|
SearchPageEvents["recentResultClick"] = "recentResultClick";
|
|
@@ -1234,8 +1235,8 @@ class CoveoSearchPageClient {
|
|
|
1234
1235
|
constructor(opts, provider) {
|
|
1235
1236
|
this.opts = opts;
|
|
1236
1237
|
this.provider = provider;
|
|
1237
|
-
|
|
1238
|
-
|
|
1238
|
+
const shouldDisableAnalytics = opts.enableAnalytics === false || doNotTrack();
|
|
1239
|
+
this.coveoAnalyticsClient = shouldDisableAnalytics ? new NoopAnalytics() : new CoveoAnalyticsClient(opts);
|
|
1239
1240
|
}
|
|
1240
1241
|
disable() {
|
|
1241
1242
|
if (this.coveoAnalyticsClient instanceof CoveoAnalyticsClient) {
|
|
@@ -1428,6 +1429,9 @@ class CoveoSearchPageClient {
|
|
|
1428
1429
|
logOpenSmartSnippetSource(info, identifier) {
|
|
1429
1430
|
return this.logClickEvent(SearchPageEvents.openSmartSnippetSource, info, identifier);
|
|
1430
1431
|
}
|
|
1432
|
+
logOpenSmartSnippetSuggestionSource(info, snippet) {
|
|
1433
|
+
return this.logClickEvent(SearchPageEvents.openSmartSnippetSuggestionSource, info, { contentIDKey: snippet.documentId.contentIdKey, contentIDValue: snippet.documentId.contentIdValue }, snippet);
|
|
1434
|
+
}
|
|
1431
1435
|
logRecentQueryClick() {
|
|
1432
1436
|
return this.logSearchEvent(SearchPageEvents.recentQueryClick);
|
|
1433
1437
|
}
|
|
@@ -1677,7 +1681,7 @@ class CaseAssistClient {
|
|
|
1677
1681
|
var _a;
|
|
1678
1682
|
this.options = options;
|
|
1679
1683
|
this.provider = provider;
|
|
1680
|
-
const analyticsEnabled = (_a = options.enableAnalytics) !== null && _a !== void 0 ? _a : true;
|
|
1684
|
+
const analyticsEnabled = ((_a = options.enableAnalytics) !== null && _a !== void 0 ? _a : true) && !doNotTrack();
|
|
1681
1685
|
this.coveoAnalyticsClient = analyticsEnabled ? new CoveoAnalyticsClient(options) : new NoopAnalytics();
|
|
1682
1686
|
this.svc = new SVCPlugin({ client: this.coveoAnalyticsClient });
|
|
1683
1687
|
}
|
package/dist/library.js
CHANGED
|
@@ -83556,6 +83556,7 @@ var SearchPageEvents;
|
|
|
83556
83556
|
SearchPageEvents["showMoreSmartSnippetSuggestion"] = "showMoreSmartSnippetSuggestion";
|
|
83557
83557
|
SearchPageEvents["showLessSmartSnippetSuggestion"] = "showLessSmartSnippetSuggestion";
|
|
83558
83558
|
SearchPageEvents["openSmartSnippetSource"] = "openSmartSnippetSource";
|
|
83559
|
+
SearchPageEvents["openSmartSnippetSuggestionSource"] = "openSmartSnippetSuggestionSource";
|
|
83559
83560
|
SearchPageEvents["recentQueryClick"] = "recentQueriesClick";
|
|
83560
83561
|
SearchPageEvents["clearRecentQueries"] = "clearRecentQueries";
|
|
83561
83562
|
SearchPageEvents["recentResultClick"] = "recentResultClick";
|
|
@@ -83677,8 +83678,8 @@ var CoveoSearchPageClient = (function () {
|
|
|
83677
83678
|
function CoveoSearchPageClient(opts, provider) {
|
|
83678
83679
|
this.opts = opts;
|
|
83679
83680
|
this.provider = provider;
|
|
83680
|
-
|
|
83681
|
-
|
|
83681
|
+
var shouldDisableAnalytics = opts.enableAnalytics === false || doNotTrack();
|
|
83682
|
+
this.coveoAnalyticsClient = shouldDisableAnalytics ? new NoopAnalytics() : new CoveoAnalyticsClient(opts);
|
|
83682
83683
|
}
|
|
83683
83684
|
CoveoSearchPageClient.prototype.disable = function () {
|
|
83684
83685
|
if (this.coveoAnalyticsClient instanceof CoveoAnalyticsClient) {
|
|
@@ -83889,6 +83890,9 @@ var CoveoSearchPageClient = (function () {
|
|
|
83889
83890
|
CoveoSearchPageClient.prototype.logOpenSmartSnippetSource = function (info, identifier) {
|
|
83890
83891
|
return this.logClickEvent(SearchPageEvents.openSmartSnippetSource, info, identifier);
|
|
83891
83892
|
};
|
|
83893
|
+
CoveoSearchPageClient.prototype.logOpenSmartSnippetSuggestionSource = function (info, snippet) {
|
|
83894
|
+
return this.logClickEvent(SearchPageEvents.openSmartSnippetSuggestionSource, info, { contentIDKey: snippet.documentId.contentIdKey, contentIDValue: snippet.documentId.contentIdValue }, snippet);
|
|
83895
|
+
};
|
|
83892
83896
|
CoveoSearchPageClient.prototype.logRecentQueryClick = function () {
|
|
83893
83897
|
return this.logSearchEvent(SearchPageEvents.recentQueryClick);
|
|
83894
83898
|
};
|
|
@@ -84057,7 +84061,7 @@ var CaseAssistClient = (function () {
|
|
|
84057
84061
|
var _a;
|
|
84058
84062
|
this.options = options;
|
|
84059
84063
|
this.provider = provider;
|
|
84060
|
-
var analyticsEnabled = (_a = options.enableAnalytics) !== null && _a !== void 0 ? _a : true;
|
|
84064
|
+
var analyticsEnabled = ((_a = options.enableAnalytics) !== null && _a !== void 0 ? _a : true) && !doNotTrack();
|
|
84061
84065
|
this.coveoAnalyticsClient = analyticsEnabled ? new CoveoAnalyticsClient(options) : new NoopAnalytics();
|
|
84062
84066
|
this.svc = new SVCPlugin({ client: this.coveoAnalyticsClient });
|
|
84063
84067
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "coveo.analytics",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.20.1",
|
|
4
4
|
"description": "📈 Coveo analytics client (node and browser compatible) ",
|
|
5
5
|
"main": "dist/library.js",
|
|
6
6
|
"module": "dist/library.es.js",
|
|
@@ -23,7 +23,7 @@
|
|
|
23
23
|
},
|
|
24
24
|
"license": "MIT",
|
|
25
25
|
"dependencies": {
|
|
26
|
-
"@react-native-async-storage/async-storage": "^1.17.
|
|
26
|
+
"@react-native-async-storage/async-storage": "^1.17.5",
|
|
27
27
|
"cross-fetch": "^3.1.5"
|
|
28
28
|
},
|
|
29
29
|
"devDependencies": {
|
|
@@ -6,11 +6,16 @@ import {
|
|
|
6
6
|
DocumentSuggestion,
|
|
7
7
|
FieldSuggestion,
|
|
8
8
|
} from './caseAssistActions';
|
|
9
|
-
|
|
10
9
|
import {mockFetch} from '../../tests/fetchMock';
|
|
11
10
|
import {TicketProperties} from '../plugins/svc';
|
|
12
|
-
|
|
13
11
|
const {fetchMock, fetchMockBeforeEach} = mockFetch();
|
|
12
|
+
import doNotTrack from '../donottrack';
|
|
13
|
+
jest.mock('../donottrack', () => {
|
|
14
|
+
return {
|
|
15
|
+
default: jest.fn(),
|
|
16
|
+
doNotTrack: jest.fn(),
|
|
17
|
+
};
|
|
18
|
+
});
|
|
14
19
|
|
|
15
20
|
describe('CaseAssistClient', () => {
|
|
16
21
|
const defaultSearchHub = 'origin-level-1';
|
|
@@ -151,6 +156,18 @@ describe('CaseAssistClient', () => {
|
|
|
151
156
|
expect(fetchMock.called()).toBe(false);
|
|
152
157
|
});
|
|
153
158
|
|
|
159
|
+
it('should not send events when doNotTrack is enabled', async () => {
|
|
160
|
+
(doNotTrack as jest.Mock).mockImplementationOnce(() => true);
|
|
161
|
+
|
|
162
|
+
client = new CaseAssistClient({});
|
|
163
|
+
|
|
164
|
+
await client.logEnterInterface({
|
|
165
|
+
ticket: emptyTicket,
|
|
166
|
+
});
|
|
167
|
+
|
|
168
|
+
expect(fetchMock.called()).toBe(false);
|
|
169
|
+
});
|
|
170
|
+
|
|
154
171
|
it('should not send events after #disable function is called', async () => {
|
|
155
172
|
client.disable();
|
|
156
173
|
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import CoveoAnalyticsClient, {AnalyticsClient, ClientOptions} from '../client/analytics';
|
|
2
2
|
import {NoopAnalytics} from '../client/noopAnalytics';
|
|
3
|
+
import doNotTrack from '../donottrack';
|
|
3
4
|
import {SVCPlugin} from '../plugins/svc';
|
|
4
5
|
import {
|
|
5
6
|
CaseAssistActions,
|
|
@@ -29,7 +30,7 @@ export class CaseAssistClient {
|
|
|
29
30
|
private svc: SVCPlugin;
|
|
30
31
|
|
|
31
32
|
constructor(private options: Partial<CaseAssistClientOptions>, private provider?: CaseAssistClientProvider) {
|
|
32
|
-
const analyticsEnabled = options.enableAnalytics ?? true;
|
|
33
|
+
const analyticsEnabled = (options.enableAnalytics ?? true) && !doNotTrack();
|
|
33
34
|
|
|
34
35
|
this.coveoAnalyticsClient = analyticsEnabled ? new CoveoAnalyticsClient(options) : new NoopAnalytics();
|
|
35
36
|
this.svc = new SVCPlugin({client: this.coveoAnalyticsClient});
|
|
@@ -10,7 +10,13 @@ import {
|
|
|
10
10
|
import CoveoAnalyticsClient from '../client/analytics';
|
|
11
11
|
import {NoopAnalytics} from '../client/noopAnalytics';
|
|
12
12
|
import {mockFetch} from '../../tests/fetchMock';
|
|
13
|
-
|
|
13
|
+
import doNotTrack from '../donottrack';
|
|
14
|
+
jest.mock('../donottrack', () => {
|
|
15
|
+
return {
|
|
16
|
+
default: jest.fn(),
|
|
17
|
+
doNotTrack: jest.fn(),
|
|
18
|
+
};
|
|
19
|
+
});
|
|
14
20
|
const {fetchMock, fetchMockBeforeEach} = mockFetch();
|
|
15
21
|
|
|
16
22
|
describe('SearchPageClient', () => {
|
|
@@ -594,6 +600,20 @@ describe('SearchPageClient', () => {
|
|
|
594
600
|
expectMatchDocumentPayload(SearchPageEvents.openSmartSnippetSource, fakeDocInfo, fakeDocID);
|
|
595
601
|
});
|
|
596
602
|
|
|
603
|
+
it('should send proper payload for #logOpenSmartSnippetSuggestionSource', async () => {
|
|
604
|
+
const meta = {
|
|
605
|
+
question: 'Abc',
|
|
606
|
+
answerSnippet: 'Def',
|
|
607
|
+
documentId: {contentIdKey: 'permanentid', contentIdValue: 'foo'},
|
|
608
|
+
};
|
|
609
|
+
await client.logOpenSmartSnippetSuggestionSource(fakeDocInfo, meta);
|
|
610
|
+
expectMatchDocumentPayload(SearchPageEvents.openSmartSnippetSuggestionSource, fakeDocInfo, {
|
|
611
|
+
...meta,
|
|
612
|
+
contentIDKey: meta.documentId.contentIdKey,
|
|
613
|
+
contentIDValue: meta.documentId.contentIdValue,
|
|
614
|
+
});
|
|
615
|
+
});
|
|
616
|
+
|
|
597
617
|
it('should send proper payload for #logRecentQueryClick', async () => {
|
|
598
618
|
await client.logRecentQueryClick();
|
|
599
619
|
expectMatchPayload(SearchPageEvents.recentQueryClick);
|
|
@@ -637,6 +657,13 @@ describe('SearchPageClient', () => {
|
|
|
637
657
|
expect(c.coveoAnalyticsClient instanceof NoopAnalytics).toBe(true);
|
|
638
658
|
});
|
|
639
659
|
|
|
660
|
+
it('should disable analytics when doNotTrack is enabled', async () => {
|
|
661
|
+
(doNotTrack as jest.Mock).mockImplementationOnce(() => true);
|
|
662
|
+
|
|
663
|
+
const c = new CoveoSearchPageClient({}, provider);
|
|
664
|
+
expect(c.coveoAnalyticsClient instanceof NoopAnalytics).toBe(true);
|
|
665
|
+
});
|
|
666
|
+
|
|
640
667
|
it('should allow disabling analytics after initialization', () => {
|
|
641
668
|
const c = new CoveoSearchPageClient({enableAnalytics: true}, provider);
|
|
642
669
|
expect(c.coveoAnalyticsClient instanceof CoveoAnalyticsClient).toBe(true);
|
|
@@ -28,6 +28,7 @@ import {
|
|
|
28
28
|
} from './searchPageEvents';
|
|
29
29
|
import {NoopAnalytics} from '../client/noopAnalytics';
|
|
30
30
|
import {formatOmniboxMetadata} from '../formatting/format-omnibox-metadata';
|
|
31
|
+
import doNotTrack from '../donottrack';
|
|
31
32
|
|
|
32
33
|
export interface SearchPageClientProvider {
|
|
33
34
|
getBaseMetadata: () => Record<string, any>;
|
|
@@ -51,8 +52,8 @@ export class CoveoSearchPageClient {
|
|
|
51
52
|
public coveoAnalyticsClient: AnalyticsClient;
|
|
52
53
|
|
|
53
54
|
constructor(private opts: Partial<SearchPageClientOptions>, private provider: SearchPageClientProvider) {
|
|
54
|
-
|
|
55
|
-
|
|
55
|
+
const shouldDisableAnalytics = opts.enableAnalytics === false || doNotTrack();
|
|
56
|
+
this.coveoAnalyticsClient = shouldDisableAnalytics ? new NoopAnalytics() : new CoveoAnalyticsClient(opts);
|
|
56
57
|
}
|
|
57
58
|
|
|
58
59
|
public disable() {
|
|
@@ -311,6 +312,15 @@ export class CoveoSearchPageClient {
|
|
|
311
312
|
return this.logClickEvent(SearchPageEvents.openSmartSnippetSource, info, identifier);
|
|
312
313
|
}
|
|
313
314
|
|
|
315
|
+
public logOpenSmartSnippetSuggestionSource(info: PartialDocumentInformation, snippet: SmartSnippetSuggestionMeta) {
|
|
316
|
+
return this.logClickEvent(
|
|
317
|
+
SearchPageEvents.openSmartSnippetSuggestionSource,
|
|
318
|
+
info,
|
|
319
|
+
{contentIDKey: snippet.documentId.contentIdKey, contentIDValue: snippet.documentId.contentIdValue},
|
|
320
|
+
snippet
|
|
321
|
+
);
|
|
322
|
+
}
|
|
323
|
+
|
|
314
324
|
public logRecentQueryClick() {
|
|
315
325
|
return this.logSearchEvent(SearchPageEvents.recentQueryClick);
|
|
316
326
|
}
|
|
@@ -229,6 +229,10 @@ export enum SearchPageEvents {
|
|
|
229
229
|
* Identifies the custom event that gets logged when a user clicks on the source of an answer in a smart snippet.
|
|
230
230
|
*/
|
|
231
231
|
openSmartSnippetSource = 'openSmartSnippetSource',
|
|
232
|
+
/**
|
|
233
|
+
* Identifies the custom event that gets logged when a user clicks on the source of a snippet suggestion for a related question.
|
|
234
|
+
*/
|
|
235
|
+
openSmartSnippetSuggestionSource = 'openSmartSnippetSuggestionSource',
|
|
232
236
|
/**
|
|
233
237
|
* Identifies the search event that gets logged when a recent queries list item gets clicked.
|
|
234
238
|
*/
|