Skip to content

Commit

Permalink
Add environment-specific Beam Analytics integration
Browse files Browse the repository at this point in the history
- Add analytics script to production only
- Create environment detection helpers
- Update project documentation
  • Loading branch information
screenfluent committed Nov 18, 2024
1 parent 9abd724 commit 9624ebf
Show file tree
Hide file tree
Showing 4 changed files with 34 additions and 0 deletions.
9 changes: 9 additions & 0 deletions .cascade/deployment.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,11 @@
"files": "644",
"directories": "755"
}
},
"analytics": {
"provider": "Beam Analytics",
"token": "93f53d9b-fadc-433a-9c7c-9621ac1ee672",
"script": "https://beamanalytics.b-cdn.net/beam.min.js"
}
},
"staging": {
Expand All @@ -43,6 +48,10 @@
"files": "644",
"directories": "755"
}
},
"analytics": {
"enabled": false,
"note": "Analytics disabled in staging environment"
}
}
},
Expand Down
6 changes: 6 additions & 0 deletions .cascade/features.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,12 @@
"status": "complete",
"description": "Ensure unique and valid llms.txt URLs",
"constraints": ["unique", "valid_url"]
},
"analytics": {
"status": "complete",
"description": "Beam Analytics integration for production environment",
"provider": "Beam Analytics",
"environment": "production_only"
}
},
"deployment": {
Expand Down
11 changes: 11 additions & 0 deletions includes/environment.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<?php

function isProduction() {
$host = $_SERVER['HTTP_HOST'] ?? '';
return $host === 'llmstxt.directory';
}

function isStaging() {
$host = $_SERVER['HTTP_HOST'] ?? '';
return $host === 'staging.llmstxt.directory';
}
8 changes: 8 additions & 0 deletions public/index.php
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
<?php require_once __DIR__ . '/../includes/environment.php'; ?>
<!DOCTYPE html>
<html lang="en">
<head>
Expand All @@ -7,6 +8,13 @@
<link rel="preconnect" href="https://fonts.googleapis.com">
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
<link href="https://fonts.googleapis.com/css2?family=Space+Grotesk:wght@400;500;600;700&display=swap" rel="stylesheet">
<?php if (isProduction()): ?>
<script
src="https://beamanalytics.b-cdn.net/beam.min.js"
data-token="93f53d9b-fadc-433a-9c7c-9621ac1ee672"
async
></script>
<?php endif; ?>
<style>
body {
margin: 0;
Expand Down

0 comments on commit 9624ebf

Please sign in to comment.