Skip to content
This repository has been archived by the owner on Nov 11, 2018. It is now read-only.

feat(counting): refactor the way counting works #5

Merged
merged 2 commits into from
May 6, 2014

Conversation

coderbyheart
Copy link
Member

The current implementation increases the number of visits for a domain if

  • the request is made by the base script from=outside
  • and it is the first time a user visits the domain firstvisit=true

This is not how we want to count visits to .HIV domains.

We want to count every visit to a .HIV domain within a configurable threshold between consecutive visits.

As we are currently not storing user state in the backend we require clients (the banners) to send information about recurring users. In order to be flexible about the threshold and adapt our counting backend in the feature without needing to change the request the following changes have been made to the request:

  • clients MUST send the timestamp of the visit in the parameter ct, e.g. ct=1397341234000
  • clients SHOULD send the timestamp of the previous visit in the parameter pt, e.g. ct=1397340001000. If it cannot be determined they must send an empty value: pt=. Clients should use cookies with a lifetime of 30 days to track the last visit.

For simplicity timestamps are expressed as integers (unix timestamps in microseconds) in the users timezone.

If the previous timestamp is present, we calculate the diff in seconds and if it is greater than the configured threashhold, we count a click. If the previous timestamp is not present we count a click.

The new format makes request parameters absolut thus enabling us in the future to drop already applied request or enable throttling mechanisms based on the time.

The current implementation increases the number of visits for a domain if
- the request is made by the base script `from=outside`
- and it is the first time a user visits the domain `firstvisit=true`

This is **not** how we want to count visits to .HIV domains.

We want to count **every** visit to a .HIV domain within a configurable threshold between consecutive visits.

As we are currently not storing user state in the backend we require clients (the banners) to send information about recurring users. In order to be flexible about the threshold and adapt our counting backend in the feature without needing to change the request the following changes have been made to the request:
- clients **MUST** send the timestamp of the visit in the parameter `ct`, e.g. `ct=1397341234000`
- clients **SHOULD** send the timestamp of the previous visit in the parameter `pt`, e.g. `ct=1397340001000`. If it cannot be determined they must send an empty value: `pt=`. Clients should use cookies with a lifetime of 30 days to track the last visit.

For simplicity timestamps are expressed as integers (unix timestamps in **microseconds**) in the users timezone.

If the previous timestamp *is present*, we calculate the diff in seconds and if it is greater than the configured threashhold, we count a click. If the previous timestamp *is not present* we count a click.

The new format makes request parameters absolut thus enabling us in the future to drop already applied request or enable throttling mechanisms based on the time.
@coderbyheart coderbyheart self-assigned this May 6, 2014
@coderbyheart
Copy link
Member Author

@peterthomassen @nils-wisiol fyi, this is a refactoring of the backend counting code.

coderbyheart added a commit that referenced this pull request May 6, 2014
feat(counting): refactor the way counting works
@coderbyheart coderbyheart merged commit 2963497 into master May 6, 2014
@coderbyheart coderbyheart deleted the rewrite-counting branch May 6, 2014 21:48
coderbyheart added a commit to dothiv/clickcounter that referenced this pull request May 6, 2014
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
1 participant