Skip to content

Commit 3660f5b

Browse files
committed
merge main, regenerate insights client
2 parents 7e50493 + aa0715f commit 3660f5b

35 files changed

+1421
-40
lines changed

.github/actions/cache/action.yml

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ description: Restore cached dependencies.
44

55
inputs:
66
job:
7-
description: 'The job that requires this composite'
7+
description: The job that requires this composite
88
required: true
99

1010
runs:
@@ -39,6 +39,13 @@ runs:
3939
path: /home/runner/work/api-clients-automation/api-clients-automation/clients/algoliasearch-client-javascript/client-analytics/dist
4040
key: ${{ runner.os }}-js-client-analytics-${{ hashFiles('clients/algoliasearch-client-javascript/client-analytics/**') }}
4141

42+
- name: Restore built JavaScript insights client
43+
if: ${{ inputs.job == 'cts' }}
44+
uses: actions/cache@v2
45+
with:
46+
path: /home/runner/work/api-clients-automation/api-clients-automation/clients/algoliasearch-client-javascript/client-insights/dist
47+
key: ${{ runner.os }}-js-client-insights-${{ hashFiles('clients/algoliasearch-client-javascript/client-insights/**') }}
48+
4249
- name: Restore built Java client
4350
if: ${{ inputs.job == 'cts' }}
4451
uses: actions/cache@v2

.github/actions/setup/action.yml

Lines changed: 17 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@ runs:
4646
echo "::set-output name=JS_RECOMMEND_CLIENT_CHANGED::$(git diff --shortstat origin/${{ github.base_ref }}..HEAD -- clients/algoliasearch-client-javascript/recommend | wc -l)"
4747
echo "::set-output name=JS_PERSO_CLIENT_CHANGED::$(git diff --shortstat origin/${{ github.base_ref }}..HEAD -- clients/algoliasearch-client-javascript/client-personalization | wc -l)"
4848
echo "::set-output name=JS_ANALYTICS_CLIENT_CHANGED::$(git diff --shortstat origin/${{ github.base_ref }}..HEAD -- clients/algoliasearch-client-javascript/client-analytics | wc -l)"
49+
echo "::set-output name=JS_INSIGHTS_CLIENT_CHANGED::$(git diff --shortstat origin/${{ github.base_ref }}..HEAD -- clients/algoliasearch-client-javascript/client-insights | wc -l)"
4950
echo "::set-output name=JS_TEMPLATE_CHANGED::$(git diff --shortstat origin/${{ github.base_ref }}..HEAD -- templates/javascript | wc -l)"
5051
5152
echo "::set-output name=JAVA_CLIENT_CHANGED::$(git diff --shortstat origin/${{ github.base_ref }}..HEAD -- clients/algoliasearch-client-java-2 | wc -l)"
@@ -54,47 +55,50 @@ runs:
5455
outputs:
5556
# specs variables
5657
RUN_SPECS_SEARCH:
57-
description: 'Determine if the `specs_search` job should run'
58+
description: Determine if the `specs_search` job should run
5859
value: ${{ github.ref == 'refs/heads/main' || steps.diff.outputs.GITHUB_ACTIONS_CHANGED > 0 || steps.diff.outputs.SCRIPTS_CHANGED > 0 || steps.diff.outputs.COMMON_SPECS_CHANGED > 0 || steps.diff.outputs.SEARCH_SPECS_CHANGED > 0 }}
5960
RUN_SPECS_RECOMMEND:
60-
description: 'Determine if the `specs_recommend` job should run'
61+
description: Determine if the `specs_recommend` job should run
6162
value: ${{ github.ref == 'refs/heads/main' || steps.diff.outputs.GITHUB_ACTIONS_CHANGED > 0 || steps.diff.outputs.SCRIPTS_CHANGED > 0 || steps.diff.outputs.COMMON_SPECS_CHANGED > 0 || steps.diff.outputs.RECOMMEND_SPECS_CHANGED > 0 }}
6263
RUN_SPECS_QS:
63-
description: 'Determine if the `specs_qs` job should run'
64+
description: Determine if the `specs_qs` job should run
6465
value: ${{ github.ref == 'refs/heads/main' || steps.diff.outputs.GITHUB_ACTIONS_CHANGED > 0 || steps.diff.outputs.SCRIPTS_CHANGED > 0 || steps.diff.outputs.COMMON_SPECS_CHANGED > 0 || steps.diff.outputs.QS_SPECS_CHANGED > 0 }}
6566
RUN_SPECS_PERSO:
66-
description: 'Determine if the `specs_perso` job should run'
67+
description: Determine if the `specs_perso` job should run
6768
value: ${{ github.ref == 'refs/heads/main' || steps.diff.outputs.GITHUB_ACTIONS_CHANGED > 0 || steps.diff.outputs.SCRIPTS_CHANGED > 0 || steps.diff.outputs.COMMON_SPECS_CHANGED > 0 || steps.diff.outputs.PERSO_SPECS_CHANGED > 0 }}
6869
RUN_SPECS_INSIGHTS:
69-
description: 'Determine if the `specs_insights` job should run'
70+
description: Determine if the `specs_insights` job should run
7071
value: ${{ github.ref == 'refs/heads/main' || steps.diff.outputs.GITHUB_ACTIONS_CHANGED > 0 || steps.diff.outputs.SCRIPTS_CHANGED > 0 || steps.diff.outputs.COMMON_SPECS_CHANGED > 0 || steps.diff.outputs.INSIGHTS_SPECS_CHANGED > 0 }}
7172
RUN_SPECS_ANALYTICS:
72-
description: 'Determine if the `specs_analytics` job should run'
73+
description: Determine if the `specs_analytics` job should run
7374
value: ${{ github.ref == 'refs/heads/main' || steps.diff.outputs.GITHUB_ACTIONS_CHANGED > 0 || steps.diff.outputs.SCRIPTS_CHANGED > 0 || steps.diff.outputs.COMMON_SPECS_CHANGED > 0 || steps.diff.outputs.ANALYTICS_SPECS_CHANGED > 0 }}
7475
RUN_SPECS_AB:
75-
description: 'Determine if the `specs_ab` job should run'
76+
description: Determine if the `specs_ab` job should run
7677
value: ${{ github.ref == 'refs/heads/main' || steps.diff.outputs.GITHUB_ACTIONS_CHANGED > 0 || steps.diff.outputs.SCRIPTS_CHANGED > 0 || steps.diff.outputs.COMMON_SPECS_CHANGED > 0 || steps.diff.outputs.AB_SPECS_CHANGED > 0 }}
7778

7879
# js client variables
7980
RUN_JS_CLIENT_SEARCH:
80-
description: 'Determine if the `client_javascript_search` job should run'
81+
description: Determine if the `client_javascript_search` job should run
8182
value: ${{ github.ref == 'refs/heads/main' || steps.diff.outputs.GITHUB_ACTIONS_CHANGED > 0 || steps.diff.outputs.COMMON_SPECS_CHANGED > 0 || steps.diff.outputs.SEARCH_SPECS_CHANGED > 0 || steps.diff.outputs.SCRIPTS_CHANGED > 0 || steps.diff.outputs.JS_SEARCH_CLIENT_CHANGED > 0 || steps.diff.outputs.JS_TEMPLATE_CHANGED > 0 }}
8283
RUN_JS_CLIENT_RECOMMEND:
83-
description: 'Determine if the `client_javascript_recommend` job should run'
84+
description: Determine if the `client_javascript_recommend` job should run
8485
value: ${{ github.ref == 'refs/heads/main' || steps.diff.outputs.GITHUB_ACTIONS_CHANGED > 0 || steps.diff.outputs.COMMON_SPECS_CHANGED > 0 || steps.diff.outputs.RECOMMEND_SPECS_CHANGED > 0 || steps.diff.outputs.SCRIPTS_CHANGED > 0 || steps.diff.outputs.JS_RECOMMEND_CLIENT_CHANGED > 0 || steps.diff.outputs.JS_TEMPLATE_CHANGED > 0 }}
8586
RUN_JS_CLIENT_PERSO:
86-
description: 'Determine if the `client_javascript_perso` job should run'
87+
description: Determine if the `client_javascript_perso` job should run
8788
value: ${{ github.ref == 'refs/heads/main' || steps.diff.outputs.GITHUB_ACTIONS_CHANGED > 0 || steps.diff.outputs.COMMON_SPECS_CHANGED > 0 || steps.diff.outputs.PERSO_SPECS_CHANGED > 0 || steps.diff.outputs.SCRIPTS_CHANGED > 0 || steps.diff.outputs.JS_PERSO_CLIENT_CHANGED > 0 || steps.diff.outputs.JS_TEMPLATE_CHANGED > 0 }}
8889
RUN_JS_CLIENT_ANALYTICS:
89-
description: 'Determine if the `client_javascript_analytics` job should run'
90+
description: Determine if the `client_javascript_analytics` job should run
9091
value: ${{ github.ref == 'refs/heads/main' || steps.diff.outputs.GITHUB_ACTIONS_CHANGED > 0 || steps.diff.outputs.COMMON_SPECS_CHANGED > 0 || steps.diff.outputs.ANALYTICS_SPECS_CHANGED > 0 || steps.diff.outputs.SCRIPTS_CHANGED > 0 || steps.diff.outputs.JS_ANALYTICS_CLIENT_CHANGED > 0 || steps.diff.outputs.JS_TEMPLATE_CHANGED > 0 }}
92+
RUN_JS_CLIENT_INSIGHTS:
93+
description: Determine if the `client_javascript_insights` job should run
94+
value: ${{ github.ref == 'refs/heads/main' || steps.diff.outputs.GITHUB_ACTIONS_CHANGED > 0 || steps.diff.outputs.COMMON_SPECS_CHANGED > 0 || steps.diff.outputs.INSIGHTS_SPECS_CHANGED > 0 || steps.diff.outputs.SCRIPTS_CHANGED > 0 || steps.diff.outputs.JS_INSIGHTS_CLIENT_CHANGED > 0 || steps.diff.outputs.JS_TEMPLATE_CHANGED > 0 }}
9195

9296
# java client variables
9397
RUN_JAVA_CLIENT:
94-
description: 'Determine if the `client_java_*` job should run'
98+
description: Determine if the `client_java_*` job should run
9599
value: ${{ github.ref == 'refs/heads/main' || steps.diff.outputs.GITHUB_ACTIONS_CHANGED > 0 || steps.diff.outputs.COMMON_SPECS_CHANGED > 0 || steps.diff.outputs.SEARCH_SPECS_CHANGED > 0 || steps.diff.outputs.SCRIPTS_CHANGED > 0 || steps.diff.outputs.JAVA_CLIENT_CHANGED > 0 || steps.diff.outputs.JAVA_TEMPLATE_CHANGED > 0 }}
96100

97101
# cts variables
98102
RUN_CTS:
99-
description: 'Determine if the `cts` job should run'
103+
description: Determine if the `cts` job should run
100104
value: ${{ github.ref_name == 'main' || steps.diff.outputs.GITHUB_ACTIONS_CHANGED > 0 || steps.diff.outputs.SPECS_CHANGED > 0 || steps.diff.outputs.TESTS_CHANGED > 0 || steps.diff.outputs.JS_CLIENT_CHANGED > 0 || steps.diff.outputs.JS_TEMPLATE_CHANGED > 0 || steps.diff.outputs.JAVA_CLIENT_CHANGED > 0 || steps.diff.outputs.JAVA_TEMPLATE_CHANGED > 0 }}

.github/workflows/check.yml

Lines changed: 64 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,9 @@ jobs:
2222
- name: Setup
2323
id: setup
2424
uses: ./.github/actions/setup
25+
26+
- name: Lint GitHub actions
27+
run: yarn eslint --ext=yml .github/actions .github/workflows
2528
outputs:
2629
RUN_SPECS_SEARCH: ${{ steps.setup.outputs.RUN_SPECS_SEARCH }}
2730
RUN_SPECS_RECOMMEND: ${{ steps.setup.outputs.RUN_SPECS_RECOMMEND }}
@@ -35,6 +38,7 @@ jobs:
3538
RUN_JS_CLIENT_RECOMMEND: ${{ steps.setup.outputs.RUN_JS_CLIENT_RECOMMEND }}
3639
RUN_JS_CLIENT_PERSO: ${{ steps.setup.outputs.RUN_JS_CLIENT_PERSO }}
3740
RUN_JS_CLIENT_ANALYTICS: ${{ steps.setup.outputs.RUN_JS_CLIENT_ANALYTICS }}
41+
RUN_JS_CLIENT_INSIGHTS: ${{ steps.setup.outputs.RUN_JS_CLIENT_INSIGHTS }}
3842

3943
RUN_JAVA_CLIENT: ${{ steps.setup.outputs.RUN_JAVA_CLIENT }}
4044

@@ -53,6 +57,9 @@ jobs:
5357
- name: Checking search specs
5458
run: yarn build:specs search
5559

60+
- name: Lint search specs
61+
run: yarn eslint --ext=yml specs/search
62+
5663
specs_recommend:
5764
runs-on: ubuntu-20.04
5865
needs: setup
@@ -66,6 +73,9 @@ jobs:
6673
- name: Checking recommend specs
6774
run: yarn build:specs recommend
6875

76+
- name: Lint recommend specs
77+
run: yarn eslint --ext=yml specs/recommend
78+
6979
specs_perso:
7080
runs-on: ubuntu-20.04
7181
needs: setup
@@ -79,6 +89,9 @@ jobs:
7989
- name: Checking personalization specs
8090
run: yarn build:specs personalization
8191

92+
- name: Lint personalization specs
93+
run: yarn eslint --ext=yml specs/personalization
94+
8295
specs_analytics:
8396
runs-on: ubuntu-20.04
8497
needs: setup
@@ -92,6 +105,25 @@ jobs:
92105
- name: Checking analytics specs
93106
run: yarn build:specs analytics
94107

108+
- name: Lint analytics specs
109+
run: yarn eslint --ext=yml specs/analytics
110+
111+
specs_insights:
112+
runs-on: ubuntu-20.04
113+
needs: setup
114+
if: ${{ always() && needs.setup.outputs.RUN_SPECS_INSIGHTS == 'true' }}
115+
steps:
116+
- uses: actions/checkout@v2
117+
118+
- name: Restore cache
119+
uses: ./.github/actions/cache
120+
121+
- name: Checking insights specs
122+
run: yarn build:specs insights
123+
124+
- name: Lint insights specs
125+
run: yarn eslint --ext=yml specs/insights
126+
95127
client_javascript_search:
96128
runs-on: ubuntu-20.04
97129
needs: [specs_search]
@@ -192,6 +224,31 @@ jobs:
192224
if: steps.cache.outputs.cache-hit != 'true'
193225
run: yarn build:clients javascript analytics
194226

227+
client_javascript_insights:
228+
runs-on: ubuntu-20.04
229+
needs: [specs_insights]
230+
if: ${{ always() && needs.setup.outputs.RUN_JS_CLIENT_INSIGHTS == 'true' }}
231+
steps:
232+
- uses: actions/checkout@v2
233+
234+
- name: Restore cache
235+
uses: ./.github/actions/cache
236+
237+
- name: Cache insights client
238+
id: cache
239+
uses: actions/cache@v2
240+
with:
241+
path: /home/runner/work/api-clients-automation/api-clients-automation/clients/algoliasearch-client-javascript/client-insights/dist
242+
key: ${{ runner.os }}-js-client-insights-${{ hashFiles('clients/algoliasearch-client-javascript/client-insights/**') }}
243+
244+
- name: Generate insights client
245+
if: steps.cache.outputs.cache-hit != 'true'
246+
run: yarn generate javascript insights
247+
248+
- name: Build insights client
249+
if: steps.cache.outputs.cache-hit != 'true'
250+
run: yarn build:clients javascript insights
251+
195252
client_java_search:
196253
runs-on: ubuntu-20.04
197254
needs: [specs_search]
@@ -222,13 +279,13 @@ jobs:
222279
cts:
223280
runs-on: ubuntu-20.04
224281
needs:
225-
[
226-
client_javascript_search,
227-
client_javascript_recommend,
228-
client_javascript_perso,
229-
client_javascript_analytics,
230-
client_java_search,
231-
]
282+
- client_javascript_search
283+
- client_javascript_recommend
284+
- client_javascript_perso
285+
- client_javascript_analytics
286+
- client_javascript_insights
287+
- client_java_search
288+
232289
if: ${{ always() && needs.setup.outputs.RUN_CTS == 'true' }}
233290
steps:
234291
- uses: actions/checkout@v2
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
node_modules
2+
dist
3+
.openapi-generator
4+
.env
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
# OpenAPI Generator Ignore
2+
# Generated by openapi-generator https://github.com/openapitools/openapi-generator
3+
4+
# Use this file to prevent files from being overwritten by the generator.
5+
# The patterns follow closely to .gitignore or .dockerignore.
6+
7+
git_push.sh
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
// This is the entrypoint for the package
2+
export * from './src/apis';
3+
export * from './model/models';
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
/**
2+
* Error.
3+
*/
4+
export type ErrorBase = {
5+
message?: string;
6+
};
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
/**
2+
* Insights event.
3+
*/
4+
export type InsightEvent = {
5+
/**
6+
* An eventType can be a click, a conversion, or a view.
7+
*/
8+
eventType: InsightEventEventType;
9+
/**
10+
* A user-defined string used to categorize events.
11+
*/
12+
eventName: string;
13+
/**
14+
* Name of the targeted index.
15+
*/
16+
index: string;
17+
/**
18+
* A user identifier. Depending if the user is logged-in or not, several strategies can be used from a sessionId to a technical identifier.
19+
*/
20+
userToken: string;
21+
/**
22+
* Time of the event expressed in milliseconds since the Unix epoch.
23+
*/
24+
timestamp?: number;
25+
/**
26+
* Algolia queryID. This is required when an event is tied to a search.
27+
*/
28+
queryID?: string;
29+
/**
30+
* An array of index objectID. Limited to 20 objects. An event can’t have both objectIDs and filters at the same time.
31+
*/
32+
objectIDs?: string[];
33+
/**
34+
* An array of filters. Limited to 10 filters. An event can’t have both objectIDs and filters at the same time.
35+
*/
36+
filters?: string[];
37+
/**
38+
* Position of the click in the list of Algolia search results. This field is required if a queryID is provided. One position must be provided for each objectID.
39+
*/
40+
positions?: number[];
41+
};
42+
43+
export type InsightEventEventType = 'click' | 'conversion' | 'view';
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
import type { InsightEvent } from './insightEvent';
2+
3+
/**
4+
* Object containing the events sent.
5+
*/
6+
export type InsightEvents = {
7+
/**
8+
* Array of events sent.
9+
*/
10+
events: InsightEvent[];
11+
};
Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
/* eslint-disable no-param-reassign */
2+
import type { RequestOptions } from '../utils/types';
3+
4+
export * from './errorBase';
5+
export * from './insightEvent';
6+
export * from './insightEvents';
7+
export * from './pushEventsResponse';
8+
9+
export interface Authentication {
10+
/**
11+
* Apply authentication settings to header and query params.
12+
*/
13+
applyToRequest: (requestOptions: RequestOptions) => Promise<void> | void;
14+
}
15+
16+
export class ApiKeyAuth implements Authentication {
17+
apiKey: string = '';
18+
19+
constructor(private location: string, private paramName: string) {}
20+
21+
applyToRequest(requestOptions: RequestOptions): void {
22+
if (this.location === 'query') {
23+
requestOptions.queryParameters[this.paramName] = this.apiKey;
24+
} else if (
25+
this.location === 'header' &&
26+
requestOptions &&
27+
requestOptions.headers
28+
) {
29+
requestOptions.headers[this.paramName] = this.apiKey;
30+
} else if (
31+
this.location === 'cookie' &&
32+
requestOptions &&
33+
requestOptions.headers
34+
) {
35+
if (requestOptions.headers.Cookie) {
36+
requestOptions.headers.Cookie += `; ${
37+
this.paramName
38+
}=${encodeURIComponent(this.apiKey)}`;
39+
} else {
40+
requestOptions.headers.Cookie = `${this.paramName}=${encodeURIComponent(
41+
this.apiKey
42+
)}`;
43+
}
44+
}
45+
}
46+
}
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
export type PushEventsResponse = {
2+
/**
3+
* A message confirming the event push.
4+
*/
5+
message: string;
6+
};
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
{
2+
"name": "@algolia/client-insights",
3+
"version": "5.0.0",
4+
"description": "JavaScript client for @algolia/client-insights",
5+
"repository": "algolia/algoliasearch-client-javascript",
6+
"author": "Algolia",
7+
"private": true,
8+
"license": "MIT",
9+
"main": "dist/api.js",
10+
"types": "dist/api.d.ts",
11+
"scripts": {
12+
"clean": "rm -Rf node_modules/ *.js",
13+
"build": "tsc",
14+
"test": "yarn build && node dist/client.js"
15+
},
16+
"engines": {
17+
"node": "^16.0.0",
18+
"yarn": "^3.0.0"
19+
},
20+
"devDependencies": {
21+
"@types/node": "16.11.11",
22+
"typescript": "4.5.4"
23+
}
24+
}
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
import { InsightsApi } from './insightsApi';
2+
3+
export * from './insightsApi';
4+
export * from '../utils/errors';
5+
export { EchoRequester } from '../utils/requester/EchoRequester';
6+
7+
export const APIS = [InsightsApi];

0 commit comments

Comments
 (0)