Report user activity that occurs on indexed documents such as viewing or editing. This signal improves search quality.
from glean.api_client import Glean, models
from glean.api_client.utils import parse_datetime
import os
with Glean(
api_token=os.getenv("GLEAN_API_TOKEN", ""),
) as glean:
glean.client.activity.report(events=[
{
"action": models.ActivityEventAction.HISTORICAL_VIEW,
"timestamp": parse_datetime("2000-01-23T04:56:07.000Z"),
"url": "https://example.com/",
},
{
"action": models.ActivityEventAction.SEARCH,
"params": {
"query": "query",
},
"timestamp": parse_datetime("2000-01-23T04:56:07.000Z"),
"url": "https://example.com/search?q=query",
},
{
"action": models.ActivityEventAction.VIEW,
"params": {
"duration": 20,
"referrer": "https://example.com/document",
},
"timestamp": parse_datetime("2000-01-23T04:56:07.000Z"),
"url": "https://example.com/",
},
])
# Use the SDK ...| Parameter | Type | Required | Description |
|---|---|---|---|
events |
List[models.ActivityEvent] | ✔️ | N/A |
retries |
Optional[utils.RetryConfig] | ➖ | Configuration to override the default retry behavior of the client. |
| Error Type | Status Code | Content Type |
|---|---|---|
| errors.GleanError | 4XX, 5XX | */* |
Report events that happen to results within a Glean client UI, such as search result views and clicks. This signal improves search quality.
from glean.api_client import Glean, models
import os
with Glean(
api_token=os.getenv("GLEAN_API_TOKEN", ""),
) as glean:
glean.client.activity.feedback(feedback1={
"tracking_tokens": [
"trackingTokens",
],
"event": models.Event.VIEW,
})
# Use the SDK ...| Parameter | Type | Required | Description | Example |
|---|---|---|---|---|
feedback_query_parameter |
Optional[str] | ➖ | A URL encoded versions of Feedback. This is useful for requests. | |
feedback1 |
Optional[models.Feedback] | ➖ | N/A | { "trackingTokens": [ "trackingTokens" ], "event": "VIEW" } |
retries |
Optional[utils.RetryConfig] | ➖ | Configuration to override the default retry behavior of the client. |
| Error Type | Status Code | Content Type |
|---|---|---|
| errors.GleanError | 4XX, 5XX | */* |