XBlock 开发event tracking & logging

  1. XBlock 开发问题-event tracking: 请大牛帮忙确定:XBlock是通过runtime.publish来tracking 用户点击行为嘛?例如下面截图:

自问自答:感谢@种瓜 qq群里分享。


Get a quick feeling for how to emit events from three different parts of the code base: Python, JavaScript, and XBlocks.

Example 0: Find the tracking log file
On localhost devstack, the tracking log file is located in /edx/var/log/tracking/tracking.log .

If you’re working with a sandbox, first SSH in as described in the DevOps Sandboxes wiki page, and then find the tracking log file.

Tail this file from a command line to see events emitted ‘in real time’.

Example 1:** (Server-side events) Emit an event in** Python. This should set event_source: server .
from eventtracking import tracker

        'name': 'foo',
        'address': {
            'postal_code': '90210',
            'country': 'United States'

Examples in the code: https://github.com/edx/edx-platform/search?utf8=✓&q=tracker.emit
More information and testing approaches: http://edx.readthedocs.org/projects/edx-developer-guide/en/latest/analytics.html

Example 2: Emit an event in JavaScript. This should set event_source: browser.
Logger.log("edx.video.awesome_mode_enabled", {"button_pressed": "the really big purple one", "button_id": 15, "..."})

Example 3:Emit events in XBlocks
self.runtime.publish(self, "company.xblock.content.viewed", event_data)

其他相关信息,请查看open edx 关于 Event Design and Review Process的官方文档: 1.https://openedx.atlassian.net/wiki/display/AN/Event+Design+and+Review+Process


Powered by eduStack & ifLab