Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor(headless): migrate logParametersChange #3460

Merged
merged 26 commits into from
Jan 26, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
0d58607
change name of old function
alexprudhomme Dec 6, 2023
1c87b63
new next function and tests
alexprudhomme Dec 6, 2023
0350bbb
migrate searchBox/submit
alexprudhomme Dec 7, 2023
a03fab5
revert optional legacy analytics
alexprudhomme Dec 7, 2023
1c5ff62
hard coded values in tests
alexprudhomme Dec 7, 2023
cd6444b
insight case not using the right interface..
alexprudhomme Dec 7, 2023
39d90b5
Merge branch 'KIT-2933' into KIT-2905
alexprudhomme Dec 7, 2023
8e66b93
add support for search box submit
alexprudhomme Dec 7, 2023
04eab38
beter interfaces
alexprudhomme Dec 7, 2023
4abf6be
Merge branch 'KIT-2933' into KIT-2905
alexprudhomme Dec 7, 2023
82952be
never use coreSearchBox
alexprudhomme Dec 7, 2023
107513d
Merge branch 'KIT-2933' into KIT-2905
alexprudhomme Dec 7, 2023
308fd24
fix test
alexprudhomme Dec 7, 2023
491cee6
Merge branch 'KIT-2933' into KIT-2905
alexprudhomme Dec 7, 2023
b7f0d9f
remove firstResult and numberOfResult analytics check
alexprudhomme Dec 7, 2023
077bf76
put back interfaceLoad
alexprudhomme Dec 7, 2023
9813d32
Update search-parameter-analytics-actions.test.ts
alexprudhomme Dec 7, 2023
c7c8600
Merge branch 'master' into KIT-2933
alexprudhomme Dec 13, 2023
e733afb
Merge branch 'KIT-2933' into KIT-2905
alexprudhomme Dec 13, 2023
b0b53cc
Merge branch 'master' into KIT-2933
alexprudhomme Dec 14, 2023
5ce7dec
refactor(headless): migrate searchboxAsYouType event (#3472)
alexprudhomme Dec 14, 2023
1ce36bc
Merge branch 'KIT-2933' into KIT-2905
alexprudhomme Dec 14, 2023
01d8257
Merge branch 'master' into KIT-2905
alexprudhomme Dec 15, 2023
262d8b8
Merge branch 'master' into KIT-2905
louis-bompart Dec 29, 2023
0a96a9b
Merge branch 'master' into KIT-2905
louis-bompart Jan 26, 2024
d5d1402
ensure paramChanges uses fExcluded when relevant
louis-bompart Jan 26, 2024
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
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,10 @@ import {getDebugInitialState} from '../../features/debug/debug-state';
import {getPaginationInitialState} from '../../features/pagination/pagination-state';
import {getQueryInitialState} from '../../features/query/query-state';
import {SearchParameters} from '../../features/search-parameters/search-parameter-actions';
import {logParametersChange} from '../../features/search-parameters/search-parameter-analytics-actions';
import {
legacyLogParametersChange,
parametersChange,
} from '../../features/search-parameters/search-parameter-analytics-actions';
import {executeSearch} from '../../features/search/search-actions';
import {StaticFilterValue} from '../../features/static-filter-set/static-filter-set-state';
import {SearchParametersState} from '../../state/search-app-state';
Expand Down Expand Up @@ -59,7 +62,10 @@ export function buildSearchParameterManager(

controller.synchronize(parameters);
dispatch(
executeSearch({legacy: logParametersChange(oldParams, newParams)})
executeSearch({
legacy: legacyLogParametersChange(oldParams, newParams),
next: parametersChange(oldParams, newParams),
})
);
},

Expand Down
Original file line number Diff line number Diff line change
@@ -1,22 +1,38 @@
import {buildMockSearchAppEngine} from '../../test';
import {logInterfaceChange} from '../analytics/analytics-actions';
import {
interfaceChange,
logInterfaceChange,
} from '../analytics/analytics-actions';
import {LegacySearchAction} from '../analytics/analytics-utils';
import {
logFacetClearAll,
logFacetDeselect,
logFacetSelect,
logFacetExclude,
facetDeselect,
facetClearAll,
facetExclude,
logFacetUnexclude,
} from '../facets/facet-set/facet-set-analytics-actions';
import {
logPageNumber,
logPagerResize,
} from '../pagination/pagination-analytics-actions';
import {logSearchboxSubmit} from '../query/query-analytics-actions';
import {logResultsSort} from '../sort-criteria/sort-criteria-analytics-actions';
import {logParametersChange} from './search-parameter-analytics-actions';
import {
logSearchboxSubmit,
searchboxSubmit,
} from '../query/query-analytics-actions';
import {
logResultsSort,
resultsSort,
} from '../sort-criteria/sort-criteria-analytics-actions';
import {
legacyLogParametersChange,
parametersChange,
} from './search-parameter-analytics-actions';
import {logParametersChange} from './search-parameter-insight-analytics-actions';

describe('logParametersChange', () => {
describe('legacyLogParametersChange', () => {
function expectIdenticalActionType(
action1: LegacySearchAction,
action2: LegacySearchAction
Expand All @@ -29,67 +45,67 @@ describe('logParametersChange', () => {

it('should log #logSearchboxSubmit when #q parameter changes', () => {
expectIdenticalActionType(
logParametersChange({}, {q: 'test'}),
legacyLogParametersChange({}, {q: 'test'}),
logSearchboxSubmit()
);
});

it('should log #logResultsSort when #sortCriteria parameter changes', () => {
expectIdenticalActionType(
logParametersChange({}, {sortCriteria: 'size ascending'}),
legacyLogParametersChange({}, {sortCriteria: 'size ascending'}),
logResultsSort()
);
});

it('should log #logPageNumber when #firstResult parameter changes', () => {
expectIdenticalActionType(
logParametersChange({}, {firstResult: 10}),
legacyLogParametersChange({}, {firstResult: 10}),
logPageNumber()
);
});

it('should log #logPagerResize when #firstResult parameter changes', () => {
expectIdenticalActionType(
logParametersChange({}, {numberOfResults: 25}),
legacyLogParametersChange({}, {numberOfResults: 25}),
logPagerResize()
);
});

testFacetSelectLogging('f', expectIdenticalActionType);
legacyTestFacetSelectLogging('f', expectIdenticalActionType);

testFacetSelectLogging('af', expectIdenticalActionType);
legacyTestFacetSelectLogging('af', expectIdenticalActionType);

testFacetSelectLogging('cf', expectIdenticalActionType);
legacyTestFacetSelectLogging('cf', expectIdenticalActionType);

testFacetExcludeLogging(expectIdenticalActionType);
legacyTestFacetExcludeLogging(expectIdenticalActionType);

it('should log a generic #logInterfaceChange when an unmanaged parameter', () => {
expectIdenticalActionType(
logParametersChange({}, {cq: 'hello'}),
legacyLogParametersChange({}, {cq: 'hello'}),
logInterfaceChange()
);
});
});

function testFacetSelectLogging(
function legacyTestFacetSelectLogging(
parameter: string,
expectIdenticalActionType: (
action1: LegacySearchAction,
action2: LegacySearchAction
) => void
) {
testFacetLogging(parameter, expectIdenticalActionType);
legacyTestFacetLogging(parameter, expectIdenticalActionType);

it(`should log #logFacetSelect when an ${parameter} parameter is added`, () => {
expectIdenticalActionType(
logParametersChange({}, {[parameter]: {author: ['Cervantes']}}),
legacyLogParametersChange({}, {[parameter]: {author: ['Cervantes']}}),
logFacetSelect({facetId: 'author', facetValue: 'Cervantes'})
);
});

it(`should log #logFacetSelect when an ${parameter} parameter is modified & a value added`, () => {
expectIdenticalActionType(
logParametersChange(
legacyLogParametersChange(
{[parameter]: {author: ['Cervantes']}},
{[parameter]: {author: ['Cervantes', 'Orwell']}}
),
Expand All @@ -98,13 +114,13 @@ function testFacetSelectLogging(
});
}

function testFacetExcludeLogging(
function legacyTestFacetExcludeLogging(
expectIdenticalActionType: (
action1: LegacySearchAction,
action2: LegacySearchAction
) => void
) {
it('should log #logFacetDeselect when an fExcluded parameter with a single value is removed', () => {
it('should log #logFacetUnexclude when an fExcluded parameter with a single value is removed', () => {
expectIdenticalActionType(
logParametersChange({fExcluded: {author: ['Cervantes']}}, {}),
logFacetUnexclude({facetId: 'author', facetValue: 'Cervantes'})
Expand All @@ -118,7 +134,7 @@ function testFacetExcludeLogging(
);
});

it('should log #logFacetDeselect when an fExcluded parameter is modified & a value removed', () => {
it('should log #logFacetUnexclude when an fExcluded parameter is modified & a value removed', () => {
expectIdenticalActionType(
logParametersChange(
{fExcluded: {author: ['Cervantes', 'Orwell']}},
Expand All @@ -130,14 +146,14 @@ function testFacetExcludeLogging(

it('should log #logFacetSelect when an fExcluded parameter is added', () => {
expectIdenticalActionType(
logParametersChange({}, {fExcluded: {author: ['Cervantes']}}),
legacyLogParametersChange({}, {fExcluded: {author: ['Cervantes']}}),
logFacetExclude({facetId: 'author', facetValue: 'Cervantes'})
);
});

it('should log #logFacetSelect when an fExcluded parameter is modified & a value added', () => {
expectIdenticalActionType(
logParametersChange(
legacyLogParametersChange(
{fExcluded: {author: ['Cervantes']}},
{fExcluded: {author: ['Cervantes', 'Orwell']}}
),
Expand All @@ -146,7 +162,7 @@ function testFacetExcludeLogging(
});
}

function testFacetLogging(
function legacyTestFacetLogging(
parameter: string,
expectIdenticalActionType: (
action1: LegacySearchAction,
Expand All @@ -155,25 +171,113 @@ function testFacetLogging(
) {
it(`should log #logFacetDeselect when an ${parameter} parameter with a single value is removed`, () => {
expectIdenticalActionType(
logParametersChange({[parameter]: {author: ['Cervantes']}}, {}),
legacyLogParametersChange({[parameter]: {author: ['Cervantes']}}, {}),
logFacetDeselect({facetId: 'author', facetValue: 'Cervantes'})
);
});

it(`should log #logFacetClearAll when an ${parameter} parameter with multiple values is removed`, () => {
expectIdenticalActionType(
logParametersChange({[parameter]: {author: ['Cervantes', 'Orwell']}}, {}),
legacyLogParametersChange(
{[parameter]: {author: ['Cervantes', 'Orwell']}},
{}
),
logFacetClearAll('author')
);
});

it(`should log #logFacetDeselect when an ${parameter} parameter is modified & a value removed`, () => {
expectIdenticalActionType(
logParametersChange(
legacyLogParametersChange(
{[parameter]: {author: ['Cervantes', 'Orwell']}},
{[parameter]: {author: ['Cervantes']}}
),
logFacetDeselect({facetId: 'author', facetValue: 'Orwell'})
);
});
}

// --------------------- KIT-2859 : Everything above this will get deleted ! :) ---------------------
const ANY_FACET_ID = 'author';
const ANY_FACET_VALUE = 'Cervantes';

function testFacetExcludeLogging() {
testFacetSelectLogging('fExcluded');

it('should log #facetSelect when an fExcluded parameter is added', () => {
const action = parametersChange({}, {fExcluded: {author: ['Cervantes']}});

expect(action.actionCause).toEqual(
facetExclude(ANY_FACET_ID, ANY_FACET_VALUE).actionCause
);
});

it('should log #facetSelect when an fExcluded parameter is modified & a value added', () => {
const action = parametersChange(
{fExcluded: {author: ['Cervantes']}},
{fExcluded: {author: ['Cervantes', 'Orwell']}}
);

expect(action.actionCause).toEqual(
facetExclude(ANY_FACET_ID, ANY_FACET_VALUE).actionCause
);
});
}

describe('parametersChange', () => {
it('should log #searchboxSubmit when #q parameter changes', () => {
const action = parametersChange({}, {q: 'test'});

expect(action.actionCause).toEqual(searchboxSubmit().actionCause);
});

it('should log #resultsSort when #sortCriteria parameter changes', () => {
const action = parametersChange({}, {sortCriteria: 'size ascending'});

expect(action.actionCause).toEqual(resultsSort().actionCause);
});

testFacetSelectLogging('f');

testFacetSelectLogging('af');

testFacetSelectLogging('cf');

testFacetExcludeLogging();

it('should log a generic #interfaceLoad when an unmanaged parameter', () => {
const action = parametersChange({}, {cq: 'hello'});

expect(action.actionCause).toEqual(interfaceChange().actionCause);
});
});

function testFacetSelectLogging(parameter: string) {
it(`should log #facetDeselect when an ${parameter} parameter with a single value is removed`, () => {
const action = parametersChange({[parameter]: {author: ['Cervantes']}}, {});

expect(action.actionCause).toEqual(
facetDeselect(ANY_FACET_ID, ANY_FACET_VALUE).actionCause
);
});

it(`should log #facetClearAll when an ${parameter} parameter with multiple values is removed`, () => {
const action = parametersChange(
{[parameter]: {author: ['Cervantes', 'Orwell']}},
{}
);

expect(action.actionCause).toEqual(facetClearAll(ANY_FACET_ID).actionCause);
});

it(`should log #facetDeselect when an ${parameter} parameter is modified & a value removed`, () => {
const action = parametersChange(
{[parameter]: {author: ['Cervantes', 'Orwell']}},
{[parameter]: {author: ['Cervantes']}}
);

expect(action.actionCause).toEqual(
facetDeselect(ANY_FACET_ID, ANY_FACET_VALUE).actionCause
);
});
}
Loading
Loading