Skip to content

Commit

Permalink
Merge pull request #69 from QAInsights/feature/telemetry-lambda
Browse files Browse the repository at this point in the history
Update: Telemetry to AWS Lambda
  • Loading branch information
QAInsights authored Dec 9, 2023
2 parents 3a10220 + b04c7ae commit c383d55
Show file tree
Hide file tree
Showing 8 changed files with 25 additions and 19 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/release-workflow.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ jobs:

runs-on: ${{ matrix.os }}
env:
RELEASE_TAG: 0.2.0
RELEASE_TAG: 0.3.0
INTEL_DMG: Hamster-x86-64-intel.dmg
ARM64_DMG: Hamster-arm64-silicon.dmg
MIXPANEL_TOKEN: ${{ secrets.MIXPANEL_TOKEN }}
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ An app that puts your recent JMeter test plans just a click away from your Mac m
- No personal information or entities are collected.
- The data collected is not shared with any third-party.
- The data collected is not used for any marketing purposes.
- The data is being collected using [Mixpanel](https://mixpanel.com).
- The data is being collected using [Mixpanel](https://mixpanel.com) via AWS Lambda.
- You can opt out of telemetry by configuring `false` in `~/.hamster_app.properties` file and restart the app.
- ```commandline
[TELEMETRY]
Expand Down
4 changes: 2 additions & 2 deletions hamster/.hamster_app.properties
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[JMETER]
home = /Users/naveenkumar/Tools/apache-jmeter-5.6.1
home = /Users/naveenkumar/Tools/apache-jmeter-5.6.2

[TELEMETRY]
enabled = false
enabled = true
2 changes: 1 addition & 1 deletion hamster/__version__.py
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
__version_info__ = (0, 2, 0)
__version_info__ = (0, 3, 0)
__version__ = '.'.join(map(str, __version_info__))
7 changes: 3 additions & 4 deletions hamster/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,10 @@ def __init__(self):
self.authors = ['NaveenKumar Namachivayam', 'Leela Prasad Vadla']
self.about_website = 'https://QAInsights.com'
self.app_uuid = str(uuid.uuid4())
self.telemetry_url = 'https://dcx0r39ip3.execute-api.us-east-2.amazonaws.com/hamster-mixpanel'
self.log_dir = os.path.join(os.path.expanduser("~"), 'hamster_logs')

self.valid_events = ['Launch JMeter', 'Recent Test Plans', 'Edit JMETER_HOME', 'View Config', 'Restart',
'About', 'Refresh', 'Help']

@property
def authors_str(self):
Expand Down Expand Up @@ -90,6 +92,3 @@ def jmeter_path():
jmeter_home = jmeter_home.rstrip('/')
jmeter_bin = jmeter_home + '/bin/jmeter'
return jmeter_home, jmeter_bin



23 changes: 15 additions & 8 deletions hamster/menu.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import os
import webbrowser
import logging

import requests
from functools import wraps

import rumps
Expand All @@ -11,10 +11,6 @@
from config import jmeter_path, icon_path, properties_file_path, config_parser, jmeter_plist
from config import app_config, uuid

from mixpanel import Mixpanel

mp = Mixpanel(os.environ.get('MIXPANEL_TOKEN'))

# Create a logger
logger = logging.getLogger(__name__)

Expand All @@ -40,9 +36,20 @@ def decorator(func):
def wrapper(*args, **kwargs):
try:
if telemetry_enabled:
mp.track(ids, menu_item)
logger.info(f"Clicked {menu_item}")
return func(*args, **kwargs)
# Call AWS Lambda function
try:
if menu_item in app_config.valid_events:
requests.post(app_config.telemetry_url, json={
"uuid": ids,
"menu_item": menu_item
})

logger.info(f'Clicked {menu_item}')
return func(*args, **kwargs)

except Exception as e:
logger.error(e)

else:
logger.info(f"Telemetry is disabled. Not tracking {menu_item}")
return func(*args, **kwargs)
Expand Down
2 changes: 1 addition & 1 deletion windows/__init__.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
__VERSION__ = "0.2.0"
__VERSION__ = "0.3.0"
2 changes: 1 addition & 1 deletion windows/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ def __init__(self):
self.menu_items_dict = OrderedDict()

self.jmeter_recent_files_pattern = re.compile("recent_file_.*")
self.app_version = "0.1.0"
self.app_version = "0.3.0"
self.buy_me_a_coffee_url = 'https://www.buymeacoffee.com/QAInsights'
self.authors = ['NaveenKumar Namachivayam', 'Leela Prasad Vadla']
self.about_website = 'https://QAInsights.com'
Expand Down

0 comments on commit c383d55

Please sign in to comment.