Skip to content

Commit

Permalink
Fix expando events on previews getting wrong provider
Browse files Browse the repository at this point in the history
  • Loading branch information
Matt Lee committed Oct 7, 2016
1 parent c23a188 commit 5db40de
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 7 deletions.
11 changes: 4 additions & 7 deletions r2/r2/public/static/js/analytics.js
Original file line number Diff line number Diff line change
Expand Up @@ -470,13 +470,10 @@ r.analytics = {
if ('linkType' in targetData) {
payload['target_type'] = targetData.linkType;

if (targetData.linkType === 'self' ||
targetData.linkDomain === r.config.cur_domain) {
// self posts and reddit live embeds
payload['provider'] = 'reddit';
} else {
payload['provider'] = 'embedly';
}
}

if ('provider' in targetData) {
payload['provider'] = targetData.provider;
}

if ('linkFullname' in targetData) {
Expand Down
11 changes: 11 additions & 0 deletions r2/r2/public/static/js/expando.js
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,17 @@
this.$expando.html(this.cachedHTML);
}

if (!this._expandoEventData.provider) {
// this needs to be deferred until the actual embed markup is available.
var $media = this.$expando.children();

if ($media.is('iframe')) {
this._expandoEventData.provider = 'embedly';
} else {
this._expandoEventData.provider = 'reddit';
}
}

this.showExpandoContent();
this.fireExpandEvent();
},
Expand Down

0 comments on commit 5db40de

Please sign in to comment.