Skip to content

Commit 2495c8d

Browse files
Abutonlazebnyi
andauthored
✨ Source Snapchat Marketing : add attribution_windows and action_report_time to request parameters (#30586)
Co-authored-by: Serhii Lazebnyi <[email protected]>
1 parent ba3bdb1 commit 2495c8d

File tree

6 files changed

+60
-5
lines changed

6 files changed

+60
-5
lines changed

airbyte-integrations/connectors/source-snapchat-marketing/metadata.yaml

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ data:
88
connectorSubtype: api
99
connectorType: source
1010
definitionId: 200330b2-ea62-4d11-ac6d-cfe3e3f8ab2b
11-
dockerImageTag: 0.5.0
11+
dockerImageTag: 0.6.0
1212
dockerRepository: airbyte/source-snapchat-marketing
1313
githubIssueLabel: source-snapchat-marketing
1414
icon: snapchat.svg

airbyte-integrations/connectors/source-snapchat-marketing/pyproject.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ requires = [ "poetry-core>=1.0.0",]
33
build-backend = "poetry.core.masonry.api"
44

55
[tool.poetry]
6-
version = "0.5.0"
6+
version = "0.6.0"
77
name = "source-snapchat-marketing"
88
description = "Source implementation for Snapchat Marketing."
99
authors = [ "Airbyte <[email protected]>",]

airbyte-integrations/connectors/source-snapchat-marketing/source_snapchat_marketing/source.py

+26-3
Original file line numberDiff line numberDiff line change
@@ -165,10 +165,13 @@ class SnapchatMarketingStream(HttpStream, ABC):
165165
primary_key = "id"
166166
raise_on_http_errors = True
167167

168-
def __init__(self, start_date, end_date, **kwargs):
168+
def __init__(self, start_date, end_date, action_report_time, swipe_up_attribution_window, view_attribution_window, **kwargs):
169169
super().__init__(**kwargs)
170170
self.start_date = start_date
171171
self.end_date = end_date
172+
self.action_report_time = action_report_time
173+
self.swipe_up_attribution_window = swipe_up_attribution_window
174+
self.view_attribution_window = view_attribution_window
172175

173176
def next_page_token(self, response: requests.Response) -> Optional[Mapping[str, Any]]:
174177
next_page_cursor = response.json().get("paging", False)
@@ -246,7 +249,14 @@ def stream_slices(self, **kwargs) -> Iterable[Optional[Mapping[str, Any]]]:
246249
self.initial_state = stream_state.get(self.cursor_field) if stream_state else self.start_date
247250
self.max_state = self.initial_state
248251

249-
parent_stream = self.parent(authenticator=self.authenticator, start_date=self.start_date, end_date=self.end_date)
252+
parent_stream = self.parent(
253+
authenticator=self.authenticator,
254+
start_date=self.start_date,
255+
end_date=self.end_date,
256+
action_report_time=self.action_report_time,
257+
swipe_up_attribution_window=self.swipe_up_attribution_window,
258+
view_attribution_window=self.view_attribution_window,
259+
)
250260
stream_slices = get_parent_ids(parent_stream)
251261

252262
if stream_slices:
@@ -368,7 +378,14 @@ def parent(self) -> SnapchatMarketingStream:
368378
def stream_slices(self, **kwargs) -> Iterable[Optional[Mapping[str, Any]]]:
369379
"""Each stream slice represents each entity id from parent stream"""
370380

371-
parent_stream = self.parent(authenticator=self.authenticator, start_date=self.start_date, end_date=self.end_date)
381+
parent_stream = self.parent(
382+
authenticator=self.authenticator,
383+
start_date=self.start_date,
384+
end_date=self.end_date,
385+
action_report_time=self.action_report_time,
386+
swipe_up_attribution_window=self.swipe_up_attribution_window,
387+
view_attribution_window=self.view_attribution_window,
388+
)
372389
self.parent_name = parent_stream.name
373390
stream_slices = get_parent_ids(parent_stream)
374391

@@ -388,6 +405,9 @@ def request_params(
388405

389406
params = super().request_params(stream_state=stream_state, stream_slice=stream_slice, next_page_token=next_page_token)
390407
params["granularity"] = self.granularity.value
408+
params["action_report_time"] = self.action_report_time
409+
params["swipe_up_attribution_window"] = self.swipe_up_attribution_window
410+
params["view_attribution_window"] = self.view_attribution_window
391411
if self.metrics:
392412
params["fields"] = ",".join(self.metrics)
393413

@@ -808,6 +828,9 @@ def streams(self, config: Mapping[str, Any]) -> List[Stream]:
808828
),
809829
"start_date": config["start_date"],
810830
"end_date": config.get("end_date", default_end_date),
831+
"action_report_time": config.get("action_report_time", "conversion"),
832+
"swipe_up_attribution_window": config.get("swipe_up_attribution_window", "28_DAY"),
833+
"view_attribution_window": config.get("view_attribution_window", "1_DAY"),
811834
}
812835

813836
return [

airbyte-integrations/connectors/source-snapchat-marketing/source_snapchat_marketing/spec.json

+24
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,30 @@
4545
"examples": ["2022-01-30"],
4646
"order": 4,
4747
"format": "date"
48+
},
49+
"action_report_time": {
50+
"type": "string",
51+
"enum": ["conversion", "impression"],
52+
"title": "Action Report Time",
53+
"description": "Specifies the principle for conversion reporting.",
54+
"default": "conversion",
55+
"order": 5
56+
},
57+
"swipe_up_attribution_window": {
58+
"type": "string",
59+
"title": "Swipe Up Attribution Window",
60+
"description": "Attribution window for swipe ups.",
61+
"enum": ["1_DAY", "7_DAY", "28_DAY"],
62+
"default": "28_DAY",
63+
"order": 6
64+
},
65+
"view_attribution_window": {
66+
"type": "string",
67+
"title": "View Attribution Window",
68+
"description": "Attribution window for views.",
69+
"enum": ["1_HOUR", "3_HOUR", "6_HOUR", "1_DAY", "7_DAY"],
70+
"default": "1_DAY",
71+
"order": 7
4872
}
4973
}
5074
},

airbyte-integrations/connectors/source-snapchat-marketing/unit_tests/unit_test.py

+3
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,9 @@
2323
"authenticator": NoAuth(),
2424
"start_date": "2000-01-01",
2525
"end_date": "2000-02-10",
26+
"action_report_time": "impression",
27+
"swipe_up_attribution_window": "7_DAY",
28+
"view_attribution_window": "1_DAY",
2629
}
2730
stats_stream = AdaccountsStatsDaily(**config_mock)
2831

docs/integrations/sources/snapchat-marketing.md

+5
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,10 @@ This page guides you through the process of setting up the Snapchat Marketing so
1717
* client_secret
1818
* refresh_token
1919
* start_date
20+
* end_date
21+
* action_report_time (Optional, Default value is conversion) It specifies the principle for conversion reporting.
22+
* swipe_up_attribution_window (Optional, Default value is 1_DAY) This is the attribution window for swipe up.
23+
* view_attribution_window (Optional, Default value is 28_DAY) This is the attribution window for views.
2024
<!-- /env:oss -->
2125

2226
## Setup guide
@@ -113,6 +117,7 @@ Snapchat Marketing API has limitations to 1000 items per page.
113117
114118
| Version | Date | Pull Request | Subject |
115119
|:--------|:-----------|:---------------------------------------------------------|:-------------------------------------------------------------------------------|
120+
| 0.6.0 | 2024-04-10 | [30586](https://github.com/airbytehq/airbyte/pull/30586) | Add `attribution_windows`,`action_report_time` as optional configurable params |
116121
| 0.5.0 | 2024-03-19 | [36267](https://github.com/airbytehq/airbyte/pull/36267) | Pin airbyte-cdk version to `^0` |
117122
| 0.4.0 | 2024-02-27 | [35660](https://github.com/airbytehq/airbyte/pull/35660) | Add new fields to streams `ads`, `adsquads`, `creatives`, and `media` |
118123
| 0.3.2 | 2024-02-12 | [35171](https://github.com/airbytehq/airbyte/pull/35171) | Manage dependencies with Poetry. |

0 commit comments

Comments
 (0)