Skip to content

Commit d312723

Browse files
committed
feat(headers): rename userAgent to algoliaAgent
I've not changed anything in `clients/`, as i thought that is generated
1 parent e400a96 commit d312723

File tree

31 files changed

+68
-68
lines changed

31 files changed

+68
-68
lines changed

generators/src/main/java/com/algolia/codegen/AlgoliaJavascriptGenerator.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ private void setDefaultGeneratorOptions() {
5959

6060
additionalProperties.put("apiName", apiName);
6161
additionalProperties.put("capitalizedApiName", Utils.capitalize(apiName));
62-
additionalProperties.put("userAgent", Utils.capitalize(CLIENT));
62+
additionalProperties.put("algoliaAgent", Utils.capitalize(CLIENT));
6363
additionalProperties.put("gitRepoId", "algoliasearch-client-javascript");
6464
}
6565

playground/java/src/main/java/com/algolia/playground/Insights.java

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
import com.algolia.exceptions.AlgoliaRuntimeException;
66
import com.algolia.model.insights.*;
77
import com.algolia.api.InsightsClient;
8-
import com.algolia.utils.UserAgent;
8+
import com.algolia.utils.AlgoliaAgent;
99
import io.github.cdimascio.dotenv.Dotenv;
1010

1111
public class Insights {
@@ -15,10 +15,10 @@ public static void main(String[] args) {
1515
InsightsClient client = new InsightsClient(
1616
dotenv.get("ALGOLIA_APPLICATION_ID"),
1717
dotenv.get("ALGOLIA_SEARCH_KEY"),
18-
new UserAgent.Segment[] {
19-
new UserAgent.Segment("test", "8.0.0"),
20-
new UserAgent.Segment("JVM", "11.0.14"),
21-
new UserAgent.Segment("no version"),
18+
new AlgoliaAgent.Segment[] {
19+
new AlgoliaAgent.Segment("test", "8.0.0"),
20+
new AlgoliaAgent.Segment("JVM", "11.0.14"),
21+
new AlgoliaAgent.Segment("no version"),
2222
}
2323
);
2424

playground/java/src/main/java/com/algolia/playground/Search.java

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
import com.algolia.exceptions.AlgoliaRuntimeException;
66
import com.algolia.model.search.*;
77
import com.algolia.api.SearchClient;
8-
import com.algolia.utils.UserAgent;
8+
import com.algolia.utils.AlgoliaAgent;
99
import io.github.cdimascio.dotenv.Dotenv;
1010
import java.util.concurrent.CompletableFuture;
1111
import java.util.concurrent.ExecutionException;
@@ -19,10 +19,10 @@ public static void main(String[] args) {
1919
SearchClient client = new SearchClient(
2020
dotenv.get("ALGOLIA_APPLICATION_ID"),
2121
dotenv.get("ALGOLIA_SEARCH_KEY"),
22-
new UserAgent.Segment[] {
23-
new UserAgent.Segment("test", "8.0.0"),
24-
new UserAgent.Segment("JVM", "11.0.14"),
25-
new UserAgent.Segment("no version"),
22+
new AlgoliaAgent.Segment[] {
23+
new AlgoliaAgent.Segment("test", "8.0.0"),
24+
new AlgoliaAgent.Segment("JVM", "11.0.14"),
25+
new AlgoliaAgent.Segment("no version"),
2626
}
2727
);
2828

playground/javascript/browser/app.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import './app.css';
44

55
const client = searchClient('QPBQ67WNIG', 'b590ae1153bf574215ca1605c19eb1fe');
66

7-
client.addUserAgent('Browser playground', '0.0.1');
7+
client.addAlgoliaAgent('Browser playground', '0.0.1');
88

99
const searchButton = document.querySelector('#search');
1010

playground/javascript/node/algoliasearch.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ const personalizationApiKey =
2727
// Init client with appId and apiKey
2828
const client = algoliasearch(appId, apiKey);
2929

30-
client.addUserAgent('algoliasearch node playground', '0.0.1');
30+
client.addAlgoliaAgent('algoliasearch node playground', '0.0.1');
3131

3232
async function testAlgoliasearch() {
3333
try {

playground/javascript/node/search.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ const searchQuery = process.env.SEARCH_QUERY || 'test_query';
1313
// Init client with appId and apiKey
1414
const client = searchClient(appId, apiKey);
1515

16-
client.addUserAgent('Node playground', '0.0.1');
16+
client.addAlgoliaAgent('Node playground', '0.0.1');
1717

1818
async function testSearch() {
1919
try {

templates/java/libraries/okhttp-gson/ApiClient.mustache

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ package {{invokerPackage}};
22

33
import com.algolia.utils.Requester;
44
import com.algolia.exceptions.*;
5-
import com.algolia.utils.UserAgent;
5+
import com.algolia.utils.AlgoliaAgent;
66
import com.algolia.utils.JSON;
77
import com.algolia.utils.RequestOptions;
88

@@ -37,17 +37,17 @@ public class ApiClient {
3737
/*
3838
* Constructor for ApiClient with custom Requester
3939
*/
40-
public ApiClient(String appId, String apiKey, Requester requester, String clientName, UserAgent.Segment[] segments) {
40+
public ApiClient(String appId, String apiKey, Requester requester, String clientName, AlgoliaAgent.Segment[] segments) {
4141
this.contentType = "application/json";
4242
43-
UserAgent ua = new UserAgent("{{packageVersion}}");
44-
ua.addSegment(new UserAgent.Segment(clientName, "{{packageVersion}}"));
43+
AlgoliaAgent ua = new AlgoliaAgent("{{packageVersion}}");
44+
ua.addSegment(new AlgoliaAgent.Segment(clientName, "{{packageVersion}}"));
4545
if(segments != null) {
46-
for(UserAgent.Segment segment : segments) {
46+
for(AlgoliaAgent.Segment segment : segments) {
4747
ua.addSegment(segment);
4848
}
4949
}
50-
setUserAgent(ua.toString());
50+
setAlgoliaAgent(ua.toString());
5151

5252
defaultHeaderMap.put("X-Algolia-Application-Id", appId);
5353
defaultHeaderMap.put("X-Algolia-API-Key", apiKey);
@@ -64,11 +64,11 @@ public class ApiClient {
6464
/**
6565
* Set the User-Agent header's value (by adding to the default header map).
6666
*
67-
* @param userAgent HTTP request's user agent
67+
* @param algoliaAgent HTTP request's user agent
6868
* @return ApiClient
6969
*/
70-
public ApiClient setUserAgent(String userAgent) {
71-
addDefaultHeader("User-Agent", userAgent);
70+
public ApiClient setAlgoliaAgent(String algoliaAgent) {
71+
addDefaultHeader("User-Agent", algoliaAgent);
7272
return this;
7373
}
7474

templates/java/libraries/okhttp-gson/api.mustache

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -36,17 +36,17 @@ public class {{classname}} extends ApiClient {
3636
this(appId, apiKey, new HttpRequester(getDefaultHosts(null)), null);
3737
}
3838

39-
public {{classname}}(String appId, String apiKey, UserAgent.Segment[] userAgentSegments) {
40-
this(appId, apiKey, new HttpRequester(getDefaultHosts(null)), userAgentSegments);
39+
public {{classname}}(String appId, String apiKey, AlgoliaAgent.Segment[] algoliaAgentSegments) {
40+
this(appId, apiKey, new HttpRequester(getDefaultHosts(null)), algoliaAgentSegments);
4141
}
4242

4343
{{/fallbackToAliasHost}}
4444
public {{classname}}(String appId, String apiKey, String region) {
4545
this(appId, apiKey, new HttpRequester(getDefaultHosts(region)), null);
4646
}
4747

48-
public {{classname}}(String appId, String apiKey, String region, UserAgent.Segment[] userAgentSegments) {
49-
this(appId, apiKey, new HttpRequester(getDefaultHosts(region)), userAgentSegments);
48+
public {{classname}}(String appId, String apiKey, String region, AlgoliaAgent.Segment[] algoliaAgentSegments) {
49+
this(appId, apiKey, new HttpRequester(getDefaultHosts(region)), algoliaAgentSegments);
5050
}
5151
{{/hasRegionalHost}}
5252

@@ -55,17 +55,17 @@ public class {{classname}} extends ApiClient {
5555
this(appId, apiKey, new HttpRequester(getDefaultHosts(appId)), null);
5656
}
5757

58-
public {{classname}}(String appId, String apiKey, UserAgent.Segment[] userAgentSegments) {
59-
this(appId, apiKey, new HttpRequester(getDefaultHosts(appId)), userAgentSegments);
58+
public {{classname}}(String appId, String apiKey, AlgoliaAgent.Segment[] algoliaAgentSegments) {
59+
this(appId, apiKey, new HttpRequester(getDefaultHosts(appId)), algoliaAgentSegments);
6060
}
6161
{{/hasRegionalHost}}
6262

6363
public {{classname}}(String appId, String apiKey, Requester requester) {
6464
this(appId, apiKey, requester, null);
6565
}
6666

67-
public {{classname}}(String appId, String apiKey, Requester requester, UserAgent.Segment[] userAgentSegments) {
68-
super(appId, apiKey, requester, "{{{baseName}}}", userAgentSegments);
67+
public {{classname}}(String appId, String apiKey, Requester requester, AlgoliaAgent.Segment[] algoliaAgentSegments) {
68+
super(appId, apiKey, requester, "{{{baseName}}}", algoliaAgentSegments);
6969
}
7070

7171
{{^hasRegionalHost}}

templates/javascript/api-single.mustache

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import {
22
createAuth,
33
createTransporter,
4-
getUserAgent,
4+
getAlgoliaAgent,
55
shuffle,
66
} from '@experimental-api-clients-automation/client-common';
77
import type {
@@ -89,21 +89,21 @@ export function create{{capitalizedApiName}}(options: CreateClientOptions{{#hasR
8989
...auth.headers(),
9090
},
9191
baseQueryParameters: auth.queryParameters(),
92-
userAgent: getUserAgent({
93-
userAgents: options.userAgents,
94-
client: '{{{userAgent}}}',
92+
algoliaAgent: getAlgoliaAgent({
93+
algoliaAgents: options.algoliaAgents,
94+
client: '{{{algoliaAgent}}}',
9595
version: apiClientVersion,
9696
}),
9797
timeouts: options.timeouts,
9898
requester: options.requester,
9999
});
100100

101-
function addUserAgent(segment: string, version?: string): void {
102-
transporter.userAgent.add({ segment, version });
101+
function addAlgoliaAgent(segment: string, version?: string): void {
102+
transporter.algoliaAgent.add({ segment, version });
103103
}
104104

105105
return {
106-
addUserAgent,
106+
addAlgoliaAgent,
107107
{{#operation}}
108108
/**
109109
{{#notes}}

templates/javascript/browser.mustache

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ export function {{apiName}}(
4141
write: 30,
4242
},
4343
requester: options?.requester ?? createXhrRequester(),
44-
userAgents: [{ segment: 'Browser' }],
44+
algoliaAgents: [{ segment: 'Browser' }],
4545
authMode: 'WithinQueryParameters',
4646
responsesCache: options?.responsesCache ?? createMemoryCache(),
4747
requestsCache: options?.requestsCache ?? createMemoryCache({ serializable: false }),

templates/javascript/node.mustache

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ export function {{apiName}}(
4141
write: 30,
4242
},
4343
requester: options?.requester ?? createHttpRequester(),
44-
userAgents: [{ segment: 'Node.js', version: process.versions.node }],
44+
algoliaAgents: [{ segment: 'Node.js', version: process.versions.node }],
4545
responsesCache: options?.responsesCache ?? createNullCache(),
4646
requestsCache: options?.requestsCache ?? createNullCache(),
4747
hostsCache: options?.hostsCache ?? createMemoryCache(),

templates/php/Configuration.mustache

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ abstract class Configuration
3030
*
3131
* @var string
3232
*/
33-
protected $userAgent = null;
33+
protected $algoliaAgent = null;
3434
3535
/**
3636
* Debug switch (default set to false)
@@ -252,19 +252,19 @@ abstract class Configuration
252252
/**
253253
* Sets the user agent of the api client
254254
*
255-
* @param string $userAgent the user agent of the api client
255+
* @param string $algoliaAgent the user agent of the api client
256256
*
257257
* @throws \InvalidArgumentException
258258
*
259259
* @return $this
260260
*/
261-
public function setUserAgent($userAgent)
261+
public function setAlgoliaAgent($algoliaAgent)
262262
{
263-
if (!is_string($userAgent)) {
263+
if (!is_string($algoliaAgent)) {
264264
throw new \InvalidArgumentException('User-agent must be a string.');
265265
}
266266

267-
$this->userAgent = $userAgent;
267+
$this->algoliaAgent = $algoliaAgent;
268268

269269
return $this;
270270
}
@@ -274,8 +274,8 @@ abstract class Configuration
274274
*
275275
* @return string user agent
276276
*/
277-
public function getUserAgent()
277+
public function getAlgoliaAgent()
278278
{
279-
return $this->userAgent;
279+
return $this->algoliaAgent;
280280
}
281281
}

tests/CTS/client/abtesting/api.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
}
2020
],
2121
"expected": {
22-
"testSubject": "actual.userAgent",
22+
"testSubject": "actual.algoliaAgent",
2323
"match": {
2424
"regexp": "/Algolia%20for%20(.+)%20\\(\\d+\\.\\d+\\.\\d+\\)/"
2525
}

tests/CTS/client/analytics/api.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
}
1313
],
1414
"expected": {
15-
"testSubject": "actual.userAgent",
15+
"testSubject": "actual.algoliaAgent",
1616
"match": {
1717
"regexp": "/Algolia%20for%20(.+)%20\\(\\d+\\.\\d+\\.\\d+\\)/"
1818
}

tests/CTS/client/insights/api.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
}
1313
],
1414
"expected": {
15-
"testSubject": "actual.userAgent",
15+
"testSubject": "actual.algoliaAgent",
1616
"match": {
1717
"regexp": "/Algolia%20for%20(.+)%20\\(\\d+\\.\\d+\\.\\d+\\)/"
1818
}

tests/CTS/client/personalization/api.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
"path": "getPersonalizationStrategy",
99
"parameters": [],
1010
"expected": {
11-
"testSubject": "actual.userAgent",
11+
"testSubject": "actual.algoliaAgent",
1212
"match": {
1313
"regexp": "/Algolia%20for%20(.+)%20\\(\\d+\\.\\d+\\.\\d+\\)/"
1414
}

tests/CTS/client/predict/api.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
}
1818
],
1919
"expected": {
20-
"testSubject": "actual.userAgent",
20+
"testSubject": "actual.algoliaAgent",
2121
"match": {
2222
"regexp": "/Algolia%20for%20(.+)%20\\(\\d+\\.\\d+\\.\\d+\\)/"
2323
}

tests/CTS/client/query-suggestions/api.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
{}
1111
],
1212
"expected": {
13-
"testSubject": "actual.userAgent",
13+
"testSubject": "actual.algoliaAgent",
1414
"match": {
1515
"regexp": "/Algolia%20for%20(.+)%20\\(\\d+\\.\\d+\\.\\d+\\)/"
1616
}

tests/CTS/client/recommend/api.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@
3434
}
3535
],
3636
"expected": {
37-
"testSubject": "actual.userAgent",
37+
"testSubject": "actual.algoliaAgent",
3838
"match": {
3939
"regexp": "/Algolia%20for%20(.+)%20\\(\\d+\\.\\d+\\.\\d+\\)/"
4040
}

tests/CTS/client/search/api.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@
3636
}
3737
],
3838
"expected": {
39-
"testSubject": "actual.userAgent",
39+
"testSubject": "actual.algoliaAgent",
4040
"match": {
4141
"regexp": "/Algolia%20for%20(.+)%20\\(\\d+\\.\\d+\\.\\d+\\)/"
4242
}

tests/CTS/client/sources/api.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@
5050
}
5151
],
5252
"expected": {
53-
"testSubject": "actual.userAgent",
53+
"testSubject": "actual.algoliaAgent",
5454
"match": {
5555
"regexp": "/Algolia%20for%20(.+)%20\\(\\d+\\.\\d+\\.\\d+\\)/"
5656
}

tests/output/javascript/src/client/abtesting.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ describe('api', () => {
2828
actual = await actual;
2929
}
3030

31-
expect(actual.userAgent).toMatch(
31+
expect(actual.algoliaAgent).toMatch(
3232
/Algolia%20for%20(.+)%20\(\d+\.\d+\.\d+\)/
3333
);
3434
});

tests/output/javascript/src/client/analytics.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ describe('api', () => {
2424
actual = await actual;
2525
}
2626

27-
expect(actual.userAgent).toMatch(
27+
expect(actual.algoliaAgent).toMatch(
2828
/Algolia%20for%20(.+)%20\(\d+\.\d+\.\d+\)/
2929
);
3030
});

tests/output/javascript/src/client/insights.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ describe('api', () => {
2424
actual = await actual;
2525
}
2626

27-
expect(actual.userAgent).toMatch(
27+
expect(actual.algoliaAgent).toMatch(
2828
/Algolia%20for%20(.+)%20\(\d+\.\d+\.\d+\)/
2929
);
3030
});

tests/output/javascript/src/client/personalization.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ describe('api', () => {
2626
actual = await actual;
2727
}
2828

29-
expect(actual.userAgent).toMatch(
29+
expect(actual.algoliaAgent).toMatch(
3030
/Algolia%20for%20(.+)%20\(\d+\.\d+\.\d+\)/
3131
);
3232
});

tests/output/javascript/src/client/predict.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ describe('api', () => {
2727
actual = await actual;
2828
}
2929

30-
expect(actual.userAgent).toMatch(
30+
expect(actual.algoliaAgent).toMatch(
3131
/Algolia%20for%20(.+)%20\(\d+\.\d+\.\d+\)/
3232
);
3333
});

0 commit comments

Comments
 (0)