Skip to content

Commit

Permalink
Opt-in for telemetry
Browse files Browse the repository at this point in the history
  • Loading branch information
sergeche committed Jul 14, 2020
1 parent 84b0e20 commit 0f0ed79
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 4 deletions.
4 changes: 0 additions & 4 deletions config.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,6 @@ def get_settings(key: str, default=None):

if settings is None:
settings = sublime.load_settings('Emmet.sublime-settings')
if not settings.get('uid'):
uid = str(uuid.uuid4())
settings.set('uid', uid)
sublime.save_settings('Emmet.sublime-settings')
settings.add_on_change('config', handle_settings_change)

return settings.get(key, default)
Expand Down
33 changes: 33 additions & 0 deletions telemetry.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import uuid
import urllib
import sublime
from .config import get_settings
Expand Down Expand Up @@ -94,3 +95,35 @@ def _flush_queue():
if queue:
# print('schedule next request')
schedule_send()


def check_telemetry():
settings = sublime.load_settings('Emmet.sublime-settings')
updated = False
if not settings.get('uid'):
uid = str(uuid.uuid4())
settings.set('uid', uid)
updated = True

if settings.get('telemetry', None) is None:
allow_telemetry = ask_for_telemetry()
settings.set('telemetry', bool(allow_telemetry))
updated = True

if updated:
sublime.save_settings('Emmet.sublime-settings')


def ask_for_telemetry():
return sublime.ok_cancel_dialog(
"""
Would you like to enable anonymous usage stats for Emmet?
It will help me better understand how Emmet is used and prioritize future improvements.
You can enable/disable telemetry later via Preferences > Package Settings > Emmet2 > Settings
""", 'Yes, enable telemetry')


def plugin_loaded():
check_telemetry()

0 comments on commit 0f0ed79

Please sign in to comment.