From 5a8b7911e678e6428842da2167aa316a8d32a873 Mon Sep 17 00:00:00 2001 From: Sean Capaloff-Jones Date: Fri, 11 Oct 2024 18:02:24 +0000 Subject: [PATCH 1/4] formatting and linting --- .github/workflows/build.yaml | 2 +- .lintstagedrc | 2 +- .prettierignore | 4 ++-- dv360_api/dv360.ts | 38 ++++++++++-------------------------- dv360_api/dv360_resources.ts | 6 ++---- dv360_api/utils.ts | 2 +- eslint.config.js | 2 +- 7 files changed, 18 insertions(+), 38 deletions(-) diff --git a/.github/workflows/build.yaml b/.github/workflows/build.yaml index 48169c3..cef4b84 100644 --- a/.github/workflows/build.yaml +++ b/.github/workflows/build.yaml @@ -31,7 +31,7 @@ jobs: run: npx yarn lint-staged - name: Prettier check - run: npx yarn prettier -c dv360/src/**/*.ts sa360/src/**/*.ts cm360/**/*.js googleads/old/src/**/*.ts + run: npx prettier -c dv360/src/**/*.ts sa360/src/**/*.ts cm360/**/*.js googleads/old/src/**/*.ts - name: Print errors run: find . -name "*.warn" -type f -exec cat {} \; diff --git a/.lintstagedrc b/.lintstagedrc index 02c5bc3..718a50c 100644 --- a/.lintstagedrc +++ b/.lintstagedrc @@ -1 +1 @@ -{ '**/*.{ts, js}': ['npx prettier --write .'] } +{"**/*.{ts, js}": ["npx prettier --write ."]} diff --git a/.prettierignore b/.prettierignore index bdd99fc..53fa88e 100644 --- a/.prettierignore +++ b/.prettierignore @@ -1,3 +1,3 @@ +*.json node_modules -.prettierrc -googleads/*.js +.* \ No newline at end of file diff --git a/dv360_api/dv360.ts b/dv360_api/dv360.ts index 68959e5..ea93d18 100644 --- a/dv360_api/dv360.ts +++ b/dv360_api/dv360.ts @@ -789,35 +789,28 @@ export class InventorySources extends DisplayVideoApiClient { /** * @throws {!Error} As this method is not allowed for this type */ - override createResource( - requestUri: string, - payload: DisplayVideoResource, - ): DisplayVideoResource { + override createResource(): DisplayVideoResource { throw ObjectUtil.error('405 Method Not Allowed'); } /** * @throws {!Error} As this method is not allowed for this type */ - override patchResource(requestUri: string): DisplayVideoResource { + override patchResource(): DisplayVideoResource { throw ObjectUtil.error('405 Method Not Allowed'); } /** * @throws {!Error} As this method is not allowed for this type */ - override patchResourceByComparison( - requestUri: string, - original: DisplayVideoResource, - modified: DisplayVideoResource | null, - ): DisplayVideoResource { + override patchResourceByComparison(): DisplayVideoResource { throw ObjectUtil.error('405 Method Not Allowed'); } /** * @throws {!Error} As this method is not allowed for this type */ - override deleteResource(requestUri: string) { + override deleteResource() { throw ObjectUtil.error('405 Method Not Allowed'); } @@ -952,35 +945,28 @@ export class TargetingOptions extends DisplayVideoApiClient { /** * @throws {!Error} As this method is not allowed for this type */ - override createResource( - requestUri: string, - payload: DisplayVideoResource, - ): DisplayVideoResource { + override createResource(): DisplayVideoResource { throw ObjectUtil.error('405 Method Not Allowed'); } /** * @throws {!Error} As this method is not allowed for this type */ - override patchResource(requestUri: string): DisplayVideoResource { + override patchResource(): DisplayVideoResource { throw ObjectUtil.error('405 Method Not Allowed'); } /** * @throws {!Error} As this method is not allowed for this type */ - override patchResourceByComparison( - requestUri: string, - original: DisplayVideoResource, - modified: DisplayVideoResource | null, - ): DisplayVideoResource { + override patchResourceByComparison(): DisplayVideoResource { throw ObjectUtil.error('405 Method Not Allowed'); } /** * @throws {!Error} As this method is not allowed for this type */ - override deleteResource(requestUri: string) { + override deleteResource() { throw ObjectUtil.error('405 Method Not Allowed'); } @@ -1171,18 +1157,14 @@ export class AssignedTargetingOptions extends DisplayVideoApiClient { /** * @throws {!Error} As this method is not allowed for this type */ - override patchResource(requestUri: string): DisplayVideoResource { + override patchResource(): DisplayVideoResource { throw ObjectUtil.error('405 Method Not Allowed'); } /** * @throws {!Error} As this method is not allowed for this type */ - override patchResourceByComparison( - requestUri: string, - original: DisplayVideoResource, - modified: DisplayVideoResource | null, - ): DisplayVideoResource { + override patchResourceByComparison(): DisplayVideoResource { throw ObjectUtil.error('405 Method Not Allowed'); } diff --git a/dv360_api/dv360_resources.ts b/dv360_api/dv360_resources.ts index ab3f020..bf8f166 100644 --- a/dv360_api/dv360_resources.ts +++ b/dv360_api/dv360_resources.ts @@ -53,8 +53,6 @@ import { LineItemPartnerRevenueModelMapper, Pacing, PacingMapper, - PerformanceGoal, - PerformanceGoalMapper, RawApiDate, RawStatus, RawTargetingType, @@ -1446,7 +1444,7 @@ export class InventorySource extends DisplayVideoResource { return result; } - override getChangedProperties(other: DisplayVideoResource | null): string[] { + override getChangedProperties(): string[] { return []; } @@ -1624,7 +1622,7 @@ export class TargetingOption extends DisplayVideoResource { return result; } - override getChangedProperties(other: DisplayVideoResource | null): string[] { + override getChangedProperties(): string[] { return []; } diff --git a/dv360_api/utils.ts b/dv360_api/utils.ts index be47ba2..b14cf89 100644 --- a/dv360_api/utils.ts +++ b/dv360_api/utils.ts @@ -259,7 +259,7 @@ export const ObjectUtil = { * @return True if the object contains all properties, false * otherwise */ - hasOwnProperties( + hasOwnProperties( obj: unknown, { requiredProperties = [], diff --git a/eslint.config.js b/eslint.config.js index cb68789..8da17ad 100644 --- a/eslint.config.js +++ b/eslint.config.js @@ -10,7 +10,7 @@ const ignores = [ 'googleads/**/*', 'cm360/**/*', 'ts/dv360_api/**/*', - 'dist/**/*', + '**/dist/**/*', ]; const rules = { From ae44558ec67c8329378084151ceac93ba79871c5 Mon Sep 17 00:00:00 2001 From: Sean Capaloff-Jones Date: Fri, 11 Oct 2024 18:39:37 +0000 Subject: [PATCH 2/4] remove ignore rule for html --- .gitignore | 1 + common/html/glossary.html | 4 ++-- common/html/guide.html | 2 +- 3 files changed, 4 insertions(+), 3 deletions(-) diff --git a/.gitignore b/.gitignore index 86a60ac..c4969a1 100644 --- a/.gitignore +++ b/.gitignore @@ -3,6 +3,7 @@ Code.js* dv360/dv360_api **/node_modules **/html/ +!**/common/html yarn-error.log dist .vscode diff --git a/common/html/glossary.html b/common/html/glossary.html index d1ab37f..66dc83d 100644 --- a/common/html/glossary.html +++ b/common/html/glossary.html @@ -14,7 +14,7 @@ limitations under the License. --> - + @@ -59,4 +59,4 @@

font-size: 1.1em; padding-top: 0.5em; } - \ No newline at end of file + diff --git a/common/html/guide.html b/common/html/guide.html index 34fd670..cad3121 100644 --- a/common/html/guide.html +++ b/common/html/guide.html @@ -14,7 +14,7 @@ limitations under the License. --> - + From 18455dac7301decfee37a007f4b1873901297e0e Mon Sep 17 00:00:00 2001 From: Sean Capaloff-Jones Date: Fri, 11 Oct 2024 18:41:05 +0000 Subject: [PATCH 3/4] fix linting for html --- common/html/glossary.html | 90 ++++++++++--------- common/html/guide.html | 185 ++++++++++++++++++++++---------------- 2 files changed, 156 insertions(+), 119 deletions(-) diff --git a/common/html/glossary.html b/common/html/glossary.html index 66dc83d..069d4dc 100644 --- a/common/html/glossary.html +++ b/common/html/glossary.html @@ -14,49 +14,57 @@ limitations under the License. --> - - + + - - - -

Glossary

- -

Overview

-

Pre-Launch QA

-

Before a campaign's flight start date, you can manually run Pre-Launch QA from the top menu - (Launch Monitor > Pre-Launch QA) from the top menu. You will receive a report - with any actionable items for all campaigns. You can modify the filters to find the details you - care about. By default, only anomalous values are shown.

- -

Launch Monitor

-

The Launch Monitor runs hourly by default (this is a setting you can control). It will update a - sheet. Specify "CSV Back-up" under Launch Monitor Options if you want to store - your reports as a CSV automatically. They will be stored in Google Drive under a folder.

- -

Rules

- + + + +

Glossary

+ +

Overview

+

Pre-Launch QA

+

+ Before a campaign's flight start date, you can manually run Pre-Launch QA + from the top menu (Launch Monitor > Pre-Launch QA) from the + top menu. You will receive a report with any actionable items for all + campaigns. You can modify the filters to find the details you care about. By + default, only anomalous values are shown. +

+ +

Launch Monitor

+

+ The Launch Monitor runs hourly by default (this is a setting you can + control). It will update a sheet. Specify "CSV Back-up" under + Launch Monitor Options if you want to store your reports as + a CSV automatically. They will be stored in Google Drive under a folder. +

+ +

Rules

+

- Parameters -
    - -
  • - -
+ Parameters +
    + +
  • + +
-
- -
+

- - - + + + + diff --git a/common/html/guide.html b/common/html/guide.html index cad3121..0cb3cc1 100644 --- a/common/html/guide.html +++ b/common/html/guide.html @@ -14,87 +14,116 @@ limitations under the License. --> - - + + - - - -

Getting Started

+ + + +

Getting Started

-

Setup - General

-The following steps will set up Launch Monitor +

Setup - General

+ The following steps will set up Launch Monitor -
    -
  1. - Add the Agency ID and - Advertiser ID -
  2. -
  3. - Click on Extensions > Apps Script. Click on the gear icon/Project - Settings on the left. -
  4. - If you haven't yet set up a project for this tool, please check Setting up - a GCP Project. Under Google Cloud Platform (GCP) Project, add a - Project Number then click Set Project. -
  5. -
  6. - Click on Triggers on the left menu. Click on Add Trigger. -
  7. -
  8. - Under Choose which function to run, click on launchMonitor. - Under Select event source, choose Time-driven. You can - keep everything else the same. Click Save. -
  9. -
  10. - (Optional) Assign a Report Label for - your report. It's used to prefix CSV report exports. Consider the client's name as the prefix. -
  11. -
  12. - (Optional) Add email addresses to have reports sent by email. If blank, no - emails will be sent. -
  13. -
  14. - (Optional) Add a Google Drive Folder ID. By - default, this will go to a folder called launch_monitor, but that can be - changed by modifying the location with a preferred Drive ID. -
  15. -
  16. - Click on SA360 Launch Monitor > Initialize Campaigns -
  17. -
+
    +
  1. + Add the Agency ID and + Advertiser ID +
  2. +
  3. + Click on Extensions > Apps Script. Click on the gear + icon/Project Settings on the left. +
  4. -

    Setting up a GCP Project

    -To set up a GCP project for Launch Monitor, take the following steps: +
  5. + If you haven't yet set up a project for this tool, please check + Setting up a GCP Project. Under + Google Cloud Platform (GCP) Project, add a + Project Number then click Set Project. +
  6. +
  7. + Click on Triggers on the left menu. Click on + Add Trigger. +
  8. +
  9. + Under Choose which function to run, click on + launchMonitor. Under + Select event source, choose Time-driven. + You can keep everything else the same. Click Save. +
  10. +
  11. + (Optional) Assign a + Report Label for your report. It's + used to prefix CSV report exports. Consider the client's name as the + prefix. +
  12. +
  13. + (Optional) Add email addresses to have reports sent by + email. If blank, no emails will be sent. +
  14. +
  15. + (Optional) Add a + Google Drive Folder ID. By default, this + will go to a folder called launch_monitor, but that can + be changed by modifying the location with a preferred Drive ID. +
  16. +
  17. + Click on SA360 Launch Monitor > Initialize Campaigns +
  18. +
-
    -
  1. - Enable the following APIs: - -
  2. -
  3. - Add an OAuth consent screen. -
      -
    • For the base use case, select Internal
    • . -
    • Fill out only the required fields (App name, User support email, and Email addresses).
    • -
    • Press Save and Continue.
    • -
    -
  4. -
+

Setting up a GCP Project

+ To set up a GCP project for Launch Monitor, take the following steps: + +
    +
  1. + Enable the following APIs: + +
  2. +
  3. + Add an + OAuth consent screen. +
      +
    • For the base use case, select Internal
    • + . +
    • + Fill out only the required fields (App name, User support email, and + Email addresses). +
    • +
    • Press Save and Continue.
    • +
    +
  4. +
From fbbbf2ed5ba0fc392b468e745ffbac3f900ae58e Mon Sep 17 00:00:00 2001 From: Sean Capaloff-Jones Date: Fri, 11 Oct 2024 18:43:40 +0000 Subject: [PATCH 4/4] remove unecessary try/catch block --- common/ads_api.ts | 16 ++++++---------- 1 file changed, 6 insertions(+), 10 deletions(-) diff --git a/common/ads_api.ts b/common/ads_api.ts index 2d5b4ec..3174b02 100644 --- a/common/ads_api.ts +++ b/common/ads_api.ts @@ -187,16 +187,12 @@ export class GoogleAdsApi implements AdTypes.GoogleAdsApiInterface { contentType: 'application/json', payload: JSON.stringify({ ...params, pageToken }), }; - try { - const res = JSON.parse( - UrlFetchApp.fetch(url, req).getContentText(), - ) as AdTypes.AdsSearchResponse>; - pageToken = res.nextPageToken; - for (const row of res.results || []) { - yield row; - } - } catch { - throw new Error('bad'); + const res = JSON.parse( + UrlFetchApp.fetch(url, req).getContentText(), + ) as AdTypes.AdsSearchResponse>; + pageToken = res.nextPageToken; + for (const row of res.results || []) { + yield row; } } while (pageToken); }