From e23828777fca2a38bc0552aa485f08106cba4e18 Mon Sep 17 00:00:00 2001 From: Torsten Dittmann Date: Thu, 4 Feb 2021 10:26:58 +0100 Subject: [PATCH] add client id to analytics --- app/tasks/install.php | 30 +++++++++++++++++++++++------- composer.lock | 12 ++++++------ 2 files changed, 29 insertions(+), 13 deletions(-) diff --git a/app/tasks/install.php b/app/tasks/install.php index bc262937c..ac7e45cfc 100644 --- a/app/tasks/install.php +++ b/app/tasks/install.php @@ -29,13 +29,23 @@ $cli * 5. Run docker-compose up -d - DONE * 6. Run data migration */ - $analytics = new GoogleAnalytics('UA-26264668-9', uniqid('installation')); + $config = Config::getParam('variables'); $path = '/usr/src/code/appwrite'; $defaultHTTPPort = '80'; $defaultHTTPSPort = '443'; $vars = []; + /** + * Generates an anonymous hash value based on following informations: + * - Host's machine name + * - Host's local IP adress + * + * This value allows us to collect information without invading the privacy of our users. + */ + $cid = GoogleAnalytics::getUniqueByHostname(); + $analytics = new GoogleAnalytics('UA-26264668-9', $cid); + foreach($config as $category) { foreach($category['variables'] ?? [] as $var) { $vars[] = $var; @@ -138,12 +148,16 @@ $cli ; if(!file_put_contents($path.'/docker-compose.yml', $templateForCompose->render(false))) { - Console::error('Failed to save Docker Compose file'); + $message = 'Failed to save Docker Compose file'; + $analytics->createEvent('install/server', 'install', APP_VERSION_STABLE.' - '.$message, 0); + Console::error($message); Console::exit(1); } if(!file_put_contents($path.'/.env', $templateForEnv->render(false))) { - Console::error('Failed to save environment variables file'); + $message = 'Failed to save environment variables file'; + $analytics->createEvent('install/server', 'install', APP_VERSION_STABLE.' - '.$message, 0); + Console::error($message); Console::exit(1); } @@ -162,12 +176,14 @@ $cli $exit = Console::execute("${env} docker-compose -f {$path}/docker-compose.yml up -d --remove-orphans --renew-anon-volumes", '', $stdout, $stderr); if ($exit !== 0) { - Console::error('Failed to install Appwrite dockers'); + $message = 'Failed to install Appwrite dockers'; + $analytics->createEvent('install/server', 'install', APP_VERSION_STABLE.' - '.$message, 0); + Console::error($message); Console::error($stderr); Console::exit($exit); - $analytics->createEvent('install/server', 'install', APP_VERSION_STABLE.' Install Server failed'); } else { - Console::success('Appwrite installed successfully'); - $analytics->createEvent('install/server', 'install', APP_VERSION_STABLE.' Install Server successfully'); + $message = 'Appwrite installed successfully'; + $analytics->createEvent('install/server', 'install', APP_VERSION_STABLE.' - '.$message, 1); + Console::success($message); } }); \ No newline at end of file diff --git a/composer.lock b/composer.lock index 2b4a9b11d..4da0e3a87 100644 --- a/composer.lock +++ b/composer.lock @@ -1229,16 +1229,16 @@ }, { "name": "utopia-php/analytics", - "version": "0.1.0", + "version": "0.1.1", "source": { "type": "git", "url": "https://github.com/utopia-php/analytics.git", - "reference": "a1f2a1672a927bef8cd4d9b47e5cfbc856a3c72f" + "reference": "5e9ce43523b19ae71973567f219275f97bbec5d9" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/utopia-php/analytics/zipball/a1f2a1672a927bef8cd4d9b47e5cfbc856a3c72f", - "reference": "a1f2a1672a927bef8cd4d9b47e5cfbc856a3c72f", + "url": "https://api.github.com/repos/utopia-php/analytics/zipball/5e9ce43523b19ae71973567f219275f97bbec5d9", + "reference": "5e9ce43523b19ae71973567f219275f97bbec5d9", "shasum": "" }, "require": { @@ -1278,9 +1278,9 @@ ], "support": { "issues": "https://github.com/utopia-php/analytics/issues", - "source": "https://github.com/utopia-php/analytics/tree/0.1.0" + "source": "https://github.com/utopia-php/analytics/tree/0.1.1" }, - "time": "2021-02-03T17:07:09+00:00" + "time": "2021-02-04T09:14:43+00:00" }, { "name": "utopia-php/audit",