Skip to content

feat: add funnelIds to remoteConfig and handle development defaults #2899

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
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
13 changes: 11 additions & 2 deletions src/remoteConfig.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { GrowthBook } from '@growthbook/growthbook';
import { logger } from './logger';
import { isProd } from './common/utils';
import { isProd, isTest } from './common';
import type { CoresRole } from './types';
import type { PurchaseType } from './common/plus';

Expand Down Expand Up @@ -28,6 +28,7 @@ type RemoteConfigValue = {
paddleIps: string[];
paddleTestDiscountIds: string[];
paddleProductIds: Partial<Record<PurchaseType, string>>;
funnelIds: Record<string, string>;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we make this typed web_funnel_id, onboarding_funnel_id, I don't think we will introduce many different funnel types as much + also they need other changes so better to have it typed

Copy link
Contributor

@capJavert capJavert Jul 7, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
funnelIds: Record<string, string>;
funnelIds: Partial<{
web_funnel_id: string,
onboarding_funnel_id: string
}>;

};

class RemoteConfig {
Expand Down Expand Up @@ -56,7 +57,15 @@ class RemoteConfig {

get vars(): Partial<RemoteConfigValue> {
if (!process.env.GROWTHBOOK_API_CONFIG_CLIENT_KEY) {
return {};
return {
...(!isProd &&
!isTest && {
funnelIds: {
web_funnel_id: 'paid-v1',
onboarding_funnel_id: 'organic-v1',
},
}),
};
}

if (!this.gb) {
Expand Down
5 changes: 5 additions & 0 deletions src/routes/boot.ts
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,7 @@ import { getBalance, type GetBalanceResult } from '../common/njord';
import { logger } from '../logger';
import { freyjaClient, type FunnelState } from '../integrations/freyja';
import { isUserPartOfOrganization } from '../common/plus';
import { remoteConfig } from '../remoteConfig';

export type BootSquadSource = Omit<GQLSource, 'currentMember'> & {
permalink: string;
Expand Down Expand Up @@ -784,6 +785,10 @@ const resolveDynamicFunnelId = (featureKey: string, userId: string): string => {
const gbClient = getUserGrowthBookInstance(userId, {
allocationClient,
});
if (!process.env.GROWTHBOOK_API_CONFIG_CLIENT_KEY) {
// In development, we use a static value for the feature key
return remoteConfig?.vars?.funnelIds?.[featureKey] || 'off';
}
return gbClient.getFeatureValue(featureKey, 'off');
};

Expand Down
Loading