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

feat: add invite team members nudge flow #5549

Merged
merged 15 commits into from
May 15, 2024
Merged

feat: add invite team members nudge flow #5549

merged 15 commits into from
May 15, 2024

Conversation

jainpawan21
Copy link
Member

@jainpawan21 jainpawan21 commented May 12, 2024

What changed? Why was the change needed?

In NV-3697, we want to use Novu workflow to send in-app and after some delay email. hubspot will be used to send email

Novu workflow :- Trigger -> in-app -> delay (24hr) -> email (with condition on webhook)

Flow:- User trigger the workflow, based on all conditions, in-app notification is sent to the user. After 24hr delay, workflow will create post request to webhookUrl (here webhookurl is new /invites/webhook API). If all conditions are satisfied, email is sent using hubspot.

Screenshots

Expand for optional sections

Related enterprise PR

Special notes for your reviewer

@jainpawan21 jainpawan21 requested a review from a team as a code owner May 12, 2024 11:34
Copy link

linear bot commented May 12, 2024

Copy link

netlify bot commented May 12, 2024

Deploy Preview for novu-design ready!

Name Link
🔨 Latest commit fcc67f7
🔍 Latest deploy log https://app.netlify.com/sites/novu-design/deploys/66441f4eae045a0007293a7d
😎 Deploy Preview https://deploy-preview-5549--novu-design.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.

Copy link

netlify bot commented May 12, 2024

Deploy Preview for dev-web-novu ready!

Name Link
🔨 Latest commit fcc67f7
🔍 Latest deploy log https://app.netlify.com/sites/dev-web-novu/deploys/66441f4e9a7ca40008e15cef
😎 Deploy Preview https://deploy-preview-5549--dev-web-novu.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.

@jainpawan21 jainpawan21 changed the title feat: add initial flow for invite nudge feat: add invite team members nudge flow May 13, 2024
Comment on lines 226 to 230
// check if this is first trigger
const notifications = await this.notificationRepository.count({
_organizationId: command.organizationId,
_environmentId: command.environmentId,
});
Copy link
Contributor

Choose a reason for hiding this comment

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

chore: This will be super costly in terms of Mongo request, what we can do instead is take the first five or whatever number of notifications, and if there are then return.

Copy link
Member Author

Choose a reason for hiding this comment

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

Shall I add limit 1 ?

Copy link
Contributor

Choose a reason for hiding this comment

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

yes, but maybe better would be to do that with findOne

@@ -206,4 +221,68 @@ export class ParseEventRequest {

return reservedVariables?.map((reservedVariable) => reservedVariable.type) || [];
}

public async sendInAppNudgeForTeamMemberInvite(command: ParseEventRequestCommand) {
Copy link
Contributor

Choose a reason for hiding this comment

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

chore: we don't need to do this for self-hosted

Copy link
Member Author

Choose a reason for hiding this comment

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

I have this condition before novu.trigger.
Wdyt? I should add similar conditions here

Copy link
Contributor

Choose a reason for hiding this comment

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

yes, but all code above it is not needed to be executed

@@ -206,4 +221,68 @@ export class ParseEventRequest {

return reservedVariables?.map((reservedVariable) => reservedVariable.type) || [];
}

public async sendInAppNudgeForTeamMemberInvite(command: ParseEventRequestCommand) {
Copy link
Contributor

Choose a reason for hiding this comment

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

🤓 nitpick (non-blocking): can we please also cover this logic with e2e tests?

@@ -206,4 +221,68 @@ export class ParseEventRequest {

return reservedVariables?.map((reservedVariable) => reservedVariable.type) || [];
}

public async sendInAppNudgeForTeamMemberInvite(command: ParseEventRequestCommand) {
Copy link
Contributor

Choose a reason for hiding this comment

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

chore: and let's maybe also have this under the feature flag so we can disable if something is odd

Copy link
Member Author

Choose a reason for hiding this comment

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

Copy link
Contributor

Choose a reason for hiding this comment

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

yes, but with the new feature flag created in LD and as well as constant in the code

export class InviteNudgeWebhook {
constructor(private memberRepository: MemberRepository) {}

async execute(command: InviteNudgeWebhookCommand) {
Copy link
Contributor

Choose a reason for hiding this comment

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

chore: same behind the feature flag

apps/web/src/AppRoutes.tsx Show resolved Hide resolved
Comment on lines 24 to 25
const location = useLocation();
const state = location.state as { redirectTo?: { pathname?: string } };
Copy link
Contributor

Choose a reason for hiding this comment

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

🤓 nitpick (non-blocking): please put the appropriate types on the useLocation hook

Copy link
Contributor

@antonjoel82 antonjoel82 left a comment

Choose a reason for hiding this comment

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

Left a couple notes on the web side!

Comment on lines +22 to +27
export interface LocationState {
redirectTo: {
pathname: string;
};
}

Copy link
Contributor

Choose a reason for hiding this comment

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

question: Why are we defining the type for the return of the useLocation hook here?‏

Copy link
Contributor

Choose a reason for hiding this comment

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

chore: We should avoid exporting a generic type from here as we may unknowingly cause circular dependencies‏

Comment on lines 82 to 86
if (state?.redirectTo?.pathname) {
navigate(state?.redirectTo?.pathname);
} else {
navigate(ROUTES.WORKFLOWS);
}
Copy link
Contributor

Choose a reason for hiding this comment

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

suggestion:

Suggested change
if (state?.redirectTo?.pathname) {
navigate(state?.redirectTo?.pathname);
} else {
navigate(ROUTES.WORKFLOWS);
}
navigate(state?.redirectTo?.pathname || ROUTES.WORKFLOWS);

@jainpawan21 jainpawan21 merged commit 17230b1 into next May 15, 2024
26 checks passed
@jainpawan21 jainpawan21 deleted the NV-3697 branch May 15, 2024 02:54
github-actions bot pushed a commit that referenced this pull request May 16, 2024
* feat: add initial flow for invite nudge

* feat: add route redirect

* fix: add protonmail in cspell

* fix: create const for payload key

* fix: add state prop in navigate

* fix: add user in analytics

* fix: add webhook url variable

* fix: pr comments, featute flag

* fix: update hubspot list env variable

* fix: failing test

* fix: navigate to pathname

* fix: decryption api key for webhook hmac
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants