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 @@ -139,13 +139,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 @@ -273,6 +274,33 @@ activitysmith.live_activities.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>

```python
activitysmith.live_activities.stream(
"benchmark-run",
content_state=content_state(
title="Benchmark Run",
subtitle="sampling",
type="timer",
duration_seconds=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 `end_stream(...)` with the same `stream_key` 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 `auto_dismiss_minutes` to choose a different dismissal time, including `0` for immediate dismissal.
Expand Down Expand Up @@ -382,7 +410,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 src="https://cdn.activitysmith.com/features/metrics-live-activity-with-icon.png" alt="Metrics Live Activity with an SF Symbol icon on the iPhone Lock Screen" width="680" />
Expand Down
31 changes: 30 additions & 1 deletion activitysmith/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
from activitysmith_openapi.api.metrics_api import MetricsApi
from activitysmith_openapi.api.push_notifications_api import PushNotificationsApi

SDK_VERSION = "1.6.0"
SDK_VERSION = "1.7.0"
SDK_HEADER_NAME = "X-ActivitySmith-SDK"
SDK_HEADER_VALUE = f"python-v{SDK_VERSION}"

Expand Down Expand Up @@ -166,6 +166,8 @@ def content_state(
percentage: int | float | None = None,
value: int | float | None = None,
upper_limit: int | float | None = None,
duration_seconds: int | float | None = None,
counts_down: bool | None = None,
color: str | None = None,
step_color: str | None = None,
auto_dismiss_seconds: int | None = None,
Expand All @@ -185,6 +187,8 @@ def content_state(
"percentage": percentage,
"value": value,
"upper_limit": upper_limit,
"duration_seconds": duration_seconds,
"counts_down": counts_down,
"color": color,
"step_color": step_color,
"auto_dismiss_seconds": auto_dismiss_seconds,
Expand Down Expand Up @@ -265,6 +269,8 @@ def _build_live_activity_request(
percentage: Any | None = None,
value: Any | None = None,
upper_limit: Any | None = None,
duration_seconds: Any | None = None,
counts_down: Any | None = None,
color: Any | None = None,
step_color: Any | None = None,
auto_dismiss_seconds: Any | None = None,
Expand All @@ -288,6 +294,8 @@ def _build_live_activity_request(
"percentage": percentage,
"value": value,
"upper_limit": upper_limit,
"duration_seconds": duration_seconds,
"counts_down": counts_down,
"color": color,
"step_color": step_color,
"auto_dismiss_seconds": auto_dismiss_seconds,
Expand Down Expand Up @@ -387,6 +395,7 @@ class LiveActivitiesResource:
TYPE_METRICS = "metrics"
TYPE_STATS = "stats"
TYPE_ALERT = "alert"
TYPE_TIMER = "timer"

def __init__(self, api: LiveActivitiesApi) -> None:
self._api = api
Expand Down Expand Up @@ -434,6 +443,8 @@ def start(
percentage: Any | None = None,
value: Any | None = None,
upper_limit: Any | None = None,
duration_seconds: Any | None = None,
counts_down: Any | None = None,
color: Any | None = None,
step_color: Any | None = None,
action: Any | None = None,
Expand All @@ -456,6 +467,8 @@ def start(
percentage=percentage,
value=value,
upper_limit=upper_limit,
duration_seconds=duration_seconds,
counts_down=counts_down,
color=color,
step_color=step_color,
action=action,
Expand Down Expand Up @@ -485,6 +498,8 @@ def update(
percentage: Any | None = None,
value: Any | None = None,
upper_limit: Any | None = None,
duration_seconds: Any | None = None,
counts_down: Any | None = None,
color: Any | None = None,
step_color: Any | None = None,
action: Any | None = None,
Expand All @@ -505,6 +520,8 @@ def update(
percentage=percentage,
value=value,
upper_limit=upper_limit,
duration_seconds=duration_seconds,
counts_down=counts_down,
color=color,
step_color=step_color,
action=action,
Expand All @@ -529,6 +546,8 @@ def end(
percentage: Any | None = None,
value: Any | None = None,
upper_limit: Any | None = None,
duration_seconds: Any | None = None,
counts_down: Any | None = None,
color: Any | None = None,
step_color: Any | None = None,
auto_dismiss_minutes: Any | None = None,
Expand All @@ -550,6 +569,8 @@ def end(
percentage=percentage,
value=value,
upper_limit=upper_limit,
duration_seconds=duration_seconds,
counts_down=counts_down,
color=color,
step_color=step_color,
auto_dismiss_minutes=auto_dismiss_minutes,
Expand All @@ -575,6 +596,8 @@ def stream(
percentage: Any | None = None,
value: Any | None = None,
upper_limit: Any | None = None,
duration_seconds: Any | None = None,
counts_down: Any | None = None,
color: Any | None = None,
step_color: Any | None = None,
action: Any | None = None,
Expand All @@ -597,6 +620,8 @@ def stream(
percentage=percentage,
value=value,
upper_limit=upper_limit,
duration_seconds=duration_seconds,
counts_down=counts_down,
color=color,
step_color=step_color,
action=action,
Expand Down Expand Up @@ -627,6 +652,8 @@ def end_stream(
percentage: Any | None = None,
value: Any | None = None,
upper_limit: Any | None = None,
duration_seconds: Any | None = None,
counts_down: Any | None = None,
color: Any | None = None,
step_color: Any | None = None,
auto_dismiss_minutes: Any | None = None,
Expand All @@ -648,6 +675,8 @@ def end_stream(
percentage=percentage,
value=value,
upper_limit=upper_limit,
duration_seconds=duration_seconds,
counts_down=counts_down,
color=color,
step_color=step_color,
auto_dismiss_minutes=auto_dismiss_minutes,
Expand Down
Loading