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

Allow custom metrics endpoint #1037

Merged
merged 4 commits into from
Mar 5, 2024
Merged

Allow custom metrics endpoint #1037

merged 4 commits into from
Mar 5, 2024

Conversation

danieljackins
Copy link
Contributor

@danieljackins danieljackins commented Feb 13, 2024

Allows users to set a custom metrics endpoint when loading Analytics. Tested locally by setting a custom endpoint and confirming it was used.

  • I've included a changeset (psst. run yarn changeset. Read about changesets here).

Copy link

changeset-bot bot commented Feb 13, 2024

🦋 Changeset detected

Latest commit: 9baea6d

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
@segment/analytics-next Minor

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

Comment on lines 361 to 363
Stats.initRemoteMetrics(
legacySettings.metrics ?? { host: options.metricsEndpoint }
)
Copy link
Contributor

Choose a reason for hiding this comment

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

What happens if Stats.initRemoteMetrics receives { host: undefined } ? Given that we were always sending the legacySettings.metrics object which looks like could be either full or undefined.

I'm also curious if we need this coalescing here as just above we're already overriding it.

/**
* Allows you to change the metrics endpoint used
*/
metricsEndpoint?: string
Copy link
Contributor

@silesky silesky Feb 14, 2024

Choose a reason for hiding this comment

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

Can you provide some background about the impetus / use case for a new setting (maybe link to the issue / description is OK)? (I saw an issue around this, but I figured we would just default to the overridden apiHost / protocol.)

i.e.

integrations: {
        'Segment.io': {
          // assume https://MY-CUSTOM-API-PROXY.com/v1/m  proxies to
          // https://api.segment.io/v1/m
          apiHost: 'MY-CUSTOM-API-PROXY.com/v1',
          protocol: 'https' // optional
        }

(forgive me if I am missing something silly)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

No that makes sense! Updated to default to that value and to respect protocol if set

@danieljackins danieljackins merged commit e435279 into master Mar 5, 2024
4 checks passed
@danieljackins danieljackins deleted the metrics-config branch March 5, 2024 21:00
@github-actions github-actions bot mentioned this pull request Mar 5, 2024
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.

3 participants