diff --git a/packages/js/src/httpClient.ts b/packages/js/src/httpClient.ts index 60fc8982..9f25b84e 100644 --- a/packages/js/src/httpClient.ts +++ b/packages/js/src/httpClient.ts @@ -9,6 +9,10 @@ export interface ClientOptions { orgId?: string; } +// The browsers don't have process.env, fake it +const process: { env: Record } = + typeof window === 'undefined' ? global.process : { env: {} }; + export default abstract class HTTPClient { protected readonly client: FetchClient; diff --git a/packages/pino/src/index.ts b/packages/pino/src/index.ts index 63e2a758..7d306dd9 100644 --- a/packages/pino/src/index.ts +++ b/packages/pino/src/index.ts @@ -1,6 +1,10 @@ import build from 'pino-abstract-transport'; import { Axiom, ClientOptions } from '@axiomhq/js'; +// The browsers don't have process.env, fake it +const process: { env: Record } = + typeof window === 'undefined' ? global.process : { env: {} }; + export enum AxiomEventLevel { Trace = 'trace', Debug = 'debug', diff --git a/packages/winston/src/index.ts b/packages/winston/src/index.ts index 51ddcd6d..aa13cac4 100644 --- a/packages/winston/src/index.ts +++ b/packages/winston/src/index.ts @@ -2,6 +2,10 @@ import Transport, { TransportStreamOptions } from 'winston-transport'; import { AxiomWithoutBatching } from '@axiomhq/js'; +// The browsers don't have process.env, fake it +const process: { env: Record } = + typeof window === 'undefined' ? global.process : { env: {} }; + export interface WinstonOptions extends TransportStreamOptions { dataset?: string; token?: string;