vinceanalytics / vince

vince is a High Performance , API only , distributed, in-memory alternative to Google Analytics
https://www.vinceanalytics.com/
Apache License 2.0
86 stars 3 forks source link

Events planned? #9

Open Ziedelth opened 1 month ago

Ziedelth commented 1 month ago

Hi, it's me again! It's more of a question than a problem.

My goal is to develop a mobile application, which I've already started developing, that's similar to my website, but with a few different features. But I'd also like to be able to track users on it with events or whatever to find out which features are being used.

I know that Google Analytics or Firebase Analytics already allow you to do this, but is it planned with Vince? That could be cool, because it could make it possible to have a single piece of software for tracking users. Plus, it might be cool to be able to extend it to a website.

gernest commented 1 month ago

@Ziedelth I think you can send events directly to vince via /api/v1/event . The event is the same json payload that vince client sends.

The only required fields are n for event name u for url d for domain. Which you can design based on your needs.

Ziedelth commented 1 month ago

And how can I retrieve the custom events sent?

gernest commented 1 month ago

And how can I retrieve the custom events sent?

I don't understand the question. From vince point of view, setting n="pageview" or n="cusom_name" is not so different. you can do all api calls as usual, you can filter by event="custom_name" breakdown by event ...etc.

Ziedelth commented 1 month ago

Sorry, that came out wrong. For sending custom events, if I understand correctly, I have to POST https://vince.shikkanime.fr/api/v1/event {"n": "custom_event", "u": "myUrl", "d": "shikkanime.fr"} and for "u" I can send the name of the mobile view page? For example "calendar".

And to see if the event has been sent, can I make a few requests on the "admin" side (request requiring the token, e.g. stats/timeseries)?

Also, on the other hand, how are unique visitors calculated? Because currently, with my application, when I make a web request, I have the same User-Agent for different devices. Will I need to change the User-Agent to something more unique?

gernest commented 1 month ago

And to see if the event has been sent, can I make a few requests on the "admin" side (request requiring the token, e.g. stats/timeseries)?

Yes, I think maybe try breakdown with property=event then you should see stats regarding the events you care about. You aslo know we have events metrics right? Which just counts the events.

Also, on the other hand, how are unique visitors calculated?

A hash of ip address, which you can set via ip=xxx , user agent via ua=xxx , domain via d=xxx and host of the uriyou send via u=xxx

You have many options on how to make events unique by designing around the fields I mentioned above.

gernest commented 1 month ago

@Ziedelth was my advice helpful?

Ziedelth commented 1 month ago

Hi, sorry I haven't had a chance to test, and being out of town, I can only test next week.

Ziedelth commented 1 month ago

Hi, sorry for the delay, but I'm back! I tested what we said above, but I have a 401 error, am I missing any info? image

gernest commented 1 month ago

401 means you didn't set auth header. All api calls need to be authorised like you have always done when querying stats.

Ziedelth commented 1 month ago

But the web request from Javscript does not require it? No?

gernest commented 1 month ago

But the web request from Javscript does not require it? No?

Yep, but it sends the request on a different endpoint /api/event , for your request you are hitting /api/v1/event anything on /api/v1/ prefix requires auth.

Ziedelth commented 1 month ago

I always get a 401 error, even with my token filled in.

gernest commented 1 month ago

care to share debug text representation of the full request here (please not the screenshot).

Ziedelth commented 1 month ago
curl -v --location 'https://vince.shikkanime.fr/api/v1/event' --header 'Content-Type: application/json' --header 'Authorization: Bearer xxx' --data '{
    "n": "custom_event",
    "u": "/homePage",
    "d": "example.com"
}'
*   Trying 88.169.137.150:443...
* Connected to vince.shikkanime.fr (88.169.137.150) port 443 (#0)
* ALPN, offering h2
* ALPN, offering http/1.1
*  CAfile: /etc/ssl/certs/ca-certificates.crt
*  CApath: /etc/ssl/certs
* TLSv1.0 (OUT), TLS header, Certificate Status (22):
* TLSv1.3 (OUT), TLS handshake, Client hello (1):
* TLSv1.2 (IN), TLS header, Certificate Status (22):
* TLSv1.3 (IN), TLS handshake, Server hello (2):
* TLSv1.2 (IN), TLS header, Finished (20):
* TLSv1.2 (IN), TLS header, Supplemental data (23):
* TLSv1.3 (IN), TLS handshake, Encrypted Extensions (8):
* TLSv1.2 (IN), TLS header, Supplemental data (23):
* TLSv1.3 (IN), TLS handshake, Certificate (11):
* TLSv1.2 (IN), TLS header, Supplemental data (23):
* TLSv1.3 (IN), TLS handshake, CERT verify (15):
* TLSv1.2 (IN), TLS header, Supplemental data (23):
* TLSv1.3 (IN), TLS handshake, Finished (20):
* TLSv1.2 (OUT), TLS header, Finished (20):
* TLSv1.3 (OUT), TLS change cipher, Change cipher spec (1):
* TLSv1.2 (OUT), TLS header, Supplemental data (23):
* TLSv1.3 (OUT), TLS handshake, Finished (20):
* SSL connection using TLSv1.3 / TLS_AES_256_GCM_SHA384
* ALPN, server accepted to use http/1.1
* Server certificate:
*  subject: CN=vince.shikkanime.fr
*  start date: May 15 00:55:32 2024 GMT
*  expire date: Aug 13 00:55:31 2024 GMT
*  subjectAltName: host "vince.shikkanime.fr" matched cert's "vince.shikkanime.fr"
*  issuer: C=US; O=Let's Encrypt; CN=R3
*  SSL certificate verify ok.
* TLSv1.2 (OUT), TLS header, Supplemental data (23):
> POST /api/v1/event HTTP/1.1
> Host: vince.shikkanime.fr
> User-Agent: curl/7.81.0
> Accept: */*
> Content-Type: application/json
> Authorization: Bearer xxx
> Content-Length: 73
> 
* TLSv1.2 (IN), TLS header, Supplemental data (23):
* TLSv1.3 (IN), TLS handshake, Newsession Ticket (4):
* TLSv1.2 (IN), TLS header, Supplemental data (23):
* TLSv1.3 (IN), TLS handshake, Newsession Ticket (4):
* old SSL session ID is stale, removing
* TLSv1.2 (IN), TLS header, Supplemental data (23):
* Mark bundle as not supporting multiuse
< HTTP/1.1 401 Unauthorized
< Date: Thu, 16 May 2024 12:43:35 GMT
< Server: Apache
< Access-Control-Allow-Credentials: true
< Access-Control-Allow-Headers: Content-Type, Authorization
< Access-Control-Allow-Methods: OPTIONS, GET, POST
< X-Vince-Version: v0.0.67
< Content-Length: 0
< 
* Connection #0 to host vince.shikkanime.fr left intact