2828// Get configuration from environment variables
2929var projectToken = Environment . GetEnvironmentVariable ( "POSTHOG_PROJECT_TOKEN" )
3030 ?? Environment . GetEnvironmentVariable ( "POSTHOG_PROJECT_API_KEY" ) ;
31- var personalApiKey = Environment . GetEnvironmentVariable ( "POSTHOG_PERSONAL_API_KEY " ) ;
31+ var secretKey = Environment . GetEnvironmentVariable ( "POSTHOG_SECRET_KEY " ) ;
3232var endpoint = Environment . GetEnvironmentVariable ( "POSTHOG_HOST" ) ?? "https://us.i.posthog.com" ;
3333
3434// Check credentials
5858
5959Console . WriteLine ( "✅ PostHog credentials loaded successfully!" ) ;
6060Console . WriteLine ( $ " Project Token: ✅ Configured") ;
61- Console . WriteLine ( $ " Personal API Key: { ( string . IsNullOrEmpty ( personalApiKey ) ? "❌ Not set (local evaluation disabled)" : "✅ Configured" ) } ") ;
61+ Console . WriteLine ( $ " Secret Key: { ( string . IsNullOrEmpty ( secretKey ) ? "❌ Not set (local evaluation disabled)" : "✅ Configured" ) } ") ;
6262Console . WriteLine ( $ " Endpoint: { endpoint } ") ;
6363Console . WriteLine ( ) ;
6464
6565// Create PostHog options
6666var options = new PostHogOptions
6767{
6868 ProjectToken = projectToken ,
69- PersonalApiKey = personalApiKey ,
69+ SecretKey = secretKey ,
7070 HostUrl = new Uri ( endpoint ) ,
7171 FlushAt = 1 , // Flush immediately for demo purposes
7272 FlushInterval = TimeSpan . FromSeconds ( 1 )
8787// Display menu
8888while ( true )
8989{
90- ShowMenu ( hasPersonalApiKey : ! string . IsNullOrEmpty ( personalApiKey ) ) ;
90+ ShowMenu ( hasSecretKey : ! string . IsNullOrEmpty ( secretKey ) ) ;
9191 var choice = Prompt ( "\n Enter your choice (1-6): " ) ;
9292
9393 switch ( choice )
102102 await RunFeatureFlagExamples ( posthog ) ;
103103 break ;
104104 case "4" :
105- await RunLocalEvaluationExample ( posthog , hasPersonalApiKey : ! string . IsNullOrEmpty ( personalApiKey ) ) ;
105+ await RunLocalEvaluationExample ( posthog , hasSecretKey : ! string . IsNullOrEmpty ( secretKey ) ) ;
106106 break ;
107107 case "5" :
108- await RunAllExamples ( posthog , hasPersonalApiKey : ! string . IsNullOrEmpty ( personalApiKey ) ) ;
108+ await RunAllExamples ( posthog , hasSecretKey : ! string . IsNullOrEmpty ( secretKey ) ) ;
109109 break ;
110110 case "6" :
111111 Console . WriteLine ( "👋 Goodbye!" ) ;
131131 Console . WriteLine ( ) ;
132132}
133133
134- static void ShowMenu ( bool hasPersonalApiKey )
134+ static void ShowMenu ( bool hasSecretKey )
135135{
136136 Console . WriteLine ( "🦔 PostHog .NET SDK Demo - Choose an example to run:" ) ;
137137 Console . WriteLine ( ) ;
138138 Console . WriteLine ( "1. Capture events" ) ;
139139 Console . WriteLine ( "2. Identify users" ) ;
140140 Console . WriteLine ( "3. Feature flags (remote evaluation)" ) ;
141- Console . WriteLine ( $ "4. Local evaluation with ETag polling{ ( hasPersonalApiKey ? "" : " (requires Personal API Key)" ) } ") ;
141+ Console . WriteLine ( $ "4. Local evaluation with ETag polling{ ( hasSecretKey ? "" : " (requires Secret Key)" ) } ") ;
142142 Console . WriteLine ( "5. Run all examples" ) ;
143143 Console . WriteLine ( "6. Exit" ) ;
144144}
@@ -283,17 +283,17 @@ static async Task RunFeatureFlagExamples(PostHogClient posthog)
283283 }
284284}
285285
286- static async Task RunLocalEvaluationExample ( PostHogClient posthog , bool hasPersonalApiKey )
286+ static async Task RunLocalEvaluationExample ( PostHogClient posthog , bool hasSecretKey )
287287{
288288 Console . WriteLine ( "\n " + new string ( '=' , 60 ) ) ;
289289 Console . WriteLine ( "LOCAL EVALUATION WITH ETAG POLLING" ) ;
290290 Console . WriteLine ( new string ( '=' , 60 ) ) ;
291291
292- if ( ! hasPersonalApiKey )
292+ if ( ! hasSecretKey )
293293 {
294- Console . WriteLine ( "\n ⚠️ This example requires a Personal API Key to be set." ) ;
295- Console . WriteLine ( " Set POSTHOG_PERSONAL_API_KEY in your .env file." ) ;
296- Console . WriteLine ( " Personal API keys can be created at:" ) ;
294+ Console . WriteLine ( "\n ⚠️ This example requires a Secret Key to be set." ) ;
295+ Console . WriteLine ( " Set POSTHOG_SECRET_KEY in your .env file." ) ;
296+ Console . WriteLine ( " Secret keys can be created at:" ) ;
297297 Console . WriteLine ( " https://us.posthog.com/settings/user-api-keys" ) ;
298298 return ;
299299 }
@@ -368,12 +368,12 @@ static async Task RunLocalEvaluationExample(PostHogClient posthog, bool hasPerso
368368 Console . WriteLine ( " ✓ Polling stopped" ) ;
369369}
370370
371- static async Task RunAllExamples ( PostHogClient posthog , bool hasPersonalApiKey )
371+ static async Task RunAllExamples ( PostHogClient posthog , bool hasSecretKey )
372372{
373373 Console . WriteLine ( "\n 🔄 Running all examples…" ) ;
374374
375375 await RunCaptureExamples ( posthog ) ;
376376 await RunIdentifyExamples ( posthog ) ;
377377 await RunFeatureFlagExamples ( posthog ) ;
378- await RunLocalEvaluationExample ( posthog , hasPersonalApiKey ) ;
378+ await RunLocalEvaluationExample ( posthog , hasSecretKey ) ;
379379}
0 commit comments