Comment embeds: protect against empty "created" timestamp

[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
This commit is contained in:
xiongchiamiov
2015-05-29 16:17:04 -07:00
parent 22f64446e3
commit e150c1e2e9

View File

@@ -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,
@@ -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];