Skip to content
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

feat: Proxy server header capability #628

Merged

Conversation

mohitanand-cred
Copy link
Contributor

Changes:

  • Added support for custom header and query items parameter.
  • New struct called ProxyServerConfig which takes in proxy server url and a delegate(MixpanelProxyServerDelegate).
  • MixpanelProxyServerDelegate can be used to provide headers or query items to the proxy server. The delegate func mixpanelResourceForProxyServer(_ mixpanel: MixpanelInstance) -> ServerProxyResource? is being called when its time flush the batch request.
  • Created a new initialize function in Mixpanel which takes in ProxyServerConfig instead of just serverURL.

optOutTrackingByDefault: Bool = false,
useUniqueDistinctId: Bool = false,
superProperties: Properties? = nil,
proxyServerConfig: ProxyServerConfig) -> MixpanelInstance {
Copy link
Contributor

Choose a reason for hiding this comment

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

if proxyServerConfig is optional, could you add proxyServerConfig: ProxyServerConfig? = nil to the existing initialize function rather than adding a new function?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thanks for the feedback on the PR 🙌 . On using the same intialize function, they are few points I want to highlight.

  • By combining serverURL and ProxyServerConfig into one method, we risk users setting both parameters, which doesn't align with their intended use. Ideally one of them should be set. Keeping them separate ensures users have a clear choice without the possibility of configuring conflicting options.
  • With two distinct initialization methods, we're directly guiding users on their options. One method is for basic server URL configuration, and the other is for more advanced proxy configurations.

@zihejia
Copy link
Contributor

zihejia commented Mar 29, 2024

thank you so much @mohitanand-cred ! the PR looks good except one comment, also could you rebase/merge from the latest master and make sure all CI tests pass?

@jaredmixpanel jaredmixpanel requested a review from zihejia April 8, 2024 17:33
Copy link
Contributor

@jaredmixpanel jaredmixpanel left a comment

Choose a reason for hiding this comment

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

LGTM

@jaredmixpanel jaredmixpanel merged commit ec92bd9 into mixpanel:master Apr 8, 2024
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants