@@ -668,12 +668,52 @@ def create_release(self, repo_owner: str, repo_name: str, tag_name: str, release
668668
669669 def user_activity_query (self , variables : dict [str , Any ], query : str ) -> Dict [str , Any ]:
670670 """
671- Performs a user activity query using GitHub's GraphQL API across all repositories and organisations.
671+ Performs a user activity query using GitHub's GraphQL API for the authenticated user (token owner).
672+
673+ **Important**: To query private organization activities, the query MUST use the `viewer` field
674+ instead of `user(login:)`. The `viewer` field returns data for the authenticated user (token owner)
675+ and includes all private contributions and organization activities.
676+
677+ **Query Requirements**:
678+ - Use `viewer { ... }` to query the authenticated user's activity
679+ - Do NOT use `user(login: "username") { ... }` as it only shows public contributions
680+ - The `viewer` query automatically includes private repositories and organizations
681+
682+ **Example Query Structure**:
683+ ```graphql
684+ query($from: DateTime!, $to: DateTime!) {
685+ viewer {
686+ contributionsCollection(from: $from, to: $to) {
687+ commitContributionsByRepository(maxRepositories: 100) {
688+ repository {
689+ name
690+ isPrivate
691+ owner { login }
692+ }
693+ contributions { totalCount }
694+ }
695+ pullRequestContributionsByRepository(maxRepositories: 100) {
696+ repository {
697+ name
698+ isPrivate
699+ owner { login }
700+ }
701+ contributions { totalCount }
702+ }
703+ }
704+ }
705+ }
706+ ```
672707 Args:
673- variables (dict[str, Any]): The variables to include in the query i.e. {"login": "username", "from": "2023-01-01", "to": "2023-12-31"}.
674- query (str): The search query string. GitHub GraphQL query summary collection that includes all activity across all orgs, public and private.
708+ variables (dict[str, Any]): Query variables. For authenticated user queries, only include:
709+ - "from": Start date in ISO 8601 format (e.g., "2024-10-01T00:00:00Z")
710+ - "to": End date in ISO 8601 format (e.g., "2024-10-31T23:59:59Z")
711+ Do NOT include "login" variable when using `viewer`.
712+ query (str): GraphQL query string. Must use `viewer` field to access authenticated user's
713+ private activities across all organizations.
675714 Returns:
676- Dict[str, Any]: The JSON response from the GitHub API containing search results if successful.
715+ Dict[str, Any]: The JSON response from GitHub's GraphQL API containing the authenticated
716+ user's activity data, including private repositories and organizations.
677717 """
678718 logging .info ("Performing user query on GitHub" )
679719
0 commit comments