@prisma/extension-optimize 0.0.0-dev.202408261001 → 0.0.0-dev.202408261016

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/README.md +50 -27
  2. package/package.json +2 -2
package/README.md CHANGED
@@ -13,19 +13,26 @@ Prisma is leading Data DX, a philosophy that promotes simplicity in data-driven
13
13
 
14
14
  ## Getting started with Prisma Optimize
15
15
 
16
- Enabling Prisma Optimize in your local development workflow is really simple.
16
+ ### Resources
17
17
 
18
- ### 1. Install the extension
18
+ You can explore Optimize with the following resources:
19
19
 
20
- ```
21
- npm install @prisma/extension-optimize --save-dev
22
- ```
20
+ - [Get started](https://pris.ly/optimize/r/getting-started)
21
+ - [Documentation](https://pris.ly/d/optimize)
22
+ - [Prisma Data Platform](https://console.prisma.io/login?utm_source=github&utm_medium=optimize-readme)
23
+
24
+ ### Using Optimize
25
+
26
+ #### 1. Launch Optimize
27
+
28
+ 1. Log in to your [Prisma Data Platform](https://console.prisma.io/login?utm_source=github&utm_medium=optimize-readme) account.
29
+ 2. Access and launch the Optimize dashboard by following the instructions here.
23
30
 
24
- > Starting a Prisma ORM project from scratch? Follow https://www.prisma.io/docs/getting-started
31
+ #### 2. Add Optimize to your application
25
32
 
26
- ### 2. Enable the `tracing` preview feature in your Prisma schema
33
+ ##### 2.1. Update Your schema.prisma file
27
34
 
28
- Prisma Optimize uses [Prisma ORM's OpenTelemetry tracing functionality](https://www.prisma.io/docs/orm/prisma-client/observability-and-logging/opentelemetry-tracing). Enabled it in your Prisma schema:
35
+ Prisma Optimize uses [Prisma ORM's OpenTelemetry tracing functionality](https://www.prisma.io/docs/orm/prisma-client/observability-and-logging/opentelemetry-tracing). In the `generator` block of your Prisma schema, add the tracing preview feature:
29
36
 
30
37
  ```diff
31
38
  generator client {
@@ -34,37 +41,53 @@ Prisma Optimize uses [Prisma ORM's OpenTelemetry tracing functionality](https://
34
41
  }
35
42
  ```
36
43
 
37
- After enabling the `tracing` preview feature, you need to re-generate your Prisma Client:
44
+ Then, generate the Prisma Client:
38
45
 
39
- ```
46
+ ```shell
40
47
  npx prisma generate
41
48
  ```
42
49
 
43
- ### 3. Extend your Prisma Client with Prisma Optimize support
50
+ ##### 2.2. Install the Optimize Prisma Client extension
51
+
52
+ Install the latest versions of Prisma Client and the Optimize extension:
53
+
54
+ ```shell
55
+ npm install @prisma/client@latest @prisma/extension-optimize
56
+ ```
57
+
58
+ ##### 2.3. Create an API Key via Optimize's UI and add it to your .env file
59
+
60
+ Generate an Optimize API key by following the instructions [here](https://pris.ly/optimize/r/api-token-generation) and add it to your .env file:
61
+
62
+ ```env
63
+ OPTIMIZE_API_KEY="YOUR_OPTIMIZE_API_KEY"
64
+ ```
65
+
66
+ ##### 2.4. Extend your Prisma Client instance with the Optimize extension
67
+
68
+ Extend your existing Prisma Client instance with the Optimize extension:
44
69
 
45
70
  ```typescript
46
71
  import { PrismaClient } from "@prisma/client";
47
72
  import { withOptimize } from "@prisma/extension-optimize";
48
73
 
49
- const prisma = new PrismaClient().$extends(withOptimize());
74
+ const prisma = new PrismaClient().$extends(withOptimize({ token: process.env.OPTIMIZE_API_KEY }));
50
75
  ```
51
76
 
52
- The extension will orchestrate the user experience around Prisma Optimize. When running your app, you will:
77
+ ##### 2.5. Use Prisma Optimize to generate insights
78
+
79
+ Follow these steps to start generating query insights with Prisma Optimize:
80
+
81
+ 1. In the Optimize dashboard, click the Start recording button, then run your app.
82
+
83
+ 2. After your app runs and insights are generated for the desired queries, click the Stop recording button.
84
+
85
+ 3. Explore individual query details by clicking on them, and check the Recommendations tab for any suggested improvements to enhance query performance.
53
86
 
54
- - Be required to log into the Prisma Data Platform through your GitHub account
55
- - And be instructed to visit the URL of your Optimize dashboard:
87
+ > **_NOTE:_** Use the [AI Explainer](https://pris.ly/optimize/r/ai-explainer) feature to understand recommendations and apply them within your Prisma model context.
56
88
 
57
- ```terminal
58
- $ tsx index.ts
59
-
60
- ┌─────────────────────────────────┐
61
- │ See your Optimize dashboard at: │
62
- │ https://optimize.prisma.io/ │
63
- └─────────────────────────────────┘
64
-
65
- [...]
66
- ```
89
+ For a hands-on learning experience, try out the [step-by-step example](https://github.com/prisma/prisma-examples/optimize/starter).
67
90
 
68
- ## Got feedback?
91
+ ### Need help?
69
92
 
70
- Please [submit an issue](https://github.com/prisma/optimize-feedback/issues/new/choose) or [join a discussion](https://github.com/prisma/optimize-feedback/discussions) in our [feedback repository](https://github.com/prisma/optimize-feedback/)
93
+ If you need assistance, reach out in the #help-and-questions channel on our [Discord](https://pris.ly/discord), or connect with our community to see how others are using Optimize.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@prisma/extension-optimize",
3
- "version": "0.0.0-dev.202408261001",
3
+ "version": "0.0.0-dev.202408261016",
4
4
  "sideEffects": false,
5
5
  "description": "",
6
6
  "main": "./dist/index.js",
@@ -28,7 +28,7 @@
28
28
  "hono": "4.4.6",
29
29
  "tsup": "8.0.2",
30
30
  "vitest": "1.4.0",
31
- "common": "0.0.0-dev.202408261001"
31
+ "common": "0.0.0-dev.202408261016"
32
32
  },
33
33
  "peerDependencies": {
34
34
  "@prisma/client": "5.x"