Skip to content

Commit 0128c51

Browse files
authored
fix: move glacier drop learn more url to posthog feature flag payload (#1912)
1 parent 30231e7 commit 0128c51

File tree

10 files changed

+25
-10
lines changed

10 files changed

+25
-10
lines changed

apps/browser-extension-wallet/.env.defaults

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,6 @@ TEMPO_VOTE_URL_MAINNET=https://tempo.vote
6060
TEMPO_VOTE_URL_PREPROD=https://preprod.tempo.vote
6161
TEMPO_VOTE_URL_PREVIEW=https://preview.tempo.vote
6262
TEMPO_VOTE_URL_SANCHONET=https://sanchonet.tempo.vote
63-
MIDNIGHT_LEARN_MORE_URL=http://midnighttge.io
6463

6564
# events tracking
6665
POSTHOG_HOST=https://e.lw.iog.io

apps/browser-extension-wallet/.env.developerpreview

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,6 @@ TEMPO_VOTE_URL_MAINNET=https://tempo.vote
5858
TEMPO_VOTE_URL_PREPROD=https://preprod.tempo.vote
5959
TEMPO_VOTE_URL_PREVIEW=https://preview.tempo.vote
6060
TEMPO_VOTE_URL_SANCHONET=https://sanchonet.tempo.vote
61-
MIDNIGHT_LEARN_MORE_URL=http://midnighttge.io
6261

6362
# events tracking
6463
POSTHOG_HOST=https://e.lw.iog.io

apps/browser-extension-wallet/.env.example

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,6 @@ TEMPO_VOTE_URL_MAINNET=https://tempo.vote
5757
TEMPO_VOTE_URL_PREPROD=https://preprod.tempo.vote
5858
TEMPO_VOTE_URL_PREVIEW=https://preview.tempo.vote
5959
TEMPO_VOTE_URL_SANCHONET=https://sanchonet.tempo.vote
60-
MIDNIGHT_LEARN_MORE_URL=http://midnighttge.io
6160

6261
# events tracking
6362
POSTHOG_HOST=https://e.lw.iog.io

apps/browser-extension-wallet/src/lib/scripts/types/feature-flags.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import { Cardano } from '@cardano-sdk/core';
22
import { z } from 'zod';
33
import { DeepRequired } from 'utility-types';
44
import { JsonType } from 'posthog-js';
5-
import { commonSchema, dappExplorerSchema } from '@providers/PostHogClientProvider/schema';
5+
import { commonSchema, dappExplorerSchema, glacierDropSchema } from '@providers/PostHogClientProvider/schema';
66

77
export enum ExperimentName {
88
CREATE_PAPER_WALLET = 'create-paper-wallet',
@@ -29,6 +29,7 @@ export type FeatureFlagsByNetwork = Record<Cardano.NetworkMagics, FeatureFlags>;
2929
// so we use extra types with DeepRequired, these types can be removed after Lace uses strict null checks
3030
export type FeatureFlagCommonSchema = DeepRequired<z.infer<typeof commonSchema>>;
3131
export type FeatureFlagDappExplorerSchema = DeepRequired<z.infer<typeof dappExplorerSchema>>;
32+
export type FeatureFlagGlacierDropSchema = DeepRequired<z.infer<typeof glacierDropSchema>>;
3233

3334
// Using `false` as a fallback type for the payload, as it can be optional, and we (sadly) don't have
3435
// strict null checks enabled so `false` is a replacement for `undefined` in this case
@@ -37,6 +38,7 @@ type FeatureFlagPayload<T extends Record<string, unknown> = {}> = (FeatureFlagCo
3738

3839
type FeatureFlagCustomPayloads = {
3940
[ExperimentName.DAPP_EXPLORER]: FeatureFlagPayload<FeatureFlagDappExplorerSchema>;
41+
[ExperimentName.GLACIER_DROP]: FeatureFlagPayload<FeatureFlagGlacierDropSchema>;
4042
};
4143

4244
export type FeatureFlagPayloads = {

apps/browser-extension-wallet/src/providers/PostHogClientProvider/client/PostHogClient.ts

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,8 @@ import {
3232
FeatureFlagPayloads,
3333
FeatureFlagsByNetwork,
3434
FeatureFlags,
35-
RawFeatureFlagPayloads
35+
RawFeatureFlagPayloads,
36+
FeatureFlagGlacierDropSchema
3637
} from '@lib/scripts/types/feature-flags';
3738
import { config } from '@src/config';
3839
import { featureFlagSchema, networksEnumSchema, NetworksEnumSchema } from '../schema';
@@ -313,6 +314,11 @@ export class PostHogClient<Action extends string = string> {
313314
continue;
314315
}
315316

317+
if (featureFlag === ExperimentName.GLACIER_DROP) {
318+
payloadsByFeature[featureFlag] = featureFlagSchema.glacierDrop.parse(payload) as FeatureFlagGlacierDropSchema;
319+
continue;
320+
}
321+
316322
// type-casting can be removed after Lace uses strict null checks
317323
payloadsByFeature[featureFlag] = featureFlagSchema.common.parse(payload) as FeatureFlagCommonSchema;
318324
} catch (error) {

apps/browser-extension-wallet/src/providers/PostHogClientProvider/schema.ts

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,14 @@ export const dappExplorerSchema = commonSchema.merge(
4141
})
4242
);
4343

44+
export const glacierDropSchema = commonSchema.merge(
45+
z.object({
46+
learnMoreUrl: z.string().url()
47+
})
48+
);
49+
4450
export const featureFlagSchema = {
4551
common: z.preprocess(parseJsonPreprocessor, commonSchema),
46-
dappExplorer: z.preprocess(parseJsonPreprocessor, dappExplorerSchema)
52+
dappExplorer: z.preprocess(parseJsonPreprocessor, dappExplorerSchema),
53+
glacierDrop: z.preprocess(parseJsonPreprocessor, glacierDropSchema)
4754
};

apps/browser-extension-wallet/src/views/browser-view/features/assets/components/MidnightEventBanner.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ export const MidnightEventBanner = (): JSX.Element => {
2727
const posthog = usePostHogClientContext();
2828

2929
const isGlacierDropEnabled = posthog?.isFeatureFlagEnabled('glacier-drop');
30+
const glacierDropPayload = posthog.getFeatureFlagPayload('glacier-drop');
3031

3132
useEffect(() => {
3233
const loadStorage = async () => {
@@ -140,7 +141,7 @@ export const MidnightEventBanner = (): JSX.Element => {
140141
reminder: t('midnightEventBanner.reminder')
141142
}}
142143
onReminder={handleReminder}
143-
onLearnMore={() => openExternalLink(process.env.MIDNIGHT_LEARN_MORE_URL)}
144+
onLearnMore={() => glacierDropPayload && openExternalLink(glacierDropPayload?.learnMoreUrl)}
144145
onClose={() => handleDialog(true)}
145146
/>
146147
</Box>

apps/browser-extension-wallet/src/views/browser-view/features/settings/components/SettingsLayout.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,14 +24,15 @@ export const SettingsLayout = ({
2424
const posthog = usePostHogClientContext();
2525

2626
const isGlacierDropEnabled = posthog?.isFeatureFlagEnabled('glacier-drop');
27+
const glacierDropPayload = posthog?.getFeatureFlagPayload('glacier-drop');
2728

2829
const sidePanelContent = (
2930
<div>
3031
{isGlacierDropEnabled ? (
3132
<Box mb="$32">
3233
<MidnightPreLaunchSettingsBanner
3334
bannerImageUrl={MidnightPreLaunchBannerImage}
34-
onCtaButtonClick={() => openExternalLink(process.env.MIDNIGHT_LEARN_MORE_URL)}
35+
onCtaButtonClick={() => glacierDropPayload && openExternalLink(glacierDropPayload?.learnMoreUrl)}
3536
/>
3637
</Box>
3738
) : undefined}

apps/browser-extension-wallet/src/views/browser-view/features/settings/components/SettingsWalletBase.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,7 @@ export const SettingsWalletBase = <AdditionalDrawers extends string>({
8383
const isNetworkChoiceEnabled = AVAILABLE_CHAINS.length > 1;
8484
const authorizedAppsEnabled = process.env.USE_DAPP_CONNECTOR === 'true' && !isSharedWallet;
8585
const isGlacierDropEnabled = posthog?.isFeatureFlagEnabled('glacier-drop');
86+
const glacierDropPayload = posthog?.getFeatureFlagPayload('glacier-drop');
8687

8788
useEffect(() => {
8889
const openCollateralDrawer = async () => {
@@ -184,7 +185,7 @@ export const SettingsWalletBase = <AdditionalDrawers extends string>({
184185
<SettingsLink
185186
description={t('browserView.settings.wallet.midnight.prelaunch.description')}
186187
data-testid="settings-wallet-midnight-prelaunch-link"
187-
onClick={() => openExternalLink(process.env.MIDNIGHT_LEARN_MORE_URL)}
188+
onClick={() => glacierDropPayload && openExternalLink(glacierDropPayload?.learnMoreUrl)}
188189
>
189190
{t('browserView.settings.wallet.midnight.prelaunch.title')}
190191
</SettingsLink>

packages/common/src/ui/components/Button/styles.module.scss

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -312,7 +312,7 @@ $btn-gap: var(--btn-gap, size_unit(1));
312312
}
313313

314314
.btn[data-color='gradient-secondary'] {
315-
@extend .btn[data-color='gradient'];
315+
@extend .btn, [data-color='gradient'];
316316
background: linear-gradient($btn-gradient2-bg, $btn-gradient2-bg) padding-box, var(--lace-gradient) border-box;
317317

318318
&:hover:not(.loading) {

0 commit comments

Comments
 (0)