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

Fix docs links & other small updates #273

Open
wants to merge 4 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
6 changes: 3 additions & 3 deletions opensaas-sh/blog/src/content/docs/general/admin-dashboard.md
Original file line number Diff line number Diff line change
Expand Up @@ -51,10 +51,10 @@ The Admin analytics dashboard is a single place for you to view your most import

<!-- TODO: add photo -->

- [Stripe](/guides/stripe-integration):
- [Payments Processor](/guides/payments-integration/):
- total revenue
- revenue for each day of the past week
- [Google or Plausible](/guides/analytics):
- [Google or Plausible](/guides/analytics/):
- total number of page views (non-unique)
- percentage change in page views from the previous day
- top sources/referrers with unique visitor count (i.e. how many people came from that source to your app)
Expand All @@ -81,7 +81,7 @@ job dailyStatsJob {
```
For more info on Wasp's recurring background jobs, check out the [Wasp Jobs docs](https://wasp-lang.dev/docs/advanced/jobs).

For a guide on how to integrate these services so that you can view your analytics via the dashboard, check out the [Stripe](/guides/stripe-integration) and [Analytics guide](/guides/analytics) of the docs.
For a guide on how to integrate these services so that you can view your analytics via the dashboard, check out the [Payments Integration](/guides/payments-integration/) and [Analytics guide](/guides/analytics/) of the docs.

:::note[Help us improve]
We're always looking to improve the Admin dashboard. If you feel something is missing or could be improved, consider [opening an issue](https://github.com/wasp-lang/open-saas/issues) or [submitting a pull request](https://github.com/wasp-lang/open-saas/pulls)
Expand Down
29 changes: 15 additions & 14 deletions opensaas-sh/blog/src/content/docs/general/user-overview.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,8 @@ entity User {=psl
createdAt DateTime @default(now())
lastActiveTimestamp DateTime @default(now())
isAdmin Boolean @default(false)
stripeId String?
paymentProcessorUserId String? @unique
lemonSqueezyCustomerPortalUrl String? // You can delete this if you're not using Lemon Squeezy as your payments processor.
checkoutSessionId String?
subscriptionPlan String?
subscriptionStatus String?
Expand All @@ -34,7 +35,7 @@ entity User {=psl
psl=}
```

We store all pertinent information to the user, including identification, subscription, and Stripe information. Meanwhile, Wasp abstracts away all the Auth related entities dealing with `passwords`, `sessions`, and `socialLogins`, so you don't have to worry about these at all in your Prisma schema (if you want to learn more about this process, check out the [Wasp Auth Docs](https://wasp-lang.dev/docs/auth/overview)).
We store all pertinent information to the user, including identification, subscription, and payment processor information. Meanwhile, Wasp abstracts away all the Auth related entities dealing with `passwords`, `sessions`, and `socialLogins`, so you don't have to worry about these at all in your Prisma schema (if you want to learn more about this process, check out the [Wasp Auth Docs](https://wasp-lang.dev/docs/auth/overview)).

## Stripe and Subscriptions

Expand All @@ -44,7 +45,7 @@ We use Stripe to handle all of our subscription payments. The `User` entity has
entity User {=psl
id Int @id @default(autoincrement())
//...
stripeId String?
paymentProcessorUserId String? @unique
checkoutSessionId String?
subscriptionPlan String?
subscriptionStatus String?
Expand All @@ -54,19 +55,19 @@ entity User {=psl
psl=}
```

- `stripeId`: The Stripe customer ID. This is created by Stripe on checkout and used to identify the customer.
- `checkoutSessionId`: The Stripe checkout session ID. This is created by Stripe on checkout and used to identify the checkout session.
- `subscriptionPlan`: The subscription plan the user is on. This is set by the app and is used to determine what features the user has access to. By default, we have two plan: `hobby` and `pro`.
- `subscriptionStatus`: The subscription status of the user. This is set by Stripe and is used to determine whether the user has access to the app or not. By default, we have four statuses: `active`, `past_due`, `canceled`, and `deleted`.
- `credits` (optional): By default, a user is given 3 credits to trial your product before they have to pay. You can create a one-time purchase product in Stripe to allow users to purchase more credits if they run out.
- `paymentProcessorUserId`: The payment processor customer ID. This is created on checkout and used to identify the customer.
- `checkoutSessionId`: The payment processor checkout session ID. This is created by Stripe on checkout and used to identify the checkout session.
- `subscriptionPlan`: The subscription plan the user is on. This is set by the app and is used to determine what features the user has access to. By default, we have three plans: `hobby` and `pro` subscription plans, as well as a `credits10` one-time purchase plan.
- `subscriptionStatus`: The subscription status of the user. This is set by the payment processor and is used to determine whether the user has access to the app or not. By default, we have four statuses: `active`, `past_due`, `cancel_at_period_end`, and `deleted`.
- `credits` (optional): By default, a user is given 3 credits to trial your product before they have to pay. You can create a one-time purchase product in Stripe to allow users to purchase more credits if they run out, e.g. the `credits10` plan in the template.

### Subscription Statuses

In general, we determine if a user has paid for an initial subscription by checking if the `subscriptionStatus` field is set. This field is set by Stripe within your webhook handler and is used to signify more detailed information on the user's current status. By default, the template handles four statuses: `active`, `past_due`, `canceled_at_period_end`, and `deleted`.
In general, we determine if a user has paid for an initial subscription by checking if the `subscriptionStatus` field is set. This field is set by Stripe within your webhook handler and is used to signify more detailed information on the user's current status. By default, the template handles four statuses: `active`, `past_due`, `cancel_at_period_end`, and `deleted`.

- When `active` the user has paid for a subscription and has full access to the app.

- When `canceled_at_period_end`, the user has canceled their subscription and has access to the app until the end of their billing period.
- When `cancel_at_period_end`, the user has canceled their subscription and has access to the app until the end of their billing period.

- When `deleted`, the user has reached the end of their subscription period after canceling and no longer has access to the app.

Expand Down Expand Up @@ -96,17 +97,17 @@ if (subscription.status === 'past_due') {
}
```

See the client-side [authorization section](/guides/authorization) below for more info on how to handle these statuses within your app.
See the client-side [authorization section](/guides/authorization/) below for more info on how to handle these statuses within your app.

### Subscription Plans

The `subscriptionPlan` field is used to determine what features the user has access to.

By default, we have two plans: `hobby` and `pro`.
By default, we have three plans: `hobby` and `pro` subscription plans, as well as a `credits10` one-time purchase plan.

You can add more plans by adding more products and price IDs to your Stripe product and updating environment variables in your `.env.server` file as well as the relevant code in your app.

See the [Stripe Integration Guide](/guides/stripe-integration) for more info on how to do this.
See the [Payments Integration Guide](/guides/payments-integration/) for more info on how to do this.

## User Roles

Expand All @@ -130,4 +131,4 @@ As an Admin, a user has access to the Admin dashboard, along with the user table
If you'd like to give yourself and/or certain users admin privileges, follow the instructions in the [Admin Dashboard](/general/admin-dashboard/#permissions) section.
:::

As a general User, a user has access to the user-facing app that sits behind the login, but not the Admin dashboard. You can further restrict access to certain features within the app by following the [authorization guide](/guides/authorization).
As a general User, a user has access to the user-facing app that sits behind the login, but not the Admin dashboard. You can further restrict access to certain features within the app by following the [authorization guide](/guides/authorization/).
8 changes: 4 additions & 4 deletions opensaas-sh/blog/src/content/docs/guides/analytics.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ banner:
---
This guide will show you how to integrate analytics for your app. You can choose between [Google Analytics](#google-analytics) and [Plausible](#plausible).

Google Analytics is free, but uses cookies, so you'll probably want/need to implement the [Cookie Consent Modal](./cookie-consent.md) when using it.
Google Analytics is free, but uses cookies, so you'll probably want/need to implement the [Cookie Consent Modal](/guides/cookie-consent/) when using it.

Plausible is an open-source, privacy-friendly alternative to Google Analytics. **You DO NOT have to use the cookie consent modal** with Plausible, as it does not use cookies. It's also easier to use than Google if you use their hosted service, but be aware it is a paid feature. It is completely free if you want to self-host it, although this comes with some additional setup steps.

Expand Down Expand Up @@ -40,7 +40,7 @@ app OpenSaaS {
Go back to your Plausible dashboard, click on your username in the top right, and click on the `Settings` tab. Scroll down, find your API key and paste it into your `.env.server` file under the `PLAUSIBLE_API_KEY` variable.

:::note[No Cookies]
Plausible does not use cookies, so you don't need to add it to your [Cookie Consent Modal](./cookie-consent.md), hence the script can be added directly to `app.head` in your `main.wasp` file.
Plausible does not use cookies, so you don't need to add it to your [Cookie Consent Modal](/guides/cookie-consent/), hence the script can be added directly to `app.head` in your `main.wasp` file.
:::

### Self-hosted Plausible
Expand Down Expand Up @@ -77,7 +77,7 @@ Once you've created a new Property, some Installation Instructions will pop up.
```sh title="<your-google-analytics-id>"
https://www.googletagmanager.com/gtag/js?id=<your-google-analytics-id>
```
and copy and paste the Google Analytics ID into your `.env.client` file to get it working with the [Cookie Consent Modal](./cookie-consent.md) provided with this template:
and copy and paste the Google Analytics ID into your `.env.client` file to get it working with the [Cookie Consent Modal](/guides/cookie-consent/) provided with this template:

```sh title=".env.client"
REACT_APP_GOOGLE_ANALYTICS_ID=<your-google-analytics-id> # e.g. G-1234567890
Expand Down Expand Up @@ -105,7 +105,7 @@ Then, set up the Google Analytics API access by following these steps:

6. **Encode and add the Credentials:** Add the `client_email` and the `private_key` from your JSON Key file into your `.env.server` file. But be careful! Because Google uses a special PEM private key, you need to first convert the key to base64, otherwise you will run into errors parsing the key. To do this, in a terminal window, run the command below and paste the output into your `.env.server` file under the `GOOGLE_ANALYTICS_PRIVATE_KEY` variable:
```sh
echo -n "PRIVATE_KEY" | base64
echo -n "-----BEGIN PRIVATE KEY-----\nMI...A++eK\n-----END PRIVATE KEY-----\n" | base64
```

7. **Add your Google Analytics Property ID:** You will find the Property ID in your Google Analytics dashboard in the `Admin > Property > Property Settings > Property Details` section of your Google Analytics property (**not** your Google Cloud console). Add this 9-digit number to your `.env.server` file under the `GOOGLE_ANALYTICS_PROPERTY_ID` variable.
Expand Down
6 changes: 3 additions & 3 deletions opensaas-sh/blog/src/content/docs/guides/authorization.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@ This guide will help you get started with authorization in your SaaS app.

Authorization refers to what users can access in your app. This is useful for differentiating between users who have paid for different subscription tiers (e.g. "hobby" vs "pro"), or between users who have admin privileges and those who do not.

Authorization differs from [authentication](/guides/authentication) in that authentication refers to the process of verifying that a user is who they say they are (e.g. logging in with a username and password).
Authorization differs from [authentication](/guides/authentication/) in that authentication refers to the process of verifying that a user is who they say they are (e.g. logging in with a username and password).

To learn more about the different types of user permissions built into this SaaS template, including Stripe subscription tiers and statuses, check out the [User Permissions Reference](/general/user-permissions).
To learn more about the different types of user permissions built into this SaaS template, including Stripe subscription tiers and statuses, check out the [User Overview Reference](/general/user-overview/).

Also, check out our [blog post](https://wasp-lang.dev/blog/2022/11/29/permissions-in-web-apps) to learn more about authorization (access control) in web apps.

Expand Down Expand Up @@ -48,7 +48,7 @@ export default function Example({ user }: { user: User }) {
if (user.subscriptionStatus === 'past_due') {
return (<span>Your subscription is past due. Please update your payment information.</span>)
}
if (user.subscriptionStatus === 'canceled') {
if (user.subscriptionStatus === 'cancel_at_period_end') {
return (<span>Your will susbscription end on 01.01.2024</span>)
}
if (user.subscriptionStatus === 'active') {
Expand Down
4 changes: 2 additions & 2 deletions opensaas-sh/blog/src/content/docs/guides/cookie-consent.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ Below, we will guide you through the necessary steps to get the cookie consent m

### Google Analytics

What's impotant to note for this template is that we are simply using the `onAccept` callbacks to dynamically add or remove our [Google Analytics](./analytics.md/#google-analytics) cookies from the page. In order for it to work correctly with your app, you need to add your [Google Analytics ID](./analytics.md/#google-analytics) to your `.env.client` file.
What's impotant to note for this template is that we are simply using the `onAccept` callbacks to dynamically add or remove our [Google Analytics](/guides/analytics/#google-analytics) cookies from the page. In order for it to work correctly with your app, you need to add your [Google Analytics ID](/guides/analytics/#google-analytics) to your `.env.client` file.

```sh title=".env.client"
REACT_APP_GOOGLE_ANALYTICS_ID=G-1234567890
Expand All @@ -45,7 +45,7 @@ cc_cookie # Cookie Consent cookie. The name of this cookie can be changed in the

### Plausible Analytics

If you decide to go with [Plausible Analytics](./analytics.md/#plausible), you **DO NOT** need to ask users for their consent to use cookies because Plausible, as a privacy-first analytics provider, [does not use cookies](https://plausible.io/privacy-focused-web-analytics). Instead, It collects website usage data anonymously and in aggregate form only, without any personally identifiable information
If you decide to go with [Plausible Analytics](/guides/analytics/#plausible), you **DO NOT** need to ask users for their consent to use cookies because Plausible, as a privacy-first analytics provider, [does not use cookies](https://plausible.io/privacy-focused-web-analytics). Instead, It collects website usage data anonymously and in aggregate form only, without any personally identifiable information

**By avoiding cookies, Plausible Analytics avoids the need for cookie consent banners.**

Expand Down
2 changes: 1 addition & 1 deletion opensaas-sh/blog/src/content/docs/guides/deploying.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ Make sure you've got all your API keys and environment variables set up before y

#### Env Vars
##### Payment Processor Vars
In the [Payments Processor integration guide](/guides/payments-integration), you set up your API keys using test keys and test product ids. You'll need to get the live/production versions of those keys. To get these, repeat the instructions in the [Integration Guide](/guides/payments-integration) without being in test mode. Add the new keys to your deployed environment secrets.
In the [Payments Processor integration guide](/guides/payments-integration/), you set up your API keys using test keys and test product ids. You'll need to get the live/production versions of those keys. To get these, repeat the instructions in the [Integration Guide](/guides/payments-integration/) without being in test mode. Add the new keys to your deployed environment secrets.

##### Other Vars
Many of your other environment variables will probably be the same as in development, but you should double-check that they are set correctly for production.
Expand Down
10 changes: 5 additions & 5 deletions opensaas-sh/blog/src/content/docs/guides/payments-integration.md
Original file line number Diff line number Diff line change
Expand Up @@ -132,11 +132,6 @@ See this [GitHuh issue](https://github.com/stripe/stripe-cli/issues/933) for mor
stripe listen --forward-to localhost:3001/payments-webhook
```

:::note[Webhook URL]
In older versions of this template, the webhook URL was `http://localhost:3001/stripe-webhook`.
If you're using an older version, make sure to use the url that matches the webhook url in your `main.wasp` file payemnts API definition.
:::

You should see a message like this:

```sh
Expand All @@ -159,6 +154,11 @@ stripe login
stripe listen --forward-to localhost:3001/payments-webhook
```

:::caution[Webhook URL]
In older versions of this template, the webhook URL was `http://localhost:3001/stripe-webhook`.
If you're using an older version, **make sure to use the url that matches the webhook url in your `main.wasp` file payemnts API definition.**
:::

remember to copy and paste the outputted webhook signing secret (`whsec_...`) into your `.env.server` file under `STRIPE_WEBHOOK_SECRET=` if you haven't already.

- In another terminal window, trigger a test event:
Expand Down
2 changes: 1 addition & 1 deletion opensaas-sh/blog/src/content/docs/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ The template itself is built on top of some very powerful tools and frameworks,

- 🐝 [Wasp](https://wasp-lang.dev) - a full-stack React, NodeJS, Prisma framework with superpowers
- 🚀 [Astro](https://starlight.astro.build/) - Astro's lightweight "Starlight" template for documentation and blog
- 💸 [Stripe](https://stripe.com) - for products and payments
- 💸 [Stripe](https://stripe.com) or [Lemon Squeezy](https://lemonsqueezy.com/) - for products and payments
- 📈 [Plausible](https://plausible.io) or [Google](https://analytics.google.com/) Analytics
- 🤖 [OpenAI](https://openai.com) - OpenAI API integrated into the app or [Replicate](https://replicate.com/) (coming soon 👀)
- 📦 [AWS S3](https://aws.amazon.com/s3/) - for file uploads
Expand Down
6 changes: 3 additions & 3 deletions opensaas-sh/blog/src/content/docs/start/guided-tour.md
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,7 @@ For development purposes, Wasp provides a `Dummy` email sender which Open SaaS c
```
:::

We will explain more about these auth methods, and how to properly integrate them into your app, in the [Authentication Guide](/guides/authentication).
We will explain more about these auth methods, and how to properly integrate them into your app, in the [Authentication Guide](/guides/authentication/).

### Subscription Payments with Stripe or Lemon Squeezy

Expand Down Expand Up @@ -239,7 +239,7 @@ api paymentsWebhook {

Within the webhook handler, we look for specific events that the Payment Processor sends us to let us know which payment was completed and for which user. Then we update the user's subscription status in the database.

To learn more about configuring the app to handle your products and payments, check out the [Payments Integration guide](/guides/payments-integration).
To learn more about configuring the app to handle your products and payments, check out the [Payments Integration guide](/guides/payments-integration/).

:::tip[Star our Repo on GitHub! 🌟]
We've packed in a ton of features and love into this SaaS starter, and offer it all to you for free!
Expand Down Expand Up @@ -269,7 +269,7 @@ job dailyStatsJob {
}
```

For more info on integrating Plausible or Google Analytics, check out the [Analytics guide](/guides/analytics).
For more info on integrating Plausible or Google Analytics, check out the [Analytics guide](/guides/analytics/).

## App Customization Walkthrough

Expand Down
Loading