Class ShrimpTest

Description

ShrimpTest Core class

The core ShrimpTest controller class. One global instance of this class is created, as $shrimp.

Located in /classes/core.php (line 17)


	
			
Variable Summary
Method Summary
ShrimpTest ShrimpTest ()
bool blocked_visit ([string $user_agent = false])
void check_cookie ()
void ensure_db ()
bool exempt_visitor ()
string get_interface_slug ()
int get_override_variant (int $experiment_id)
int get_visitor_variant (int $experiment_id, [int $visitor_id = false])
boolean has_been_touched ()
void init ()
void load_plugins ()
void print_foot ()
int set_cookie ()
void touch_experiment (int $experiment_id, array $args)
void touch_metric (int $experiment_id, array $args)
float update_visitor_metric (int $experiment_id, float $value, [boolean $monotonic = false], [int $visitor_id = false])
void versioning ()
Variables
int $cookie_days (line 41)

How long ShrimpTest cookies should live for

string $cookie_domain (line 23)

Some cookie environment constants based on WordPress install

string $cookie_dough (line 36)

A random hash used to produce the random cookie values

string $cookie_name (line 31)

By default, set to "ebisen"

string $cookie_path (line 24)

Some cookie environment constants based on WordPress install

int $db_version = 28 (line 47)

Database schema version: change to force database schema update

ShrimpTest_Interface $interface = null (line 86)

reference to the ShrimpTest_Interface instance

ShrimpTest_Model $model = null (line 91)

reference to the ShrimpTest_Model instance

array $override_variants (line 80)

An array which maps experiments to overridden variants, for when the logged-in user has used the variant preview to override the variant they are viewing.

array $touched_experiments (line 67)

A collection of information on the experiments which were "touched" during this execution.

array $touched_metrics (line 73)

A collection of information on the metrics which were "touched" during this execution.

string $visitor_cookie (line 59)

Variables to track information about/throughout the current execution

int $visitor_id (line 55)

Variables to track information about/throughout the current execution

Methods
Constructor ShrimpTest (line 99)

ShrimpTest constructor

Hint: run init() to get the party started.

ShrimpTest ShrimpTest ()
blocked_visit (line 283)

Check whether this visitor/visit should be "blocked" from the testing pool.

A visit is blocked if it's an AJAX or XMLRPC call, if we're in wp-admin, or if the shrimptest_blocked_visit filter returns true.

bool blocked_visit ([string $user_agent = false])
  • string $user_agent: user agent string
check_cookie (line 201)

Check to see if the user has a valid ShrimpTest cookie. If not, calls set_cookie().

This will only happen if the user is not "exempt", as determined by exempt_visitor().

void check_cookie ()
ensure_db (line 605)

Make sure that our tables are set up.

  • global: wpdb $wpdb:
void ensure_db ()
exempt_visitor (line 314)

Check whether the visitor/visit is exempt from ShrimpTest behavior.

A user is exempt if they're logged in or if the shrimptest_exempt_visitor filter returns true.

bool exempt_visitor ()
get_interface_slug (line 580)

Get the $slug variable from the active ShrimpTest_Interface

string get_interface_slug ()
get_override_variant (line 406)

Get the current user's "override" variant id for a particular experiment.

A variant is "overridden" when the variant preview feature is used.

int get_override_variant (int $experiment_id)
  • int $experiment_id
get_touched_experiments (line 441)

Get the array of experiments which have been "touched" throughout this execution.

void get_touched_experiments ()
get_touched_metrics (line 463)

Get the array of metrics which have been "touched" throughout this execution.

void get_touched_metrics ()
get_visitor_variant (line 340)

Get the current visitor's variant id for a particular experiment id

This function will return a variant id for the current (or given) visitor and the given experiment, first checking if the user has an "override" set. It will only work if the visitor is not exempt.

Returns null if unavailable.

int get_visitor_variant (int $experiment_id, [int $visitor_id = false])
  • int $experiment_id
  • int $visitor_id
has_been_touched (line 472)

Check whether we have "touched" any experiments or metrics during execution.

boolean has_been_touched ()
init (line 111)

The actual initialization function

Initializes all the internal cookie settings, calls load_model_and_interface(), load_default_metric_and_variant(), load_plugins(), and then registers a number of actions.

Must be called separately, after the constructor.

void init ()
load_default_metric_and_variant (line 176)

Load the default metric and variant types: the "manual" type

void load_default_metric_and_variant ()
load_model_and_interface (line 148)

Initialize a ShrimpTest_Model as $model and ShrimpTest_Interface as $interface

The SHRIMPTEST_MODEL_CLASS and SHRIMPTEST_INTERFACE_CLASS constants are used as the model and interface class names, respectively.

void load_model_and_interface ()
load_plugins (line 184)

Load all files in the /plugins directory

void load_plugins ()
override_variant (line 557)

Records the "override" variant specified in the $_POST request.

  • global: int $user_ID:
void override_variant ()
print_foot (line 486)

Prints a script in the footer to support accurate counting of "unique human visitors".

void print_foot ()
record_cookieability (line 533)

Record the "cookieability" of a user who has pinged back

The script printed by print_foot() will ping back, if the user has JavaScript. This ping will then tell us whether the user actually picked up the cookie we sent them or not. Only users whose cookies were picked up are used in statistics.

void record_cookieability ()
set_cookie (line 246)

Sets the cookie and returns the visitor id

int set_cookie ()
touch_experiment (line 429)

"Touch" an experiment, with the given arguments

This function is used to keep track of what experiments were accessed ("touched") througout the printing of the current page. This information is not normally printed, but is used to produce the ShrimpTest bar (or ShrimpTest component of the Admin Bar) when an admin is logged in.

void touch_experiment (int $experiment_id, array $args)
  • int $experiment_id
  • array $args
touch_metric (line 451)

Like touch_experiment, but for metrics

void touch_metric (int $experiment_id, array $args)
  • int $experiment_id
  • array $args
update_visitor_metric (line 377)

Update a goal metric's value for the current (or given user)

Returns the updated value.

float update_visitor_metric (int $experiment_id, float $value, [boolean $monotonic = false], [int $visitor_id = false])
  • int $experiment_id
  • float $value
  • boolean $monotonic: if true, will only update if the value is greater (optional)
  • int $visitor_id
versioning (line 589)

Adds DB versioning support

Note here I use site_option because ShrimpTest db tables exist for each site.

void versioning ()

Documentation generated on Sat, 04 Sep 2010 23:40:57 -0400 by phpDocumentor 1.4.3