@adobe/spacecat-shared-google-client 1.0.2 → 1.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +7 -0
- package/package.json +1 -1
- package/src/index.js +16 -0
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,10 @@
|
|
|
1
|
+
# [@adobe/spacecat-shared-google-client-v1.1.0](https://github.com/adobe/spacecat-shared/compare/@adobe/spacecat-shared-google-client-v1.0.2...@adobe/spacecat-shared-google-client-v1.1.0) (2024-05-24)
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
### Features
|
|
5
|
+
|
|
6
|
+
* filter fetched organic search data from google by base url ([#239](https://github.com/adobe/spacecat-shared/issues/239)) ([0bfba19](https://github.com/adobe/spacecat-shared/commit/0bfba19d08122c969f513154c697dd75017b8e43))
|
|
7
|
+
|
|
1
8
|
# [@adobe/spacecat-shared-google-client-v1.0.2](https://github.com/adobe/spacecat-shared/compare/@adobe/spacecat-shared-google-client-v1.0.1...@adobe/spacecat-shared-google-client-v1.0.2) (2024-05-22)
|
|
2
9
|
|
|
3
10
|
|
package/package.json
CHANGED
package/src/index.js
CHANGED
|
@@ -14,6 +14,7 @@ import { google } from 'googleapis';
|
|
|
14
14
|
import { OAuth2Client } from 'google-auth-library';
|
|
15
15
|
import { GetSecretValueCommand, SecretsManagerClient } from '@aws-sdk/client-secrets-manager';
|
|
16
16
|
import {
|
|
17
|
+
composeAuditURL,
|
|
17
18
|
isArray,
|
|
18
19
|
isInteger,
|
|
19
20
|
isValidDate, isValidUrl,
|
|
@@ -40,6 +41,7 @@ export default class GoogleClient {
|
|
|
40
41
|
tokenType: secrets.token_type,
|
|
41
42
|
expiryDate: secrets.expiry_date,
|
|
42
43
|
siteUrl: secrets.site_url,
|
|
44
|
+
baseUrl: baseURL,
|
|
43
45
|
clientId: context.env.GOOGLE_CLIENT_ID,
|
|
44
46
|
clientSecret: context.env.GOOGLE_CLIENT_SECRET,
|
|
45
47
|
redirectUri: context.env.GOOGLE_REDIRECT_URI,
|
|
@@ -77,6 +79,7 @@ export default class GoogleClient {
|
|
|
77
79
|
this.authClient = authClient;
|
|
78
80
|
this.expiryDate = config.expiryDate;
|
|
79
81
|
this.siteUrl = config.siteUrl;
|
|
82
|
+
this.baseUrl = config.baseUrl;
|
|
80
83
|
this.log = log;
|
|
81
84
|
}
|
|
82
85
|
|
|
@@ -108,6 +111,8 @@ export default class GoogleClient {
|
|
|
108
111
|
|
|
109
112
|
await this.#refreshTokenIfExpired();
|
|
110
113
|
|
|
114
|
+
const auditUrl = await composeAuditURL(this.baseUrl);
|
|
115
|
+
|
|
111
116
|
const webmasters = google.webmasters({
|
|
112
117
|
version: 'v3',
|
|
113
118
|
auth: this.authClient,
|
|
@@ -123,6 +128,17 @@ export default class GoogleClient {
|
|
|
123
128
|
dimensions,
|
|
124
129
|
startRow,
|
|
125
130
|
rowLimit,
|
|
131
|
+
dimensionFilterGroups: [
|
|
132
|
+
{
|
|
133
|
+
filters: [
|
|
134
|
+
{
|
|
135
|
+
dimension: 'page',
|
|
136
|
+
operator: 'contains',
|
|
137
|
+
expression: auditUrl,
|
|
138
|
+
},
|
|
139
|
+
],
|
|
140
|
+
},
|
|
141
|
+
],
|
|
126
142
|
},
|
|
127
143
|
};
|
|
128
144
|
this.log.info(`Retrieving organic search data: ${JSON.stringify(params)}`);
|