blob: 48e024790c99ef8185f4ce0a151eba66af085db2 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
|
## Introduction
The js/ folder contains:
* index.php - a servlet described below
* piwik.js - the uncompressed piwik.js source for you to study or reference
* README.md - this documentation file
### Why Use "js/index.php"?
* js/index.php (or implicitly as "js/") can be used to serve up the minified
piwik.js
* it supports conditional-GET and Last-Modified, so piwik.js can be cached
by the browser
* it supports deflate/gzip compression if your web server (e.g., Apache
without mod_deflate or mod_gzip), shrinking the data transfer to 8K
* js/index.php (or implicitly as "js/") can also act as a proxy to piwik.php
* If you are concerned about the impact of browser-based privacy filters which
attempt to block tracking, you can change your tracking code to use "js/"
instead of "piwik.js" and "piwik.php", respectively.
Note that in order for [Page Overlay](https://piwik.org/docs/page-overlay/) to work, the Piwik tracker method `setAPIUrl()` needs to be called with its parameter pointing to the root directory of Piwik. E.g.:
```js
_paq.push(['setAPIUrl', u]);
```
## Deployment
* piwik.js is minified using YUICompressor 2.4.7.
To install YUICompressor run:
```bash
$ cd /path/to/piwik/js/
$ wget https://github.com/downloads/yui/yuicompressor/yuicompressor-2.4.7.zip
$ unzip yuicompressor-2.4.7.zip
```
To compress the code containing the evil "eval", run:
```bash
$ cd /path/to/piwik/js/
$ sed '/<DEBUG>/,/<\/DEBUG>/d' < piwik.js | sed 's/eval/replacedEvilString/' | java -jar yuicompressor-2.4.7/build/yuicompressor-2.4.7.jar --type js --line-break 1000 | sed 's/replacedEvilString/eval/' | sed 's/^[/][*]/\/*!/' > piwik.min.js && cp piwik.min.js ../piwik.js
```
This will generate the minify /path/to/piwik/js/piwik.min.js and copy it to
/path/to/piwik/piwik.js. Both "js/piwik.min.js" and "piwik.js" need to be committed.
* In a production environment, the tests/javascript folder is not used and can
be removed (if present).
* We use /*! to include Piwik's license header in the minified source. Read
Stallman's "The JavaScript Trap" for more information.
* Information about the current version number you have installed can be found under [What version of Piwik do I have?](https://piwik.org/faq/how-to-update/faq_8/).
|