Skip to content
This repository has been archived by the owner on Nov 9, 2017. It is now read-only.

Commit

Permalink
Comment embeds: protect against empty "created" timestamp
Browse files Browse the repository at this point in the history
[A BuzzFeed article][0] with a bunch of comment embeds has been causing
difficulty for the data team, since none of the embeds have the
`data-embed-created` field in the embed.

Figuring out why that's happening is another issue we should tackle, but in the
meantime, let's avoid sending a nonsense value if we don't have something
useful.

[0]: http://www.buzzfeed.com/sarahgalo/books-according-to-reddit
  • Loading branch information
xiongchiamiov committed Jun 1, 2015
1 parent 22f6444 commit e150c1e
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion r2/r2/public/static/js/embed/embed.js
Expand Up @@ -55,7 +55,6 @@
'event_ts': now.getTime(),
'event_ts_utc_offset': now.getTimezoneOffset() / -60,
'user_agent': navigator.userAgent,
'embed_ts_created': config.created,
'sr_id': thing.sr_id,
'sr_name': thing.sr_name,
'embed_id': thing.id,
Expand All @@ -67,6 +66,13 @@
'comment_deleted': thing.deleted,
'uuid': App.utils.uuid(),
};

// If the creation field doesn't exist (due to manual modification, bad
// oEmbed plugin, etc.), don't send the field at all to avoid messing up
// the data pipeline.
if (config.created !== "null") {
data['embed_ts_created'] = config.created;
}

for (var name in payload) {
data[name] = payload[name];
Expand Down

0 comments on commit e150c1e

Please sign in to comment.