Skip to content
Open
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
4 changes: 3 additions & 1 deletion eslint.config.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ const gitignorePath = path.resolve(__dirname, '.gitignore');
export default tseslint.config(
includeIgnoreFile(gitignorePath),

{ files: [ '**/*.{js,mjs,cjs,ts,jsx,tsx}', '**/*.pw.tsx' ] },
{ files: [ '**/*.{js,mjs,cjs,ts,jsx,tsx}' ] },

{ ignores: [
'deploy/tools/',
Expand All @@ -69,6 +69,8 @@ export default tseslint.config(
'next.config.js',
'./toolkit/theme/design-system/dist',
'./toolkit/theme/design-system/build',
// TODO: we ignored these, need to be put back into "files" section :63
'**/*.pw.tsx',
] },

{ languageOptions: { globals: { ...globals.browser, ...globals.node } } },
Expand Down
31 changes: 20 additions & 11 deletions instrumentation.node.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,19 @@ import { getNodeAutoInstrumentations } from '@opentelemetry/auto-instrumentation
import { OTLPMetricExporter } from '@opentelemetry/exporter-metrics-otlp-proto';
import { OTLPTraceExporter } from '@opentelemetry/exporter-trace-otlp-http';
import { Resource } from '@opentelemetry/resources';
import type {
PushMetricExporter } from '@opentelemetry/sdk-metrics';
import {
PeriodicExportingMetricReader,
ConsoleMetricExporter,
} from '@opentelemetry/sdk-metrics';
import { NodeSDK } from '@opentelemetry/sdk-node';
import { SimpleSpanProcessor } from '@opentelemetry/sdk-trace-node';
import { SEMRESATTRS_SERVICE_NAME, SEMRESATTRS_SERVICE_VERSION, SEMRESATTRS_SERVICE_INSTANCE_ID } from '@opentelemetry/semantic-conventions';
import {
SEMRESATTRS_SERVICE_NAME,
SEMRESATTRS_SERVICE_VERSION,
SEMRESATTRS_SERVICE_INSTANCE_ID,
} from '@opentelemetry/semantic-conventions';

diag.setLogger(new DiagConsoleLogger(), DiagLogLevel.INFO);

Expand All @@ -19,23 +25,26 @@ const traceExporter = new OTLPTraceExporter();
const sdk = new NodeSDK({
resource: new Resource({
[SEMRESATTRS_SERVICE_NAME]: 'blockscout_frontend',
[SEMRESATTRS_SERVICE_VERSION]: process.env.NEXT_PUBLIC_GIT_TAG || process.env.NEXT_PUBLIC_GIT_COMMIT_SHA || 'unknown_version',
[SEMRESATTRS_SERVICE_VERSION]:
process.env.NEXT_PUBLIC_GIT_TAG ||
process.env.NEXT_PUBLIC_GIT_COMMIT_SHA ||
'unknown_version',
[SEMRESATTRS_SERVICE_INSTANCE_ID]:
process.env.NEXT_PUBLIC_APP_INSTANCE ||
process.env.NEXT_PUBLIC_APP_HOST?.replace('.blockscout.com', '').replaceAll('-', '_') ||
'unknown_app',
process.env.NEXT_PUBLIC_APP_INSTANCE ||
process.env.NEXT_PUBLIC_APP_HOST?.replace(
'.blockscout.com',
'',
).replaceAll('-', '_') ||
'unknown_app',
}),
spanProcessor: new SimpleSpanProcessor(traceExporter),
traceExporter,
metricReader: new PeriodicExportingMetricReader({
exporter:
process.env.NODE_ENV === 'production' ?
// eslint-disable-next-line @typescript-eslint/no-explicit-any
new OTLPMetricExporter() as any :
// eslint-disable-next-line @typescript-eslint/no-explicit-any
new ConsoleMetricExporter() as any,
// eslint-disable-next-line @typescript-eslint/no-explicit-any
}) as any,
(new OTLPMetricExporter() as unknown as PushMetricExporter) :
new ConsoleMetricExporter(),
}) as unknown as undefined,
instrumentations: [
getNodeAutoInstrumentations({
'@opentelemetry/instrumentation-http': {
Expand Down
40 changes: 35 additions & 5 deletions nextjs/nextjs-routes.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,11 @@

// prettier-ignore
declare module "nextjs-routes" {
import type {
GetServerSidePropsContext as NextGetServerSidePropsContext,
GetServerSidePropsResult as NextGetServerSidePropsResult
} from "nextjs";

export type Route =
| StaticRoute<"/404">
| StaticRoute<"/account/api-key">
Expand Down Expand Up @@ -107,6 +112,33 @@ declare module "nextjs-routes" {
* route({ pathname: "/foos/[foo]", query: { foo: "bar" }}) will produce "/foos/bar".
*/
export declare function route(r: Route): string;

/**
* Nearly identical to GetServerSidePropsContext from next, but further narrows
* types based on nextjs-route's route data.
*/
export type GetServerSidePropsContext<
Pathname extends Route["pathname"] = Route["pathname"],
Preview extends NextGetServerSidePropsContext["previewData"] = NextGetServerSidePropsContext["previewData"]
> = Omit<NextGetServerSidePropsContext, 'params' | 'query' | 'defaultLocale' | 'locale' | 'locales'> & {
params: Extract<Route, { pathname: Pathname }>["query"];
query: Query;
defaultLocale?: undefined;
locale?: Locale;
locales?: undefined;
};

/**
* Nearly identical to GetServerSideProps from next, but further narrows
* types based on nextjs-route's route data.
*/
export type GetServerSideProps<
Props extends { [key: string]: any } = { [key: string]: any },
Pathname extends Route["pathname"] = Route["pathname"],
Preview extends NextGetServerSideProps["previewData"] = NextGetServerSideProps["previewData"]
> = (
context: GetServerSidePropsContext<Pathname, Preview>
) => Promise<NextGetServerSidePropsResult<Props>>
}

// prettier-ignore
Expand All @@ -121,13 +153,12 @@ declare module "next/link" {
} from "react";
export * from "next/dist/client/link";

type Query = { query?: { [key: string]: string | string[] | undefined } };
type StaticRoute = Exclude<Route, { query: any }>["pathname"];

export interface LinkProps
extends Omit<NextLinkProps, "href" | "locale">,
AnchorHTMLAttributes<HTMLAnchorElement> {
href: Route | StaticRoute | Query;
href: Route | StaticRoute | Omit<Route, "pathname">
locale?: false;
}

Expand Down Expand Up @@ -155,7 +186,6 @@ declare module "next/router" {

type NextTransitionOptions = NonNullable<Parameters<Router["push"]>[2]>;
type StaticRoute = Exclude<Route, { query: any }>["pathname"];
type Query = { query?: { [key: string]: string | string[] | undefined } };

interface TransitionOptions extends Omit<NextTransitionOptions, "locale"> {
locale?: false;
Expand All @@ -177,12 +207,12 @@ declare module "next/router" {
locale?: Locale;
locales?: undefined;
push(
url: Route | StaticRoute | Query,
url: Route | StaticRoute | Omit<Route, "pathname">,
as?: string,
options?: TransitionOptions
): Promise<boolean>;
replace(
url: Route | StaticRoute | Query,
url: Route | StaticRoute | Omit<Route, "pathname">,
as?: string,
options?: TransitionOptions
): Promise<boolean>;
Expand Down
2 changes: 1 addition & 1 deletion tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,6 @@
"./toolkit/package",
"./toolkit/theme/design-system/build",
"./toolkit/theme/design-system/dist",
"**/*.pw.tsx"
"**/*.pw.tsx" // TODO: this needs to be put back in the include section :21
],
}
Loading