Skip to content

feat: add metrics.hits, with support for new instrumentation/content/hits endpoint #410

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 4 commits into from
May 20, 2025

Conversation

toph-allen
Copy link
Collaborator

Intent

Add support support for Posit Connect's content hits endpoint (GET /v1/instrumentation/content/hits)

Closes #403

Notes

  • Implementation lives in metrics/hits.py
  • from and to parameters are named start and end in Python to work around reserved keywords. The rename_params function shared across all metrics classes has been collapsed into a single function.

Tests

  • Tests have been added which cover all of the new functionality.

@toph-allen toph-allen requested a review from tdstein as a code owner May 13, 2025 17:19
Copy link

github-actions bot commented May 13, 2025

☂️ Python Coverage

current status: ✅

Overall Coverage

Lines Covered Coverage Threshold Status
1900 1791 94% 0% 🟢

New Files

File Coverage Status
src/posit/connect/metrics/hits.py 100% 🟢
src/posit/connect/metrics/rename_params.py 100% 🟢
TOTAL 100% 🟢

Modified Files

File Coverage Status
src/posit/connect/metrics/metrics.py 100% 🟢
src/posit/connect/metrics/shiny_usage.py 100% 🟢
src/posit/connect/metrics/visits.py 100% 🟢
src/posit/connect/resources.py 92% 🟢
TOTAL 98% 🟢

updated for commit: 7576f00 by action🐍

Comment on lines +26 to +35
Parameters
----------
start : str, not required
The timestamp that starts the time window of interest in RFC 3339 format.
Any hit information that happened prior to this timestamp will not be returned.
Example: "2025-05-01T00:00:00Z"
end : str, not required
The timestamp that ends the time window of interest in RFC 3339 format.
Any hit information that happened after this timestamp will not be returned.
Example: "2025-05-02T00:00:00Z"
Copy link
Collaborator

Choose a reason for hiding this comment

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

Should we include something here about how 'start' and 'end' are translated to 'from' and 'to'?

Also, another option here is to just use **kwargs and state the use of from and to in the docstring.

def fetch(
        self,
        **kwargs,
    ) -> Iterable[Hit]:
        """
        Fetch all content hit records matching the specified conditions.

        Parameters
        ----------
        from : str, not required
            The timestamp that starts the time window of interest in RFC 3339 format.
            Any hit information that happened prior to this timestamp will not be returned.
            Example: "2025-05-01T00:00:00Z"
        to : str, not required
            The timestamp that ends the time window of interest in RFC 3339 format.
            Any hit information that happened after this timestamp will not be returned.
            Example: "2025-05-02T00:00:00Z"

        Returns
        -------
        Iterable[Hit]
            All content hit records matching the specified conditions.
        """
        ...

@toph-allen toph-allen merged commit dc6bbb5 into main May 20, 2025
40 checks passed
@toph-allen toph-allen deleted the toph/client-metrics-hits branch May 20, 2025 16:42
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.

Support upcoming /v1/intrumentation/content/hits endpoint
2 participants