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

Get referral code from the web app when onboarding invitee #618

Merged

Conversation

vyorkin
Copy link
Contributor

@vyorkin vyorkin commented Sep 24, 2024

Copy link

github-actions bot commented Sep 24, 2024

📦 build.zip [updated at Oct 11, 1:46:58 PM UTC]

import * as styles from './styles.module.css';
import { WebAppMessageHandler } from './WebAppMessageHandler';

const DEBUG_INVITEE_FLOW = true;
Copy link
Contributor

Choose a reason for hiding this comment

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

Do not forget to remove before merge

}

function setReferralCode(_referralCode: string) {
// save referralCode
Copy link
Contributor

Choose a reason for hiding this comment

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

Here we also need not to safe incorrect code to avoid softlock state for the user who clicked on incorrect link

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Now referral code is checked on the webapp side, so it should be safe to just save it here as is

Copy link
Contributor

Choose a reason for hiding this comment

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

I think, doublecheck will not harm :)

Copy link
Contributor

Choose a reason for hiding this comment

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

Extension should be more reliable then web

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Updated ✅ Response will fail in case of incorrect referral code. The saveReferrer function is commented out because its implementation is already a part of my other PR

: 'https://app.zerion.io'
);

enum WebAppCallbackMethod {
Copy link
Contributor

Choose a reason for hiding this comment

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

Aren't enums considered deprecated?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ah, right, changed to just type

Copy link
Member

Choose a reason for hiding this comment

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

Are they?...

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Not really, some consider them bad, some don't... I think in this context its not a big deal: I just wanted to have some "sum"-type to enumerate possible callback methods

}
}

export function WebAppMessageHandler({ path }: { path: string }) {
Copy link
Contributor

Choose a reason for hiding this comment

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

let's use pathname here?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

return value as RemoteConfig[K];
},
useErrorBoundary: false,
cacheTime: 0,
Copy link
Member

Choose a reason for hiding this comment

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

why?

Copy link
Member

Choose a reason for hiding this comment

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

Copy link
Contributor Author

@vyorkin vyorkin Oct 10, 2024

Choose a reason for hiding this comment

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

removed cacheTime: 0, added staleTime: 8000

return value as RemoteConfig[K];
},
useErrorBoundary: false,
staleTime: 10000,
Copy link
Contributor

Choose a reason for hiding this comment

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

Do we need to provide suspense here?
Hope this will not lead to ui blinking

Copy link
Contributor Author

@vyorkin vyorkin Oct 11, 2024

Choose a reason for hiding this comment

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

✅ Yep, let's have suspense: false

isLoading: isLoadingRemoteConfigValue,
} = useRemoteConfigValue('extension_referral_program');

if (isLoadingRemoteConfigValue) {
Copy link
Contributor

Choose a reason for hiding this comment

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

If we use isLoading, we can set suspense: false inside useQuery

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thanks, updated ✅


const ZERION_WEB_APP_URL = new URL(
process.env.NODE_ENV === 'development'
? 'http://localhost:3000'
Copy link
Contributor

Choose a reason for hiding this comment

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

Looks like this should be a var inside .env file

Copy link
Member

Choose a reason for hiding this comment

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

Agree, or just use hardcoded 'https://app.zerion.io', and localhost link shouldn't be commited
Whichever's easier

Copy link
Contributor Author

@vyorkin vyorkin Oct 11, 2024

Choose a reason for hiding this comment

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

I don't think we need https://localhost:3000 anymore (since the other PR is already merged) ✅ Updated


type WebAppCallbackMethod = 'set-referral-code';

interface WebAppMessage<T = unknown> {
Copy link
Contributor

Choose a reason for hiding this comment

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

We don't use generic value of this interface anywhere. But this is probably not a problem.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Let's just have params?: unknown for now ✅

@vyorkin vyorkin merged commit 43674ee into feature/referral-program Oct 11, 2024
2 checks passed
@vyorkin vyorkin deleted the feature/get-referral-code-from-web-app branch October 11, 2024 21:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants