docs: updates for breaking changes (#9558)

- Update modules registration
- Update `medusa-config.js` to `medusa-config.ts`
- Update the out directory in the admin deployment guide
- Update logger imports
- Other fixes

Note: will need to re-generate references afterwards

Closes #9548
This commit is contained in:
Shahed Nasser authored and GitHub committed 2024-10-14 10:40:30 +00:00
1 parent 2a9fc0e514
commit b6df24463d
53 files changed
+319 -324

No files matched your search

@@ -44,14 +44,13 @@ Also, install the dependencies relevant for the exporter you use. If you're usin
npm install @opentelemetry/exporter-zipkin
```
### Add instrumentation.js
### Add instrumentation.ts
Next, create the file `instrumentation.js` with the following content:
Next, create the file `instrumentation.ts` with the following content:
```js title="instrumentation.js"
const { registerOtel } = require("@medusajs/medusa")
// If using an exporter other than Zipkin, require it here.
const { ZipkinExporter } = require("@opentelemetry/exporter-zipkin")
```ts title="instrumentation.ts"
import { registerOtel } from "@medusajs/medusa"
import { ZipkinExporter } from "@opentelemetry/exporter-zipkin"
// If using an exporter other than Zipkin, initialize it here.
const exporter = new ZipkinExporter({
@@ -72,7 +71,7 @@ export function register() {
}
```
In the `instrumentation.js` file, you export a `register` function that uses Medusa's `registerOtel` utility function.
In the `instrumentation.ts` file, you export a `register` function that uses Medusa's `registerOtel` utility function.
You also initialize an instance of the exporter, such as Zipkin, and pass it to the `registerOtel` function.
@@ -26,13 +26,13 @@ export const highlights = [
]
```ts title="src/jobs/log-message.ts" highlights={highlights}
import { Logger } from "@medusajs/medusa"
import { MedusaContainer } from "@medusajs/framework/types"
import { ContainerRegistrationKeys } from "@medusajs/framework/utils"
export default async function myCustomJob(
container: MedusaContainer
) {
const logger: Logger = container.resolve("logger")
const logger = container.resolve(ContainerRegistrationKeys.LOGGER)
logger.info("I'm using the logger!")
}
@@ -129,11 +129,14 @@ The `Logger` class has an `activity` method used to log a message of level `info
For example:
```ts title="src/loaders/log-message.ts"
import { Logger, MedusaContainer } from "@medusajs/medusa"
```ts title="src/jobs/log-message.ts"
import { MedusaContainer } from "@medusajs/framework/types"
import { ContainerRegistrationKeys } from "@medusajs/framework/utils"
export default async (container: MedusaContainer) => {
const logger = container.resolve<Logger>("logger")
export default async function myCustomJob(
container: MedusaContainer
) {
const logger = container.resolve(ContainerRegistrationKeys.LOGGER)
const activityId = logger.activity("First log message")
@@ -141,7 +144,6 @@ export default async (container: MedusaContainer) => {
logger.success(activityId, "Last log message")
}
```
The `activity` method returns the ID of the started activity. This ID can then be passed to one of the following methods of the `Logger` class: