Skip to content

Commit

Permalink
Added CLI version & OS to all analytics events
Browse files Browse the repository at this point in the history
  • Loading branch information
Ghurfa committed Oct 12, 2023
1 parent a753769 commit c3f1b3c
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 8 deletions.
2 changes: 1 addition & 1 deletion pros/cli/conductor.py
Original file line number Diff line number Diff line change
Expand Up @@ -230,7 +230,7 @@ def uninstall_template(project: c.Project, query: c.BaseTemplate, remove_user: b
@default_options
def new_project(ctx: click.Context, path: str, target: str, version: str,
force_user: bool = False, force_system: bool = False,
no_default_libs: bool = False, compile_after: bool = True, build_cache: bool = None, **kwargs):
no_default_libs: bool = False, compile_after: bool = True, build_cache: bool = None, beta: bool = False, **kwargs):
"""
Create a new PROS project
Expand Down
16 changes: 9 additions & 7 deletions pros/ga/analytics.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
from os import path
from configparser import ConfigParser
import sys
import uuid
import time
from requests_futures.sessions import FuturesSession
import random
from concurrent.futures import as_completed
from pros.common.utils import get_version

agent = 'pros-cli'

Expand Down Expand Up @@ -60,22 +60,24 @@ def __init__(self):
self.pendingRequests = []

def send(self, action, kw={}):
#Send analytics to GA
# Send analytics to GA
if not self.useAnalytics or self.sent:
#print("not sending")
return
self.sent=True # Prevent Send from being called multiple times

self.sent = True # Prevent Send from being called multiple times
try:
#copy kw to prevent modifying the original
# Copy kw to prevent modifying the original
kwargs = kw.copy()
kwargs["engagement_time_msec"] = 1
kwargs["cli_version"] = get_version()
kwargs["platform"] = sys.platform

for key, val in kwargs.items():
# checking for required value
if val is None:
kwargs[key] = "Unspecified_Default"
key = config['analytics']['api_key']
url = f'https://www.google-analytics.com/mp/collect?measurement_id=G-PXK9EBVY1Y&api_secret={key}'
url = f'https://www.google-analytics.com/mp/collect?measurement_id=G-PXK9EBVY1Y&api_secret=DRDnqpaeTSebT7BsuGk_oA'
payload = {
"client_id": f'CLI.{self.user_timestamp}',
"user_id": self.uID,
Expand Down

0 comments on commit c3f1b3c

Please sign in to comment.