Skip to content
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

Add enableAnalytics to getPreferences #3152

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from
Draft
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
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,
};
}
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
Loading