From e150c1e2e9205c5026d7fae0407d4917c8b94ead Mon Sep 17 00:00:00 2001 From: xiongchiamiov Date: Fri, 29 May 2015 16:17:04 -0700 Subject: [PATCH] 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 --- r2/r2/public/static/js/embed/embed.js | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/r2/r2/public/static/js/embed/embed.js b/r2/r2/public/static/js/embed/embed.js index d6eb26df7..dd3798fa2 100644 --- a/r2/r2/public/static/js/embed/embed.js +++ b/r2/r2/public/static/js/embed/embed.js @@ -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];