It is probably more of a me problem, but it took me a good hour to figure out how emails were designated as test. This all spawned from testing test-custom_segmentation and slowly stepping through function and trying to understand each piece. Eventually I was lead to the tag_emails() function in custom-segmentation.R
which appears to be controlling it and is 1 of the 2 places in this .R script where hs_dry_run() is used... However, in my testing/debugging when I eventually make it to mc_subscriber_emails() it's not actually used as the df_ind$mc_interest var is not NA. It' not clear to me from the comments when this would be NA or not - there are 2 comments that I don't fully understand that I think are related.
i think I MIGHT GET IT... Basically, no matter what it loops through all relevant members of interest group, if hs_dry_run() is FALSE it skips it would do some matching and actually give you the email address. If TRUE (default) ...it would .... wait what!? WRONG -THATS NOT IT, I thought I was on to it...
okay so now! it looks like the test emails are being controlled by something completely different than hs_dry_run() and in fact they are a "hdx-signals-test" attribute that is tored as a tag attribute for each member. This must be done externally by some process/setting on mailchimp website? So anyways the conditional on line 120 of last code chunk says that if this tag is present return the email address.
So there we have it, I think I got there in the end, but will leave this brain dump here in the hopes that it will inspire us to simplify this. Don't see why it is not as simple as filtering a data.frame to the email addresses designated as test emails. I see the desire to pull from the mailchimp server, but geeeesh, thats tricky
It is probably more of a me problem, but it took me a good hour to figure out how emails were designated as test. This all spawned from testing
test-custom_segmentation
and slowly stepping through function and trying to understand each piece. Eventually I was lead to thetag_emails()
function incustom-segmentation.R
https://github.com/OCHA-DAP/hdx-signals/blob/37fd8ab78787c40c7ad93911a741be306e4e52f7/src/email/mailchimp/custom_segmentation.R#L140-L161
which appears to be controlling it and is 1 of the 2 places in this
.R
script wherehs_dry_run()
is used... However, in my testing/debugging when I eventually make it tomc_subscriber_emails()
it's not actually used as thedf_ind$mc_interest
var is not NA. It' not clear to me from the comments when this would be NA or not - there are 2 comments that I don't fully understand that I think are related.https://github.com/OCHA-DAP/hdx-signals/blob/37fd8ab78787c40c7ad93911a741be306e4e52f7/src/email/mailchimp/custom_segmentation.R#L98-L107
So anyway that leads me to
interest_emails()
func which also has thehs_dry_run()
.... now after staring at this code chunk for quite some time ....https://github.com/OCHA-DAP/hdx-signals/blob/37fd8ab78787c40c7ad93911a741be306e4e52f7/src/email/mailchimp/custom_segmentation.R#L114-L134
i think I MIGHT GET IT... Basically, no matter what it loops through all relevant members of interest group, if
hs_dry_run()
isFALSE
it skips it would do some matching and actually give you the email address. IfTRUE
(default) ...it would .... wait what!? WRONG -THATS NOT IT, I thought I was on to it...okay so now! it looks like the test emails are being controlled by something completely different than
hs_dry_run()
and in fact they are a"hdx-signals-test"
attribute that is tored as a tag attribute for each member. This must be done externally by some process/setting on mailchimp website? So anyways the conditional on line 120 of last code chunk says that if this tag is present return the email address.So there we have it, I think I got there in the end, but will leave this brain dump here in the hopes that it will inspire us to simplify this. Don't see why it is not as simple as filtering a data.frame to the email addresses designated as test emails. I see the desire to pull from the mailchimp server, but geeeesh, thats tricky