Skip to content

Commit

Permalink
Merge pull request #26 from axiomhq/fake-process-env
Browse files Browse the repository at this point in the history
Fake process.env for browsers
  • Loading branch information
bahlo authored Jun 26, 2023
2 parents e5232a9 + 6fd08a4 commit 6c0b4a5
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 0 deletions.
4 changes: 4 additions & 0 deletions packages/js/src/httpClient.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,10 @@ export interface ClientOptions {
orgId?: string;
}

// The browsers don't have process.env, fake it
const process: { env: Record<string, string | undefined> } =
typeof window === 'undefined' ? global.process : { env: {} };

export default abstract class HTTPClient {
protected readonly client: FetchClient;

Expand Down
4 changes: 4 additions & 0 deletions packages/pino/src/index.ts
Original file line number Diff line number Diff line change
@@ -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<string, string | undefined> } =
typeof window === 'undefined' ? global.process : { env: {} };

export enum AxiomEventLevel {
Trace = 'trace',
Debug = 'debug',
Expand Down
4 changes: 4 additions & 0 deletions packages/winston/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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<string, string | undefined> } =
typeof window === 'undefined' ? global.process : { env: {} };

export interface WinstonOptions extends TransportStreamOptions {
dataset?: string;
token?: string;
Expand Down

0 comments on commit 6c0b4a5

Please sign in to comment.