Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Various Fixes and Improvements for Analytics #51

Merged
merged 14 commits into from
Feb 20, 2024
37 changes: 37 additions & 0 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
name: "Tests"

on: [pull_request]
jobs:
test:
name: Unit Tests
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
services:
[
Plausible,
HubSpot,
Orbit
]

steps:
- name: Checkout repository
uses: actions/checkout@v3
with:
fetch-depth: 2

- run: git checkout HEAD^2

- name: Add Environment Variables
run: |
echo "PA_APIKEY=${{ secrets.PA_APIKEY }}" > .env
echo "PA_DOMAIN=${{ secrets.PA_DOMAIN }}" >> .env
echo "HS_APIKEY=${{ secrets.HS_APIKEY }}" >> .env
echo "OR_APIKEY=${{ secrets.OR_APIKEY }}" >> .env
echo "OR_WORKSPACEID=${{ secrets.OR_WORKSPACEID }}" >> .env

- name: Run ${{matrix.services}} Tests
run: |
docker run --env-file .env --rm -v $PWD:/app composer sh -c \
"composer install --ignore-platform-reqs && ./vendor/bin/phpunit --configuration phpunit.xml --filter ${{matrix.services}}"
13 changes: 0 additions & 13 deletions .travis.yml

This file was deleted.

29 changes: 3 additions & 26 deletions src/Analytics/Adapter.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
namespace Utopia\Analytics;

use Exception;
use Utopia\CLI\Console;

abstract class Adapter
{
Expand Down Expand Up @@ -72,7 +71,7 @@ abstract public function validate(Event $event): bool;
/**
* Sets the client IP address.
*
* @param string $clientIP The IP address to use.
* @param string $clientIP The IP address to use.
*/
public function setClientIP(string $clientIP): self
{
Expand All @@ -84,7 +83,7 @@ public function setClientIP(string $clientIP): self
/**
* Sets the client user agent.
*
* @param string $userAgent The user agent to use.
* @param string $userAgent The user agent to use.
*/
public function setUserAgent(string $userAgent): self
{
Expand All @@ -98,13 +97,7 @@ public function setUserAgent(string $userAgent): self
*/
public function createEvent(Event $event): bool
{
try {
return $this->send($event);
} catch (\Exception $e) {
$this->logError($e);

return false;
}
return $this->send($event);
eldadfux marked this conversation as resolved.
Show resolved Hide resolved
}

/**
Expand Down Expand Up @@ -212,20 +205,4 @@ protected function flatten(array $data, string $prefix = ''): array

return $output;
}

/**
* Log Error
*
* @return void
*/
protected function logError(Exception $e)
{
Console::error('[Error] '.$this->getName().' Error: ');
Console::error('[Error] Type: '.get_class($e));
Console::error('[Error] Message: '.$e->getMessage());
Console::error('[Error] File: '.$e->getFile());
Console::error('[Error] Line: '.$e->getLine());
Console::error('[Error] Trace: ');
Console::error($e->getTraceAsString());
}
}
2 changes: 1 addition & 1 deletion src/Analytics/Adapter/GoogleAnalytics.php
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ public function getName(): string

/**
* @param string $cid
* Adapter configuration
* Adapter configuration
* @return GoogleAnalytics
*/
public function __construct(string $tid, string $cid)
Expand Down
Loading
Loading