|
| 1 | +[](https://github.com/freenalytics/freenalytics-connector-web) |
| 2 | +[](https://github.com/freenalytics/freenalytics-connector-web) |
| 3 | +[](https://github.com/freenalytics/freenalytics-connector-web) |
| 4 | +[](https://github.com/freenalytics/freenalytics-connector-web) |
| 5 | +[](https://github.com/freenalytics/freenalytics-connector-web) |
| 6 | + |
| 7 | +# freenalytics-connector-web |
| 8 | + |
| 9 | +A connector library for applications that use the official Web template. |
| 10 | + |
| 11 | +## Setting-up Your Application |
| 12 | + |
| 13 | +In order to use this connector library, you should use the Official Web Template when creating your application. |
| 14 | + |
| 15 | +This library will follow the following schema: |
| 16 | + |
| 17 | +```yml |
| 18 | +type: object |
| 19 | +properties: |
| 20 | + page_title: |
| 21 | + type: string |
| 22 | + url_route: |
| 23 | + type: string |
| 24 | + user_time_in_page: |
| 25 | + type: number |
| 26 | + user_scrolled: |
| 27 | + type: boolean |
| 28 | + user_first_visit: |
| 29 | + type: boolean |
| 30 | + user_location: |
| 31 | + type: string |
| 32 | + referrer: |
| 33 | + type: string |
| 34 | + num_of_clicks: |
| 35 | + type: integer |
| 36 | + element_clicked: |
| 37 | + type: object |
| 38 | + properties: |
| 39 | + url_route: |
| 40 | + type: string |
| 41 | + tag_name: |
| 42 | + type: string |
| 43 | + class_name: |
| 44 | + type: string |
| 45 | + id: |
| 46 | + type: string |
| 47 | + page_x: |
| 48 | + type: integer |
| 49 | + page_y: |
| 50 | + type: integer |
| 51 | + client_x: |
| 52 | + type: integer |
| 53 | + client_y: |
| 54 | + type: integer |
| 55 | +``` |
| 56 | +
|
| 57 | +## Usage |
| 58 | +
|
| 59 | +In order to integrate this library with your webpage, add the following tags inside your `head` tag in your `html` pages: |
| 60 | + |
| 61 | +```html |
| 62 | +<script type="text/javascript" src="https://cdn.jsdelivr.net/gh/freenalytics/[email protected]/connector.min.js"></script> |
| 63 | +<script type="text/javascript" src="/script.js"></script> |
| 64 | +``` |
| 65 | + |
| 66 | +Notice that the second `script` tag points to a local script named `script.js`. |
| 67 | + |
| 68 | +In this case, you need to instantiate the client with your information. An example of what this `script.js` file could look like: |
| 69 | + |
| 70 | +```js |
| 71 | +const client = new freenalytics.Client({ |
| 72 | + apiUrl: 'http://localhost:4000/api', |
| 73 | + domain: 'FD-107hpu34tlb7s7mro' |
| 74 | +}); |
| 75 | +client.initialize(); |
| 76 | +``` |
| 77 | + |
| 78 | +Once you have that set up, the client will automatically send relevant data periodically. |
| 79 | + |
| 80 | +Check out the [web example](https://github.com/freenalytics/example-web) repository for a better view on how to set this up on your |
| 81 | +own project. |
| 82 | + |
| 83 | +## Development |
| 84 | + |
| 85 | +In order to develop this library, clone the repository: |
| 86 | + |
| 87 | +```text |
| 88 | +git clone https://github.com/freenalytics/freenalytics-connector-web |
| 89 | +``` |
| 90 | + |
| 91 | +And install the dependencies: |
| 92 | + |
| 93 | +```text |
| 94 | +npm install |
| 95 | +``` |
| 96 | + |
| 97 | +You can start the bundler in watch mode with: |
| 98 | + |
| 99 | +```text |
| 100 | +npm run build:watch |
| 101 | +``` |
| 102 | + |
| 103 | +And start an HTTP server to serve the bundle locally with: |
| 104 | + |
| 105 | +```text |
| 106 | +npm run dev:serve |
| 107 | +``` |
| 108 | + |
| 109 | +Make sure to check that the linting is correct with: |
| 110 | + |
| 111 | +```text |
| 112 | +npm run lint |
| 113 | +``` |
| 114 | + |
| 115 | +And that the tests run successfully: |
| 116 | + |
| 117 | +```text |
| 118 | +npm run test |
| 119 | +``` |
| 120 | + |
| 121 | +## Author |
| 122 | + |
| 123 | +This application was made by [Freenalytics](https://github.com/freenalytics) as a final college project. |
0 commit comments