Skip to content

Commit 92ccbcf

Browse files
authored
feat: support neural perso (v0.0.11) (#36)
1 parent 8c3dfcc commit 92ccbcf

File tree

7 files changed

+47
-5
lines changed

7 files changed

+47
-5
lines changed

package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "algolia-analyzer",
3-
"version": "0.0.10",
3+
"version": "0.0.11",
44
"author": "Emmanuel Krebs <[email protected]>",
55
"license": "MIT",
66
"scripts": {

src/components/Tags.tsx

+1
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,7 @@ const apiString: Record<ApiType, string> = {
7777
're-ranking': 'reRanking',
7878
search: 'search',
7979
dashboard: 'dashboard',
80+
neuralperso: 'neuralPerso',
8081
};
8182

8283
export const ApiTag: FC<CustomTagProps & { api: ApiType }> = ({ api, reversed, ...props }) => (

src/manifest.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"manifest_version": 3,
33
"name": "Algolia Analyzer",
44
"description": "algolia-analyzer",
5-
"version": "0.0.10",
5+
"version": "0.0.11",
66
"minimum_chrome_version": "60",
77
"icons": {
88
"16": "./content/icons/icon-16.png",

src/utils/Request.ts

+2-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,8 @@ export type ApiType =
66
| 'merchandising'
77
| 'query-categorization'
88
| 're-ranking'
9-
| 'search';
9+
| 'search'
10+
| 'neuralperso';
1011

1112
export interface Request {
1213
id: string;

src/utils/__tests__/getUrlData.test.ts

+35
Original file line numberDiff line numberDiff line change
@@ -381,4 +381,39 @@ describe('getUrlData', () => {
381381
});
382382
});
383383
});
384+
385+
describe('neural perso', () => {
386+
it('/config', () => {
387+
expect(getUrlData(new URL('https://neuralperso.eu.algolia.com/1/config'))).toEqual({
388+
api: 'neuralperso',
389+
cluster: 'eu',
390+
apiSubPath: 'config',
391+
index: null,
392+
queryStringParameters: {},
393+
displayableUrl: 'neuralperso.eu.algolia.com/1/config',
394+
});
395+
});
396+
397+
it('/users', () => {
398+
expect(getUrlData(new URL('https://neuralperso.eu.algolia.com/1/users?limit=10'))).toEqual({
399+
api: 'neuralperso',
400+
cluster: 'eu',
401+
apiSubPath: 'users',
402+
index: null,
403+
queryStringParameters: { limit: '10' },
404+
displayableUrl: 'neuralperso.eu.algolia.com/1/users',
405+
});
406+
});
407+
408+
it('/users/*', () => {
409+
expect(getUrlData(new URL('https://neuralperso.eu.algolia.com/1/users/products'))).toEqual({
410+
api: 'neuralperso',
411+
cluster: 'eu',
412+
apiSubPath: 'users',
413+
index: 'products',
414+
queryStringParameters: {},
415+
displayableUrl: 'neuralperso.eu.algolia.com/1/users/products',
416+
});
417+
});
418+
});
384419
});

src/utils/constants.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ export const urlPattern = new URLPattern({
33
});
44
export const urlPattern2 = new URLPattern({
55
hostname:
6-
'(merchandising-staging|analytics|automation|query-categorization|re-ranking).*.algolia.com',
6+
'(merchandising-staging|analytics|automation|query-categorization|re-ranking|neuralperso).*.algolia.com',
77
});
88
export const urlPattern3 = new URLPattern({
99
hostname: '(beta-dashboard|dashboard).algolia.com',

src/utils/getUrlData.ts

+6-1
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,10 @@ const getApiPathCluster = (url: URL): Pick<UrlData, 'api' | 'cluster'> & { apiPa
4040
api = 'insights';
4141
}
4242

43+
if (url.host.startsWith('neuralperso')) {
44+
api = 'neuralperso';
45+
}
46+
4347
if (cluster === api) {
4448
cluster = country;
4549
}
@@ -106,7 +110,8 @@ const getIndexAndSubPath = (
106110
case 're-ranking':
107111
case 'merchandising':
108112
case 'insights':
109-
case 'automation': {
113+
case 'automation':
114+
case 'neuralperso': {
110115
const { array, item } = spliceItemAt(apiPathParts, 1, null);
111116
apiSubPath = array.join('/');
112117
index = item ?? queryStringParameters.index ?? null;

0 commit comments

Comments
 (0)