Skip to content

Commit d811613

Browse files
Keep the API user agent reading the deployed version
Go back to building the user agent from deployed_version.txt instead of a hard coded version number. The deployed version stamp already tells the logs which build made each call, so a separate release number is not needed.
1 parent 35b4ad6 commit d811613

1 file changed

Lines changed: 6 additions & 6 deletions

File tree

common.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -126,11 +126,6 @@ class TrackingType(enum.Enum):
126126

127127
_USER_AGENT_PREFIX = 'cloud-solutions/mas-scenemachine'
128128

129-
# Released application version, surfaced in the API user-agent so Google Cloud
130-
# logs attribute calls to a clean "scene-machine v1" instead of the deploy stamp
131-
# (branch + timestamp) that deployed_version.txt holds. Bump on a release.
132-
VERSION = '1.0.0'
133-
134129

135130
@functools.lru_cache(maxsize=None)
136131
def get_api_client_headers(tracking_type: TrackingType) -> dict[str, str]:
@@ -145,7 +140,12 @@ def get_api_client_headers(tracking_type: TrackingType) -> dict[str, str]:
145140
A dictionary of headers.
146141
"""
147142

148-
user_agent = f'{_USER_AGENT_PREFIX}-{tracking_type.value}-v{VERSION}'
143+
user_agent = f'{_USER_AGENT_PREFIX}-{tracking_type.value}-v'
144+
try:
145+
with open('deployed_version.txt', 'r') as f:
146+
user_agent += f.read().strip()
147+
except FileNotFoundError:
148+
user_agent += 'unknown'
149149

150150
return {
151151
'User-Agent': user_agent,

0 commit comments

Comments
 (0)