* Refactor services architecture with provider pattern and factory classes - Extract telemetry, error handling, and feature flags into separate service modules - Implement provider pattern with factory classes for better abstraction - Move PostHog-specific implementations to dedicated provider classes - Add interfaces for telemetry, error, and feature flags providers - Update imports across codebase to use new service structure - Add unit tests for telemetry service * Refactor service providers and centralize distinct ID management - Move provider interfaces to dedicated providers/ subdirectories - Extract distinct ID management to shared logging/distinctId module - Simplify PostHogClientProvider by removing distinct ID parameter - Update service factories to use centralized distinct ID - Reorganize test files to __tests__/ directories - Remove redundant distinct ID handling across services * merge main * clean up * add grok coder free model to cline provider (#5808) * add free grok-coder-free model to cline provider * add changeset * fix typo * v3.26.6 Release Notes (#5788) * changeset version bump * Updating CHANGELOG.md format * Update CHANGELOG.md for version 3.26.6 with user-friendly descriptions --------- Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> Co-authored-by: github-actions <github-actions@github.com> Co-authored-by: pashpashpash <nik@cline.bot> * Remove top padding from ActionButtons component (#5806) Eliminate unnecessary top padding in the chat view. * removing middle out from params to or / cline providers (#5811) * Dify.ai integration (#5761) * add focus chain settings to statemanager initialize function (#5798) * add custom gpt-5 system prompt (#5757) * gpt-5 system prompt * add changeset * Focus chain telemetry tweaks (#5810) Co-authored-by: Kevin Bond <kevin@Kevins-MacBook-Pro.local> * Remove eslint-rules test patterns from Mocha spec configuration (#5812) Update the "spec" array in .mocharc.json to exclude "eslint-rules/__tests__/**/*.test.ts", as that directory has been removed. * Increase horizontal margin in AutoApproveBar component (#5813) Update the mx-[5px] to mx-[15px] in the div's className to adjust horizontal spacing for improved layout alignment. * fix: remove hardcoded Ollama host from options (#5816) * fix: remove hardcoded Ollama host from options Updates the Ollama handler to remove the hardcoded "http://localhost:11434" as the `ollamaBaseUrl` fallback option for the host to allow the Ollama SDK to handle the default endpoint configured on users' machine. Reason: Ollama allows cross-origin requests from 127.0.0.1 and 0.0.0.0 by default. However, when we use localhost, the browser would resolve it through DNS, which can result in different IP addresses. Docs: https://github.com/ollama/ollama/blob/main/docs/faq.md#how-can-i-expose-ollama-on-my-network * add changeset * deep-planning prompt PowerShell (#5699) * Windows/Powershell specific deep planning prompt changes * Prompt adjustments --------- Co-authored-by: Kevin Bond <kevin@Kevins-MacBook-Pro.local> * Changes to condenseToolResponse & summarizeTask prompting (#5817) * Condense & deep planning prompt adjustments * Removed ps prompting ready for PR * rebase * Fixed typo on one word --------- Co-authored-by: Kevin Bond <kevin@Kevins-MacBook-Pro.local> * rename CacheService to StateManager (#5681) * rename CacheService to StateManager * fix types * infer state key types from existing interfaces (#5815) * fix: AutoApproveModal positioning and scrolling behavior (#5819) * fix: AutoApproveModal positioning and scrolling behavior - Add dynamic positioning calculation to prevent modal overflow - Implement proper flex layout with scrollable content container - Ensure minimum usable height and top margin constraints - Fix modal positioning when button is near viewport edges * Add changeset * clean up * template-based system prompt (#5731) * Refactor system prompt architecture with new template-based system - Move existing system prompt files to legacy directory - Implement new modular system with PromptBuilder, PromptRegistry, and TemplateEngine - Add component-based prompt structure with reusable parts (capabilities, rules, tool_use, etc.) - Create variant-specific templates for generic and next-gen models - Add comprehensive test suite with snapshots for different model configurations - Introduce template engine with placeholder support for dynamic prompt generation * Refactor system prompt architecture with modular tool definitions - Extract tool specifications into dedicated modules under tools/ - Add ClineToolSet class for managing tool variants by model family - Restructure prompt components with centralized index exports - Update prompt builder and registry to support new tool architecture - Reorganize shared utilities and type definitions - Update all test snapshots to reflect new prompt structure * Update snapshots * reorg * Update template format * clean up * typos * focus chain section * fix task progress in attempt_completion * Implement tool retrieval with fallback options in PromptBuilder - Added `getToolByNameWithFallback` and `getToolsForVariantWithFallback` methods to `ClineToolSet` for improved tool resolution. - Updated `getToolsPrompts` in `PromptBuilder` to utilize these new methods, allowing for better handling of tool requests with fallback to generic tools. - Enhanced sorting and filtering of tools based on context requirements and requested order. * update fild structure * clean up * fix static test string * Update snapshot names * Update unit test * Remove unused placeholders and update docs * Update README on how to add new tool * Remove task_progress reference from attempt_completion tool description when focus chain is disabled * Upgrade posthog-node to v5.8.0 and add exception filtering - Update posthog-node from v4.8.1 to v5.8.0 - Add EventMessage import for type safety - Implement posthogEventFilter to only capture exceptions from Cline extension - Filter exceptions by checking for "cline" in error messages or "saoudrizwan" in stack frames * Use env var keys - Add PostHogClientConfig to ErrorProviderFactory with proper validation - Update PostHogErrorProvider to use dedicated client instead of shared one - Add API key validation in PostHogFeatureFlagsProvider before client creation - Enhance error handling with fallback to NoOpErrorProvider instead of throwing - Standardize configuration passing across telemetry, error, and feature flag services * Upadte filter * update filter * update imports * use secret * disable enableExceptionAutocapture * removes vscode.env.machineId * initializeDistinctId * use get trap as workaround * on exit --------- Co-authored-by: pashpashpash <nik@cline.bot> Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> Co-authored-by: github-actions <github-actions@github.com> Co-authored-by: Toshii <94262432+0xToshii@users.noreply.github.com> Co-authored-by: Yunus Emre AYHAN <ayhanyunusemre@gmail.com> Co-authored-by: celestial-vault <58194240+celestial-vault@users.noreply.github.com> Co-authored-by: canvrno <46584286+canvrno@users.noreply.github.com> Co-authored-by: Kevin Bond <kevin@Kevins-MacBook-Pro.local>
75 lines
2.4 KiB
TypeScript
75 lines
2.4 KiB
TypeScript
import { posthogConfig } from "@shared/services/config/posthog-config"
|
|
import posthog from "posthog-js"
|
|
import { PostHogProvider } from "posthog-js/react"
|
|
import { type ReactNode, useEffect, useState } from "react"
|
|
import { useExtensionState } from "./context/ExtensionStateContext"
|
|
|
|
export function CustomPostHogProvider({ children }: { children: ReactNode }) {
|
|
const { distinctId, version, userInfo } = useExtensionState()
|
|
|
|
// NOTE: This is a hack to stop recording webview click events temporarily.
|
|
// Remove this to re-enable.
|
|
// const isTelemetryEnabled = telemetrySetting !== "disabled";
|
|
const isTelemetryEnabled = false
|
|
const [isActive, setIsActive] = useState(false)
|
|
|
|
useEffect(() => {
|
|
if (isActive || !isTelemetryEnabled || !posthogConfig.apiKey) {
|
|
return
|
|
}
|
|
// At this point, we know apiKey is defined due to the check above
|
|
const apiKey = posthogConfig.apiKey as string
|
|
posthog.init(apiKey, {
|
|
api_host: posthogConfig.host,
|
|
ui_host: posthogConfig.uiHost,
|
|
disable_session_recording: true,
|
|
capture_pageview: false,
|
|
capture_dead_clicks: true,
|
|
// Feature flags should work regardless of telemetry opt-out
|
|
advanced_disable_decide: false,
|
|
// Autocapture should respect telemetry settings
|
|
autocapture: false,
|
|
})
|
|
setIsActive(true)
|
|
}, [])
|
|
|
|
useEffect(() => {
|
|
if (!isTelemetryEnabled || !isActive || !distinctId || !version) {
|
|
return
|
|
}
|
|
|
|
posthog.set_config({
|
|
before_send: (payload) => {
|
|
// Only filter out events if telemetry is disabled, but allow feature flag requests
|
|
if (!isTelemetryEnabled && payload?.event !== "$feature_flag_called") {
|
|
return null
|
|
}
|
|
|
|
if (payload?.properties) {
|
|
payload.properties.extension_version = version
|
|
payload.properties.distinct_id = distinctId
|
|
}
|
|
return payload
|
|
},
|
|
})
|
|
|
|
const optedIn = posthog.has_opted_in_capturing()
|
|
const optedOut = posthog.has_opted_out_capturing()
|
|
const args = {
|
|
email: userInfo?.email,
|
|
name: userInfo?.displayName,
|
|
}
|
|
if (isTelemetryEnabled && !optedIn) {
|
|
posthog.opt_in_capturing()
|
|
posthog.identify(distinctId, args)
|
|
} else if (!isTelemetryEnabled && !optedOut) {
|
|
// For feature flags to work, we need to identify the user even when telemetry is disabled
|
|
posthog.identify(distinctId, args)
|
|
// Then opt out of capturing other events
|
|
posthog.opt_out_capturing()
|
|
}
|
|
}, [isActive, isTelemetryEnabled, distinctId, version])
|
|
|
|
return <PostHogProvider client={posthog}>{children}</PostHogProvider>
|
|
}
|