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