These are chat archives for reactioncommerce/reaction

21st
Feb 2019
Janus Reith
@janus-reith
Feb 21 06:29
*Node
Loan Laux
@loan-laux
Feb 21 06:30
@zzh1234567 Then it looks like you've got an answer :)
@janus-reith That would be really cool to see!
Janus Reith
@janus-reith
Feb 21 06:37
Good morning!

@loan-laux Yes, compared to e.g. Loggly, Sentry can be self-hosted, and also has great client-side error handling.
Could be great to be informed about and able to pinpoint an error even before a visitor complains.

I could get the client part to work, but Im struggling with the server.
We have the Loggrer/bunyan instance, but im not sure if Logging this would cover all errors.
Then we have ReactionError, an instance of that is sent to GraphQL Clients - Could also be helpful to log them.

Janus Reith
@janus-reith
Feb 21 07:50
Just noticed the addStream fucntion of bunyan, this should make it work
Now what I wonder: Both meteor and non-meteor code use Logger from the node module.
Which would be the best place, server/index with a meteor.startup function, or the new meteor-free startup method of register.js?
Loan Laux
@loan-laux
Feb 21 07:53
I'd say Meteor-free, always when possible
Janus Reith
@janus-reith
Feb 21 07:53
Yes, by preference
But I wonder if this might work, if Meteor code would import Logger then

Probably a matter of technical understanding of the details and I'm a bit unsure there.

Like

Loan Laux
@loan-laux
Feb 21 07:55
Well I don't see any issue, Meteor is capable of running and interacting with any pure Node code AFAIK
Aaaaah I got what you meant
Well, there's only one way of knowing!
Janus Reith
@janus-reith
Feb 21 07:55
Yes, what I wondered is if they are in the same context, and both import Logger if they share the same instance
will try out
Ildar Samit
@ildar-samit
Feb 21 10:02
Hey @spencern, I was told you might be able to help with a Reaction question I have. Our client is a liquor store that needs to collect a small deposit for every bottle sold (usually 10 cents per bottle, but it varies). What's the best way to add a new charge to a purchase, on the cart page? Docs describe how to create a new tax plugin, but I couldn't find anything about adding an additional generic charge (ie that's not a tax). If you or anyone else here could point in the right direction, it would be extremely helpful. Thanks!
Loan Laux
@loan-laux
Feb 21 10:11
@ildar-samit I think I would create a fork of the Stripe/PayPal/Authorize plugin to specifically answer that need. Not sure that's doable with hooks alone.
Ildar Samit
@ildar-samit
Feb 21 10:17
Thanks @loan-laux, we are using Stripe so I could look into that. But Reaction does all sorts of price calculations (that I'm not very familiar with) before things even get to Stripe. So I'm wondering how to do deposit calculations on the cart page, which is before Stripe comes into play. I could of course just do the math somewhere and at least show the deposit cost to the user. But then Reaction's own price calculations wouldn't match those that the user has been shown. I feel like I would have to bypass all checkout-related price calculations that Reaction does. Quite an undertaking just to add a few cents to the price of a bottle of wine :)
A hook to add an arbitrary additional cost to a purchase would've been very helpful here :)
Loan Laux
@loan-laux
Feb 21 10:19
Allow me to understand a bit better... Are you looking at charging 10% on checkout and 90% later, or just add 10% more to the price of each bottle?
Ildar Samit
@ildar-samit
Feb 21 10:24
For each bottle sold, a liquor store in Canada needs to charge the customer a tiny "deposit" for the bottle. The charge is usually small - 10 cents (not percent!) per bottle. So if I buy three bottles of wine for $20 each, my total would be: 3 x $20 + 3 x $0.10 = $60.30 (plus of course taxes and shipping etc). This small charge needs to be shown to the customer on the cart page. The cart page would show a subtotal , taxes, shipping, deposit, and the grand total.
Loan Laux
@loan-laux
Feb 21 10:28
And is it refunded by your client to their customers at any point in the future? Or does it go to some government entity?
Ildar Samit
@ildar-samit
Feb 21 10:31
I think it goes to the government. It's not refunded to the customer. (I believe the customer can return the bottle for recycling and get that deposit back, from the government)
Loan Laux
@loan-laux
Feb 21 10:34
So it's sort of a tax, isn't it?
To me, it really looks like a custom tax plugin would be a perfect fit but I may be missing some elements.
Ildar Samit
@ildar-samit
Feb 21 10:40
Yes it can be looked at as a tax, and I've thought about treating it as a tax but didn't know enough about Reaction's inner workings to predict if it would interfere with anything else Reaction does behind the scenes (since it's not a very usual tax). I'll look into creating a custom tax plugin. Thanks so much!
Loan Laux
@loan-laux
Feb 21 10:46
This Gitter is pretty active, but if you ever need dedicated help to expedite this and get your code checked by another set of (expert) eyes: https://outgrow.io ;)
Ildar Samit
@ildar-samit
Feb 21 10:50
Awesome, thank you very much!
Janus Reith
@janus-reith
Feb 21 12:35

So, mostly finished my Sentry Logger for client and server, just a bit rough around the edges!
It works as a plugin without touching core code, all that needs to be done is to pass two environment vars "SENTRY_CLIENT_URL" and "SENTRY_SERVER_URL" to your reaction container. (I kept those Logs separate)

As far as I can tell this should intercept all relevant logs properly, although Meteor put some obstacles in my way.

  • Client and Server @reactioncommerce/logger-Logs(Matches the bunyan Log levels with sentry log levels, and also respects current Reaction Log Level)
  • Client Errors
  • Server Errors and Meteor.Errors
  • ReactionError GraphQL API errrors
reaction-next-starterkit ist not included as it is out of scope with the current plugin system, but including it there should be pretty straightforward as there is an exisiting example
Marvin Kome
@marvinkome
Feb 21 16:15
Hello
Is it possible to use an existing db for reaction?
Janus Reith
@janus-reith
Feb 21 16:28
particularize "existing db"
Marvin Kome
@marvinkome
Feb 21 16:28
an already running mongo db instance
currently it's trying to use a docker installed mongo instance
Janus Reith
@janus-reith
Feb 21 16:29
yes, that is possible
Marvin Kome
@marvinkome
Feb 21 16:29
How please
Janus Reith
@janus-reith
Feb 21 16:30
take a look at the docker-composer.yaml in the reaction folder (assuming you started with reaction-platform)
in there, remove the mongo container that you won't need
and alter the file .env
which holds the enivironment vars for the reaction meteor container
there should be MONGO_URL=mongodb://mongo:27017/reaction and MONGO_OPLOG_URL=mongodb://mongo:27017/local
you can alter them to your needs
You will probably want to work with two separate docker-compose files for local development and production, and keep the mongo container for your dev environment
Marvin Kome
@marvinkome
Feb 21 16:33
Ok, what will i alter it to? locahost?
Janus Reith
@janus-reith
Feb 21 16:35
if that is where your mongo db is running, probably yes
Marvin Kome
@marvinkome
Feb 21 16:35
Also is it true my digital ocean server needs to have 2 cpus and 4gb ram
Janus Reith
@janus-reith
Feb 21 16:36
always depends on the load / how many users would be active on the same time.
But yes, 4 gb ram would be helpful to deal with spikes in memory usage
Theoretically you could also start with 1 gb of ram which would be enough to run it, but you would need to build the image beforehand, as this is more resource intensive.
Marvin Kome
@marvinkome
Feb 21 16:41
i only have 1gb
Frederico Maia Arantes
@fredericomaia10
Feb 21 18:43
Hello, I'm trying to use reaction to build a new e-commerce. At this moment should I use version 1 or 2?
I saw that version 2 is still RC, so, I'm not sure if is stable enough.. and I wanted to avoid a migration from 1 to 2. Can someone help me with that?
Janus Reith
@janus-reith
Feb 21 19:12
Depends on when you want to ship
on the one hand, next-js starterkit still lacks some views/features and has less usage examples, on the other nextjs has way faster laod times and seo due to ssr and is way better to work with due to shorter rebuild times
e.g. the nextjs storefront still doesn't have a search funtionality
Personally, I'd still stick to the nextjs storefront and also did when I started a new project a month ago.
New features are pretty easy to implement
Frederico Maia Arantes
@fredericomaia10
Feb 21 19:17
well, is my first time developing with reaction, I have developed a few projects with meteor and a small one with react.. so, not sure when I could finish, but my best target will be 1 month
would be 1 month *
Janus Reith
@janus-reith
Feb 21 19:18
1 month could be tough
To what degree would customization go?
Frederico Maia Arantes
@fredericomaia10
Feb 21 19:19
the main customization would be selling services instead of products
there is only one more developer in the team
Janus Reith
@janus-reith
Feb 21 19:21
In general this shouldn't be too hard, just leave out shipping cost and maybe change some wordings, although I don't know your specific requierements
Janus Reith
@janus-reith
Feb 21 19:34

You could simply compare:
(This is both a release candidate of v2.0, but the main difference is the separate nextjs storefront while the meteor based is still included atm )

Classic:
https://reaction-core.staging.reactioncommerce.com

Nextjs:
https://storefront.staging.reactioncommerce.com/

Take a look at both and decide if the latter suits your needs - e.g. search is missing and a dedicated profile page and internationalization.
Also keep in mind that there will be and where a lot of potentially breaking changes between the RC*s (well, the same was the case for stable releases)

As the latest commits that remove the customer relevant parts of the meteor project were not merged until the release of the latest rc, you could also take a current v2.0 RC
and still build upon that.
I did that with rc7 and the result is pretty stable.
Actually, more stable for my use case than 1.17 was. Some issues I had before in production didn't came anymore, although I also reimplemented some customizations and therefore can't pinpoint the root cause.

The advantage is that adding items to cart and creating orders is already converted to graphql mutations instead of meteor methods, therefore if one decides to switch to the nextjs based storefront the transition would be easier.
(GraphQL should be preferred in general over the very meteor-specific Meteor calls)

Frederico Maia Arantes
@fredericomaia10
Feb 21 19:38
yeah, version 2 looks great to me and its performance is quite better
I'll try setting up my environment and check how it works, I think that version 2 would be the best choice, I'll give a try
thanks so much for your answers
Frederico Maia Arantes
@fredericomaia10
Feb 21 19:58
just complementing, it's a personal project so, we can decide about the MVP for launching :)
MVP features *