Skip to content

Commit

Permalink
Merge pull request #2 from ganpatagarwal/STOKE-1153-sync-more-report-…
Browse files Browse the repository at this point in the history
…types-for-amazon-ads

Stoke 1153 sync more report types for amazon ads
  • Loading branch information
ganpatagarwal authored Apr 5, 2023
2 parents f13700e + d7eca75 commit 6d7eeb5
Show file tree
Hide file tree
Showing 6 changed files with 116 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"streams": [
{
"stream": {
"name": "sponsored_products_report_stream",
"name": "sponsored_brands_report_stream",
"json_schema": {},
"supported_sync_modes": ["full_refresh", "incremental"],
"source_defined_primary_key": [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,8 @@
"campaigns",
"keywords",
"productAds",
"targets"
"targets",
"searchTerm"
]
},
"type": "array",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,7 @@ connectionSpecification:
- keywords
- productAds
- targets
- searchTerm
type: array
uniqueItems: true
order: 9
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@
"attributedUnitsOrdered14dSameSKU",
"attributedUnitsOrdered30dSameSKU",
],
"keywords": [
"keywords_donotuse": [
"campaignName",
"campaignId",
"adGroupName",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -89,15 +89,10 @@
"unitsSoldSameSku30d",
],
"keywords": [
"campaignName",
"campaignId",
"adGroupName",
"adGroupId",
"keywordId",
"keyword",
"matchType",
"impressions",
"clicks",
"costPerClick",
"clickThroughRate",
"cost",
"purchases1d",
"purchases7d",
Expand All @@ -123,6 +118,32 @@
"unitsSoldSameSku7d",
"unitsSoldSameSku14d",
"unitsSoldSameSku30d",
"kindleEditionNormalizedPagesRead14d",
"kindleEditionNormalizedPagesRoyalties14d",
"salesOtherSku7d",
"unitsSoldOtherSku7d",
"acosClicks7d",
"acosClicks14d",
"roasClicks7d",
"roasClicks14d",
"keywordId",
"keyword",
"campaignBudgetCurrencyCode",
"startDate",
"endDate",
"portfolioId",
"campaignName",
"campaignId",
"campaignBudgetType",
"campaignBudgetAmount",
"campaignStatus",
"keywordBid",
"adGroupName",
"adGroupId",
"keywordType",
"matchType",
"targeting",
"adKeywordStatus",
],
"targets": [
"campaignName",
Expand Down Expand Up @@ -247,6 +268,64 @@
"keywordId",
"targeting",
"keywordType",
],
"searchTerm": [
"impressions",
"clicks",
"costPerClick",
"clickThroughRate",
"cost",
"purchases1d",
"purchases7d",
"purchases14d",
"purchases30d",
"purchasesSameSku1d",
"purchasesSameSku7d",
"purchasesSameSku14d",
"purchasesSameSku30d",
"unitsSoldClicks1d",
"unitsSoldClicks7d",
"unitsSoldClicks14d",
"unitsSoldClicks30d",
"sales1d",
"sales7d",
"sales14d",
"sales30d",
"attributedSalesSameSku1d",
"attributedSalesSameSku7d",
"attributedSalesSameSku14d",
"attributedSalesSameSku30d",
"unitsSoldSameSku1d",
"unitsSoldSameSku7d",
"unitsSoldSameSku14d",
"unitsSoldSameSku30d",
"kindleEditionNormalizedPagesRead14d",
"kindleEditionNormalizedPagesRoyalties14d",
"salesOtherSku7d",
"unitsSoldOtherSku7d",
"acosClicks7d",
"acosClicks14d",
"roasClicks7d",
"roasClicks14d",
"keywordId",
"keyword",
"campaignBudgetCurrencyCode",
"startDate",
"endDate",
"portfolioId",
"searchTerm",
"campaignName",
"campaignId",
"campaignBudgetType",
"campaignBudgetAmount",
"campaignStatus",
"keywordBid",
"adGroupName",
"adGroupId",
"keywordType",
"matchType",
"targeting",
"adKeywordStatus",
]
}

Expand Down Expand Up @@ -297,7 +376,30 @@ def _get_init_report_body(self, report_date: str, record_type: str, profile):
filters = [{"field": "keywordType", "values": ["TARGETING_EXPRESSION", "TARGETING_EXPRESSION_PREDEFINED"]}]

if record_type == "keywords":
filters = [{"field": "keywordType", "values": ["BROAD", "PHRASE", "EXACT"]}]
filters = [
{
"field": "keywordType",
"values": ["BROAD", "PHRASE", "EXACT", "TARGETING_EXPRESSION", "TARGETING_EXPRESSION_PREDEFINED"]
},
{
"field": "adKeywordStatus",
"values": [
"ENABLED",
"PAUSED",
"ARCHIVED"
]
}
]

elif record_type == "searchTerm":
group_by = ["searchTerm"]
reportTypeId = "spSearchTerm"
filters = [
{
"field": "keywordType",
"values": ["BROAD", "PHRASE", "EXACT", "TARGETING_EXPRESSION", "TARGETING_EXPRESSION_PREDEFINED"]
}
]

body = {
"name": f"{record_type} report {report_date}",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ class RecordType(str, Enum):
PRODUCTADS = "productAds"
TARGETS = "targets"
ASINS = "asins"
SEARCHTERM = "searchTerm"


class Status(str, Enum):
Expand Down

0 comments on commit 6d7eeb5

Please sign in to comment.