Skip to content

Commit 0ca77e5

Browse files
authored
chore(o11y): update server jobs to use structured logging (#6387)
* chore(o11y): update server jobs to use structured logging * chore: move initializeEnvVars logic to config.ts
1 parent 6b0cbdd commit 0ca77e5

File tree

7 files changed

+168
-273
lines changed

7 files changed

+168
-273
lines changed

.storybook/preview.tsx

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@ import { TestComponentWrapper } from "../src/TestComponentWrapper";
1414

1515
const inter = Inter({ subsets: ["latin"], variable: "--font-inter" });
1616

17-
sb.mock("../src/initializeEnvVars", { spy: false });
1817
sb.mock("../src/config", { spy: false });
1918

2019
const AppDecorator: Preview["decorators"] = (storyFn) => {

src/config.ts

Lines changed: 28 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,24 @@
44

55
// Only process.env variables starting with `NEXT_PUBLIC_` will be shipped to the client:
66
import "./app/functions/server/notInClientComponent";
7-
import "./initializeEnvVars";
7+
8+
import { resolve } from "node:path";
9+
import { fileURLToPath } from "node:url";
10+
import env from "@next/env";
11+
12+
// Initialize variables from env file if appropriate
13+
// Doesn't run in tests by design, so ignore for coverage:
14+
/* c8 ignore start */
15+
if (
16+
typeof process.env.NEXT_RUNTIME !== "string" &&
17+
(process.env.NODE_ENV !== "test" || process.env.PLAYWRIGHT === "true")
18+
) {
19+
// If we're in Next.js, our `.env` files are already set up to be loaded.
20+
// Outside of Next.js (e.g. in cron jobs), however, we need to explicitly load them.
21+
// (In unit tests, `next/jest` takes care of this, so no need to run this there.)
22+
env.loadEnvConfig(resolve(fileURLToPath(import.meta.url), "../../"));
23+
}
24+
/* c8 ignore end */
825

926
// Don't need to have coverage on config object
1027
/* c8 ignore start */
@@ -92,6 +109,16 @@ export const config = {
92109
}),
93110
},
94111
},
112+
aws: {
113+
accessKeyId: getEnvString("AWS_ACCESS_KEY_ID", { fallbackValue: "" }),
114+
secretAccessKey: getEnvString("AWS_SECRET_ACCESS_KEY", {
115+
fallbackValue: "",
116+
}),
117+
region: getEnvString("AWS_REGION", { fallbackValue: "us-west-1" }),
118+
s3: {
119+
logoBucket: getEnvString("S3_BUCKET", { fallbackValue: "" }),
120+
},
121+
},
95122
} as const;
96123
/* c8 ignore end */
97124

src/initializeEnvVars.js

Lines changed: 0 additions & 23 deletions
This file was deleted.

src/scripts/cronjobs/deleteSubsNoFxaUid.ts

Lines changed: 0 additions & 137 deletions
This file was deleted.

0 commit comments

Comments
 (0)