> ## Documentation Index
> Fetch the complete documentation index at: https://backstage.spotify.com/docs/llms.txt
> Use this file to discover all available pages before exploring further.

# Tech Insights

> Expose facts from the Backstage Tech Insights backend as Soundcheck facts, bridging Tech Insights data into Soundcheck checks.

The Tech Insights integration plugin for [Soundcheck](https://backstage.spotify.com/plugins/soundcheck/)
exposes facts from [Tech Insight backend](https://github.com/backstage/community-plugins/blob/main/workspaces/tech-insights/plugins/tech-insights-backend/README.md), allowing them to be used in Soundcheck checks.

## Prerequisites

### Add the TechInsightsHubFactCollector to Soundcheck

First, add the `@spotify/backstage-plugin-soundcheck-backend-module-techinsights` package:

```bash theme={"theme":{"light":"github-light","dark":"dracula"}}
yarn workspace backend add @spotify/backstage-plugin-soundcheck-backend-module-techinsights
```

Then add the following to your `packages/backend/src/index.ts` file:

```ts packages/backend/src/index.ts highlight={4} theme={"theme":{"light":"github-light","dark":"dracula"}}
const backend = createBackend();

backend.add(import('@spotify/backstage-plugin-soundcheck-backend'));
backend.add(
  import('@spotify/backstage-plugin-soundcheck-backend-module-techinsights'),
);
// ...

backend.start();
```

Consult the [Soundcheck Backend documentation](../../../setup-and-installation#backend-setup) for additional details on setting up the Soundcheck backend.

### Rate Limiting (Optional)

This fact collector can be rate limited in Soundcheck using the following configuration:

```yaml theme={"theme":{"light":"github-light","dark":"dracula"}}
soundcheck:
  job:
    workers:
      techinsights:
        limiter:
          max: 1000
          duration: 60000
```

In this example, the fact collector is limited to 1000 executions per minute.

This fact collector handles 429 rate limit errors from Tech Insights. Soundcheck will automatically wait and retry requests that are rate limited.

## Using TechInsight facts in Soundcheck

Soundcheck fact references for this plugin follow the format `techinsights:default/<id>` where `<id>`
is the fact retriever identifier from Tech Insights.

For example, if there is a Tech Insights fact retriever with an ID of `entityOwnershipFactRetriever`, its Soundcheck fact reference would be
`techinsights:default/entityOwnershipFactRetriever`.

Soundcheck fact references enable facts from Tech Insights to be used in Soundcheck check. Here is an example of a Soundcheck check that makes use of a fact from Tech Insights.

```yaml theme={"theme":{"light":"github-light","dark":"dracula"}}
id: has-owner
rule:
  factRef: techinsights:default/entityOwnershipFactRetriever
  path: $.hasOwner
  operator: equal
  value: true
```

When this check is executed, it will pull the fact(s) with a fact retriever identifier of `entityOwnershipFactRetriever` from Tech Insights and perform the specified check logic on it.

Currently, the collection of facts from Tech Insights is not scheduled or cached. Tech Insights facts are only
collected on demand, when a check using a Tech Insights fact is executed (which can be scheduled).
