Add new pages and refactor existing code

This commit adds new Admin and Accounts pages, while also improving code by refactoring various portions such as extracting services from the join page and dynamically importing packages in logging and monitoring code. The build command is also removed from the WordPress package, and SWC minification is enabled in the Next.js configuration. Updated marketing content is also included in this commit.
This commit is contained in:
giancarlo
2024-04-08 11:47:26 +08:00
parent c77c9295c3
commit 2b447167f7
15 changed files with 154 additions and 89 deletions

View File

@@ -7,7 +7,6 @@
"format": "prettier --check \"**/*.{ts,tsx}\"",
"lint": "eslint .",
"typecheck": "tsc --noEmit",
"build": "contentlayer build",
"start": "docker compose up"
},
"prettier": "@kit/prettier-config",

View File

@@ -1,9 +1,3 @@
import {
BaselimeSDK,
BetterHttpInstrumentation,
VercelPlugin,
} from '@baselime/node-opentelemetry';
const INSTRUMENTATION_SERVICE_NAME = process.env.INSTRUMENTATION_SERVICE_NAME;
if (!INSTRUMENTATION_SERVICE_NAME) {
@@ -18,7 +12,11 @@ if (!INSTRUMENTATION_SERVICE_NAME) {
*
* Please set the MONITORING_INSTRUMENTATION_PROVIDER environment variable to 'baselime' to register Baselime instrumentation.
*/
export function registerBaselimeInstrumentation() {
export async function registerBaselimeInstrumentation() {
const { BaselimeSDK, BetterHttpInstrumentation, VercelPlugin } = await import(
'@baselime/node-opentelemetry'
);
const sdk = new BaselimeSDK({
serverless: true,
service: INSTRUMENTATION_SERVICE_NAME,

View File

@@ -1,11 +1,3 @@
import { Resource } from '@opentelemetry/resources';
import { NodeSDK } from '@opentelemetry/sdk-node';
import { SEMRESATTRS_SERVICE_NAME } from '@opentelemetry/semantic-conventions';
import {
SentryPropagator,
SentrySpanProcessor,
} from '@sentry/opentelemetry-node';
const INSTRUMENTATION_SERVICE_NAME = process.env.INSTRUMENTATION_SERVICE_NAME;
if (!INSTRUMENTATION_SERVICE_NAME) {
@@ -20,7 +12,18 @@ if (!INSTRUMENTATION_SERVICE_NAME) {
*
* Please set the MONITORING_INSTRUMENTATION_PROVIDER environment variable to 'sentry' to register Sentry instrumentation.
*/
export function registerSentryInstrumentation() {
export async function registerSentryInstrumentation() {
const { Resource } = await import('@opentelemetry/resources');
const { NodeSDK } = await import('@opentelemetry/sdk-node');
const { SEMRESATTRS_SERVICE_NAME } = await import(
'@opentelemetry/semantic-conventions'
);
const { SentrySpanProcessor, SentryPropagator } = await import(
'@sentry/opentelemetry-node'
);
const sdk = new NodeSDK({
resource: new Resource({
[SEMRESATTRS_SERVICE_NAME]: INSTRUMENTATION_SERVICE_NAME,

View File

@@ -17,7 +17,6 @@ const DEFAULT_INSTRUMENTATION_PROVIDER = process.env
* Please set the MONITORING_INSTRUMENTATION_PROVIDER environment variable to register the monitoring instrumentation provider.
*/
export async function registerInstrumentation() {
// Only run instrumentation in Node.js environment
if (
process.env.NEXT_RUNTIME !== 'nodejs' ||
!DEFAULT_INSTRUMENTATION_PROVIDER
@@ -39,6 +38,8 @@ export async function registerInstrumentation() {
}
default:
throw new Error(`Unknown instrumentation provider`);
throw new Error(
`Unknown instrumentation provider: ${DEFAULT_INSTRUMENTATION_PROVIDER as string}`,
);
}
}

View File

@@ -1,12 +1,14 @@
import { Logger as LoggerInstance } from './logger';
const LOGGER = process.env.LOGGER ?? 'pino';
/*
* Logger
* By default, the logger is set to use Pino. To change the logger, update the import statement below.
* to your desired logger implementation.
*/
async function getLogger(): Promise<LoggerInstance> {
switch (process.env.LOGGER ?? 'pino') {
switch (LOGGER) {
case 'pino': {
const { Logger: PinoLogger } = await import('./impl/pino');