Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Autopost to new newsletter's mailchimp which has id 243735091b #5

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 20 additions & 0 deletions lib/commands/addToMailchimp.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
const Mailchimp = require('mailchimp-api-v3')

const mailchimp = new Mailchimp(process.env.MAILCHIMP_API_KEY);

module.exports.postToMailchimp = function(userInformation) {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

entirely style related comment, feel free to ignore, but i think it's generally better to do something like:

const postToMailchimp = function(...) {
...
}

module.exports = {
  postToMailchimp,
};

console.log('Posting to mailchimp')
return mailchimp.post('/lists/243735091b/members', {
email_address: userInformation.email,
status: 'subscribed',
merge_fields: {
MMERGE3: userInformation.company_name,
MMERGE6: userInformation.name
}
})
.catch(err => {
console.log('Error adding user to mailchimp')
console.log(params)

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

feel like we should probably use console.error here, and also is params defined?

console.log(err)
})
}
4 changes: 4 additions & 0 deletions lib/res/signup.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
const Team = require("../models/team");
const qs = require("querystring");
const invite = require("../buttons/invite");
const postToMailchimp = require('../commands/addToMailchimp').postToMailchimp

const CHANNEL = process.env.SIGNUP_CHANNEL || "admin-signups";

Expand All @@ -26,6 +27,9 @@ function signup(req, res, next) {
console.log(params);

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

looks like this was here already, but do we want to leave it? is it necessary i mean? typically logs like this should be removed before merging


postToSlack(params)
.then(() => {
postToMailchimp(params);
})
.then(() => {
if (!params.redirect_uri) {
res.send(200, "signup request sent");
Expand Down