Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
E
edx-platform
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
edx
edx-platform
Commits
fcfb0f4a
Commit
fcfb0f4a
authored
Feb 12, 2016
by
Gabe Mulley
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #11522 from edx/gabe/remove-ga-fields
copy event on write
parents
fb3a09e6
239c3822
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
72 additions
and
2 deletions
+72
-2
common/djangoapps/track/shim.py
+5
-2
common/djangoapps/track/tests/test_shim.py
+67
-0
No files found.
common/djangoapps/track/shim.py
View file @
fcfb0f4a
...
...
@@ -177,7 +177,10 @@ class GoogleAnalyticsProcessor(object):
context
=
event
.
get
(
'context'
,
{})
course_id
=
context
.
get
(
'course_id'
)
copied_event
=
event
.
copy
()
if
course_id
is
not
None
:
event
[
'label'
]
=
course_id
copied_
event
[
'label'
]
=
course_id
event
[
'nonInteraction'
]
=
1
copied_event
[
'nonInteraction'
]
=
1
return
copied_event
common/djangoapps/track/tests/test_shim.py
View file @
fcfb0f4a
...
...
@@ -149,3 +149,70 @@ class GoogleAnalyticsProcessorTestCase(EventTrackingTestCase):
'timestamp'
:
FROZEN_TIME
,
}
assert_events_equal
(
expected_event
,
emitted_event
)
@override_settings
(
EVENT_TRACKING_BACKENDS
=
{
'0'
:
{
'ENGINE'
:
'eventtracking.backends.routing.RoutingBackend'
,
'OPTIONS'
:
{
'backends'
:
{
'first'
:
{
'ENGINE'
:
'track.tests.InMemoryBackend'
}
},
'processors'
:
[
{
'ENGINE'
:
'track.shim.GoogleAnalyticsProcessor'
}
]
}
},
'1'
:
{
'ENGINE'
:
'eventtracking.backends.routing.RoutingBackend'
,
'OPTIONS'
:
{
'backends'
:
{
'second'
:
{
'ENGINE'
:
'track.tests.InMemoryBackend'
}
}
}
}
}
)
class
MultipleShimGoogleAnalyticsProcessorTestCase
(
EventTrackingTestCase
):
"""Ensure changes don't impact other backends"""
def
test_multiple_backends
(
self
):
data
=
{
sentinel
.
key
:
sentinel
.
value
,
}
context
=
{
'path'
:
sentinel
.
path
,
'user_id'
:
sentinel
.
user_id
,
'course_id'
:
sentinel
.
course_id
,
'org_id'
:
sentinel
.
org_id
,
'client_id'
:
sentinel
.
client_id
,
}
with
self
.
tracker
.
context
(
'test'
,
context
):
self
.
tracker
.
emit
(
sentinel
.
name
,
data
)
segment_emitted_event
=
self
.
tracker
.
backends
[
'0'
]
.
backends
[
'first'
]
.
events
[
0
]
log_emitted_event
=
self
.
tracker
.
backends
[
'1'
]
.
backends
[
'second'
]
.
events
[
0
]
expected_event
=
{
'context'
:
context
,
'data'
:
data
,
'label'
:
sentinel
.
course_id
,
'name'
:
sentinel
.
name
,
'nonInteraction'
:
1
,
'timestamp'
:
FROZEN_TIME
,
}
assert_events_equal
(
expected_event
,
segment_emitted_event
)
expected_event
=
{
'context'
:
context
,
'data'
:
data
,
'name'
:
sentinel
.
name
,
'timestamp'
:
FROZEN_TIME
,
}
assert_events_equal
(
expected_event
,
log_emitted_event
)
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment