gnikyt / laravel-shopify

A full-featured Laravel package for aiding in Shopify App development
MIT License
1.24k stars 374 forks source link

hook into new website joined #229

Closed tzookb closed 5 years ago

tzookb commented 5 years ago

I want to create some basic data when a new website gets created on my app.

So when he does install, I'll know about it and could create initial data.

I know there is the authenticate, but how do I hook into that?

Thanks!

gnikyt commented 5 years ago

https://github.com/ohmybrew/laravel-shopify/wiki/After-Authentication-Job

all information there will help. you create the job, add it to your config to run inline or though a queue.

tzookb commented 5 years ago

perfect!

taiviemthoi commented 4 years ago

@osiset if I want it to run only when installing the app (excluding login) Can I reuse AuthControllerTrait @ authenticate?

Kyon147 commented 4 years ago

@osiset if I want it to run only when installing the app (excluding login) Can I reuse AuthControllerTrait @ authenticate?

Authenticate still runs every time it needs to get a new session, it's not only on install. You still want to use the AfterAuthenticateJob that @osiset has suggested. If you want to only run something once, you would need to track in a DB or something if that job or function has already ran. If so, just skip over it in the AfterAuthJob.

This is what I usually do for welcome emails etc - a table just logs if a shop has had an email before if they have it skips.

taiviemthoi commented 4 years ago

@Kyon147 Thank But how to know that app has been installed before I think compare current time with created_at field in table shop? But it doesn't seem to be very accurate (in case I don't use any other table)

Kyon147 commented 4 years ago

@Kyon147 Thank But how to know that app has been installed before I think compare current time with created_at field in table shop? But it doesn't seem to be very accurate (in case I don't use any other table)

What are you trying to achieve by knowing if the app has been installed before?

taiviemthoi commented 4 years ago

@Kyon147 I want to see how many people have installed the app in the day I use redis to count, so it is desirable to install the variable when it first installs (login, reinstall does not count)

Kyon147 commented 4 years ago

@Kyon147 I want to see how many people have installed the app in the day I use redis to count, so it is desirable to install the variable when it first installs (login, reinstall does not count)

Why not just add a check in the AfterAuthJob then?

Create a table like "installs" and when they install for the first time in the AfterAuthJob just add their shop id to the table, created date etc.

Then when that job fires, always check to see if their shop_id or domain exists, if they do just skip over it.

That way you have your log then. No need to mess around with the base package files as your changes will be overwritten when you update.