deploy-stack 0.2.6 → 0.2.7

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "deploy-stack",
3
- "version": "0.2.6",
3
+ "version": "0.2.7",
4
4
  "description": "Provision production-ready AWS infrastructure and CI/CD pipelines in seconds.",
5
5
  "type": "module",
6
6
  "bin": {
@@ -6,7 +6,7 @@ import color from 'picocolors';
6
6
 
7
7
  import { checkDependency } from '../utils/system.js';
8
8
  import { detectFramework } from '../utils/detector.js';
9
- import { trackEvent } from '../core/telemetry.js';
9
+ import { trackEvent, flushTelemetry } from '../core/telemetry.js';
10
10
  import { getFrameworkWarning } from '../utils/warnings.js';
11
11
  import { provisionStateBucket } from '../utils/aws.js';
12
12
  import { generateTemplates } from '../utils/generator.js';
@@ -193,6 +193,7 @@ export async function mainStack() {
193
193
  s.stop('❌ Failed to provision remote state or authenticate with AWS.');
194
194
  console.error(color.red(`AWS Error: ${error.message}`));
195
195
  trackEvent('cli-error', { step: 'aws_provisioning', error_code: error.name || 'UNKNOWN' });
196
+ await flushTelemetry();
196
197
  process.exit(1);
197
198
  }
198
199
 
@@ -251,4 +252,7 @@ export async function mainStack() {
251
252
  ${color.magenta('🚀 Infrastructure ready! Need help or have feedback? Grab 15 mins with Anton:')}
252
253
  ${color.underline('https://calendly.com/anton-codes-iac/15min')}
253
254
  `);
255
+
256
+ // 10.Ensure all analytics are sent before the CLI terminates
257
+ await flushTelemetry();
254
258
  }
@@ -1,9 +1,11 @@
1
1
  import crypto from 'crypto';
2
2
 
3
- const TELEMETRY_ENDPOINT = 'https://app.posthog.com/capture';
3
+ const TELEMETRY_ENDPOINT = 'https://eu.i.posthog.com/capture/';
4
4
 
5
5
  const POSTHOG_API_KEY = 'phc_o2wgA3jVT9rVDiGSDzFAR42zZeiVGhhCY53HXVHUcYGT';
6
6
 
7
+ const pendingRequests = [];
8
+
7
9
  export function trackEvent(eventName, properties) {
8
10
  // 1. Respect privacy standards
9
11
  if (process.env.DO_NOT_TRACK === '1' || process.env.DO_NOT_TRACK === 'true') {
@@ -20,8 +22,8 @@ export function trackEvent(eventName, properties) {
20
22
  const payload = {
21
23
  api_key: POSTHOG_API_KEY,
22
24
  event: eventName,
25
+ distinct_id: anonymousProjectId,
23
26
  properties: {
24
- distinct_id: anonymousProjectId, // Used to count unique projects, not identify them
25
27
  os: process.platform,
26
28
  node_version: process.version,
27
29
  ...properties
@@ -29,11 +31,19 @@ export function trackEvent(eventName, properties) {
29
31
  };
30
32
 
31
33
  // 4. Fire and forget (No 'await' so we don't block the user's terminal)
32
- fetch(TELEMETRY_ENDPOINT, {
34
+ const request = fetch(TELEMETRY_ENDPOINT, {
33
35
  method: 'POST',
34
36
  headers: { 'Content-Type': 'application/json' },
35
37
  body: JSON.stringify(payload),
36
- }).catch(() => {
38
+ }).catch((err) => {
37
39
  // Silently swallow network errors (e.g., user is offline)
38
40
  });
41
+
42
+ pendingRequests.push(request);
43
+ }
44
+
45
+ export async function flushTelemetry() {
46
+ if (pendingRequests.length > 0) {
47
+ await Promise.all(pendingRequests);
48
+ }
39
49
  }
@@ -55,4 +55,8 @@ resource "aws_cloudfront_distribution" "cdn" {
55
55
  output "cloudfront_url" {
56
56
  description = "Your globally cached, HTTPS-secured application URL"
57
57
  value = "https://${aws_cloudfront_distribution.cdn.domain_name}"
58
+ }
59
+
60
+ output "z_NEXT_STEP_REQUIRED" {
61
+ value = "⚠️ Your infrastructure is up, but these URLs will return 503 errors until you push your code to GitHub and the Actions pipeline deploys your container."
58
62
  }