Skip to content

Improve configuration of the PostHog client #52

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Feb 14, 2025

Conversation

haacked
Copy link
Collaborator

@haacked haacked commented Feb 14, 2025

No description provided.

@haacked haacked merged commit 679a542 into main Feb 14, 2025
4 checks passed
@haacked haacked deleted the haacked/improve-posthog-configuration branch February 14, 2025 23:11
Copy link
Contributor

@greptile-apps greptile-apps bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

PR Summary

This PR introduces a builder pattern for PostHog configuration in ASP.NET Core applications, improving service registration flexibility and configuration options.

  • Added new PostHogOptionsBuilder in /src/PostHog.AspNetCore/PostHogOptionsBuilder.cs for structured configuration
  • Removed /src/PostHog.AspNetCore/Library/Ensure.cs utility class - ensure null checking is handled appropriately in new implementation
  • Modified /src/PostHog.AspNetCore/Registration.cs to use builder pattern and return IHostApplicationBuilder for better method chaining
  • Updated version from 1.0.0-beta.8 to 1.0.0-beta.9 across configuration files
  • Added internal visibility between PostHog and PostHog.AspNetCore assemblies in /src/PostHog/Config/AssemblyInfo.cs

7 file(s) reviewed, 3 comment(s)
Edit PR Review Bot Settings | Greptile

=> UseConfigurationSection(builder.Configuration.GetSection(configurationSectionName));

/// <summary>
/// Specifies the the configuration section to use for PostHog options. If this call is omitted,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

syntax: Typo in XML comment - 'the the' is duplicated

Suggested change
/// Specifies the the configuration section to use for PostHog options. If this call is omitted,
/// Specifies the configuration section to use for PostHog options. If this call is omitted,

/// </summary>
/// <param name="builder">The <see cref="IHostApplicationBuilder"/>.</param>
/// <param name="configurationSection">The configuration section where to load config settings.</param>
/// <param name="options">Provides a mean to configure the <see cref="PostHogClient"/> and some of the services it uses.</param>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

syntax: typo in XML comment: 'Provides a mean' should be 'Provides a means'

Suggested change
/// <param name="options">Provides a mean to configure the <see cref="PostHogClient"/> and some of the services it uses.</param>
/// <param name="options">Provides a means to configure the <see cref="PostHogClient"/> and some of the services it uses.</param>

builder.Services.AddSingleton<ITaskScheduler, TaskRunTaskScheduler>();
builder.Services.AddSingleton<IPostHogClient, PostHogClient>();
return builder.Services.AddHttpClient(nameof(PostHogClient));
options = NotNull(options);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

logic: NotNull check on options happens after builder - should check builder first since it's the primary parameter

Suggested change
options = NotNull(options);
builder = NotNull(builder);
options = NotNull(options);

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant