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

Js lib getting #3

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open

Js lib getting #3

wants to merge 2 commits into from

Conversation

hypesystem
Copy link
Contributor

This adds an endpoint /lib/:projectId/openlytics.js which exposes a javascript script.

If the script is included in a page as <script src="{{ openlyticsUrl }}/lib/:projectId/openlytics.js"></script>, it registers an object openlytics with a single method pageview(), which sends off a pageview.

Eg., this code could be included on a client page:

<script src="https://myopenlytics.example.com/lib/my-project/openlytics.js"></script>
<script>
openlytics.pageview();
</script>

The script automatically gets the right URL (although I didn't know how to guess http/https for now) for openlytics, and includes the project ID in the script. This gives us a much neater JS interface than Google Analytics on the client side 😄

cc @Arth101 because this might interest you.

@hypesystem hypesystem requested a review from ath88 September 28, 2017 08:44
@hypesystem
Copy link
Contributor Author

I have realized that we can do somewhat better than this.

No need for userId in frontend. We will always be sending user agent and IP anyway. So let's hash those as a userId upon reception, together with the source host and forget them. (Save only the hash.)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant