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

Add Scopes Update Webhook to Remix Template #875

Merged
merged 2 commits into from
Dec 18, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 5 additions & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# @shopify/shopify-app-template-remix

## 2024.12.18

- [875](https://github.com/Shopify/shopify-app-template-remix/pull/875) Add Scopes Update Webhook

## 2024.12.05

- [#910](https://github.com/Shopify/shopify-app-template-remix/pull/910) Install `openssl` in Docker image to fix Prisma (see [#25817](https://github.com/prisma/prisma/issues/25817#issuecomment-2538544254))
Expand All @@ -12,7 +16,6 @@
- [#891](https://github.com/Shopify/shopify-app-template-remix/pull/891) Enable remix future flags.

## 2024.11.26

- [888](https://github.com/Shopify/shopify-app-template-remix/pull/888) Update restResources version to 2024-10

## 2024.11.06
Expand All @@ -33,7 +36,7 @@

## 2024.09.17

- [842](https://github.com/Shopify/shopify-app-template-remix/pull/842)Move webhook processing to individual routes
- [842](https://github.com/Shopify/shopify-app-template-remix/pull/842) Move webhook processing to individual routes

## 2024.08.19

Expand Down
21 changes: 21 additions & 0 deletions app/routes/webhooks.app.scopes_update.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
import type { ActionFunctionArgs } from "@remix-run/node";
import { authenticate } from "../shopify.server";
import db from "../db.server";

export const action = async ({ request }: ActionFunctionArgs) => {
const { payload, session, topic, shop } = await authenticate.webhook(request);
console.log(`Received ${topic} webhook for ${shop}`);

const current = payload.current as string[];
if (session) {
await db.session.update({
where: {
id: session.id
},
data: {
scope: current.toString(),
lizkenyon marked this conversation as resolved.
Show resolved Hide resolved
},
});
}
return new Response();
};
5 changes: 5 additions & 0 deletions shopify.app.toml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,11 @@ api_version = "2024-10"
uri = "/webhooks/app/uninstalled"
topics = ["app/uninstalled"]

# Handled by: /app/routes/webhooks.app.scopes_update.tsx
[[webhooks.subscriptions]]
topics = [ "app/scopes_update" ]
uri = "/webhooks/app/scopes_update"
Copy link
Contributor

Choose a reason for hiding this comment

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

What happens when the CLI creates a new app toml. Would this config be lost?

Choose a reason for hiding this comment

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

#875

|--------|--------|--------|--------|--------|

| Cell | Cell | Cell | Cell | Cell |https://www.ibm.com/new/announcements/ibm-sevone-named-value-leader-in-ema-radar-report-2024-for-network-operations-observability
| Cell | Cell | Cell | Cell | Cell

|📱💸 andhttps://github.com/Shopify/shopify-app-template-remix#add-scopes-update-webhook

| Cell | Cell | Cell | Cell | Cell

Suggested change
uri = "/webhooks/app/scopes_update"
uri = _"/webhooks/app/scopes_update"_

##|

Suggested change
uri = "/webhooks/app/scopes_update"
uri = "/webhooks/app/scopes_update"

| Cell | Cell | Cell | Cell | Cell |
| Cell | Cell | Cell | Cell | Cell |


# Webhooks can have filters
# Only receive webhooks for product updates with a product price >= 10.00
# See: https://shopify.dev/docs/apps/build/webhooks/customize/filters
Expand Down
Loading