Skip to content

Commit

Permalink
Expando: Add media prefs to events
Browse files Browse the repository at this point in the history
  • Loading branch information
Matt Lee committed Oct 7, 2016
1 parent 7d3217a commit acefcc1
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 0 deletions.
12 changes: 12 additions & 0 deletions r2/r2/lib/template_helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -180,6 +180,17 @@ def js_config(extra_config=None):
cur_listing = ""
listing_over_18 = False
pref_no_profanity = not logged or c.user.pref_no_profanity
pref_media_preview = c.user.pref_media_preview

if not feature.is_enabled("autoexpand_media_previews"):
expando_preference = None
elif pref_media_preview == "subreddit":
expando_preference = "subreddit_default"
elif pref_media_preview == "on":
expando_preference = "auto_expand"
else:
expando_preference = "do_not_expand"

nsfw_media_acknowledged = logged and c.user.nsfw_media_acknowledged

if isinstance(c.site, Subreddit) and not c.default_sr:
Expand Down Expand Up @@ -258,6 +269,7 @@ def js_config(extra_config=None):
"static_root": static(''),
"over_18": bool(c.over18),
"listing_over_18": listing_over_18,
"expando_preference": expando_preference,
"pref_no_profanity": pref_no_profanity,
"nsfw_media_acknowledged": nsfw_media_acknowledged,
"new_window": logged and bool(c.user.pref_newwindow),
Expand Down
10 changes: 10 additions & 0 deletions r2/r2/public/static/js/analytics.js
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,14 @@ r.analytics = {
r.analytics.screenviewEvent();
}

if (r.config.expando_preference) {
r.analytics.contextData.expando_preference = r.config.expando_preference;
}

if (r.config.pref_no_profanity) {
r.analytics.contextData.media_preference_hide_nsfw = r.config.pref_no_profanity
}

r.analytics.firePageTrackingPixel(r.analytics.stripAnalyticsParams);

},
Expand Down Expand Up @@ -448,6 +456,8 @@ r.analytics = {
'listing_name',
'referrer_domain',
'referrer_url',
'expando_preference',
'media_preference_hide_nsfw',
]);

if ('linkIsNSFW' in targetData) {
Expand Down

0 comments on commit acefcc1

Please sign in to comment.