Open filipiz opened 11 years ago
Hi @filipiz are you able to show me a simple example of your context config? It could just be a simple case of tweaking it.
Hi Jonathan!
Bellow you can see my config.
My tasks are executed daily, to check if users didn't forget to insert some data in one of our softwares. So..
Well, I'm using 2 contexts: production (the default) and development.
If I'm running under development context, I want to use the expectation's key to get user data from the webservice, but I don't want to send e-mail to that e-mail, I want to send it to my e-mail.
I don't know if I made myself understood. See if you can understand it.
And think about the helper. =)
module.exports = function(grunt) {
// Project configuration.
grunt.initConfig({
lint: {
all: ['grunt.js', 'src/**/*.js', 'test/**/*.js']
},
jshint: {
options: {
browser: true
}
},
qunit: {
},
togglreview : {
toggl : {
apiKey : 'xxx', //API Filipi
workspace : 000
},
reportDir : '/tmp/',
templateDir : './templates/',
mandrill : {
apiKey : 'xxx',
fromName : 'Nextt',
fromEmail : 'contato@nextt',
to : [
{email: 'filipi@nextt', name:'Filipi Zimermann', fname: 'Filipi'},
{email: 'manager@nextt', name:'The Manager', fname: 'Manager'}
]
},
expectations : {
'user1@nextt' : {journey:8, min : 6},
'user2@nextt' : {journey:8, min : 6},
}
},
context : {
development : {
options : {
togglreview : {
reportDir : '/tmp/',
mandrill : {
to : [
{email: 'filipi@nextt', name:'Filipi Zimermann', fname: 'Filipi'}
]
}
}
},
tasks : {
'default' : 'lint loadtogglusers loadtogglentries processtoggldata generatereport savereport'
}
}
}
});
grunt.loadTasks('./tasks');
grunt.loadNpmTasks('grunt-context');
// Default task.
grunt.registerTask('default', 'loadtogglusers loadtogglentries processtoggldata generatereport sendreportemail sendwarningemails');
grunt.registerTask('dev', 'context:development');
};
Hi @filipiz if I understand correctly you wish to when running "context:development" send emails to your email address instead of 'user1@nextt' when you process the expectations.
If that's the case then I'd recommend extending your togglreview task instead to support this scenario. Consider the following:
{
....
togglreview : {
....
expectations : {
users: {
'user1@nextt' : {journey:8, min : 6},
'user2@nextt' : {journey:8, min : 6}
}
}
},
context : {
development : {
options : {
togglreview : {
reportDir : '/tmp/',
mandrill : {
to : [
{email: 'filipi@nextt', name:'Filipi Zimermann', fname: 'Filipi'}
]
}
expectations : {
recipients: 'filipi@nextt'
}
}
},
tasks : {
'default' : 'lint loadtogglusers loadtogglentries processtoggldata generatereport savereport'
}
}
}
}
}
With the above I've added expectations.recipients and changed the default object to expectations.users, you could simply check for the existence of the recipients key in the togglreview task. If it exists, all mails should be sent to this instead of the user.
This has the advantage of allowing you to maintain the user emails addresses and optionally include these in the email sent to yourself.
Guys.
I miss a helper that tells me in which context my task is running (I built some tasks and I dont want some e-mails get sent on dev context).
Maybe I'll do a pull resquest for this. Just leaving the issue in case somebody else is faster than me.