Skip to content

Commit 50188d6

Browse files
Ji Limeta-codesync[bot]
authored andcommitted
add new AMM fields to attribution_data
Summary: Update business SDK to include new AMM fields in attribution data: attribution_source -touchpoint_type -touchpoint_ts Updated CHANGELOG.md to document the changes in v22.0.4. Reviewed By: daegwang, satwikareddy3 Differential Revision: D83920663 Privacy Context Container: L1390617 fbshipit-source-id: bd6d6c06371d1b5a548cf510d5991d67c310c736
1 parent 7ec216a commit 50188d6

File tree

3 files changed

+95
-5
lines changed

3 files changed

+95
-5
lines changed

CHANGELOG.md

Lines changed: 4 additions & 1 deletion
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+
## v24.0.0
9+
### Changed
10+
- Add AMM fields to attribution data
11+
812
## v22.0.3
913
### Changed
1014
- Fix the OriginalEventData class to add the missing methods
@@ -161,4 +165,3 @@ All notable changes to this project will be documented in this file.
161165
$async_job = $async_job->getSelf();
162166
}
163167
```
164-

src/FacebookAds/Object/ServerSide/AttributionData.php

Lines changed: 78 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,9 @@ class AttributionData implements ArrayAccess {
4343
private $attribution_model;
4444
private $attr_window;
4545
private $attribution_value;
46+
private $attribution_source;
47+
private $touchpoint_type;
48+
private $touchpoint_ts;
4649

4750
protected static $param_types = array(
4851
'scope' => 'string',
@@ -54,6 +57,9 @@ class AttributionData implements ArrayAccess {
5457
'attribution_model' => 'FacebookAds\Object\ServerSide\AttributionModel',
5558
'attr_window' => 'int',
5659
'attribution_value' => 'float',
60+
'attribution_source' => 'string',
61+
'touchpoint_type' => 'string',
62+
'touchpoint_ts' => 'int',
5763
);
5864

5965
protected static $attributeMap = array(
@@ -66,6 +72,9 @@ class AttributionData implements ArrayAccess {
6672
'attribution_model' => 'attribution_model',
6773
'attr_window' => 'attr_window',
6874
'attribution_value' => 'attribution_value',
75+
'attribution_source' => 'attribution_source',
76+
'touchpoint_type' => 'touchpoint_type',
77+
'touchpoint_ts' => 'touchpoint_ts',
6978
);
7079

7180
protected static $setters = array(
@@ -78,6 +87,9 @@ class AttributionData implements ArrayAccess {
7887
'attribution_model' => 'setAttributionModel',
7988
'attr_window' => 'setAttrWindow',
8089
'attribution_value' => 'setAttributionValue',
90+
'attribution_source' => 'setAttributionSource',
91+
'touchpoint_type' => 'setTouchpointType',
92+
'touchpoint_ts' => 'setTouchpointTs',
8193
);
8294

8395
protected static $getters = array(
@@ -90,6 +102,9 @@ class AttributionData implements ArrayAccess {
90102
'attribution_model' => 'getAttributionModel',
91103
'attr_window' => 'getAttrWindow',
92104
'attribution_value' => 'getAttributionValue',
105+
'attribution_source' => 'getAttributionSource',
106+
'touchpoint_type' => 'getTouchpointType',
107+
'touchpoint_ts' => 'getTouchpointTs',
93108
);
94109

95110
protected $container = array();
@@ -104,6 +119,9 @@ public function __construct(?array $data = null) {
104119
$this->container['attribution_model'] = isset($data['attribution_model']) ? $data['attribution_model'] : null;
105120
$this->container['attr_window'] = isset($data['attr_window']) ? $data['attr_window'] : null;
106121
$this->container['attribution_value'] = isset($data['attribution_value']) ? $data['attribution_value'] : null;
122+
$this->container['attribution_source'] = isset($data['attribution_source']) ? $data['attribution_source'] : null;
123+
$this->container['touchpoint_type'] = isset($data['touchpoint_type']) ? $data['touchpoint_type'] : null;
124+
$this->container['touchpoint_ts'] = isset($data['touchpoint_ts']) ? $data['touchpoint_ts'] : null;
107125
}
108126

109127
public static function paramTypes() {
@@ -230,6 +248,39 @@ public function setAttributionValue($attribution_value) {
230248
return $this;
231249
}
232250

251+
/**
252+
* Sets attribution_source
253+
* @param string $attribution_source The attribution source to differentiate the source of the data, e.g. whether this is from AMM or Custom Attribution or any other sources.
254+
* @return $this
255+
*/
256+
public function setAttributionSource($attribution_source) {
257+
$this->container['attribution_source'] = $attribution_source;
258+
259+
return $this;
260+
}
261+
262+
/**
263+
* Sets touchpoint_type
264+
* @param string $touchpoint_type The engagement type that caused the original credited conversion.
265+
* @return $this
266+
*/
267+
public function setTouchpointType($touchpoint_type) {
268+
$this->container['touchpoint_type'] = $touchpoint_type;
269+
270+
return $this;
271+
}
272+
273+
/**
274+
* Sets touchpoint_ts
275+
* @param int $touchpoint_ts The time when the touchpoint event occurred with the ad that the install was credited to.
276+
* @return $this
277+
*/
278+
public function setTouchpointTs($touchpoint_ts) {
279+
$this->container['touchpoint_ts'] = $touchpoint_ts;
280+
281+
return $this;
282+
}
283+
233284
/**
234285
* Gets touchpoint type.
235286
* @return string
@@ -302,6 +353,30 @@ public function getAttributionValue() {
302353
return $this->container['attribution_value'];
303354
}
304355

356+
/**
357+
* Gets attribution source.
358+
* @return string
359+
*/
360+
public function getAttributionSource() {
361+
return $this->container['attribution_source'];
362+
}
363+
364+
/**
365+
* Gets touchpoint type.
366+
* @return string
367+
*/
368+
public function getTouchpointType() {
369+
return $this->container['touchpoint_type'];
370+
}
371+
372+
/**
373+
* Gets touchpoint timestamp.
374+
* @return int
375+
*/
376+
public function getTouchpointTs() {
377+
return $this->container['touchpoint_ts'];
378+
}
379+
305380
/**
306381
* Returns true if offset exists. False otherwise.
307382
* @param integer $offset Offset
@@ -355,6 +430,9 @@ public function normalize() {
355430
$normalized_payload['attribution_model'] = $this->getAttributionModel();
356431
$normalized_payload['attr_window'] = $this->getAttrWindow();
357432
$normalized_payload['attribution_value'] = $this->getAttributionValue();
433+
$normalized_payload['attribution_source'] = $this->getAttributionSource();
434+
$normalized_payload['touchpoint_type'] = $this->getTouchpointType();
435+
$normalized_payload['touchpoint_ts'] = $this->getTouchpointTs();
358436
return $normalized_payload;
359437
}
360438

test/FacebookAdsTest/Object/ServerSide/AttributionDataTest.php

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -37,8 +37,11 @@ public function testBuilderAndConstructor() {
3737
'campaign_id' => '345',
3838
'attr_window' => 7,
3939
'attribution_share' => 0.5,
40-
'attribution_model' => 'last_touch'
41-
'attribution_value' => 3.45
40+
'attribution_model' => 'last_touch',
41+
'attribution_value' => 3.45,
42+
'attribution_source' => 'AMM',
43+
'touchpoint_type' => 'click',
44+
'touchpoint_ts' => 1234567890
4245
);
4346
$builder = (new AttributionData())
4447
->setScope($expected['scope'])
@@ -49,7 +52,10 @@ public function testBuilderAndConstructor() {
4952
->setAttrWindow($expected['attr_window'])
5053
->setAttributionShare($expected['attribution_share'])
5154
->setAttributionModel($expected['attribution_model'])
52-
->setAttributionValue($expected['attribution_value']);
55+
->setAttributionValue($expected['attribution_value'])
56+
->setAttributionSource($expected['attribution_source'])
57+
->setTouchpointType($expected['touchpoint_type'])
58+
->setTouchpointTs($expected['touchpoint_ts']);
5359
$this->assertEquals($expected, $builder->normalize());
5460

5561
$constructor = new AttributionData(array(
@@ -61,7 +67,10 @@ public function testBuilderAndConstructor() {
6167
'attr_window' => $expected['attr_window'],
6268
'attribution_share' => $expected['attribution_share'],
6369
'attribution_model' => $expected['attribution_model'],
64-
'attribution_value' => $expected['attribution_value']
70+
'attribution_value' => $expected['attribution_value'],
71+
'attribution_source' => $expected['attribution_source'],
72+
'touchpoint_type' => $expected['touchpoint_type'],
73+
'touchpoint_ts' => $expected['touchpoint_ts']
6574
));
6675
$this->assertEquals($expected, $constructor->normalize());
6776
}

0 commit comments

Comments
 (0)