r74724 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r74723‎ | r74724 | r74725 >
Date:18:43, 13 October 2010
Author:awjrichards
Status:deferred
Tags:
Comment:
Updated utm_source handling code to allow for utm_source cleanup when adding tracking data via the API
Modified paths:
  • /trunk/extensions/DonationInterface/payflowpro_gateway/api_payflowpro_gateway.php (modified) (history)
  • /trunk/extensions/DonationInterface/payflowpro_gateway/payflowpro_gateway.body.php (modified) (history)

Diff [purge]

Index: trunk/extensions/DonationInterface/payflowpro_gateway/api_payflowpro_gateway.php
@@ -114,8 +114,16 @@
115115 // fetch the CSRF prevention token and set it if it's not already set
116116 $token = PayflowProGateway::fnPayflowEditToken( $wgPayflowGatewaySalt );
117117
 118+ // retrieve and unpack the json encoded string of tracking data
 119+ $tracking_data = json_decode( $params[ 'tracking_data' ], true );
 120+
 121+ // ensure the utm_source is formatted correctly
 122+ $utm_source_str = ( isset( $tracking_data[ 'utm_source' ] )) ? $tracking_data[ 'utm_source' ] : null;
 123+ $utm_source_id = ( isset( $tracking_data[ 'utm_source_id' ] )) ? $tracking_data[ 'utm_source_id' ] : null;
 124+ $tracking_data[ 'utm_source' ] = PayflowProGateway::getUtmSource( $utm_source_str, $utm_source_id );
 125+
118126 // fetch the contribution_tracking_id by inserting tracking data to contrib tracking table
119 - $contribution_tracking_id = PayflowProGateway::insertContributionTracking( json_decode( $params[ 'tracking_data' ], true ));
 127+ $contribution_tracking_id = PayflowProGateway::insertContributionTracking( $tracking_data );
120128
121129 // this try/catch design pattern stolen from ClickTracking/ApiSpecialClickTracking.php
122130 try {
Index: trunk/extensions/DonationInterface/payflowpro_gateway/payflowpro_gateway.body.php
@@ -933,7 +933,7 @@
934934 'order_id' => $order_id,
935935 'numAttempt' => $numAttempt,
936936 'referrer' => 'http://www.baz.test.com/index.php?action=foo&action=bar',
937 - 'utm_source' => $this->getUtmSource(),
 937+ 'utm_source' => self::getUtmSource(),
938938 'utm_medium' => $wgRequest->getText( 'utm_medium' ),
939939 'utm_campaign' => $wgRequest->getText( 'utm_campaign' ),
940940 'language' => 'en',
@@ -968,7 +968,7 @@
969969 'order_id' => $order_id,
970970 'numAttempt' => $numAttempt,
971971 'referrer' => ( $wgRequest->getVal( 'referrer' )) ? $wgRequest->getVal( 'referrer' ) : $wgRequest->getHeader( 'referer' ),
972 - 'utm_source' => $this->getUtmSource(),
 972+ 'utm_source' => self::getUtmSource(),
973973 'utm_medium' => $wgRequest->getText( 'utm_medium' ),
974974 'utm_campaign' => $wgRequest->getText( 'utm_campaign' ),
975975 // try to honr the user-set language (uselang), otherwise the language set in the URL (language)
@@ -1015,20 +1015,34 @@
10161016 *
10171017 * the utm_source is structured as: banner.landing_page.payment_instrument
10181018 *
 1019+ * @param string $utm_source The utm_source for tracking - if not passed directly,
 1020+ * we try to figure it out from the request object
 1021+ * @param int $utm_source_id The utm_source_id for tracking - if not passed directly,
 1022+ * we try to figure it out from the request object
10191023 * @return string The full utm_source
10201024 */
1021 - public function getUtmSource() {
 1025+ public static function getUtmSource( $utm_source=null, $utm_source_id=null ) {
10221026 global $wgRequest;
10231027
1024 - // fetch whatever was passed in as the utm_source
1025 - $utm_source = $wgRequest->getText( 'utm_source' );
 1028+ /**
 1029+ * fetch whatever was passed in as the utm_source
 1030+ *
 1031+ * if utm_source was not passed in as a param, we try to divine it from
 1032+ * the request. if it's not set there, no big deal, we'll just be
 1033+ * missing some tracking data.
 1034+ */
 1035+ if ( is_null( $utm_source )) {
 1036+ $utm_source = $wgRequest->getText( 'utm_source' );
 1037+ }
10261038
10271039 /**
10281040 * if we have a utm_source_id, then the user is on a single-step credit card form.
10291041 * if that's the case, we treat the single-step credit card form as a landing page,
10301042 * which we label as cc#, where # = the utm_source_id
10311043 */
1032 - $utm_source_id = $wgRequest->getVal( 'utm_source_id', 0 );
 1044+ if ( is_null( $utm_source_id )) {
 1045+ $utm_source_id = $wgRequest->getVal( 'utm_source_id', 0 );
 1046+ }
10331047
10341048 // this is how the CC portion of the utm_source should be defined
10351049 $correct_cc_source = ( $utm_source_id ) ? 'cc' . $utm_source_id . '.cc' : 'cc';

Status & tagging log