Skip to content

Commit 5c8e000

Browse files
authored
Merge pull request #214 from 18F/migrate-ga3-to-ga4
Migrate ga3 to ga4
2 parents cca4b99 + 9fb01a8 commit 5c8e000

File tree

10 files changed

+6412
-1104
lines changed

10 files changed

+6412
-1104
lines changed

.nvmrc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
18.19.0

README.md

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,7 @@ in response to HTTP requests.
1313

1414
This Analytics API maintains the schema for the database that the
1515
[Analytics Reporter](https://github.com/18F/analytics-reporter)
16-
writes to.
17-
Thus, the Analytics API must be setup and
16+
writes to. Thus, the Analytics API must be setup and
1817
configured before the Analytics Reporter starts writing data.
1918

2019
First, create the database:
@@ -23,6 +22,10 @@ First, create the database:
2322
createdb analytics-reporter
2423
```
2524

25+
````bash
26+
export NODE_ENV=development # developing locally
27+
````
28+
2629
Once the database is created, clone the app and install the dependencies via NPM.
2730
The install script has a postinstall hook that will migrate
2831
the database.
@@ -48,6 +51,7 @@ is configured to write to the same database and run with the `--write-to-databas
4851
# Using the API
4952

5053
The Analytics API exposes 3 API endpoints:
54+
include version in the request, ie `/v1.1/`
5155

5256
- `/reports/:report_name/data`
5357
- `/agencies/:agency_name/reports/:reportName/data`

env.example

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
export NODE_ENV=development
2+
export POSTGRES_USER=postgres
3+
export POSTGRES_PASSWORD=123abc
4+
POSTGRES_DATABASE=analytics-reporter

knexfile.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,9 @@ module.exports = {
22
development: {
33
client: 'postgresql',
44
connection: {
5-
database: 'analytics-reporter'
5+
user: process.env.POSTGRES_USER || 'postgres',
6+
password: process.env.POSTGRES_PASSWORD || '123abc',
7+
database: process.env.POSTGRES_DATABASE || 'analytics-reporter',
68
}
79
},
810
production: {
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
exports.up = function(knex) {
2+
return knex.schema.createTable("analytics_data_ga4", table => {
3+
table.increments("id")
4+
table.string("report_name")
5+
table.string("report_agency")
6+
table.dateTime("date")
7+
table.jsonb("data")
8+
table.timestamps(true, true)
9+
table.string("version")
10+
})
11+
};
12+
13+
exports.down = function(knex) {
14+
return knex.schema.dropTable('analytics_data_ga4')
15+
};

0 commit comments

Comments
 (0)