Skip to content
Merged
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
12 changes: 6 additions & 6 deletions platform-includes/llm-rules-logs/javascript.nextjs.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,11 @@

````markdown {filename:rules.md}

# Logs
# Logs

- Where logs are used, ensure Sentry is imported using `import * as Sentry from "@sentry/nextjs"`
- Where logs are used, ensure Sentry is imported using `import * as Sentry from "@sentry/nextjs"`
- Enable logging in Sentry using `Sentry.init({ _experiments: { enableLogs: true } })`
- Reference the logger using `const { logger } = Sentry`
- Sentry initialization needs to be updated to include the `logger` integration.
- Sentry offers a `consoleLoggingIntegration` that can be used to log specific console error types automatically without instrumenting the individual logger calls

## Configuration
Expand All @@ -25,7 +25,7 @@ Sentry.init({
_experiments: {
enableLogs: true,
},

});
```

Expand All @@ -41,7 +41,7 @@ Sentry.init({
});
```

## Logger Examples
## Logger Examples

```javascript
import * as Sentry from "@sentry/nextjs";
Expand All @@ -65,4 +65,4 @@ logger.fatal("Database connection pool exhausted", {
});
```
````
</Expandable>
</Expandable>
12 changes: 6 additions & 6 deletions platform-includes/llm-rules-logs/javascript.node.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,11 @@

````markdown {filename:rules.md}

# Logs
# Logs

- Where logs are used, ensure Sentry is imported using `import * as Sentry from "@sentry/node"`
- Where logs are used, ensure Sentry is imported using `import * as Sentry from "@sentry/node"`
- Enable logging in Sentry using `Sentry.init({ _experiments: { enableLogs: true } })`
- Reference the logger using `const { logger } = Sentry`
- Sentry initialization needs to be updated to include the `logger` integration.
- Sentry offers a `consoleLoggingIntegration` that can be used to log specific console error types automatically without instrumenting the individual logger calls

## Configuration
Expand All @@ -25,7 +25,7 @@ Sentry.init({
_experiments: {
enableLogs: true,
},

});
```

Expand All @@ -41,7 +41,7 @@ Sentry.init({
});
```

## Logger Examples
## Logger Examples

```javascript
import * as Sentry from "@sentry/node";
Expand All @@ -65,4 +65,4 @@ logger.fatal("Database connection pool exhausted", {
});
```
````
</Expandable>
</Expandable>
12 changes: 6 additions & 6 deletions platform-includes/llm-rules-logs/javascript.react.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,11 @@

````markdown {filename:rules.md}

# Logs
# Logs

- Where logs are used, ensure Sentry is imported using `import * as Sentry from "@sentry/react"`
- Where logs are used, ensure Sentry is imported using `import * as Sentry from "@sentry/react"`
- Enable logging in Sentry using `Sentry.init({ _experiments: { enableLogs: true } })`
- Reference the logger using `const { logger } = Sentry`
- Sentry initialization needs to be updated to include the `logger` integration.
- Sentry offers a `consoleLoggingIntegration` that can be used to log specific console error types automatically without instrumenting the individual logger calls

## Configuration
Expand All @@ -23,7 +23,7 @@ Sentry.init({
_experiments: {
enableLogs: true,
},

});
```

Expand All @@ -39,7 +39,7 @@ Sentry.init({
});
```

## Logger Examples
## Logger Examples

```javascript
import * as Sentry from "@sentry/react";
Expand All @@ -63,4 +63,4 @@ logger.fatal("Database connection pool exhausted", {
});
```
````
</Expandable>
</Expandable>
145 changes: 68 additions & 77 deletions platform-includes/llm-rules-platform/_default.mdx
Original file line number Diff line number Diff line change
@@ -1,21 +1,82 @@
<Expandable title="AI Rules for Cursor or Windsurf" copy={true}>

Sentry provides a set of rules you can use to help your LLM use Sentry correctly. Copy this file and add it to your projects rules configuration.
Sentry provides a set of rules you can use to help your LLM use Sentry correctly. Copy this file and add it to your projects rules configuration.

````markdown {filename:rules.md}

These examples should be used as guidance when configuring Sentry functionlaity within a project.

# Error / Exception Tracking

- Use `Sentry.captureException(error)` to capture an exception and log the error in Sentry.
- Use this in try catch blocks or areas where exceptions are expected

# Logs
# Tracing Examples

- Spans should be created for meaningful actions within an applications like button clicks, API calls, and function calls
- Use the `Sentry.startSpan` function to create a span
- Child spans can exist within a parent span

## Custom Span instrumentation in component actions

- Name custom spans with meaningful names and operations.
- Attach attributes based on relevant information and metrics from the request

```javascript
function TestComponent() {
const handleTestButtonClick = () => {
// Create a transaction/span to measure performance
Sentry.startSpan(
{
op: "ui.click",
name: "Test Button Click",
},
(span) => {
const value = "some config";
const metric = "some metric";

// Metrics can be added to the span
span.setAttribute("config", value);
span.setAttribute("metric", metric);

doSomething();
}
);
};

return (
<button type="button" onClick={handleTestButtonClick}>
Test Sentry
</button>
);
}
```

## Custom span instrumentation in API calls

- Name custom spans with meaningful names and operations.
- Attach attributes based on relevant information and metrics from the request

```javascript
async function fetchUserData(userId) {
return Sentry.startSpan(
{
op: "http.client",
name: `GET /api/users/${userId}`,
},
async () => {
const response = await fetch(`/api/users/${userId}`);
const data = await response.json();
return data;
}
);
}
```

# Logs

- Where logs are used, ensure Sentry is imported using `import * as Sentry from "@sentry/browser"`
- Where logs are used, ensure Sentry is imported using `import * as Sentry from "@sentry/browser"`
- Enable logging in Sentry using `Sentry.init({ _experiments: { enableLogs: true } })`
- Reference the logger using `const { logger } = Sentry`
- Sentry initialization needs to be updated to include the `logger` integration.
- Sentry offers a `consoleLoggingIntegration` that can be used to log specific console error types automatically without instrumenting the individual logger calls

## Configuration
Expand All @@ -31,7 +92,6 @@ Sentry.init({
_experiments: {
enableLogs: true,
},

});
```

Expand All @@ -47,7 +107,7 @@ Sentry.init({
});
```

## Logger Examples
## Logger Examples

```javascript
import * as Sentry from "@sentry/browser";
Expand All @@ -70,75 +130,6 @@ logger.fatal("Database connection pool exhausted", {
activeConnections: 100,
});
```

# Tracing Examples

- Spans should be created for meaningful actions within an applications like button clicks, API calls, and function calls
- Use the `Sentry.startSpan` function to create a span
- Child spans can exist within a parent span

## Custom Span instrumentation in component actions

- Name custom spans with meaningful names and operations.
- Attach attributes based on relevant information and metrics from the request

```javascript
function TestComponent() {
const handleTestButtonClick = () => {
// Create a transaction/span to measure performance
Sentry.startSpan({
op: "ui.click",
name: "Test Button Click"
}, async (span) => {

const value = "some config"
const metric = "some metric"

// Metrics can be added to the span
span.setAttribute("config", value)
span.setAttribute("metric", metric)

doSomething();
});
};

return (
<button
type="button"
onClick={handleTestButtonClick}
>
Test Sentry
</button>
);
}
```

## Custom span instrumentation in API calls

- Name custom spans with meaningful names and operations.
- Attach attributes based on relevant information and metrics from the request

```javascript
async function fetchUserData(userId) {
return Sentry.startSpan(
{
op: "http.client",
name: `GET /api/users/${userId}`,
},
async () => {
try {
const response = await fetch(`/api/users/${userId}`);
const data = await response.json();
return data;
} catch (error) {
// Capture error with the current span
Sentry.captureException(error);
throw error;
}
}
);
}
```
````

</Expandable>
</Expandable>
Loading