Skip to content

Commit

Permalink
feat: implement sd report metrics and group sb,sp report metrics
Browse files Browse the repository at this point in the history
  • Loading branch information
nguyentoanit committed Aug 18, 2020
1 parent 0c3626a commit 987c68a
Show file tree
Hide file tree
Showing 27 changed files with 319 additions and 18 deletions.
15 changes: 3 additions & 12 deletions src/operations/reports/metrics/index.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,3 @@
export * from './sponsored-products-ad-group-report-metrics'
export * from './sponsored-products-asins-report-metrics'
export * from './sponsored-products-campaign-report-metrics'
export * from './sponsored-products-keyword-report-metrics'
export * from './sponsored-products-product-ads-report-metrics'
export * from './sponsored-products-product-targeting-report-metrics'
export * from './sponsored-brands-ad-group-report-metrics'
export * from './sponsored-brands-campaign-report-metrics'
export * from './sponsored-brands-headline-search-report-metrics'
export * from './sponsored-brands-keyword-report-metrics'
export * from './sponsored-brands-search-term-report-metrics'
export * from './sponsored-brands-target-report-metrics'
export * from './sponsored-brands/index'
export * from './sponsored-display/index'
export * from './sponsored-products/index'
6 changes: 6 additions & 0 deletions src/operations/reports/metrics/sponsored-brands/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
export * from './sponsored-brands-ad-group-report-metrics'
export * from './sponsored-brands-campaign-report-metrics'
export * from './sponsored-brands-headline-search-report-metrics'
export * from './sponsored-brands-keyword-report-metrics'
export * from './sponsored-brands-search-term-report-metrics'
export * from './sponsored-brands-target-report-metrics'
5 changes: 5 additions & 0 deletions src/operations/reports/metrics/sponsored-display/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
export * from './sponsored-display-ad-group-report-metrics'
export * from './sponsored-display-campaign-report-metrics'
export * from './sponsored-display-common-report-metrics'
export * from './sponsored-display-product-ads-report-metrics'
export * from './sponsored-display-target-report-metrics'
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
import * as t from 'io-ts'
import { SponsoredDisplayCommonReportMetrics } from './sponsored-display-common-report-metrics'

/**
* Metrics specific to remarketing and T00020 tactic ad group.
*/
export const SponsoredDisplayAdGroupReportMetrics = t.union([
SponsoredDisplayCommonReportMetrics,

t.union([
/**
* The name of the ad group.
*/
t.literal('adGroupName'),

/**
* The identifier of the ad group.
*/
t.literal('adGroupId'),
]),
])

export type SponsoredDisplayAdGroupReportMetrics = t.TypeOf<
typeof SponsoredDisplayAdGroupReportMetrics
>
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
import * as t from 'io-ts'
import { SponsoredDisplayCommonReportMetrics } from './sponsored-display-common-report-metrics'

/**
* These metrics are specific to T00001 tactic campaign reports.
*/
export const SponsoredDisplayCampaignReportMetrics = t.union([
SponsoredDisplayCommonReportMetrics,

t.union([
/**
* The name of the campaign.
*/
t.literal('campaignName'),

/**
* The identifier of the campaign.
*/
t.literal('campaignId'),

/**
* The status of the campaign.
*/
t.literal('campaignStatus'),

/**
* The currency code associated with the campaign.
*/
t.literal('currency'),

/**
* Total number of ad impressions.
*/
t.literal('impressions'),

/**
* Total number of ad clicks associated with the campaign. Divide clicks by impressions to calculate click through rate (CTR).
*/
t.literal('clicks'),

/**
* The total cost of all ad clicks for the campaign. Divide cost by clicks to calculate average cost per click (CPC).
*/
t.literal('cost'),

/**
* Number of attributed detail page views occuring within 14 days of click on an ad.
*/
t.literal('attributedDPV14d'),

/**
* Number of attributed units sold occurring within 14 days of click on an ad.
*/
t.literal('attributedUnitsSold14d'),

/**
* Aggregate value of attributed sales occurring within 14 days of click on ad.
*/
t.literal('attributedSales14d'),
]),
])

export type SponsoredDisplayCampaignReportMetrics = t.TypeOf<
typeof SponsoredDisplayCampaignReportMetrics
>
Original file line number Diff line number Diff line change
@@ -0,0 +1,136 @@
import * as t from 'io-ts'

export const SponsoredDisplayCommonReportMetrics = t.union([
/**
* The name of the campaign.
*/
t.literal('campaignName'),

/**
* The identifier of the campaign.
*/
t.literal('campaignId'),

/**
* Total number of ad impressions.
*/
t.literal('impressions'),

/**
* Total number of ad clicks associated with the campaign.
*/
t.literal('clicks'),

/**
* The total cost of all ad clicks for the campaign. Divide cost by clicks to calculate average cost per click (CPC).
*/
t.literal('cost'),

/**
* The currency code associated with the campaign.
*/
t.literal('currency'),

/**
* Total number of attributed conversion events occuring within 24 hours of ad click.
*/
t.literal('attributedConversions1d'),

/**
* Total number of attributed conversion events occuring within 7 days of ad click.
*/
t.literal('attributedConversions7d'),

/**
* Total number of attributed conversion events occuring within 14 days of ad click.
*/
t.literal('attributedConversions14d'),

/**
* Total number of attributed conversion events occuring within 30 days of ad click.
*/
t.literal('attributedConversions30d'),

/**
* Total number of attributed conversion events occuring within 24 hours of ad click, where the SKU of the product advertised and the SKU of the conversion event are equivalent.
*/
t.literal('attributedConversions1dSameSKU'),

/**
* Total number of attributed conversion events occuring within 7 days of ad click, where the SKU of the product advertised and the SKU of the conversion event are equivalent.
*/
t.literal('attributedConversions7dSameSKU'),

/**
* Total number of attributed conversion events occuring within 14 days of ad click, where the SKU of the product advertised and the SKU of the conversion event are equivalent.
*/
t.literal('attributedConversions14dSameSKU'),

/**
* Total number of attributed conversion events occuring within 30 days of ad click, where the SKU of the product advertised and the SKU of the conversion event are equivalent.
*/
t.literal('attributedConversions30dSameSKU'),

/**
* Total number of attributed units ordered within 24 hours of ad click.
*/
t.literal('attributedUnitsOrdered1d'),

/**
* Total number of attributed units ordered within 7 days of ad click.
*/
t.literal('attributedUnitsOrdered7d'),

/**
* Total number of attributed units ordered within 14 days of ad click.
*/
t.literal('attributedUnitsOrdered14d'),

/**
* Total number of attributed units ordered within 30 days of ad click.
*/
t.literal('attributedUnitsOrdered30d'),

/**
* Total number of attributed sales occuring within 24 hours of ad click.
*/
t.literal('attributedSales1d'),

/**
* Total number of attributed sales occuring within 7 days of ad click.
*/
t.literal('attributedSales7d'),

/**
* Total number of attributed sales occuring within 14 days of ad click.
*/
t.literal('attributedSales14d'),

/**
* Total number of attributed sales occuring within 30 days of ad click.
*/
t.literal('attributedSales30d'),

/**
* Aggregate value of all attributed sales occuring within 24 hours of ad click, where the SKU of the product advertised and the SKU of the purchased item are equivalent.
*/
t.literal('attributedSales1dSameSKU'),

/**
* Aggregate value of all attributed sales occuring within 7 days of ad click, where the SKU of the product advertised and the SKU of the purchased item are equivalent.
*/
t.literal('attributedSales7dSameSKU'),

/**
* Aggregate value of all attributed sales occuring within 14 days of ad click, where the SKU of the product advertised and the SKU of the purchased item are equivalent.
*/
t.literal('attributedSales14dSameSKU'),

/**
* Aggregate value of all attributed sales occuring within 30 days of ad click, where the SKU of the product advertised and the SKU of the purchased item are equivalent.
*/
t.literal('attributedSales30dSameSKU'),
])
export type SponsoredDisplayCommonReportMetrics = t.TypeOf<
typeof SponsoredDisplayCommonReportMetrics
>
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
import * as t from 'io-ts'
import { SponsoredDisplayAdGroupReportMetrics } from './sponsored-display-ad-group-report-metrics'

/**
* Metrics specific to remarketing and T00020 tactic product ad.
*/
export const SponsoredDisplayProductAdsReportMetrics = t.union([
SponsoredDisplayAdGroupReportMetrics,

t.union([
/**
* The ASIN of the product.
*/
t.literal('asin'),

/**
* The SKU of the product.
*/
t.literal('sku'),

/**
* The unique numerical ID of the ad.
*/
t.literal('adId'),
]),
])

export type SponsoredDisplayProductAdsReportMetrics = t.TypeOf<
typeof SponsoredDisplayProductAdsReportMetrics
>
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
import * as t from 'io-ts'
import { SponsoredDisplayCommonReportMetrics } from './sponsored-display-common-report-metrics'

/**
* These metrics are specific to T00020 tactic targeting reports:
*/
export const SponsoredDisplayTargetReportMetrics = t.union([
SponsoredDisplayCommonReportMetrics,

t.union([
/**
* The identifier of the targeting expression used in a bid.
*/
t.literal('targetId'),

/**
* The string representation of your expression object in targeting clauses.
*/
t.literal('targetingExpression'),

/**
* The resolved string representation of your expression object in targeting clauses.
*/
t.literal('targetingText'),

/**
* The type of match for the targeting expression used in bid.
* For manually created expressions, this value is TARGETING_EXPRESSION.
* For auto-targeting expressions this value is TARGETING_EXPRESSION_PREDEFINED.
*/
t.literal('targetingType'),
]),
])

export type SponsoredDisplayTargetReportMetrics = t.TypeOf<
typeof SponsoredDisplayTargetReportMetrics
>
6 changes: 6 additions & 0 deletions src/operations/reports/metrics/sponsored-products/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
export * from './sponsored-products-ad-group-report-metrics'
export * from './sponsored-products-asins-report-metrics'
export * from './sponsored-products-campaign-report-metrics'
export * from './sponsored-products-keyword-report-metrics'
export * from './sponsored-products-product-ads-report-metrics'
export * from './sponsored-products-product-targeting-report-metrics'
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { BaseReportParams } from '../base-report-params'
import { SponsoredProductsReportType } from '../report-types'
import { SponsoredProductsAdGroupReportMetrics } from '../metrics/sponsored-products-ad-group-report-metrics'
import { SponsoredProductsAdGroupReportMetrics } from '../metrics'

export interface SponsoredProductsAdGroupReportParams
extends BaseReportParams<SponsoredProductsReportType, SponsoredProductsAdGroupReportMetrics> {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { BaseReportParams } from '../base-report-params'
import { SponsoredProductsReportType } from '../report-types'
import { SponsoredProductsAsinsReportMetrics } from '../metrics/sponsored-products-asins-report-metrics'
import { SponsoredProductsAsinsReportMetrics } from '../metrics'

export interface SponsoredProductsAsinsReportParams
extends BaseReportParams<SponsoredProductsReportType, SponsoredProductsAsinsReportMetrics> {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { BaseReportParams } from '../base-report-params'
import { SponsoredProductsReportType } from '../report-types'
import { SponsoredProductsCampaignReportMetrics } from '../metrics/sponsored-products-campaign-report-metrics'
import { SponsoredProductsCampaignReportMetrics } from '../metrics'

export interface SponsoredProductsCampaignReportParams
extends BaseReportParams<SponsoredProductsReportType, SponsoredProductsCampaignReportMetrics> {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { BaseReportParams } from '../base-report-params'
import { SponsoredProductsReportType } from '../report-types'
import { SponsoredProductsKeywordReportMetrics } from '../metrics/sponsored-products-keyword-report-metrics'
import { SponsoredProductsKeywordReportMetrics } from '../metrics'

export interface SponsoredProductsKeywordReportParams
extends BaseReportParams<SponsoredProductsReportType, SponsoredProductsKeywordReportMetrics> {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { BaseReportParams } from '../base-report-params'
import { SponsoredProductsReportType } from '../report-types'
import { SponsoredProductsProductAdsReportMetrics } from '../metrics/sponsored-products-product-ads-report-metrics'
import { SponsoredProductsProductAdsReportMetrics } from '../metrics'

export interface SponsoredProductsProductAdsReportParams
extends BaseReportParams<SponsoredProductsReportType, SponsoredProductsProductAdsReportMetrics> {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { BaseReportParams } from '../base-report-params'
import { SponsoredProductsReportType } from '../report-types'
import { SponsoredProductsProductTargetingReportMetrics } from '../metrics/sponsored-products-product-targeting-report-metrics'
import { SponsoredProductsProductTargetingReportMetrics } from '../metrics'

export interface SponsoredProductsTargetsReportParams
extends BaseReportParams<
Expand Down

0 comments on commit 987c68a

Please sign in to comment.