USAGE
Add this Workflow Activity to your site to make WebGUI beg users to come back and re-visit your site. File under ACME::EvilInventions.
View a screenshot here
DESCRIPTION
Sends custom emails to users on your site who haven't logged in for a certain number of days. You can configure:
So that you don't annoy users too much only a single email is sent to a user when their inactive streak reaches the specified number of days. If they blatantly ignore your email and don't log back in we don't send them any more emails (unless of course you set up a 3 day activity, a 4 day activity, a 5 day act.. did I say that?)
INSTALLATION
Follow the standard workflow activity installation procedure, namely:
And then add the activity to one of the workflows on your site:
TIP: If you set your log-level to INFO instead of WARN (in /data/etc/log.conf) you'll be able to see proof that users in the group you selected are being spammed ;)
ERRATA
This code was developed using TestDrivenDevelopment, hence the presence of a test file. The tests create a dummy workflow, an instance of this activity, and a test user with some fake login entries, and then triggers the activity with different parameter combinations, checking that emails are sent/not sent correctly (any emails that are sent are pulled back out of the emailQueue before they can be really sent). For want of a better place, I keep this file in /data/WebGUI/t/Asset/Wobject/ (WebGUI core doesn't have a subfolder for Workflow Activity tests yet). If you want to run the tests, create a batch file called webgui-test along the lines of:
export WEBGUI_CONFIG=/data/WebGUI/etc/myconfigfile.conf
cd /data/WebGUI/t
echo "Checking syntax:"
/data/wre/prereqs/perl/bin/perl -c Asset/Wobject/$1.t && echo && echo "Running Tests:" && /data/wre/prereqs/perl/bin/prove $2 Asset/Wobject/$1.t $3
And run the tests with the command:
./webgui-test SdhInactivityReminder -v
You should see the following output:
Checking syntax:
Asset/Wobject/SdhInactivityReminder.t syntax OK
Running Tests:
Asset/Wobject/SdhInactivityReminder....1..11
# Create test workflow and activity
ok 1 - Create workflow
ok 2 - The object isa WebGUI::Workflow
ok 3 - use WebGUI::Workflow::Activity::SdhInactivityReminder;
ok 4 - Create activity
ok 5 - The object isa WebGUI::Workflow::Activity::SdhInactivityReminder
ok 6 - Activity has an ID
ok 7 - Workflow has one activity
# Create test user, last login 4 days ago
ok 8 - The object isa WebGUI::User
# Set to remind after 3 days
ok 9 - Email handled correctly (expectEmail=0)
# Set to remind after 4 days
ok 10 - Email handled correctly (expectEmail=1)
# Set to remind after 5 days
ok 11 - Email handled correctly (expectEmail=0)
ok
All tests successful.
Files=1, Tests=11, 1 wallclock secs ( 0.30 cusr + 0.14 csys = 0.44 CPU)
The test file contains some of the test helper methods from my Wg automated testing library (which lets you do things like test wobjects by simulating a user clicking through your site, filling out fields etc..). I've only included methods such as addUser, addWorkflow and addActivity. The entire library will hopefully be cleaned up and released at some point.
--Patrick (patspam)