Skip to content

Commit

Permalink
Add utm_source to outgoing links.
Browse files Browse the repository at this point in the history
  • Loading branch information
chuckharmston committed Jan 10, 2017
1 parent 06aba6e commit 500fb05
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 2 deletions.
2 changes: 1 addition & 1 deletion lib/messenger.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ class Messenger {
embeds.forEach(embed => {
this.msg.channel.sendEmbed(embed);
});
});
}).catch(err => console.log(err));
}

negotiateMatch(match) {
Expand Down
9 changes: 9 additions & 0 deletions lib/middleware/utm.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
const Url = require('urijs');

module.exports = (client, embed) => {
console.log(embed);
if (embed.url) {
embed.url = Url(embed.url).query({ utm_source: 'discord' }).toString();
}
return embed;
}
4 changes: 3 additions & 1 deletion lib/response-types.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ const Discord = require('discord.js');
const Url = require('urijs');

const manamoji = require('./middleware/manamoji');
const utm = require('./middleware/utm');


class TextResponse {
constructor(client, cardName) {
Expand Down Expand Up @@ -61,7 +63,7 @@ class TextResponse {
}
}

TextResponse.prototype.middleware = [ manamoji ];
TextResponse.prototype.middleware = [ manamoji, utm ];
TextResponse.prototype.url = 'https://api.scryfall.com/cards/named';


Expand Down

0 comments on commit 500fb05

Please sign in to comment.