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 churn email (a pull request preview) #2

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
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
9 changes: 8 additions & 1 deletion index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,14 @@ app.get('/', (req, res) => {

const functions = getFunctions();

app.use('/api/inngest', serve(inngest, [...functions]));
app.use(
'/api/inngest',
serve(inngest, [...functions], {
signingKey: process.env.IS_PULL_REQUEST
? process.env.INNGEST_BRANCH_SIGNING_KEY
: process.env.INNGEST_SIGNING_KEY,
})
);

app.listen(PORT, async () => {
console.log(`✅ Server started on localhost:${PORT}
Expand Down
3 changes: 3 additions & 0 deletions inngest/client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,8 @@ import type { Events } from './events';
export const inngest = new Inngest({
name: 'Demo App',
schemas: new EventSchemas().fromRecord<Events>(),
eventKey: process.env.IS_PULL_REQUEST
? process.env.INNGEST_BRANCH_EVENT_KEY
: process.env.INNGEST_EVENT_KEY,
env: process.env.RENDER_GIT_BRANCH,
});
11 changes: 11 additions & 0 deletions inngest/emails.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,3 +21,14 @@ export const sendUpgradeEmail = inngest.createFunction(
};
}
);

export const sendChurnEmail = inngest.createFunction(
{ name: 'Send Churn Email' },
{ event: 'billing/subscription.cancelled' },
async ({ event }) => {
return {
success: true,
message: `churn email sent to user: ${event.user.id}`,
};
}
);
1 change: 0 additions & 1 deletion inngest/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ const functions = [...Object.values(emails), ...Object.values(payments)];

// We use a function to do this in order to dynamically add the cron test function
export function getFunctions() {
console.log('Get functions', process.env.RENDER_GIT_BRANCH);
// Only set the cron trigger to run in production, not branch envs
if (
!Boolean(process.env.RENDER_GIT_BRANCH) ||
Expand Down
5 changes: 3 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
},
"engine": {
"node": ">=20",
"pnpm": "^8.6.2"
}
"pnpm": "8.6.2"
},
"packageManager": "[email protected]"
}