Skip to content

Commit

Permalink
Fake process.env for browsers
Browse files Browse the repository at this point in the history
Otherwise we get this:
> Uncaught ReferenceError: process is not defined
  • Loading branch information
bahlo committed Jun 26, 2023
1 parent bad81b3 commit 63a58b5
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 0 deletions.
3 changes: 3 additions & 0 deletions packages/js/src/httpClient.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,9 @@ export interface ClientOptions {
orgId?: string;
}

// The browsers don't have process.env, fake it
const process = typeof window === 'undefined' ? process : { env: {} };

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

Expand Down
3 changes: 3 additions & 0 deletions packages/pino/src/index.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
import build from 'pino-abstract-transport';
import { Axiom, ClientOptions } from '@axiomhq/js';

// The browsers don't have process.env, fake it
const process = typeof window === 'undefined' ? process : { env: {} };

export enum AxiomEventLevel {
Trace = 'trace',
Debug = 'debug',
Expand Down
3 changes: 3 additions & 0 deletions packages/winston/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@ import Transport, { TransportStreamOptions } from 'winston-transport';

import { AxiomWithoutBatching } from '@axiomhq/js';

// The browsers don't have process.env, fake it
const process = typeof window === 'undefined' ? process : { env: {} };

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

0 comments on commit 63a58b5

Please sign in to comment.