prompt: You will be provided with a partial code base and an issue statement explaining a problem to resolve.
  <issue>
  [Feature]: Collect telemetry data about how `send_anonymous_usage_stats` was configured
  The project context (and its schema) should be updated to include the key `send_anonymous_usage_stats_source` with the value `ProjectSettingService.get_with_metadata('send_anonymous_usage_stats')[1]['source'].value`, which can be one of the following strings:
  - `auto`
  - `config_override`
  - `db`
  - `default`
  - `dotenv`
  - `env`
  - `inherited`
  - `meltano_env`
  - `meltano_yml`
  
  CC @pnadolny13 @aaronsteers 
  
  </issue>
  <code>
  [start of src/meltano/core/tracking/contexts/project.py]
  1 """Project context for the Snowplow tracker."""
  2 
  3 from __future__ import annotations
  4 
  5 import uuid
  6 from enum import Enum, auto
  7 
  8 from cached_property import cached_property
  9 from snowplow_tracker import SelfDescribingJson
  10 from structlog.stdlib import get_logger
  11 
  12 from meltano.core.project import Project
  13 from meltano.core.project_settings_service import ProjectSettingsService
  14 from meltano.core.tracking.schemas import ProjectContextSchema
  15 from meltano.core.utils import hash_sha256
  16 
  17 logger = get_logger(__name__)
  18 
  19 
  20 class ProjectUUIDSource(Enum):
  21     """The source of the `project_uuid` used for telemetry."""
  22 
  23     # The UUID was explicitly provided in the config as the `project_id`.
  24     explicit = auto()
  25 
  26     # The UUID was derived by hashing the `project_id` in the config.
  27     derived = auto()
  28 
  29     # The UUID was randomly generated (UUID v4) since no `project_id` was configured.
  30     random = auto()
  31 
  32 
  33 class ProjectContext(SelfDescribingJson):
  34     """Tracking context for the Meltano project."""
  35 
  36     def __init__(self, project: Project, client_id: uuid.UUID):
  37         """Initialize a meltano tracking "project" context.
  38 
  39         Args:
  40             project: The Meltano project.
  41             client_id: The client ID from `analytics.json`.
  42         """
  43         self.project = project
  44         self.settings_service = ProjectSettingsService(project)
  45         self.send_anonymous_usage_stats = self.settings_service.get(
  46             "send_anonymous_usage_stats", True
  47         )
  48 
  49         super().__init__(
  50             ProjectContextSchema.url,
  51             {
  52                 "context_uuid": str(uuid.uuid4()),
  53                 "project_uuid": str(self.project_uuid),
  54                 "project_uuid_source": self.project_uuid_source.name,
  55                 "client_uuid": str(client_id),
  56                 "environment_name_hash": (
  57                     hash_sha256(self.project.active_environment.name)
  58                     if self.project.active_environment
  59                     else None
  60                 ),
  61             },
  62         )
  63 
  64     @property
  65     def project_uuid_source(self) -> ProjectUUIDSource:
  66         """Obtain the source of the `project_uuid` used for telemetry.
  67 
  68         Returns:
  69             ProjectUUIDSource: The source of the `project_uuid` used for telemetry.
  70         """
  71         # Ensure the `project_uuid` has been generated
  72         self.project_uuid  # noqa: WPS428
  73         return self._project_uuid_source
  74 
  75     @cached_property
  76     def project_uuid(self) -> uuid.UUID:
  77         """Obtain the `project_id` from the project config file.
  78 
  79         If it is not found (e.g. first time run), generate a valid v4 UUID, and and store it in the
  80         project config file.
  81 
  82         Returns:
  83             The project UUID.
  84         """
  85         project_id_str = self.settings_service.get("project_id")
  86 
  87         if project_id_str:
  88             try:
  89                 # Project ID might already be a UUID
  90                 project_id = uuid.UUID(project_id_str)
  91             except ValueError:
  92                 # If the project ID is not a UUID, then we hash it, and use the hash to make a UUID
  93                 project_id = uuid.UUID(hash_sha256(project_id_str)[::2])
  94                 self._project_uuid_source = ProjectUUIDSource.derived
  95             else:
  96                 self._project_uuid_source = ProjectUUIDSource.explicit
  97         else:
  98             project_id = uuid.uuid4()
  99             self._project_uuid_source = ProjectUUIDSource.random
  100 
  101         return project_id
  102
  [end of src/meltano/core/tracking/contexts/project.py]
  [start of src/meltano/core/tracking/schemas.py]
  1 """Meltano Iglu schemas metadata & utilities."""
  2 
  3 from __future__ import annotations
  4 
  5 from dataclasses import dataclass
  6 
  7 DEFAULT_VENDOR = "com.meltano"
  8 
  9 
  10 @dataclass
  11 class IgluSchema:
  12     """Dataclass to store the name, version, vendor, and URL for an Iglu schema."""
  13 
  14     name: str
  15     version: str
  16     vendor: str = DEFAULT_VENDOR
  17 
  18     @property
  19     def url(self) -> str:
  20         """Construct an iglu schema URL.
  21 
  22         Returns:
  23             The URL to the schema.
  24         """
  25         return f"iglu:{self.vendor}/{self.name}/jsonschema/{self.version}"
  26 
  27 
  28 CliContextSchema = IgluSchema("cli_context", "1-1-0")
  29 CliEventSchema = IgluSchema("cli_event", "1-0-1")
  30 BlockEventSchema = IgluSchema("block_event", "1-0-0")
  31 EnvironmentContextSchema = IgluSchema("environment_context", "1-0-0")
  32 ExceptionContextSchema = IgluSchema("exception_context", "1-0-0")
  33 ExitEventSchema = IgluSchema("exit_event", "1-0-0")
  34 PluginsContextSchema = IgluSchema("plugins_context", "1-0-0")
  35 ProjectContextSchema = IgluSchema("project_context", "1-0-0")
  36 TelemetryStateChangeEventSchema = IgluSchema("telemetry_state_change_event", "1-0-0")
  37
  [end of src/meltano/core/tracking/schemas.py]
  </code>
  
  I need you to solve this issue by generating a single patch file that I can apply directly to this repository using git apply. Please respond with a single patch file in the following format.
  <patch>
  diff --git a/file.py b/file.py
  --- a/file.py
  +++ b/file.py
  @@ -1,27 +1,35 @@
   def euclidean(a, b):
  -    while b:
  -        a, b = b, a % b
  -    return a
  +    if b == 0:
  +        return a
  +    return euclidean(b, a % b)
   
   
   def bresenham(x0, y0, x1, y1):
       points = []
       dx = abs(x1 - x0)
       dy = abs(y1 - y0)
  -    sx = 1 if x0 < x1 else -1
  -    sy = 1 if y0 < y1 else -1
  -    err = dx - dy
  +    x, y = x0, y0
  +    sx = -1 if x0 > x1 else 1
  +    sy = -1 if y0 > y1 else 1
   
  -    while True:
  -        points.append((x0, y0))
  -        if x0 == x1 and y0 == y1:
  -            break
  -        e2 = 2 * err
  -        if e2 > -dy:
  -            err -= dy
  -            x0 += sx
  -        if e2 < dx:
  -            err += dx
  -            y0 += sy
  +    if dx > dy:
  +        err = dx / 2.0
  +        while x != x1:
  +            points.append((x, y))
  +            err -= dy
  +            if err < 0:
  +                y += sy
  +                err += dx
  +            x += sx
  +    else:
  +        err = dy / 2.0
  +        while y != y1:
  +            points.append((x, y))
  +            err -= dx
  +            if err < 0:
  +                x += sx
  +                err += dy
  +            y += sy
  +
  +    points.append((x, y))
       return points
  
  </patch>
golden_diff: diff --git a/src/meltano/core/tracking/contexts/project.py b/src/meltano/core/tracking/contexts/project.py
  --- a/src/meltano/core/tracking/contexts/project.py
  +++ b/src/meltano/core/tracking/contexts/project.py
  @@ -42,9 +42,10 @@
           """
           self.project = project
           self.settings_service = ProjectSettingsService(project)
  -        self.send_anonymous_usage_stats = self.settings_service.get(
  -            "send_anonymous_usage_stats", True
  -        )
  +        (
  +            send_anonymous_usage_stats,
  +            send_anonymous_usage_stats_metadata,
  +        ) = self.settings_service.get_with_metadata("send_anonymous_usage_stats")
   
           super().__init__(
               ProjectContextSchema.url,
  @@ -58,6 +59,10 @@
                       if self.project.active_environment
                       else None
                   ),
  +                "send_anonymous_usage_stats": send_anonymous_usage_stats,
  +                "send_anonymous_usage_stats_source": (
  +                    send_anonymous_usage_stats_metadata["source"].value
  +                ),
               },
           )
   
  diff --git a/src/meltano/core/tracking/schemas.py b/src/meltano/core/tracking/schemas.py
  --- a/src/meltano/core/tracking/schemas.py
  +++ b/src/meltano/core/tracking/schemas.py
  @@ -32,5 +32,5 @@
   ExceptionContextSchema = IgluSchema("exception_context", "1-0-0")
   ExitEventSchema = IgluSchema("exit_event", "1-0-0")
   PluginsContextSchema = IgluSchema("plugins_context", "1-0-0")
  -ProjectContextSchema = IgluSchema("project_context", "1-0-0")
  +ProjectContextSchema = IgluSchema("project_context", "1-1-0")
   TelemetryStateChangeEventSchema = IgluSchema("telemetry_state_change_event", "1-0-0")
  
verification_info: {"golden_diff": "diff --git a/src/meltano/core/tracking/contexts/project.py b/src/meltano/core/tracking/contexts/project.py\n--- a/src/meltano/core/tracking/contexts/project.py\n+++ b/src/meltano/core/tracking/contexts/project.py\n@@ -42,9 +42,10 @@\n         \"\"\"\n         self.project = project\n         self.settings_service = ProjectSettingsService(project)\n-        self.send_anonymous_usage_stats = self.settings_service.get(\n-            \"send_anonymous_usage_stats\", True\n-        )\n+        (\n+            send_anonymous_usage_stats,\n+            send_anonymous_usage_stats_metadata,\n+        ) = self.settings_service.get_with_metadata(\"send_anonymous_usage_stats\")\n \n         super().__init__(\n             ProjectContextSchema.url,\n@@ -58,6 +59,10 @@\n                     if self.project.active_environment\n                     else None\n                 ),\n+                \"send_anonymous_usage_stats\": send_anonymous_usage_stats,\n+                \"send_anonymous_usage_stats_source\": (\n+                    send_anonymous_usage_stats_metadata[\"source\"].value\n+                ),\n             },\n         )\n \ndiff --git a/src/meltano/core/tracking/schemas.py b/src/meltano/core/tracking/schemas.py\n--- a/src/meltano/core/tracking/schemas.py\n+++ b/src/meltano/core/tracking/schemas.py\n@@ -32,5 +32,5 @@\n ExceptionContextSchema = IgluSchema(\"exception_context\", \"1-0-0\")\n ExitEventSchema = IgluSchema(\"exit_event\", \"1-0-0\")\n PluginsContextSchema = IgluSchema(\"plugins_context\", \"1-0-0\")\n-ProjectContextSchema = IgluSchema(\"project_context\", \"1-0-0\")\n+ProjectContextSchema = IgluSchema(\"project_context\", \"1-1-0\")\n TelemetryStateChangeEventSchema = IgluSchema(\"telemetry_state_change_event\", \"1-0-0\")\n", "issue": "[Feature]: Collect telemetry data about how `send_anonymous_usage_stats` was configured\nThe project context (and its schema) should be updated to include the key `send_anonymous_usage_stats_source` with the value `ProjectSettingService.get_with_metadata('send_anonymous_usage_stats')[1]['source'].value`, which can be one of the following strings:\r\n- `auto`\r\n- `config_override`\r\n- `db`\r\n- `default`\r\n- `dotenv`\r\n- `env`\r\n- `inherited`\r\n- `meltano_env`\r\n- `meltano_yml`\r\n\r\nCC @pnadolny13 @aaronsteers \n", "before_files": [{"content": "\"\"\"Project context for the Snowplow tracker.\"\"\"\n\nfrom __future__ import annotations\n\nimport uuid\nfrom enum import Enum, auto\n\nfrom cached_property import cached_property\nfrom snowplow_tracker import SelfDescribingJson\nfrom structlog.stdlib import get_logger\n\nfrom meltano.core.project import Project\nfrom meltano.core.project_settings_service import ProjectSettingsService\nfrom meltano.core.tracking.schemas import ProjectContextSchema\nfrom meltano.core.utils import hash_sha256\n\nlogger = get_logger(__name__)\n\n\nclass ProjectUUIDSource(Enum):\n    \"\"\"The source of the `project_uuid` used for telemetry.\"\"\"\n\n    # The UUID was explicitly provided in the config as the `project_id`.\n    explicit = auto()\n\n    # The UUID was derived by hashing the `project_id` in the config.\n    derived = auto()\n\n    # The UUID was randomly generated (UUID v4) since no `project_id` was configured.\n    random = auto()\n\n\nclass ProjectContext(SelfDescribingJson):\n    \"\"\"Tracking context for the Meltano project.\"\"\"\n\n    def __init__(self, project: Project, client_id: uuid.UUID):\n        \"\"\"Initialize a meltano tracking \"project\" context.\n\n        Args:\n            project: The Meltano project.\n            client_id: The client ID from `analytics.json`.\n        \"\"\"\n        self.project = project\n        self.settings_service = ProjectSettingsService(project)\n        self.send_anonymous_usage_stats = self.settings_service.get(\n            \"send_anonymous_usage_stats\", True\n        )\n\n        super().__init__(\n            ProjectContextSchema.url,\n            {\n                \"context_uuid\": str(uuid.uuid4()),\n                \"project_uuid\": str(self.project_uuid),\n                \"project_uuid_source\": self.project_uuid_source.name,\n                \"client_uuid\": str(client_id),\n                \"environment_name_hash\": (\n                    hash_sha256(self.project.active_environment.name)\n                    if self.project.active_environment\n                    else None\n                ),\n            },\n        )\n\n    @property\n    def project_uuid_source(self) -> ProjectUUIDSource:\n        \"\"\"Obtain the source of the `project_uuid` used for telemetry.\n\n        Returns:\n            ProjectUUIDSource: The source of the `project_uuid` used for telemetry.\n        \"\"\"\n        # Ensure the `project_uuid` has been generated\n        self.project_uuid  # noqa: WPS428\n        return self._project_uuid_source\n\n    @cached_property\n    def project_uuid(self) -> uuid.UUID:\n        \"\"\"Obtain the `project_id` from the project config file.\n\n        If it is not found (e.g. first time run), generate a valid v4 UUID, and and store it in the\n        project config file.\n\n        Returns:\n            The project UUID.\n        \"\"\"\n        project_id_str = self.settings_service.get(\"project_id\")\n\n        if project_id_str:\n            try:\n                # Project ID might already be a UUID\n                project_id = uuid.UUID(project_id_str)\n            except ValueError:\n                # If the project ID is not a UUID, then we hash it, and use the hash to make a UUID\n                project_id = uuid.UUID(hash_sha256(project_id_str)[::2])\n                self._project_uuid_source = ProjectUUIDSource.derived\n            else:\n                self._project_uuid_source = ProjectUUIDSource.explicit\n        else:\n            project_id = uuid.uuid4()\n            self._project_uuid_source = ProjectUUIDSource.random\n\n        return project_id\n", "path": "src/meltano/core/tracking/contexts/project.py"}, {"content": "\"\"\"Meltano Iglu schemas metadata & utilities.\"\"\"\n\nfrom __future__ import annotations\n\nfrom dataclasses import dataclass\n\nDEFAULT_VENDOR = \"com.meltano\"\n\n\n@dataclass\nclass IgluSchema:\n    \"\"\"Dataclass to store the name, version, vendor, and URL for an Iglu schema.\"\"\"\n\n    name: str\n    version: str\n    vendor: str = DEFAULT_VENDOR\n\n    @property\n    def url(self) -> str:\n        \"\"\"Construct an iglu schema URL.\n\n        Returns:\n            The URL to the schema.\n        \"\"\"\n        return f\"iglu:{self.vendor}/{self.name}/jsonschema/{self.version}\"\n\n\nCliContextSchema = IgluSchema(\"cli_context\", \"1-1-0\")\nCliEventSchema = IgluSchema(\"cli_event\", \"1-0-1\")\nBlockEventSchema = IgluSchema(\"block_event\", \"1-0-0\")\nEnvironmentContextSchema = IgluSchema(\"environment_context\", \"1-0-0\")\nExceptionContextSchema = IgluSchema(\"exception_context\", \"1-0-0\")\nExitEventSchema = IgluSchema(\"exit_event\", \"1-0-0\")\nPluginsContextSchema = IgluSchema(\"plugins_context\", \"1-0-0\")\nProjectContextSchema = IgluSchema(\"project_context\", \"1-0-0\")\nTelemetryStateChangeEventSchema = IgluSchema(\"telemetry_state_change_event\", \"1-0-0\")\n", "path": "src/meltano/core/tracking/schemas.py"}]}