Skip to content

Commit b43da64

Browse files
committed
cleanup and changes to GA
1 parent 9330b0f commit b43da64

10 files changed

Lines changed: 128 additions & 332 deletions

File tree

.env.local.example

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
# Local Environment Variables
2+
# This file is for local development only and will NOT be committed to git
3+
# Copy this file to .env.local and fill in your actual credentials
4+
5+
# Google Analytics 4 Configuration
6+
GA_PROPERTY_ID=your-ga4-property-id-here
7+
GOOGLE_SERVICE_ACCOUNT_KEY={"type":"service_account","project_id":"your-project-id","private_key":"-----BEGIN PRIVATE KEY-----\nYOUR_PRIVATE_KEY_HERE\n-----END PRIVATE KEY-----\n","client_email":"your-service-account@your-project-id.iam.gserviceaccount.com"}
8+
9+
# JIRA Configuration
10+
JIRA_BASE_URL=https://your-domain.atlassian.net
11+
JIRA_USERNAME=your-email@company.com
12+
JIRA_API_TOKEN=your-jira-api-token-here
13+
14+
# OpenAI Configuration (optional)
15+
OPENAI_API_KEY=your-openai-api-key-here
16+
17+
# Site Password
18+
SITE_PASS=docsdash2024

LOCAL_TESTING.md

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
# Local Testing Setup
2+
3+
This allows you to test the actual data fetching mechanism locally with real credentials.
4+
5+
## Quick Setup
6+
7+
1. **Copy the template:**
8+
```bash
9+
cp .env.local.example .env.local
10+
```
11+
12+
2. **Edit .env.local with your real credentials:**
13+
```env
14+
# Google Analytics 4
15+
GA_PROPERTY_ID=your-actual-ga4-property-id
16+
GOOGLE_SERVICE_ACCOUNT_KEY={"type":"service_account","project_id":"your-project",...}
17+
18+
# JIRA
19+
JIRA_BASE_URL=https://your-domain.atlassian.net
20+
JIRA_USERNAME=your-email@company.com
21+
JIRA_API_TOKEN=your-actual-jira-api-token
22+
23+
# OpenAI (optional)
24+
OPENAI_API_KEY=your-openai-api-key
25+
26+
# Site Password
27+
SITE_PASS=docsdash2024
28+
```
29+
30+
3. **Test the fetch:**
31+
```bash
32+
npm run fetch-data
33+
```
34+
35+
4. **Start development server:**
36+
```bash
37+
npm run dev
38+
```
39+
40+
## How It Works
41+
42+
- **Local Development**: Uses credentials from `.env.local` file
43+
- **GitHub Actions**: Uses credentials from GitHub secrets
44+
- **No Sample Data**: Tests actual API calls and data fetching
45+
- **Secure**: `.env.local` is ignored by git and won't be committed
46+
47+
## Files
48+
49+
- `.env.local.example` - Template with placeholder values
50+
- `.env.local` - Your actual credentials (create this, don't commit)
51+
- Scripts automatically load `.env.local` if it exists
52+
53+
## Notes
54+
55+
- The `.env.local` file is in `.gitignore` so it won't be committed
56+
- If `.env.local` doesn't exist, scripts fall back to environment variables
57+
- This tests the exact same fetch mechanism used in production

README.md

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -184,18 +184,6 @@ Add the new data to `src/data/sample-data.json` and update `scripts/fetch-data.j
184184
| `RecentIssuesTable` | Table with status badges |
185185
| `TrafficSourcesChart` | Pie chart |
186186

187-
## AI Assistant
188-
189-
The AI assistant uses OpenAI's API to provide insights. Users provide their own API key, which is stored in their browser's localStorage (never sent to your servers).
190-
191-
### Customizing the AI Context
192-
193-
Edit the `buildContext()` function in `src/components/AIAssistant.jsx` to change what data is sent to the AI.
194-
195-
### Using a Different LLM
196-
197-
Replace the OpenAI API call with any other provider (Anthropic, Google, etc.) by modifying the `sendMessage()` function.
198-
199187
## Data Refresh Schedule
200188

201189
The GitHub Action runs every 6 hours by default. To change this, edit `.github/workflows/fetch-and-deploy.yml`:
@@ -221,7 +209,6 @@ docsdash/
221209
├── src/
222210
│ ├── components/
223211
│ │ ├── charts/ # Chart components
224-
│ │ ├── AIAssistant.jsx # LLM integration
225212
│ │ ├── ChartCard.jsx # Chart wrapper
226213
│ │ └── MetricCard.jsx # Metric display
227214
│ ├── data/

package-lock.json

Lines changed: 13 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
},
1313
"dependencies": {
1414
"@google-analytics/data": "^5.2.1",
15+
"dotenv": "^17.2.3",
1516
"express": "^4.18.2",
1617
"google-trends-api": "^4.9.2",
1718
"lucide-react": "^0.303.0",

scripts/ai-assistant-api.js

Lines changed: 0 additions & 65 deletions
This file was deleted.

scripts/fetch-ga.js

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,27 @@
1010
* Required Environment Variables:
1111
* - GA_PROPERTY_ID: Google Analytics 4 property ID
1212
* - GOOGLE_SERVICE_ACCOUNT_KEY: JSON key for GCP service account
13+
*
14+
* Local Development:
15+
* Create .env.local file with your credentials (won't be committed to git)
1316
*/
1417

15-
// Check if we're in a CI environment with real credentials
18+
// Load environment variables from .env.local for local development
19+
import { config } from 'dotenv'
20+
import { fileURLToPath } from 'url'
21+
import { dirname, join } from 'path'
22+
23+
const __filename = fileURLToPath(import.meta.url)
24+
const __dirname = dirname(__filename)
25+
26+
// Try to load .env.local first (for local development)
27+
try {
28+
config({ path: join(__dirname, '../.env.local') })
29+
} catch (error) {
30+
// .env.local doesn't exist, will use environment variables (GitHub Actions)
31+
}
32+
33+
// Check if we have credentials (either from .env.local or environment)
1634
const hasGACredentials = process.env.GA_PROPERTY_ID && process.env.GOOGLE_SERVICE_ACCOUNT_KEY
1735

1836
export async function fetchGoogleAnalyticsData() {

scripts/fetch-jira.js

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/**
2-
* Fetch Jira Data
2+
* Fetch JIRA Data
33
*
44
* Uses the Jira REST API to fetch:
55
* - Open issues by priority
@@ -13,9 +13,27 @@
1313
* - JIRA_EMAIL: Jira account email
1414
* - JIRA_API_TOKEN: Jira API token
1515
* - JIRA_PROJECT_KEY: Jira project key (e.g., DOC)
16+
*
17+
* Local Development:
18+
* Create .env.local file with your credentials (won't be committed to git)
1619
*/
1720

18-
// Check if we're in a CI environment with real credentials
21+
// Load environment variables from .env.local for local development
22+
import { config } from 'dotenv'
23+
import { fileURLToPath } from 'url'
24+
import { dirname, join } from 'path'
25+
26+
const __filename = fileURLToPath(import.meta.url)
27+
const __dirname = dirname(__filename)
28+
29+
// Try to load .env.local first (for local development)
30+
try {
31+
config({ path: join(__dirname, '.env.local') })
32+
} catch (error) {
33+
// .env.local doesn't exist, will use environment variables (GitHub Actions)
34+
}
35+
36+
// Check if we have credentials (either from .env.local or environment)
1937
const hasJiraCredentials = process.env.JIRA_BASE_URL && process.env.JIRA_EMAIL && process.env.JIRA_API_TOKEN
2038

2139
export async function fetchJiraData() {

server.js

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@ import express from 'express'
77
import { fileURLToPath } from 'url'
88
import { dirname, join } from 'path'
99
import insightsHandler from './scripts/insights-api.js'
10-
import aiAssistantHandler from './scripts/ai-assistant-api.js'
1110

1211
const __filename = fileURLToPath(import.meta.url)
1312
const __dirname = dirname(__filename)
@@ -33,16 +32,12 @@ app.use((req, res, next) => {
3332
// Insights API endpoint
3433
app.post('/api/insights', insightsHandler)
3534

36-
// AI Assistant API endpoint
37-
app.post('/api/ai-assistant', aiAssistantHandler)
38-
3935
// Serve static files from public directory
4036
app.use(express.static(join(__dirname, 'public')))
4137

4238
// Start server
4339
app.listen(PORT, () => {
4440
console.log(`🚀 API server running on http://localhost:${PORT}`)
4541
console.log(`📊 Insights endpoint available at http://localhost:${PORT}/api/insights`)
46-
console.log(`🤖 AI Assistant endpoint available at http://localhost:${PORT}/api/ai-assistant`)
4742
console.log(`🔑 Using OPENAI_API_KEY from environment: ${process.env.OPENAI_API_KEY ? '✅' : '❌ Not set'}`)
4843
})

0 commit comments

Comments
 (0)