Skip to content

Commit

Permalink
Add enableAnalytics to getPreferences
Browse files Browse the repository at this point in the history
  • Loading branch information
GuillaumeRx committed Feb 25, 2025
1 parent 6222525 commit 89a5540
Show file tree
Hide file tree
Showing 8 changed files with 19 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ describe('snap_getPreferences', () => {
displayNftMedia: false,
useNftDetection: false,
useExternalPricingData: true,
enableAnalytics: false,
}),
};

Expand All @@ -60,6 +61,7 @@ describe('snap_getPreferences', () => {
displayNftMedia: false,
useNftDetection: false,
useExternalPricingData: true,
enableAnalytics: false,
});
});
});
Expand Down
2 changes: 2 additions & 0 deletions packages/snaps-sdk/src/types/methods/get-preferences.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ export type GetPreferencesParams = never;
* @property displayNftMedia - Whether to display NFT media.
* @property useNftDetection - Whether to auto-detect NFTs.
* @property useExternalPricingData - Whether to get token price data from an external source.
* @property enableAnalytics - Whether the user has chosen to participate in analytics.
*/
export type GetPreferencesResult = {
locale: string;
Expand All @@ -32,4 +33,5 @@ export type GetPreferencesResult = {
displayNftMedia: boolean;
useNftDetection: boolean;
useExternalPricingData: boolean;
enableAnalytics: boolean;
};
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ describe('getGetPreferencesMethodImplementation', () => {
displayNftMedia: true,
useNftDetection: true,
useExternalPricingData: true,
enableAnalytics: true,
});
});

Expand All @@ -41,6 +42,7 @@ describe('getGetPreferencesMethodImplementation', () => {
displayNftMedia: true,
useNftDetection: true,
useExternalPricingData: true,
enableAnalytics: true,
});
});

Expand All @@ -62,6 +64,7 @@ describe('getGetPreferencesMethodImplementation', () => {
displayNftMedia: true,
useNftDetection: true,
useExternalPricingData: true,
enableAnalytics: true,
});
});

Expand All @@ -83,6 +86,7 @@ describe('getGetPreferencesMethodImplementation', () => {
displayNftMedia: true,
useNftDetection: true,
useExternalPricingData: true,
enableAnalytics: true,
});
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import type { SimulationOptions } from '../../options';
* @param options.displayNftMedia - Whether to display NFT media.
* @param options.useNftDetection - Whether to auto-detect NFTs.
* @param options.useExternalPricingData - Whether to get token price data from an external source.
* @param options.enableAnalytics - Whether to enable analytics.
* @returns The implementation of the `getPreferences` hook.
*/
export function getGetPreferencesMethodImplementation({
Expand All @@ -27,6 +28,7 @@ export function getGetPreferencesMethodImplementation({
displayNftMedia,
useNftDetection,
useExternalPricingData,
enableAnalytics,
}: SimulationOptions) {
return () => {
return {
Expand All @@ -40,6 +42,7 @@ export function getGetPreferencesMethodImplementation({
displayNftMedia,
useNftDetection,
useExternalPricingData,
enableAnalytics,
};
};
}
2 changes: 2 additions & 0 deletions packages/snaps-simulation/src/options.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ describe('getOptions', () => {
"useNftDetection": true,
"useSecurityAlerts": true,
"useTokenDetection": true,
"enableAnalytics": true,
}
`);
});
Expand All @@ -44,6 +45,7 @@ describe('getOptions', () => {
"useNftDetection": true,
"useSecurityAlerts": true,
"useTokenDetection": true,
"enableAnalytics": true,
}
`);
});
Expand Down
2 changes: 2 additions & 0 deletions packages/snaps-simulation/src/options.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ const SimulationOptionsStruct = object({
displayNftMedia: defaulted(optional(boolean()), true),
useNftDetection: defaulted(optional(boolean()), true),
useExternalPricingData: defaulted(optional(boolean()), true),
enableAnalytics: defaulted(optional(boolean()), true),
});

/**
Expand All @@ -48,6 +49,7 @@ const SimulationOptionsStruct = object({
* @property displayNftMedia - Whether to display NFT media.
* @property useNftDetection - Whether to auto-detect NFTs.
* @property useExternalPricingData - Whether to get token price data from an external source.
* @property enableAnalytics - Whether to enable analytics.
*/
export type SimulationUserOptions = Infer<typeof SimulationOptionsStruct>;

Expand Down
3 changes: 3 additions & 0 deletions packages/snaps-simulation/src/test-utils/options.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ import type { SimulationOptions } from '../options';
* @param options.displayNftMedia - Whether to display NFT media.
* @param options.useNftDetection - Whether to auto-detect NFTs.
* @param options.useExternalPricingData - Whether to get token price data from an external source.
* @param options.enableAnalytics - Whether to enable analytics.
* @returns The options for the simulation.
*/
export function getMockOptions({
Expand All @@ -34,6 +35,7 @@ export function getMockOptions({
displayNftMedia = true,
useNftDetection = true,
useExternalPricingData = true,
enableAnalytics = true,
}: Partial<SimulationOptions> = {}): SimulationOptions {
return {
currency,
Expand All @@ -49,5 +51,6 @@ export function getMockOptions({
displayNftMedia,
useNftDetection,
useExternalPricingData,
enableAnalytics,
};
}
1 change: 1 addition & 0 deletions packages/snaps-simulator/src/features/simulation/sagas.ts
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,7 @@ export function* initSaga({ payload }: PayloadAction<string>) {
displayNftMedia: true,
useNftDetection: true,
useExternalPricingData: true,
enableAnalytics: true,
}),
getUnlockPromise: async () => Promise.resolve(true),
showDialog: async (...args: Parameters<typeof showDialog>) =>
Expand Down

0 comments on commit 89a5540

Please sign in to comment.