Skip to content

App will not open if dont have posthog product analytic credentials #1311

@littlekirkycode

Description

@littlekirkycode

Bug (I think)

Running the app after copying .env.example to .env (as instructed) causes an UnhandledPromiseRejectionWarning on both dev and package builds - that prevents the window from opening (only on mac and I can't find the reason why it works on windows test build).

UnhandledPromiseRejectionWarning: Error: Configuration: Could not parse user-provided export URL: 'xxx/i/v1/logs'

Cause

initOtelTransport in otel-log-transport.ts (introduced in #1278) only guards against empty values:

if (!apiKey || !apiHost) {
  return noop;
}

.env.example ships with xxx as a placeholder, which is truthy and passes this check. The exporter then receives xxx/i/v1/logs as the URL, which isn't parseable.

This doesn't affect developers with real PostHog API credentials — only those using the default placeholder values.

Fix

Validate the URL before passing it to the exporter:

const url = `${apiHost}/i/v1/logs`;
try {
  new URL(url);
} catch {
  return noop;
}

I put this fix into the windows PR

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions