Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 0 additions & 2 deletions .env.development
Original file line number Diff line number Diff line change
Expand Up @@ -76,5 +76,3 @@ SOURCEBOT_TELEMETRY_DISABLED=true # Disables telemetry collection
# CONFIG_MAX_REPOS_NO_TOKEN=
NODE_ENV=development
# SOURCEBOT_TENANCY_MODE=single

# NEXT_PUBLIC_SOURCEBOT_CLOUD_ENVIRONMENT=
87 changes: 0 additions & 87 deletions .github/workflows/_gcp-deploy.yml

This file was deleted.

20 changes: 0 additions & 20 deletions .github/workflows/deploy-demo.yml

This file was deleted.

3 changes: 0 additions & 3 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
# @see: https://docs.docker.com/build/building/variables/#scoping

ARG NEXT_PUBLIC_SENTRY_ENVIRONMENT
ARG NEXT_PUBLIC_SOURCEBOT_CLOUD_ENVIRONMENT
ARG NEXT_PUBLIC_SENTRY_WEBAPP_DSN
ARG NEXT_PUBLIC_SENTRY_BACKEND_DSN
ARG NEXT_PUBLIC_LANGFUSE_PUBLIC_KEY
Expand Down Expand Up @@ -52,8 +51,6 @@ ENV SKIP_ENV_VALIDATION=1
# -----------
ARG NEXT_PUBLIC_SENTRY_ENVIRONMENT
ENV NEXT_PUBLIC_SENTRY_ENVIRONMENT=$NEXT_PUBLIC_SENTRY_ENVIRONMENT
ARG NEXT_PUBLIC_SOURCEBOT_CLOUD_ENVIRONMENT
ENV NEXT_PUBLIC_SOURCEBOT_CLOUD_ENVIRONMENT=$NEXT_PUBLIC_SOURCEBOT_CLOUD_ENVIRONMENT
ARG NEXT_PUBLIC_SENTRY_WEBAPP_DSN
ENV NEXT_PUBLIC_SENTRY_WEBAPP_DSN=$NEXT_PUBLIC_SENTRY_WEBAPP_DSN
ARG NEXT_PUBLIC_LANGFUSE_PUBLIC_KEY
Expand Down
7 changes: 0 additions & 7 deletions packages/shared/src/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,6 @@ import { ConfigSettings } from "./types.js";

export const SOURCEBOT_SUPPORT_EMAIL = 'team@sourcebot.dev';

export const SOURCEBOT_CLOUD_ENVIRONMENT = [
"dev",
"demo",
"staging",
"prod",
] as const;

export const SOURCEBOT_UNLIMITED_SEATS = -1;

/**
Expand Down
23 changes: 0 additions & 23 deletions packages/shared/src/entitlements.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ import { base64Decode } from "./utils.js";
import { z } from "zod";
import { createLogger } from "./logger.js";
import { env } from "./env.server.js";
import { env as clientEnv } from "./env.client.js";
import { SOURCEBOT_SUPPORT_EMAIL, SOURCEBOT_UNLIMITED_SEATS } from "./constants.js";
import { verifySignature } from "./crypto.js";

Expand All @@ -23,8 +22,6 @@ type LicenseKeyPayload = z.infer<typeof eeLicenseKeyPayloadSchema>;
// eslint-disable-next-line @typescript-eslint/no-unused-vars
const planLabels = {
oss: "OSS",
"cloud:team": "Team",
"cloud:demo": "Demo",
"self-hosted:enterprise": "Enterprise (Self-Hosted)",
"self-hosted:enterprise-unlimited": "Enterprise (Self-Hosted) Unlimited",
} as const;
Expand All @@ -49,12 +46,6 @@ const entitlementsByPlan: Record<Plan, Entitlement[]> = {
oss: [
"anonymous-access"
],
"cloud:team": [
"billing",
"multi-tenancy",
"sso",
"code-nav"
],
"self-hosted:enterprise": [
"search-contexts",
"sso",
Expand All @@ -74,12 +65,6 @@ const entitlementsByPlan: Record<Plan, Entitlement[]> = {
"github-app",
"anonymous-access"
],
// Special entitlement for https://demo.sourcebot.dev
"cloud:demo": [
"anonymous-access",
"code-nav",
"search-contexts"
],
} as const;


Expand Down Expand Up @@ -118,14 +103,6 @@ export const getLicenseKey = (): LicenseKeyPayload | null => {
}

export const getPlan = (): Plan => {
if (clientEnv.NEXT_PUBLIC_SOURCEBOT_CLOUD_ENVIRONMENT) {
if (clientEnv.NEXT_PUBLIC_SOURCEBOT_CLOUD_ENVIRONMENT === "demo") {
return "cloud:demo";
}

return "cloud:team";
}

const licenseKey = getLicenseKey();
if (licenseKey) {
const expiryDate = new Date(licenseKey.expiryDate);
Expand Down
3 changes: 0 additions & 3 deletions packages/shared/src/env.client.ts
Original file line number Diff line number Diff line change
@@ -1,18 +1,15 @@
import { createEnv } from "@t3-oss/env-core";
import { z } from "zod";
import { SOURCEBOT_CLOUD_ENVIRONMENT } from "./constants.js";

export const env = createEnv({
clientPrefix: "NEXT_PUBLIC_",
client: {
NEXT_PUBLIC_SOURCEBOT_CLOUD_ENVIRONMENT: z.enum(SOURCEBOT_CLOUD_ENVIRONMENT).optional(),
NEXT_PUBLIC_SENTRY_BACKEND_DSN: z.string().optional(),
NEXT_PUBLIC_SENTRY_ENVIRONMENT: z.string().optional(),
NEXT_PUBLIC_LANGFUSE_PUBLIC_KEY: z.string().optional(),
NEXT_PUBLIC_LANGFUSE_BASE_URL: z.string().optional()
},
runtimeEnvStrict: {
NEXT_PUBLIC_SOURCEBOT_CLOUD_ENVIRONMENT: process.env.NEXT_PUBLIC_SOURCEBOT_CLOUD_ENVIRONMENT,
NEXT_PUBLIC_SENTRY_BACKEND_DSN: process.env.NEXT_PUBLIC_SENTRY_BACKEND_DSN,
NEXT_PUBLIC_SENTRY_ENVIRONMENT: process.env.NEXT_PUBLIC_SENTRY_ENVIRONMENT,
NEXT_PUBLIC_LANGFUSE_PUBLIC_KEY: process.env.NEXT_PUBLIC_LANGFUSE_PUBLIC_KEY,
Expand Down
17 changes: 16 additions & 1 deletion packages/shared/src/env.server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,6 @@ export const env = createEnv({
// Misc
CONFIG_MAX_REPOS_NO_TOKEN: numberSchema.default(Number.MAX_SAFE_INTEGER),
NODE_ENV: z.enum(["development", "test", "production"]),
SOURCEBOT_TELEMETRY_DISABLED: booleanSchema.default('false'),
// @note: this is also declared in the Dockerfile.
POSTHOG_PAPIK: z.string().default("phc_lLPuFFi5LH6c94eFJcqvYVFwiJffVcV6HD8U4a1OnRW"),

Expand Down Expand Up @@ -274,6 +273,22 @@ export const env = createEnv({
// A comma separated list of glob patterns that shwould always be indexed regardless of their size.
ALWAYS_INDEX_FILE_PATTERNS: z.string().optional(),

/**
* Configure whether to send telemetry events.
* By default, all events are anonymized and do not contain PII data,
* unless SOURCEBOT_TELEMETRY_PII_COLLECTION_ENABLED is set to true.
*/
SOURCEBOT_TELEMETRY_DISABLED: booleanSchema.default('false'),

/**
* Configure whether to collect PII data in telemetry events.
* If SOURCEBOT_TELEMETRY_DISABLED is true, this setting is
* ignored.
*/
SOURCEBOT_TELEMETRY_PII_COLLECTION_ENABLED: booleanSchema.default('false'),

//// DEPRECATED ////

/**
* @deprecated This setting is deprecated. Please use the `identityProviders` section of the config file instead.
*/
Expand Down
14 changes: 0 additions & 14 deletions packages/web/src/app/[domain]/components/repositoryCarousel.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -85,20 +85,6 @@ export function RepositoryCarousel({
))}
</CarouselContent>
</Carousel>
{process.env.NEXT_PUBLIC_SOURCEBOT_CLOUD_ENVIRONMENT === "demo" && (
<p className="text-sm text-muted-foreground text-center">
Interested in using Sourcebot on your code? Check out our{' '}
<a
href="https://docs.sourcebot.dev/docs/overview"
target="_blank"
rel="noopener noreferrer"
className="text-primary hover:underline"
onClick={() => captureEvent('wa_demo_docs_link_pressed', {})}
>
docs
</a>
</p>
)}
</div>
)
}
Expand Down
10 changes: 4 additions & 6 deletions packages/web/src/app/[domain]/settings/layout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -115,12 +115,10 @@ export default async function SettingsLayout(
href: `/${domain}/settings/permission-syncing`,
}
] : []),
...(env.NEXT_PUBLIC_SOURCEBOT_CLOUD_ENVIRONMENT === undefined ? [
{
title: "License",
href: `/${domain}/settings/license`,
}
] : []),
{
title: "License",
href: `/${domain}/settings/license`,
}
]

return (
Expand Down
7 changes: 1 addition & 6 deletions packages/web/src/app/[domain]/settings/license/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,7 @@ import { Button } from "@/components/ui/button";
import { Info, Mail } from "lucide-react";
import { getOrgMembers } from "@/actions";
import { isServiceError } from "@/lib/utils";
import { notFound, ServiceErrorException } from "@/lib/serviceError";
import { env } from "@sourcebot/shared/client";
import { ServiceErrorException } from "@/lib/serviceError";

interface LicensePageProps {
params: Promise<{
Expand All @@ -19,10 +18,6 @@ export default async function LicensePage(props: LicensePageProps) {
domain
} = params;

if (env.NEXT_PUBLIC_SOURCEBOT_CLOUD_ENVIRONMENT !== undefined) {
notFound();
}

const licenseKey = getLicenseKey();
const entitlements = getEntitlements();
const plan = getPlan();
Expand Down
5 changes: 0 additions & 5 deletions packages/web/src/app/components/authSecurityNotice.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -59,11 +59,6 @@ export const AuthSecurityNotice = ({ closable = false }: AuthSecurityNoticeProps
return null;
}

// Only render for self-hosted deployments
if (env.NEXT_PUBLIC_SOURCEBOT_CLOUD_ENVIRONMENT !== undefined) {
return null;
}

return (
<div className={`p-4 rounded-lg bg-[var(--highlight)]/10 border border-[var(--highlight)]/20 relative ${closable ? 'pr-10' : ''}`}>
{closable && (
Expand Down
3 changes: 2 additions & 1 deletion packages/web/src/app/layout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,8 @@ export default function RootLayout({
<SessionProvider>
<PlanProvider entitlements={getEntitlements()}>
<PostHogProvider
isDisabled={env.SOURCEBOT_TELEMETRY_DISABLED === "true"}
isDisabled={env.SOURCEBOT_TELEMETRY_DISABLED === 'true'}
isPiiEnabled={env.SOURCEBOT_TELEMETRY_PII_COLLECTION_ENABLED === 'true'}
// @note: the posthog api key doesn't need to be kept secret,
// so we are safe to send it to the client.
posthogApiKey={env.POSTHOG_PAPIK}
Expand Down
15 changes: 8 additions & 7 deletions packages/web/src/app/posthogProvider.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ function PostHogPageView() {
interface PostHogProviderProps {
children: React.ReactNode
isDisabled: boolean
isPiiEnabled: boolean
posthogApiKey: string
sourcebotVersion: string
sourcebotInstallId: string
Expand All @@ -41,6 +42,7 @@ interface PostHogProviderProps {
export function PostHogProvider({
children,
isDisabled,
isPiiEnabled,
posthogApiKey,
sourcebotVersion,
sourcebotInstallId,
Expand All @@ -55,10 +57,10 @@ export function PostHogProvider({
person_profiles: 'identified_only',
capture_pageview: false,
autocapture: false,
// In self-hosted mode, we don't want to capture the following
// default properties.
// If PII is not enabled, we don't want to capture the following
// default properties that may contain PII.
// @see: https://posthog.com/docs/data/events#default-properties
property_denylist: env.NEXT_PUBLIC_SOURCEBOT_CLOUD_ENVIRONMENT === undefined ? [
property_denylist: isPiiEnabled === false ? [
'$current_url',
'$pathname',
'$session_entry_url',
Expand All @@ -81,7 +83,7 @@ export function PostHogProvider({
} else {
console.debug("PostHog telemetry disabled");
}
}, [isDisabled, posthogApiKey, sourcebotInstallId, sourcebotVersion]);
}, [isDisabled, isPiiEnabled, posthogApiKey, sourcebotInstallId, sourcebotVersion]);

useEffect(() => {
if (!session) {
Expand All @@ -90,13 +92,12 @@ export function PostHogProvider({

posthog.identify(
session.user.id,
// Only include email & name when running in a cloud environment.
env.NEXT_PUBLIC_SOURCEBOT_CLOUD_ENVIRONMENT !== undefined ? {
isPiiEnabled === true ? {
email: session.user.email,
name: session.user.name,
} : undefined
);
}, [session]);
}, [isPiiEnabled, session]);

return (
<PHProvider client={posthog}>
Expand Down
Loading