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

Usage information #8

Open
juliomac opened this issue Oct 18, 2016 · 3 comments
Open

Usage information #8

juliomac opened this issue Oct 18, 2016 · 3 comments

Comments

@juliomac
Copy link

juliomac commented Oct 18, 2016

Dear @brettle ,

Thanks for the enormous effort put on these packages. Really an outstanding work!

I have an application where anonymous visitors can search for available dates and select rooms prior to sign-up. They can create an account only when they are ready to purchase and, only after properly signed-up is that they have access to discounts, promotions and to be able to continue with purchase process.

In this project, I want to track how many times certain Date ranges were searched for and the Drop Rate (how many anonymous users signed-up- and completed the process)

Do you think theses packages could be useful here? I want the anonymous users to have logged-in state only after sign-up. After sign-up, I want to relate previously anonymous _id behavior to the new signed-up user _id. Is it possible?

@brettle
Copy link
Owner

brettle commented Oct 20, 2016

With these packages, the user's _id does not change after sign-up, so it should be easy to determine a user's pre-signup behavior after they sign-up. You can also determine which users have signed up. Per the documentation for brettle:accounts-login-state, "On the server, LoginState.signedUp() itself takes an optional user argument (defaults to Meteor.user()) which you can use to determine whether a particular user has signed up".

@juliomac
Copy link
Author

juliomac commented Oct 22, 2016

Thanks @brettle for your quick answer!

I've read your documentation, cloned and have been testing your demo app.

I notice the package does create a user on Meteor.users and, if tested for Meteor.userId() I do get a result. So I have to change the way I differentiate an anonymous user from one logged with an account. It seems like I will have to replace the instances where I test if user has an account (signed-up / logged-in) from If (Meteor.userId() to if(LoginState.signedUp()), right?

I found out that adding only meteor-accounts-deluxe does not expose the LoginState.signedUp() methods on client/server, but adding the specific meteor-accounts-login-state made it to work.

On my tests on Meteor Shell, however, the if(LoginState.signedUp()) still gave me an error like:

 > LoginState.signedUp()
Error: Meteor.userId can only be invoked in method calls. Use this.userId in publish functions.
    at AccountsServer.userId (accounts_server.js:80:13)
    at AccountsServer.user (accounts_common.js:53:23)
  ...

What is the correct way for testing it on Server?

@brettle
Copy link
Owner

brettle commented Oct 30, 2016

Yes, on the client or in a server method, if(LoginState.signedUp()) is the correct way to check whether the current user has signed up.

However, I don't think the concept of "current user" is defined within Meteor Shell, so you need to call LoginState.signedup(user) instead, where user is the user you are asking about.

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

No branches or pull requests

2 participants