You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
* Add prefetchConfig function
* Make running of vercel function async
* Adjust vercion of sdk
* Adjust example
* Fix for test
* Adjust README
* Add check for config expiration to avoid running Vercel Function too much
* Add section about using cron job to readme
* Adjust readme
This SDK is inteded to be used in [Vercel Edge Middleware](https://vercel.com/docs/functions/edge-middleware)
26
+
This SDK is inteded to be used in [Vercel Edge Middleware](https://vercel.com/docs/functions/edge-middleware) and in [Vercel Function](https://vercel.com/docs/functions/quickstart) for hydration and keeping stored config up-to-date.
27
+
27
28
[Vercel Edge Config Store ](https://vercel.com/docs/storage/edge-config/using-edge-config) is required for storing Eppo configs.
28
29
29
30
#### Example of usage in middleware.ts file
@@ -67,6 +68,8 @@ export async function middleware(request: NextRequest) {
Your middleware, each time running, will start this cloud function (by doing an async request to the url specidifed in `vercelParams.vercelFunctionUrl`), and it will fetch and store configs.
158
+
159
+
The flow is next:
160
+
- if config stored in Vercel Config Store is not outdated, middleware will give return up-to-date assignment;
161
+
- if config stored in Vercel Config Store is outdated, middleware will still give an assignment requested, just outdated, and send a request to start Vercel Function to prefetch up-to-date config; Next run of the middleware will give an updated result;
162
+
163
+
164
+
### Vercel Cron Job
165
+
166
+
You can hydrate data using [Vercel Cron Job](https://vercel.com/guides/how-to-setup-cron-jobs-on-vercel).
167
+
For this, in your middleware, do not provide a URL to Vercel Function.
168
+
Create a Vercel Function and as in the example above, and create a cron job like:
169
+
170
+
```ts
171
+
{
172
+
"crons": [
173
+
{
174
+
"path": "/api/eppo-prefetch",
175
+
"schedule": "0 5 * * *"
176
+
}
177
+
]
178
+
}
179
+
```
180
+
98
181
## Assignment functions
99
182
100
183
Every Eppo flag has a return type that is set once on creation in the dashboard. Once a flag is created, assignments in code should be made using the corresponding typed function:
0 commit comments