Skip to content

Commit

Permalink
feat: update start date and end date as required since google api cha…
Browse files Browse the repository at this point in the history
…nged its validation
  • Loading branch information
7sferry committed Oct 13, 2023
1 parent 6ef8bf9 commit 2183d38
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 6 deletions.
10 changes: 6 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -55,13 +55,15 @@ required. it's your GA4 property id from Google Analytics Page.

### startDate

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

### endDate

required since v1.3.0. it's based on Google Analytics date value. Could be '30daysAgo', 'today', '
yesterday', or ISO date format (yyyy-MM-dd) like '2022-12-31'.
required since v1.3.0. it's based on Google Analytics date value. Could be '30daysAgo', 'today', 'yesterday', or ISO
date format (yyyy-MM-dd) like '2022-12-31'. Default value 'today'. Since v1.3.0 I encourage to specify your endDate.

### metric

Expand Down
2 changes: 1 addition & 1 deletion gatsby-node.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ exports.sourceNodes = async ({actions, createNodeId, createContentDigest}, plugi
requestBody: {
dimensions: [{name: "pagePath"}],
metrics: [{name: metric}],
dateRanges: [{startDate: pluginOptions.startDate, endDate: pluginOptions.endDate}],
dateRanges: [{startDate: pluginOptions.startDate || '30daysAgo', endDate: pluginOptions.endDate || 'today'}],
limit: pluginOptions.limit,
orderBys: [{metric: {metricName: metric}, desc: pluginOptions.desc === true}],
},
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "gatsby-plugin-google-analytics-data-reporting-api",
"description": "Reporting API for Google Analytics 4 (GA4)",
"version": "1.3.0",
"version": "1.3.1",
"main": "gatsby-node.js",
"author": "Ferry Suhandri",
"license": "MIT",
Expand Down

0 comments on commit 2183d38

Please sign in to comment.