Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

coveo.analytics

Package Overview
Dependencies
Maintainers
16
Versions
259
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

coveo.analytics - npm Package Compare versions

Comparing version 2.23.8 to 2.23.9

1

dist/definitions/client/analytics.d.ts

@@ -102,2 +102,3 @@ import { AnyEventResponse, ClickEventRequest, ClickEventResponse, CustomEventRequest, CustomEventResponse, EventType, HealthResponse, SearchEventRequest, SearchEventResponse, ViewEventRequest, ViewEventResponse, VisitResponse, VariableArgumentsPayload, PreparedClickEventRequest, PreparedCustomEventRequest, PreparedViewEventRequest, PreparedSearchEventRequest } from '../events';

private processCustomParameters;
private mapCustomParametersToCustomData;
private lowercaseKeys;

@@ -104,0 +105,0 @@ private validateParams;

export declare const keysOf: <T>(o: T) => Extract<keyof T, string>[];
export declare function isObject(o: any): boolean;

2

package.json
{
"name": "coveo.analytics",
"version": "2.23.8",
"version": "2.23.9",
"description": "📈 Coveo analytics client (node and browser compatible) ",

@@ -5,0 +5,0 @@ "main": "dist/library.js",

@@ -37,2 +37,3 @@ import {

import {NullStorage} from '../storage';
import {isObject} from './utils';

@@ -298,3 +299,5 @@ export const Version = 'v15';

const processCustomParameters: ProcessPayloadStep = (currentPayload) =>
usesMeasurementProtocol ? this.processCustomParameters(currentPayload) : currentPayload;
usesMeasurementProtocol
? this.processCustomParameters(currentPayload)
: this.mapCustomParametersToCustomData(currentPayload);

@@ -494,5 +497,7 @@ const payloadToSend = await [

const {custom, ...rest} = payload;
let lowercasedCustom = {};
if (custom && isObject(custom)) {
lowercasedCustom = this.lowercaseKeys(custom);
}
const lowercasedCustom = this.lowercaseKeys(custom);
const newPayload = convertCustomMeasurementProtocolKeys(rest);

@@ -506,12 +511,19 @@

private lowercaseKeys(custom: any) {
const keys = Object.keys(custom || {});
private mapCustomParametersToCustomData(payload: IRequestPayload): IRequestPayload {
const {custom, ...rest} = payload;
if (custom && isObject(custom)) {
const lowercasedCustom = this.lowercaseKeys(custom);
return {...rest, customData: {...lowercasedCustom, ...payload.customData}};
} else {
return payload;
}
}
return keys.reduce(
(all, key) => ({
...all,
[key.toLowerCase()]: custom[key],
}),
{}
);
private lowercaseKeys(custom: Record<string, unknown>) {
const keys = Object.keys(custom);
let result: Record<string, unknown> = {};
keys.forEach((key) => {
result[key.toLowerCase() as string] = custom[key];
});
return result;
}

@@ -518,0 +530,0 @@

// Object.keys returns `string[]` this adds types
// see https://github.com/microsoft/TypeScript/pull/12253#issuecomment-393954723
export const keysOf = Object.keys as <T>(o: T) => Extract<keyof T, string>[];
export function isObject(o: any): boolean {
return o !== null && typeof o === 'object' && !Array.isArray(o);
}

@@ -41,3 +41,3 @@ import {PluginClass, PluginOptions, BasePlugin} from '../plugins/BasePlugin';

if (!actionFunction) {
throw new Error(`The function "${fn}" does not exists on the plugin "${name}".`);
throw new Error(`The function "${fn}" does not exist on the plugin "${name}".`);
}

@@ -44,0 +44,0 @@ if (typeof actionFunction !== 'function') {

@@ -1,5 +0,3 @@

import {handleOneAnalyticsEvent} from './simpleanalytics';
import coveoua from './simpleanalytics';
import {createAnalyticsClientMock, visitorIdMock} from '../../tests/analyticsClientMock';
import {EC} from '../plugins/ec';
import {SVC} from '../plugins/svc';
import {TestPlugin} from '../../tests/pluginMock';

@@ -11,17 +9,2 @@ import {uuidv4} from '../client/crypto';

jest.mock('../plugins/svc', () => {
const SVC = jest.fn().mockImplementation(() => {});
(SVC as any)['Id'] = 'svc';
return {
SVC: SVC,
};
});
jest.mock('../plugins/ec', () => {
const EC = jest.fn().mockImplementation(() => {});
(EC as any)['Id'] = 'ec';
return {
EC: EC,
};
});
const uuidv4Mock = jest.fn();

@@ -44,3 +27,3 @@ jest.mock('../client/crypto', () => ({

}
someProperty: 'foo';
someProperty: string = 'foo';
}

@@ -61,3 +44,3 @@

uuidv4Mock.mockImplementationOnce(() => visitorIdMock);
handleOneAnalyticsEvent('reset');
coveoua('reset');
});

@@ -73,7 +56,7 @@

it('throws when initializing without a token', () => {
expect(() => handleOneAnalyticsEvent('init')).toThrow(`You must pass your token when you call 'init'`);
expect(() => coveoua('init')).toThrow(`You must pass your token when you call 'init'`);
});
it('throws when initializing with a token that is not a string nor a AnalyticClient', () => {
expect(() => handleOneAnalyticsEvent('init', {})).toThrow(
expect(() => coveoua('init', {})).toThrow(
`You must pass either your token or a valid object when you call 'init'`

@@ -84,13 +67,13 @@ );

it('can initialize with analyticsClient', () => {
expect(() => handleOneAnalyticsEvent('init', analyticsClientMock)).not.toThrow();
expect(() => coveoua('init', analyticsClientMock)).not.toThrow();
});
it('can initialize with a token', () => {
expect(() => handleOneAnalyticsEvent('init', 'SOME TOKEN')).not.toThrow();
expect(() => coveoua('init', 'SOME TOKEN')).not.toThrow();
});
it('default to analytics.cloud.coveo.com when no endpoint is given', async () => {
handleOneAnalyticsEvent('init', 'SOME TOKEN');
coveoua('init', 'SOME TOKEN');
await handleOneAnalyticsEvent('send', 'pageview');
await coveoua('send', 'pageview');

@@ -103,5 +86,5 @@ expect(fetchMock.calls().length).toBe(1);

it('default to analytics.cloud.coveo.com when the endpoint is an empty string', async () => {
handleOneAnalyticsEvent('init', 'SOME TOKEN', '');
coveoua('init', 'SOME TOKEN', '');
await handleOneAnalyticsEvent('send', 'pageview');
await coveoua('send', 'pageview');

@@ -114,5 +97,5 @@ expect(fetchMock.calls().length).toBe(1);

it('default to analytics.cloud.coveo.com when an options object is given but does not include an endpoint', async () => {
handleOneAnalyticsEvent('init', 'SOME TOKEN', {});
coveoua('init', 'SOME TOKEN', {});
await handleOneAnalyticsEvent('send', 'pageview');
await coveoua('send', 'pageview');

@@ -124,5 +107,5 @@ expect(fetchMock.calls().length).toBe(1);

it('default to analytics.cloud.coveo.com when an options object is given but the endpoint property is falsy', async () => {
handleOneAnalyticsEvent('init', 'SOME TOKEN', {endpoint: ''});
coveoua('init', 'SOME TOKEN', {endpoint: ''});
await handleOneAnalyticsEvent('send', 'pageview');
await coveoua('send', 'pageview');

@@ -134,5 +117,5 @@ expect(fetchMock.calls().length).toBe(1);

it('uses the endpoint given if its a non-empty string', async () => {
handleOneAnalyticsEvent('init', 'SOME TOKEN', 'https://someendpoint.com');
coveoua('init', 'SOME TOKEN', 'https://someendpoint.com');
await handleOneAnalyticsEvent('send', 'pageview');
await coveoua('send', 'pageview');

@@ -144,5 +127,5 @@ expect(fetchMock.calls().length).toBe(1);

it('uses the endpoint given if the options object include a non-empty string', async () => {
handleOneAnalyticsEvent('init', 'SOME TOKEN', {endpoint: 'https://someendpoint.com'});
coveoua('init', 'SOME TOKEN', {endpoint: 'https://someendpoint.com'});
await handleOneAnalyticsEvent('send', 'pageview');
await coveoua('send', 'pageview');

@@ -154,26 +137,22 @@ expect(fetchMock.calls().length).toBe(1);

it('uses EC and SVC plugins by default', () => {
handleOneAnalyticsEvent('init', 'SOME TOKEN');
expect(SVC).toHaveBeenCalled();
expect(EC).toHaveBeenCalled();
coveoua('init', 'SOME TOKEN');
expect(() => coveoua('callPlugin', 'ec', 'nosuchfunction')).toThrow(/does not exist/);
expect(() => coveoua('callPlugin', 'svc', 'nosuchfunction')).toThrow(/does not exist/);
});
it('can accepts no plugins', () => {
handleOneAnalyticsEvent('init', 'SOME TOKEN', {plugins: []});
expect(SVC).not.toHaveBeenCalled();
expect(EC).not.toHaveBeenCalled();
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/);
});
it('can accepts one plugin', () => {
handleOneAnalyticsEvent('init', 'SOME TOKEN', {plugins: ['svc']});
expect(SVC).toHaveBeenCalled();
expect(EC).not.toHaveBeenCalled();
it('can accept one plugin', () => {
coveoua('init', 'SOME TOKEN', {plugins: ['svc']});
expect(() => coveoua('callPlugin', 'ec', 'nosuchfunction')).toThrow(/is not required/);
expect(() => coveoua('callPlugin', 'svc', 'nosuchfunction')).toThrow(/does not exist/);
});
it('can send pageview with analyticsClient', () => {
handleOneAnalyticsEvent('init', analyticsClientMock);
expect(() => handleOneAnalyticsEvent('send', 'pageview')).not.toThrow();
coveoua('init', analyticsClientMock);
expect(() => coveoua('send', 'pageview')).not.toThrow();
});

@@ -184,9 +163,7 @@ });

it(`throw if the initForProxy don't receive an endpoint`, () => {
expect(() => handleOneAnalyticsEvent('initForProxy')).toThrow(
`You must pass your endpoint when you call 'initForProxy'`
);
expect(() => coveoua('initForProxy')).toThrow(`You must pass your endpoint when you call 'initForProxy'`);
});
it(`throw if the initForProxy receive an endpoint that's is not a string`, () => {
expect(() => handleOneAnalyticsEvent('initForProxy', {})).toThrow(
expect(() => coveoua('initForProxy', {})).toThrow(
`You must pass a string as the endpoint parameter when you call 'initForProxy'`

@@ -199,15 +176,13 @@ );

it('throws when not initialized', () => {
expect(() => handleOneAnalyticsEvent('send')).toThrow(`You must call init before sending an event`);
expect(() => coveoua('send')).toThrow(`You must call init before sending an event`);
});
it('throws when send is called without any other arguments', () => {
handleOneAnalyticsEvent('init', 'MYTOKEN');
expect(() => handleOneAnalyticsEvent('send')).toThrow(
`You must provide an event type when calling "send".`
);
coveoua('init', 'MYTOKEN');
expect(() => coveoua('send')).toThrow(`You must provide an event type when calling "send".`);
});
it('can send pageview', async () => {
handleOneAnalyticsEvent('init', 'MYTOKEN');
await handleOneAnalyticsEvent('send', 'pageview');
coveoua('init', 'MYTOKEN', {plugins: []});
await coveoua('send', 'pageview');

@@ -219,4 +194,4 @@ expect(fetchMock.calls().length).toBe(1);

it('can send pageview with customdata', async () => {
handleOneAnalyticsEvent('init', 'MYTOKEN', {plugins: []});
await handleOneAnalyticsEvent('send', 'pageview', {somedata: 'asd'});
coveoua('init', 'MYTOKEN', {plugins: []});
await coveoua('send', 'pageview', {somedata: 'asd'});

@@ -229,4 +204,4 @@ expect(fetchMock.calls().length).toBe(1);

it('can send view event with clientId', async () => {
handleOneAnalyticsEvent('init', 'MYTOKEN', {plugins: []});
await handleOneAnalyticsEvent('send', 'view');
coveoua('init', 'MYTOKEN', {plugins: []});
await coveoua('send', 'view');

@@ -239,4 +214,4 @@ expect(fetchMock.calls().length).toBe(1);

it('can send any event to the endpoint', async () => {
handleOneAnalyticsEvent('init', 'MYTOKEN');
await handleOneAnalyticsEvent('send', someRandomEventName);
coveoua('init', 'MYTOKEN');
await coveoua('send', someRandomEventName);

@@ -248,4 +223,4 @@ expect(fetchMock.calls().length).toBe(1);

it('can send an event with a proxy endpoint', async () => {
handleOneAnalyticsEvent('initForProxy', 'https://myProxyEndpoint.com');
await handleOneAnalyticsEvent('send', someRandomEventName);
coveoua('initForProxy', 'https://myProxyEndpoint.com');
await coveoua('send', someRandomEventName);

@@ -259,5 +234,5 @@ expect(fetchMock.calls().length).toBe(1);

it('can set a new parameter', async () => {
handleOneAnalyticsEvent('init', 'MYTOKEN');
handleOneAnalyticsEvent('set', 'userId', 'something');
await handleOneAnalyticsEvent('send', someRandomEventName);
coveoua('init', 'MYTOKEN');
coveoua('set', 'userId', 'something');
await coveoua('send', someRandomEventName);

@@ -270,7 +245,7 @@ expect(fetchMock.calls().length).toBe(1);

it('can set parameters using an object', async () => {
handleOneAnalyticsEvent('init', 'MYTOKEN');
handleOneAnalyticsEvent('set', {
coveoua('init', 'MYTOKEN');
coveoua('set', {
userId: 'something',
});
await handleOneAnalyticsEvent('send', someRandomEventName);
await coveoua('send', someRandomEventName);

@@ -281,2 +256,118 @@ expect(fetchMock.calls().length).toBe(1);

});
it('can set a custom_website parameter on a collect event', async () => {
coveoua('init', 'MYTOKEN', {plugins: ['ec']});
coveoua('set', 'custom', {context_website: 'MY_WEBSITE'});
await coveoua('send', 'pageview');
expect(fetchMock.calls().length).toBe(1);
let result = JSON.parse(fetchMock.lastCall()![1]!.body!.toString());
expect(result).toHaveProperty('context_website', 'MY_WEBSITE');
});
it('does not set custom parameters which are strings', async () => {
coveoua('init', 'MYTOKEN', {plugins: ['ec']});
coveoua('set', 'custom', 'test');
await coveoua('send', 'pageview');
expect(fetchMock.calls().length).toBe(1);
let result = JSON.parse(fetchMock.lastCall()![1]!.body!.toString());
expect(Object.keys(result).length).toBe(11);
});
it('does not set custom parameters which are arrays', async () => {
coveoua('init', 'MYTOKEN', {plugins: ['ec']});
coveoua('set', 'custom', ['test']);
await coveoua('send', 'pageview');
expect(fetchMock.calls().length).toBe(1);
let result = JSON.parse(fetchMock.lastCall()![1]!.body!.toString());
expect(Object.keys(result).length).toBe(11);
});
it('does not set custom parameters which are null', async () => {
coveoua('init', 'MYTOKEN', {plugins: ['ec']});
coveoua('set', 'custom', null);
await coveoua('send', 'pageview');
expect(fetchMock.calls().length).toBe(1);
let result = JSON.parse(fetchMock.lastCall()![1]!.body!.toString());
expect(Object.keys(result).length).toBe(11);
});
it('does not set custom parameters which are undefined', async () => {
coveoua('init', 'MYTOKEN', {plugins: ['ec']});
coveoua('set', 'custom', undefined);
await coveoua('send', 'pageview');
expect(fetchMock.calls().length).toBe(1);
let result = JSON.parse(fetchMock.lastCall()![1]!.body!.toString());
expect(Object.keys(result).length).toBe(11);
});
it('can set a custom_website parameter on a non-collect event', async () => {
coveoua('init', 'MYTOKEN', {plugins: []});
coveoua('set', 'custom', {context_website: 'MY_WEBSITE'});
await coveoua('send', 'view', {somedata: 'something'});
expect(fetchMock.calls().length).toBe(1);
let result = JSON.parse(fetchMock.lastCall()![1]!.body!.toString());
expect(result).toHaveProperty('somedata', 'something');
expect(result).toHaveProperty('customData.context_website', 'MY_WEBSITE');
});
it('does not add a customData entry for custom params which are null', async () => {
coveoua('init', 'MYTOKEN', {plugins: []});
coveoua('set', 'custom', null);
await coveoua('send', 'view', {somedata: 'something'});
expect(fetchMock.calls().length).toBe(1);
let result = JSON.parse(fetchMock.lastCall()![1]!.body!.toString());
expect(result).toHaveProperty('somedata', 'something');
expect(result).not.toHaveProperty('customData');
});
it('does not add a customData entry for custom params which are undefined', async () => {
coveoua('init', 'MYTOKEN', {plugins: []});
coveoua('set', 'custom', undefined);
await coveoua('send', 'view', {somedata: 'something'});
expect(fetchMock.calls().length).toBe(1);
let result = JSON.parse(fetchMock.lastCall()![1]!.body!.toString());
expect(result).toHaveProperty('somedata', 'something');
expect(result).not.toHaveProperty('customData');
});
it('does not add a customData entry for customData params which are strings', async () => {
coveoua('init', 'MYTOKEN', {plugins: []});
coveoua('set', 'custom', 'test');
await coveoua('send', 'view', {somedata: 'something'});
expect(fetchMock.calls().length).toBe(1);
let result = JSON.parse(fetchMock.lastCall()![1]!.body!.toString());
expect(result).toHaveProperty('somedata', 'something');
expect(result).not.toHaveProperty('customData');
});
it('does not add a customData entry for customData params which are arrays', async () => {
coveoua('init', 'MYTOKEN', [{plugins: []}]);
coveoua('set', 'custom', [test]);
await coveoua('send', 'view', {somedata: 'something'});
expect(fetchMock.calls().length).toBe(1);
let result = JSON.parse(fetchMock.lastCall()![1]!.body!.toString());
expect(result).toHaveProperty('somedata', 'something');
expect(result).not.toHaveProperty('customData');
});
it('will not override hardcoded customData parameters', async () => {
coveoua('init', 'MYTOKEN', {plugins: []});
coveoua('set', 'custom', {context_website: 'MY_WEBSITE'});
await coveoua('send', 'view', {somedata: 'something', customData: {context_website: 'MY_OTHER_WEBSITE'}});
expect(fetchMock.calls().length).toBe(1);
let result = JSON.parse(fetchMock.lastCall()![1]!.body!.toString());
expect(result).toHaveProperty('somedata', 'something');
expect(result).toHaveProperty('customData.context_website', 'MY_OTHER_WEBSITE');
});
});

@@ -288,3 +379,3 @@

handleOneAnalyticsEvent('onLoad', callback);
coveoua('onLoad', callback);

@@ -295,3 +386,3 @@ expect(callback).toHaveBeenCalledTimes(1);

it('throws when registering an invalid onLoad event', () => {
expect(() => handleOneAnalyticsEvent('onLoad', undefined)).toThrow();
expect(() => coveoua('onLoad', undefined)).toThrow();
});

@@ -302,7 +393,7 @@ });

it('register properly', () => {
handleOneAnalyticsEvent('provide', 'test', TestPlugin);
coveoua('provide', 'test', TestPlugin);
handleOneAnalyticsEvent('init', 'MYTOKEN');
coveoua('init', 'MYTOKEN');
expect(() => handleOneAnalyticsEvent('require', 'test')).not.toThrow();
expect(() => coveoua('require', 'test')).not.toThrow();
});

@@ -313,6 +404,6 @@ });

it('resolves properly plugin actions', () => {
handleOneAnalyticsEvent('provide', 'test', TestPluginWithSpy);
handleOneAnalyticsEvent('init', 'MYTOKEN', {plugins: ['test']});
coveoua('provide', 'test', TestPluginWithSpy);
coveoua('init', 'MYTOKEN', {plugins: ['test']});
handleOneAnalyticsEvent('callPlugin', 'test', 'testMethod', 'foo', 'bar');
coveoua('callPlugin', 'test', 'testMethod', 'foo', 'bar');

@@ -324,25 +415,18 @@ expect(TestPluginWithSpy.spy).toHaveBeenCalledTimes(1);

it('throws when a namespaced action is called and that the namespace/plugin is not required', () => {
handleOneAnalyticsEvent('init', 'SOME TOKEN', {plugins: ['ec']});
coveoua('init', 'SOME TOKEN', {plugins: ['ec']});
expect(() => handleOneAnalyticsEvent('callPlugin', 'svc', 'setTicket')).toThrow(
`The plugin "svc" is not required. Check that you required it on initialization.`
);
expect(() => coveoua('callPlugin', 'svc', 'setTicket')).toThrow(/is not required/);
});
it('throws when a namespaced action is called and that this action does not exists on the plugin', () => {
handleOneAnalyticsEvent('init', 'SOME TOKEN', {plugins: ['svc']});
coveoua('init', 'SOME TOKEN', {plugins: ['svc']});
expect(() => handleOneAnalyticsEvent('callPlugin', 'svc', 'fooBarBaz')).toThrow(
`The function "fooBarBaz" does not exists on the plugin "svc".`
);
expect(() => coveoua('callPlugin', 'svc', 'fooBarBaz')).toThrow(/does not exist/);
});
it('throws when a namespaced action is called and that this action is not a function on the plugin', () => {
handleOneAnalyticsEvent('provide', 'test', TestPluginWithSpy);
coveoua('provide', 'test', TestPluginWithSpy);
handleOneAnalyticsEvent('init', 'SOME TOKEN', {plugins: ['test']});
expect(() => handleOneAnalyticsEvent('callPlugin', 'test', 'someProperty')).toThrow(
`The function "someProperty" does not exists on the plugin "test".`
);
coveoua('init', 'SOME TOKEN', {plugins: ['test']});
expect(() => coveoua('callPlugin', 'test', 'someProperty')).toThrow(/is not a function/);
});

@@ -353,18 +437,16 @@ });

it('can require a plugin', () => {
handleOneAnalyticsEvent('provide', 'test', TestPlugin);
handleOneAnalyticsEvent('init', 'MYTOKEN', {plugins: []});
coveoua('provide', 'test', TestPlugin);
coveoua('init', 'MYTOKEN', {plugins: []});
expect(() => handleOneAnalyticsEvent('require', 'test')).not.toThrow();
expect(() => coveoua('require', 'test')).not.toThrow();
});
it('throws if not initialized', () => {
expect(() => handleOneAnalyticsEvent('require', 'test')).toThrow(
`You must call init before requiring a plugin`
);
expect(() => coveoua('require', 'test')).toThrow(`You must call init before requiring a plugin`);
});
it('throws if the plugin is not registered first', () => {
handleOneAnalyticsEvent('init', 'MYTOKEN', {plugins: []});
coveoua('init', 'MYTOKEN', {plugins: []});
expect(() => handleOneAnalyticsEvent('require', 'test')).toThrow(
expect(() => coveoua('require', 'test')).toThrow(
`No plugin named "test" is currently registered. If you use a custom plugin, use 'provide' first.`

@@ -377,7 +459,7 @@ );

it('reset the client', () => {
handleOneAnalyticsEvent('init', 'MYTOKEN');
coveoua('init', 'MYTOKEN');
handleOneAnalyticsEvent('reset');
coveoua('reset');
expect(() => handleOneAnalyticsEvent('send')).toThrow(`You must call init before sending an event`);
expect(() => coveoua('send')).toThrow(`You must call init before sending an event`);
});

@@ -387,8 +469,8 @@

const fakePlugin = TestPlugin;
handleOneAnalyticsEvent('provide', 'test', fakePlugin);
handleOneAnalyticsEvent('init', 'MYTOKEN', {plugins: ['test']});
coveoua('provide', 'test', fakePlugin);
coveoua('init', 'MYTOKEN', {plugins: ['test']});
handleOneAnalyticsEvent('reset');
coveoua('reset');
expect(() => handleOneAnalyticsEvent('init', 'MYTOKEN', {plugins: ['test']})).toThrow(
expect(() => coveoua('init', 'MYTOKEN', {plugins: ['test']})).toThrow(
`No plugin named "test" is currently registered. If you use a custom plugin, use 'provide' first.`

@@ -399,9 +481,9 @@ );

it('reset the params', async () => {
handleOneAnalyticsEvent('init', 'MYTOKEN');
handleOneAnalyticsEvent('set', 'userId', 'something');
coveoua('init', 'MYTOKEN');
coveoua('set', 'userId', 'something');
handleOneAnalyticsEvent('reset');
coveoua('reset');
handleOneAnalyticsEvent('init', 'MYTOKEN');
await handleOneAnalyticsEvent('send', someRandomEventName);
coveoua('init', 'MYTOKEN');
await coveoua('send', someRandomEventName);

@@ -415,5 +497,5 @@ expect(fetchMock.calls().length).toBe(1);

it('throws when called with an unknown action', () => {
handleOneAnalyticsEvent('init', 'SOME TOKEN', {plugins: ['svc']});
coveoua('init', 'SOME TOKEN', {plugins: ['svc']});
expect(() => handleOneAnalyticsEvent('potato')).toThrow(
expect(() => coveoua('potato')).toThrow(
`The action "potato" does not exist. Available actions: init, set, send, onLoad, callPlugin, reset, require, provide.`

@@ -424,6 +506,6 @@ );

it('resolves properly plugin actions', () => {
handleOneAnalyticsEvent('provide', 'test', TestPluginWithSpy);
handleOneAnalyticsEvent('init', 'MYTOKEN', {plugins: ['test']});
coveoua('provide', 'test', TestPluginWithSpy);
coveoua('init', 'MYTOKEN', {plugins: ['test']});
handleOneAnalyticsEvent('test:testMethod', 'foo', 'bar');
coveoua('test:testMethod', 'foo', 'bar');

@@ -430,0 +512,0 @@ expect(TestPluginWithSpy.spy).toHaveBeenCalledTimes(1);

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is too big to display

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc