Skip to content

Commit 6ef8bf9

Browse files
committed
feat: update start date and end date as required since google api changed its validation
1 parent 22ad385 commit 6ef8bf9

File tree

3 files changed

+7
-9
lines changed

3 files changed

+7
-9
lines changed

README.md

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ plugins: [{
2727
serviceAccountEmail: process.env.ANALYTICS_EMAIL,
2828
privateKey: process.env.ANALYTICS_PRIVATE_KEY,
2929
property: process.env.ANALYTICS_GA4,
30-
startDate: `2005-01-01`,
30+
startDate: `2020-01-01`,
3131
endDate: `yesterday`,
3232
limit: 100,
3333
metric: `screenPageViews`,
@@ -55,15 +55,13 @@ required. it's your GA4 property id from Google Analytics Page.
5555

5656
### startDate
5757

58-
optional. you can skip this option. it's based on Google Analytics date value. Could be '30daysAgo', 'today', '
59-
yesterday', or ISO date format (yyyy-MM-dd) like '2022-12-31'. Since v1.2.0 Default value is '2005-01-01' because new
60-
Google API changed it. If you still use version <= 1.1.0 you should specify 'startDate' in your gatsby-config or
61-
upgrade to newer version.
58+
required since v1.3.0. it's based on Google Analytics date value. Could be '30daysAgo', 'today', '
59+
yesterday', or ISO date format (yyyy-MM-dd) like '2022-12-31'.
6260

6361
### endDate
6462

65-
optional. you can skip this option. it's based on Google Analytics date value. Could be '30daysAgo', 'today', '
66-
yesterday', or ISO date format (yyyy-MM-dd) like '2022-12-31'. Default value is 'today'.
63+
required since v1.3.0. it's based on Google Analytics date value. Could be '30daysAgo', 'today', '
64+
yesterday', or ISO date format (yyyy-MM-dd) like '2022-12-31'.
6765

6866
### metric
6967

gatsby-node.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ exports.sourceNodes = async ({actions, createNodeId, createContentDigest}, plugi
2929
requestBody: {
3030
dimensions: [{name: "pagePath"}],
3131
metrics: [{name: metric}],
32-
dateRanges: [{startDate: pluginOptions.startDate || '2005-01-01', endDate: pluginOptions.endDate || 'today'}],
32+
dateRanges: [{startDate: pluginOptions.startDate, endDate: pluginOptions.endDate}],
3333
limit: pluginOptions.limit,
3434
orderBys: [{metric: {metricName: metric}, desc: pluginOptions.desc === true}],
3535
},

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "gatsby-plugin-google-analytics-data-reporting-api",
33
"description": "Reporting API for Google Analytics 4 (GA4)",
4-
"version": "1.2.2",
4+
"version": "1.3.0",
55
"main": "gatsby-node.js",
66
"author": "Ferry Suhandri",
77
"license": "MIT",

0 commit comments

Comments
 (0)