[Canonical page](<https://docs.dhtmlx.com/planning-engine/rust/api/core/project/analytics-options/>)
[Full documentation index](<https://docs.dhtmlx.com/planning-engine/llms.txt>)


# AnalyticsOptions

Selects the analytics that a call adds to [`ScheduleResult::analytics`](<https://docs.dhtmlx.com/planning-engine/rust/api/core/results/schedule-result.md#analytics>). It's set as the `analytics` field of [`SolveOptions`](<https://docs.dhtmlx.com/planning-engine/rust/api/core/project/solve-options.md>), [`PreviewOptions`](<https://docs.dhtmlx.com/planning-engine/rust/api/core/project/preview-options.md>) and [`AnalyzeOptions`](<https://docs.dhtmlx.com/planning-engine/rust/api/core/project/analyze-options.md>). `AnalyticsOptions::default()` requests nothing.

## Declaration

```rust
#[derive(Clone, Debug, Default, PartialEq)]
pub struct AnalyticsOptions {
    pub slack: bool,
    pub critical_path: bool,
}
```

## Fields

| Field | Type | Default | Description |
|---|---|---|---|
| `slack` | `bool` | `false` | Fills [`Analytics::slack`](<https://docs.dhtmlx.com/planning-engine/rust/api/core/results/analytics.md>) with one [`TaskSlack`](<https://docs.dhtmlx.com/planning-engine/rust/api/core/results/task-slack.md>) entry per active leaf task and milestone. |
| `critical_path` | `bool` | `false` | Fills [`Analytics::critical_path`](<https://docs.dhtmlx.com/planning-engine/rust/api/core/results/analytics.md>) with the critical tasks and links as a [`Critical`](<https://docs.dhtmlx.com/planning-engine/rust/api/core/results/critical.md>). |

When both fields are `false`, `result.analytics` is `None`. When at least one is `true`, `result.analytics` is `Some`, and fields that weren't requested stay `None`. Check [`Analytics::status`](<https://docs.dhtmlx.com/planning-engine/rust/api/core/results/analytics-status.md>) before reading them.

## Example

```rust
use plen_core::{AnalyticsOptions, Project, ProjectData, SolveOptions};

fn main() -> Result<(), Box<dyn std::error::Error>> {
    let mut project = Project::default();
    let options = SolveOptions {
        analytics: AnalyticsOptions {
            slack: true,
            critical_path: true,
        },
        ..Default::default()
    };

    let result = project.solve(Some(ProjectData::default()), &options)?;
    if let Some(analytics) = &result.analytics {
        if let Some(critical) = &analytics.critical_path {
            println!("{} critical tasks", critical.tasks.len());
        }
    }
    Ok(())
}
```

## Related

- [`Analytics`](<https://docs.dhtmlx.com/planning-engine/rust/api/core/results/analytics.md>) - the result section these flags fill
- [`SolveOptions`](<https://docs.dhtmlx.com/planning-engine/rust/api/core/project/solve-options.md>) - carries it for `Project::solve`
- [`Project::analyze`](<https://docs.dhtmlx.com/planning-engine/rust/api/core/project/project.md#analyze>) - computes analytics without scheduling
- [Critical path and slack](<https://docs.dhtmlx.com/planning-engine/rust/scheduling/critical-path-and-slack.md#requesting-analytics>) - requesting and reading critical path and slack
