Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 7 additions & 6 deletions .cspell.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,7 @@
"cache": {
"useCache": true
},
"ignorePaths": [
"CHANGELOG.md",
"packages/platform-mock-api/src/converse/templates/**",
"packages/coveo-analytics/README.md",
"packages/coveo-analytics/docs/technical-overview.md"
],
"ignorePaths": ["CHANGELOG.md", "packages/platform-mock-api/src/converse/templates/**"],
"import": ["@cspell/dict-fr-fr/cspell-ext.json"],
"words": [
"adjustednumberoflikes",
Expand Down Expand Up @@ -344,6 +339,12 @@
"ytvideoduration",
"ytvideoid",
"ytviewcount",
"coveoanalytics",
"donottrack",
"pageviewid",
"storeid",
"uuidv",
"uuidvalidate",
"γίγγλυμος",
"στόμα"
]
Expand Down
2 changes: 1 addition & 1 deletion packages/coveo-analytics/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ Since calls to the coveo analytics service need to be authenticated, the library

## Available actions

After the library has loaded sucessfully, you can interact with coveoua through the global `coveoua` function. Any interaction with the library happens through this function by supplying both a action name, followed by an optional series of action arguments. The following actions are available:
After the library has loaded successfully, you can interact with coveoua through the global `coveoua` function. Any interaction with the library happens through this function by supplying both an action name, followed by an optional series of action arguments. The following actions are available:

### Initialization

Expand Down
4 changes: 2 additions & 2 deletions packages/coveo-analytics/docs/technical-overview.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,11 +38,11 @@ This section holds the library that is compiled for browser usage. It wraps the

### src/formatting

This sections holds some formatting methods for metadata.
This section holds some formatting methods for metadata.

### src/hook

This section holds "hooks" that are executed on sending a new event. It is mostly used to centralise a specific logic that modifies the event in some way.
This section holds "hooks" that are executed on sending a new event. It is mostly used to centralize a specific logic that modifies the event in some way.

`addDefaultValues.ts` ensures that some values are always included

Expand Down
25 changes: 10 additions & 15 deletions packages/coveo-analytics/functional/ec-events.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ describe('ec events', () => {
brand: 'brand',
unknown: 'ok',
});
coveoua('ec:setAction', 'detail', {storeid: 'amazing'});
coveoua('ec:setAction', 'detail', {storeid: 'testStoreId'});
await coveoua('send', 'pageview');

const [body] = getParsedBody();
Expand All @@ -124,7 +124,7 @@ describe('ec events', () => {
it('can send a product detail view event with custom values', async () => {
coveoua('ec:addProduct', {name: 'wow', id: 'something', brand: 'brand'});
coveoua('ec:setAction', 'detail', {
storeid: 'amazing',
storeid: 'testStoreId',
custom: {verycustom: 'value'},
});
await coveoua('send', 'pageview');
Expand Down Expand Up @@ -606,7 +606,7 @@ describe('ec events', () => {

it('context_website does not overwrite trackingId', async () => {
const contextWebsite = 'tracksite';
const trackingId = 'trackingid';
const trackingId = 'testTrackingId';
await coveoua('set', 'custom', {context_website: contextWebsite});
await coveoua('set', 'trackingId', trackingId);
await coveoua('send', 'pageview');
Expand Down Expand Up @@ -649,7 +649,7 @@ describe('ec events', () => {

it('siteName does not overwrite trackingId', async () => {
const website = 'tracksite';
const trackingId = 'trackingid';
const trackingId = 'testTrackingId';
await coveoua('set', 'custom', {siteName: website});
await coveoua('set', 'trackingId', trackingId);
await coveoua('send', 'pageview');
Expand All @@ -667,7 +667,7 @@ describe('ec events', () => {
describe('with auto-detection of userId', () => {
describe('with API key', () => {
beforeEach(() => {
coveoua('init', 'xxapikey', anEndpoint);
coveoua('init', 'testApiKey', anEndpoint);
});

it('should set userId to anonymous', async () => {
Expand Down Expand Up @@ -697,12 +697,7 @@ describe('ec events', () => {
});
describe('with Search Token', () => {
beforeEach(() => {
const searchToken =
'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.' +
'eyJ1cmwiOiJodHRwczovL3d3dy55b3V0dWJlLmNvb' +
'S93YXRjaD92PW9IZzVTSllSSEEwIiwidXNlcklkIj' +
'oiUmljayBBc3RsZXkiLCJleHAiOjE1MTYyMzkwMjJ9.' +
'gOxUfMZuwMFw-QK-q0xOKJ-23YgGwFJbncCIHgIxjcc';
const searchToken = 'e30.e30.e30';
coveoua('init', searchToken, anEndpoint);
});

Expand Down Expand Up @@ -780,7 +775,7 @@ describe('ec events', () => {
});

it('should be able to set the anonymizeIp to true for anything in between', async () => {
await coveoua('set', 'anonymizeIp', 'pôtato');
await coveoua('set', 'anonymizeIp', 'testValue');
await coveoua('send', 'pageview');

const [event] = getParsedBody();
Expand Down Expand Up @@ -1008,7 +1003,7 @@ describe('ec events', () => {
it('can send a product with the group property', async () => {
await coveoua('ec:addProduct', {
id: 'something',
group: 'nsync',
group: 'testGroup',
});
await coveoua('send', 'event');

Expand All @@ -1018,7 +1013,7 @@ describe('ec events', () => {
...defaultContextValues,
t: 'event',
pr1id: 'something',
pr1group: 'nsync',
pr1group: 'testGroup',
});
});

Expand Down Expand Up @@ -1060,7 +1055,7 @@ describe('ec events', () => {
// @ts-ignore
delete window.location;
// @ts-ignore
// Ooommmpf... JSDOM does not support any form of navigation, so let's overwrite the whole thing 💥.
// Warning: JSDOM does not support any form of navigation, so let's overwrite the whole thing 💥.
window.location = new URL(url);
};

Expand Down
10 changes: 5 additions & 5 deletions packages/coveo-analytics/functional/svc-events.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ describe('svc events', () => {
coveoua('svc:setTicket', {
subject: 'super subject',
description: 'some description',
category: 'some smort category',
category: 'testCategory',
custom: {verycustom: 'value'},
});

Expand All @@ -81,7 +81,7 @@ describe('svc events', () => {
svc_action_data: {classificationId: 'someId', requestID: 'someReqId'},
svc_ticket_subject: 'super subject',
svc_ticket_description: 'some description',
svc_ticket_category: 'some smort category',
svc_ticket_category: 'testCategory',
svc_ticket_custom: {verycustom: 'value'},
});
});
Expand All @@ -90,7 +90,7 @@ describe('svc events', () => {
await coveoua('svc:setTicket', {
subject: 'super subject',
description: 'some description',
category: 'some smort category',
category: 'testCategory',
custom: {verycustom: 'value'},
unknown: 'ok',
});
Expand All @@ -103,7 +103,7 @@ describe('svc events', () => {
t: 'event',
svc_ticket_subject: 'super subject',
svc_ticket_description: 'some description',
svc_ticket_category: 'some smort category',
svc_ticket_category: 'testCategory',
svc_ticket_custom: {verycustom: 'value'},
});
});
Expand All @@ -116,7 +116,7 @@ describe('svc events', () => {
// @ts-ignore
delete window.location;
// @ts-ignore
// Ooommmpf... JSDOM does not support any form of navigation, so let's overwrite the whole thing 💥.
// Warning: JSDOM does not support any form of navigation, so let's overwrite the whole thing 💥.
window.location = new URL(url);
};
});
12 changes: 6 additions & 6 deletions packages/coveo-analytics/src/client/analytics.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -268,9 +268,9 @@ describe('Analytics', () => {
await client.sendEvent(EventType.view, {
fine: 1,
ok: 0,
notok: '',
emptyField: '',
invalid: null,
ohno: undefined,
undefinedField: undefined,
});

const [body] = getParsedBodyCalls();
Expand Down Expand Up @@ -439,7 +439,7 @@ describe('Analytics', () => {
describe('for API keys', () => {
beforeEach(() => {
client = new CoveoAnalyticsClient({
token: 'xxapikey',
token: 'testApiKey',
endpoint: anEndpoint,
version: A_VERSION,
});
Expand Down Expand Up @@ -487,7 +487,7 @@ describe('Analytics', () => {
describe('for OAuth Tokens', () => {
beforeEach(() => {
client = new CoveoAnalyticsClient({
token: 'xtoken',
token: 'testToken',
endpoint: anEndpoint,
version: A_VERSION,
});
Expand Down Expand Up @@ -515,7 +515,7 @@ describe('Analytics', () => {
const trackingId = 'yourfavoritefood.ca ';
beforeEach(() => {
client = new CoveoAnalyticsClient({
token: 'xtoken',
token: 'testToken',
endpoint: anEndpoint,
version: A_VERSION,
});
Expand Down Expand Up @@ -545,7 +545,7 @@ describe('Analytics', () => {
const trackingId = 'yourfavoritefood.ca ';
beforeEach(() => {
client = new CoveoAnalyticsClient({
token: 'xtoken',
token: 'testToken',
endpoint: anEndpoint,
version: A_VERSION,
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import {
describe('AnalyticsBeaconClient', () => {
const baseUrl = 'https://bloup.com';
const token = '👛';
const currentVisitorId = 'hereiam';
const currentVisitorId = 'mockVisitorId';

const originalSendBeacon = navigator.sendBeacon;
const sendBeaconMock = jest.fn();
Expand Down
4 changes: 2 additions & 2 deletions packages/coveo-analytics/src/client/analyticsFetchClient.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ export class AnalyticsFetchClient implements AnalyticsRequestClient {
try {
response = await fetch(url, fetchData);
} catch (error) {
console.error('An error has occured when sending the event.', error);
console.error('An error has occurred when sending the event.', error);
return;
}

Expand All @@ -55,7 +55,7 @@ export class AnalyticsFetchClient implements AnalyticsRequestClient {
/* If you don't parse the response, it won't appear in the network tab. */
}
console.error(
`An error has occured when sending the "${eventType}" event.`,
`An error has occurred when sending the "${eventType}" event.`,
response,
payload
);
Expand Down
20 changes: 10 additions & 10 deletions packages/coveo-analytics/src/coveoua/simpleanalytics.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ class TestPluginWithSpy extends TestPlugin {
describe('simpleanalytics', () => {
const analyticsClientMock = createAnalyticsClientMock();
const analyticsEndpoint = 'https://analytics.cloud.coveo.com/rest/ua/v15/analytics';
const someRandomEventName = 'kawabunga';
const someRandomEventName = 'testEventName';

beforeEach(() => {
jest.clearAllMocks();
Expand Down Expand Up @@ -133,23 +133,23 @@ describe('simpleanalytics', () => {

it('uses EC, SVC and Link plugins by default', () => {
coveoua('init', 'SOME TOKEN');
expect(() => coveoua('callPlugin', 'ec', 'nosuchfunction')).toThrow(/does not exist/);
expect(() => coveoua('callPlugin', 'svc', 'nosuchfunction')).toThrow(/does not exist/);
expect(() => coveoua('callPlugin', 'link', 'nosuchfunction')).toThrow(/does not exist/);
expect(() => coveoua('callPlugin', 'ec', 'missingFunction')).toThrow(/does not exist/);
expect(() => coveoua('callPlugin', 'svc', 'missingFunction')).toThrow(/does not exist/);
expect(() => coveoua('callPlugin', 'link', 'missingFunction')).toThrow(/does not exist/);
});

it('can accept no plugins', () => {
coveoua('init', 'SOME TOKEN', {plugins: []});
expect(() => coveoua('callPlugin', 'ec', 'nosuchfunction')).toThrow(/is not required/);
expect(() => coveoua('callPlugin', 'svc', 'nosuchfunction')).toThrow(/is not required/);
expect(() => coveoua('callPlugin', 'link', 'nosuchfunction')).toThrow(/is not required/);
expect(() => coveoua('callPlugin', 'ec', 'missingFunction')).toThrow(/is not required/);
expect(() => coveoua('callPlugin', 'svc', 'missingFunction')).toThrow(/is not required/);
expect(() => coveoua('callPlugin', 'link', 'missingFunction')).toThrow(/is not required/);
});

it('can accept one plugin', () => {
coveoua('init', 'SOME TOKEN', {plugins: ['svc']});
expect(() => coveoua('callPlugin', 'ec', 'nosuchfunction')).toThrow(/is not required/);
expect(() => coveoua('callPlugin', 'link', 'nosuchfunction')).toThrow(/is not required/);
expect(() => coveoua('callPlugin', 'svc', 'nosuchfunction')).toThrow(/does not exist/);
expect(() => coveoua('callPlugin', 'ec', 'missingFunction')).toThrow(/is not required/);
expect(() => coveoua('callPlugin', 'link', 'missingFunction')).toThrow(/is not required/);
expect(() => coveoua('callPlugin', 'svc', 'missingFunction')).toThrow(/does not exist/);
});

it('can send pageview with analyticsClient', () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ describe('#formatArrayForCoveoCustomData', () => {

it('correctly truncates the data when it contains more than 256 characters', () => {
const longString =
/* cspell:disable-next-line */
'Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Aenean commodo ligula eget dolor. Aenean massa. Cum sociis natoque penatibus et magnis dis parturient montes, nascetur ridiculus mus. Donec quam felis, ultricies nec, pellentesque eu, pretium quis,';
const rawData = ['1', longString];
expect(formatArrayForCoveoCustomData(rawData)).toEqual(longString);
Expand Down
2 changes: 1 addition & 1 deletion packages/coveo-analytics/src/insight/insightClient.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1835,7 +1835,7 @@ describe('InsightClient', () => {
const document = {
title: 'Some Title',
uri: 'https://www.some-uri.com',
uriHash: 'Acp8NfEWi0DeðeZU',
uriHash: 'testUriHash',
permanentId: '8c88cd894t2767a96fa4f109041bb62bb54ca21ff31c1d760814b60cbcf2',
};
await client.logViewedDocumentClick(document, baseCaseMetadata);
Expand Down
8 changes: 4 additions & 4 deletions packages/coveo-analytics/src/plugins/ec.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ describe('EC plugin', () => {
});

it('should not append the product with a random event type', () => {
ec.addProduct({id: ':sorandom:'});
ec.addProduct({id: ':testProductId:'});

const result = executeRegisteredHook('🎲', {});

Expand Down Expand Up @@ -299,7 +299,7 @@ describe('EC plugin', () => {
});

it('should not append the impression with a random event type', () => {
ec.addImpression({id: ':sorandom:'});
ec.addImpression({id: ':testProductId:'});

const result = executeRegisteredHook('🎲', {});

Expand Down Expand Up @@ -330,14 +330,14 @@ describe('EC plugin', () => {
});

it('should convert known impression keys that are extended for Coveo into the measurement protocol format', () => {
ec.addImpression({name: '🧀', group: 'mahgroup'});
ec.addImpression({name: '🧀', group: 'testGroup'});

const result = executeRegisteredHook(ECPluginEventTypes.event, {});

expect(result).toEqual({
...defaultResult,
il1pi1nm: '🧀',
il1pi1group: 'mahgroup',
il1pi1group: 'testGroup',
});
});

Expand Down
2 changes: 1 addition & 1 deletion packages/coveo-analytics/src/plugins/link.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,7 @@ describe('CoveoLinkPlugin', () => {
});

it('errors on invalid urls', async () => {
const url: string = 'somethingthatisobviouslynotaurl';
const url: string = 'invalidTestUrl';
await expect(link.decorate(url)).rejects.toThrow('Invalid URL provided');
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ export interface ReactNativeRuntimeOptions {
storage: ReactNativeStorage;
/**
* Key for storing the visitor ID value.
* @defaut visitorId
* @default visitorId
*/
visitorIdKey?: string;
token?: string;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ describe('ReactNativeRuntime', () => {

it('should call "storage.getItem" when getting the visitor ID', async () => {
jest.spyOn(runtimeEnvironment.storage, 'setItem');
await client.setCurrentVisitorId('myid');
await client.setCurrentVisitorId('testVisitorId');
expect(runtimeEnvironment.storage.setItem).toHaveBeenCalled();
});
});
2 changes: 1 addition & 1 deletion packages/coveo-analytics/tests/analyticsClientMock.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import {NoopAnalytics} from '../src/client/noopAnalytics';
import {NoopRuntime} from '../src/client/runtimeEnvironment';
import {AnyEventResponse, EventType} from '../src/events';

export const visitorIdMock = 'mockvisitorid';
export const visitorIdMock = 'mockVisitorId';

const makeEvent = (eventType: EventType | string) =>
Promise.resolve({
Expand Down
Loading