Skip to content

Commit

Permalink
added other revenue type.
Browse files Browse the repository at this point in the history
  • Loading branch information
noitcudni committed Dec 3, 2010
1 parent ff62efa commit dff5bbc
Show file tree
Hide file tree
Showing 3 changed files with 48 additions and 20 deletions.
15 changes: 12 additions & 3 deletions examples/index.php
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,11 @@
$kt->track_indirect_revenue($uid, 1130, "st1", "st22", "st333");
break;
}

case "php other revenue":
{
$kt->track_other_revenue($uid, 1130, "st1", "st22", "st333");
break;
}
case "php event":
{
$kt->track_event($uid, "test php event", 10, 2,
Expand Down Expand Up @@ -176,12 +180,14 @@
<input name="clicked_button" type="submit" value="php credits revenue"/>
<input name="clicked_button" type="submit" value="php direct revenue"/>
<input name="clicked_button" type="submit" value="php indirect revenue"/>
<input name="clicked_button" type="submit" value="php other revenue"/>

<input name="clicked_button" type="button" value="js revenue" onclick="test_js_revenue()"/>
<input name="clicked_button" type="button" value="js advertisement revenue" onclick="test_js_adveritisement_revenue()"/>
<input name="clicked_button" type="button" value="js advertisement revenue" onclick="test_js_advertisement_revenue()"/>
<input name="clicked_button" type="button" value="js credits revenue" onclick="test_js_credits_revenue()"/>
<input name="clicked_button" type="button" value="js direct revenue" onclick="test_js_direct_revenue()"/>
<input name="clicked_button" type="button" value="js indirect revenue" onclick="test_js_indirect_revenue()"/>
<input name="clicked_button" type="button" value="js other revenue" onclick="test_js_other_revenue()"/>

<input name="clicked_button" type="submit" value="php event"/>
<input name="clicked_button" type="button" value="js event" onclick="test_js_event()"/>
Expand Down Expand Up @@ -362,7 +368,7 @@ function(response){
function test_js_revenue(){
kt.track_revenue(220, "advertisement", "st111", "st222", "st3333");
}
function test_js_adveritisement_revenue(){
function test_js_advertisement_revenue(){
kt.track_advertisement_revenue(220, "st111", "st222", "st3333");
}
function test_js_credits_revenue(){
Expand All @@ -374,6 +380,9 @@ function test_js_direct_revenue(){
function test_js_indirect_revenue(){
kt.track_indirect_revenue(220, "st111", "st222", "st3333");
}
function test_js_other_revenue(){
kt.track_other_revenue(220, "st111", "st222", "st333");
}

function test_js_event(){
kt.track_event("js event", 2, 10, "jsSt1", "jsSt2", "jsSt3");
Expand Down
20 changes: 14 additions & 6 deletions js/kontagent.js
Original file line number Diff line number Diff line change
Expand Up @@ -403,7 +403,7 @@ Kontagent.prototype = {
this.kt_outbound_msg('cpu', params);
},

track_revenue : function(amount_in_cents, revenue_type,
track_revenue_impl : function(amount_in_cents, revenue_type,
st1, st2, st3)
{
var uid = FB.getSession().uid;
Expand All @@ -418,22 +418,30 @@ Kontagent.prototype = {
this.kt_outbound_msg('mtu', params);
}
},

// backward compatible
track_revenue : function(amount_in_cents)
{
this.track_revenue_impl(amount_in_cents, null, null, null, null);
},
track_advertisement_revenue : function(amount_in_cents, st1, st2, st3)
{
this.track_revenue(amount_in_cents, "advertisement", st1, st2, st3);
this.track_revenue_impl(amount_in_cents, "advertisement", st1, st2, st3);
},
track_credits_revenue : function(amount_in_cents, st1, st2, st3)
{
this.track_revenue(amount_in_cents, "credits", st1, st2, st3);
this.track_revenue_impl(amount_in_cents, "credits", st1, st2, st3);
},
track_direct_revenue : function(amount_in_cents, st1, st2, st3)
{
this.track_revenue(amount_in_cents, "direct", st1, st2, st3);
this.track_revenue_impl(amount_in_cents, "direct", st1, st2, st3);
},
track_indirect_revenue : function(amount_in_cents, st1, st2, st3)
{
this.track_revenue(amount_in_cents, "indirect", st1, st2, st3);
this.track_revenue_impl(amount_in_cents, "indirect", st1, st2, st3);
},
track_other_revenue : function(amount_in_cents, st1, st2, st3)
{
this.track_revenue_impl(amount_in_cents, "other", st1, st2, st3);
},

track_event : function(event_name, value, level,
Expand Down
33 changes: 22 additions & 11 deletions php/kontagent.php
Original file line number Diff line number Diff line change
Expand Up @@ -397,37 +397,48 @@ public function gen_tracking_revenue_url($uid, $amount_in_cents,
if(isset($st3)) $params['st3'] = $st3;
return $this->m_kt_comm_layer->gen_tracking_url('v1', 'mtu', $params);
}
public function track_revenue($uid, $amount_in_cents,
$revenue_type=null, $st1=null, $st2=null, $st3=null)

public function track_revenue_impl($uid, $amount_in_cents,
$revenue_type, $st1=null, $st2=null, $st3=null)
{
$tracking_url = $this->gen_tracking_revenue_url($uid, $amount_in_cents,
$revenue_type, $st1, $st2, $st3);
$this->m_kt_comm_layer->api_call_method($tracking_url);
}

// backward compatible
public function track_revenue($uid, $amount_in_cents)
{
$this->track_revenue_impl($uid, $amount_in_cents, null, null, null, null);
}
public function track_advertisement_revenue($uid, $amount_in_cents,
$st1=null, $st2=null, $st3=null)
{
$this->track_revenue($uid, $amount_in_cents, "advertisement",
$st1, $st2, $st3);
$this->track_revenue_impl($uid, $amount_in_cents, "advertisement",
$st1, $st2, $st3);
}
public function track_credits_revenue($uid, $amount_in_cents,
$st1=null, $st2=null, $st3=null)
{
$this->track_revenue($uid, $amount_in_cents, "credits",
$st1, $st2, $st3);
$this->track_revenue_impl($uid, $amount_in_cents, "credits",
$st1, $st2, $st3);
}
public function track_direct_revenue($uid, $amount_in_cents,
$st1=null, $st2=null, $st3=null)
{
$this->track_revenue($uid, $amount_in_cents, "direct",
$st1, $st2, $st3);
$this->track_revenue_impl($uid, $amount_in_cents, "direct",
$st1, $st2, $st3);
}
public function track_indirect_revenue($uid, $amount_in_cents,
$st1=null, $st2=null, $st3=null)
{
$this->track_revenue($uid, $amount_in_cents, "indirect",
$st1, $st2, $st3);
$this->track_revenue_impl($uid, $amount_in_cents, "indirect",
$st1, $st2, $st3);
}
public function track_other_revenue($uid, $amount_in_cents,
$st1=null, $st2=null, $st3=null)
{
$this->track_revenue_impl($uid, $amount_in_cents, "other",
$st1, $st2, $st3);
}

public function gen_tracking_event_url($uid, $event_name, $value=null, $level=null,
Expand Down

0 comments on commit dff5bbc

Please sign in to comment.