Skip to content

Commit

Permalink
revert useAlgoliaTracking
Browse files Browse the repository at this point in the history
  • Loading branch information
millotp committed Dec 13, 2022
1 parent 413f946 commit 725996b
Show file tree
Hide file tree
Showing 9 changed files with 26 additions and 19 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,6 @@ describe('api', () => {
`Algolia for JavaScript (${apiClientVersion}); Search (${apiClientVersion});`
),
},
useAlgoliaTracking: true,
baseHeaders: {
'content-type': 'text/plain',
'x-algolia-api-key': 'API_KEY',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,6 @@ export function createTransporter({
baseHeaders,
baseQueryParameters,
algoliaAgent,
useAlgoliaTracking,
timeouts,
requester,
requestsCache,
Expand Down Expand Up @@ -111,12 +110,15 @@ export function createTransporter({
: {};

const queryParameters: QueryParameters = {
...(useAlgoliaTracking ? { 'x-algolia-agent': algoliaAgent.value } : {}),
...baseQueryParameters,
...request.queryParameters,
...dataQueryParameters,
};

if (algoliaAgent.value) {
queryParameters['x-algolia-agent'] = algoliaAgent.value;
}

if (requestOptions && requestOptions.queryParameters) {
for (const key of Object.keys(requestOptions.queryParameters)) {
// We want to keep `undefined` and `null` values,
Expand Down Expand Up @@ -338,7 +340,6 @@ export function createTransporter({
requester,
timeouts,
algoliaAgent,
useAlgoliaTracking,
baseHeaders,
baseQueryParameters,
hosts,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ type OverriddenTransporterOptions =

export type CreateClientOptions = Omit<
TransporterOptions,
OverriddenTransporterOptions | 'algoliaAgent' | 'useAlgoliaTracking'
OverriddenTransporterOptions | 'algoliaAgent'
> &
Partial<Pick<TransporterOptions, OverriddenTransporterOptions>> & {
appId: string;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -139,8 +139,6 @@ export type TransporterOptions = {
* The user agent used. Sent on query parameters.
*/
algoliaAgent: AlgoliaAgent;

useAlgoliaTracking: boolean;
};

export type Transporter = TransporterOptions & {
Expand Down
6 changes: 3 additions & 3 deletions clients/algoliasearch-client-javascript/yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -113,9 +113,9 @@ __metadata:
version: 0.0.0-use.local
resolution: "@algolia/ingestion@workspace:packages/ingestion"
dependencies:
"@algolia/client-common": 5.0.0-alpha.26
"@algolia/requester-browser-xhr": 5.0.0-alpha.26
"@algolia/requester-node-http": 5.0.0-alpha.26
"@algolia/client-common": 5.0.0-alpha.27
"@algolia/requester-browser-xhr": 5.0.0-alpha.27
"@algolia/requester-node-http": 5.0.0-alpha.27
"@types/node": 16.11.59
rollup: 2.79.1
typescript: 4.8.3
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ private void setDefaultGeneratorOptions() {
additionalProperties.put("algoliaAgent", Utils.capitalize(CLIENT));
additionalProperties.put("gitRepoId", "algoliasearch-client-javascript");
additionalProperties.put("isSearchClient", CLIENT.equals("search"));
additionalProperties.put("useAlgoliaTracking", !CLIENT.equals("ingestion"));
additionalProperties.put("useAlgoliaUA", !CLIENT.equals("ingestion"));
additionalProperties.put("isAlgoliasearchClient", isAlgoliasearchClient);

if (isAlgoliasearchClient) {
Expand Down
4 changes: 2 additions & 2 deletions playground/javascript/node/ingestion.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,11 @@ const apiKey =
'**** ADMIN_KEY *****';

// Init client with appId and apiKey
const client = ingestionClient(appId, apiKey, 'us', {authMode: 'WithinHeaders'});
const client = ingestionClient(appId, apiKey, 'us', {authMode: 'WithinHeaders', hosts: [{url: 'staging-data.us.algolia.com', accept: 'readWrite', protocol: 'https'}]});

async function testIngestion() {
try {
const res = await client.createAuthentication({input: {appID: appId, apiKey}, name: 'test', type: 'algolia'});
const res = await client.getAuthentications();

console.log(`[OK]`, res);
} catch (e) {
Expand Down
File renamed without changes.
21 changes: 15 additions & 6 deletions templates/javascript/clients/api-single.mustache
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,21 @@ export function create{{capitalizedApiName}}({
const transporter = createTransporter({
hosts: getDefaultHosts({{^hasRegionalHost}}appIdOption{{/hasRegionalHost}}{{#hasRegionalHost}}regionOption{{/hasRegionalHost}}),
...options,
useAlgoliaTracking: {{{useAlgoliaTracking}}},
algoliaAgent: getAlgoliaAgent({
algoliaAgents,
client: '{{{algoliaAgent}}}',
version: apiClientVersion,
}),
algoliaAgent:
{{^useAlgoliaUA}}
{...getAlgoliaAgent({
algoliaAgents,
client: '{{{algoliaAgent}}}',
version: apiClientVersion,
}), value: ''},
{{/useAlgoliaUA}}
{{#useAlgoliaUA}}
getAlgoliaAgent({
algoliaAgents,
client: '{{{algoliaAgent}}}',
version: apiClientVersion,
}),
{{/useAlgoliaUA}}
baseHeaders: {
'content-type': 'text/plain',
...auth.headers(),
Expand Down

0 comments on commit 725996b

Please sign in to comment.