mirror of
https://github.com/cline/cline.git
synced 2026-10-30 18:12:49 +08:00
fix(cli): route PostHog networking through shared fetch (#9149)
* fix(cli): route PostHog networking through shared fetch * remove unnecessary `as RequestInit` casts from PostHog fetch wrappers PostHogFetchOptions is a structural subset of RequestInit, so the cast is unnecessary. Also removes a stale comment about shared client support in PostHogErrorProvider.
This commit is contained in:
@@ -3,10 +3,11 @@ import { StateManager } from "@/core/storage/StateManager"
|
||||
import { HostProvider } from "@/hosts/host-provider"
|
||||
import { getDistinctId } from "@/services/logging/distinctId"
|
||||
import { PostHogClientProvider } from "@/services/telemetry/providers/posthog/PostHogClientProvider"
|
||||
import { fetch } from "@/shared/net"
|
||||
import { Setting } from "@/shared/proto/index.host"
|
||||
import { Logger } from "@/shared/services/Logger"
|
||||
import * as pkg from "../../../../package.json"
|
||||
import { PostHogClientValidConfig } from "../../../shared/services/config/posthog-config"
|
||||
import type { PostHogClientValidConfig } from "../../../shared/services/config/posthog-config"
|
||||
import { getErrorLevelFromString } from ".."
|
||||
import { ClineError } from "../ClineError"
|
||||
import type { ErrorSettings, IErrorProvider } from "./IErrorProvider"
|
||||
@@ -24,9 +25,9 @@ export class PostHogErrorProvider implements IErrorProvider {
|
||||
private readonly isSharedClient = false
|
||||
|
||||
constructor(clientConfig: PostHogClientValidConfig) {
|
||||
// Use shared PostHog client if provided, otherwise create a new one
|
||||
this.client = new PostHog(clientConfig.errorTrackingApiKey, {
|
||||
host: clientConfig.host,
|
||||
fetch: (url, options) => fetch(url, options),
|
||||
enableExceptionAutocapture: false, // NOTE: Re-enable it once the api key is set to env var
|
||||
before_send: (event) => PostHogClientProvider.eventFilter(event),
|
||||
})
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
import { PostHog } from "posthog-node"
|
||||
import { getDistinctId } from "@/services/logging/distinctId"
|
||||
import { fetch } from "@/shared/net"
|
||||
import { Logger } from "@/shared/services/Logger"
|
||||
import { posthogConfig } from "../../../shared/services/config/posthog-config"
|
||||
import type { FeatureFlagsAndPayloads, FeatureFlagsSettings, IFeatureFlagsProvider } from "./IFeatureFlagsProvider"
|
||||
@@ -26,6 +27,7 @@ export class PostHogFeatureFlagsProvider implements IFeatureFlagsProvider {
|
||||
}
|
||||
this.client = new PostHog(posthogConfig.apiKey, {
|
||||
host: posthogConfig.host,
|
||||
fetch: (url, options) => fetch(url, options),
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
import { EventMessage, PostHog } from "posthog-node"
|
||||
import { type EventMessage, PostHog } from "posthog-node"
|
||||
import { ClineEndpoint } from "@/config"
|
||||
import { fetch } from "@/shared/net"
|
||||
import { posthogConfig } from "@/shared/services/config/posthog-config"
|
||||
import { Logger } from "@/shared/services/Logger"
|
||||
|
||||
@@ -30,6 +31,7 @@ export class PostHogClientProvider {
|
||||
this.client = posthogConfig.apiKey
|
||||
? new PostHog(posthogConfig.apiKey, {
|
||||
host: posthogConfig.host,
|
||||
fetch: (url, options) => fetch(url, options),
|
||||
enableExceptionAutocapture: false, // This is only enabled for error services
|
||||
before_send: (event) => PostHogClientProvider.eventFilter(event),
|
||||
})
|
||||
|
||||
@@ -3,6 +3,7 @@ import { StateManager } from "@/core/storage/StateManager"
|
||||
import { HostProvider } from "@/hosts/host-provider"
|
||||
import { getErrorLevelFromString } from "@/services/error"
|
||||
import { getDistinctId, setDistinctId } from "@/services/logging/distinctId"
|
||||
import { fetch } from "@/shared/net"
|
||||
import { Setting } from "@/shared/proto/index.host"
|
||||
import { Logger } from "@/shared/services/Logger"
|
||||
import { posthogConfig } from "../../../../shared/services/config/posthog-config"
|
||||
@@ -33,6 +34,7 @@ export class PostHogTelemetryProvider implements ITelemetryProvider {
|
||||
}
|
||||
this.client = new PostHog(posthogConfig.apiKey, {
|
||||
host: posthogConfig.host,
|
||||
fetch: (url, options) => fetch(url, options),
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user