@posthog/wizard 2.38.0 → 2.38.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{add-mcp-server-to-clients-CeoyDLC-.js → add-mcp-server-to-clients-BB1_aH5M.js} +5 -5
- package/dist/{add-mcp-server-to-clients-CeoyDLC-.js.map → add-mcp-server-to-clients-BB1_aH5M.js.map} +1 -1
- package/dist/{agent-interface-BAodys0H.js → agent-interface-kOuzXg84.js} +13 -11
- package/dist/{agent-interface-BAodys0H.js.map → agent-interface-kOuzXg84.js.map} +1 -1
- package/dist/{agent-runner-BMuJP8fb.js → agent-runner-DZhaiwD5.js} +20 -18
- package/dist/{agent-runner-BMuJP8fb.js.map → agent-runner-DZhaiwD5.js.map} +1 -1
- package/dist/analytics-B1SC2jaf.js +2 -0
- package/dist/{analytics-CvIK_07d.js → analytics-Z_2kCTpB.js} +3 -3
- package/dist/{analytics-CvIK_07d.js.map → analytics-Z_2kCTpB.js.map} +1 -1
- package/dist/{api-CyA47qug.js → api-CwhOyprf.js} +3 -3
- package/dist/{api-CyA47qug.js.map → api-CwhOyprf.js.map} +1 -1
- package/dist/bin.js +50 -50
- package/dist/{ci-install-C_o0Q7Fg.js → ci-install-CWDY86uB.js} +4 -4
- package/dist/{ci-install-C_o0Q7Fg.js.map → ci-install-CWDY86uB.js.map} +1 -1
- package/dist/{debug-BhGq9rn9.js → debug-BmdpjMub.js} +1 -1
- package/dist/{debug-CgdI7Rd-.js → debug-CaRHQrDY.js} +38 -12
- package/dist/{debug-CgdI7Rd-.js.map → debug-CaRHQrDY.js.map} +1 -1
- package/dist/{defaults-b2Bo9Wid.js → defaults-a0e6IRjP.js} +1 -1
- package/dist/{defaults-b2Bo9Wid.js.map → defaults-a0e6IRjP.js.map} +1 -1
- package/dist/{env-api-key-Bezg_uXQ.js → env-api-key-DEl3LJBv.js} +1 -1
- package/dist/{env-api-key-Bezg_uXQ.js.map → env-api-key-DEl3LJBv.js.map} +1 -1
- package/dist/{environment-v22_Genm.js → environment-knibpXF2.js} +3 -3
- package/dist/{environment-v22_Genm.js.map → environment-knibpXF2.js.map} +1 -1
- package/dist/{file-utils-Gvc2Ysa_.js → file-utils-DWYX_G1o.js} +2 -2
- package/dist/{file-utils-Gvc2Ysa_.js.map → file-utils-DWYX_G1o.js.map} +1 -1
- package/dist/{headless-ui-BtBcuxOj.js → headless-ui-C4JCi9Zz.js} +2 -2
- package/dist/{headless-ui-BtBcuxOj.js.map → headless-ui-C4JCi9Zz.js.map} +1 -1
- package/dist/{host-resolution-CUjt6efz.js → host-resolution-C18FwVrM.js} +3 -3
- package/dist/{host-resolution-CUjt6efz.js.map → host-resolution-C18FwVrM.js.map} +1 -1
- package/dist/{interactive-CRdgBMxk.js → interactive-46qgS-UA.js} +2 -2
- package/dist/{interactive-CRdgBMxk.js.map → interactive-46qgS-UA.js.map} +1 -1
- package/dist/{mcp-XWzcKTeK.js → mcp-QWL5Obf3.js} +2 -2
- package/dist/{mcp-XWzcKTeK.js.map → mcp-QWL5Obf3.js.map} +1 -1
- package/dist/{mcp-prompt-streaming-DeC85Icy.js → mcp-prompt-streaming-BpNkFksF.js} +4 -4
- package/dist/{mcp-prompt-streaming-DeC85Icy.js.map → mcp-prompt-streaming-BpNkFksF.js.map} +1 -1
- package/dist/{non-interactive-B-Ku4EOx.js → non-interactive-3_T1d0cj.js} +2 -2
- package/dist/{non-interactive-B-Ku4EOx.js.map → non-interactive-3_T1d0cj.js.map} +1 -1
- package/dist/{package-json-DCuoye-H.js → package-json-CDs1ZVKu.js} +1 -1
- package/dist/{package-json-DCuoye-H.js.map → package-json-CDs1ZVKu.js.map} +1 -1
- package/dist/{package-manager-Dj6dTKlK.js → package-manager-C5VVQHQ-.js} +2 -2
- package/dist/{package-manager-Dj6dTKlK.js.map → package-manager-C5VVQHQ-.js.map} +1 -1
- package/dist/{playground-CmKFAlCE.js → playground-CbzUpMuN.js} +6 -6
- package/dist/{playground-CmKFAlCE.js.map → playground-CbzUpMuN.js.map} +1 -1
- package/dist/{posthog-Dnl6wsYc.js → posthog-BESrI6-T.js} +1 -1
- package/dist/{posthog-Dnl6wsYc.js.map → posthog-BESrI6-T.js.map} +1 -1
- package/dist/{posthog-integration-CcJWXPDa.js → posthog-integration-6vdi4wRB.js} +16 -16
- package/dist/{posthog-integration-CcJWXPDa.js.map → posthog-integration-6vdi4wRB.js.map} +1 -1
- package/dist/{provisioning-BIuAPRcH.js → provisioning-DK0tS98H.js} +4 -4
- package/dist/{provisioning-BIuAPRcH.js.map → provisioning-DK0tS98H.js.map} +1 -1
- package/dist/{registry-ByrVTIE9.js → registry-DfXVjxsP.js} +5 -5
- package/dist/{registry-ByrVTIE9.js.map → registry-DfXVjxsP.js.map} +1 -1
- package/dist/{security-uSP4HiC0.js → security-BMVH_bjk.js} +3 -3
- package/dist/{security-uSP4HiC0.js.map → security-BMVH_bjk.js.map} +1 -1
- package/dist/{setup-utils-DhmigSLO.js → setup-utils-v9I6PQyP.js} +9 -9
- package/dist/{setup-utils-DhmigSLO.js.map → setup-utils-v9I6PQyP.js.map} +1 -1
- package/dist/{start-tui-DKHnPg5a.js → start-tui-CylEL6i_.js} +19 -19
- package/dist/{start-tui-DKHnPg5a.js.map → start-tui-CylEL6i_.js.map} +1 -1
- package/dist/{steps-BBzIrOMY.js → steps-DQdpexNM.js} +7 -7
- package/dist/{steps-BBzIrOMY.js.map → steps-DQdpexNM.js.map} +1 -1
- package/dist/{store-BV1a-8Wp.js → store-Db0X2V5D.js} +5 -5
- package/dist/{store-BV1a-8Wp.js.map → store-Db0X2V5D.js.map} +1 -1
- package/dist/{subagent-fP1QmYBX.js → subagent-Pk9jRXRf.js} +2 -2
- package/dist/{subagent-fP1QmYBX.js.map → subagent-Pk9jRXRf.js.map} +1 -1
- package/dist/{task-stream-C6s7qUCE.js → task-stream-rC4IEUHC.js} +3 -3
- package/dist/{task-stream-C6s7qUCE.js.map → task-stream-rC4IEUHC.js.map} +1 -1
- package/dist/{tasks-YFkqfEio.js → tasks-B46phMJu.js} +2 -2
- package/dist/{tasks-YFkqfEio.js.map → tasks-B46phMJu.js.map} +1 -1
- package/dist/{telemetry-wOdXbZLp.js → telemetry-BJAHymMq.js} +3 -3
- package/dist/{telemetry-wOdXbZLp.js.map → telemetry-BJAHymMq.js.map} +1 -1
- package/dist/{terminal-IAHPQoAT.js → terminal-BTQSAkC-.js} +13 -13
- package/dist/{terminal-IAHPQoAT.js.map → terminal-BTQSAkC-.js.map} +1 -1
- package/dist/{tools-DdzmiBKF.js → tools-C_m5knXt.js} +4 -4
- package/dist/{tools-DdzmiBKF.js.map → tools-C_m5knXt.js.map} +1 -1
- package/dist/{urls-BR7jQgQp.js → urls-BCmeQMIb.js} +2 -2
- package/dist/{urls-BR7jQgQp.js.map → urls-BCmeQMIb.js.map} +1 -1
- package/dist/{wizard-abort-lbH6n2WG.js → wizard-abort-CMzW4LVM.js} +1 -1
- package/dist/{wizard-abort-bulz-_og.js → wizard-abort-DkngXmxN.js} +4 -4
- package/dist/{wizard-abort-bulz-_og.js.map → wizard-abort-DkngXmxN.js.map} +1 -1
- package/dist/{wizard-session-DWeUEncV.js → wizard-session-BoXAZEOf.js} +1 -1
- package/dist/{wizard-session-DWeUEncV.js.map → wizard-session-BoXAZEOf.js.map} +1 -1
- package/dist/{wizard-session-B1ZM4OBv.js → wizard-session-C8W_6X0j.js} +1 -1
- package/dist/{wizard-tools-CGrE1O_b.js → wizard-tools-C8nVWLeI.js} +72 -17
- package/dist/wizard-tools-C8nVWLeI.js.map +1 -0
- package/package.json +1 -1
- package/dist/wizard-tools-CGrE1O_b.js.map +0 -1
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { S as ANALYTICS_TEAM_TAG, b as ANALYTICS_HOST_URL, r as debug, s as logToFile, x as ANALYTICS_POSTHOG_PUBLIC_PROJECT_WRITE_KEY } from "./debug-
|
|
1
|
+
import { S as ANALYTICS_TEAM_TAG, b as ANALYTICS_HOST_URL, r as debug, s as logToFile, x as ANALYTICS_POSTHOG_PUBLIC_PROJECT_WRITE_KEY } from "./debug-CaRHQrDY.js";
|
|
2
2
|
import { PostHog } from "posthog-node";
|
|
3
3
|
import { v4 } from "uuid";
|
|
4
4
|
//#region src/utils/ci-flag-overrides.ts
|
|
@@ -227,6 +227,6 @@ var Analytics = class {
|
|
|
227
227
|
};
|
|
228
228
|
const analytics = new Analytics();
|
|
229
229
|
//#endregion
|
|
230
|
-
export { ciExcludedTaskTypes as i,
|
|
230
|
+
export { ciExcludedTaskTypes as a, sessionProperties as i, analytics as n, groupsFromUser as r, Analytics as t };
|
|
231
231
|
|
|
232
|
-
//# sourceMappingURL=analytics-
|
|
232
|
+
//# sourceMappingURL=analytics-Z_2kCTpB.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"analytics-CvIK_07d.js","names":["uuidv4"],"sources":["../src/utils/ci-flag-overrides.ts","../src/utils/analytics.ts"],"sourcesContent":["/**\n * CI-only feature-flag overrides.\n *\n * CI must route deterministically: a run that tests the orchestrator arm says\n * so explicitly instead of depending on a live feature flag someone can edit\n * mid-week. The override env var (see the allowlist in `env.ts`) is a JSON\n * object of flag key → value, merged over whatever PostHog returned.\n *\n * The override path exists only in CI builds (`pnpm build:ci`). Published\n * builds inline NODE_ENV as the literal \"production\", the guards collapse,\n * and tsdown strips the rest from the bundle — and the smoke test asserts the\n * env var names are physically absent from production output (which is also\n * why no comment in this file may spell them out), so this can never quietly\n * become a production surface.\n */\nimport { runtimeEnv } from '@env';\nimport { logToFile } from './debug';\n\nexport function applyCiFlagOverrides(\n flags: Record<string, string>,\n): Record<string, string> {\n // Compared inline (not via env.ts's IS_PRODUCTION_BUILD) so tsdown replaces\n // it with a literal right here and the bundler can prove the rest of this\n // function unreachable in production builds. The smoke test enforces that.\n if (process.env.NODE_ENV === 'production') return flags;\n\n const raw = runtimeEnv('WIZARD_CI_FLAG_OVERRIDES');\n if (!raw) return flags;\n\n let overrides: Record<string, unknown>;\n try {\n overrides = JSON.parse(raw) as Record<string, unknown>;\n } catch {\n // A malformed override is a CI misconfiguration. Fail the run loudly\n // rather than silently testing whatever the live flags happen to say.\n throw new Error(\n 'The CI flag-override env var is not valid JSON (expected {\"flag-key\": value, ...}).',\n );\n }\n\n const merged = { ...flags };\n for (const [key, value] of Object.entries(overrides)) {\n merged[key] = String(value);\n }\n logToFile('[flags] CI overrides applied', overrides);\n return merged;\n}\n\n/**\n * Task types excluded from this run. The exclusion env var (see the allowlist\n * in `env.ts`) is a comma-separated list (e.g. `dashboard`), set by the CI\n * harness that owns the policy — the wizard and the served content stay\n * run-mode agnostic. CI-build only, same as the flag overrides: published\n * builds strip this path.\n */\nexport function ciExcludedTaskTypes(): readonly string[] {\n if (process.env.NODE_ENV === 'production') return [];\n\n const raw = runtimeEnv('WIZARD_CI_EXCLUDE_TASKS');\n if (!raw) return [];\n const types = raw\n .split(',')\n .map((t) => t.trim())\n .filter(Boolean);\n if (types.length > 0) logToFile('[flags] CI task exclusions', types);\n return types;\n}\n","import { PostHog } from 'posthog-node';\nimport {\n ANALYTICS_HOST_URL,\n ANALYTICS_POSTHOG_PUBLIC_PROJECT_WRITE_KEY,\n ANALYTICS_TEAM_TAG,\n} from '@lib/constants';\nimport type { WizardSession } from '@lib/wizard-session';\nimport type { ApiUser } from '@lib/api';\nimport { v4 as uuidv4 } from 'uuid';\nimport { IS_PRODUCTION_BUILD } from '@env';\nimport { debug, logToFile } from './debug';\nimport { applyCiFlagOverrides } from './ci-flag-overrides';\n\n/**\n * Extract a standard property bag from the current session.\n * Used by store-level analytics and available for ad-hoc captures.\n */\nexport function sessionProperties(\n session: WizardSession,\n): Record<string, unknown> {\n return {\n integration: session.integration,\n detected_framework: session.detectedFrameworkLabel,\n typescript: session.typescript,\n project_id: session.credentials?.projectId,\n discovered_features: session.discoveredFeatures,\n additional_features: session.additionalFeatureQueue,\n run_phase: session.runPhase,\n };\n}\n\nexport function groupsFromUser(\n user: ApiUser | null,\n host: string,\n): Record<string, string> {\n const groups: Record<string, string> = { instance: host };\n if (!user) return groups;\n\n const organizationId = user.organization?.id;\n if (organizationId) groups.organization = organizationId;\n\n const customerId = user.organization?.customer_id;\n if (customerId) groups.customer = customerId;\n\n const projectUuid = user.team?.uuid;\n if (projectUuid) groups.project = projectUuid;\n\n return groups;\n}\n\nexport class Analytics {\n private client: PostHog;\n private tags: Record<string, string | boolean | number | null | undefined> =\n {};\n private distinctId?: string;\n private anonymousId: string;\n private _runId: string;\n private sessionId: string | null = null;\n private appName = 'wizard';\n private activeFlags: Record<string, string> | null = null;\n private groups: Record<string, string> = {};\n private personProperties: Record<string, string> = {};\n\n constructor() {\n this.client = new PostHog(ANALYTICS_POSTHOG_PUBLIC_PROJECT_WRITE_KEY, {\n host: ANALYTICS_HOST_URL,\n flushAt: 1,\n flushInterval: 0,\n enableExceptionAutocapture: true,\n before_send: (event) => {\n if (!event) return event;\n if (Object.keys(this.groups).length > 0) {\n event.groups = { ...this.groups, ...event.groups };\n }\n // Autocaptured exceptions arrive with a random uuid and\n // `$process_person_profile: false` — reattach the run's identity\n // and tags so they land on the same person as everything else.\n if (event.event === '$exception') {\n event.distinctId = this.distinctId ?? this.anonymousId;\n const { $process_person_profile, ...properties } =\n event.properties ?? {};\n void $process_person_profile;\n event.properties = { ...this.tags, ...properties };\n }\n return event;\n },\n });\n\n this.tags = { $app_name: this.appName };\n // Tag every run with its build type so prod / dev / ci / headless segment\n // cleanly in analytics. tsdown inlines IS_PRODUCTION_BUILD to `true` in\n // published builds and `false` for dev/tsx/test runs. Non-interactive runs\n // upgrade this in runWizardCI: dev `--ci` runs to 'ci', published headless\n // runs to 'headless'.\n this.tags.build = IS_PRODUCTION_BUILD ? 'prod' : 'dev';\n\n this.anonymousId = uuidv4();\n\n // One id per process = one id per wizard run, registered in the tag bag\n // so it rides on every capture, exception, and autocaptured exception\n // (all of which merge `this.tags`). Lets you separate two runs by the\n // same logged-in user, who otherwise share one distinct id. Distinct\n // from `anonymousId`, the pre-login *person* id that gets aliased onto\n // the real user at login. `$session_id` is intentionally not set here —\n // it stays null until OAuth completes (see identifyUser).\n this._runId = uuidv4();\n this.tags.run_id = this._runId;\n\n this.distinctId = undefined;\n }\n\n /** Per-process run id, tagged on every event and gateway trace. */\n get runId(): string {\n return this._runId;\n }\n\n /** Build type for this run ('prod' | 'dev' | 'ci' | 'headless') — the same value tagged on every analytics event. */\n get build(): string {\n return String(this.tags.build ?? 'dev');\n }\n\n /**\n * Associate the run with the logged-in user, once per id. Identifies them\n * (email, name) and records those person properties so events carry them and\n * feature flags can target the individual user — without the email here the\n * wizard only sends `$app_name`, so email-targeted flags never match. Opens\n * the analytics session on first login, then aliases the run's anonymous id\n * onto the identified person so pre-login events merge in.\n */\n identifyUser(user: ApiUser) {\n const distinctId = user.distinct_id;\n if (this.distinctId === distinctId || distinctId === this.anonymousId) {\n return;\n }\n this.distinctId = distinctId;\n // Open the analytics session on first login. Null until here, so\n // pre-OAuth events carry only `run_id`; from now on every event also\n // carries `$session_id` and PostHog groups the authenticated run into a\n // native Session. Stored in the tag bag so it rides on every subsequent\n // capture and exception.\n if (!this.sessionId) {\n this.sessionId = uuidv4();\n this.tags.$session_id = this.sessionId;\n }\n const props: Record<string, string> = {};\n if (user.email) props.email = user.email;\n const name = [user.first_name, user.last_name]\n .filter(Boolean)\n .join(' ')\n .trim();\n if (name) props.name = name;\n this.personProperties = props;\n this.client.identify({ distinctId, properties: { $set: props } });\n this.client.alias({\n distinctId,\n alias: this.anonymousId,\n });\n // The flag snapshot is per identity. Anything evaluated before login (the\n // intro screen reads the tools-menu flag) was anonymous — drop it so the\n // next read re-evaluates as this user.\n this.activeFlags = null;\n }\n\n /** Person properties sent with flag evaluation: app name plus the user's. */\n private flagPersonProperties(): Record<string, string> {\n return { $app_name: this.appName, ...this.personProperties };\n }\n\n setTag(key: string, value: string | boolean | number | null | undefined) {\n this.tags[key] = value;\n }\n\n setGroups(groups: Record<string, string>) {\n this.groups = groups;\n }\n\n captureException(error: Error, properties: Record<string, unknown> = {}) {\n this.client.captureException(error, this.distinctId ?? this.anonymousId, {\n team: ANALYTICS_TEAM_TAG,\n ...this.tags,\n ...properties,\n });\n }\n\n capture(eventName: string, properties?: Record<string, unknown>) {\n this.client.capture({\n distinctId: this.distinctId ?? this.anonymousId,\n event: eventName,\n properties: {\n ...this.tags,\n ...properties,\n },\n });\n }\n\n /**\n * Capture a wizard-specific event. Automatically prepends \"wizard: \" to the event name.\n * All new wizard analytics should use this method instead of capture() directly.\n */\n wizardCapture(eventName: string, properties?: Record<string, unknown>): void {\n this.capture(`wizard: ${eventName}`, properties);\n }\n\n /**\n * Flush pending events without firing the \"setup wizard finished\" terminal\n * event. Use this from CLI error paths that exit before any wizard run\n * starts — `shutdown()` would inflate the run count with a \"finished\" event\n * for a parse error that never actually ran the wizard.\n */\n async flush(): Promise<void> {\n await this.client.shutdown();\n }\n\n async getFeatureFlag(flagKey: string): Promise<string | boolean | undefined> {\n try {\n const distinctId = this.distinctId ?? this.anonymousId;\n return await this.client.getFeatureFlag(flagKey, distinctId, {\n sendFeatureFlagEvents: true,\n personProperties: this.flagPersonProperties(),\n });\n } catch (error) {\n debug('Failed to get feature flag:', flagKey, error);\n return undefined;\n }\n }\n\n /**\n * Evaluate all feature flags for the current user at the start of a run.\n * Result is cached; subsequent calls in the same run return the same map.\n * Returns flag key -> string value (booleans become 'true'/'false').\n */\n async getAllFlagsForWizard(): Promise<Record<string, string>> {\n if (this.activeFlags !== null) {\n return this.activeFlags;\n }\n const out: Record<string, string> = {};\n try {\n const distinctId = this.distinctId ?? this.anonymousId;\n logToFile('[flags] evaluating as', {\n distinctId,\n identified: this.distinctId !== undefined,\n personProperties: this.flagPersonProperties(),\n });\n const result = await this.client.getAllFlagsAndPayloads(distinctId, {\n personProperties: this.flagPersonProperties(),\n });\n const flags = result.featureFlags ?? {};\n for (const [key, value] of Object.entries(flags)) {\n if (value === undefined) continue;\n out[key] = typeof value === 'boolean' ? String(value) : String(value);\n }\n } catch (error) {\n debug('Failed to get all feature flags:', error);\n this.captureException(\n error instanceof Error ? error : new Error(String(error)),\n { step: 'get_all_flags' },\n );\n }\n // Outside the fetch guard on purpose: a malformed CI override must fail\n // the run loudly, and a valid one applies even when the fetch failed —\n // CI routing stays deterministic either way.\n this.activeFlags = applyCiFlagOverrides(out);\n logToFile('[flags] evaluated', this.activeFlags);\n return this.activeFlags;\n }\n\n async shutdown(status: 'success' | 'error' | 'cancelled') {\n if (Object.keys(this.tags).length === 0) {\n return;\n }\n\n this.client.capture({\n distinctId: this.distinctId ?? this.anonymousId,\n event: 'setup wizard finished',\n properties: {\n // Flat for filtering; the nested `tags` snapshot stays for back-compat.\n ...this.tags,\n run_id: this._runId,\n ...(this.sessionId ? { $session_id: this.sessionId } : {}),\n status,\n tags: this.tags,\n },\n });\n\n await this.client.shutdown();\n }\n}\n\nexport const analytics = new Analytics();\n"],"mappings":";;;;AAkBA,SAAgB,qBACd,OACwB;AAImB,QAAO;;;;;;;;;AA+BpD,SAAgB,sBAAyC;AACZ,QAAO,EAAE;;;;;;;;ACvCtD,SAAgB,kBACd,SACyB;AACzB,QAAO;EACL,aAAa,QAAQ;EACrB,oBAAoB,QAAQ;EAC5B,YAAY,QAAQ;EACpB,YAAY,QAAQ,aAAa;EACjC,qBAAqB,QAAQ;EAC7B,qBAAqB,QAAQ;EAC7B,WAAW,QAAQ;EACpB;;AAGH,SAAgB,eACd,MACA,MACwB;CACxB,MAAM,SAAiC,EAAE,UAAU,MAAM;AACzD,KAAI,CAAC,KAAM,QAAO;CAElB,MAAM,iBAAiB,KAAK,cAAc;AAC1C,KAAI,eAAgB,QAAO,eAAe;CAE1C,MAAM,aAAa,KAAK,cAAc;AACtC,KAAI,WAAY,QAAO,WAAW;CAElC,MAAM,cAAc,KAAK,MAAM;AAC/B,KAAI,YAAa,QAAO,UAAU;AAElC,QAAO;;AAGT,IAAa,YAAb,MAAuB;CACrB;CACA,OACE,EAAE;CACJ;CACA;CACA;CACA,YAAmC;CACnC,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AAM,SAHS,MAAM,KAAK,OAAO,uBAAuB,YAAY,EAClE,kBAAkB,KAAK,sBAAsB,EAC9C,CAAC,EACmB,gBAAgB,EAAE;AACvC,QAAK,MAAM,CAAC,KAAK,UAAU,OAAO,QAAQ,MAAM,EAAE;AAChD,QAAI,UAAU,KAAA,EAAW;AACzB,QAAI,OAAO,OAAO,UAAU,YAAY,OAAO,MAAM,GAAG,OAAO,MAAM;;WAEhE,OAAO;AACd,SAAM,oCAAoC,MAAM;AAChD,QAAK,iBACH,iBAAiB,QAAQ,QAAQ,IAAI,MAAM,OAAO,MAAM,CAAC,EACzD,EAAE,MAAM,iBAAiB,CAC1B;;AAKH,OAAK,cAAc,qBAAqB,IAAI;AAC5C,YAAU,qBAAqB,KAAK,YAAY;AAChD,SAAO,KAAK;;CAGd,MAAM,SAAS,QAA2C;AACxD,MAAI,OAAO,KAAK,KAAK,KAAK,CAAC,WAAW,EACpC;AAGF,OAAK,OAAO,QAAQ;GAClB,YAAY,KAAK,cAAc,KAAK;GACpC,OAAO;GACP,YAAY;IAEV,GAAG,KAAK;IACR,QAAQ,KAAK;IACb,GAAI,KAAK,YAAY,EAAE,aAAa,KAAK,WAAW,GAAG,EAAE;IACzD;IACA,MAAM,KAAK;IACZ;GACF,CAAC;AAEF,QAAM,KAAK,OAAO,UAAU;;;AAIhC,MAAa,YAAY,IAAI,WAAW"}
|
|
1
|
+
{"version":3,"file":"analytics-Z_2kCTpB.js","names":["uuidv4"],"sources":["../src/utils/ci-flag-overrides.ts","../src/utils/analytics.ts"],"sourcesContent":["/**\n * CI-only feature-flag overrides.\n *\n * CI must route deterministically: a run that tests the orchestrator arm says\n * so explicitly instead of depending on a live feature flag someone can edit\n * mid-week. The override env var (see the allowlist in `env.ts`) is a JSON\n * object of flag key → value, merged over whatever PostHog returned.\n *\n * The override path exists only in CI builds (`pnpm build:ci`). Published\n * builds inline NODE_ENV as the literal \"production\", the guards collapse,\n * and tsdown strips the rest from the bundle — and the smoke test asserts the\n * env var names are physically absent from production output (which is also\n * why no comment in this file may spell them out), so this can never quietly\n * become a production surface.\n */\nimport { runtimeEnv } from '@env';\nimport { logToFile } from './debug';\n\nexport function applyCiFlagOverrides(\n flags: Record<string, string>,\n): Record<string, string> {\n // Compared inline (not via env.ts's IS_PRODUCTION_BUILD) so tsdown replaces\n // it with a literal right here and the bundler can prove the rest of this\n // function unreachable in production builds. The smoke test enforces that.\n if (process.env.NODE_ENV === 'production') return flags;\n\n const raw = runtimeEnv('WIZARD_CI_FLAG_OVERRIDES');\n if (!raw) return flags;\n\n let overrides: Record<string, unknown>;\n try {\n overrides = JSON.parse(raw) as Record<string, unknown>;\n } catch {\n // A malformed override is a CI misconfiguration. Fail the run loudly\n // rather than silently testing whatever the live flags happen to say.\n throw new Error(\n 'The CI flag-override env var is not valid JSON (expected {\"flag-key\": value, ...}).',\n );\n }\n\n const merged = { ...flags };\n for (const [key, value] of Object.entries(overrides)) {\n merged[key] = String(value);\n }\n logToFile('[flags] CI overrides applied', overrides);\n return merged;\n}\n\n/**\n * Task types excluded from this run. The exclusion env var (see the allowlist\n * in `env.ts`) is a comma-separated list (e.g. `dashboard`), set by the CI\n * harness that owns the policy — the wizard and the served content stay\n * run-mode agnostic. CI-build only, same as the flag overrides: published\n * builds strip this path.\n */\nexport function ciExcludedTaskTypes(): readonly string[] {\n if (process.env.NODE_ENV === 'production') return [];\n\n const raw = runtimeEnv('WIZARD_CI_EXCLUDE_TASKS');\n if (!raw) return [];\n const types = raw\n .split(',')\n .map((t) => t.trim())\n .filter(Boolean);\n if (types.length > 0) logToFile('[flags] CI task exclusions', types);\n return types;\n}\n","import { PostHog } from 'posthog-node';\nimport {\n ANALYTICS_HOST_URL,\n ANALYTICS_POSTHOG_PUBLIC_PROJECT_WRITE_KEY,\n ANALYTICS_TEAM_TAG,\n} from '@lib/constants';\nimport type { WizardSession } from '@lib/wizard-session';\nimport type { ApiUser } from '@lib/api';\nimport { v4 as uuidv4 } from 'uuid';\nimport { IS_PRODUCTION_BUILD } from '@env';\nimport { debug, logToFile } from './debug';\nimport { applyCiFlagOverrides } from './ci-flag-overrides';\n\n/**\n * Extract a standard property bag from the current session.\n * Used by store-level analytics and available for ad-hoc captures.\n */\nexport function sessionProperties(\n session: WizardSession,\n): Record<string, unknown> {\n return {\n integration: session.integration,\n detected_framework: session.detectedFrameworkLabel,\n typescript: session.typescript,\n project_id: session.credentials?.projectId,\n discovered_features: session.discoveredFeatures,\n additional_features: session.additionalFeatureQueue,\n run_phase: session.runPhase,\n };\n}\n\nexport function groupsFromUser(\n user: ApiUser | null,\n host: string,\n): Record<string, string> {\n const groups: Record<string, string> = { instance: host };\n if (!user) return groups;\n\n const organizationId = user.organization?.id;\n if (organizationId) groups.organization = organizationId;\n\n const customerId = user.organization?.customer_id;\n if (customerId) groups.customer = customerId;\n\n const projectUuid = user.team?.uuid;\n if (projectUuid) groups.project = projectUuid;\n\n return groups;\n}\n\nexport class Analytics {\n private client: PostHog;\n private tags: Record<string, string | boolean | number | null | undefined> =\n {};\n private distinctId?: string;\n private anonymousId: string;\n private _runId: string;\n private sessionId: string | null = null;\n private appName = 'wizard';\n private activeFlags: Record<string, string> | null = null;\n private groups: Record<string, string> = {};\n private personProperties: Record<string, string> = {};\n\n constructor() {\n this.client = new PostHog(ANALYTICS_POSTHOG_PUBLIC_PROJECT_WRITE_KEY, {\n host: ANALYTICS_HOST_URL,\n flushAt: 1,\n flushInterval: 0,\n enableExceptionAutocapture: true,\n before_send: (event) => {\n if (!event) return event;\n if (Object.keys(this.groups).length > 0) {\n event.groups = { ...this.groups, ...event.groups };\n }\n // Autocaptured exceptions arrive with a random uuid and\n // `$process_person_profile: false` — reattach the run's identity\n // and tags so they land on the same person as everything else.\n if (event.event === '$exception') {\n event.distinctId = this.distinctId ?? this.anonymousId;\n const { $process_person_profile, ...properties } =\n event.properties ?? {};\n void $process_person_profile;\n event.properties = { ...this.tags, ...properties };\n }\n return event;\n },\n });\n\n this.tags = { $app_name: this.appName };\n // Tag every run with its build type so prod / dev / ci / headless segment\n // cleanly in analytics. tsdown inlines IS_PRODUCTION_BUILD to `true` in\n // published builds and `false` for dev/tsx/test runs. Non-interactive runs\n // upgrade this in runWizardCI: dev `--ci` runs to 'ci', published headless\n // runs to 'headless'.\n this.tags.build = IS_PRODUCTION_BUILD ? 'prod' : 'dev';\n\n this.anonymousId = uuidv4();\n\n // One id per process = one id per wizard run, registered in the tag bag\n // so it rides on every capture, exception, and autocaptured exception\n // (all of which merge `this.tags`). Lets you separate two runs by the\n // same logged-in user, who otherwise share one distinct id. Distinct\n // from `anonymousId`, the pre-login *person* id that gets aliased onto\n // the real user at login. `$session_id` is intentionally not set here —\n // it stays null until OAuth completes (see identifyUser).\n this._runId = uuidv4();\n this.tags.run_id = this._runId;\n\n this.distinctId = undefined;\n }\n\n /** Per-process run id, tagged on every event and gateway trace. */\n get runId(): string {\n return this._runId;\n }\n\n /** Build type for this run ('prod' | 'dev' | 'ci' | 'headless') — the same value tagged on every analytics event. */\n get build(): string {\n return String(this.tags.build ?? 'dev');\n }\n\n /**\n * Associate the run with the logged-in user, once per id. Identifies them\n * (email, name) and records those person properties so events carry them and\n * feature flags can target the individual user — without the email here the\n * wizard only sends `$app_name`, so email-targeted flags never match. Opens\n * the analytics session on first login, then aliases the run's anonymous id\n * onto the identified person so pre-login events merge in.\n */\n identifyUser(user: ApiUser) {\n const distinctId = user.distinct_id;\n if (this.distinctId === distinctId || distinctId === this.anonymousId) {\n return;\n }\n this.distinctId = distinctId;\n // Open the analytics session on first login. Null until here, so\n // pre-OAuth events carry only `run_id`; from now on every event also\n // carries `$session_id` and PostHog groups the authenticated run into a\n // native Session. Stored in the tag bag so it rides on every subsequent\n // capture and exception.\n if (!this.sessionId) {\n this.sessionId = uuidv4();\n this.tags.$session_id = this.sessionId;\n }\n const props: Record<string, string> = {};\n if (user.email) props.email = user.email;\n const name = [user.first_name, user.last_name]\n .filter(Boolean)\n .join(' ')\n .trim();\n if (name) props.name = name;\n this.personProperties = props;\n this.client.identify({ distinctId, properties: { $set: props } });\n this.client.alias({\n distinctId,\n alias: this.anonymousId,\n });\n // The flag snapshot is per identity. Anything evaluated before login (the\n // intro screen reads the tools-menu flag) was anonymous — drop it so the\n // next read re-evaluates as this user.\n this.activeFlags = null;\n }\n\n /** Person properties sent with flag evaluation: app name plus the user's. */\n private flagPersonProperties(): Record<string, string> {\n return { $app_name: this.appName, ...this.personProperties };\n }\n\n setTag(key: string, value: string | boolean | number | null | undefined) {\n this.tags[key] = value;\n }\n\n setGroups(groups: Record<string, string>) {\n this.groups = groups;\n }\n\n captureException(error: Error, properties: Record<string, unknown> = {}) {\n this.client.captureException(error, this.distinctId ?? this.anonymousId, {\n team: ANALYTICS_TEAM_TAG,\n ...this.tags,\n ...properties,\n });\n }\n\n capture(eventName: string, properties?: Record<string, unknown>) {\n this.client.capture({\n distinctId: this.distinctId ?? this.anonymousId,\n event: eventName,\n properties: {\n ...this.tags,\n ...properties,\n },\n });\n }\n\n /**\n * Capture a wizard-specific event. Automatically prepends \"wizard: \" to the event name.\n * All new wizard analytics should use this method instead of capture() directly.\n */\n wizardCapture(eventName: string, properties?: Record<string, unknown>): void {\n this.capture(`wizard: ${eventName}`, properties);\n }\n\n /**\n * Flush pending events without firing the \"setup wizard finished\" terminal\n * event. Use this from CLI error paths that exit before any wizard run\n * starts — `shutdown()` would inflate the run count with a \"finished\" event\n * for a parse error that never actually ran the wizard.\n */\n async flush(): Promise<void> {\n await this.client.shutdown();\n }\n\n async getFeatureFlag(flagKey: string): Promise<string | boolean | undefined> {\n try {\n const distinctId = this.distinctId ?? this.anonymousId;\n return await this.client.getFeatureFlag(flagKey, distinctId, {\n sendFeatureFlagEvents: true,\n personProperties: this.flagPersonProperties(),\n });\n } catch (error) {\n debug('Failed to get feature flag:', flagKey, error);\n return undefined;\n }\n }\n\n /**\n * Evaluate all feature flags for the current user at the start of a run.\n * Result is cached; subsequent calls in the same run return the same map.\n * Returns flag key -> string value (booleans become 'true'/'false').\n */\n async getAllFlagsForWizard(): Promise<Record<string, string>> {\n if (this.activeFlags !== null) {\n return this.activeFlags;\n }\n const out: Record<string, string> = {};\n try {\n const distinctId = this.distinctId ?? this.anonymousId;\n logToFile('[flags] evaluating as', {\n distinctId,\n identified: this.distinctId !== undefined,\n personProperties: this.flagPersonProperties(),\n });\n const result = await this.client.getAllFlagsAndPayloads(distinctId, {\n personProperties: this.flagPersonProperties(),\n });\n const flags = result.featureFlags ?? {};\n for (const [key, value] of Object.entries(flags)) {\n if (value === undefined) continue;\n out[key] = typeof value === 'boolean' ? String(value) : String(value);\n }\n } catch (error) {\n debug('Failed to get all feature flags:', error);\n this.captureException(\n error instanceof Error ? error : new Error(String(error)),\n { step: 'get_all_flags' },\n );\n }\n // Outside the fetch guard on purpose: a malformed CI override must fail\n // the run loudly, and a valid one applies even when the fetch failed —\n // CI routing stays deterministic either way.\n this.activeFlags = applyCiFlagOverrides(out);\n logToFile('[flags] evaluated', this.activeFlags);\n return this.activeFlags;\n }\n\n async shutdown(status: 'success' | 'error' | 'cancelled') {\n if (Object.keys(this.tags).length === 0) {\n return;\n }\n\n this.client.capture({\n distinctId: this.distinctId ?? this.anonymousId,\n event: 'setup wizard finished',\n properties: {\n // Flat for filtering; the nested `tags` snapshot stays for back-compat.\n ...this.tags,\n run_id: this._runId,\n ...(this.sessionId ? { $session_id: this.sessionId } : {}),\n status,\n tags: this.tags,\n },\n });\n\n await this.client.shutdown();\n }\n}\n\nexport const analytics = new Analytics();\n"],"mappings":";;;;AAkBA,SAAgB,qBACd,OACwB;AAImB,QAAO;;;;;;;;;AA+BpD,SAAgB,sBAAyC;AACZ,QAAO,EAAE;;;;;;;;ACvCtD,SAAgB,kBACd,SACyB;AACzB,QAAO;EACL,aAAa,QAAQ;EACrB,oBAAoB,QAAQ;EAC5B,YAAY,QAAQ;EACpB,YAAY,QAAQ,aAAa;EACjC,qBAAqB,QAAQ;EAC7B,qBAAqB,QAAQ;EAC7B,WAAW,QAAQ;EACpB;;AAGH,S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-1,6 +1,6 @@
|
|
|
1
1
|
import { t as __exportAll } from "./rolldown-runtime-B_-DWIq7.js";
|
|
2
|
-
import { ct as WIZARD_USER_AGENT } from "./debug-
|
|
3
|
-
import {
|
|
2
|
+
import { ct as WIZARD_USER_AGENT } from "./debug-CaRHQrDY.js";
|
|
3
|
+
import { n as analytics } from "./analytics-Z_2kCTpB.js";
|
|
4
4
|
import axios from "axios";
|
|
5
5
|
import { z } from "zod";
|
|
6
6
|
//#region src/lib/api.ts
|
|
@@ -170,4 +170,4 @@ function handleApiError(error, operation) {
|
|
|
170
170
|
//#endregion
|
|
171
171
|
export { fetchUserData as a, fetchSlackConnected as i, api_exports as n, handleApiError as o, fetchProjectData as r, ApiError as t };
|
|
172
172
|
|
|
173
|
-
//# sourceMappingURL=api-
|
|
173
|
+
//# sourceMappingURL=api-CwhOyprf.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"api-CyA47qug.js","names":[],"sources":["../src/lib/api.ts"],"sourcesContent":["import axios, { AxiosError } from 'axios';\nimport { z } from 'zod';\nimport { analytics } from '@utils/analytics';\nimport { WIZARD_USER_AGENT } from './constants';\n\n/**\n * User payload from `/api/users/@me/`. Schema typed for the fields the\n * wizard actually reads + passthrough on everything else so the full\n * upstream response rides through to the session for downstream features\n * (account-aware copy, plan-gated flows, org/team metadata, etc.).\n *\n * Top-level uses `.passthrough()` so unknown fields aren't stripped;\n * the few nested objects we care about (team, organization,\n * organizations[]) do the same so their additional fields survive too.\n *\n * Keep `distinct_id` required — analytics depends on it. Everything\n * else added here is nullish so partial responses don't fail parsing.\n */\nexport const ApiUserSchema = z\n .object({\n // Identifiers\n distinct_id: z.string(),\n uuid: z.string().nullish(),\n id: z.number().nullish(),\n\n // Profile\n email: z.string().nullish(),\n first_name: z.string().nullish(),\n last_name: z.string().nullish(),\n date_joined: z.string().nullish(),\n is_email_verified: z.boolean().nullish(),\n is_2fa_enabled: z.boolean().nullish(),\n is_staff: z.boolean().nullish(),\n\n // Preferences\n theme_mode: z.string().nullish(),\n toolbar_mode: z.string().nullish(),\n hide_mcp_hints: z.boolean().nullish(),\n\n // Optional / nullable on the backend — pre-onboarding signup paths\n // return null and older accounts may not have it set. Treat as a\n // hint, never a guarantee.\n role_at_organization: z.string().nullish(),\n\n // Current team + organization (objects from the API, kept typed on\n // the fields the wizard uses; passthrough preserves the rest).\n team: z\n .object({\n id: z.number(),\n uuid: z.string().nullish(),\n organization: z.string().uuid(),\n api_token: z.string().nullish(),\n project_id: z.number().nullish(),\n name: z.string().nullish(),\n timezone: z.string().nullish(),\n })\n .passthrough(),\n organization: z\n .object({\n id: z.string().uuid(),\n name: z.string().nullish(),\n slug: z.string().nullish(),\n membership_level: z.number().nullish(),\n customer_id: z.string().nullish(),\n // Org-level AI consent gate. Signals drops all findings while\n // this is not true. Null on older orgs (pre-2026-05 default\n // flip) — treat null as \"unknown\", not \"off\".\n is_ai_data_processing_approved: z.boolean().nullish(),\n })\n .passthrough(),\n organizations: z.array(\n z\n .object({\n id: z.string().uuid(),\n name: z.string().nullish(),\n membership_level: z.number().nullish(),\n })\n .passthrough(),\n ),\n })\n .passthrough();\n\n/**\n * Single activity log entry the wizard cares about. The PostHog endpoint\n * returns much more — schema kept minimal so changes upstream don't break us.\n *\n * @unused — no current caller after the Phase 6 streaming-agent pivot\n * dropped activity_log polling. Deliberately retained: this is a thin,\n * well-typed wrapper around a stable PostHog endpoint, and we're likely\n * to want it again for a future feature (e.g. \"what changed in your\n * project recently\"). Re-deriving the schema is more work than letting\n * it sit dormant.\n */\nexport const ActivityLogEntrySchema = z\n .object({\n scope: z.string().nullish(),\n activity: z.string().nullish(),\n created_at: z.string().nullish(),\n })\n .passthrough();\n\n/** @unused — see ActivityLogEntrySchema. */\nexport const ActivityLogResponseSchema = z.object({\n results: z.array(ActivityLogEntrySchema),\n});\n\n/** @unused — see ActivityLogEntrySchema. */\nexport type ActivityLogEntry = z.infer<typeof ActivityLogEntrySchema>;\n\nexport const ApiProjectSchema = z.object({\n id: z.number(),\n uuid: z.string().uuid(),\n organization: z.string().uuid(),\n api_token: z.string(),\n name: z.string(),\n // Product opt-ins (TeamSerializer-compat fields on /api/projects/:id).\n // Project-level truth for \"is this product enabled\" — a product can be\n // instrumented from another repo or the snippet, so these settings\n // override repo-local evidence. Null/absent = unknown. Only the\n // opt-ins a signals decision consumes: replay + exception autocapture\n // feed signal-source choices; surveys feeds the surveys-scout tuning.\n session_recording_opt_in: z.boolean().nullish(),\n autocapture_exceptions_opt_in: z.boolean().nullish(),\n surveys_opt_in: z.boolean().nullish(),\n});\n\nexport type ApiUser = z.infer<typeof ApiUserSchema>;\nexport type ApiProject = z.infer<typeof ApiProjectSchema>;\n\nexport class ApiError extends Error {\n constructor(\n message: string,\n public readonly statusCode?: number,\n public readonly endpoint?: string,\n ) {\n super(message);\n this.name = 'ApiError';\n }\n}\n\nexport async function fetchUserData(\n accessToken: string,\n baseUrl: string,\n): Promise<ApiUser> {\n try {\n const response = await axios.get(`${baseUrl}/api/users/@me/`, {\n headers: {\n Authorization: `Bearer ${accessToken}`,\n 'User-Agent': WIZARD_USER_AGENT,\n },\n });\n\n return ApiUserSchema.parse(response.data);\n } catch (error) {\n const apiError = handleApiError(error, 'fetch user data');\n analytics.captureException(apiError, {\n endpoint: '/api/users/@me/',\n baseUrl,\n });\n throw apiError;\n }\n}\n\n/**\n * Best-effort fetch of recent activity log entries. Returns [] on any error\n * so callers can treat absence of results as \"haven't detected anything yet\"\n * rather than a hard failure.\n *\n * @unused — no current caller after the Phase 6 streaming-agent pivot\n * dropped activity_log polling from McpSuggestedPromptsScreen.\n * Deliberately retained for future features that want a soft signal of\n * recent project changes (e.g. dashboards, audit summaries). See the\n * ActivityLogEntrySchema doc comment for the keep-vs-delete rationale.\n */\nexport async function fetchRecentActivity(\n accessToken: string,\n projectId: number,\n baseUrl: string,\n since: Date,\n): Promise<ActivityLogEntry[]> {\n try {\n const response = await axios.get(\n `${baseUrl}/api/projects/${projectId}/activity_log/`,\n {\n params: { limit: 10 },\n headers: {\n Authorization: `Bearer ${accessToken}`,\n 'User-Agent': WIZARD_USER_AGENT,\n },\n // Short timeout — best-effort probe, not a critical path.\n timeout: 4000,\n },\n );\n const parsed = ActivityLogResponseSchema.safeParse(response.data);\n if (!parsed.success) return [];\n const sinceMs = since.getTime();\n return parsed.data.results.filter((entry) => {\n if (!entry.created_at) return false;\n const t = Date.parse(entry.created_at);\n return Number.isFinite(t) && t >= sinceMs;\n });\n } catch {\n return [];\n }\n}\n\nexport async function fetchProjectData(\n accessToken: string,\n projectId: number,\n baseUrl: string,\n): Promise<ApiProject> {\n try {\n const response = await axios.get(`${baseUrl}/api/projects/${projectId}/`, {\n headers: {\n Authorization: `Bearer ${accessToken}`,\n 'User-Agent': WIZARD_USER_AGENT,\n },\n });\n\n return ApiProjectSchema.parse(response.data);\n } catch (error) {\n const apiError = handleApiError(error, 'fetch project data');\n analytics.captureException(apiError, {\n endpoint: `/api/projects/${projectId}/`,\n baseUrl,\n projectId,\n });\n throw apiError;\n }\n}\n\n/** Minimal shape of `/api/projects/:id/integrations/` — we only read `kind`. */\nconst IntegrationsResponseSchema = z.object({\n results: z.array(z.object({ kind: z.string().nullish() }).passthrough()),\n});\n\n/**\n * Check whether the project already has a Slack integration connected.\n * Requires the `integration:read` scope. Throws on failure — callers\n * (including the SlackConnectScreen poll) decide how to degrade and\n * are responsible for capturing the error exactly once.\n */\nexport async function fetchSlackConnected(\n accessToken: string,\n projectId: number,\n baseUrl: string,\n signal?: AbortSignal,\n): Promise<boolean> {\n const response = await axios.get(\n `${baseUrl}/api/projects/${projectId}/integrations/`,\n {\n headers: {\n Authorization: `Bearer ${accessToken}`,\n 'User-Agent': WIZARD_USER_AGENT,\n },\n signal,\n },\n );\n const parsed = IntegrationsResponseSchema.safeParse(response.data);\n if (!parsed.success) return false;\n return parsed.data.results.some((i) => i.kind === 'slack');\n}\n\nexport function handleApiError(error: unknown, operation: string): ApiError {\n if (axios.isAxiosError(error)) {\n const axiosError = error as AxiosError<{ detail?: string }>;\n const status = axiosError.response?.status;\n const detail = axiosError.response?.data?.detail;\n const endpoint = axiosError.config?.url;\n\n if (status === 401) {\n return new ApiError(\n `Authentication failed while trying to ${operation}`,\n status,\n endpoint,\n );\n }\n\n if (status === 403) {\n return new ApiError(\n `Access denied while trying to ${operation}`,\n status,\n endpoint,\n );\n }\n\n if (status === 404) {\n return new ApiError(\n `Resource not found while trying to ${operation}`,\n status,\n endpoint,\n );\n }\n\n const message = detail || `Failed to ${operation}`;\n return new ApiError(message, status, endpoint);\n }\n\n if (error instanceof z.ZodError) {\n return new ApiError(`Invalid response format while trying to ${operation}`);\n }\n\n return new ApiError(\n `Unexpected error while trying to ${operation}: ${\n error instanceof Error ? error.message : 'Unknown error'\n }`,\n );\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAkBA,MAAa,gBAAgB,EAC1B,OAAO;CAEN,aAAa,EAAE,QAAQ;CACvB,MAAM,EAAE,QAAQ,CAAC,SAAS;CAC1B,IAAI,EAAE,QAAQ,CAAC,SAAS;CAGxB,OAAO,EAAE,QAAQ,CAAC,SAAS;CAC3B,YAAY,EAAE,QAAQ,CAAC,SAAS;CAChC,WAAW,EAAE,QAAQ,CAAC,SAAS;CAC/B,aAAa,EAAE,QAAQ,CAAC,SAAS;CACjC,mBAAmB,EAAE,SAAS,CAAC,SAAS;CACxC,gBAAgB,EAAE,SAAS,CAAC,SAAS;CACrC,UAAU,EAAE,SAAS,CAAC,SAAS;CAG/B,YAAY,EAAE,QAAQ,CAAC,SAAS;CAChC,cAAc,EAAE,QAAQ,CAAC,SAAS;CAClC,gBAAgB,EAAE,SAAS,CAAC,SAAS;CAKrC,sBAAsB,EAAE,QAAQ,CAAC,SAAS;CAI1C,MAAM,EACH,OAAO;EACN,IAAI,EAAE,QAAQ;EACd,MAAM,EAAE,QAAQ,CAAC,SAAS;EAC1B,cAAc,EAAE,QAAQ,CAAC,MAAM;EAC/B,WAAW,EAAE,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SAAgB,eAAe,OAAgB,WAA6B;AAC1E,KAAI,MAAM,aAAa,MAAM,EAAE;EAC7B,MAAM,aAAa;EACnB,MAAM,SAAS,WAAW,UAAU;EACpC,MAAM,SAAS,WAAW,UAAU,MAAM;EAC1C,MAAM,WAAW,WAAW,QAAQ;AAEpC,MAAI,WAAW,IACb,QAAO,IAAI,SACT,yCAAyC,aACzC,QACA,SACD;AAGH,MAAI,WAAW,IACb,QAAO,IAAI,SACT,iCAAiC,aACjC,QACA,SACD;AAGH,MAAI,WAAW,IACb,QAAO,IAAI,SACT,sCAAsC,aACtC,QACA,SACD;AAIH,SAAO,IAAI,SADK,UAAU,aAAa,aACV,QAAQ,SAAS;;AAGhD,KAAI,iBAAiB,EAAE,SACrB,QAAO,IAAI,SAAS,2CAA2C,YAAY;AAG7E,QAAO,IAAI,SACT,oCAAoC,UAAU,IAC5C,iBAAiB,QAAQ,MAAM,UAAU,kBAE5C"}
|
|
1
|
+
{"version":3,"file":"api-CwhOyprf.js","names":[],"sources":["../src/lib/api.ts"],"sourcesContent":["import axios, { AxiosError } from 'axios';\nimport { z } from 'zod';\nimport { analytics } from '@utils/analytics';\nimport { WIZARD_USER_AGENT } from './constants';\n\n/**\n * User payload from `/api/users/@me/`. Schema typed for the fields the\n * wizard actually reads + passthrough on everything else so the full\n * upstream response rides through to the session for downstream features\n * (account-aware copy, plan-gated flows, org/team metadata, etc.).\n *\n * Top-level uses `.passthrough()` so unknown fields aren't stripped;\n * the few nested objects we care about (team, organization,\n * organizations[]) do the same so their additional fields survive too.\n *\n * Keep `distinct_id` required — analytics depends on it. Everything\n * else added here is nullish so partial responses don't fail parsing.\n */\nexport const ApiUserSchema = z\n .object({\n // Identifiers\n distinct_id: z.string(),\n uuid: z.string().nullish(),\n id: z.number().nullish(),\n\n // Profile\n email: z.string().nullish(),\n first_name: z.string().nullish(),\n last_name: z.string().nullish(),\n date_joined: z.string().nullish(),\n is_email_verified: z.boolean().nullish(),\n is_2fa_enabled: z.boolean().nullish(),\n is_staff: z.boolean().nullish(),\n\n // Preferences\n theme_mode: z.string().nullish(),\n toolbar_mode: z.string().nullish(),\n hide_mcp_hints: z.boolean().nullish(),\n\n // Optional / nullable on the backend — pre-onboarding signup paths\n // return null and older accounts may not have it set. Treat as a\n // hint, never a guarantee.\n role_at_organization: z.string().nullish(),\n\n // Current team + organization (objects from the API, kept typed on\n // the fields the wizard uses; passthrough preserves the rest).\n team: z\n .object({\n id: z.number(),\n uuid: z.string().nullish(),\n organization: z.string().uuid(),\n api_token: z.string().nullish(),\n project_id: z.number().nullish(),\n name: z.string().nullish(),\n timezone: z.string().nullish(),\n })\n .passthrough(),\n organization: z\n .object({\n id: z.string().uuid(),\n name: z.string().nullish(),\n slug: z.string().nullish(),\n membership_level: z.number().nullish(),\n customer_id: z.string().nullish(),\n // Org-level AI consent gate. Signals drops all findings while\n // this is not true. Null on older orgs (pre-2026-05 default\n // flip) — treat null as \"unknown\", not \"off\".\n is_ai_data_processing_approved: z.boolean().nullish(),\n })\n .passthrough(),\n organizations: z.array(\n z\n .object({\n id: z.string().uuid(),\n name: z.string().nullish(),\n membership_level: z.number().nullish(),\n })\n .passthrough(),\n ),\n })\n .passthrough();\n\n/**\n * Single activity log entry the wizard cares about. The PostHog endpoint\n * returns much more — schema kept minimal so changes upstream don't break us.\n *\n * @unused — no current caller after the Phase 6 streaming-agent pivot\n * dropped activity_log polling. Deliberately retained: this is a thin,\n * well-typed wrapper around a stable PostHog endpoint, and we're likely\n * to want it again for a future feature (e.g. \"what changed in your\n * project recently\"). Re-deriving the schema is more work than letting\n * it sit dormant.\n */\nexport const ActivityLogEntrySchema = z\n .object({\n scope: z.string().nullish(),\n activity: z.string().nullish(),\n created_at: z.string().nullish(),\n })\n .passthrough();\n\n/** @unused — see ActivityLogEntrySchema. */\nexport const ActivityLogResponseSchema = z.object({\n results: z.array(ActivityLogEntrySchema),\n});\n\n/** @unused — see ActivityLogEntrySchema. */\nexport type ActivityLogEntry = z.infer<typeof ActivityLogEntrySchema>;\n\nexport const ApiProjectSchema = z.object({\n id: z.number(),\n uuid: z.string().uuid(),\n organization: z.string().uuid(),\n api_token: z.string(),\n name: z.string(),\n // Product opt-ins (TeamSerializer-compat fields on /api/projects/:id).\n // Project-level truth for \"is this product enabled\" — a product can be\n // instrumented from another repo or the snippet, so these settings\n // override repo-local evidence. Null/absent = unknown. Only the\n // opt-ins a signals decision consumes: replay + exception autocapture\n // feed signal-source choices; surveys feeds the surveys-scout tuning.\n session_recording_opt_in: z.boolean().nullish(),\n autocapture_exceptions_opt_in: z.boolean().nullish(),\n surveys_opt_in: z.boolean().nullish(),\n});\n\nexport type ApiUser = z.infer<typeof ApiUserSchema>;\nexport type ApiProject = z.infer<typeof ApiProjectSchema>;\n\nexport class ApiError extends Error {\n constructor(\n message: string,\n public readonly statusCode?: number,\n public readonly endpoint?: string,\n ) {\n super(message);\n this.name = 'ApiError';\n }\n}\n\nexport async function fetchUserData(\n accessToken: string,\n baseUrl: string,\n): Promise<ApiUser> {\n try {\n const response = await axios.get(`${baseUrl}/api/users/@me/`, {\n headers: {\n Authorization: `Bearer ${accessToken}`,\n 'User-Agent': WIZARD_USER_AGENT,\n },\n });\n\n return ApiUserSchema.parse(response.data);\n } catch (error) {\n const apiError = handleApiError(error, 'fetch user data');\n analytics.captureException(apiError, {\n endpoint: '/api/users/@me/',\n baseUrl,\n });\n throw apiError;\n }\n}\n\n/**\n * Best-effort fetch of recent activity log entries. Returns [] on any error\n * so callers can treat absence of results as \"haven't detected anything yet\"\n * rather than a hard failure.\n *\n * @unused — no current caller after the Phase 6 streaming-agent pivot\n * dropped activity_log polling from McpSuggestedPromptsScreen.\n * Deliberately retained for future features that want a soft signal of\n * recent project changes (e.g. dashboards, audit summaries). See the\n * ActivityLogEntrySchema doc comment for the keep-vs-delete rationale.\n */\nexport async function fetchRecentActivity(\n accessToken: string,\n projectId: number,\n baseUrl: string,\n since: Date,\n): Promise<ActivityLogEntry[]> {\n try {\n const response = await axios.get(\n `${baseUrl}/api/projects/${projectId}/activity_log/`,\n {\n params: { limit: 10 },\n headers: {\n Authorization: `Bearer ${accessToken}`,\n 'User-Agent': WIZARD_USER_AGENT,\n },\n // Short timeout — best-effort probe, not a critical path.\n timeout: 4000,\n },\n );\n const parsed = ActivityLogResponseSchema.safeParse(response.data);\n if (!parsed.success) return [];\n const sinceMs = since.getTime();\n return parsed.data.results.filter((entry) => {\n if (!entry.created_at) return false;\n const t = Date.parse(entry.created_at);\n return Number.isFinite(t) && t >= sinceMs;\n });\n } catch {\n return [];\n }\n}\n\nexport async function fetchProjectData(\n accessToken: string,\n projectId: number,\n baseUrl: string,\n): Promise<ApiProject> {\n try {\n const response = await axios.get(`${baseUrl}/api/projects/${projectId}/`, {\n headers: {\n Authorization: `Bearer ${accessToken}`,\n 'User-Agent': WIZARD_USER_AGENT,\n },\n });\n\n return ApiProjectSchema.parse(response.data);\n } catch (error) {\n const apiError = handleApiError(error, 'fetch project data');\n analytics.captureException(apiError, {\n endpoint: `/api/projects/${projectId}/`,\n baseUrl,\n projectId,\n });\n throw apiError;\n }\n}\n\n/** Minimal shape of `/api/projects/:id/integrations/` — we only read `kind`. */\nconst IntegrationsResponseSchema = z.object({\n results: z.array(z.object({ kind: z.string().nullish() }).passthrough()),\n});\n\n/**\n * Check whether the project already has a Slack integration connected.\n * Requires the `integration:read` scope. Throws on failure — callers\n * (including the SlackConnectScreen poll) decide how to degrade and\n * are responsible for capturing the error exactly once.\n */\nexport async function fetchSlackConnected(\n accessToken: string,\n projectId: number,\n baseUrl: string,\n signal?: AbortSignal,\n): Promise<boolean> {\n const response = await axios.get(\n `${baseUrl}/api/projects/${projectId}/integrations/`,\n {\n headers: {\n Authorization: `Bearer ${accessToken}`,\n 'User-Agent': WIZARD_USER_AGENT,\n },\n signal,\n },\n );\n const parsed = IntegrationsResponseSchema.safeParse(response.data);\n if (!parsed.success) return false;\n return parsed.data.results.some((i) => i.kind === 'slack');\n}\n\nexport function handleApiError(error: unknown, operation: string): ApiError {\n if (axios.isAxiosError(error)) {\n const axiosError = error as AxiosError<{ detail?: string }>;\n const status = axiosError.response?.status;\n const detail = axiosError.response?.data?.detail;\n const endpoint = axiosError.config?.url;\n\n if (status === 401) {\n return new ApiError(\n `Authentication failed while trying to ${operation}`,\n status,\n endpoint,\n );\n }\n\n if (status === 403) {\n return new ApiError(\n `Access denied while trying to ${operation}`,\n status,\n endpoint,\n );\n }\n\n if (status === 404) {\n return new ApiError(\n `Resource not found while trying to ${operation}`,\n status,\n endpoint,\n );\n }\n\n const message = detail || `Failed to ${operation}`;\n return new ApiError(message, status, endpoint);\n }\n\n if (error instanceof z.ZodError) {\n return new ApiError(`Invalid response format while trying to ${operation}`);\n }\n\n return new ApiError(\n `Unexpected error while trying to ${operation}: ${\n error instanceof Error ? error.message : 'Unknown error'\n }`,\n );\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAkBA,MAAa,gBAAgB,EAC1B,OAAO;CAEN,aAAa,EAAE,QAAQ;CACvB,MAAM,EAAE,QAAQ,CAAC,SAAS;CAC1B,IAAI,EAAE,QAAQ,CAAC,SAAS;CAGxB,OAAO,EAAE,QAAQ,CAAC,SAAS;CAC3B,YAAY,EAAE,QAAQ,CAAC,SAAS;CAChC,WAAW,EAAE,QAAQ,CAAC,SAAS;CAC/B,aAAa,EAAE,QAAQ,CAAC,SAAS;CACjC,mBAAmB,EAAE,SAAS,CAAC,SAAS;CACxC,gBAAgB,EAAE,SAAS,CAAC,SAAS;CACrC,UAAU,EAAE,SAAS,CAAC,SAAS;CAG/B,YAAY,EAAE,QAAQ,CAAC,SAAS;CAChC,cAAc,EAAE,QAAQ,CAAC,SAAS;CAClC,gBAAgB,EAAE,SAAS,CAAC,SAAS;CAKrC,sBAAsB,EAAE,QAAQ,CAAC,SAAS;CAI1C,MAAM,EACH,OAAO;EACN,IAAI,EAAE,QAAQ;EACd,MAAM,EAAE,QAAQ,CAAC,SAAS;EAC1B,cAAc,EAAE,QAAQ,CAA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EAAE,SAAS,QAAQ;;AAG5D,SAAgB,eAAe,OAAgB,WAA6B;AAC1E,KAAI,MAAM,aAAa,MAAM,EAAE;EAC7B,MAAM,aAAa;EACnB,MAAM,SAAS,WAAW,UAAU;EACpC,MAAM,SAAS,WAAW,UAAU,MAAM;EAC1C,MAAM,WAAW,WAAW,QAAQ;AAEpC,MAAI,WAAW,IACb,QAAO,IAAI,SACT,yCAAyC,aACzC,QACA,SACD;AAGH,MAAI,WAAW,IACb,QAAO,IAAI,SACT,iCAAiC,aACjC,QACA,SACD;AAGH,MAAI,WAAW,IACb,QAAO,IAAI,SACT,sCAAsC,aACtC,QACA,SACD;AAIH,SAAO,IAAI,SADK,UAAU,aAAa,aACV,QAAQ,SAAS;;AAGhD,KAAI,iBAAiB,EAAE,SACrB,QAAO,IAAI,SAAS,2CAA2C,YAAY;AAG7E,QAAO,IAAI,SACT,oCAAoC,UAAU,IAC5C,iBAAiB,QAAQ,MAAM,UAAU,kBAE5C"}
|
package/dist/bin.js
CHANGED
|
@@ -1,21 +1,21 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import { F as Integration, V as POSTHOG_DOCS_URL, a as getLogFilePath, ct as WIZARD_USER_AGENT, dt as getSkillsBaseUrl, ft as VERSION, h as LoggingUI, m as setUI, p as getUI, r as debug, s as logToFile } from "./debug-
|
|
3
|
-
import {
|
|
4
|
-
import { r as setEntryCommand } from "./telemetry-
|
|
5
|
-
import { n as isUsingTypeScript } from "./setup-utils-
|
|
6
|
-
import { o as getUiHostFromHost } from "./urls-
|
|
7
|
-
import { t as HostResolution } from "./host-resolution-
|
|
8
|
-
import { o as handleApiError } from "./api-
|
|
9
|
-
import "./wizard-session-
|
|
10
|
-
import { r as runCleanups } from "./wizard-abort-
|
|
11
|
-
import { n as isNonInteractiveEnvironment } from "./environment-
|
|
12
|
-
import { n as runAgent, o as authenticate } from "./agent-runner-
|
|
13
|
-
import { C as SETUP_REPORT_FILE, l as recoverOrphanedSettingsBackups, p as AgentSignals } from "./agent-interface-
|
|
14
|
-
import { h as AUDIT_REPORT_FILE, i as fetchSkillMenu, m as AUDIT_CHECKS_KEY, p as AUDIT_CHECKS_FILE, t as WIZARD_TOOL_NAMES } from "./wizard-tools-
|
|
15
|
-
import { i as SPINNER_MESSAGE, t as FRAMEWORK_REGISTRY } from "./registry-
|
|
16
|
-
import { _ as gatherFrameworkContext, a as LINE_CHART_BLOCK, b as parseRequirementsTxt, g as detectProjectsWithAgent, h as HEALTH_CHECK_STEP, i as FUNNEL_BLOCK, m as Icons, n as integrationRunStep, o as PRODUCT_SUITE_BLOCK, p as Colors, r as posthogIntegrationConfig, s as StatusPeekTrigger, u as isClearBlock, v as parsePipfile, y as parsePyprojectToml } from "./posthog-integration-
|
|
17
|
-
import { n as safeReadFile, r as walkProjectFiles, t as IGNORED_DIRS } from "./file-utils-
|
|
18
|
-
import { n as readApiKeyFromEnv } from "./env-api-key-
|
|
2
|
+
import { F as Integration, V as POSTHOG_DOCS_URL, a as getLogFilePath, ct as WIZARD_USER_AGENT, dt as getSkillsBaseUrl, ft as VERSION, h as LoggingUI, m as setUI, p as getUI, r as debug, s as logToFile } from "./debug-CaRHQrDY.js";
|
|
3
|
+
import { n as analytics } from "./analytics-Z_2kCTpB.js";
|
|
4
|
+
import { r as setEntryCommand } from "./telemetry-BJAHymMq.js";
|
|
5
|
+
import { n as isUsingTypeScript } from "./setup-utils-v9I6PQyP.js";
|
|
6
|
+
import { o as getUiHostFromHost } from "./urls-BCmeQMIb.js";
|
|
7
|
+
import { t as HostResolution } from "./host-resolution-C18FwVrM.js";
|
|
8
|
+
import { o as handleApiError } from "./api-CwhOyprf.js";
|
|
9
|
+
import "./wizard-session-BoXAZEOf.js";
|
|
10
|
+
import { r as runCleanups } from "./wizard-abort-DkngXmxN.js";
|
|
11
|
+
import { n as isNonInteractiveEnvironment } from "./environment-knibpXF2.js";
|
|
12
|
+
import { n as runAgent, o as authenticate } from "./agent-runner-DZhaiwD5.js";
|
|
13
|
+
import { C as SETUP_REPORT_FILE, l as recoverOrphanedSettingsBackups, p as AgentSignals } from "./agent-interface-kOuzXg84.js";
|
|
14
|
+
import { h as AUDIT_REPORT_FILE, i as fetchSkillMenu, m as AUDIT_CHECKS_KEY, p as AUDIT_CHECKS_FILE, t as WIZARD_TOOL_NAMES } from "./wizard-tools-C8nVWLeI.js";
|
|
15
|
+
import { i as SPINNER_MESSAGE, t as FRAMEWORK_REGISTRY } from "./registry-DfXVjxsP.js";
|
|
16
|
+
import { _ as gatherFrameworkContext, a as LINE_CHART_BLOCK, b as parseRequirementsTxt, g as detectProjectsWithAgent, h as HEALTH_CHECK_STEP, i as FUNNEL_BLOCK, m as Icons, n as integrationRunStep, o as PRODUCT_SUITE_BLOCK, p as Colors, r as posthogIntegrationConfig, s as StatusPeekTrigger, u as isClearBlock, v as parsePipfile, y as parsePyprojectToml } from "./posthog-integration-6vdi4wRB.js";
|
|
17
|
+
import { n as safeReadFile, r as walkProjectFiles, t as IGNORED_DIRS } from "./file-utils-DWYX_G1o.js";
|
|
18
|
+
import { n as readApiKeyFromEnv } from "./env-api-key-DEl3LJBv.js";
|
|
19
19
|
import { satisfies } from "semver";
|
|
20
20
|
import yargs from "yargs";
|
|
21
21
|
import { hideBin } from "yargs/helpers";
|
|
@@ -243,7 +243,7 @@ function runProvision(argv) {
|
|
|
243
243
|
}
|
|
244
244
|
async function provision({ email, region, name, baseUrl, jsonMode }) {
|
|
245
245
|
try {
|
|
246
|
-
const { provisionNewAccount } = await import("./provisioning-
|
|
246
|
+
const { provisionNewAccount } = await import("./provisioning-DK0tS98H.js").then((n) => n.n);
|
|
247
247
|
if (!jsonMode) getUI().log.info(`Provisioning account for ${email} in ${region}...`);
|
|
248
248
|
emitResult(await provisionNewAccount(email, name, region, { baseUrl }), jsonMode);
|
|
249
249
|
process.exit(0);
|
|
@@ -308,22 +308,22 @@ const basicIntegrationCommand = {
|
|
|
308
308
|
setEntryCommand("integrate");
|
|
309
309
|
(async () => {
|
|
310
310
|
if (isHeadless(argv)) {
|
|
311
|
-
const { runHeadlessInstall } = await import("./ci-install-
|
|
311
|
+
const { runHeadlessInstall } = await import("./ci-install-CWDY86uB.js");
|
|
312
312
|
return runHeadlessInstall(argv);
|
|
313
313
|
}
|
|
314
314
|
if (argv.ci) {
|
|
315
|
-
const { runCIInstall } = await import("./ci-install-
|
|
315
|
+
const { runCIInstall } = await import("./ci-install-CWDY86uB.js");
|
|
316
316
|
return runCIInstall(argv);
|
|
317
317
|
}
|
|
318
318
|
if (isNonInteractiveEnvironment()) {
|
|
319
|
-
const { failNonInteractive } = await import("./non-interactive-
|
|
319
|
+
const { failNonInteractive } = await import("./non-interactive-3_T1d0cj.js");
|
|
320
320
|
return failNonInteractive();
|
|
321
321
|
}
|
|
322
322
|
if (argv.playground) {
|
|
323
|
-
const { runPlayground } = await import("./playground-
|
|
323
|
+
const { runPlayground } = await import("./playground-CbzUpMuN.js");
|
|
324
324
|
return runPlayground();
|
|
325
325
|
}
|
|
326
|
-
const { runInteractive } = await import("./interactive-
|
|
326
|
+
const { runInteractive } = await import("./interactive-46qgS-UA.js");
|
|
327
327
|
runInteractive(argv);
|
|
328
328
|
})();
|
|
329
329
|
}
|
|
@@ -4043,13 +4043,13 @@ const mcpAddCommand = {
|
|
|
4043
4043
|
function runMcpAdd(argv) {
|
|
4044
4044
|
const features = parseFeatures(argv.features);
|
|
4045
4045
|
(async () => {
|
|
4046
|
-
const { readApiKeyFromEnv } = await import("./env-api-key-
|
|
4046
|
+
const { readApiKeyFromEnv } = await import("./env-api-key-DEl3LJBv.js").then((n) => n.t);
|
|
4047
4047
|
const apiKey = argv.apiKey || readApiKeyFromEnv();
|
|
4048
4048
|
const debug = argv.debug;
|
|
4049
4049
|
const localMcp = argv.local;
|
|
4050
4050
|
try {
|
|
4051
|
-
const { startTUI } = await import("./start-tui-
|
|
4052
|
-
const { buildSession } = await import("./wizard-session-
|
|
4051
|
+
const { startTUI } = await import("./start-tui-CylEL6i_.js");
|
|
4052
|
+
const { buildSession } = await import("./wizard-session-C8W_6X0j.js");
|
|
4053
4053
|
const tui = startTUI(VERSION, Program.McpAdd);
|
|
4054
4054
|
tui.store.session = buildSession({
|
|
4055
4055
|
debug,
|
|
@@ -4061,7 +4061,7 @@ function runMcpAdd(argv) {
|
|
|
4061
4061
|
} catch (error) {
|
|
4062
4062
|
if (!isTUIUnavailable(error)) throw error;
|
|
4063
4063
|
setUI(new LoggingUI());
|
|
4064
|
-
const { addMCPServerToClientsStep } = await import("./add-mcp-server-to-clients-
|
|
4064
|
+
const { addMCPServerToClientsStep } = await import("./add-mcp-server-to-clients-BB1_aH5M.js").then((n) => n.r);
|
|
4065
4065
|
await addMCPServerToClientsStep({
|
|
4066
4066
|
local: localMcp,
|
|
4067
4067
|
features,
|
|
@@ -4100,8 +4100,8 @@ function runMcpRemove(argv) {
|
|
|
4100
4100
|
const debug = argv.debug;
|
|
4101
4101
|
const localMcp = argv.local;
|
|
4102
4102
|
try {
|
|
4103
|
-
const { startTUI } = await import("./start-tui-
|
|
4104
|
-
const { buildSession } = await import("./wizard-session-
|
|
4103
|
+
const { startTUI } = await import("./start-tui-CylEL6i_.js");
|
|
4104
|
+
const { buildSession } = await import("./wizard-session-C8W_6X0j.js");
|
|
4105
4105
|
const tui = startTUI(VERSION, Program.McpRemove);
|
|
4106
4106
|
tui.store.session = buildSession({
|
|
4107
4107
|
debug,
|
|
@@ -4110,7 +4110,7 @@ function runMcpRemove(argv) {
|
|
|
4110
4110
|
});
|
|
4111
4111
|
} catch {
|
|
4112
4112
|
setUI(new LoggingUI());
|
|
4113
|
-
const { removeMCPServerFromClientsStep } = await import("./add-mcp-server-to-clients-
|
|
4113
|
+
const { removeMCPServerFromClientsStep } = await import("./add-mcp-server-to-clients-BB1_aH5M.js").then((n) => n.r);
|
|
4114
4114
|
await removeMCPServerFromClientsStep({ local: localMcp });
|
|
4115
4115
|
}
|
|
4116
4116
|
})();
|
|
@@ -4132,8 +4132,8 @@ function runMcpTutorial(argv) {
|
|
|
4132
4132
|
const debug = argv.debug;
|
|
4133
4133
|
const localMcp = argv.local;
|
|
4134
4134
|
try {
|
|
4135
|
-
const { startTUI } = await import("./start-tui-
|
|
4136
|
-
const { buildSession } = await import("./wizard-session-
|
|
4135
|
+
const { startTUI } = await import("./start-tui-CylEL6i_.js");
|
|
4136
|
+
const { buildSession } = await import("./wizard-session-C8W_6X0j.js");
|
|
4137
4137
|
const tui = startTUI(VERSION, Program.McpTutorial);
|
|
4138
4138
|
tui.store.session = buildSession({
|
|
4139
4139
|
debug,
|
|
@@ -4213,10 +4213,10 @@ function runWizard(config, options) {
|
|
|
4213
4213
|
(async () => {
|
|
4214
4214
|
try {
|
|
4215
4215
|
const installDir = options.installDir || process.cwd();
|
|
4216
|
-
const { startTUI } = await import("./start-tui-
|
|
4217
|
-
const { buildSession, RunPhase } = await import("./wizard-session-
|
|
4218
|
-
const { TaskStreamPush } = await import("./task-stream-
|
|
4219
|
-
const { PostHogDestination } = await import("./posthog-
|
|
4216
|
+
const { startTUI } = await import("./start-tui-CylEL6i_.js");
|
|
4217
|
+
const { buildSession, RunPhase } = await import("./wizard-session-C8W_6X0j.js");
|
|
4218
|
+
const { TaskStreamPush } = await import("./task-stream-rC4IEUHC.js");
|
|
4219
|
+
const { PostHogDestination } = await import("./posthog-BESrI6-T.js");
|
|
4220
4220
|
tui = startTUI(WIZARD_VERSION, config.id);
|
|
4221
4221
|
const activeTui = tui;
|
|
4222
4222
|
const session = buildSession({
|
|
@@ -4280,7 +4280,7 @@ function runWizard(config, options) {
|
|
|
4280
4280
|
if (shown(step)) await advanceStep(step, activeTui.store, config);
|
|
4281
4281
|
}
|
|
4282
4282
|
else if (skipAgent) {
|
|
4283
|
-
const { getOrAskForProjectData } = await import("./setup-utils-
|
|
4283
|
+
const { getOrAskForProjectData } = await import("./setup-utils-v9I6PQyP.js").then((n) => n.r);
|
|
4284
4284
|
const { projectApiKey, host, accessToken, projectId } = await getOrAskForProjectData({
|
|
4285
4285
|
signup: session.signup,
|
|
4286
4286
|
ci: session.ci,
|
|
@@ -4382,11 +4382,11 @@ function runNonInteractive(config, options, mode) {
|
|
|
4382
4382
|
analytics.setTag("build", mode);
|
|
4383
4383
|
(async () => {
|
|
4384
4384
|
const path = await import("path");
|
|
4385
|
-
const { buildSession, RunPhase, OutroKind } = await import("./wizard-session-
|
|
4386
|
-
const { readEnvironment } = await import("./environment-
|
|
4387
|
-
const { readApiKeyFromEnv } = await import("./env-api-key-
|
|
4388
|
-
const { configureLogFileFromEnvironment, logToFile } = await import("./debug-
|
|
4389
|
-
const { wizardAbort, WizardError } = await import("./wizard-abort-
|
|
4385
|
+
const { buildSession, RunPhase, OutroKind } = await import("./wizard-session-C8W_6X0j.js");
|
|
4386
|
+
const { readEnvironment } = await import("./environment-knibpXF2.js").then((n) => n.t);
|
|
4387
|
+
const { readApiKeyFromEnv } = await import("./env-api-key-DEl3LJBv.js").then((n) => n.t);
|
|
4388
|
+
const { configureLogFileFromEnvironment, logToFile } = await import("./debug-BmdpjMub.js");
|
|
4389
|
+
const { wizardAbort, WizardError } = await import("./wizard-abort-CMzW4LVM.js");
|
|
4390
4390
|
configureLogFileFromEnvironment();
|
|
4391
4391
|
const env = readEnvironment();
|
|
4392
4392
|
const apiKey = options.apiKey ?? readApiKeyFromEnv() ?? void 0;
|
|
@@ -4417,9 +4417,9 @@ function runNonInteractive(config, options, mode) {
|
|
|
4417
4417
|
let store = null;
|
|
4418
4418
|
let taskStream = null;
|
|
4419
4419
|
if (mode === "headless") {
|
|
4420
|
-
const { WizardStore } = await import("./store-
|
|
4421
|
-
const { HeadlessUI } = await import("./headless-ui-
|
|
4422
|
-
const { TaskStreamPush, PostHogDestination } = await import("./task-stream-
|
|
4420
|
+
const { WizardStore } = await import("./store-Db0X2V5D.js").then((n) => n.n);
|
|
4421
|
+
const { HeadlessUI } = await import("./headless-ui-C4JCi9Zz.js");
|
|
4422
|
+
const { TaskStreamPush, PostHogDestination } = await import("./task-stream-rC4IEUHC.js");
|
|
4423
4423
|
store = new WizardStore(config.id);
|
|
4424
4424
|
store.session = session;
|
|
4425
4425
|
setUI(new HeadlessUI(store));
|
|
@@ -4474,7 +4474,7 @@ function runNonInteractive(config, options, mode) {
|
|
|
4474
4474
|
});
|
|
4475
4475
|
}
|
|
4476
4476
|
}
|
|
4477
|
-
const { runAgent } = await import("./agent-runner-
|
|
4477
|
+
const { runAgent } = await import("./agent-runner-DZhaiwD5.js").then((n) => n.t);
|
|
4478
4478
|
await runAgent(config, session);
|
|
4479
4479
|
await settleStream(RunPhase.Completed);
|
|
4480
4480
|
} catch (error) {
|
|
@@ -5401,7 +5401,7 @@ async function runDoctorCI(options) {
|
|
|
5401
5401
|
getUI().intro("Welcome to the PostHog setup wizard");
|
|
5402
5402
|
getUI().log.info("Running posthog-doctor in CI mode");
|
|
5403
5403
|
try {
|
|
5404
|
-
const { getOrAskForProjectData } = await import("./setup-utils-
|
|
5404
|
+
const { getOrAskForProjectData } = await import("./setup-utils-v9I6PQyP.js").then((n) => n.r);
|
|
5405
5405
|
const { host, accessToken, projectId } = await getOrAskForProjectData({
|
|
5406
5406
|
signup: false,
|
|
5407
5407
|
ci: true,
|
|
@@ -5419,7 +5419,7 @@ async function runDoctorCI(options) {
|
|
|
5419
5419
|
for (const issue of sorted) getUI().log.info(` • [${issue.severity}] ${getKindMeta(issue.kind).title}`);
|
|
5420
5420
|
process.exit(1);
|
|
5421
5421
|
} catch (error) {
|
|
5422
|
-
const { ApiError } = await import("./api-
|
|
5422
|
+
const { ApiError } = await import("./api-CwhOyprf.js").then((n) => n.n);
|
|
5423
5423
|
const message = error instanceof ApiError && error.statusCode === 401 ? "Your PostHog API key is invalid or expired." : error instanceof Error ? error.message : String(error);
|
|
5424
5424
|
getUI().log.error(`Doctor failed: ${message}`);
|
|
5425
5425
|
process.exit(1);
|
|
@@ -5501,8 +5501,8 @@ function runSlackConnect(argv) {
|
|
|
5501
5501
|
(async () => {
|
|
5502
5502
|
const debug = argv.debug;
|
|
5503
5503
|
try {
|
|
5504
|
-
const { startTUI } = await import("./start-tui-
|
|
5505
|
-
const { buildSession } = await import("./wizard-session-
|
|
5504
|
+
const { startTUI } = await import("./start-tui-CylEL6i_.js");
|
|
5505
|
+
const { buildSession } = await import("./wizard-session-C8W_6X0j.js");
|
|
5506
5506
|
const tui = startTUI(VERSION, Program.SlackConnect);
|
|
5507
5507
|
tui.store.session = buildSession({
|
|
5508
5508
|
debug,
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { h as LoggingUI, m as setUI, p as getUI } from "./debug-
|
|
2
|
-
import { t as provisionNewAccount } from "./provisioning-
|
|
3
|
-
import { r as posthogIntegrationConfig } from "./posthog-integration-
|
|
1
|
+
import { h as LoggingUI, m as setUI, p as getUI } from "./debug-CaRHQrDY.js";
|
|
2
|
+
import { t as provisionNewAccount } from "./provisioning-DK0tS98H.js";
|
|
3
|
+
import { r as posthogIntegrationConfig } from "./posthog-integration-6vdi4wRB.js";
|
|
4
4
|
import { c as runWizardCI, s as runWizardHeadless } from "./bin.js";
|
|
5
5
|
//#region src/commands/basic-integration/ci-install.ts
|
|
6
6
|
/**
|
|
@@ -110,4 +110,4 @@ async function provisionForSignup(options) {
|
|
|
110
110
|
//#endregion
|
|
111
111
|
export { runCIInstall, runHeadlessInstall };
|
|
112
112
|
|
|
113
|
-
//# sourceMappingURL=ci-install-
|
|
113
|
+
//# sourceMappingURL=ci-install-CWDY86uB.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ci-install-
|
|
1
|
+
{"version":3,"file":"ci-install-CWDY86uB.js","names":[],"sources":["../src/commands/basic-integration/ci-install.ts"],"sourcesContent":["import type { Arguments } from 'yargs';\nimport { getUI, setUI } from '@ui';\nimport { LoggingUI } from '@ui/logging-ui';\nimport { runWizardCI, runWizardHeadless } from '@lib/runners';\nimport type { NonInteractiveMode } from '@lib/runners';\nimport { provisionNewAccount } from '@utils/provisioning';\nimport { posthogIntegrationConfig } from '@lib/programs/posthog-integration/index';\n\ntype Options = Arguments & {\n region?: string;\n baseUrl?: string;\n installDir?: string;\n apiKey?: string;\n signup?: boolean;\n email?: string;\n name?: string;\n projectId?: string;\n};\n\n/**\n * CI-mode install entry point (`--ci`, dev/test builds). Thin shell over the\n * shared non-interactive install — see `runNonInteractiveInstall`.\n */\nexport function runCIInstall(argv: Arguments): void {\n runNonInteractiveInstall(argv, 'ci');\n}\n\n/**\n * Headless install entry point (the experimental published-build run path; see\n * @lib/headless-mode). Thin shell over the shared non-interactive install.\n * Today it behaves exactly like `runCIInstall`; it is a separate function so\n * headless can diverge later (auth, prompts, …) without touching the CI path.\n */\nexport function runHeadlessInstall(argv: Arguments): void {\n runNonInteractiveInstall(argv, 'headless');\n}\n\n/**\n * Non-interactive install shared by CI and headless. Validates signup flags,\n * optionally provisions an account, then installs. `mode` only changes\n * user-facing labels, which api-key prefixes are accepted, and which runner is\n * invoked — the install itself is identical (see runNonInteractive).\n */\nfunction runNonInteractiveInstall(\n argv: Arguments,\n mode: NonInteractiveMode,\n): void {\n const options = { ...argv } as Options;\n const headless = mode === 'headless';\n const label = headless ? 'Headless' : 'CI';\n const runWizard = headless ? runWizardHeadless : runWizardCI;\n\n // Base validation (region/install-dir/api-key) is owned by the runner.\n // This layer only adds the signup branch on top.\n if (!options.apiKey && !options.signup) {\n const keyHint = headless\n ? 'personal API key phx_xxx or pha_ OAuth access token'\n : 'personal API key phx_xxx';\n return failCI(\n `${label} mode requires --api-key (${keyHint}). ` +\n 'To create a new account instead, use --signup --email you@example.com.',\n );\n }\n if (!options.apiKey && options.signup && !options.email) {\n return failCI(\n `${label} --signup requires --email to create a new account.`,\n );\n }\n warnOnUnexpectedKeyPrefix(options.apiKey, headless);\n\n void (async () => {\n if (!options.apiKey && options.signup) {\n // Fail before the irreversible provisioning step rather than after it.\n if (!options.installDir) {\n return failCI(\n `${label} mode requires --install-dir (directory to install in)`,\n );\n }\n const provisioned = await provisionForSignup(options);\n options.apiKey = provisioned.personalApiKey;\n if (options.projectId == null) options.projectId = provisioned.projectId;\n }\n runWizard(posthogIntegrationConfig, options);\n })().catch(() => {\n process.exit(1);\n });\n}\n\nfunction failCI(message: string): void {\n setUI(new LoggingUI());\n getUI().intro('PostHog Wizard');\n getUI().log.error(message);\n process.exit(1);\n}\n\n/**\n * Decide whether to warn about an unexpected `--api-key` prefix, and with what\n * message. Returns `null` when the key is acceptable for the mode.\n *\n * This is the one behavioral fork between `--ci` and headless mode: the LLM\n * Gateway accepts a personal API key (`phx_`) in either mode, but in headless\n * a `pha_` OAuth access token is *also* first-class — PostHog mints one under\n * the wizard's own OAuth application for cloud runs and passes it as the\n * api-key. Outside headless that token is unexpected and still warns.\n *\n * Extracted as a pure predicate so the fork can be unit-tested without a UI.\n */\nexport function keyPrefixWarning(\n apiKey: string | undefined,\n headless: boolean,\n): string | null {\n if (!apiKey || apiKey.startsWith('phx_')) return null;\n if (headless && apiKey.startsWith('pha_')) return null;\n const prefix = apiKey.slice(0, 4);\n const hint =\n prefix === 'pha_'\n ? ' (pha_ is an OAuth access token — CI mode expects a personal API key)'\n : prefix === 'phc_'\n ? ' (phc_ is a project/client key — expected a personal API key)'\n : '';\n return `--api-key does not start with \"phx_\"${hint}. Continuing anyway, but the LLM Gateway may reject it with a 401.`;\n}\n\nfunction warnOnUnexpectedKeyPrefix(\n apiKey: string | undefined,\n headless: boolean,\n): void {\n const message = keyPrefixWarning(apiKey, headless);\n if (!message) return;\n setUI(new LoggingUI());\n getUI().intro('PostHog Wizard');\n getUI().log.warn(message);\n}\n\n/**\n * Provision a new account and return its credentials. Throws on any failure\n * (after logging a user-facing message); the caller's `.catch` turns that\n * into a non-zero exit. The return type carries no failure sentinel.\n */\nasync function provisionForSignup(\n options: Options,\n): Promise<{ personalApiKey: string; projectId: string }> {\n setUI(new LoggingUI());\n getUI().intro('PostHog Wizard');\n const signupRegion = ((options.region as string) || 'us').toUpperCase() as\n | 'US'\n | 'EU';\n getUI().log.info(\n `Provisioning new PostHog account for ${String(\n options.email,\n )} in ${signupRegion}...`,\n );\n\n let result;\n try {\n result = await provisionNewAccount(\n options.email as string,\n options.name ?? '',\n signupRegion,\n { baseUrl: options.baseUrl },\n );\n } catch (error) {\n const msg = error instanceof Error ? error.message : String(error);\n getUI().log.error(`Provisioning failed: ${msg}`);\n throw error;\n }\n\n if (!result.personalApiKey) {\n getUI().log.error(\n 'Provisioning succeeded but no personal API key was returned — cannot continue install.',\n );\n throw new Error('provisioning returned no personal API key');\n }\n\n getUI().log.success('Account ready.');\n getUI().log.info(` Project API Key: ${result.projectApiKey}`);\n getUI().log.info(` Personal API Key: ${result.personalApiKey}`);\n getUI().log.info(` Host: ${result.host}`);\n return {\n personalApiKey: result.personalApiKey,\n projectId: result.projectId,\n };\n}\n"],"mappings":";;;;;;;;;AAuBA,SAAgB,aAAa,MAAuB;AAClD,0BAAyB,MAAM,KAAK;;;;;;;;AAStC,SAAgB,mBAAmB,MAAuB;AACxD,0BAAyB,MAAM,WAAW;;;;;;;;AAS5C,SAAS,yBACP,MACA,MACM;CACN,MAAM,UAAU,EAAE,GAAG,MAAM;CAC3B,MAAM,WAAW,SAAS;CAC1B,MAAM,QAAQ,WAAW,aAAa;CACtC,MAAM,YAAY,WAAW,oBAAoB;AAIjD,KAAI,CAAC,QAAQ,UAAU,CAAC,QAAQ,OAI9B,QAAO,OACL,GAAG,MAAM,4BAJK,WACZ,wDACA,2BAE2C,2EAE9C;AAEH,KAAI,CAAC,QAAQ,UAAU,QAAQ,UAAU,CAAC,QAAQ,MAChD,QAAO,OACL,GAAG,MAAM,qDACV;AAEH,2BAA0B,QAAQ,QAAQ,SAAS;AAEnD,EAAM,YAAY;AAChB,MAAI,CAAC,QAAQ,UAAU,QAAQ,QAAQ;AAErC,OAAI,CAAC,QAAQ,WACX,QAAO,OACL,GAAG,MAAM,wDACV;GAEH,MAAM,cAAc,MAAM,mBAAmB,QAAQ;AACrD,WAAQ,SAAS,YAAY;AAC7B,OAAI,QAAQ,aAAa,KA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ACD,QAAM,IAAI,MAAM,4CAA4C;;AAG9D,QAAO,CAAC,IAAI,QAAQ,iBAAiB;AACrC,QAAO,CAAC,IAAI,KAAK,uBAAuB,OAAO,gBAAgB;AAC/D,QAAO,CAAC,IAAI,KAAK,uBAAuB,OAAO,iBAAiB;AAChE,QAAO,CAAC,IAAI,KAAK,uBAAuB,OAAO,OAAO;AACtD,QAAO;EACL,gBAAgB,OAAO;EACvB,WAAW,OAAO;EACnB"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { n as configureLogFileFromEnvironment, s as logToFile } from "./debug-
|
|
1
|
+
import { n as configureLogFileFromEnvironment, s as logToFile } from "./debug-CaRHQrDY.js";
|
|
2
2
|
export { configureLogFileFromEnvironment, logToFile };
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import "./wizard-ui-WZ48rUgr.js";
|
|
2
|
-
import { appendFileSync } from "fs";
|
|
2
|
+
import { appendFileSync, mkdirSync } from "fs";
|
|
3
3
|
import path from "path";
|
|
4
4
|
import { inspect } from "node:util";
|
|
5
5
|
import { tmpdir } from "node:os";
|
|
@@ -28,7 +28,7 @@ function runtimeEnv(key) {
|
|
|
28
28
|
}
|
|
29
29
|
//#endregion
|
|
30
30
|
//#region src/lib/version.ts
|
|
31
|
-
const VERSION = "2.38.
|
|
31
|
+
const VERSION = "2.38.1";
|
|
32
32
|
//#endregion
|
|
33
33
|
//#region src/lib/constants.ts
|
|
34
34
|
/**
|
|
@@ -911,26 +911,52 @@ function getLogFilePath() {
|
|
|
911
911
|
return logFilePath;
|
|
912
912
|
}
|
|
913
913
|
function configureLogFile(opts) {
|
|
914
|
-
if (opts.path !== void 0)
|
|
914
|
+
if (opts.path !== void 0) {
|
|
915
|
+
logFilePath = opts.path;
|
|
916
|
+
ensuredLogDir = false;
|
|
917
|
+
}
|
|
915
918
|
if (opts.enabled !== void 0) fileLoggingEnabled = opts.enabled;
|
|
916
919
|
}
|
|
920
|
+
let ensuredLogDir = false;
|
|
921
|
+
let reportedLogFailure = false;
|
|
922
|
+
function reportLogFailureOnce(err) {
|
|
923
|
+
if (reportedLogFailure) return;
|
|
924
|
+
reportedLogFailure = true;
|
|
925
|
+
import("./analytics-B1SC2jaf.js").then(({ analytics }) => analytics.captureException(err instanceof Error ? err : new Error(String(err)), {
|
|
926
|
+
source: "log-file-write",
|
|
927
|
+
log_path: logFilePath,
|
|
928
|
+
platform: process.platform
|
|
929
|
+
})).catch(() => {});
|
|
930
|
+
}
|
|
931
|
+
function appendLine(text) {
|
|
932
|
+
try {
|
|
933
|
+
appendFileSync(logFilePath, text);
|
|
934
|
+
} catch (err) {
|
|
935
|
+
if (ensuredLogDir) {
|
|
936
|
+
reportLogFailureOnce(err);
|
|
937
|
+
return;
|
|
938
|
+
}
|
|
939
|
+
ensuredLogDir = true;
|
|
940
|
+
try {
|
|
941
|
+
mkdirSync(path.dirname(logFilePath), { recursive: true });
|
|
942
|
+
appendFileSync(logFilePath, text);
|
|
943
|
+
} catch (retryErr) {
|
|
944
|
+
reportLogFailureOnce(retryErr);
|
|
945
|
+
}
|
|
946
|
+
}
|
|
947
|
+
}
|
|
917
948
|
function configureLogFileFromEnvironment() {
|
|
918
949
|
const dir = runtimeEnv("POSTHOG_WIZARD_LOG_DIR");
|
|
919
950
|
if (dir) configureLogFile({ path: path.join(dir, "posthog-wizard.log") });
|
|
920
951
|
}
|
|
921
952
|
function initLogFile() {
|
|
922
953
|
if (!fileLoggingEnabled) return;
|
|
923
|
-
|
|
924
|
-
|
|
925
|
-
appendFileSync(logFilePath, `\n${divider}\nPostHog Wizard Run: ${(/* @__PURE__ */ new Date()).toISOString()}\n${divider}\n`);
|
|
926
|
-
} catch {}
|
|
954
|
+
const divider = "=".repeat(60);
|
|
955
|
+
appendLine(`\n${divider}\nPostHog Wizard Run: ${(/* @__PURE__ */ new Date()).toISOString()}\n${divider}\n`);
|
|
927
956
|
}
|
|
928
957
|
function logToFile(...args) {
|
|
929
958
|
if (!fileLoggingEnabled) return;
|
|
930
|
-
|
|
931
|
-
const ts = (/* @__PURE__ */ new Date()).toISOString();
|
|
932
|
-
appendFileSync(logFilePath, `[${ts}] ${renderLine(args)}\n`);
|
|
933
|
-
} catch {}
|
|
959
|
+
appendLine(`[${(/* @__PURE__ */ new Date()).toISOString()}] ${renderLine(args)}\n`);
|
|
934
960
|
}
|
|
935
961
|
function debug(...args) {
|
|
936
962
|
if (!consoleLoggingEnabled) return;
|
|
@@ -942,4 +968,4 @@ function enableDebugLogs() {
|
|
|
942
968
|
//#endregion
|
|
943
969
|
export { WIZARD_CONTACT_EMAIL as $, GPT5_MINI_MODEL as A, POSTHOG_DEV_CLIENT_ID as B, CONTEXT_MILL_RELEASES_URL as C, DETECTION_TIMEOUT_MS as D, DEFAULT_HOST_URL as E, Integration as F, POSTHOG_PROPERTY_HEADER_PREFIX as G, POSTHOG_FLAG_HEADER_PREFIX as H, OAUTH_PORTS as I, POSTHOG_TERMS_URL as J, POSTHOG_PROXY_CLIENT_ID as K, OAUTH_TIMEOUT_MS as L, HAIKU_MODEL as M, Harness as N, DUMMY_PROJECT_API_KEY as O, ISSUES_URL as P, Sequence as Q, OPUS_MODEL as R, ANALYTICS_TEAM_TAG as S, DEFAULT_AGENT_MODEL as T, POSTHOG_ORG_AI_SETTINGS_URL as U, POSTHOG_DOCS_URL as V, POSTHOG_PRIVACY_URL as W, REMOTE_SKILLS_BASE_URL as X, POSTHOG_US_CLIENT_ID as Y, SONNET_5_MODEL as Z, SIGNUP_WIZARD_READINESS_CONFIG as _, getLogFilePath as a, WIZARD_PROVISIONING_SCOPES as at, ANALYTICS_HOST_URL as b, WIZARD_BENCHMARK_FILE as c, WIZARD_USER_AGENT as ct, relativeToInstallDir as d, getSkillsBaseUrl as dt, WIZARD_INTERACTION_EVENT_NAME as et, skillTmpPath as f, VERSION as ft, SERVICE_LABELS as g, LoggingUI as h, enableDebugLogs as i, WIZARD_PI_MODEL_FLAG_KEY as it, GPT5_MODEL as j, GPT5_4_MODEL as k, WIZARD_LOG_FILE as l, WIZARD_USE_PI_HARNESS_FLAG_KEY as lt, setUI as m, runtimeEnv as mt, configureLogFileFromEnvironment as n, WIZARD_ORCHESTRATOR_FLAG_KEY as nt, initLogFile as o, WIZARD_REMARK_EVENT_NAME as ot, getUI as p, NODE_ENV as pt, POSTHOG_STATUS_PAGE_URL as q, debug as r, WIZARD_PI_EFFORT_FLAG_KEY as rt, logToFile as s, WIZARD_TOOLS_MENU_FLAG_KEY as st, configureLogFile as t, WIZARD_OAUTH_SCOPES as tt, WIZARD_YARA_REPORT_FILE as u, WIZARD_WARLOCK_DISABLED_FLAG_KEY as ut, evaluateWizardReadiness as v, CONTEXT_MILL_URL as w, ANALYTICS_POSTHOG_PUBLIC_PROJECT_WRITE_KEY as x, getBlockingServiceKeys as y, POSTHOG_APP_URL as z };
|
|
944
970
|
|
|
945
|
-
//# sourceMappingURL=debug-
|
|
971
|
+
//# sourceMappingURL=debug-CaRHQrDY.js.map
|