Skip to content

Commit cd78c06

Browse files
Ji Limeta-codesync[bot]
authored andcommitted
Add additional AMM fields to AttributionData
Summary: This diff adds four new AMM (Advanced Measurement and Matching) fields to the PHP Business SDK AttributionData class: 1. **attribution_method** (AttributionMethod): The attribution method used to attribute the event (constants: ARD, DEEPLINK, GPIR, INVALID_RESPONSE, MIR, SRN with lowercase string values) 2. **decline_reason** (DeclineReason): The decline reason for the attribution (constants: ATTRIBUTE_TO_OTHER_SOURCE, OUT_OF_LOOKBACK_WINDOW, LOOKBACK, INACTIVE, FRAUD_DETECTED, etc. with lowercase string values) 3. **auditing_token** (string): The auditing token for the attribution 4. **linkage_key** (string): The linkage key for the attribution These fields are part of the ongoing work to enhance attribution tracking capabilities in the Conversions API. This builds upon the initial AMM fields added in v24.0.0. **Changes:** - Created new enum classes extending AbstractEnum: `AttributionMethod.php` and `DeclineReason.php` - Updated `AttributionData.php` with new fields, param_types, attributeMap, setters, getters, constructor initialization, and normalize method - Updated `AttributionDataTest.php` to test the new fields in both builder and constructor patterns - Updated CHANGELOG.md to version v24.0.1 Reviewed By: shuaiwa-meta, satwikareddy3 Differential Revision: D85200641 fbshipit-source-id: d245aa3a7261a4957db2d1beb2881387819929b9
1 parent f9bf629 commit cd78c06

File tree

6 files changed

+475
-4
lines changed

6 files changed

+475
-4
lines changed

CHANGELOG.md

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,13 @@ All notable changes to this project will be documented in this file.
55

66
## Unreleased
77

8+
## v24.0.1
9+
### Added
10+
- Add additional AMM fields: attribution_method, decline_reason, auditing_token, linkage_key
11+
- Add attribution_setting nested field with inactivity_window_hours, reattribution_window_hours
12+
813
## v24.0.0
9-
### Changed
14+
### Added
1015
- Add AMM fields to attribution data
1116

1217
## v22.0.3

src/FacebookAds/Object/ServerSide/AttributionData.php

Lines changed: 131 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,11 @@ class AttributionData implements ArrayAccess {
4646
private $attribution_source;
4747
private $touchpoint_type;
4848
private $touchpoint_ts;
49+
private $attribution_method;
50+
private $decline_reason;
51+
private $auditing_token;
52+
private $linkage_key;
53+
private $attribution_setting;
4954

5055
protected static $param_types = array(
5156
'scope' => 'string',
@@ -60,6 +65,11 @@ class AttributionData implements ArrayAccess {
6065
'attribution_source' => 'string',
6166
'touchpoint_type' => 'string',
6267
'touchpoint_ts' => 'int',
68+
'attribution_method' => 'FacebookAds\Object\ServerSide\AttributionMethod',
69+
'decline_reason' => 'FacebookAds\Object\ServerSide\DeclineReason',
70+
'auditing_token' => 'string',
71+
'linkage_key' => 'string',
72+
'attribution_setting' => 'FacebookAds\Object\ServerSide\AttributionSetting',
6373
);
6474

6575
protected static $attributeMap = array(
@@ -75,6 +85,11 @@ class AttributionData implements ArrayAccess {
7585
'attribution_source' => 'attribution_source',
7686
'touchpoint_type' => 'touchpoint_type',
7787
'touchpoint_ts' => 'touchpoint_ts',
88+
'attribution_method' => 'attribution_method',
89+
'decline_reason' => 'decline_reason',
90+
'auditing_token' => 'auditing_token',
91+
'linkage_key' => 'linkage_key',
92+
'attribution_setting' => 'attribution_setting',
7893
);
7994

8095
protected static $setters = array(
@@ -90,6 +105,11 @@ class AttributionData implements ArrayAccess {
90105
'attribution_source' => 'setAttributionSource',
91106
'touchpoint_type' => 'setTouchpointType',
92107
'touchpoint_ts' => 'setTouchpointTs',
108+
'attribution_method' => 'setAttributionMethod',
109+
'decline_reason' => 'setDeclineReason',
110+
'auditing_token' => 'setAuditingToken',
111+
'linkage_key' => 'setLinkageKey',
112+
'attribution_setting' => 'setAttributionSetting',
93113
);
94114

95115
protected static $getters = array(
@@ -105,6 +125,11 @@ class AttributionData implements ArrayAccess {
105125
'attribution_source' => 'getAttributionSource',
106126
'touchpoint_type' => 'getTouchpointType',
107127
'touchpoint_ts' => 'getTouchpointTs',
128+
'attribution_method' => 'getAttributionMethod',
129+
'decline_reason' => 'getDeclineReason',
130+
'auditing_token' => 'getAuditingToken',
131+
'linkage_key' => 'getLinkageKey',
132+
'attribution_setting' => 'getAttributionSetting',
108133
);
109134

110135
protected $container = array();
@@ -122,6 +147,11 @@ public function __construct(?array $data = null) {
122147
$this->container['attribution_source'] = isset($data['attribution_source']) ? $data['attribution_source'] : null;
123148
$this->container['touchpoint_type'] = isset($data['touchpoint_type']) ? $data['touchpoint_type'] : null;
124149
$this->container['touchpoint_ts'] = isset($data['touchpoint_ts']) ? $data['touchpoint_ts'] : null;
150+
$this->container['attribution_method'] = isset($data['attribution_method']) ? $data['attribution_method'] : null;
151+
$this->container['decline_reason'] = isset($data['decline_reason']) ? $data['decline_reason'] : null;
152+
$this->container['auditing_token'] = isset($data['auditing_token']) ? $data['auditing_token'] : null;
153+
$this->container['linkage_key'] = isset($data['linkage_key']) ? $data['linkage_key'] : null;
154+
$this->container['attribution_setting'] = isset($data['attribution_setting']) ? $data['attribution_setting'] : null;
125155
}
126156

127157
public static function paramTypes() {
@@ -281,6 +311,61 @@ public function setTouchpointTs($touchpoint_ts) {
281311
return $this;
282312
}
283313

314+
/**
315+
* Sets attribution_method
316+
* @param string $attribution_method The attribution method used to attribute the event.
317+
* @return $this
318+
*/
319+
public function setAttributionMethod($attribution_method) {
320+
$this->container['attribution_method'] = $attribution_method;
321+
322+
return $this;
323+
}
324+
325+
/**
326+
* Sets decline_reason
327+
* @param string $decline_reason The decline reason for the attribution.
328+
* @return $this
329+
*/
330+
public function setDeclineReason($decline_reason) {
331+
$this->container['decline_reason'] = $decline_reason;
332+
333+
return $this;
334+
}
335+
336+
/**
337+
* Sets auditing_token
338+
* @param string $auditing_token The auditing token for the attribution.
339+
* @return $this
340+
*/
341+
public function setAuditingToken($auditing_token) {
342+
$this->container['auditing_token'] = $auditing_token;
343+
344+
return $this;
345+
}
346+
347+
/**
348+
* Sets linkage_key
349+
* @param string $linkage_key The linkage key for the attribution.
350+
* @return $this
351+
*/
352+
public function setLinkageKey($linkage_key) {
353+
$this->container['linkage_key'] = $linkage_key;
354+
355+
return $this;
356+
}
357+
358+
/**
359+
* Sets attribution_setting
360+
* @param AttributionSetting $attribution_setting The attribution setting for the attribution.
361+
* @return $this
362+
*/
363+
public function setAttributionSetting($attribution_setting) {
364+
$this->container['attribution_setting'] = $attribution_setting;
365+
366+
return $this;
367+
}
368+
284369
/**
285370
* Gets touchpoint type.
286371
* @return string
@@ -377,6 +462,46 @@ public function getTouchpointTs() {
377462
return $this->container['touchpoint_ts'];
378463
}
379464

465+
/**
466+
* Gets attribution method.
467+
* @return string
468+
*/
469+
public function getAttributionMethod() {
470+
return $this->container['attribution_method'];
471+
}
472+
473+
/**
474+
* Gets decline reason.
475+
* @return string
476+
*/
477+
public function getDeclineReason() {
478+
return $this->container['decline_reason'];
479+
}
480+
481+
/**
482+
* Gets auditing token.
483+
* @return string
484+
*/
485+
public function getAuditingToken() {
486+
return $this->container['auditing_token'];
487+
}
488+
489+
/**
490+
* Gets linkage key.
491+
* @return string
492+
*/
493+
public function getLinkageKey() {
494+
return $this->container['linkage_key'];
495+
}
496+
497+
/**
498+
* Gets attribution setting.
499+
* @return AttributionSetting
500+
*/
501+
public function getAttributionSetting() {
502+
return $this->container['attribution_setting'];
503+
}
504+
380505
/**
381506
* Returns true if offset exists. False otherwise.
382507
* @param integer $offset Offset
@@ -433,6 +558,12 @@ public function normalize() {
433558
$normalized_payload['attribution_source'] = $this->getAttributionSource();
434559
$normalized_payload['touchpoint_type'] = $this->getTouchpointType();
435560
$normalized_payload['touchpoint_ts'] = $this->getTouchpointTs();
561+
$normalized_payload['attribution_method'] = $this->getAttributionMethod();
562+
$normalized_payload['decline_reason'] = $this->getDeclineReason();
563+
$normalized_payload['auditing_token'] = $this->getAuditingToken();
564+
$normalized_payload['linkage_key'] = $this->getLinkageKey();
565+
$attribution_setting = $this->getAttributionSetting();
566+
$normalized_payload['attribution_setting'] = $attribution_setting != null ? $attribution_setting->normalize() : null;
436567
return $normalized_payload;
437568
}
438569

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
<?php
2+
/**
3+
* Copyright (c) 2015-present, Facebook, Inc. All rights reserved.
4+
*
5+
* You are hereby granted a non-exclusive, worldwide, royalty-free license to
6+
* use, copy, modify, and distribute this software in source code or binary
7+
* form for use in connection with the web services and APIs provided by
8+
* Facebook.
9+
*
10+
* As with any software that integrates with the Facebook platform, your use
11+
* of this software is subject to the Facebook Developer Principles and
12+
* Policies [http://developers.facebook.com/policy/]. This copyright notice
13+
* shall be included in all copies or substantial portions of the software.
14+
*
15+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
18+
* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
20+
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
21+
* DEALINGS IN THE SOFTWARE.
22+
*
23+
*/
24+
25+
namespace FacebookAds\Object\ServerSide;
26+
27+
use FacebookAds\Enum\AbstractEnum;
28+
29+
/**
30+
* Class AttributionMethod
31+
* @package FacebookAds\Object\ServerSide
32+
*/
33+
class AttributionMethod extends AbstractEnum {
34+
35+
const ARD = 'ard';
36+
const DEEPLINK = 'deeplink';
37+
const GPIR = 'gpir';
38+
const INVALID_RESPONSE = 'invalid_response';
39+
const MIR = 'mir';
40+
const SRN = 'srn';
41+
42+
public function getFieldTypes() {
43+
return array(
44+
'ARD' => 'string',
45+
'DEEPLINK' => 'string',
46+
'GPIR' => 'string',
47+
'INVALID_RESPONSE' => 'string',
48+
'MIR' => 'string',
49+
'SRN' => 'string',
50+
);
51+
}
52+
}

0 commit comments

Comments
 (0)