Skip to content

Commit

Permalink
Remove Google Analytics support
Browse files Browse the repository at this point in the history
  • Loading branch information
tschoonj committed Dec 27, 2023
1 parent 5962228 commit 0fd25c9
Show file tree
Hide file tree
Showing 7 changed files with 7 additions and 255 deletions.
4 changes: 0 additions & 4 deletions .bumpversion.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,6 @@ replace = AC_INIT([xraylib],[{new_version}],[[email protected]])
search = VERSION {current_version}
replace = VERSION {new_version}

[bumpversion:file:java/GoogleAnalyticsThread.java]
search = GOOGLE_ANALYTICS_APPLICATION_VERSION = "{current_version}";
replace = GOOGLE_ANALYTICS_APPLICATION_VERSION = "{new_version}";

[bumpversion:file:java/build.gradle.in]
search = version = '{current_version}'
replace = version = '{new_version}'
Expand Down
6 changes: 6 additions & 0 deletions Changelog
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
Version 4.1.4 Tom Schoonjans

- Bug fix: return 0.0 early in `PM3_auger_cascade_kissel` and `PM4_auger_cascade_kissel` (reported and fixed by Chris Ninham)
- Bug fix: ensure that meson will error out when `python-numpy-bindings` is set to `enabled`, but `cython` is not found.
- Remove Google Analytics support as they have discontinued Universal Analytics

Version 4.1.3 Tom Schoonjans

- Fix bug in python meson build, resulting in numpy integers not being accepted by SWIG generated python bindings (reported by Christian Koernig)
Expand Down
82 changes: 0 additions & 82 deletions java/GoogleAnalyticsThread.java

This file was deleted.

3 changes: 1 addition & 2 deletions java/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,7 @@ java_source = \
compoundDataNIST.java \
radioNuclideData.java \
Crystal_Struct.java \
Crystal_Atom.java \
GoogleAnalyticsThread.java
Crystal_Atom.java

if ENABLE_JAVA

Expand Down
1 change: 0 additions & 1 deletion java/Xraylib.java
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,6 @@ public class Xraylib {

static {
try {
new GoogleAnalyticsThread().start();
XRayInit();
}
catch (Exception e){
Expand Down
85 changes: 0 additions & 85 deletions python/xraylib_np.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -12,97 +12,12 @@
cimport xraylib_np_c as xrl
import numpy as np
cimport numpy as np
cimport cython
from cython.parallel import prange
cimport cython.parallel

np.import_array()

__version__ = xrl.__version__.decode("utf-8")

import urllib
import os
import http.client
import uuid
from uuid import UUID
import platform
from pathlib import Path
import threading

def __valid_uuid(_uuid):
try:
a = UUID(_uuid)
except ValueError:
return False
return True

def __send_google_analytics_launch_event():
GOOGLE_ANALYTICS_ENDPOINT = "https://www.google-analytics.com/collect"
GOOGLE_ANALYTICS_TRACKING_ID = "UA-42595764-5"
GOOGLE_ANALYTICS_APPLICATION_NAME = "xraylib"
GOOGLE_ANALYTICS_APPLICATION_VERSION = __version__
GOOGLE_ANALYTICS_HIT_TYPE = "event"

payload = dict(
v=1, # protocol version
tid=GOOGLE_ANALYTICS_TRACKING_ID, # tracking id
t=GOOGLE_ANALYTICS_HIT_TYPE, # hit type
an=GOOGLE_ANALYTICS_APPLICATION_NAME, # app name
av=GOOGLE_ANALYTICS_APPLICATION_VERSION, # app version
)

if 'CI' in os.environ:
payload['cid'] = '60220817-0a15-49ce-b581-9cab2b225e7d' # our default UUID for CI
payload['ec'] = 'CI-python_np'
else:
if os.name == 'nt':
import winreg
with winreg.CreateKey(winreg.HKEY_CURRENT_USER, r'Software\xraylib\ga_conf') as _key:
try:
_uuid = winreg.QueryValueEx(_key, 'uuid')[0]
if not __valid_uuid(_uuid):
raise Exception("Invalid UUID")
except Exception as e:
_uuid = str(uuid.uuid4())
winreg.SetValueEx(_key, 'uuid', 0, winreg.REG_SZ, _uuid)
else:
try:
f = Path('~', '.config', 'xraylib', 'ga.conf').expanduser()
f.parent.mkdir(mode=0o700, parents=True, exist_ok=True)
if f.exists():
if f.is_file():
_uuid = f.read_text().strip()
if not __valid_uuid(_uuid):
_uuid = str(uuid.uuid4())
f.write_text(_uuid)
else:
return
else:
_uuid = str(uuid.uuid4())
f.write_text(_uuid)
except:
pass

payload['cid'] = _uuid
payload['ec'] = 'python_np'

payload['ea'] = 'import'
payload['el'] = 'xraylib-{}-Python-{}-{}'.format(__version__, platform.python_version(), platform.platform())
payload['ua'] = "Opera/9.80 (Windows NT 6.0) Presto/2.12.388 Version/12.14"

try:
data = urllib.parse.urlencode(payload).encode()
connection = http.client.HTTPSConnection('www.google-analytics.com', port=443, key_file=None, cert_file=None, timeout=1)
connection.request('POST', '/collect', data)
response = connection.getresponse()
except:
pass

threading.Thread(target=__send_google_analytics_launch_event).start()




XRAYLIB_MAJOR = xrl.XRAYLIB_MAJOR
XRAYLIB_MINOR = xrl.XRAYLIB_MINOR
AVOGNUM = xrl.AVOGNUM
Expand Down
81 changes: 0 additions & 81 deletions src/xraylib.i
Original file line number Diff line number Diff line change
Expand Up @@ -36,87 +36,6 @@ THIS SOFTWARE IS PROVIDED BY Bruno Golosio, Antonio Brunetti, Manuel Sanchez del
#ifdef SWIGPYTHON
%pythoncode {
__version__ = VERSION

import urllib
import os
import http.client
import uuid
from uuid import UUID
import platform
from pathlib import Path
import threading

def __valid_uuid(_uuid):
try:
a = UUID(_uuid)
except ValueError:
return False
return True

def __send_google_analytics_launch_event():
GOOGLE_ANALYTICS_ENDPOINT = "https://www.google-analytics.com/collect"
GOOGLE_ANALYTICS_TRACKING_ID = "UA-42595764-5"
GOOGLE_ANALYTICS_APPLICATION_NAME = "xraylib"
GOOGLE_ANALYTICS_APPLICATION_VERSION = __version__
GOOGLE_ANALYTICS_HIT_TYPE = "event"

payload = dict(
v=1, # protocol version
tid=GOOGLE_ANALYTICS_TRACKING_ID, # tracking id
t=GOOGLE_ANALYTICS_HIT_TYPE, # hit type
an=GOOGLE_ANALYTICS_APPLICATION_NAME, # app name
av=GOOGLE_ANALYTICS_APPLICATION_VERSION, # app version
)

if 'CI' in os.environ:
payload['cid'] = '60220817-0a15-49ce-b581-9cab2b225e7d' # our default UUID for CI
payload['ec'] = 'CI-python'
else:
if os.name == 'nt':
import winreg
with winreg.CreateKey(winreg.HKEY_CURRENT_USER, r'Software\xraylib\ga_conf') as _key:
try:
_uuid = winreg.QueryValueEx(_key, 'uuid')[0]
if not __valid_uuid(_uuid):
raise Exception("Invalid UUID")
except Exception as e:
_uuid = str(uuid.uuid4())
winreg.SetValueEx(_key, 'uuid', 0, winreg.REG_SZ, _uuid)
else:
try:
f = Path('~', '.config', 'xraylib', 'ga.conf').expanduser()
f.parent.mkdir(mode=0o700, parents=True, exist_ok=True)
if f.exists():
if f.is_file():
_uuid = f.read_text().strip()
if not __valid_uuid(_uuid):
_uuid = str(uuid.uuid4())
f.write_text(_uuid)
else:
return
else:
_uuid = str(uuid.uuid4())
f.write_text(_uuid)
except:
pass

payload['cid'] = _uuid
payload['ec'] = 'python'

payload['ea'] = 'import'
payload['el'] = 'xraylib-{}-Python-{}-{}'.format(__version__, platform.python_version(), platform.platform())
payload['ua'] = "Opera/9.80 (Windows NT 6.0) Presto/2.12.388 Version/12.14"

try:
data = urllib.parse.urlencode(payload).encode()
connection = http.client.HTTPSConnection('www.google-analytics.com', port=443, key_file=None, cert_file=None, timeout=1)
connection.request('POST', '/collect', data)
response = connection.getresponse()
except:
pass

threading.Thread(target=__send_google_analytics_launch_event).start()

}
#endif

Expand Down

0 comments on commit 0fd25c9

Please sign in to comment.