Skip to content

Commit 2b077af

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: The attribution source to differentiate the source of the data, e.g. whether this is from AMM or Custom Attribution or any other sources - touchpoint_type: The engagement type that caused the original credited conversion - touchpoint_ts: The time when the touchpoint event occurred with the ad that the install was credited to Added full implementation including: - param_types definitions - __init__ method parameters - complete getter/setter properties - normalize() method updates - comprehensive documentation - updated test coverage Reviewed By: wenhaizhu, satwikareddy3 Differential Revision: D83868650 Privacy Context Container: L1390617 fbshipit-source-id: d390862a0f62508869771befd882db7b2bac9a7d
1 parent 500cfa1 commit 2b077af

File tree

3 files changed

+94
-2
lines changed

3 files changed

+94
-2
lines changed

CHANGELOG.md

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

55
## Unreleased
66

7+
## v24.0.0
8+
9+
10+
### Added
11+
- Add AMM fields to attribution data
12+
713
## v23.0.0
814

915

@@ -136,4 +142,3 @@ All notable changes to this project will be documented in this file.
136142
### Deprecated
137143
- `parent_id` in `AbstractCrudObject`.
138144
- Function `remote_create`, `remote_read`, `remote_update` and `remote_delete` for `AbstractCrudObject`. Check out our [recommended way](https://github.com/facebook/facebook-python-business-sdk#exploring-the-graph) to make API call with python SDK.
139-

facebook_business/adobjects/serverside/attribution_data.py

Lines changed: 82 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,9 +34,12 @@ class AttributionData(object):
3434
'attribution_model': 'AttributionModel',
3535
'attr_window': 'int',
3636
'attribution_value': 'float',
37+
'attribution_source': 'str',
38+
'touchpoint_type': 'str',
39+
'touchpoint_ts': 'int',
3740
}
3841

39-
def __init__(self, scope = None, visit_time = None, ad_id = None, adset_id = None, campaign_id = None, attribution_share = None, attribution_model = None, attr_window = None, attribution_value = None):
42+
def __init__(self, scope = None, visit_time = None, ad_id = None, adset_id = None, campaign_id = None, attribution_share = None, attribution_model = None, attr_window = None, attribution_value = None, attribution_source = None, touchpoint_type = None, touchpoint_ts = None):
4043
# type: (str, int, str, str, str, float, AttributionModel, int, float) -> None
4144

4245
"""Conversions API Attribution Data"""
@@ -49,6 +52,9 @@ def __init__(self, scope = None, visit_time = None, ad_id = None, adset_id = Non
4952
self._attribution_model = None
5053
self._attr_window = None
5154
self._attribution_value = None
55+
self._attribution_source = None
56+
self._touchpoint_type = None
57+
self._touchpoint_ts = None
5258

5359
if scope is not None:
5460
self.scope = scope
@@ -68,6 +74,12 @@ def __init__(self, scope = None, visit_time = None, ad_id = None, adset_id = Non
6874
self.attr_window = attr_window
6975
if attribution_value is not None:
7076
self.attribution_value = attribution_value
77+
if attribution_source is not None:
78+
self.attribution_source = attribution_source
79+
if touchpoint_type is not None:
80+
self.touchpoint_type = touchpoint_type
81+
if touchpoint_ts is not None:
82+
self.touchpoint_ts = touchpoint_ts
7183

7284
@property
7385
def scope(self):
@@ -270,6 +282,72 @@ def attribution_value(self, attribution_value):
270282
"""
271283
self._attribution_value = attribution_value
272284

285+
@property
286+
def attribution_source(self):
287+
"""Gets the attribution_source of Attribution Data.
288+
289+
The attribution source To differentiate the source of the data, e.g. whether this is from AMM or Custom Attribution or any other sources.
290+
291+
:return: The attribution_source of Attribution Data.
292+
:rtype: float
293+
"""
294+
return self._attribution_source
295+
296+
@attribution_source.setter
297+
def attribution_source(self, attribution_source):
298+
"""Sets the attribution_source of Attribution Data.
299+
300+
The attribution source To differentiate the source of the data, e.g. whether this is from AMM or Custom Attribution or any other sources.
301+
302+
:param attribution_source: The attribution_source of Attribution Data.
303+
:type: float
304+
"""
305+
self._attribution_source = attribution_source
306+
307+
@property
308+
def touchpoint_type(self):
309+
"""Gets the touchpoint_type of Attribution Data.
310+
311+
The engagement type that caused the original credited conversion.
312+
313+
:return: The touchpoint_type of Attribution Data.
314+
:rtype: float
315+
"""
316+
return self._touchpoint_type
317+
318+
@touchpoint_type.setter
319+
def touchpoint_type(self, touchpoint_type):
320+
"""Sets the touchpoint_type of Attribution Data.
321+
322+
The engagement type that caused the original credited conversion.
323+
324+
:param touchpoint_type: The touchpoint_type of Attribution Data.
325+
:type: float
326+
"""
327+
self._touchpoint_type = touchpoint_type
328+
329+
@property
330+
def touchpoint_ts(self):
331+
"""Gets the touchpoint_ts of Attribution Data.
332+
333+
The time when the touchpoint event occurred with the ad that the install was credited to.
334+
335+
:return: The touchpoint_ts of Attribution Data.
336+
:rtype: float
337+
"""
338+
return self._touchpoint_ts
339+
340+
@touchpoint_ts.setter
341+
def touchpoint_ts(self, touchpoint_ts):
342+
"""Sets the touchpoint_ts of Attribution Data.
343+
344+
The time when the touchpoint event occurred with the ad that the install was credited to.
345+
346+
:param touchpoint_ts: The touchpoint_ts of Attribution Data.
347+
:type: float
348+
"""
349+
self._touchpoint_ts = touchpoint_ts
350+
273351

274352
def normalize(self):
275353
normalized_payload = {
@@ -282,6 +360,9 @@ def normalize(self):
282360
'attribution_model': self.attribution_model,
283361
'attr_window': self.attr_window,
284362
'attribution_value': self.attribution_value,
363+
'attribution_source': self.attribution_source,
364+
'touchpoint_type': self.touchpoint_type,
365+
'touchpoint_ts': self.touchpoint_ts,
285366
}
286367
normalized_payload = {k: v for k, v in normalized_payload.items() if v is not None}
287368
return normalized_payload

facebook_business/adobjects/serverside/tests/attribution_data_test.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,9 @@ def test_normalize(self):
3636
'attribution_share': 0.5,
3737
'attribution_model': AttributionModel.LAST_CLICK,
3838
'attribution_value': 10.5,
39+
'attribution_source': 'amm',
40+
'touchpoint_type': 'onsite_click',
41+
'touchpoint_ts': 12345,
3942
}
4043
attribution_data = AttributionData(
4144
scope=expected['scope'],
@@ -47,6 +50,9 @@ def test_normalize(self):
4750
attribution_share=expected['attribution_share'],
4851
attribution_model=expected['attribution_model'],
4952
attribution_value=expected['attribution_value'],
53+
attribution_source=expected['attribution_source'],
54+
touchpoint_type=expected['touchpoint_type'],
55+
touchpoint_ts=expected['touchpoint_ts'],
5056
)
5157

5258
self.assertEqual(attribution_data.normalize(), expected)

0 commit comments

Comments
 (0)