Skip to content

Commit 39f1f67

Browse files
authored
feat: add signal for event-tracking emission (#230)
1 parent 24ed9ce commit 39f1f67

File tree

6 files changed

+99
-1
lines changed

6 files changed

+99
-1
lines changed

CHANGELOG.rst

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,12 @@ Change Log
1414
Unreleased
1515
----------
1616

17+
[9.1.0] - 2023-11-07
18+
--------------------
19+
Added
20+
~~~~~~~
21+
* Added new event TRACKING_EVENT_EMITTED.
22+
1723
[9.0.1] - 2023-10-31
1824
--------------------
1925
Changed

openedx_events/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,4 +5,4 @@
55
more information about the project.
66
"""
77

8-
__version__ = "9.0.1"
8+
__version__ = "9.1.0"

openedx_events/analytics/__init__.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
"""
2+
Package where events related to the analytics subdomain are implemented.
3+
4+
The analytics subdomain corresponds to {Architecture Subdomain} defined in
5+
the OEP-41.
6+
"""

openedx_events/analytics/data.py

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
"""
2+
Data attributes for events within the architecture subdomain ``analytics``.
3+
4+
These attributes follow the form of attr objects specified in OEP-49 data
5+
pattern.
6+
"""
7+
8+
from datetime import datetime
9+
10+
import attr
11+
12+
13+
@attr.s(frozen=True)
14+
class TrackingLogData:
15+
"""
16+
Data describing tracking events.
17+
18+
Arguments:
19+
name (str): event name
20+
timestamp (datetime): timestamp of the event
21+
data (str): json string representation of a dictionary with extra data (optional),
22+
e.g. {"course_id": "course-v1:edX+DemoX+Demo_Course"}
23+
context (dict): json string representation of a dictionary of context data
24+
defined in https://edx.readthedocs.io/projects/devdata/en/latest/internal_data_formats/tracking_logs/
25+
"""
26+
27+
name = attr.ib(type=str)
28+
timestamp = attr.ib(type=datetime)
29+
data = attr.ib(type=str)
30+
context = attr.ib(type=str)

openedx_events/analytics/signals.py

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
"""
2+
Standardized signals definitions for events within the architecture subdomain ``analytics``.
3+
4+
All signals defined in this module must follow the name and versioning
5+
conventions specified in OEP-41.
6+
7+
They also must comply with the payload definition specified in
8+
docs/decisions/0003-events-payload.rst
9+
"""
10+
11+
from openedx_events.analytics.data import TrackingLogData
12+
from openedx_events.tooling import OpenEdxPublicSignal
13+
14+
# .. event_type: org.openedx.analytics.tracking.event.emitted.v1
15+
# .. event_name: TRACKING_EVENT_EMITTED
16+
# .. event_description: emitted when a tracking log is created.
17+
# .. event_data: TrackingLogData
18+
TRACKING_EVENT_EMITTED = OpenEdxPublicSignal(
19+
event_type="org.openedx.analytics.tracking.event.emitted.v1",
20+
data={
21+
"tracking_log": TrackingLogData,
22+
}
23+
)
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
{
2+
"name": "CloudEvent",
3+
"type": "record",
4+
"doc": "Avro Event Format for CloudEvents created with openedx_events/schema",
5+
"fields": [
6+
{
7+
"name": "tracking_log",
8+
"type": {
9+
"name": "TrackingLogData",
10+
"type": "record",
11+
"fields": [
12+
{
13+
"name": "name",
14+
"type": "string"
15+
},
16+
{
17+
"name": "timestamp",
18+
"type": "string"
19+
},
20+
{
21+
"name": "data",
22+
"type": "string"
23+
},
24+
{
25+
"name": "context",
26+
"type": "string"
27+
}
28+
]
29+
}
30+
}
31+
],
32+
"namespace": "org.openedx.analytics.tracking.event.emitted.v1"
33+
}

0 commit comments

Comments
 (0)