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
32 changes: 30 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -132,13 +132,14 @@ $activitysmith->notifications->send(

## Live Activities

There are five types of Live Activities:
There are six types of Live Activities:

- `stats`: best for showing business numbers side by side, such as revenue, sales, new users, conversion, refunds, or any other value you want visible at a glance
- `metrics`: best for live percentage values that change often, like server CPU, memory usage, disk usage, or error rate
- `segmented_progress`: best for anything that moves through clear stages, like deployments, onboarding flows, backups, ETL pipelines, migrations, and AI agent runs
- `progress`: best for tracking real-time progress with percentage, like tasks, backups, migrations, syncs, or uploads
- `alert`: best for status updates, such as feature adoption, reactivation, onboarding blockers, incidents, escalations, and other operational states
- `timer`: best for countdowns and elapsed runtime, like benchmark runs, uploads, backups, transcodes, and long-running jobs

### Start & Update Live Activity

Expand Down Expand Up @@ -266,6 +267,33 @@ $activitysmith->liveActivities->stream(
);
```

#### Timer

<p align="center">
<img
src="https://cdn.activitysmith.com/features/timer-live-activity.png"
alt="Timer Live Activity showing a benchmark run countdown"
width="680"
/>
</p>

```php
$activitysmith->liveActivities->stream(
'benchmark-run',
contentState: LiveActivityContentState::make(
title: 'Benchmark Run',
subtitle: 'sampling',
type: 'timer',
durationSeconds: 300,
color: 'cyan',
),
);
```

For a countdown, send `duration_seconds`. You can update `title`, `subtitle`, `color`, or any other visible field as the work changes. Leave `duration_seconds` out unless you want to change the timer.

To start at 00:00 and count up, set `counts_down: false` and leave out `duration_seconds`.

### End Live Activity

Call `endStream(...)` with the same `streamKey` to dismiss the Live Activity. You can include final values before it is removed. By default, iOS removes the Live Activity after two minutes. Set `autoDismissMinutes` to choose a different dismissal time, including `0` for immediate dismissal.
Expand Down Expand Up @@ -375,7 +403,7 @@ Add more context to Live Activities with icons and badges.

#### Icon

Supported Live Activity types: `stats`, `metrics`, `progress`, `segmented_progress`, and `alert`.
Supported Live Activity types: `stats`, `metrics`, `progress`, `segmented_progress`, `alert`, and `timer`.

<p align="center">
<img
Expand Down
110 changes: 107 additions & 3 deletions generated/Model/ContentStateEnd.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
* ContentStateEnd Class Doc Comment
*
* @category Class
* @description End payload requires title. For segmented_progress include current_step and optionally number_of_steps. For progress include percentage or value with upper_limit. For metrics and stats include a non-empty metrics array. For alert include message. Optional icon is supported by all Live Activity types. Optional badge is supported by alert, progress, and segmented_progress. Type is optional when ending an existing activity. You can send an updated number_of_steps here if the workflow changed after start.
* @description End payload requires title. For segmented_progress include current_step and optionally number_of_steps. For progress include percentage or value with upper_limit. For metrics and stats include a non-empty metrics array. For alert include message. For timer, omit duration_seconds to preserve and freeze the latest timer state. Optional icon is supported by all Live Activity types. Optional badge is supported by alert, progress, and segmented_progress. Type is optional when ending an existing activity. You can send an updated number_of_steps here if the workflow changed after start.
* @package ActivitySmith\Generated
* @author OpenAPI Generator team
* @link https://openapi-generator.tech
Expand Down Expand Up @@ -65,6 +65,9 @@ class ContentStateEnd implements ModelInterface, ArrayAccess, \JsonSerializable
'percentage' => 'float',
'value' => 'float',
'upperLimit' => 'float',
'durationSeconds' => 'float',
'countsDown' => 'bool',
'isRunning' => 'bool',
'metrics' => '\ActivitySmith\Generated\Model\ActivityMetric[]',
'message' => 'string',
'icon' => '\ActivitySmith\Generated\Model\LiveActivityAlertIcon',
Expand All @@ -91,6 +94,9 @@ class ContentStateEnd implements ModelInterface, ArrayAccess, \JsonSerializable
'percentage' => null,
'value' => null,
'upperLimit' => null,
'durationSeconds' => null,
'countsDown' => null,
'isRunning' => null,
'metrics' => null,
'message' => null,
'icon' => null,
Expand All @@ -115,6 +121,9 @@ class ContentStateEnd implements ModelInterface, ArrayAccess, \JsonSerializable
'percentage' => false,
'value' => false,
'upperLimit' => false,
'durationSeconds' => false,
'countsDown' => false,
'isRunning' => false,
'metrics' => false,
'message' => false,
'icon' => false,
Expand Down Expand Up @@ -219,6 +228,9 @@ public function isNullableSetToNull(string $property): bool
'percentage' => 'percentage',
'value' => 'value',
'upperLimit' => 'upper_limit',
'durationSeconds' => 'duration_seconds',
'countsDown' => 'counts_down',
'isRunning' => 'is_running',
'metrics' => 'metrics',
'message' => 'message',
'icon' => 'icon',
Expand All @@ -243,6 +255,9 @@ public function isNullableSetToNull(string $property): bool
'percentage' => 'setPercentage',
'value' => 'setValue',
'upperLimit' => 'setUpperLimit',
'durationSeconds' => 'setDurationSeconds',
'countsDown' => 'setCountsDown',
'isRunning' => 'setIsRunning',
'metrics' => 'setMetrics',
'message' => 'setMessage',
'icon' => 'setIcon',
Expand All @@ -267,6 +282,9 @@ public function isNullableSetToNull(string $property): bool
'percentage' => 'getPercentage',
'value' => 'getValue',
'upperLimit' => 'getUpperLimit',
'durationSeconds' => 'getDurationSeconds',
'countsDown' => 'getCountsDown',
'isRunning' => 'getIsRunning',
'metrics' => 'getMetrics',
'message' => 'getMessage',
'icon' => 'getIcon',
Expand Down Expand Up @@ -324,6 +342,7 @@ public function getModelName()
public const TYPE_METRICS = 'metrics';
public const TYPE_STATS = 'stats';
public const TYPE_ALERT = 'alert';
public const TYPE_TIMER = 'timer';
public const COLOR_LIME = 'lime';
public const COLOR_GREEN = 'green';
public const COLOR_CYAN = 'cyan';
Expand Down Expand Up @@ -368,6 +387,7 @@ public function getTypeAllowableValues()
self::TYPE_METRICS,
self::TYPE_STATS,
self::TYPE_ALERT,
self::TYPE_TIMER,
];
}

Expand Down Expand Up @@ -456,6 +476,9 @@ public function __construct(array $data = null)
$this->setIfExists('percentage', $data ?? [], null);
$this->setIfExists('value', $data ?? [], null);
$this->setIfExists('upperLimit', $data ?? [], null);
$this->setIfExists('durationSeconds', $data ?? [], null);
$this->setIfExists('countsDown', $data ?? [], true);
$this->setIfExists('isRunning', $data ?? [], true);
$this->setIfExists('metrics', $data ?? [], null);
$this->setIfExists('message', $data ?? [], null);
$this->setIfExists('icon', $data ?? [], null);
Expand Down Expand Up @@ -778,6 +801,87 @@ public function setUpperLimit($upperLimit)
return $this;
}

/**
* Gets durationSeconds
*
* @return float|null
*/
public function getDurationSeconds()
{
return $this->container['durationSeconds'];
}

/**
* Sets durationSeconds
*
* @param float|null $durationSeconds Timer duration in seconds. For type=timer, omit duration_seconds on end to preserve and freeze the latest timer state.
*
* @return self
*/
public function setDurationSeconds($durationSeconds)
{
if (is_null($durationSeconds)) {
throw new \InvalidArgumentException('non-nullable durationSeconds cannot be null');
}
$this->container['durationSeconds'] = $durationSeconds;

return $this;
}

/**
* Gets countsDown
*
* @return bool|null
*/
public function getCountsDown()
{
return $this->container['countsDown'];
}

/**
* Sets countsDown
*
* @param bool|null $countsDown Use with type=timer. When true or omitted, the timer counts down from duration_seconds. Set false for an elapsed timer; omit duration_seconds for an open-ended elapsed timer.
*
* @return self
*/
public function setCountsDown($countsDown)
{
if (is_null($countsDown)) {
throw new \InvalidArgumentException('non-nullable countsDown cannot be null');
}
$this->container['countsDown'] = $countsDown;

return $this;
}

/**
* Gets isRunning
*
* @return bool|null
*/
public function getIsRunning()
{
return $this->container['isRunning'];
}

/**
* Sets isRunning
*
* @param bool|null $isRunning Use with type=timer. Defaults to true. Set false to pause/freeze via API; set true on a paused timer to resume.
*
* @return self
*/
public function setIsRunning($isRunning)
{
if (is_null($isRunning)) {
throw new \InvalidArgumentException('non-nullable isRunning cannot be null');
}
$this->container['isRunning'] = $isRunning;

return $this;
}

/**
* Gets metrics
*
Expand Down Expand Up @@ -857,7 +961,7 @@ public function getIcon()
/**
* Sets icon
*
* @param \ActivitySmith\Generated\Model\LiveActivityAlertIcon|null $icon Optional SF Symbol icon. Supported by alert, progress, segmented_progress, metrics, and stats.
* @param \ActivitySmith\Generated\Model\LiveActivityAlertIcon|null $icon Optional SF Symbol icon. Supported by alert, progress, segmented_progress, metrics, stats, and timer.
*
* @return self
*/
Expand Down Expand Up @@ -948,7 +1052,7 @@ public function getColor()
/**
* Sets color
*
* @param string|null $color Optional. Accent color for progress, segmented_progress, and metrics Live Activities. For Alert Live Activities, this tints the action button when action is included.
* @param string|null $color Optional. Accent color for progress, segmented_progress, metrics, and timer Live Activities. For Alert Live Activities, this tints the action button when action is included.
*
* @return self
*/
Expand Down
Loading