-
Notifications
You must be signed in to change notification settings - Fork 21
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: add signal for event-tracking emission #230
Merged
mariajgrimaldi
merged 8 commits into
openedx:main
from
eduNEXT:cag/add-openedx-event-signal
Nov 14, 2023
Merged
Changes from all commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
4d9272c
feat: add signal for event-tracking emission
Ian2012 d0cbb35
chore: bump version to 9.1.0
Ian2012 4800d4a
fix: update event type to follow conventions
Ian2012 a4f58da
fix: rename tracking log event emitted
Ian2012 8659922
chore: improve docstring
Ian2012 e2bfc1c
docs: update 9.1.0 date
Ian2012 f3045cc
fix: rename tracking event
Ian2012 689ab46
chore: bump version to 9.1.0
Ian2012 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,4 +5,4 @@ | |
more information about the project. | ||
""" | ||
|
||
__version__ = "9.0.1" | ||
__version__ = "9.1.0" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
""" | ||
Package where events related to the analytics subdomain are implemented. | ||
|
||
The analytics subdomain corresponds to {Architecture Subdomain} defined in | ||
the OEP-41. | ||
""" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
""" | ||
Data attributes for events within the architecture subdomain ``analytics``. | ||
|
||
These attributes follow the form of attr objects specified in OEP-49 data | ||
pattern. | ||
""" | ||
|
||
from datetime import datetime | ||
|
||
import attr | ||
|
||
|
||
@attr.s(frozen=True) | ||
class TrackingLogData: | ||
""" | ||
Data describing tracking events. | ||
|
||
Arguments: | ||
name (str): event name | ||
timestamp (datetime): timestamp of the event | ||
data (str): json string representation of a dictionary with extra data (optional), | ||
e.g. {"course_id": "course-v1:edX+DemoX+Demo_Course"} | ||
context (dict): json string representation of a dictionary of context data | ||
defined in https://edx.readthedocs.io/projects/devdata/en/latest/internal_data_formats/tracking_logs/ | ||
""" | ||
|
||
name = attr.ib(type=str) | ||
timestamp = attr.ib(type=datetime) | ||
data = attr.ib(type=str) | ||
context = attr.ib(type=str) | ||
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
""" | ||
Standardized signals definitions for events within the architecture subdomain ``analytics``. | ||
|
||
All signals defined in this module must follow the name and versioning | ||
conventions specified in OEP-41. | ||
|
||
They also must comply with the payload definition specified in | ||
docs/decisions/0003-events-payload.rst | ||
""" | ||
|
||
from openedx_events.analytics.data import TrackingLogData | ||
from openedx_events.tooling import OpenEdxPublicSignal | ||
|
||
# .. event_type: org.openedx.analytics.tracking.event.emitted.v1 | ||
# .. event_name: TRACKING_EVENT_EMITTED | ||
# .. event_description: emitted when a tracking log is created. | ||
# .. event_data: TrackingLogData | ||
TRACKING_EVENT_EMITTED = OpenEdxPublicSignal( | ||
Ian2012 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
event_type="org.openedx.analytics.tracking.event.emitted.v1", | ||
data={ | ||
"tracking_log": TrackingLogData, | ||
} | ||
) |
33 changes: 33 additions & 0 deletions
33
.../event_bus/avro/tests/schemas/org+openedx+analytics+tracking+event+emitted+v1_schema.avsc
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
{ | ||
"name": "CloudEvent", | ||
"type": "record", | ||
"doc": "Avro Event Format for CloudEvents created with openedx_events/schema", | ||
"fields": [ | ||
{ | ||
"name": "tracking_log", | ||
"type": { | ||
"name": "TrackingLogData", | ||
"type": "record", | ||
"fields": [ | ||
{ | ||
"name": "name", | ||
"type": "string" | ||
}, | ||
{ | ||
"name": "timestamp", | ||
"type": "string" | ||
}, | ||
{ | ||
"name": "data", | ||
"type": "string" | ||
}, | ||
{ | ||
"name": "context", | ||
"type": "string" | ||
} | ||
] | ||
} | ||
} | ||
], | ||
"namespace": "org.openedx.analytics.tracking.event.emitted.v1" | ||
} |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As the event bus doesn't support dictionaries we are sending a JSON string version of the context and the extra data. It's expected that the event bus consumer to handle this information