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
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
## 1.12.0

Adds the new `value` Live Activity type.

## 1.11.0

This version adds support for Metadata and iOS deep links, and expands Tags support when updating or ending Live Activities.
Expand Down
84 changes: 49 additions & 35 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -138,33 +138,43 @@ activitysmith.notifications.send(

Choose the Live Activity type that matches what you want to show:

![Stats Live Activity with six labeled sales metrics](https://cdn.activitysmith.com/features/stats-live-activity.png)
- ![Value Live Activity showing revenue with a growth badge](https://cdn.activitysmith.com/features/value-live-activity.png) **Value**: Show a single value on your Lock Screen, such as revenue, a queue count, or a temperature.

**Stats**: Show up to 8 labeled values on your Lock Screen, from revenue and orders to uptime and conversion.
- ![Stats Live Activity with six labeled sales metrics](https://cdn.activitysmith.com/features/stats-live-activity.png) **Stats**: Show up to 8 labeled values on your Lock Screen, from revenue and orders to uptime and conversion.

![Metrics Live Activity with CPU and memory values](https://cdn.activitysmith.com/features/metrics-live-activity-start.png)
- ![Alert Live Activity showing a customer reactivation update](https://cdn.activitysmith.com/features/alert-live-activity.png) **Alert**: Show status updates with a clear message, badge, and icon. When you add an action button, `color` controls the button tint.

**Metrics**: Track two related values with segmented bars, such as CPU and memory.
- ![Metrics Live Activity with CPU and memory values](https://cdn.activitysmith.com/features/metrics-live-activity-start.png) **Metrics**: Track two related values with segmented bars, such as CPU and memory.

![Segmented Progress Live Activity showing a workflow step](https://cdn.activitysmith.com/features/update-live-activity.png)
- ![Segmented Progress Live Activity showing a workflow step](https://cdn.activitysmith.com/features/update-live-activity.png) **Segmented Progress**: Show progress through a known set of steps, like build, test, deploy, and verify.

**Segmented Progress**: Show progress through a known set of steps, like build, test, deploy, and verify.
- ![Progress Live Activity showing percentage completion](https://cdn.activitysmith.com/features/progress-live-activity.png) **Progress**: Show percentage progress for jobs that move continuously toward completion.

![Progress Live Activity showing percentage completion](https://cdn.activitysmith.com/features/progress-live-activity.png)
- ![Timer Live Activity showing a benchmark run countdown](https://cdn.activitysmith.com/features/timer-live-activity.png) **Timer**: Count down from a duration, or count up from 00:00 while a job runs.

**Progress**: Show percentage progress for jobs that move continuously toward completion.

![Alert Live Activity showing a customer reactivation update](https://cdn.activitysmith.com/features/alert-live-activity.png)
### Start & Update Live Activity

**Alert**: Show status updates with a clear message, badge, and icon. When you add an action button, `color` controls the button tint.
Use a stable `stream_key` to identify the metric, job, deployment, or system you want to keep visible. The first `stream(...)` call starts the Live Activity. Later calls with the same `stream_key` update it.

![Timer Live Activity showing a benchmark run countdown](https://cdn.activitysmith.com/features/timer-live-activity.png)
#### Value

**Timer**: Count down from a duration, or count up from 00:00 while a job runs.
![Value Live Activity stream example](https://cdn.activitysmith.com/features/value-live-activity.png)

### Start & Update Live Activity
```python
activitysmith.live_activities.stream(
"revenue-today",
content_state=content_state(
title="Revenue",
type="value",
value="$1,240",
color="green",
icon=alert_icon("dollarsign.circle", color="green"),
badge=alert_badge("↑ 18%", color="purple"),
),
)
```

Use a stable `stream_key` to identify the metric, job, deployment, or system you want to keep visible. The first `stream(...)` call starts the Live Activity. Later calls with the same `stream_key` update it.
Send a string or number in `value`. Strings keep their formatting, including currency symbols, units, and decimal places.

#### Stats

Expand All @@ -189,6 +199,23 @@ activitysmith.live_activities.stream(
)
```

#### Alert

![Alert Live Activity stream example](https://cdn.activitysmith.com/features/alert-live-activity.png)

```python
activitysmith.live_activities.stream(
"customer-ops",
content_state=content_state(
title="Reactivation",
message="Lumen came back after 2 weeks",
type="alert",
icon=alert_icon("cloud.sun", color="yellow"),
badge=alert_badge("Customer", color="magenta"),
),
)
```

#### Metrics

![Metrics Live Activity stream example](https://cdn.activitysmith.com/features/metrics-live-activity-start.png)
Expand Down Expand Up @@ -241,23 +268,6 @@ activitysmith.live_activities.stream(
)
```

#### Alert

![Alert Live Activity stream example](https://cdn.activitysmith.com/features/alert-live-activity.png)

```python
activitysmith.live_activities.stream(
"customer-ops",
content_state=content_state(
title="Reactivation",
message="Lumen came back after 2 weeks",
type="alert",
icon=alert_icon("cloud.sun", color="yellow"),
badge=alert_badge("Customer", color="magenta"),
),
)
```

#### Timer

![Timer Live Activity stream example](https://cdn.activitysmith.com/features/timer-live-activity.png)
Expand Down Expand Up @@ -305,7 +315,7 @@ Add more context to Live Activities with icons and badges.

#### Icon

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

![Metrics Live Activity with an SF Symbol icon on the iPhone Lock Screen](https://cdn.activitysmith.com/features/metrics-live-activity-with-icon.png)

Expand Down Expand Up @@ -333,7 +343,7 @@ The `icon.symbol` value is an Apple SF Symbol name. Browse the catalog with one

#### Badge

Badges are supported by `alert`, `progress`, and `segmented_progress` Live Activities.
Badges are supported by `value`, `alert`, `segmented_progress`, and `progress` Live Activities.

![Progress Live Activity with a badge on the iPhone Lock Screen](https://cdn.activitysmith.com/features/progress-live-activity-with-badge.png)

Expand Down Expand Up @@ -445,7 +455,7 @@ activitysmith.live_activities.stream(

Use `secondary_action` when you want a second button beside the primary `action`.

The secondary action button is supported for `alert`, `progress`, and `segmented_progress` Live Activities. Both buttons use the same `open_url`, `webhook`, and Apple Shortcut payload shapes.
The secondary action button is supported for `value`, `alert`, `segmented_progress`, and `progress` Live Activities. Both buttons use the same `open_url`, `webhook`, and Apple Shortcut payload shapes.

```python
activitysmith.live_activities.stream(
Expand Down Expand Up @@ -608,3 +618,7 @@ Wrap API calls with `try/except`. The SDK raises exceptions for non-2xx response
### [PyPI Package](https://pypi.org/project/activitysmith/)

Install the ActivitySmith Python SDK from PyPI

### [Source Code](https://github.com/ActivitySmithHQ/activitysmith-python)

View the Python SDK source on GitHub
5 changes: 3 additions & 2 deletions activitysmith/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@

from .normalization import normalize_live_activity_request, normalize_metric_request

SDK_VERSION = "1.11.0"
SDK_VERSION = "1.12.0"
SDK_HEADER_NAME = "X-ActivitySmith-SDK"
SDK_HEADER_VALUE = f"python-v{SDK_VERSION}"

Expand Down Expand Up @@ -175,7 +175,7 @@ def content_state(
number_of_steps: int | None = None,
current_step: int | None = None,
percentage: int | float | None = None,
value: int | float | None = None,
value: str | int | float | None = None,
upper_limit: int | float | None = None,
duration_seconds: int | float | None = None,
counts_down: bool | None = None,
Expand Down Expand Up @@ -421,6 +421,7 @@ class LiveActivitiesResource:
TYPE_STATS = "stats"
TYPE_ALERT = "alert"
TYPE_TIMER = "timer"
TYPE_VALUE = "value"

def __init__(self, api: LiveActivitiesApi) -> None:
self._api = api
Expand Down
8 changes: 7 additions & 1 deletion activitysmith/normalization.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
"""Adapt plain values to the generated client's union models."""
from typing import Any
from activitysmith_openapi.models.live_activity_value import LiveActivityValue

from activitysmith_openapi.models.activity_metric_value import ActivityMetricValue
from activitysmith_openapi.models.metric_value_update_request_value import MetricValueUpdateRequestValue
Expand All @@ -22,7 +23,12 @@ def normalize_live_activity_request(request: Any) -> Any:
if not isinstance(request, dict):
return request
state = request.get("content_state")
if not isinstance(state, dict) or not isinstance(state.get("metrics"), (list, tuple)):
if not isinstance(state, dict):
return request
if "value" in state:
state = {**state, "value": _wrap_value(state["value"], LiveActivityValue)}
request = {**request, "content_state": state}
if not isinstance(state.get("metrics"), (list, tuple)):
return request
metrics = []
for metric in state["metrics"]:
Expand Down
3 changes: 2 additions & 1 deletion activitysmith_openapi/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
""" # noqa: E501


__version__ = "1.11.0"
__version__ = "1.12.0"

# import apis into sdk package
from activitysmith_openapi.api.app_icon_badges_api import AppIconBadgesApi
Expand Down Expand Up @@ -62,6 +62,7 @@
from activitysmith_openapi.models.live_activity_stream_request import LiveActivityStreamRequest
from activitysmith_openapi.models.live_activity_update_request import LiveActivityUpdateRequest
from activitysmith_openapi.models.live_activity_update_response import LiveActivityUpdateResponse
from activitysmith_openapi.models.live_activity_value import LiveActivityValue
from activitysmith_openapi.models.live_activity_webhook_method import LiveActivityWebhookMethod
from activitysmith_openapi.models.metadata_value import MetadataValue
from activitysmith_openapi.models.metric_error import MetricError
Expand Down
6 changes: 3 additions & 3 deletions activitysmith_openapi/api/app_icon_badges_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -95,8 +95,8 @@ def update_app_icon_badge_count(
'400': "BadRequestError",
'403': "ForbiddenError",
'422': "UpdateAppIconBadgeCount422Response",
'502': "AppIconBadgeCountUpdateError",
'429': "RateLimitError",
'502': "AppIconBadgeCountUpdateError",
}
response_data = self.api_client.call_api(
*_param,
Expand Down Expand Up @@ -167,8 +167,8 @@ def update_app_icon_badge_count_with_http_info(
'400': "BadRequestError",
'403': "ForbiddenError",
'422': "UpdateAppIconBadgeCount422Response",
'502': "AppIconBadgeCountUpdateError",
'429': "RateLimitError",
'502': "AppIconBadgeCountUpdateError",
}
response_data = self.api_client.call_api(
*_param,
Expand Down Expand Up @@ -239,8 +239,8 @@ def update_app_icon_badge_count_without_preload_content(
'400': "BadRequestError",
'403': "ForbiddenError",
'422': "UpdateAppIconBadgeCount422Response",
'502': "AppIconBadgeCountUpdateError",
'429': "RateLimitError",
'502': "AppIconBadgeCountUpdateError",
}
response_data = self.api_client.call_api(
*_param,
Expand Down
Loading
Loading