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

# Angular

> Install Tracelit in an Angular project by calling init() in AppComponent's ngOnInit lifecycle hook.

```bash theme={null}
npm install @tracelit/tracker
```

Call `init()` in `ngOnInit` of your root `AppComponent`:

```ts theme={null}
// src/app/app.component.ts
import { Component, OnInit } from '@angular/core'
import { init } from '@tracelit/tracker'

@Component({
  selector: 'app-root',
  templateUrl: './app.component.html'
})
export class AppComponent implements OnInit {
  ngOnInit() {
    init({ token: 'YOUR_TOKEN_HERE', environment: 'production' })
  }
}
```

<Warning>
  Always set `environment`. Only `"production"` and `"development"` are accepted. If omitted, events default to `development`.
</Warning>

Tracelit detects Angular Router navigation automatically via `history.pushState` — no router hooks needed.

***

## Adding user identity

Inject your auth service and call `identify()` once the user is resolved:

```ts theme={null}
// src/app/app.component.ts
import { Component, OnInit } from '@angular/core'
import { init, identify, reset } from '@tracelit/tracker'
import { AuthService } from './auth.service'

@Component({
  selector: 'app-root',
  templateUrl: './app.component.html'
})
export class AppComponent implements OnInit {
  constructor(private auth: AuthService) {}

  ngOnInit() {
    init({ token: 'YOUR_TOKEN_HERE', environment: 'production' })

    this.auth.user$.subscribe(user => {
      if (user) identify(user.id, { email: user.email, plan: user.plan })
      else reset()
    })
  }
}
```

***

## LLM Prompt

Paste this into your coding assistant to install Tracelit for you:

```text theme={null}
Install Tracelit in my Angular project.
Initialize @tracelit/tracker in AppComponent ngOnInit with:
init({ token: 'YOUR_TOKEN_HERE', environment: 'production' })
Make minimal edits, show changed files, and provide a short verification checklist.
```

***

## What's next?

| Topic                                   | Description                                   | Guide                             |
| --------------------------------------- | --------------------------------------------- | --------------------------------- |
| <Icon icon="user" /> **Identify users** | Full guide to linking sessions to real users. | [Read](/tracking/identify-users)  |
| <Icon icon="tag" /> **Feature tagging** | Tag flows in session replays.                 | [Read](/features/feature-tagging) |
