Skip to content

Commit 7371e56

Browse files
shuaiwa-metafacebook-github-bot
authored andcommitted
update attribution_data, custom_data and original_event_data fields
Summary: Update attribution_data, custom_data and original_event_data: 1. add attribution_value to attribution_data 2. add net_revenue to custom_data 3. add order_id & event_id to original_event_data Reviewed By: satwikareddy3 Differential Revision: D74686692 Privacy Context Container: L1246766 fbshipit-source-id: 8897af331397000576d0f31a18079ee799b47797
1 parent 3d8ee11 commit 7371e56

File tree

7 files changed

+126
-5
lines changed

7 files changed

+126
-5
lines changed

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,10 @@ All notable changes to this project will be documented in this file.
55

66
## Unreleased
77

8+
## v22.0.2
9+
### Changed
10+
- Update attribution_data, custom_data and original_event_data fields
11+
812
## v17.0.0
913

1014

src/FacebookAds/Object/ServerSide/AttributionData.php

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ class AttributionData implements ArrayAccess {
4242
private $attribution_share;
4343
private $attribution_model;
4444
private $attr_window;
45+
private $attribution_value;
4546

4647
protected static $param_types = array(
4748
'scope' => 'string',
@@ -52,6 +53,7 @@ class AttributionData implements ArrayAccess {
5253
'attribution_share' => 'float',
5354
'attribution_model' => 'FacebookAds\Object\ServerSide\AttributionModel',
5455
'attr_window' => 'int',
56+
'attribution_value' => 'float',
5557
);
5658

5759
protected static $attributeMap = array(
@@ -63,6 +65,7 @@ class AttributionData implements ArrayAccess {
6365
'attribution_share' => 'attribution_share',
6466
'attribution_model' => 'attribution_model',
6567
'attr_window' => 'attr_window',
68+
'attribution_value' => 'attribution_value',
6669
);
6770

6871
protected static $setters = array(
@@ -74,6 +77,7 @@ class AttributionData implements ArrayAccess {
7477
'attribution_share' => 'setAttributionShare',
7578
'attribution_model' => 'setAttributionModel',
7679
'attr_window' => 'setAttrWindow',
80+
'attribution_value' => 'setAttributionValue',
7781
);
7882

7983
protected static $getters = array(
@@ -85,6 +89,7 @@ class AttributionData implements ArrayAccess {
8589
'attribution_share' => 'getAttributionShare',
8690
'attribution_model' => 'getAttributionModel',
8791
'attr_window' => 'getAttrWindow',
92+
'attribution_value' => 'getAttributionValue',
8893
);
8994

9095
protected $container = array();
@@ -98,6 +103,7 @@ public function __construct(?array $data = null) {
98103
$this->container['attribution_share'] = isset($data['attribution_share']) ? $data['attribution_share'] : null;
99104
$this->container['attribution_model'] = isset($data['attribution_model']) ? $data['attribution_model'] : null;
100105
$this->container['attr_window'] = isset($data['attr_window']) ? $data['attr_window'] : null;
106+
$this->container['attribution_value'] = isset($data['attribution_value']) ? $data['attribution_value'] : null;
101107
}
102108

103109
public static function paramTypes() {
@@ -213,6 +219,17 @@ public function setAttrWindow($attr_window) {
213219
return $this;
214220
}
215221

222+
/**
223+
* Sets attribution_value
224+
* @param float $attribution_value The share of value generated by this click-conversion pair that is attributed to Meta.
225+
* @return $this
226+
*/
227+
public function setAttributionValue($attribution_value) {
228+
$this->container['attribution_value'] = $attribution_value;
229+
230+
return $this;
231+
}
232+
216233
/**
217234
* Gets touchpoint type.
218235
* @return string
@@ -277,6 +294,14 @@ public function getAttrWindow() {
277294
return $this->container['attr_window'];
278295
}
279296

297+
/**
298+
* Gets attribution value.
299+
* @return float
300+
*/
301+
public function getAttributionValue() {
302+
return $this->container['attribution_value'];
303+
}
304+
280305
/**
281306
* Returns true if offset exists. False otherwise.
282307
* @param integer $offset Offset
@@ -329,6 +354,7 @@ public function normalize() {
329354
$normalized_payload['attribution_share'] = $this->getAttributionShare();
330355
$normalized_payload['attribution_model'] = $this->getAttributionModel();
331356
$normalized_payload['attr_window'] = $this->getAttrWindow();
357+
$normalized_payload['attribution_value'] = $this->getAttributionValue();
332358
return $normalized_payload;
333359
}
334360

src/FacebookAds/Object/ServerSide/CustomData.php

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ class CustomData implements ArrayAccess {
3636
*/
3737
protected static $param_types = array(
3838
'value' => 'float',
39+
'net_revenue' => 'float',
3940
'currency' => 'string',
4041
'content_name' => 'string',
4142
'content_category' => 'string',
@@ -57,6 +58,7 @@ class CustomData implements ArrayAccess {
5758
*/
5859
protected static $attributeMap = array(
5960
'value' => 'value',
61+
'net_revenue' => 'net_revenue',
6062
'currency' => 'currency',
6163
'content_name' => 'content_name',
6264
'content_category' => 'content_category',
@@ -78,6 +80,7 @@ class CustomData implements ArrayAccess {
7880
*/
7981
protected static $setters = array(
8082
'value' => 'setValue',
83+
'net_revenue' => 'setNetRevenue',
8184
'currency' => 'setCurrency',
8285
'content_name' => 'setContentName',
8386
'content_category' => 'setContentCategory',
@@ -99,6 +102,7 @@ class CustomData implements ArrayAccess {
99102
*/
100103
protected static $getters = array(
101104
'value' => 'getValue',
105+
'net_revenue' => 'getNetRevenue',
102106
'currency' => 'getCurrency',
103107
'content_name' => 'getContentName',
104108
'content_category' => 'getContentCategory',
@@ -126,6 +130,7 @@ class CustomData implements ArrayAccess {
126130
*/
127131
public function __construct(?array $data = null) {
128132
$this->container['value'] = isset($data['value']) ? $data['value'] : null;
133+
$this->container['net_revenue'] = isset($data['net_revenue']) ? $data['net_revenue'] : null;
129134
$this->container['currency'] = isset($data['currency']) ? $data['currency'] : null;
130135
$this->container['content_name'] = isset($data['content_name']) ? $data['content_name'] : null;
131136
$this->container['content_category'] = isset($data['content_category']) ? $data['content_category'] : null;
@@ -190,6 +195,18 @@ public function setValue($value) {
190195
return $this;
191196
}
192197

198+
/**
199+
* Sets net_revenue
200+
* @param float $net_revenue A numeric net_revenue associated with this event.
201+
* This could be a monetary net_revenue or a net_revenue in some other metric.
202+
* @return $this
203+
*/
204+
public function setNetRevenue($net_revenue) {
205+
$this->container['net_revenue'] = $net_revenue;
206+
207+
return $this;
208+
}
209+
193210
/**
194211
* Sets currency
195212
* @param string $currency The currency for the value specified, if applicable.
@@ -422,6 +439,7 @@ public function normalize() {
422439
$normalized_payload = array();
423440

424441
$normalized_payload['value'] = $this->getValue();
442+
$normalized_payload['net_revenue'] = $this->getNetRevenue();
425443
$normalized_payload['currency'] =
426444
Normalizer::normalize('currency', $this->getCurrency());
427445
$normalized_payload['content_name'] = $this->getContentName();
@@ -476,6 +494,15 @@ public function getValue() {
476494
return $this->container['value'];
477495
}
478496

497+
/**
498+
* Gets a numeric net_revenue associated with this event.
499+
* This could be a monetary net_revenue or a net_revenue in some other metric.
500+
* @return float
501+
*/
502+
public function getNetRevenue() {
503+
return $this->container['net_revenue'];
504+
}
505+
479506
/**
480507
* Gets currency for the value specified, if applicable.
481508
* @return string

src/FacebookAds/Object/ServerSide/OriginalEventData.php

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,32 +36,44 @@ class OriginalEventData implements ArrayAccess {
3636

3737
private $event_name;
3838
private $event_time;
39+
private $order_id;
40+
private $event_id;
3941

4042
protected static $param_types = array(
4143
'event_name' => 'string',
4244
'event_time' => 'int',
45+
'order_id' => 'string',
46+
'event_id' => 'string',
4347
);
4448

4549
protected static $attributeMap = array(
4650
'event_name' => 'event_name',
4751
'event_time' => 'event_time',
52+
'order_id' => 'order_id',
53+
'event_id' => 'event_id',
4854
);
4955

5056
protected static $setters = array(
5157
'event_name' => 'setEventName',
5258
'event_time' => 'setEventTime',
59+
'order_id' => 'setOrderID',
60+
'event_id' => 'setEventID',
5361
);
5462

5563
protected static $getters = array(
5664
'event_name' => 'getEventName',
5765
'event_time' => 'getEventTime',
66+
'order_id' => 'getOrderID',
67+
'event_id' => 'getEventID',
5868
);
5969

6070
protected $container = array();
6171

6272
public function __construct(?array $data = null) {
6373
$this->container['event_name'] = isset($data['event_name']) ? $data['event_name'] : null;
6474
$this->container['event_time'] = isset($data['event_time']) ? $data['event_time'] : null;
75+
$this->container['order_id'] = isset($data['order_id']) ? $data['order_id'] : null;
76+
$this->container['event_id'] = isset($data['event_id']) ? $data['event_id'] : null;
6577
}
6678

6779
public static function paramTypes() {
@@ -111,6 +123,28 @@ public function setEventTime($event_time) {
111123
return $this;
112124
}
113125

126+
/**
127+
* Sets the order ID
128+
* @param string $order_id The order ID for this transaction as a string.
129+
* @return $this
130+
*/
131+
public function setOrderID($order_id) {
132+
$this->container['order_id'] = $order_id;
133+
134+
return $this;
135+
}
136+
137+
/**
138+
* Sets the event ID
139+
* @param string $event_id A unique string chosen by the advertiser.
140+
* @return $this
141+
*/
142+
public function setEventID($event_id) {
143+
$this->container['event_id'] = $event_id;
144+
145+
return $this;
146+
}
147+
114148
/**
115149
* Gets Meta pixel Standard Event or Custom Event name.
116150
* @return string
@@ -127,11 +161,29 @@ public function getEventTime() {
127161
return $this->container['event_time'];
128162
}
129163

164+
/**
165+
* Gets order ID of the original event.
166+
* @return string
167+
*/
168+
public function getOrderID() {
169+
return $this->container['order_id'];
170+
}
171+
172+
/**
173+
* Gets event ID of the original event.
174+
* @return string
175+
*/
176+
public function getEventID() {
177+
return $this->container['event_id'];
178+
}
179+
130180
public function normalize() {
131181
$normalized_payload = array();
132182

133183
$normalized_payload['event_name'] = $this->getEventName();
134184
$normalized_payload['event_time'] = $this->getEventTime();
185+
$normalized_payload['order_id'] = $this->getOrderID();
186+
$normalized_payload['event_id'] = $this->getEventID();
135187
return $normalized_payload;
136188
}
137189

test/FacebookAdsTest/Object/ServerSide/AttributionDataTest.php

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ public function testBuilderAndConstructor() {
3838
'attr_window' => 7,
3939
'attribution_share' => 0.5,
4040
'attribution_model' => 'last_touch'
41+
'attribution_value' => 3.45
4142
);
4243
$builder = (new AttributionData())
4344
->setScope($expected['scope'])
@@ -47,7 +48,8 @@ public function testBuilderAndConstructor() {
4748
->setCampaignId($expected['campaign_id'])
4849
->setAttrWindow($expected['attr_window'])
4950
->setAttributionShare($expected['attribution_share'])
50-
->setAttributionModel($expected['attribution_model']);
51+
->setAttributionModel($expected['attribution_model'])
52+
->setAttributionValue($expected['attribution_value']);
5153
$this->assertEquals($expected, $builder->normalize());
5254

5355
$constructor = new AttributionData(array(
@@ -58,7 +60,8 @@ public function testBuilderAndConstructor() {
5860
'campaign_id' => $expected['campaign_id'],
5961
'attr_window' => $expected['attr_window'],
6062
'attribution_share' => $expected['attribution_share'],
61-
'attribution_model' => $expected['attribution_model']
63+
'attribution_model' => $expected['attribution_model'],
64+
'attribution_value' => $expected['attribution_value']
6265
));
6366
$this->assertEquals($expected, $constructor->normalize());
6467
}

test/FacebookAdsTest/Object/ServerSide/CustomDataTest.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ public function testBuilderAndConstructor() {
3939
$content = new Content($content_state);
4040
$state = array(
4141
'value' => 0.1,
42+
'net_revenue' => 0.05,
4243
'currency' => 'usd',
4344
'content_name' => 'content-name-2',
4445
'content_category' => 'content-category-3',
@@ -59,6 +60,7 @@ public function testBuilderAndConstructor() {
5960
);
6061
$builder = (new CustomData())
6162
->setValue($state['value'])
63+
->setNetRevenue($state['net_revenue'])
6264
->setCurrency($state['currency'])
6365
->setContentName($state['content_name'])
6466
->setContentCategory($state['content_category'])
@@ -77,6 +79,7 @@ public function testBuilderAndConstructor() {
7779

7880
$constructor = new CustomData(array(
7981
'value' => $state['value'],
82+
'net_revenue' => $state['net_revenue'],
8083
'currency' => $state['currency'],
8184
'content_name' => $state['content_name'],
8285
'content_category' => $state['content_category'],

test/FacebookAdsTest/Object/ServerSide/OriginalEventDataTest.php

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -31,16 +31,22 @@ class OriginalEventDataTest extends AbstractUnitTestCase {
3131
public function testBuilderAndConstructor() {
3232
$expected = array(
3333
'event_name' => 'event-name-1',
34-
'event_time' => 123456
34+
'event_time' => 123456,
35+
'order_id' => 'order-1',
36+
'event_id' => 'event-1'
3537
);
3638
$builder = (new OriginalEventData())
3739
->setEventName($expected['event_name'])
38-
->setCurrency($expected['event_time']);
40+
->setCurrency($expected['event_time'])
41+
->setOrderID($expected['order_id'])
42+
->setEventID($expected['event_id']);
3943
$this->assertEquals($expected, $builder->normalize());
4044

4145
$constructor = new OriginalEventData(array(
4246
'event_name' => $expected['event_name'],
43-
'event_time' => $expected['event_time']
47+
'event_time' => $expected['event_time'],
48+
'order_id' => $expected['order_id'],
49+
'event_id' => $expected['event_id']
4450
));
4551
$this->assertEquals($expected, $constructor->normalize());
4652
}

0 commit comments

Comments
 (0)