Skip to content

Commit 2183d38

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

File tree

3 files changed

+8
-6
lines changed

3 files changed

+8
-6
lines changed

README.md

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -55,13 +55,15 @@ required. it's your GA4 property id from Google Analytics Page.
5555

5656
### startDate
5757

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'.
58+
required since v1.3.0. it's based on Google Analytics date value. Could be '30daysAgo', 'today', 'yesterday', or ISO
59+
date format (yyyy-MM-dd) like '2022-12-31'. Default value '365daysAgo'. Google changed its API and for version < v1.3.0
60+
using startDate default value will throw error. Since v1.3.0 I encourage to specify your startDate in config or use
61+
dynamic value like '365daysAgo'.
6062

6163
### endDate
6264

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'.
65+
required since v1.3.0. it's based on Google Analytics date value. Could be '30daysAgo', 'today', 'yesterday', or ISO
66+
date format (yyyy-MM-dd) like '2022-12-31'. Default value 'today'. Since v1.3.0 I encourage to specify your endDate.
6567

6668
### metric
6769

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, endDate: pluginOptions.endDate}],
32+
dateRanges: [{startDate: pluginOptions.startDate || '30daysAgo', endDate: pluginOptions.endDate || 'today'}],
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.3.0",
4+
"version": "1.3.1",
55
"main": "gatsby-node.js",
66
"author": "Ferry Suhandri",
77
"license": "MIT",

0 commit comments

Comments
 (0)