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

fix: use tracing fetch #450

Merged
merged 5 commits into from
Nov 7, 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
3 changes: 2 additions & 1 deletion src/apex/handler.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,9 @@
* OF ANY KIND, either express or implied. See the License for the specific language
* governing permissions and limitations under the License.
*/
import { tracingFetch as fetch } from '@adobe/spacecat-shared-utils';

import { fetch, hasNonWWWSubdomain, toggleWWW } from '../support/utils.js';
import { hasNonWWWSubdomain, toggleWWW } from '../support/utils.js';
import { AuditBuilder } from '../common/audit-builder.js';
import { noopUrlResolver } from '../common/audit.js';

Expand Down
4 changes: 2 additions & 2 deletions src/backlinks/handler.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,11 @@
import {
internalServerError, noContent, notFound, ok,
} from '@adobe/spacecat-shared-http-utils';
import { composeAuditURL } from '@adobe/spacecat-shared-utils';
import { composeAuditURL, tracingFetch as fetch } from '@adobe/spacecat-shared-utils';
import AhrefsAPIClient from '@adobe/spacecat-shared-ahrefs-client';
import { AbortController, AbortError } from '@adobe/fetch';
import { retrieveSiteBySiteId } from '../utils/data-access.js';
import { enhanceBacklinksWithFixes, fetch } from '../support/utils.js';
import { enhanceBacklinksWithFixes } from '../support/utils.js';

const TIMEOUT = 3000;

Expand Down
3 changes: 1 addition & 2 deletions src/canonical/handler.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,7 @@
*/

import { JSDOM } from 'jsdom';
import { composeBaseURL } from '@adobe/spacecat-shared-utils';
import { fetch } from '../support/utils.js';
import { composeBaseURL, tracingFetch as fetch } from '@adobe/spacecat-shared-utils';
import { AuditBuilder } from '../common/audit-builder.js';
import { noopUrlResolver } from '../common/audit.js';

Expand Down
1 change: 1 addition & 0 deletions src/experimentation-ess/common.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@

/* c8 ignore start */
import RUMAPIClient from '@adobe/spacecat-shared-rum-api-client';
import { tracingFetch as fetch } from '@adobe/spacecat-shared-utils';
import { JSDOM } from 'jsdom';
import { LambdaClient, InvokeCommand } from '@aws-sdk/client-lambda';
import { defaultProvider } from '@aws-sdk/credential-provider-node';
Expand Down
3 changes: 1 addition & 2 deletions src/lhs/lib.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,9 @@
* governing permissions and limitations under the License.
*/

import { isObject, isValidUrl } from '@adobe/spacecat-shared-utils';
import { isObject, isValidUrl, tracingFetch as fetch } from '@adobe/spacecat-shared-utils';

import PSIClient from '../support/psi-client.js';
import { fetch } from '../support/utils.js';

/**
* Extracts audit scores from an audit.
Expand Down
3 changes: 1 addition & 2 deletions src/sitemap/handler.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,9 @@
* governing permissions and limitations under the License.
*/

import { composeAuditURL, prependSchema } from '@adobe/spacecat-shared-utils';
import { composeAuditURL, prependSchema, tracingFetch as fetch } from '@adobe/spacecat-shared-utils';
import {
extractDomainAndProtocol,
fetch,
getBaseUrlPagesFromSitemapContents,
getSitemapUrlsFromSitemapIndex,
getUrlWithoutPath,
Expand Down
5 changes: 3 additions & 2 deletions src/support/psi-client.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,11 @@
* governing permissions and limitations under the License.
*/

import { hasText, isObject, isValidUrl } from '@adobe/spacecat-shared-utils';
import {
hasText, isObject, isValidUrl, tracingFetch as fetch,
} from '@adobe/spacecat-shared-utils';

import { createUrl } from '@adobe/fetch';
import { fetch } from './utils.js';

/**
* The PSI strategies.
Expand Down
13 changes: 6 additions & 7 deletions src/support/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,19 +10,18 @@
* governing permissions and limitations under the License.
*/

import { context as h2, h1 } from '@adobe/fetch';
import { hasText, prependSchema, resolveCustomerSecretsName } from '@adobe/spacecat-shared-utils';
import {
hasText,
prependSchema,
resolveCustomerSecretsName,
tracingFetch as fetch,
} from '@adobe/spacecat-shared-utils';
import URI from 'urijs';
import { JSDOM } from 'jsdom';
import { GetSecretValueCommand, SecretsManagerClient } from '@aws-sdk/client-secrets-manager';

URI.preventInvalidHostname = true;

/* c8 ignore next 3 */
export const { fetch } = process.env.HELIX_FETCH_FORCE_HTTP1
? h1()
: h2();

// weekly pageview threshold to eliminate urls with lack of samples

export async function getRUMUrl(url) {
Expand Down
1 change: 1 addition & 0 deletions test/audits/backlinks.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ import auditBrokenBacklinks from '../../src/backlinks/handler.js';
use(sinonChai);
use(chaiAsPromised);

// eslint-disable-next-line func-names
describe('Backlinks Tests', function () {
this.timeout(10000);
let message;
Expand Down
2 changes: 1 addition & 1 deletion test/audits/experimentation-opportunities.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ import sinonChai from 'sinon-chai';
import nock from 'nock';
import { handler } from '../../src/experimentation-opportunities/experimentation-opportunities.js';
import { MockContextBuilder } from '../shared.js';
import opportunitiesData from '../fixtures/opportunitiesdata.json' assert { type: 'json' };
import opportunitiesData from '../fixtures/opportunitiesdata.json' with { type: 'json' };

use(sinonChai);

Expand Down
Loading