Skip to content

Commit 5b1b4bc

Browse files
Copilotsix7
andauthored
Remove LaunchDarkly feature flag system (#3667)
* Initial plan * Remove LaunchDarkly dependencies and enable multi-file sync by default Co-authored-by: six7 <4548309+six7@users.noreply.github.com> * Keep multi-file sync gated behind pro user check and update tests Co-authored-by: six7 <4548309+six7@users.noreply.github.com> * Remove last LaunchDarkly reference from Navbar test Co-authored-by: six7 <4548309+six7@users.noreply.github.com> * Remove idStorage feature and fix linting/test issues Co-authored-by: six7 <4548309+six7@users.noreply.github.com> * Remove remaining getLdFlagsFactorySpy references from AppContainer test Co-authored-by: six7 <4548309+six7@users.noreply.github.com> * Fix multi-file support for pro users by checking isProUser dynamically Co-authored-by: six7 <4548309+six7@users.noreply.github.com> * Delete .changeset/remove-launchdarkly.md --------- Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> Co-authored-by: six7 <4548309+six7@users.noreply.github.com> Co-authored-by: Jan Six <six.jan@gmail.com>
1 parent d4140d9 commit 5b1b4bc

35 files changed

Lines changed: 46 additions & 580 deletions
Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
MIXPANEL_ACCESS_TOKEN=
22
STORYBLOK_ACCESS_TOKEN=
33
ENVIRONMENT=development
4-
LICENSE_API_URL=https://licence.tokens.studio
5-
LAUNCHDARKLY_SDK_CLIENT=626fb05d52e5c715abd11b5e
4+
LICENSE_API_URL=https://licence.tokens.studio
Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
MIXPANEL_ACCESS_TOKEN=
22
STORYBLOK_ACCESS_TOKEN=
33
ENVIRONMENT=production
4-
LICENSE_API_URL=https://licence.tokens.studio
5-
LAUNCHDARKLY_SDK_CLIENT=626fb05d52e5c715abd11b5e
4+
LICENSE_API_URL=https://licence.tokens.studio

packages/tokens-studio-for-figma/cypress/support/mockEnv.js

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -15,14 +15,6 @@ const MockEnv = () => {
1515
success: true
1616
}).as('storyblok')
1717

18-
cy.intercept('GET', `https://app.launchdarkly.com/**`, {
19-
success: true
20-
}).as('app-launchdarkly')
21-
22-
cy.intercept('POST', `https://events.launchdarkly.com/**`, {
23-
success: true
24-
}).as('events-launchdarkly')
25-
2618
cy.intercept('GET', `**/get-license*`, {
2719
plan: 'pro'
2820
}).as('getLicense')

packages/tokens-studio-for-figma/flags.d.ts

Lines changed: 0 additions & 13 deletions
This file was deleted.

packages/tokens-studio-for-figma/package.json

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
"build": "cross-env NODE_ENV=production webpack --mode=production",
1111
"build:dev": "cross-env NODE_ENV=development webpack --mode=development",
1212
"build:preview": "cross-env NODE_ENV=development webpack --mode=development --PREVIEW_ENV=browser",
13-
"build:cy": "cross-env LAUNCHDARKLY_FLAGS=tokenThemes,gitBranchSelector,multiFileSync,tokenFlowButton yarn build",
13+
"build:cy": "yarn build",
1414
"start": "cross-env webpack --mode=development --watch",
1515
"preview:ws": "node preview-server.js",
1616
"preview:plugin": "webpack --mode=development --PREVIEW_ENV=figma",
@@ -21,7 +21,7 @@
2121
"benchmark:run": "node benchmark/index.mjs",
2222
"benchmark:run:update": "node benchmark/index.mjs --update",
2323
"prettier:format": "prettier --write 'src/**/*.{js,jsx,ts,tsx,css,json}' ",
24-
"test": "cross-env LAUNCHDARKLY_FLAGS=tokenThemes,gitBranchSelector,multiFileSync,tokenFlowButton jest",
24+
"test": "jest",
2525
"test:watch": "npm run test -- --watch --collectCoverage=false",
2626
"test:quiet": "npm run test -- --reporters=jest-silent-reporter --coverage=false",
2727
"test:coverage": "npm run test -- --collectCoverageFrom='[\"src/**/*.{js,jsx,ts,tsx}\"]' --coverage --collectCoverage=true --coverageDirectory='./' --forceExit --detectOpenHandles",
@@ -103,8 +103,6 @@
103103
"just-safe-get": "^4.0.1",
104104
"just-safe-set": "^4.0.2",
105105
"just-split": "^3.0.1",
106-
"launchdarkly-js-client-sdk": "^2.24.2",
107-
"launchdarkly-react-client-sdk": "^2.28.0",
108106
"lodash.debounce": "^4.0.8",
109107
"lz-string": "^1.5.0",
110108
"mixpanel-figma": "^2.0.1",

packages/tokens-studio-for-figma/src/app/components/AddLicenseKey/AddLicenseKey.test.tsx

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -20,14 +20,6 @@ import { addLicenseKey } from '@/utils/addLicenseKey';
2020
// Hide log calls unless they are expected. This is mainly related to react-modal
2121
jest.spyOn(console, 'error').mockImplementation(() => { });
2222

23-
jest.mock('launchdarkly-react-client-sdk', () => ({
24-
LDProvider: (props: React.PropsWithChildren<unknown>) => props.children,
25-
useLDClient: () => ({
26-
identify: () => Promise.resolve(),
27-
}),
28-
useFlags: () => ({}),
29-
}));
30-
3123
function setup(jsx: JSX.Element) {
3224
return {
3325
user: userEvent.setup(),

packages/tokens-studio-for-figma/src/app/components/AddLicenseKey/AddLicenseKey.tsx

Lines changed: 1 addition & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@ import React, {
33
useCallback, useEffect, useState,
44
} from 'react';
55
import { useDispatch, useSelector } from 'react-redux';
6-
import { useLDClient } from 'launchdarkly-react-client-sdk';
76
import { useTranslation } from 'react-i18next';
87
import {
98
Button, Heading, TextInput, Box, Stack, IconButton,
@@ -17,20 +16,16 @@ import useConfirm from '@/app/hooks/useConfirm';
1716
import { AddLicenseSource } from '@/app/store/models/userState';
1817
import ProBadge from '../ProBadge';
1918
import { userIdSelector } from '@/selectors/userIdSelector';
20-
import { licenseDetailsSelector } from '@/selectors';
21-
import { ldUserFactory } from '@/utils/ldUserFactory';
2219
import { ErrorMessage } from '../ErrorMessage';
2320
import { addLicenseKey } from '@/utils/addLicenseKey';
2421

2522
export default function AddLicenseKey() {
2623
const dispatch = useDispatch<Dispatch>();
2724
const existingKey = useSelector(licenseKeySelector);
28-
const licenseDetails = useSelector(licenseDetailsSelector);
2925
const licenseKeyError = useSelector(licenseKeyErrorSelector);
3026
const [newKey, setLicenseKey] = useState(existingKey);
3127
const { confirm } = useConfirm();
3228
const userId = useSelector(userIdSelector);
33-
const ldClient = useLDClient();
3429
const { t } = useTranslation(['licence']);
3530
const [isMasked, setIsMasked] = useState(true);
3631

@@ -50,14 +45,6 @@ export default function AddLicenseKey() {
5045
}
5146
}, [newKey, dispatch, userId]);
5247

53-
const removeAccessToFeatures = useCallback(() => {
54-
if (userId) {
55-
ldClient?.identify({
56-
key: userId,
57-
});
58-
}
59-
}, [userId, ldClient]);
60-
6148
const removeKey = useCallback(async () => {
6249
if (licenseKeyError) {
6350
dispatch.userState.removeLicenseKey(undefined);
@@ -69,10 +56,9 @@ export default function AddLicenseKey() {
6956
});
7057
if (confirmation) {
7158
dispatch.userState.removeLicenseKey(undefined);
72-
removeAccessToFeatures();
7359
}
7460
}
75-
}, [t, dispatch, confirm, removeAccessToFeatures, licenseKeyError]);
61+
}, [t, dispatch, confirm, licenseKeyError]);
7662

7763
const ManageSubscriptionLink = styled('a', {
7864
color: '$accentDefault',
@@ -83,14 +69,6 @@ export default function AddLicenseKey() {
8369
setLicenseKey(existingKey);
8470
}, [existingKey]);
8571

86-
useEffect(() => {
87-
if (userId && existingKey && licenseDetails) {
88-
ldClient?.identify(
89-
ldUserFactory(userId, licenseDetails.plan, licenseDetails.entitlements, licenseDetails.clientEmail),
90-
);
91-
}
92-
}, [userId, ldClient, existingKey, licenseDetails]);
93-
9472
const onLicenseKeyChange = useCallback((ev: React.ChangeEvent<HTMLInputElement>) => {
9573
setLicenseKey(ev.target.value.trim());
9674
}, []);

packages/tokens-studio-for-figma/src/app/components/AppContainer/AppContainer.tsx

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@ import { Tabs } from '@/constants/Tabs';
88
import { AsyncMessageChannel } from '@/AsyncMessageChannel';
99
import { useStartupProcess } from './useStartupProcess';
1010
import { ProcessStepStatus } from '@/hooks';
11-
import { withLDProviderWrapper } from '../LaunchDarkly';
1211
import { ApplicationInitSteps } from './ApplicationInitSteps';
1312
import ConfirmDialog from '../ConfirmDialog';
1413
import WindowResizer from '../WindowResizer';
@@ -35,12 +34,12 @@ type Props = StartupMessage & {
3534
const applicationInitStepLabels = {
3635
[ApplicationInitSteps.SAVE_PLUGIN_DATA]: 'Receiving local data',
3736
[ApplicationInitSteps.ADD_LICENSE]: 'Verifying license',
38-
[ApplicationInitSteps.GET_LD_FLAGS]: 'Initializing LaunchDarkly',
3937
[ApplicationInitSteps.SAVE_STORAGE_INFORMATION]: 'Checking storage type',
4038
[ApplicationInitSteps.PULL_TOKENS]: 'Fetching (remote) tokens',
4139
};
4240

43-
export const AppContainer = withLDProviderWrapper((params: Props) => {
41+
export const AppContainer = (params: Props) => {
42+
const { authData } = params;
4443
const { isDarkTheme } = useFigmaTheme();
4544
const dispatch = useDispatch<Dispatch>();
4645
const startupProcess = useStartupProcess(params);
@@ -111,5 +110,5 @@ export const AppContainer = withLDProviderWrapper((params: Props) => {
111110
</Box>
112111
);
113112

114-
return <AuthContextProvider authData={params.authData}>{appContent}</AuthContextProvider>;
115-
});
113+
return <AuthContextProvider authData={authData}>{appContent}</AuthContextProvider>;
114+
};
Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
export enum ApplicationInitSteps {
22
SAVE_PLUGIN_DATA = 'save-plugin-data',
33
ADD_LICENSE = 'add-license',
4-
GET_LD_FLAGS = 'get-ld-flags',
54
SAVE_STORAGE_INFORMATION = 'save-storage-information',
65
PULL_TOKENS = 'pull-tokens',
76
}

packages/tokens-studio-for-figma/src/app/components/AppContainer/__tests__/AppContainer.test.tsx

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -7,13 +7,11 @@ import {
77
import { AppContainer } from '../AppContainer';
88
import * as savePluginDataFactoryModule from '../startupProcessSteps/savePluginDataFactory';
99
import * as addLicenseFactoryModule from '../startupProcessSteps/addLicenseFactory';
10-
import * as getLdFlagsFactorySpyModule from '../startupProcessSteps/getLdFlagsFactory';
1110
import * as saveStorageInformationFactoryModule from '../startupProcessSteps/saveStorageInformationFactory';
1211
import * as pullTokensFactoryModule from '../startupProcessSteps/pullTokensFactory';
1312

1413
const savePluginDataFactorySpy = jest.spyOn(savePluginDataFactoryModule, 'savePluginDataFactory');
1514
const addLicenseFactorySpy = jest.spyOn(addLicenseFactoryModule, 'addLicenseFactory');
16-
const getLdFlagsFactorySpy = jest.spyOn(getLdFlagsFactorySpyModule, 'getLdFlagsFactory');
1715
const saveStorageInformationFactorySpy = jest.spyOn(saveStorageInformationFactoryModule, 'saveStorageInformationFactory');
1816
const pullTokensFactorySpy = jest.spyOn(pullTokensFactoryModule, 'pullTokensFactory');
1917

@@ -25,9 +23,6 @@ describe('AppContainer', () => {
2523
addLicenseFactorySpy.mockImplementation(() => (
2624
() => Promise.resolve()
2725
));
28-
getLdFlagsFactorySpy.mockImplementation(() => (
29-
() => Promise.resolve()
30-
));
3126
saveStorageInformationFactorySpy.mockImplementation(() => (
3227
() => Promise.resolve()
3328
));
@@ -39,7 +34,6 @@ describe('AppContainer', () => {
3934
afterAll(() => {
4035
savePluginDataFactorySpy.mockReset();
4136
addLicenseFactorySpy.mockReset();
42-
getLdFlagsFactorySpy.mockReset();
4337
saveStorageInformationFactorySpy.mockReset();
4438
pullTokensFactorySpy.mockReset();
4539
});
@@ -57,7 +51,6 @@ describe('AppContainer', () => {
5751
expect(result.queryByText('Loading, please wait')).not.toBeNull();
5852
expect(savePluginDataFactorySpy).toBeCalledTimes(1);
5953
expect(addLicenseFactorySpy).toBeCalledTimes(1);
60-
expect(getLdFlagsFactorySpy).toBeCalledTimes(1);
6154
expect(saveStorageInformationFactorySpy).toBeCalledTimes(1);
6255
expect(pullTokensFactorySpy).toBeCalledTimes(1);
6356
});

0 commit comments

Comments
 (0)