Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Formatting and linting #63

Merged
merged 4 commits into from
Oct 11, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/build.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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 {} \;
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ Code.js*
dv360/dv360_api
**/node_modules
**/html/
!**/common/html
yarn-error.log
dist
.vscode
Expand Down
2 changes: 1 addition & 1 deletion .lintstagedrc
Original file line number Diff line number Diff line change
@@ -1 +1 @@
{ '**/*.{ts, js}': ['npx prettier --write .'] }
{"**/*.{ts, js}": ["npx prettier --write ."]}
4 changes: 2 additions & 2 deletions .prettierignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
*.json
node_modules
.prettierrc
googleads/*.js
.*
16 changes: 6 additions & 10 deletions common/ads_api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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<AdTypes.ReportResponse<Q>>;
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<AdTypes.ReportResponse<Q>>;
pageToken = res.nextPageToken;
for (const row of res.results || []) {
yield row;
}
} while (pageToken);
}
Expand Down
90 changes: 49 additions & 41 deletions common/html/glossary.html
Original file line number Diff line number Diff line change
Expand Up @@ -14,49 +14,57 @@
limitations under the License.
-->

<!DOCTYPE html>
<link href="https://cdn.jsdelivr.net/npm/[email protected]/dist/css/bootstrap.min.css" rel="stylesheet">
<!doctype html>
<link
href="https://cdn.jsdelivr.net/npm/[email protected]/dist/css/bootstrap.min.css"
rel="stylesheet"
/>
<html lang="en">
<head>
<base target="_top">
</head>
<h1>Glossary</h1>

<h2 id="overview">Overview</h2>
<h3>Pre-Launch QA</h3>
<p>Before a campaign's flight start date, you can manually run Pre-Launch QA from the top menu
(<strong>Launch Monitor > Pre-Launch QA</strong>) 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.</p>

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

<h2 id="rules">Rules</h2>
<? for (const rule of rules) { ?>
<head>
<base target="_top" />
</head>
<h1>Glossary</h1>

<h2 id="overview">Overview</h2>
<h3>Pre-Launch QA</h3>
<p>
Before a campaign's flight start date, you can manually run Pre-Launch QA
from the top menu (<strong>Launch Monitor > Pre-Launch QA</strong>) 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.
</p>

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

<h2 id="rules">Rules</h2>
<? for (const rule of rules) { ?>
<h3><?= rule.name ?></h3>
<? if (Object.keys(rule.params).length) { ?>
<u>Parameters</u>
<ul>
<? for (const param of Object.values(rule.params)) { ?>
<li><?= param.label ?></li>
<? } ?>
</ul>
<u>Parameters</u>
<ul>
<? for (const param of Object.values(rule.params)) { ?>
<li><?= param.label ?></li>
<? } ?>
</ul>
<? } ?>
<div>
<?!= rule.description ?>
</div>
<div><?!= rule.description ?></div>
<hr />
<? } ?>

<style>
h2 {
border-bottom: 1px solid black;
}
h3 {
font-size: 1.1em;
padding-top: 0.5em;
}
</style>
<? } ?>

<style>
h2 {
border-bottom: 1px solid black;
}
h3 {
font-size: 1.1em;
padding-top: 0.5em;
}
</style>
</html>
185 changes: 107 additions & 78 deletions common/html/guide.html
Original file line number Diff line number Diff line change
Expand Up @@ -14,87 +14,116 @@
limitations under the License.
-->

<!DOCTYPE html>
<link href="https://cdn.jsdelivr.net/npm/[email protected]/dist/css/bootstrap.min.css" rel="stylesheet">
<!doctype html>
<link
href="https://cdn.jsdelivr.net/npm/[email protected]/dist/css/bootstrap.min.css"
rel="stylesheet"
/>
<html lang="en">
<head>
<base target="_top">
</head>
<h1>Getting Started</h1>
<head>
<base target="_top" />
</head>
<h1>Getting Started</h1>

<h2 id="setup">Setup - General</h2>
The following steps will set up Launch Monitor
<h2 id="setup">Setup - General</h2>
The following steps will set up Launch Monitor

<ol>
<li>
Add the <a href="#" id="assignAgencyId">Agency ID</a> and <a href="#" id="assignAdvertiserId">
Advertiser ID</a>
</li>
<li>
Click on <strong>Extensions > Apps Script</strong>. Click on the gear icon/<strong>Project
Settings</strong> on the left.
<li>
If you haven't yet set up a project for this tool, please check <a href="#projects">Setting up
a GCP Project</a>. Under <strong>Google Cloud Platform (GCP) Project</strong>, add a
<strong>Project Number</strong> then click <strong>Set Project</strong>.
</li>
<li>
Click on <strong>Triggers</strong> on the left menu. Click on <strong>Add Trigger</strong>.
</li>
<li>
Under <strong>Choose which function to run</strong>, click on <strong>launchMonitor</strong>.
Under <strong>Select event source</strong>, choose <strong>Time-driven</strong>. You can
keep everything else the same. Click <strong>Save</strong>.
</li>
<li>
<strong>(Optional)</strong> Assign a <a href="#" id="assignReportLabel">Report Label</a> for
your report. It's used to prefix CSV report exports. Consider the client's name as the prefix.
</li>
<li>
<strong>(Optional)</strong> Add email addresses to have reports sent by email. If blank, no
emails will be sent.
</li>
<li>
<strong>(Optional)</strong> Add a <a href="#" id="updateLaunch">Google Drive Folder ID</a>. By
default, this will go to a folder called <strong>launch_monitor</strong>, but that can be
changed by modifying the location with a preferred Drive ID.
</li>
<li>
Click on <strong>SA360 Launch Monitor > Initialize Campaigns</strong>
</li>
</ol>
<ol>
<li>
Add the <a href="#" id="assignAgencyId">Agency ID</a> and
<a href="#" id="assignAdvertiserId"> Advertiser ID</a>
</li>
<li>
Click on <strong>Extensions > Apps Script</strong>. Click on the gear
icon/<strong>Project Settings</strong> on the left.
</li>

<h2 id="projects">Setting up a GCP Project</h2>
To set up a GCP project for Launch Monitor, take the following steps:
<li>
If you haven't yet set up a project for this tool, please check
<a href="#projects">Setting up a GCP Project</a>. Under
<strong>Google Cloud Platform (GCP) Project</strong>, add a
<strong>Project Number</strong> then click <strong>Set Project</strong>.
</li>
<li>
Click on <strong>Triggers</strong> on the left menu. Click on
<strong>Add Trigger</strong>.
</li>
<li>
Under <strong>Choose which function to run</strong>, click on
<strong>launchMonitor</strong>. Under
<strong>Select event source</strong>, choose <strong>Time-driven</strong>.
You can keep everything else the same. Click <strong>Save</strong>.
</li>
<li>
<strong>(Optional)</strong> Assign a
<a href="#" id="assignReportLabel">Report Label</a> for your report. It's
used to prefix CSV report exports. Consider the client's name as the
prefix.
</li>
<li>
<strong>(Optional)</strong> Add email addresses to have reports sent by
email. If blank, no emails will be sent.
</li>
<li>
<strong>(Optional)</strong> Add a
<a href="#" id="updateLaunch">Google Drive Folder ID</a>. By default, this
will go to a folder called <strong>launch_monitor</strong>, but that can
be changed by modifying the location with a preferred Drive ID.
</li>
<li>
Click on <strong>SA360 Launch Monitor > Initialize Campaigns</strong>
</li>
</ol>

<ol>
<li>
Enable the following APIs:
<ul>
<li>
<a href="https://console.cloud.google.com/apis/api/doubleclicksearch.googleapis.com" target="_blank">
SA360 API
</a>
</li>
<li>
<a href="https://console.cloud.google.com/apis/api/searchads360.googleapis.com" target="_blank">
NEW SA360 API
</a>
</li>
<li>
<a href="https://console.cloud.google.com/apis/api/drive.googleapis.com" target="_blank">
Google Drive API
</a>
</li>
</ul>
</li>
<li>
Add an <a href="https://console.cloud.google.com/apis/credentials/consent" target="_blank">OAuth consent screen</a>.
<ul>
<li>For the base use case, select <strong>Internal</strong></li>.
<li>Fill out only the required fields (App name, User support email, and Email addresses).</li>
<li>Press <strong>Save and Continue</strong>.</li>
</ul>
</li>
</ol>
<h2 id="projects">Setting up a GCP Project</h2>
To set up a GCP project for Launch Monitor, take the following steps:

<ol>
<li>
Enable the following APIs:
<ul>
<li>
<a
href="https://console.cloud.google.com/apis/api/doubleclicksearch.googleapis.com"
target="_blank"
>
SA360 API
</a>
</li>
<li>
<a
href="https://console.cloud.google.com/apis/api/searchads360.googleapis.com"
target="_blank"
>
NEW SA360 API
</a>
</li>
<li>
<a
href="https://console.cloud.google.com/apis/api/drive.googleapis.com"
target="_blank"
>
Google Drive API
</a>
</li>
</ul>
</li>
<li>
Add an
<a
href="https://console.cloud.google.com/apis/credentials/consent"
target="_blank"
>OAuth consent screen</a
>.
<ul>
<li>For the base use case, select <strong>Internal</strong></li>
.
<li>
Fill out only the required fields (App name, User support email, and
Email addresses).
</li>
<li>Press <strong>Save and Continue</strong>.</li>
</ul>
</li>
</ol>
</html>
Loading
Loading