Using Open edX events

357 views
Skip to first unread message

Daniel McQuillen

unread,
Sep 21, 2016, 1:15:05 AM9/21/16
to General Open edX discussion
Hi,

I've been looking into how Open edX events are created and how at least some events are sent to Segment.com via Segment's javascript tracker and Python library (i.e. analytics.track() ).

As far as I can tell, just a few page tracking events and the some internal events are sent to Segment, such as:
  - edx.bi.user.account.registered 
  - edx.bi.user.account.authenticated
  - edx.course.enrollment.activated
  - ...and some other events

Meanwhile, there's a big list of events in the docs that are used internally by Open edX's internal event-tracking app, primarily I guess for consumption by Analytics Pipepline (interesting that this list doesn't have the edx.bi. prefixed events).

But I'm curious why *all* events aren't sent through the event-tracking app, which would then forward to Segment if necessary. 

Also, if we wanted to capture and work with events like "registered" or "authenticated," but don't want to use Segment, any thoughts on what the best approach would be? Should we update Open edX code to send those directly to the internal event-tracking app and then figure out how to have that app forward some/all of events to our own (external) data broker, where we can do our own integrations to things like Autopilot?

Hoping somebody already had this need and has suggestions on an approach. I'm wondering if Amazon SNS + Lambda would be ok for our purposes.

Thanks and happy Wednesday!

Daniel




Nate Aune

unread,
Jun 29, 2018, 5:52:29 PM6/29/18
to General Open edX discussion
I was also baffled why the events weren't getting pushed into Segment, and after poking around the documentation, discovered that you have to add the events that you want to track to a whitelist EVENT_TRACKING_SEGMENTIO_EMIT_WHITELIST, as explained here: https://edx.readthedocs.io/projects/edx-developer-guide/en/latest/analytics.html?highlight=segment#segment

The reason for this is because there are hundreds of potential events, and if you send all of them to Segment, you'll quickly burn through your quota. So this allows you to be more selective and only send the events that you actually care enough about to track and report on.

I added this line to lms.env.json:

  "LMS_SEGMENT_KEY": "xxxxxxxxxxxxxxxxxxx",

Then I add this line to cms.env.json:

  "CMS_SEGMENT_KEY": "xxxxxxxxxxxxxxxxxxx",

Where "xxxxxxxxxxxxxxxxxxx" is your Segment API key.

You can find the list of events that you can whitelist in this alphabetical list:

Or if you want to find events based on categories (student events, course team events):

However, even after adding these events to the whitelist, they still didn't show up in the Segment debugger. Anyone able to get this working?
EVENT_TRACKING_SEGMENTIO_EMIT_WHITELIST = ["edx.forum.comment.created", "edx.forum.response.created", "edx.forum.thread.created", "edx.video.played", "edx.video.paused", "get-student-progress-page", "edx.grades.problem.submitted", "edx.course.enrollment.activated", "edx.video.loaded", "problem_save", "problem_check"]
 
thanks,
Nate

Nate Aune

unread,
Jul 16, 2018, 8:14:18 PM7/16/18
to General Open edX discussion
I just realized that I had an error in my last message. Rather than adding the Segment keys to the lms.env.json and cms.env.json files, they should be added to the lms.auth.json and cms.auth.json files. And the key should just be SEGMENT_KEY and not LMS_SEGMENT_KEY and CMS_SEGMENT_KEY. So if you add these, then you'll be able to send events from LMS and Studio (CMS) to Segment:

I added this line to lms.auth.json:

  "SEGMENT_KEY": "xxxxxxxxxxxxxxxxxxx",

Then I add this line to cms.auth.json:

  "SEGMENT_KEY": "xxxxxxxxxxxxxxxxxxx",

Where "xxxxxxxxxxxxxxxxx" is your Segment key. Note that this could be the same Segment key, or if you want to track events from LMS separately from CMS (Studio) events, then you could use two different keys.

To whitelist events, add this line to lms.auth.json:

  "EVENT_TRACKING_SEGMENTIO_EMIT_WHITELIST": ["add-forum-admin",
                                            "add-forum-community-TA",
                                            "add-forum-mod",
                                            "add-instructor",
                                            ...
                                            "xblock.survey.submitted",
                                            "xblock.survey.view_results"]

Once you've added these lines, and restart the LMS and CMS, your events will start appearing in the Segment debugger, and you can then add any number of destinations to which to send these analytics events: Google Analytics, Mixpanel, Marketo, Redshift, etc.

To make it easier to add events to this list, I made this gist of events emitted by Open edX derived from the alphabetical list of events (provided by edX).

Nate

Lupus Furyo

unread,
Jul 18, 2018, 7:00:23 AM7/18/18
to edx-...@googlegroups.com
Hi Nate,
Thank you very much for your posts and providing the detailed instructions on how to set up Segment authentication in edX, and how to white-list desired events. So far, I could successfully add only one destination: Google Analytics. As for the rest, I am unfamiliar with any other services listed under the tab: Destinations. So, I have not tried them.
Once again, thanks a lot for your posts and introducing me to Segment.

Best, L.

--
You received this message because you are subscribed to the Google Groups "General Open edX discussion" group.
To view this discussion on the web visit https://groups.google.com/d/msgid/edx-code/50c304b4-611e-4bd5-93d6-12fe8b4b33b1%40googlegroups.com.

Lupus Furyo

unread,
Jul 18, 2018, 11:57:15 AM7/18/18
to edx-...@googlegroups.com
After Nate's earlier post, I found an open article on Emitting+Product+Events+to+Segment+and+Google+Analytics (needs sign in):
that points to the documentation of Segment.io that I used. I have successfully tested configuration on an earlier release of edX (I believe it is Cypress).

The old equivalents/flags now depreciated are SEGMENT_IO_LMS_KEY (found in the file lms.auth.json). There is also the same setting var EVENT_TRACKING_SEGMENTIO_EMIT_WHITELIST
but in addition, there is a flag that needs to be set true: SEGMENT_IO_LMS.

On a related note, something very strange is going on with all my instances of ginkgo.master if I add SEGMENT_KEY: "my-long-segment-api-key" and also "TRACKING_SEGMENTIO_WEBHOOK_SECRET": "my-secret". (I didn't even white-list any events yet). The strange behavior is:

1. After reboot, "my ship sank" (neither edX LMS or CMS can be accessed);
2. I don't see anything in logs;
3. If I try to compile assets for a theme, it won't.

Definitely, this is related to the changes I made in lms.auth.json, but when I reverted them back, I cannot return to the stable state anymore. I tested this on two machines (Open edX ginkgo.master running on VMeare guests).
Quite honestly, I have not idea what is going on here.



Lupus Furyo

unread,
Jul 18, 2018, 1:21:16 PM7/18/18
to edx-...@googlegroups.com
I tried it again on a newly created VMware guest, installed Open edX open-release/ginkgo.master from scratch, and made the changes suggested by Nate above. Everything works as expected. The issue which I was wrote about must have been related to the particular copy of VMware guest I was using (deleted). It is unrelated to use of Segment for edX.

P.S. Thanks to Nate, and his excursions into use of Segment.io for Open edX, I accidentally discovered that I had a faulty installation on edX (a VMeare guest) which I named as "prod".
Now deleted and purged from trash : )

Lupus Furyo

unread,
Jul 18, 2018, 1:42:09 PM7/18/18
to edx-...@googlegroups.com
Here's a screenshot of Segoment's debugger screen showing emitted events that have been received. This looks how nice... I am really excited!
Once again thank a lot Nate.
Segment.png
Reply all
Reply to author
Forward
0 new messages