Skip to content

Commit

Permalink
6.0.0
Browse files Browse the repository at this point in the history
  • Loading branch information
piano-analytics committed Apr 19, 2022
1 parent ee57689 commit 778f317
Show file tree
Hide file tree
Showing 62 changed files with 10,903 additions and 0 deletions.
4 changes: 4 additions & 0 deletions .cc-metadata.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# Whether this GitHub repo is for a CC-led engineering project
engineering_project: true
# Whether this repository should be featured on the CC Open Source site's "Projects" page
featured: false
5 changes: 5 additions & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# Auto detect text files and perform LF normalization
* text=auto

# JS files must always use LF for tools to work
*.js eol=lf
19 changes: 19 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
.project
.settings
.idea
*~
*.diff
*.patch
/*.html
.DS_Store
yarn.lock
package-lock.json
npm-debug.log*

# Ignore everything in dist folder except for eslint config
/dist/*
!/dist/.eslintrc.json
/amd
/node_modules
/test/data/core/jquery-iterability-transpiled.js
/test/data/qunit-fixture.js
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
# Changelog

## 6.0.0

### Added or Changed
- releasing to github
12 changes: 12 additions & 0 deletions CODE_OF_CONDUCT.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# Contributor Code of Conduct

The Creative Commons team is committed to fostering a welcoming community. This
project and all other Creative Commons open source projects are governed by our
[Code of Conduct][code_of_conduct]. Please report unacceptable behavior to
[[email protected]](mailto:[email protected]) per our
[reporting guidelines][reporting_guide].



[code_of_conduct]:https://opensource.creativecommons.org/community/code-of-conduct/
[reporting_guide]:https://opensource.creativecommons.org/community/code-of-conduct/enforcement/
9 changes: 9 additions & 0 deletions Gruntfile.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
"use strict";

module.exports = function( grunt ) {


// Load grunt tasks from NPM packages
require( "load-grunt-tasks" )( grunt );

};
21 changes: 21 additions & 0 deletions LICENSE.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
MIT License

Copyright (c) 2022 Creative Commons

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
150 changes: 150 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,150 @@
<div id="top"></div>

<br />
<div align="center">
<h1 align="center">Piano Analytics SDK JavaScript</h1>

</div>

<!-- ABOUT THE PROJECT -->
## About The Project


The Piano Analytics Javascript SDK allows you to collect audience measurement data for the [Piano Analytics](https://piano.io/product/analytics/) solution.
It works on all javascript environments dedicated to browsers (mostly websites).

This SDK makes the implementation of Piano Analytics as simple as possible, while keeping all the flexibility of the solution. By loading this small library on your platform, and using [dedicated and documented methods](https://developers.atinternet-solutions.com/piano-analytics/), you will be able to send powerful events.

It also includes [Privacy tagging methods](https://developers.atinternet-solutions.com/piano-analytics/data-collection/privacy) that allow you a perfect management of your tagging depending on the regulation you refer to.


<!-- GETTING STARTED -->
## Getting Started

- Install our library on your project (see below), you have two possibilities :
- Using directly the GitHub project to generate a file you will have to host
- Using our CDN
- Check the <a href="https://developers.atinternet-solutions.com/piano-analytics/"><strong>documentation</strong></a> for an overview of the functionalities and code examples

### Installation
Note that you can generate a file within your site with your site and collect domain already configured, which is not possible using our global CDN
#### Using GitHub
1. Clone the repo
```sh
git clone https://github.com/at-internet/piano-analytics-js
```
2. Install NPM packages
```sh
npm install
```
_Use the `--legacy-peer-deps` flag if you got peer dependencies errors from a recent npm version_
3. Enter your site and collect domain in `src/config.js` (optionnal if you want to do it in your implementation)
```js
'site': 123456,
'collectDomain': 'https://logsx.xiti.com',
```
4. Build the file
```sh
npm run build
```
_For the moment, a warning may appear saying `Creating a browser bundle that depends on "https"`. You may ignore this warning as the code using this dependency is excluded from the file generated for the browser bundle_
5. Get `piano-analytics.js` in `/dist/browser/`
6. Load it and send events
```html
<head>
<script src="https://my.website.com/piano-analytics.js"></script>
</head>
<body>
<script type="text/javascript">
pa.sendEvent('page.display', // Event name
{
'page': 'page name', // Event properties
'page_chapter1': 'chapter 1' ,
'page_chapter2': 'chapter 2' ,
'page_chapter3': 'chapter 3'
}
);
</script>
</body>
```
#### Using the CDN

1. Load the file from our CDN and configure your site and collect domain
```html
<head>
<script src="https://tag.aticdn.net/piano-analytics.js"></script>
<script type="text/javascript">
pa.setConfigurations({
site:123456,
collectDomain:'https://logsx.xiti.com'
});
</script>
</head>
```
2. Send events
```html
<body>
<script type="text/javascript">
pa.sendEvent('page.display', // Event name
{
'page': 'page name', // Event properties
'page_chapter1': 'chapter 1' ,
'page_chapter2': 'chapter 2' ,
'page_chapter3': 'chapter 3'
}
);
</script>
</body>
```

<p align="right">(<a href="#top">back to top</a>)</p>



<!-- USAGE EXAMPLES -->
## Usage

_For more examples, please refer to the [Documentation](https://developers.atinternet-solutions.com/piano-analytics/)_

<p align="right">(<a href="#top">back to top</a>)</p>

<!-- DEBUGGING -->
## Debugging

If you think there is a bug and are in a development environment, you can build the SDK without it being uglified using the following npm script
```sh
npm run rollup:browser
```
Also, quoting code using this will help us understand your issue
<p align="right">(<a href="#top">back to top</a>)</p>



<!-- CONTRIBUTING -->
## Contributing

Please do not hesitate to contribute by using this github project, we will look at any merge request or issue.
Note that we will always close merge request when accepting (or refusing) it as any modification has to be done from our side exclusively (so we will be the ones to implement your merge request if we consider it useful).
Also, it is possible that issues and requests from GitHub may take longer for us to process as we have dedicated support tools for our customers. So we suggest that you use GitHub tools for technical purposes only :)



<!-- LICENSE -->
## License

Distributed under the MIT License.

<p align="right">(<a href="#top">back to top</a>)</p>

<!-- CONTACT -->
## Contact

AtInternet a Piano Company - [email protected]

<p align="right">(<a href="#top">back to top</a>)</p>






6 changes: 6 additions & 0 deletions babel.config.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"presets": [
"@babel/preset-env"
],
"plugins": []
}
32 changes: 32 additions & 0 deletions karma.conf.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
process.env.CHROME_BIN = require('puppeteer').executablePath();
module.exports = function (config) {
config.set({
basePath: '',
browserDisconnectTimeout: 5000,
frameworks: ['mocha', 'chai'],
plugins: [
'karma-*'
],
client: {
mocha: {
timeout: 5000,
}
},
files: [
'dist/browser/piano-analytics.js',
'test/utils.js',
'test/shared/*.js',
'test/browser/*.js'
],
exclude: [
'*_bak_*'
],
colors: true,
logLevel: config.LOG_ERROR,
autoWatch: true,
browsers: ['ChromeHeadless'],
captureTimeout: 60000,
processKillTimeout: 4000,
singleRun: true
});
};
58 changes: 58 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
{
"name": "piano-analytics-js",
"description": "JavaScript library for Piano Analytics",
"version": "6.0.0",
"main": "dist/universal/piano-analytics.js",
"license": "MIT",
"author": {
"name": "Atinternet A Piano Company",
"email": "[email protected]"
},
"repository": {
"type": "git",
"url": "https://github.com/at-internet/piano-analytics-js"
},
"keywords": [
"piano",
"atinternet",
"analytics"
],
"scripts": {
"rollup": "rollup -c && rollup --config rollup.config-universal.js",
"rollup:browser": "rollup -c",
"rollup:universal": "rollup --config rollup.config-universal.js",
"build": "npm run rollup:browser --prod && npm run rollup:universal --prod",
"test": "npm run test:browser && npm run test:universal",
"test:browser": "npm run rollup:browser && karma start",
"test:universal": "npm run rollup:universal && node ./test/universal.run.js"
},
"devDependencies": {
"@babel/core": "7.17.9",
"@babel/preset-env": "7.16.11",
"@rollup/plugin-babel": "5.3.1",
"@rollup/plugin-node-resolve": "13.2.0",
"chai": "4.3.6",
"eslint": "8.13.0",
"eslint-config-standard": "16.0.3",
"eslint-plugin-import": "2.26.0",
"eslint-plugin-node": "11.1.0",
"eslint-plugin-promise": "6.0.0",
"grunt": "1.5.2",
"grunt-babel": "8.0.0",
"grunt-cli": "1.4.3",
"grunt-eslint": "24.0.0",
"grunt-karma": "4.0.2",
"karma": "6.3.18",
"karma-chai": "0.1.0",
"karma-chrome-launcher": "3.1.1",
"karma-mocha": "2.0.1",
"load-grunt-tasks": "5.1.0",
"mocha": "9.2.2",
"puppeteer": "13.5.2",
"rimraf": "3.0.2",
"rollup": "2.70.2",
"rollup-plugin-eslint": "7.0.0",
"rollup-plugin-replace": "2.2.0",
"rollup-plugin-uglify": "6.0.4"
}
}
26 changes: 26 additions & 0 deletions rollup.config-universal.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
import {babel} from '@rollup/plugin-babel';
import {eslint} from 'rollup-plugin-eslint';
import {uglify} from 'rollup-plugin-uglify';
import replace from 'rollup-plugin-replace';

export default {
input: 'src/core/PianoAnalytics.js',
plugins: [
eslint({
configFile: './src/.eslintrc.json'
}),
replace({
BUILD_BROWSER: 'false'
}),
babel({babelHelpers: 'bundled'}),
process.env.NODE_ENV === 'production' && uglify()
],
output: [
{
file: 'dist/universal/piano-analytics.js',
format: 'cjs',
exports: 'auto'
}
],
external: ['https']
};
25 changes: 25 additions & 0 deletions rollup.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
import {babel} from '@rollup/plugin-babel';
import {eslint} from 'rollup-plugin-eslint';
import {uglify} from 'rollup-plugin-uglify';
import replace from 'rollup-plugin-replace';

export default {
input: 'src/exports.js',
plugins: [
eslint({
configFile: './src/.eslintrc.json'
}),
replace({
BUILD_BROWSER: 'true'
}),
babel({babelHelpers: 'bundled'}),
process.env.NODE_ENV === 'production' && uglify()
],
output: [
{
file: 'dist/browser/piano-analytics.js',
format: 'iife'
}
],
external: ['https']
};
Loading

0 comments on commit 778f317

Please sign in to comment.