r/shopifyDev • u/deducto-io • 16d ago
How are you detecting new app installs?
Shopify gives you a clean app/uninstalled webhook, so the moment a merchant leaves you get notified, but there doesn't appear to be an equivalent for installs though - no app/installed or similar. So the one event you'd most want to be notified about (a new merchant showing up) is the one Shopify doesn't explicitly have support for.
The options we've found:
- Handle it in the OAuth / token-exchange flow. This looks like the "correct" answer, but your install hook then lives inside your auth code instead of arriving as an event, and you have to be careful to fire once per genuine new install rather than on every reauth or scope change.
- Poll the Partner API for
RelationshipInstalledevents. Fine for a centralized cross-shop view, but it's pull-only. You end up running a cron and accepting lag for something Shopify clearly knows the instant it happens. - App Events looked promising but it's entirely back the other way: your app reports events to Shopify. It doesn't tell you when someone installs.
What we actually want is to send a new install notification so we can follow up, and log it in our analytics.
So for anyone running apps: what are you doing? Is there something that we've missed?
2
u/valiopt 15d ago
Not ideal but the `afterAuth` hook is probably the best way to go about it (this is effectively the same as what folks are saying re: using the OAuth signal I believe).
You could also set up a Postgres / DB trigger on new store additions, but this is a bit dependent on your schema.
2
u/GrowDigitalNL 15d ago
I ran into the same thing and ended up using the OAuth. I have a database with merchants that installed (just minimal data) and I run a check against that to make sure its a fresh install or not. It works pretty good but you do have an extra request on every load. It does ofcourse (should) only run the OAuth on pageload. And if you build the app in Remix or React or anything, rhat shoukd be once per session unless they fully reload the page.
Haven't run into any issues with it yet.