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

Replace ortto External Embedded Webform for Onboarding guide #1657

Merged
Merged
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
5 changes: 5 additions & 0 deletions src/adapters/notifications/MockNotificationAdapter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,11 @@ import { logger } from '../../utils/logger';
import { RecurringDonation } from '../../entities/recurringDonation';

export class MockNotificationAdapter implements NotificationAdapterInterface {
async subscribeOnboarding(params: { email: string }): Promise<void> {
logger.debug('MockNotificationAdapter subscribeOnboarding', params);
return Promise.resolve(undefined);
}

async createOrttoProfile(params: User): Promise<void> {
logger.debug('MockNotificationAdapter createOrttoProfile', params);
return Promise.resolve(undefined);
Expand Down
2 changes: 2 additions & 0 deletions src/adapters/notifications/NotificationAdapterInterface.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,8 @@ export interface OrttoPerson {
}

export interface NotificationAdapterInterface {
subscribeOnboarding(params: { email: string }): Promise<void>;

createOrttoProfile(params: User): Promise<void>;

updateOrttoPeople(params: OrttoPerson[]): Promise<void>;
Expand Down
15 changes: 15 additions & 0 deletions src/adapters/notifications/NotificationCenterAdapter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,21 @@ export class NotificationCenterAdapter implements NotificationAdapterInterface {
}
}

async subscribeOnboarding(params: { email: string }): Promise<void> {
try {
const { email } = params;
if (!email) return;
await callSendNotification({
eventName: NOTIFICATIONS_EVENT_NAMES.SUBSCRIBE_ONBOARDING,
segment: {
payload: { email },
},
});
} catch (e) {
logger.error('subscribeOnboarding >> error', e);
}
}

async sendEmailConfirmation(params: {
email: string;
project: Project;
Expand Down
1 change: 1 addition & 0 deletions src/analytics/analytics.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ export enum NOTIFICATIONS_EVENT_NAMES {
SUPER_TOKENS_BALANCE_WEEK = 'One week left in stream balance',
SUPER_TOKENS_BALANCE_MONTH = 'One month left in stream balance',
SUPER_TOKENS_BALANCE_DEPLETED = 'Stream balance depleted',
SUBSCRIBE_ONBOARDING = 'Subscribe onboarding',
CREATE_ORTTO_PROFILE = 'Create Ortto profile',
SEND_EMAIL_CONFIRMATION = 'Send email confirmation',
}
17 changes: 17 additions & 0 deletions src/resolvers/onboardingFormResolver.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
import { Arg, Query, Resolver } from 'type-graphql';
import { getNotificationAdapter } from '../adapters/adaptersFactory';
import { logger } from '../utils/logger';

@Resolver()
export class OnboardingFormResolver {
@Query(_returns => Boolean)
async subscribeOnboarding(@Arg('email') email: string): Promise<boolean> {
Copy link
Contributor

Choose a reason for hiding this comment

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

Correct the decorator usage.

The static analysis tool flagged an error with the decorator usage on the method parameter. This needs to be corrected to ensure proper functionality.

-  async subscribeOnboarding(@Arg('email') email: string): Promise<boolean> {
+  async subscribeOnboarding(@Arg('email', { validate: false }) email: string): Promise<boolean> {
Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
async subscribeOnboarding(@Arg('email') email: string): Promise<boolean> {
async subscribeOnboarding(@Arg('email', { validate: false }) email: string): Promise<boolean> {
Tools
Biome

[error] 8-8: Decorators are not valid here.

Decorators are only valid on class declarations, class expressions, and class methods.
You can enable parameter decorators by setting the unsafeParameterDecoratorsEnabled option to true in your configuration file.

(parse)

try {
await getNotificationAdapter().subscribeOnboarding({ email });
return true;
} catch (e) {
logger.debug('subscribeOnboarding() error', e);
return false;
Meriem-BM marked this conversation as resolved.
Show resolved Hide resolved
}
}
}
2 changes: 2 additions & 0 deletions src/resolvers/resolvers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ import { ProjectUserInstantPowerViewResolver } from './instantPowerResolver';
import { AnchorContractAddressResolver } from './anchorContractAddressResolver';
import { RecurringDonationResolver } from './recurringDonationResolver';
import { DraftDonationResolver } from './draftDonationResolver';
import { OnboardingFormResolver } from './onboardingFormResolver';

// eslint-disable-next-line @typescript-eslint/ban-types
export const getResolvers = (): Function[] => {
Copy link
Contributor

Choose a reason for hiding this comment

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

Replace the generic Function type with a more specific type.

The use of Function as a type is discouraged due to its broad acceptance of any function-like value. Specify a more explicit function type to prevent bugs.

- export const getResolvers = (): Function[] => {
+ export const getResolvers = (): Array<() => any> => { // Adjust the return type based on actual resolver function signatures.
Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
export const getResolvers = (): Function[] => {
export const getResolvers = (): Array<() => any> => {
Tools
Biome

[error] 26-26: Don't use 'Function' as a type. (lint/complexity/noBannedTypes)

Prefer explicitly define the function shape. This type accepts any function-like value, which can be a common source of bugs.

Expand Down Expand Up @@ -49,5 +50,6 @@ export const getResolvers = (): Function[] => {

AnchorContractAddressResolver,
RecurringDonationResolver,
OnboardingFormResolver,
];
};
Loading