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

feat(headless): remove visitorId #4485

Merged
merged 2 commits into from
Oct 10, 2024
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
4 changes: 0 additions & 4 deletions packages/headless/src/api/platform-service-params.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,6 @@ export interface ClientIDParam {
clientId?: string;
}

export interface VisitorIDParam {
visitorId?: string;
}

export interface FoldingParam {
filterField?: string;
parentField?: string;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import {BaseParam, VisitorIDParam} from '../../../platform-service-params.js';
import {BaseParam} from '../../../platform-service-params.js';
import {AuthenticationParam} from '../../search-api-params.js';
import {SearchRequest} from '../../search/search-request.js';

Expand All @@ -16,7 +16,6 @@ export interface FacetSearchRequestOptions {
export interface BaseFacetSearchRequest
extends FacetSearchRequestOptions,
BaseParam,
VisitorIDParam,
AuthenticationParam {
field: string;
searchContext?: SearchRequest;
Expand Down
3 changes: 0 additions & 3 deletions packages/headless/src/api/search/html/html-api-client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,9 +41,6 @@ export const buildContentURL = (req: HtmlRequest, path: string) => {
if (req.requestedOutputSize !== undefined) {
url.addParam('requestedOutputSize', `${req.requestedOutputSize}`);
}
if (req.visitorId !== undefined) {
url.addParam('visitorId', `${req.visitorId}`);
}
return url.href;
};

Expand Down
5 changes: 2 additions & 3 deletions packages/headless/src/api/search/html/html-request.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import {BaseParam, VisitorIDParam} from '../../platform-service-params.js';
import {BaseParam} from '../../platform-service-params.js';
import {AuthenticationParam} from '../search-api-params.js';

export interface HtmlRequestOptions {
Expand All @@ -8,8 +8,7 @@ export interface HtmlRequestOptions {

export type HtmlRequest = BaseParam &
HtmlRequestOptions &
AuthenticationParam &
VisitorIDParam & {
AuthenticationParam & {
enableNavigation: boolean;
requestedOutputSize: number;
q: string;
Expand Down
2 changes: 0 additions & 2 deletions packages/headless/src/api/search/plan/plan-request.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ import {
BaseParam,
ContextParam,
LocaleParam,
VisitorIDParam,
} from '../../platform-service-params.js';
import {
AnalyticsParam,
Expand All @@ -20,6 +19,5 @@ export type PlanRequest = BaseParam &
PipelineParam &
LocaleParam &
TimezoneParam &
VisitorIDParam &
AnalyticsParam &
AuthenticationParam;
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ import {
BaseParam,
ContextParam,
LocaleParam,
VisitorIDParam,
} from '../../platform-service-params.js';
import {
ActionsHistoryParam,
Expand All @@ -24,7 +23,6 @@ export type QuerySuggestRequest = BaseParam &
LocaleParam &
TimezoneParam &
ActionsHistoryParam &
VisitorIDParam &
AuthenticationParam &
AnalyticsParam & {
count: number;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import {
DictionaryFieldContextParam,
LocaleParam,
NumberOfResultsParam,
VisitorIDParam,
} from '../../platform-service-params.js';
import {
ActionsHistoryParam,
Expand Down Expand Up @@ -35,7 +34,6 @@ export type RecommendationRequest = BaseParam &
ReferrerParam &
LocaleParam &
TimezoneParam &
VisitorIDParam &
AnalyticsParam &
AuthenticationParam &
NumberOfResultsParam;
6 changes: 0 additions & 6 deletions packages/headless/src/api/search/search-api-client.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -251,7 +251,6 @@ describe('search api client', () => {
fieldsToInclude: state.fields.fieldsToInclude,
pipeline: state.pipeline,
searchHub: state.searchHub,
visitorId: expect.any(String),
},
preprocessRequest: NoopPreprocessRequest,
requestMetadata: {method: 'search'},
Expand Down Expand Up @@ -346,7 +345,6 @@ describe('search api client', () => {
searchHub: state.searchHub,
timezone: state.configuration.search.timezone,
locale: state.configuration.search.locale,
visitorId: expect.any(String),
},
preprocessRequest: NoopPreprocessRequest,
requestMetadata: {method: 'plan'},
Expand Down Expand Up @@ -416,7 +414,6 @@ describe('search api client', () => {
timezone: state.configuration.search.timezone,
locale: state.configuration.search.locale,
actionsHistory: expect.any(Array),
visitorId: expect.any(String),
},
preprocessRequest: NoopPreprocessRequest,
requestMetadata: {method: 'querySuggest'},
Expand Down Expand Up @@ -570,7 +567,6 @@ describe('search api client', () => {
ignoreValues: [],
searchContext: {
...searchRequest,
visitorId: expect.any(String),
analytics: {
...searchRequest.analytics,
clientId: expect.any(String),
Expand Down Expand Up @@ -622,7 +618,6 @@ it calls PlatformClient.call with the category facet search params`, async () =>
ignorePaths: [],
searchContext: {
...searchRequest,
visitorId: expect.any(String),
analytics: {
...searchRequest.analytics,
clientId: expect.any(String),
Expand Down Expand Up @@ -685,7 +680,6 @@ it calls PlatformClient.call with the category facet search params`, async () =>
actionsHistory: expect.any(Array),
tab: originLevel2,
referrer: originLevel3,
visitorId: expect.any(String),
numberOfResults: recommendationState.pagination.numberOfResults,
},
preprocessRequest: NoopPreprocessRequest,
Expand Down
2 changes: 0 additions & 2 deletions packages/headless/src/api/search/search/search-request.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import {
FoldingParam,
LocaleParam,
NumberOfResultsParam,
VisitorIDParam,
} from '../../platform-service-params.js';
import {
ActionsHistoryParam,
Expand Down Expand Up @@ -54,7 +53,6 @@ export type SearchRequest = BaseParam &
PipelineParam &
SearchHubParam &
FacetOptionsParam &
VisitorIDParam &
DebugParam &
LocaleParam &
FoldingParam &
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,4 @@
import {
ContextParam,
LocaleParam,
VisitorIDParam,
} from '../../../platform-service-params.js';
import {ContextParam, LocaleParam} from '../../../platform-service-params.js';
import {
ActionsHistoryParam,
AnalyticsParam,
Expand All @@ -18,7 +14,6 @@ export type InsightQuerySuggestRequest = InsightParam &
LocaleParam &
TimezoneParam &
ActionsHistoryParam &
VisitorIDParam &
AuthenticationParam &
AnalyticsParam & {
count: number;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,6 @@ describe('#buildCategoryFacetSearchRequest', () => {

expect((await buildParams()).searchContext).toEqual({
...request,
visitorId: expect.any(String),
analytics: {
...request.analytics,
clientId: expect.any(String),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,6 @@ describe('#buildSpecificFacetSearchRequest', () => {

expect((await buildParams()).searchContext).toEqual({
...request,
visitorId: expect.any(String),
analytics: {
...request.analytics,
clientId: expect.any(String),
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,4 @@
import {
historyStore,
getVisitorID,
} from '../../api/analytics/coveo-analytics-utils.js';
import {historyStore} from '../../api/analytics/coveo-analytics-utils.js';
import {getOrganizationEndpoint} from '../../api/platform-client.js';
import {InsightQuerySuggestRequest} from '../../api/service/insight/query-suggest/query-suggest-request.js';
import {InsightAppState} from '../../state/insight-app-state.js';
Expand Down Expand Up @@ -37,7 +34,6 @@ export const buildInsightQuerySuggestRequest = async (
context: s.insightCaseContext.caseContext,
}),
...(s.configuration.analytics.enabled && {
visitorId: await getVisitorID(s.configuration.analytics),
...(s.configuration.analytics.enabled &&
(await fromAnalyticsStateToAnalyticsParams(s.configuration.analytics))),
}),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,6 @@ describe('ResultPreviewRequestBuilder', () => {
requestedOutputSize: 0,
uniqueId: '1',
url: expectedUrl,
visitorId: expect.any(String),
});
});
});
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import {getVisitorID} from '../../api/analytics/coveo-analytics-utils.js';
import {getOrganizationEndpoint} from '../../api/platform-client.js';
import {
HtmlRequest,
Expand All @@ -15,8 +14,7 @@ export async function buildInsightResultPreviewRequest(
state: StateNeededByInsightHtmlEndpoint,
options: HtmlRequestOptions
): Promise<HtmlRequest> {
const {accessToken, organizationId, analytics, environment} =
state.configuration;
const {accessToken, organizationId, environment} = state.configuration;
const {insightId} = state.insightConfiguration;

const q = state.query?.q || '';
Expand All @@ -32,9 +30,6 @@ export async function buildInsightResultPreviewRequest(
accessToken,
organizationId,
enableNavigation: false,
...(analytics.enabled && {
visitorId: await getVisitorID(state.configuration.analytics),
}),
q,
...options,
requestedOutputSize: options.requestedOutputSize || 0,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
import {NumberValue} from '@coveo/bueno';
import {createAction, createAsyncThunk} from '@reduxjs/toolkit';
import {
getVisitorID,
historyStore,
} from '../../api/analytics/coveo-analytics-utils.js';
import {historyStore} from '../../api/analytics/coveo-analytics-utils.js';
import {getSearchApiBaseUrl} from '../../api/platform-client.js';
import {QuerySuggestRequest} from '../../api/search/query-suggest/query-suggest-request.js';
import {QuerySuggestSuccessResponse} from '../../api/search/query-suggest/query-suggest-response.js';
Expand Down Expand Up @@ -181,7 +178,6 @@ export const buildQuerySuggestRequest = async (
...(s.searchHub && {searchHub: s.searchHub}),
tab: s.configuration.analytics.originLevel2,
...(s.configuration.analytics.enabled && {
visitorId: await getVisitorID(s.configuration.analytics),
...(s.configuration.analytics.enabled &&
s.configuration.analytics.analyticsMode === 'legacy'
? await legacyFromAnalyticsStateToAnalyticsParams(
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,5 @@
import {createAction, createAsyncThunk} from '@reduxjs/toolkit';
import {
getVisitorID,
historyStore,
} from '../../api/analytics/coveo-analytics-utils.js';
import {historyStore} from '../../api/analytics/coveo-analytics-utils.js';
import {getSearchApiBaseUrl} from '../../api/platform-client.js';
import {RecommendationRequest} from '../../api/search/recommendation/recommendation-request.js';
import {
Expand Down Expand Up @@ -119,9 +116,6 @@ export const buildRecommendationRequest = async (
...(s.fields && {
fieldsToInclude: s.fields.fieldsToInclude,
}),
...(s.configuration.analytics.enabled && {
visitorId: await getVisitorID(s.configuration.analytics),
}),
...(s.configuration.analytics.enabled &&
(await buildAnalyticsSection(s, recommendationInterfaceLoad()))),
...(s.configuration.search.authenticationProviders.length && {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@ describe('ResultPreviewRequestBuilder', () => {
requestedOutputSize: 0,
uniqueId: '1',
url: getSearchApiBaseUrl(''),
visitorId: expect.any(String),
});
});
});
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import {getVisitorID} from '../../api/analytics/coveo-analytics-utils.js';
import {getSearchApiBaseUrl} from '../../api/platform-client.js';
import {
HtmlRequest,
Expand All @@ -18,7 +17,7 @@ export async function buildResultPreviewRequest(
state: StateNeededByHtmlEndpoint,
options: HtmlRequestOptions
): Promise<HtmlRequest> {
const {search, accessToken, organizationId, analytics} = state.configuration;
const {search, accessToken, organizationId} = state.configuration;
const q = state.query?.q || '';

return {
Expand All @@ -31,9 +30,6 @@ export async function buildResultPreviewRequest(
accessToken,
organizationId,
enableNavigation: false,
...(analytics.enabled && {
visitorId: await getVisitorID(state.configuration.analytics),
}),
q,
...options,
requestedOutputSize: options.requestedOutputSize || 0,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -109,9 +109,9 @@ describe('buildSearchAndFoldingLoadCollectionRequest', () => {
state.configuration.analytics.enabled = true;
});

it('#visitorId is included in the request', async () => {
it('#analytics is included in the request', async () => {
const request = await buildSearchAndFoldingLoadCollectionRequest(state);
expect(request.visitorId).toBeDefined();
expect(request.analytics).toBeDefined();
});

it('#actionsHistory is included in the request', async () => {
Expand All @@ -127,9 +127,9 @@ describe('buildSearchAndFoldingLoadCollectionRequest', () => {
state.configuration.analytics.enabled = false;
});

it('#visitorId is not included in the request', async () => {
it('#analytics is not included in the request', async () => {
const request = await buildSearchAndFoldingLoadCollectionRequest(state);
expect(request.visitorId).toBeUndefined();
expect(request.analytics).toBeUndefined();
});

it('#actionsHistory is not included in the request', async () => {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
import {isNullOrUndefined} from '@coveo/bueno';
import {EventDescription} from 'coveo.analytics';
import {
getVisitorID,
historyStore,
} from '../../../api/analytics/coveo-analytics-utils.js';
import {historyStore} from '../../../api/analytics/coveo-analytics-utils.js';
import {getSearchApiBaseUrl} from '../../../api/platform-client.js';
import {SearchRequest} from '../../../api/search/search/search-request.js';
import {SearchAppState} from '../../../state/search-app-state.js';
Expand Down Expand Up @@ -32,7 +29,6 @@ export const buildSearchAndFoldingLoadCollectionRequest = async (
referrer: state.configuration.analytics.originLevel3,
timezone: state.configuration.search.timezone,
...(state.configuration.analytics.enabled && {
visitorId: await getVisitorID(state.configuration.analytics),
actionsHistory: historyStore.getHistory(),
}),
...(state.advancedSearchQueries?.aq && {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -140,12 +140,12 @@ describe('buildSearchAndFoldingLoadCollectionRequest', () => {
state.configuration.analytics.enabled = true;
});

it('#visitorId is included in the request', async () => {
it('#analytics is included in the request', async () => {
const request = buildSearchAndFoldingLoadCollectionRequest(
state,
buildMockNavigatorContextProvider()()
);
expect(request.visitorId).toBeDefined();
expect(request.analytics).toBeDefined();
});
});

Expand All @@ -156,12 +156,12 @@ describe('buildSearchAndFoldingLoadCollectionRequest', () => {
state.configuration.analytics.enabled = false;
});

it('#visitorId is not included in the request', async () => {
it('#analytics is not included in the request', async () => {
const request = buildSearchAndFoldingLoadCollectionRequest(
state,
buildMockNavigatorContextProvider()()
);
expect(request.visitorId).toBeUndefined();
expect(request.analytics).not.toBeDefined();
});

it('#actionsHistory is not included in the request', async () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,6 @@ export const buildSearchAndFoldingLoadCollectionRequest = (
tab: state.configuration.analytics.originLevel2,
referrer: navigatorContext.referrer,
timezone: state.configuration.search.timezone,
...(state.configuration.analytics.enabled && {
visitorId: navigatorContext.clientId,
}),
...(state.advancedSearchQueries?.aq && {
aq: state.advancedSearchQueries.aq,
}),
Expand Down
Loading
Loading