Skip to content

Commit 3c9764f

Browse files
committed
update to LLM text and rate limiting
1 parent 1c98683 commit 3c9764f

File tree

2 files changed

+18
-18
lines changed

2 files changed

+18
-18
lines changed

scripts/fetch-ga.js

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -120,9 +120,9 @@ export async function fetchGoogleAnalyticsData() {
120120

121121
const topPagesByPath = await Promise.all(
122122
documentationPaths.map(async (path, index) => {
123-
// Add delay to avoid rate limiting (wait 100ms between requests)
123+
// Add delay to avoid rate limiting (wait 50ms between requests)
124124
if (index > 0) {
125-
await new Promise(resolve => setTimeout(resolve, 100))
125+
await new Promise(resolve => setTimeout(resolve, 50))
126126
}
127127

128128
try {
@@ -247,9 +247,9 @@ export async function fetchGoogleAnalyticsData() {
247247
// Fetch metrics for each documentation path (reuse paths array)
248248
const pathMetrics = await Promise.all(
249249
documentationPaths.map(async (path, index) => {
250-
// Add delay to avoid rate limiting (wait 150ms between path requests)
250+
// Add delay to avoid rate limiting (wait 75ms between path requests)
251251
if (index > 0) {
252-
await new Promise(resolve => setTimeout(resolve, 150))
252+
await new Promise(resolve => setTimeout(resolve, 75))
253253
}
254254

255255
try {
@@ -280,7 +280,7 @@ export async function fetchGoogleAnalyticsData() {
280280
})
281281

282282
// Add small delay between requests for the same path
283-
await new Promise(resolve => setTimeout(resolve, 50))
283+
await new Promise(resolve => setTimeout(resolve, 25))
284284

285285
// Fetch session metrics for this path
286286
const [pathSessionResponse] = await analyticsDataClient.runReport({
@@ -312,7 +312,7 @@ export async function fetchGoogleAnalyticsData() {
312312
})
313313

314314
// Add small delay between requests for the same path
315-
await new Promise(resolve => setTimeout(resolve, 50))
315+
await new Promise(resolve => setTimeout(resolve, 25))
316316

317317
// Fetch traffic sources for this path
318318
const [pathTrafficResponse] = await analyticsDataClient.runReport({
@@ -409,9 +409,9 @@ export async function fetchGoogleAnalyticsData() {
409409
// Fetch metrics for each SDK path
410410
const sdkMetrics = await Promise.all(
411411
sdkPaths.map(async (path, index) => {
412-
// Add delay to avoid rate limiting (wait 200ms between SDK requests)
412+
// Add delay to avoid rate limiting (wait 100ms between SDK requests)
413413
if (index > 0) {
414-
await new Promise(resolve => setTimeout(resolve, 200))
414+
await new Promise(resolve => setTimeout(resolve, 100))
415415
}
416416

417417
try {
@@ -430,7 +430,7 @@ export async function fetchGoogleAnalyticsData() {
430430
})
431431

432432
// Add small delay between requests for the same SDK
433-
await new Promise(resolve => setTimeout(resolve, 50))
433+
await new Promise(resolve => setTimeout(resolve, 25))
434434

435435
// Fetch session metrics for this SDK path
436436
const [pathSessionResponse] = await analyticsDataClient.runReport({
@@ -450,7 +450,7 @@ export async function fetchGoogleAnalyticsData() {
450450
})
451451

452452
// Add small delay between requests for the same SDK
453-
await new Promise(resolve => setTimeout(resolve, 50))
453+
await new Promise(resolve => setTimeout(resolve, 25))
454454

455455
// Fetch traffic sources for this SDK path
456456
const [pathTrafficResponse] = await analyticsDataClient.runReport({

scripts/insights-api.js

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -65,14 +65,14 @@ export async function callOpenAI(apiKey, prompt, data) {
6565
*/
6666
export async function analyzeTrafficTrends(apiKey, data) {
6767
const prompt = `
68-
Analyze the following web traffic data and provide insights on:
69-
1. Overall traffic trends (increasing/decreasing/stable)
70-
2. Notable patterns in user behavior
71-
3. Top performing pages and why they might be doing well
72-
4. Areas for improvement based on bounce rates and session duration
73-
5. Any anomalies or concerning patterns
74-
75-
Focus on actionable insights that would help improve documentation effectiveness.
68+
Analyze the web traffic data and provide a brief summary in 2-3 sentences:
69+
70+
1. Overall traffic state: Are metrics trending up, down, or stable?
71+
2. Performance assessment: Is the current traffic level good, concerning, or needs improvement?
72+
73+
Then add a short paragraph (2-3 sentences) with specific recommendations for the most important actions to take based on the data.
74+
75+
Focus on clarity and actionable insights rather than detailed analysis.
7676
`
7777

7878
return await callOpenAI(apiKey, prompt, {

0 commit comments

Comments
 (0)