├── .gitignore
├── src
├── plugin
│ ├── qmldir
│ ├── abstractquerybuilder.cpp.autosave
│ ├── plugin.pri
│ ├── plugin.pro
│ ├── plugin.h
│ ├── plugin.cpp
│ ├── configutil.h
│ ├── matomobuilder.h
│ ├── googlebuilder.h
│ ├── hitbuilder.h
│ ├── context.h
│ ├── matomobuilder.cpp
│ ├── googlebuilder.cpp
│ ├── analytics.h
│ ├── hitbuilder.cpp
│ ├── configutil.cpp
│ ├── context.cpp
│ └── analytics.cpp
└── src.pro
├── tests
├── auto
│ ├── tst_config
│ │ ├── analytics.json
│ │ ├── tst_config.qrc
│ │ ├── tst_config.pro
│ │ └── tst_config.cpp
│ ├── auto.pro
│ ├── tst_google
│ │ ├── tst_google.pro
│ │ └── tst_google.cpp
│ ├── tst_matomo
│ │ ├── tst_matomo.pro
│ │ └── tst_matomo.cpp
│ ├── tst_analytics
│ │ ├── tst_analytics.pro
│ │ └── tst_analytics.cpp
│ └── tst_urlbuilder
│ │ ├── tst_urlbuilder.pro
│ │ └── tst_urlbuilder.cpp
└── tests.pro
├── examples
├── analytics_demo
│ ├── qtquickcontrols2.conf
│ ├── analytics.json
│ ├── qml.qrc
│ ├── analytics_demo.pro
│ ├── InfoPage.qml
│ ├── HomePage.qml
│ ├── main.cpp
│ ├── Main.qml
│ └── SubscriptionsPage.qml
└── examples.pro
├── .qmake.conf
├── README.md
├── qtanalytics.pro
├── doc
├── doc.pri
├── doc.pro
├── style
│ └── qt5-sidebar.html
├── qtanalytics.qdocconf
├── qtanalytics-online.qdocconf
├── qtanalytics-project.qdocconf
├── examples
│ └── analytics_demo.qdoc
├── qtanalytics-examples.qdoc
├── qtanalytics-installation.qdoc
├── index.qdoc
├── qtanalytics-group.qdoc
├── qtanalytics-usage.qdoc
└── qtanalytics-concepts.qdoc
├── server
├── docker-compose.yml
└── README.md
├── qtanalytics.pri
├── qmake-features
└── config-output.prf
├── tools
└── simple_http_server.sh
├── LICENSE.LGPL3
├── LICENSE.GPL2
└── LICENSE.GPL3
/.gitignore:
--------------------------------------------------------------------------------
1 | .vscode
2 |
--------------------------------------------------------------------------------
/src/plugin/qmldir:
--------------------------------------------------------------------------------
1 | module analytics
2 | plugin analytics
3 |
--------------------------------------------------------------------------------
/tests/auto/tst_config/analytics.json:
--------------------------------------------------------------------------------
1 | {
2 | "service": "matomo"
3 | }
4 |
--------------------------------------------------------------------------------
/examples/analytics_demo/qtquickcontrols2.conf:
--------------------------------------------------------------------------------
1 | [Controls]
2 | Style=Material
3 |
4 | [Material]
5 | Theme=Dark
6 |
--------------------------------------------------------------------------------
/tests/tests.pro:
--------------------------------------------------------------------------------
1 | TEMPLATE = subdirs
2 |
3 | include ( ../qtanalytics.pri )
4 | include ( ../doc/doc.pri )
5 |
6 | SUBDIRS = auto
7 |
--------------------------------------------------------------------------------
/.qmake.conf:
--------------------------------------------------------------------------------
1 | SOURCE_DIR=$$PWD
2 | BUILD_DIR=$$shadowed($$PWD)
3 | QMAKEFEATURES=$$SOURCE_DIR/qmake-features
4 |
5 | VERSION = 5.13.0
6 |
--------------------------------------------------------------------------------
/tests/auto/auto.pro:
--------------------------------------------------------------------------------
1 | TEMPLATE = subdirs
2 |
3 | SUBDIRS += \
4 | tst_google \
5 | tst_config \
6 | tst_analytics \
7 | tst_matomo
8 |
--------------------------------------------------------------------------------
/tests/auto/tst_config/tst_config.qrc:
--------------------------------------------------------------------------------
1 |
2 |
3 | analytics.json
4 |
5 |
6 |
--------------------------------------------------------------------------------
/src/src.pro:
--------------------------------------------------------------------------------
1 | TEMPLATE = subdirs
2 |
3 | include ( ../qtanalytics.pri )
4 | include ( ../doc/doc.pri )
5 |
6 | SUBDIRS += \
7 | plugin
8 |
9 |
10 |
--------------------------------------------------------------------------------
/examples/examples.pro:
--------------------------------------------------------------------------------
1 | TEMPLATE = subdirs
2 |
3 | include ( ../qtanalytics.pri )
4 | include ( ../doc/doc.pri )
5 |
6 |
7 | SUBDIRS += \
8 | analytics_demo
9 |
--------------------------------------------------------------------------------
/examples/analytics_demo/analytics.json:
--------------------------------------------------------------------------------
1 | {
2 | "tid": "UA-141497781-2",
3 | "cid": "555",
4 | "deviceResolution": "1280x800",
5 | "domain": "http://example.org",
6 | "tracker": "google"
7 | }
8 |
--------------------------------------------------------------------------------
/tests/auto/tst_google/tst_google.pro:
--------------------------------------------------------------------------------
1 | TEMPLATE = app
2 | TARGET = tst_google
3 |
4 | QT += testlib
5 | CONFIG += testcase
6 |
7 | include( ../../../src/plugin/plugin.pri )
8 |
9 | SOURCES += \
10 | tst_google.cpp
11 |
--------------------------------------------------------------------------------
/tests/auto/tst_matomo/tst_matomo.pro:
--------------------------------------------------------------------------------
1 | TEMPLATE = app
2 | TARGET = tst_matomo
3 |
4 | QT += testlib
5 | CONFIG += testcase
6 |
7 | include( ../../../src/plugin/plugin.pri )
8 |
9 | SOURCES += \
10 | tst_matomo.cpp
11 |
--------------------------------------------------------------------------------
/tests/auto/tst_analytics/tst_analytics.pro:
--------------------------------------------------------------------------------
1 | TEMPLATE = app
2 | TARGET = tst_analytics
3 |
4 | QT += testlib
5 | CONFIG += testcase
6 |
7 | include( ../../../src/plugin/plugin.pri )
8 |
9 | SOURCES += \
10 | tst_analytics.cpp
11 |
--------------------------------------------------------------------------------
/tests/auto/tst_urlbuilder/tst_urlbuilder.pro:
--------------------------------------------------------------------------------
1 | TEMPLATE = app
2 | TARGET = tst_urlbuilder
3 |
4 | QT += testlib
5 | CONFIG += testcase
6 |
7 | include( ../../../src/plugin/plugin.pri )
8 |
9 | SOURCES += \
10 | tst_urlbuilder.cpp
11 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # QtAnalytics
2 |
3 | A generic analytics module which can work with Google Analytics and Matomo Analytics server.
4 |
5 | # Build
6 |
7 | qmake && make && make install
8 |
9 | # Usage
10 |
11 | Please see the documentation or the example code.
12 |
--------------------------------------------------------------------------------
/tests/auto/tst_config/tst_config.pro:
--------------------------------------------------------------------------------
1 | TEMPLATE = app
2 | TARGET = tst_config
3 |
4 | QT += testlib
5 | CONFIG += testcase
6 |
7 | include( ../../../src/plugin/plugin.pri )
8 |
9 | SOURCES += \
10 | tst_config.cpp
11 |
12 | RESOURCES += \
13 | tst_config.qrc
14 |
--------------------------------------------------------------------------------
/qtanalytics.pro:
--------------------------------------------------------------------------------
1 | TEMPLATE = subdirs
2 |
3 | SUBDIRS += \
4 | src \
5 | examples \
6 | tests \
7 | doc
8 |
9 | examples.depends += src
10 | tests.depends = src
11 |
12 | OTHER_FILES += \
13 | README.md \
14 | .qmake.conf
15 |
16 |
17 | include(doc/doc.pri)
18 |
--------------------------------------------------------------------------------
/src/plugin/abstractquerybuilder.cpp.autosave:
--------------------------------------------------------------------------------
1 | #include "abstractquerybuilder.h"
2 |
3 | HitBuilder::HitBuilder()
4 | {
5 |
6 | }
7 |
8 | HitBuilder::~HitBuilder()
9 | {
10 | }
11 |
12 | void HitBuilder::addQueryItem(const QString &key, const QString &value)
13 | {
14 | m_query.addQueryItem(key, value);
15 | }
16 |
--------------------------------------------------------------------------------
/examples/analytics_demo/qml.qrc:
--------------------------------------------------------------------------------
1 |
2 |
3 | Main.qml
4 | HomePage.qml
5 | SubscriptionsPage.qml
6 | qtquickcontrols2.conf
7 | InfoPage.qml
8 | analytics.json
9 |
10 |
11 |
--------------------------------------------------------------------------------
/doc/doc.pri:
--------------------------------------------------------------------------------
1 | build_online_docs: {
2 | QMAKE_DOCS_TARGETDIR = qtanalytics
3 | QMAKE_DOCS = $$PWD/qtanalytics-online.qdocconf
4 | } else {
5 | QMAKE_DOCS = $$PWD/qtanalytics.qdocconf
6 | }
7 |
8 | load(qt_docs_targets)
9 |
10 | OTHER_FILES += \
11 | $$PWD/*.qdocconf \
12 | $$PWD/*.qdoc \
13 | $$PWD/examples/*.qdoc \
14 | $$PWD/images/*.png
15 |
--------------------------------------------------------------------------------
/doc/doc.pro:
--------------------------------------------------------------------------------
1 | TEMPLATE = aux
2 |
3 | CONFIG += force_qt
4 | QT *= quick network
5 |
6 | build_online_docs: {
7 | QMAKE_DOCS_TARGETDIR = qtanalytics
8 | QMAKE_DOCS = $$PWD/qtanalytics-online.qdocconf
9 | } else {
10 | QMAKE_DOCS = $$PWD/qtanalytics.qdocconf
11 | }
12 |
13 | include(doc.pri)
14 |
15 | OTHER_FILES += \
16 | $$PWD/*.qdocconf \
17 | $$PWD/*.qdoc \
18 | $$PWD/examples/*.qdoc \
19 | $$PWD/images/*.png
20 |
--------------------------------------------------------------------------------
/server/docker-compose.yml:
--------------------------------------------------------------------------------
1 | version: '3'
2 | services:
3 | db:
4 | image: mariadb
5 | environment:
6 | - MYSQL_ROOT_PASSWORD=securepassword
7 | volumes:
8 | - 'db_data:/var/lib/mysql'
9 | app:
10 | image: matomo
11 | ports:
12 | - '8080:80'
13 | volumes:
14 | - 'app_data:/var/www/html/config:rw'
15 | depends_on:
16 | - db
17 | volumes:
18 | db_data:
19 | driver: local
20 | app_data:
21 | driver: local
22 |
--------------------------------------------------------------------------------
/src/plugin/plugin.pri:
--------------------------------------------------------------------------------
1 | QT += qml quick
2 | CONFIG += c++11
3 |
4 | SOURCES += \
5 | $$PWD/analytics.cpp \
6 | $$PWD/configutil.cpp \
7 | $$PWD/context.cpp \
8 | $$PWD/googlebuilder.cpp \
9 | $$PWD/hitbuilder.cpp \
10 | $$PWD/matomobuilder.cpp
11 |
12 | HEADERS += \
13 | $$PWD/analytics.h \
14 | $$PWD/configutil.h \
15 | $$PWD/context.h \
16 | $$PWD/googlebuilder.h \
17 | $$PWD/hitbuilder.h \
18 | $$PWD/matomobuilder.h
19 |
20 | INCLUDEPATH = $$PWD
21 |
--------------------------------------------------------------------------------
/doc/style/qt5-sidebar.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
Qt Analytics
4 |
5 |
13 |
14 |
--------------------------------------------------------------------------------
/server/README.md:
--------------------------------------------------------------------------------
1 | # Piwik Demo
2 |
3 | ## Install Docker
4 |
5 | * https://docs.docker.com/install/
6 | * https://docs.docker.com/compose/install/
7 |
8 | ## Start Server
9 |
10 | docker-compose up
11 |
12 |
13 | ## Login
14 |
15 | http://127.0.01:8080
16 |
17 | Follow the instructions
18 |
19 | * Database Server: db
20 | * Login: root
21 | * Password: securepassword
22 | * Database name: matomo
23 |
24 | Create superuser
25 |
26 | User: root
27 | Password: securepassword
28 | Email: mail@example.org
29 |
30 | ## Create First App to Track
31 |
32 | Name: QtExampleApp
33 | Website: http://example.org
34 | Time Zone: UTC
35 | Ecommerce: No
36 |
37 | ## Add Tracker Code
38 |
39 | Browse down to MobileApps and SDKs, in the list search for Qt.
40 |
41 | Finish installation and login again
42 |
43 | ## Shutdown Server
44 |
45 | Just press Ctrl-C or in a another shell, same directory
46 |
47 | docker-compose down
48 |
49 |
50 |
51 |
52 |
--------------------------------------------------------------------------------
/doc/qtanalytics.qdocconf:
--------------------------------------------------------------------------------
1 | include($QT_INSTALL_DOCS/global/qt-html-templates-offline.qdocconf)
2 | include(qtanalytics-project.qdocconf)
3 |
4 | HTML.footer = \
5 | " \n" \
6 | " \n" \
7 | " \n" \
8 | " \n" \
9 | "\n" \
10 | "\n"
22 |
--------------------------------------------------------------------------------
/doc/qtanalytics-online.qdocconf:
--------------------------------------------------------------------------------
1 |
2 | HTML.footer = \
3 | " \n" \
4 | " \n" \
5 | " © 2019 Luxoft Sweden AB.\n" \
6 | " Documentation contributions included herein are the copyrights of\n" \
7 | " their respective owners. " \
8 | " The documentation provided herein is licensed under the terms of the" \
9 | " GNU Free Documentation" \
10 | " License version 1.3 as published by the Free Software Foundation. " \
11 | " Qt and respective logos are trademarks of The Qt Company Ltd. " \
12 | " in Finland and/or other countries worldwide. All other trademarks are property\n" \
13 | " of their respective owners.
\n"
14 |
15 | include($QT_INSTALL_DOCS/global/qt-html-templates-online.qdocconf)
16 |
17 | # Add an .html file with sidebar content, used in the online style
18 | HTML.stylesheets += style/qt5-sidebar.html
19 |
20 | HTML.nosubdirs = "false"
21 | HTML.outputsubdir = "qtanalytics"
22 |
23 | include(qtanalytics-project.qdocconf)
24 |
--------------------------------------------------------------------------------
/examples/analytics_demo/analytics_demo.pro:
--------------------------------------------------------------------------------
1 | QT += quick
2 | CONFIG += c++11
3 |
4 | OBJECTS_DIR = .obj
5 | MOC_DIR = .moc
6 |
7 | # The following define makes your compiler emit warnings if you use
8 | # any feature of Qt which as been marked deprecated (the exact warnings
9 | # depend on your compiler). Please consult the documentation of the
10 | # deprecated API in order to know how to port your code away from it.
11 | DEFINES += QT_DEPRECATED_WARNINGS
12 |
13 | # You can also make your code fail to compile if you use deprecated APIs.
14 | # In order to do so, uncomment the following line.
15 | # You can also select to disable deprecated APIs only up to a certain version of Qt.
16 | #DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0x060000 # disables all the APIs deprecated before Qt 6.0.0
17 |
18 | SOURCES += \
19 | main.cpp
20 |
21 | RESOURCES += qml.qrc
22 |
23 | include ( ../../qtanalytics.pri )
24 | include ( ../../doc/doc.pri )
25 |
26 |
27 | # Additional import path used to resolve QML modules in Qt Creator's code model
28 | QML_IMPORT_PATH =
29 |
30 | # Additional import path used to resolve QML modules just for Qt Quick Designer
31 | QML_DESIGNER_IMPORT_PATH =
32 |
33 |
--------------------------------------------------------------------------------
/src/plugin/plugin.pro:
--------------------------------------------------------------------------------
1 | TEMPLATE = lib
2 | TARGET = analytics
3 | CONFIG += plugin
4 |
5 | TARGET = $$qtLibraryTarget($$TARGET)
6 | uri = analytics
7 |
8 | include ( ../../qtanalytics.pri )
9 | include ( ../../doc/doc.pri )
10 | include ( plugin.pri )
11 | # Input
12 | SOURCES += \
13 | plugin.cpp
14 |
15 | HEADERS += \
16 | plugin.h
17 |
18 | DISTFILES = qmldir
19 |
20 | !equals(_PRO_FILE_PWD_, $$OUT_PWD) {
21 | copy_qmldir.target = $$OUT_PWD/qmldir
22 | copy_qmldir.depends = $$_PRO_FILE_PWD_/qmldir
23 | copy_qmldir.commands = $(COPY_FILE) \"$$replace(copy_qmldir.depends, /, $$QMAKE_DIR_SEP)\" \"$$replace(copy_qmldir.target, /, $$QMAKE_DIR_SEP)\"
24 | QMAKE_EXTRA_TARGETS += copy_qmldir
25 | PRE_TARGETDEPS += $$copy_qmldir.target
26 | }
27 |
28 | qmldir.files = qmldir
29 |
30 | installPath = $$[QT_INSTALL_QML]/$$replace(uri, \\., /)
31 | defined(ANALYTICS_DIR, var) {
32 | installPath = $${ANALYTICS_DIR}/analytics
33 | message( "The plugin will be installed in "$${ANALYTICS_DIR}/analytics )
34 | }
35 |
36 | qmldir.path = $$installPath
37 | target.path = $$installPath
38 | INSTALLS += target qmldir
39 |
40 | OBJECTS_DIR = .obj
41 | MOC_DIR = .moc
42 |
43 |
--------------------------------------------------------------------------------
/qtanalytics.pri:
--------------------------------------------------------------------------------
1 | isEmpty(PREFIX): PREFIX = $$[QT_INSTALL_PREFIX]
2 | isEmpty(EXAMPLES_PREFIX): EXAMPLES_PREFIX = $$[QT_INSTALL_EXAMPLES]/qtanalytics
3 |
4 | VERSIONS = $$split(VERSION, ".")
5 | VERSION_MAJOR = $$member(VERSIONS, 0)
6 | unset(VERSIONS)
7 |
8 | DEFINES += QTANALYTICS_VERSION=$$VERSION
9 | !isEmpty(QTANALYTICS_VERSION_EXTRA): DEFINES += QTANALYTICS_VERSION_EXTRA="\"$$QTANALYTICS_VERSION_EXTRA\""
10 | !isEmpty(QTANALYTICS_REVISION): DEFINES += QTANALYTICS_REVISION=$$QTANALYTICS_REVISION
11 | !isEmpty(QTANALYTICS_SETTINGS_VARIANT): DEFINES += QTANALYTICS_SETTINGS_VARIANT=$$QTANALYTICS_SETTINGS_VARIANT
12 |
13 | # from qtcreator.pri
14 | defineTest(minQtVersion) {
15 | maj = $$1
16 | min = $$2
17 | patch = $$3
18 | isEqual(QT_MAJOR_VERSION, $$maj) {
19 | isEqual(QT_MINOR_VERSION, $$min) {
20 | isEqual(QT_PATCH_VERSION, $$patch) {
21 | return(true)
22 | }
23 | greaterThan(QT_PATCH_VERSION, $$patch) {
24 | return(true)
25 | }
26 | }
27 | greaterThan(QT_MINOR_VERSION, $$min) {
28 | return(true)
29 | }
30 | }
31 | greaterThan(QT_MAJOR_VERSION, $$maj) {
32 | return(true)
33 | }
34 | return(false)
35 | }
36 |
--------------------------------------------------------------------------------
/doc/qtanalytics-project.qdocconf:
--------------------------------------------------------------------------------
1 | project = QtAnalytics
2 | description = QtAnalytics Reference Documentation
3 | url = https://doc.qt.io/QtAnalytics
4 | version = $QT_VERSION
5 |
6 | sources.fileextensions = "*.cpp *.qdoc *.mm *.qml"
7 | headers.fileextensions = "*.h *.ch *.h++ *.hh *.hpp *.hxx"
8 |
9 | examples.fileextensions = "*.cpp *.h *.js *.xq *.svg *.xml *.ui *.qhp *.qhcp *.qml"
10 | examples.imageextensions = "*.png *.jpeg *.jpg *.gif *.mng"
11 |
12 | exampledirs = ../examples ../src
13 |
14 | headerdirs = \
15 | ../src
16 |
17 | sourcedirs += \
18 | . \
19 | ../src \
20 | ../examples
21 |
22 | imagedirs = images
23 |
24 | qhp.projects = QtAnalytics
25 | qhp.QtAnalytics.file = qtanalytics.qhp
26 | qhp.QtAnalytics.namespace = io.qt.qtanalytics.$QT_VERSION_TAG
27 | qhp.QtAnalytics.virtualFolder = qtanalytics
28 | qhp.QtAnalytics.indexTitle = Qt Analytics
29 | qhp.QtAnalytics.indexRoot =
30 |
31 | qhp.QtAnalytics.filterAttributes = QtAnalytics $QT_VERSION
32 | qhp.QtAnalytics.customFilters.QtAnalytics.name = QtAnalytics $QT_VERSION
33 | qhp.QtAnalytics.customFilters.QtAnalytics.filterAttributes = QtAnalytics $QT_VERSION
34 |
35 | qhp.QtAnalytics.subprojects = manual
36 | qhp.QtAnalytics.subprojects.manual.title = Qt Analytics
37 | qhp.QtAnalytics.subprojects.manual.indexTitle = Qt Analytics
38 | qhp.QtAnalytics.subprojects.manual.type = manual
39 |
40 | navigation.homepage = "Qt Automotive Suite"
41 | navigation.landingpage = "Qt Analytics"
42 | buildversion = "Qt Analytics $QT_VERSION"
43 |
--------------------------------------------------------------------------------
/doc/examples/analytics_demo.qdoc:
--------------------------------------------------------------------------------
1 | /****************************************************************************
2 | **
3 | ** Copyright (C) 2019 Luxoft Sweden AB
4 | **
5 | ** Contact: https://www.qt.io/licensing/
6 | **
7 | ** This file is part of the QtAnalytics plugin.
8 | **
9 | ** $QT_BEGIN_LICENSE:GPL-QTAS$
10 | ** Commercial License Usage
11 | ** Licensees holding valid commercial Qt Automotive Suite licenses may use
12 | ** this file in accordance with the commercial license agreement provided
13 | ** with the Software or, alternatively, in accordance with the terms
14 | ** contained in a written agreement between you and The Qt Company. For
15 | ** licensing terms and conditions see https://www.qt.io/terms-conditions.
16 | ** For further information use the contact form at https://www.qt.io/contact-us.
17 | **
18 | ** GNU General Public License Usage
19 | ** Alternatively, this file may be used under the terms of the GNU
20 | ** General Public License version 3 or (at your option) any later version
21 | ** approved by the KDE Free Qt Foundation. The licenses are as published by
22 | ** the Free Software Foundation and appearing in the file LICENSE.GPL3
23 | ** included in the packaging of this file. Please review the following
24 | ** information to ensure the GNU General Public License requirements will
25 | ** be met: https://www.gnu.org/licenses/gpl-3.0.html.
26 | **
27 | ** $QT_END_LICENSE$
28 | **
29 | ** SPDX-License-Identifier: GPL-3.0
30 | **
31 | ****************************************************************************/
32 | /*!
33 | \example analytics_demo
34 | \title Analytics Demo
35 |
36 | \brief Demonstrates how to use the analytics plugin.
37 |
38 | */
39 |
--------------------------------------------------------------------------------
/doc/qtanalytics-examples.qdoc:
--------------------------------------------------------------------------------
1 | /****************************************************************************
2 | **
3 | ** Copyright (C) 2019 Luxoft Sweden AB
4 | **
5 | ** Contact: https://www.qt.io/licensing/
6 | **
7 | ** This file is part of the QtAnalytics plugin.
8 | **
9 | ** $QT_BEGIN_LICENSE:GPL-QTAS$
10 | ** Commercial License Usage
11 | ** Licensees holding valid commercial Qt Automotive Suite licenses may use
12 | ** this file in accordance with the commercial license agreement provided
13 | ** with the Software or, alternatively, in accordance with the terms
14 | ** contained in a written agreement between you and The Qt Company. For
15 | ** licensing terms and conditions see https://www.qt.io/terms-conditions.
16 | ** For further information use the contact form at https://www.qt.io/contact-us.
17 | **
18 | ** GNU General Public License Usage
19 | ** Alternatively, this file may be used under the terms of the GNU
20 | ** General Public License version 3 or (at your option) any later version
21 | ** approved by the KDE Free Qt Foundation. The licenses are as published by
22 | ** the Free Software Foundation and appearing in the file LICENSE.GPL3
23 | ** included in the packaging of this file. Please review the following
24 | ** information to ensure the GNU General Public License requirements will
25 | ** be met: https://www.gnu.org/licenses/gpl-3.0.html.
26 | **
27 | ** $QT_END_LICENSE$
28 | **
29 | ** SPDX-License-Identifier: GPL-3.0
30 | **
31 | ****************************************************************************/
32 |
33 | /*!
34 | \group qtanalytics-examples
35 | \title Analytics Examples
36 | \brief Examples showing how to extend the functionality of Qt Analytics.
37 |
38 | \list
39 | \li \l{qtanalytics_demo}{Analytics Demo}
40 | \endlist
41 |
42 | */
43 |
--------------------------------------------------------------------------------
/doc/qtanalytics-installation.qdoc:
--------------------------------------------------------------------------------
1 | /****************************************************************************
2 | **
3 | ** Copyright (C) 2019 Luxoft Sweden AB
4 | **
5 | ** Contact: https://www.qt.io/licensing/
6 | **
7 | ** This file is part of the QtAnalytics plugin.
8 | **
9 | ** $QT_BEGIN_LICENSE:GPL-QTAS$
10 | ** Commercial License Usage
11 | ** Licensees holding valid commercial Qt Automotive Suite licenses may use
12 | ** this file in accordance with the commercial license agreement provided
13 | ** with the Software or, alternatively, in accordance with the terms
14 | ** contained in a written agreement between you and The Qt Company. For
15 | ** licensing terms and conditions see https://www.qt.io/terms-conditions.
16 | ** For further information use the contact form at https://www.qt.io/contact-us.
17 | **
18 | ** GNU General Public License Usage
19 | ** Alternatively, this file may be used under the terms of the GNU
20 | ** General Public License version 3 or (at your option) any later version
21 | ** approved by the KDE Free Qt Foundation. The licenses are as published by
22 | ** the Free Software Foundation and appearing in the file LICENSE.GPL3
23 | ** included in the packaging of this file. Please review the following
24 | ** information to ensure the GNU General Public License requirements will
25 | ** be met: https://www.gnu.org/licenses/gpl-3.0.html.
26 | **
27 | ** $QT_END_LICENSE$
28 | **
29 | ** SPDX-License-Identifier: GPL-3.0
30 | **
31 | ****************************************************************************/
32 |
33 | /*!
34 |
35 | \page qtanalytics-installation.html
36 | \title Installation
37 |
38 | \section1 Dependencies
39 |
40 | \list
41 | \li Windows, Linux or macOS
42 | \li Qt5.4 or higher
43 | \endlist
44 |
45 | \section1 Building for desktop
46 |
47 | \code
48 | $ qmake
49 | $ make
50 | $ make install
51 | \endcode
52 |
53 | Qt Analytics plugin is installed into the Qt SDK as a QtQuick plugin. See \l {Usage} for more information how to use the plugin.
54 |
55 |
56 | */
57 |
--------------------------------------------------------------------------------
/doc/index.qdoc:
--------------------------------------------------------------------------------
1 | /****************************************************************************
2 | **
3 | ** Copyright (C) 2019 Luxoft Sweden AB
4 | **
5 | ** Contact: https://www.qt.io/licensing/
6 | **
7 | ** This file is part of the Qt analytics plugin.
8 | **
9 | ** $QT_BEGIN_LICENSE:GPL-QTAS$
10 | ** Commercial License Usage
11 | ** Licensees holding valid commercial Qt Automotive Suite licenses may use
12 | ** this file in accordance with the commercial license agreement provided
13 | ** with the Software or, alternatively, in accordance with the terms
14 | ** contained in a written agreement between you and The Qt Company. For
15 | ** licensing terms and conditions see https://www.qt.io/terms-conditions.
16 | ** For further information use the contact form at https://www.qt.io/contact-us.
17 | **
18 | ** GNU General Public License Usage
19 | ** Alternatively, this file may be used under the terms of the GNU
20 | ** General Public License version 3 or (at your option) any later version
21 | ** approved by the KDE Free Qt Foundation. The licenses are as published by
22 | ** the Free Software Foundation and appearing in the file LICENSE.GPL3
23 | ** included in the packaging of this file. Please review the following
24 | ** information to ensure the GNU General Public License requirements will
25 | ** be met: https://www.gnu.org/licenses/gpl-3.0.html.
26 | **
27 | ** $QT_END_LICENSE$
28 | **
29 | ** SPDX-License-Identifier: GPL-3.0
30 | **
31 | ****************************************************************************/
32 |
33 | /*!
34 |
35 | \page qtanalytics-index.html
36 | \keyword QtAnalytics Reference Documentation
37 | \title Qt Analytics
38 |
39 | \section1 Overview
40 |
41 | Qt analytics is a module to send user interface traces to a cloud server.
42 |
43 | \list
44 | \li \l{qtanalytics}{Qt Analytics}
45 | \li \l{Concepts}
46 | \li \l{Installation}
47 | \li \l{Usage}
48 | \endlist
49 | */
50 |
51 | /*!
52 | * \page qtanalytics-reference
53 | * \title API Reference
54 | *
55 | *
56 | * \list
57 | * \li \l{qtanalytics}{Qt Analytics}
58 | * \endlist
59 | */
60 |
--------------------------------------------------------------------------------
/qmake-features/config-output.prf:
--------------------------------------------------------------------------------
1 | defineReplace(yesNo) {
2 | if ($$1):return("yes")
3 | else:return("no")
4 | }
5 |
6 | defineTest(printConfigLine) {
7 | !build_pass:return
8 |
9 | msg="$$1"
10 | val=$$2
11 | color=$$3
12 | width=$$4
13 |
14 | isEmpty(width):width = 30
15 |
16 | unix:system("tty -s") { # check if we are on unix and stdout is a tty
17 | equals(color, "auto") {
18 | yesmatch = $$find(val, "^yes")
19 | nomatch = $$find(val, "^no")
20 | automatch = $$find(val, "^auto")
21 |
22 | !isEmpty(yesmatch):color = "green"
23 | else:!isEmpty(nomatch):color = "red"
24 | else:!isEmpty(automatch):color = "yellow"
25 | }
26 | equals(color, "red"): prolog=$$system(echo "\\\\033")[31;1m
27 | else:equals(color, "green"): prolog=$$system(echo "\\\\033")[32;1m
28 | else:equals(color, "yellow"): prolog=$$system(echo "\\\\033")[33;1m
29 | else:equals(color, "orange"): prolog=$$system(echo "\\\\033")[33m
30 | else:equals(color, "white"): prolog=$$system(echo "\\\\033")[37;1m
31 | epilog = $$system(echo "\\\\033")[0m
32 | }
33 |
34 | isEmpty(msg)|contains(msg, "^-- .*") {
35 | log($$prolog$$section(msg, "-- ", 1, -1)$$epilog$$escape_expand(\\n))
36 | return()
37 | }
38 |
39 | # The tricky part: there are no arithmetic functions in qmake!
40 | # Start by createing an array of strings, where the string at [i] consists of i dots
41 | # We need it the other way around though, hence the reverse at the end (sadly you
42 | # cannot run a $$width..1 loop, although 30..1 does work).
43 | for(i, 1..$$width) {
44 | spacingEntry=""
45 | for (j, 1..$$i) { spacingEntry += "." }
46 | spacing += $$join(spacingEntry)
47 | }
48 | spacing = $$reverse(spacing)
49 |
50 | # convert a string into an array of characters, so we can get the length via size()
51 | msgArray = $$split(msg,)
52 |
53 | log(" $$msg $$member(spacing, $$size(msgArray)) $$prolog$$val$$epilog$$escape_expand(\\n)")
54 | }
55 |
--------------------------------------------------------------------------------
/doc/qtanalytics-group.qdoc:
--------------------------------------------------------------------------------
1 | /****************************************************************************
2 | **
3 | ** Copyright (C) 2019 Luxoft Sweden AB
4 | **
5 | ** Contact: https://www.qt.io/licensing/
6 | **
7 | ** This file is part of the QtAnalytics plugin.
8 | **
9 | ** $QT_BEGIN_LICENSE:GPL-QTAS$
10 | ** Commercial License Usage
11 | ** Licensees holding valid commercial Qt Automotive Suite licenses may use
12 | ** this file in accordance with the commercial license agreement provided
13 | ** with the Software or, alternatively, in accordance with the terms
14 | ** contained in a written agreement between you and The Qt Company. For
15 | ** licensing terms and conditions see https://www.qt.io/terms-conditions.
16 | ** For further information use the contact form at https://www.qt.io/contact-us.
17 | **
18 | ** GNU General Public License Usage
19 | ** Alternatively, this file may be used under the terms of the GNU
20 | ** General Public License version 3 or (at your option) any later version
21 | ** approved by the KDE Free Qt Foundation. The licenses are as published by
22 | ** the Free Software Foundation and appearing in the file LICENSE.GPL3
23 | ** included in the packaging of this file. Please review the following
24 | ** information to ensure the GNU General Public License requirements will
25 | ** be met: https://www.gnu.org/licenses/gpl-3.0.html.
26 | **
27 | ** $QT_END_LICENSE$
28 | **
29 | ** SPDX-License-Identifier: GPL-3.0
30 | **
31 | ****************************************************************************/
32 |
33 |
34 | /*!
35 | \module qtanalytics
36 |
37 | \title Qt Analytics Module
38 | \brief Classes for interacting with a Matomo server to track user
39 | interface metrics.
40 |
41 | The QtAnalytics module allows a developer to provide traces inside a user interface to send those ui traces to a Matamo server.
42 |
43 | Tracing is limited currently to tracing page views, events and custom variables.
44 | Traces are send to the server directly using a HTTP GET or POST request. There is support currently for the Matamo server and the Google Analytics platform.
45 |
46 | */
47 |
--------------------------------------------------------------------------------
/tools/simple_http_server.sh:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 |
3 | ##
4 | ## Copyright (C) 2019 Luxoft Sweden AB. All rights reserved.
5 | ## Contact: https://www.qt.io/licensing/
6 | ##
7 | ## This file is part of the analytics module of the Qt Toolkit.
8 | ##
9 | ## $QT_BEGIN_LICENSE:LGPL$
10 | ## Commercial License Usage
11 | ## Licensees holding valid commercial Qt licenses may use this file in
12 | ## accordance with the commercial license agreement provided with the
13 | ## Software or, alternatively, in accordance with the terms contained in
14 | ## a written agreement between you and The Qt Company. For licensing terms
15 | ## and conditions see https://www.qt.io/terms-conditions. For further
16 | ## information use the contact form at https://www.qt.io/contact-us.
17 | ##
18 | ## GNU Lesser General Public License Usage
19 | ## Alternatively, this file may be used under the terms of the GNU Lesser
20 | ## General Public License version 3 as published by the Free Software
21 | ## Foundation and appearing in the file LICENSE.LGPL3 included in the
22 | ## packaging of this file. Please review the following information to
23 | ## ensure the GNU Lesser General Public License version 3 requirements
24 | ## will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
25 | ##
26 | ## GNU General Public License Usage
27 | ## Alternatively, this file may be used under the terms of the GNU
28 | ## General Public License version 2.0 or (at your option) the GNU General
29 | ## Public license version 3 or any later version approved by the KDE Free
30 | ## Qt Foundation. The licenses are as published by the Free Software
31 | ## Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
32 | ## included in the packaging of this file. Please review the following
33 | ## information to ensure the GNU General Public License requirements will
34 | ## be met: https://www.gnu.org/licenses/gpl-2.0.html and
35 | ## https://www.gnu.org/licenses/gpl-3.0.html.
36 | ##
37 | ## $QT_END_LICENSE$
38 | ##
39 |
40 | # A simple http server which prints out all incoming http requests to the console
41 |
42 | PORT=8080
43 |
44 | while true
45 | do
46 | echo -e "HTTP/1.1 200 OK\n\n $(date)" | nc -l -p $PORT -q 1
47 | echo "---------------------------"
48 | done
49 |
--------------------------------------------------------------------------------
/src/plugin/plugin.h:
--------------------------------------------------------------------------------
1 | /****************************************************************************
2 | **
3 | ** Copyright (C) 2019 Luxoft Sweden AB. All rights reserved.
4 | ** Contact: https://www.qt.io/licensing/
5 | **
6 | ** This file is part of the analytics module of the Qt Toolkit.
7 | **
8 | ** $QT_BEGIN_LICENSE:LGPL$
9 | ** Commercial License Usage
10 | ** Licensees holding valid commercial Qt licenses may use this file in
11 | ** accordance with the commercial license agreement provided with the
12 | ** Software or, alternatively, in accordance with the terms contained in
13 | ** a written agreement between you and The Qt Company. For licensing terms
14 | ** and conditions see https://www.qt.io/terms-conditions. For further
15 | ** information use the contact form at https://www.qt.io/contact-us.
16 | **
17 | ** GNU Lesser General Public License Usage
18 | ** Alternatively, this file may be used under the terms of the GNU Lesser
19 | ** General Public License version 3 as published by the Free Software
20 | ** Foundation and appearing in the file LICENSE.LGPL3 included in the
21 | ** packaging of this file. Please review the following information to
22 | ** ensure the GNU Lesser General Public License version 3 requirements
23 | ** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
24 | **
25 | ** GNU General Public License Usage
26 | ** Alternatively, this file may be used under the terms of the GNU
27 | ** General Public License version 2.0 or (at your option) the GNU General
28 | ** Public license version 3 or any later version approved by the KDE Free
29 | ** Qt Foundation. The licenses are as published by the Free Software
30 | ** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
31 | ** included in the packaging of this file. Please review the following
32 | ** information to ensure the GNU General Public License requirements will
33 | ** be met: https://www.gnu.org/licenses/gpl-2.0.html and
34 | ** https://www.gnu.org/licenses/gpl-3.0.html.
35 | **
36 | ** $QT_END_LICENSE$
37 | **
38 | ****************************************************************************/
39 |
40 | #pragma once
41 |
42 | #include
43 |
44 | class Plugin : public QQmlExtensionPlugin
45 | {
46 | Q_OBJECT
47 | Q_PLUGIN_METADATA(IID QQmlExtensionInterface_iid)
48 |
49 | public:
50 | void registerTypes(const char *uri);
51 | };
52 |
--------------------------------------------------------------------------------
/src/plugin/plugin.cpp:
--------------------------------------------------------------------------------
1 | /****************************************************************************
2 | **
3 | ** Copyright (C) 2019 Luxoft Sweden AB. All rights reserved.
4 | ** Contact: https://www.qt.io/licensing/
5 | **
6 | ** This file is part of the analytics module of the Qt Toolkit.
7 | **
8 | ** $QT_BEGIN_LICENSE:LGPL$
9 | ** Commercial License Usage
10 | ** Licensees holding valid commercial Qt licenses may use this file in
11 | ** accordance with the commercial license agreement provided with the
12 | ** Software or, alternatively, in accordance with the terms contained in
13 | ** a written agreement between you and The Qt Company. For licensing terms
14 | ** and conditions see https://www.qt.io/terms-conditions. For further
15 | ** information use the contact form at https://www.qt.io/contact-us.
16 | **
17 | ** GNU Lesser General Public License Usage
18 | ** Alternatively, this file may be used under the terms of the GNU Lesser
19 | ** General Public License version 3 as published by the Free Software
20 | ** Foundation and appearing in the file LICENSE.LGPL3 included in the
21 | ** packaging of this file. Please review the following information to
22 | ** ensure the GNU Lesser General Public License version 3 requirements
23 | ** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
24 | **
25 | ** GNU General Public License Usage
26 | ** Alternatively, this file may be used under the terms of the GNU
27 | ** General Public License version 2.0 or (at your option) the GNU General
28 | ** Public license version 3 or any later version approved by the KDE Free
29 | ** Qt Foundation. The licenses are as published by the Free Software
30 | ** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
31 | ** included in the packaging of this file. Please review the following
32 | ** information to ensure the GNU General Public License requirements will
33 | ** be met: https://www.gnu.org/licenses/gpl-2.0.html and
34 | ** https://www.gnu.org/licenses/gpl-3.0.html.
35 | **
36 | ** $QT_END_LICENSE$
37 | **
38 | ****************************************************************************/
39 |
40 | #include "plugin.h"
41 | #include "analytics.h"
42 |
43 | #include
44 |
45 | /*!
46 | * \class Plugin
47 | * \inmodule QtAnalytics
48 | * \brief The Plugin class
49 | */
50 |
51 | /*!
52 | * \brief register QtQuick types.
53 | * \param uri the uri for the type registry
54 | */
55 |
56 | void Plugin::registerTypes(const char *uri)
57 | {
58 | Q_UNUSED(uri)
59 | // @uri analytics
60 | qmlRegisterType();
61 | qmlRegisterUncreatableType(uri, 1, 0, "Analytics", "No creatable");
62 | }
63 |
64 |
--------------------------------------------------------------------------------
/src/plugin/configutil.h:
--------------------------------------------------------------------------------
1 | /****************************************************************************
2 | **
3 | ** Copyright (C) 2019 Luxoft Sweden AB. All rights reserved.
4 | ** Contact: https://www.qt.io/licensing/
5 | **
6 | ** This file is part of the analytics module of the Qt Toolkit.
7 | **
8 | ** $QT_BEGIN_LICENSE:LGPL$
9 | ** Commercial License Usage
10 | ** Licensees holding valid commercial Qt licenses may use this file in
11 | ** accordance with the commercial license agreement provided with the
12 | ** Software or, alternatively, in accordance with the terms contained in
13 | ** a written agreement between you and The Qt Company. For licensing terms
14 | ** and conditions see https://www.qt.io/terms-conditions. For further
15 | ** information use the contact form at https://www.qt.io/contact-us.
16 | **
17 | ** GNU Lesser General Public License Usage
18 | ** Alternatively, this file may be used under the terms of the GNU Lesser
19 | ** General Public License version 3 as published by the Free Software
20 | ** Foundation and appearing in the file LICENSE.LGPL3 included in the
21 | ** packaging of this file. Please review the following information to
22 | ** ensure the GNU Lesser General Public License version 3 requirements
23 | ** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
24 | **
25 | ** GNU General Public License Usage
26 | ** Alternatively, this file may be used under the terms of the GNU
27 | ** General Public License version 2.0 or (at your option) the GNU General
28 | ** Public license version 3 or any later version approved by the KDE Free
29 | ** Qt Foundation. The licenses are as published by the Free Software
30 | ** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
31 | ** included in the packaging of this file. Please review the following
32 | ** information to ensure the GNU General Public License requirements will
33 | ** be met: https://www.gnu.org/licenses/gpl-2.0.html and
34 | ** https://www.gnu.org/licenses/gpl-3.0.html.
35 | **
36 | ** $QT_END_LICENSE$
37 | **
38 | ****************************************************************************/
39 | #pragma once
40 |
41 | #include
42 |
43 | class ConfigUtil
44 | {
45 | private:
46 | ConfigUtil();
47 | public:
48 | static QString resolvePath(const QString &name);
49 | static QByteArray readJSON(const QString &path);
50 | static QJsonObject parseJSON(const QByteArray &data);
51 | static QJsonObject loadJSON(const QString &name);
52 | static QJsonObject mergeJSON(const QJsonObject &a, const QJsonObject &b);
53 | static QVariantMap toVariantMap(const QJsonObject &o);
54 | static QVariantMap mergeMap(const QVariantMap &a, const QVariantMap &b);
55 | };
56 |
--------------------------------------------------------------------------------
/doc/qtanalytics-usage.qdoc:
--------------------------------------------------------------------------------
1 | /****************************************************************************
2 | **
3 | ** Copyright (C) 2019 Luxoft Sweden AB
4 | **
5 | ** Contact: https://www.qt.io/licensing/
6 | **
7 | ** This file is part of the QtAnalytics plugin.
8 | **
9 | ** $QT_BEGIN_LICENSE:GPL-QTAS$
10 | ** Commercial License Usage
11 | ** Licensees holding valid commercial Qt Automotive Suite licenses may use
12 | ** this file in accordance with the commercial license agreement provided
13 | ** with the Software or, alternatively, in accordance with the terms
14 | ** contained in a written agreement between you and The Qt Company. For
15 | ** licensing terms and conditions see https://www.qt.io/terms-conditions.
16 | ** For further information use the contact form at https://www.qt.io/contact-us.
17 | **
18 | ** GNU General Public License Usage
19 | ** Alternatively, this file may be used under the terms of the GNU
20 | ** General Public License version 3 or (at your option) any later version
21 | ** approved by the KDE Free Qt Foundation. The licenses are as published by
22 | ** the Free Software Foundation and appearing in the file LICENSE.GPL3
23 | ** included in the packaging of this file. Please review the following
24 | ** information to ensure the GNU General Public License requirements will
25 | ** be met: https://www.gnu.org/licenses/gpl-3.0.html.
26 | **
27 | ** $QT_END_LICENSE$
28 | **
29 | ** SPDX-License-Identifier: GPL-3.0
30 | **
31 | ****************************************************************************/
32 |
33 | /*!
34 |
35 | \page qtanalytics-usage.html
36 | \title Usage
37 |
38 | \section1 Introduction
39 |
40 | The analytics plugin works with either a recent Matamo Server or Google Analytics. For both setup it is assumed the credentials and logins are available.
41 |
42 | To avoid having configuration information inside the UI code the plugin looks up a configuration file. The configuration is stored by default into a \c {:/analytics.json} document. This location can be overridden using the \c {ANALYTICS_CONFIG} environment variable.
43 |
44 | The config file must have at least a \c {tracker} key and the corresponding builder configuration.
45 |
46 | For example for a google tracker you specify
47 |
48 | \code
49 | {
50 | "tracker": "google"
51 | "tid": "UA-555555555-5",
52 | "cid": "555",
53 | "deviceResolution": "1280x800",
54 | "domain": "http://example.org",
55 | }
56 | \endcode
57 |
58 | \list
59 | \li \c tracker - the tracker backend to be used
60 | \li \c tid - the tracker id
61 | \li \c cid - the client id
62 | \li \c deviceResolution - a custom variable to be send with the tracker
63 | \li \c domain - the URI the application will identify
64 | \endlist
65 |
66 |
67 | See \l {Concepts} for more information.
68 |
69 | */
70 |
--------------------------------------------------------------------------------
/src/plugin/matomobuilder.h:
--------------------------------------------------------------------------------
1 | /****************************************************************************
2 | **
3 | ** Copyright (C) 2019 Luxoft Sweden AB. All rights reserved.
4 | ** Contact: https://www.qt.io/licensing/
5 | **
6 | ** This file is part of the analytics module of the Qt Toolkit.
7 | **
8 | ** $QT_BEGIN_LICENSE:LGPL$
9 | ** Commercial License Usage
10 | ** Licensees holding valid commercial Qt licenses may use this file in
11 | ** accordance with the commercial license agreement provided with the
12 | ** Software or, alternatively, in accordance with the terms contained in
13 | ** a written agreement between you and The Qt Company. For licensing terms
14 | ** and conditions see https://www.qt.io/terms-conditions. For further
15 | ** information use the contact form at https://www.qt.io/contact-us.
16 | **
17 | ** GNU Lesser General Public License Usage
18 | ** Alternatively, this file may be used under the terms of the GNU Lesser
19 | ** General Public License version 3 as published by the Free Software
20 | ** Foundation and appearing in the file LICENSE.LGPL3 included in the
21 | ** packaging of this file. Please review the following information to
22 | ** ensure the GNU Lesser General Public License version 3 requirements
23 | ** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
24 | **
25 | ** GNU General Public License Usage
26 | ** Alternatively, this file may be used under the terms of the GNU
27 | ** General Public License version 2.0 or (at your option) the GNU General
28 | ** Public license version 3 or any later version approved by the KDE Free
29 | ** Qt Foundation. The licenses are as published by the Free Software
30 | ** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
31 | ** included in the packaging of this file. Please review the following
32 | ** information to ensure the GNU General Public License requirements will
33 | ** be met: https://www.gnu.org/licenses/gpl-2.0.html and
34 | ** https://www.gnu.org/licenses/gpl-3.0.html.
35 | **
36 | ** $QT_END_LICENSE$
37 | **
38 | ****************************************************************************/
39 | #pragma once
40 |
41 | #include
42 |
43 | #include "hitbuilder.h"
44 |
45 | class Context;
46 |
47 |
48 | class MatomoBuilder : public HitBuilder
49 | {
50 | Q_OBJECT
51 | public:
52 | static const QString SITE_ID;
53 | static const QString ACTION_NAME;
54 | static const QString ACTION_URL;
55 | static const QString API_VERSION;
56 | static const QString EVENT_CATEGORY;
57 | static const QString EVENT_ACTION;
58 | static const QString EVENT_NAME;
59 | static const QString EVENT_VALUE;
60 | static const QString RECORDING;
61 | public:
62 | MatomoBuilder(Context *context, QObject *parent=nullptr);
63 | ~MatomoBuilder() override;
64 | void initQuery() override;
65 | void trackPage(const QString &path, const QString &title) override;
66 | void trackEvent(const QString &category, const QString &action, const QString &label, const QString &value) override;
67 | };
68 |
69 |
--------------------------------------------------------------------------------
/src/plugin/googlebuilder.h:
--------------------------------------------------------------------------------
1 | /****************************************************************************
2 | **
3 | ** Copyright (C) 2019 Luxoft Sweden AB. All rights reserved.
4 | ** Contact: https://www.qt.io/licensing/
5 | **
6 | ** This file is part of the analytics module of the Qt Toolkit.
7 | **
8 | ** $QT_BEGIN_LICENSE:LGPL$
9 | ** Commercial License Usage
10 | ** Licensees holding valid commercial Qt licenses may use this file in
11 | ** accordance with the commercial license agreement provided with the
12 | ** Software or, alternatively, in accordance with the terms contained in
13 | ** a written agreement between you and The Qt Company. For licensing terms
14 | ** and conditions see https://www.qt.io/terms-conditions. For further
15 | ** information use the contact form at https://www.qt.io/contact-us.
16 | **
17 | ** GNU Lesser General Public License Usage
18 | ** Alternatively, this file may be used under the terms of the GNU Lesser
19 | ** General Public License version 3 as published by the Free Software
20 | ** Foundation and appearing in the file LICENSE.LGPL3 included in the
21 | ** packaging of this file. Please review the following information to
22 | ** ensure the GNU Lesser General Public License version 3 requirements
23 | ** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
24 | **
25 | ** GNU General Public License Usage
26 | ** Alternatively, this file may be used under the terms of the GNU
27 | ** General Public License version 2.0 or (at your option) the GNU General
28 | ** Public license version 3 or any later version approved by the KDE Free
29 | ** Qt Foundation. The licenses are as published by the Free Software
30 | ** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
31 | ** included in the packaging of this file. Please review the following
32 | ** information to ensure the GNU General Public License requirements will
33 | ** be met: https://www.gnu.org/licenses/gpl-2.0.html and
34 | ** https://www.gnu.org/licenses/gpl-3.0.html.
35 | **
36 | ** $QT_END_LICENSE$
37 | **
38 | ****************************************************************************/
39 | #pragma once
40 |
41 | #include
42 |
43 | #include "hitbuilder.h"
44 |
45 | class Context;
46 |
47 | class GoogleBuilder : public HitBuilder
48 | {
49 | Q_OBJECT
50 | public:
51 | static const QString TRACKER_ID;
52 | static const QString VERSION;
53 | static const QString DATA_SOURCE;
54 | static const QString DOCUMENT_PATH;
55 | static const QString DOCUMENT_TITLE;
56 | static const QString EVENT_CATEGORY;
57 | static const QString EVENT_ACTION;
58 | static const QString EVENT_LABEL;
59 | static const QString EVENT_VALUE;
60 | static const QString HIT_TYPE;
61 | static const QString CLIENT_ID;
62 |
63 | explicit GoogleBuilder(Context *context, QObject *parent=nullptr);
64 | ~GoogleBuilder();
65 |
66 | // HitBuilder interface
67 | public:
68 | void initQuery();
69 | void trackPage(const QString &path, const QString &title);
70 | void trackEvent(const QString &category, const QString &action, const QString &label, const QString &value);
71 | QNetworkReply *sendQuery();
72 | };
73 |
--------------------------------------------------------------------------------
/examples/analytics_demo/InfoPage.qml:
--------------------------------------------------------------------------------
1 | /****************************************************************************
2 | **
3 | ** Copyright (C) 2018, 2019 Luxoft Sweden AB. All rights reserved.
4 | ** Contact: https://www.qt.io/licensing/
5 | **
6 | ** This file is part of the analytics module of the Qt Toolkit.
7 | **
8 | ** $QT_BEGIN_LICENSE:BSD$
9 | ** Commercial License Usage
10 | ** Licensees holding valid commercial Qt licenses may use this file in
11 | ** accordance with the commercial license agreement provided with the
12 | ** Software or, alternatively, in accordance with the terms contained in
13 | ** a written agreement between you and The Qt Company. For licensing terms
14 | ** and conditions see https://www.qt.io/terms-conditions. For further
15 | ** information use the contact form at https://www.qt.io/contact-us.
16 | **
17 | ** BSD License Usage
18 | ** Alternatively, you may use this file under the terms of the BSD license
19 | ** as follows:
20 | **
21 | ** "Redistribution and use in source and binary forms, with or without
22 | ** modification, are permitted provided that the following conditions are
23 | ** met:
24 | ** * Redistributions of source code must retain the above copyright
25 | ** notice, this list of conditions and the following disclaimer.
26 | ** * Redistributions in binary form must reproduce the above copyright
27 | ** notice, this list of conditions and the following disclaimer in
28 | ** the documentation and/or other materials provided with the
29 | ** distribution.
30 | ** * Neither the name of The Qt Company Ltd nor the names of its
31 | ** contributors may be used to endorse or promote products derived
32 | ** from this software without specific prior written permission.
33 | **
34 | **
35 | ** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
36 | ** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
37 | ** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
38 | ** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
39 | ** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
40 | ** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
41 | ** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
42 | ** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
43 | ** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
44 | ** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
45 | ** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
46 | **
47 | ** $QT_END_LICENSE$
48 | **
49 | ****************************************************************************/
50 |
51 | import QtQuick 2.11
52 | import QtQuick.Controls 2.4
53 |
54 | import analytics 1.0
55 |
56 | Page {
57 | id: root
58 | objectName: "info"
59 | title: qsTr("Info Page")
60 |
61 | contentItem: Item {
62 | Label {
63 | anchors.centerIn: parent
64 | font.pixelSize: 36
65 | text: "Information"
66 | }
67 | }
68 |
69 | Component.onCompleted: Analytics.sendVisit(root.objectName, "Info")
70 | }
71 |
--------------------------------------------------------------------------------
/tests/auto/tst_urlbuilder/tst_urlbuilder.cpp:
--------------------------------------------------------------------------------
1 | /****************************************************************************
2 | **
3 | ** Copyright (C) 2019 Luxoft Sweden AB. All rights reserved.
4 | ** Contact: https://www.qt.io/licensing/
5 | **
6 | ** This file is part of the analytics module of the Qt Toolkit.
7 | **
8 | ** $QT_BEGIN_LICENSE:LGPL$
9 | ** Commercial License Usage
10 | ** Licensees holding valid commercial Qt licenses may use this file in
11 | ** accordance with the commercial license agreement provided with the
12 | ** Software or, alternatively, in accordance with the terms contained in
13 | ** a written agreement between you and The Qt Company. For licensing terms
14 | ** and conditions see https://www.qt.io/terms-conditions. For further
15 | ** information use the contact form at https://www.qt.io/contact-us.
16 | **
17 | ** GNU Lesser General Public License Usage
18 | ** Alternatively, this file may be used under the terms of the GNU Lesser
19 | ** General Public License version 3 as published by the Free Software
20 | ** Foundation and appearing in the file LICENSE.LGPL3 included in the
21 | ** packaging of this file. Please review the following information to
22 | ** ensure the GNU Lesser General Public License version 3 requirements
23 | ** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
24 | **
25 | ** GNU General Public License Usage
26 | ** Alternatively, this file may be used under the terms of the GNU
27 | ** General Public License version 2.0 or (at your option) the GNU General
28 | ** Public license version 3 or any later version approved by the KDE Free
29 | ** Qt Foundation. The licenses are as published by the Free Software
30 | ** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
31 | ** included in the packaging of this file. Please review the following
32 | ** information to ensure the GNU General Public License requirements will
33 | ** be met: https://www.gnu.org/licenses/gpl-2.0.html and
34 | ** https://www.gnu.org/licenses/gpl-3.0.html.
35 | **
36 | ** $QT_END_LICENSE$
37 | **
38 | ****************************************************************************/
39 |
40 | #include
41 | #include
42 |
43 | #include "matomotracker.h"
44 |
45 | /*
46 | * The tracking API is documented at:
47 | * https://developer.matomo.org/api-reference/tracking-api
48 | */
49 |
50 | class UrlBuilderTestCase: public QObject {
51 | Q_OBJECT
52 | public:
53 | explicit UrlBuilderTestCase();
54 | private Q_SLOTS:
55 | void init();
56 | void cleanup();
57 | void testDefault();
58 | void testPing();
59 | void testVisit();
60 | void testEvent();
61 | private:
62 | };
63 |
64 |
65 | UrlBuilderTestCase::UrlBuilderTestCase()
66 | : QObject ()
67 | {
68 | }
69 |
70 | void UrlBuilderTestCase::init()
71 | {
72 | }
73 |
74 | void UrlBuilderTestCase::cleanup()
75 | {
76 | }
77 |
78 |
79 | void UrlBuilderTestCase::testDefault()
80 | {
81 | }
82 | void UrlBuilderTestCase::testPing()
83 | {
84 | }
85 |
86 | void UrlBuilderTestCase::testVisit()
87 | {
88 | }
89 |
90 | void UrlBuilderTestCase::testEvent()
91 | {
92 | }
93 |
94 | QTEST_MAIN(UrlBuilderTestCase)
95 |
96 | #include "tst_urlbuilder.moc"
97 |
--------------------------------------------------------------------------------
/examples/analytics_demo/HomePage.qml:
--------------------------------------------------------------------------------
1 | /****************************************************************************
2 | **
3 | ** Copyright (C) 2018, 2019 Luxoft Sweden AB. All rights reserved.
4 | ** Contact: https://www.qt.io/licensing/
5 | **
6 | ** This file is part of the analytics module of the Qt Toolkit.
7 | **
8 | ** $QT_BEGIN_LICENSE:BSD$
9 | ** Commercial License Usage
10 | ** Licensees holding valid commercial Qt licenses may use this file in
11 | ** accordance with the commercial license agreement provided with the
12 | ** Software or, alternatively, in accordance with the terms contained in
13 | ** a written agreement between you and The Qt Company. For licensing terms
14 | ** and conditions see https://www.qt.io/terms-conditions. For further
15 | ** information use the contact form at https://www.qt.io/contact-us.
16 | **
17 | ** BSD License Usage
18 | ** Alternatively, you may use this file under the terms of the BSD license
19 | ** as follows:
20 | **
21 | ** "Redistribution and use in source and binary forms, with or without
22 | ** modification, are permitted provided that the following conditions are
23 | ** met:
24 | ** * Redistributions of source code must retain the above copyright
25 | ** notice, this list of conditions and the following disclaimer.
26 | ** * Redistributions in binary form must reproduce the above copyright
27 | ** notice, this list of conditions and the following disclaimer in
28 | ** the documentation and/or other materials provided with the
29 | ** distribution.
30 | ** * Neither the name of The Qt Company Ltd nor the names of its
31 | ** contributors may be used to endorse or promote products derived
32 | ** from this software without specific prior written permission.
33 | **
34 | **
35 | ** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
36 | ** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
37 | ** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
38 | ** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
39 | ** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
40 | ** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
41 | ** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
42 | ** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
43 | ** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
44 | ** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
45 | ** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
46 | **
47 | ** $QT_END_LICENSE$
48 | **
49 | ****************************************************************************/
50 |
51 | import QtQuick 2.11
52 | import QtQuick.Controls 2.4
53 |
54 | import analytics 1.0
55 |
56 | Page {
57 | id: root
58 | objectName: "home"
59 | title: qsTr("Home")
60 |
61 | Analytics.variables: {
62 | "DeviceType": "Embedded",
63 | "DeviceBrand": "Luxoft",
64 | "DeviceModel": "Vehicle01"
65 | }
66 |
67 | Label {
68 | text: qsTr("The home page")
69 | font.pixelSize: 36
70 | anchors.centerIn: parent
71 | }
72 |
73 | Component.onCompleted: Analytics.sendVisit(root.objectName, "Home", {"1": 66} )
74 | }
75 |
--------------------------------------------------------------------------------
/examples/analytics_demo/main.cpp:
--------------------------------------------------------------------------------
1 | /****************************************************************************
2 | **
3 | ** Copyright (C) 2018, 2019 Luxoft Sweden AB. All rights reserved.
4 | ** Contact: https://www.qt.io/licensing/
5 | **
6 | ** This file is part of the analytics module of the Qt Toolkit.
7 | **
8 | ** $QT_BEGIN_LICENSE:BSD$
9 | ** Commercial License Usage
10 | ** Licensees holding valid commercial Qt licenses may use this file in
11 | ** accordance with the commercial license agreement provided with the
12 | ** Software or, alternatively, in accordance with the terms contained in
13 | ** a written agreement between you and The Qt Company. For licensing terms
14 | ** and conditions see https://www.qt.io/terms-conditions. For further
15 | ** information use the contact form at https://www.qt.io/contact-us.
16 | **
17 | ** BSD License Usage
18 | ** Alternatively, you may use this file under the terms of the BSD license
19 | ** as follows:
20 | **
21 | ** "Redistribution and use in source and binary forms, with or without
22 | ** modification, are permitted provided that the following conditions are
23 | ** met:
24 | ** * Redistributions of source code must retain the above copyright
25 | ** notice, this list of conditions and the following disclaimer.
26 | ** * Redistributions in binary form must reproduce the above copyright
27 | ** notice, this list of conditions and the following disclaimer in
28 | ** the documentation and/or other materials provided with the
29 | ** distribution.
30 | ** * Neither the name of The Qt Company Ltd nor the names of its
31 | ** contributors may be used to endorse or promote products derived
32 | ** from this software without specific prior written permission.
33 | **
34 | **
35 | ** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
36 | ** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
37 | ** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
38 | ** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
39 | ** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
40 | ** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
41 | ** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
42 | ** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
43 | ** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
44 | ** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
45 | ** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
46 | **
47 | ** $QT_END_LICENSE$
48 | **
49 | ****************************************************************************/
50 |
51 | #include
52 | #include
53 |
54 | #include
55 |
56 | int main(int argc, char *argv[])
57 | {
58 | QCoreApplication::setApplicationName("Analytics Demo");
59 | QCoreApplication::setApplicationVersion("1.0");
60 | QCoreApplication::setAttribute(Qt::AA_EnableHighDpiScaling);
61 |
62 | QGuiApplication app(argc, argv);
63 |
64 | QQmlApplicationEngine engine;
65 |
66 | engine.load(QUrl(QStringLiteral("qrc:/Main.qml")));
67 | if (engine.rootObjects().isEmpty())
68 | return -1;
69 |
70 | return app.exec();
71 | }
72 |
--------------------------------------------------------------------------------
/src/plugin/hitbuilder.h:
--------------------------------------------------------------------------------
1 | /****************************************************************************
2 | **
3 | ** Copyright (C) 2019 Luxoft Sweden AB. All rights reserved.
4 | ** Contact: https://www.qt.io/licensing/
5 | **
6 | ** This file is part of the analytics module of the Qt Toolkit.
7 | **
8 | ** $QT_BEGIN_LICENSE:LGPL$
9 | ** Commercial License Usage
10 | ** Licensees holding valid commercial Qt licenses may use this file in
11 | ** accordance with the commercial license agreement provided with the
12 | ** Software or, alternatively, in accordance with the terms contained in
13 | ** a written agreement between you and The Qt Company. For licensing terms
14 | ** and conditions see https://www.qt.io/terms-conditions. For further
15 | ** information use the contact form at https://www.qt.io/contact-us.
16 | **
17 | ** GNU Lesser General Public License Usage
18 | ** Alternatively, this file may be used under the terms of the GNU Lesser
19 | ** General Public License version 3 as published by the Free Software
20 | ** Foundation and appearing in the file LICENSE.LGPL3 included in the
21 | ** packaging of this file. Please review the following information to
22 | ** ensure the GNU Lesser General Public License version 3 requirements
23 | ** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
24 | **
25 | ** GNU General Public License Usage
26 | ** Alternatively, this file may be used under the terms of the GNU
27 | ** General Public License version 2.0 or (at your option) the GNU General
28 | ** Public license version 3 or any later version approved by the KDE Free
29 | ** Qt Foundation. The licenses are as published by the Free Software
30 | ** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
31 | ** included in the packaging of this file. Please review the following
32 | ** information to ensure the GNU General Public License requirements will
33 | ** be met: https://www.gnu.org/licenses/gpl-2.0.html and
34 | ** https://www.gnu.org/licenses/gpl-3.0.html.
35 | **
36 | ** $QT_END_LICENSE$
37 | **
38 | ****************************************************************************/
39 | #pragma once
40 |
41 | #include
42 | #include
43 |
44 | class Context;
45 |
46 | class HitBuilder : public QObject
47 | {
48 | Q_OBJECT
49 | public:
50 | explicit HitBuilder(Context *context, QObject *parent=nullptr);
51 | virtual ~HitBuilder();
52 | virtual void initQuery();
53 | virtual void trackPage(const QString &path, const QString &title);
54 | virtual void trackEvent(const QString &category, const QString &action, const QString &label, const QString &value);
55 | virtual QNetworkReply *sendQuery();
56 | virtual void reset();
57 | void addQueryItem(const QString &key, const QString& value);
58 | void configQueryItem(const QString &key, const QString &defaultValue=QString());
59 | QVariant configValue(const QString& key, const QVariant &defaultValue=QVariant()) const;
60 | QString configString(const QString &key, const QString &defaultValue=QString()) const;
61 | QNetworkReply *httpGet(const QNetworkRequest& request);
62 | QNetworkReply *httpPost(const QNetworkRequest& request, const QByteArray &data);
63 | Context *context() const;
64 | QUrlQuery query() const;
65 | QUrl url() const;
66 |
67 | protected:
68 | Context *m_context;
69 | QUrlQuery m_query;
70 | QUrl m_url;
71 | };
72 |
--------------------------------------------------------------------------------
/tests/auto/tst_config/tst_config.cpp:
--------------------------------------------------------------------------------
1 | /****************************************************************************
2 | **
3 | ** Copyright (C) 2019 Luxoft Sweden AB. All rights reserved.
4 | ** Contact: https://www.qt.io/licensing/
5 | **
6 | ** This file is part of the analytics module of the Qt Toolkit.
7 | **
8 | ** $QT_BEGIN_LICENSE:LGPL$
9 | ** Commercial License Usage
10 | ** Licensees holding valid commercial Qt licenses may use this file in
11 | ** accordance with the commercial license agreement provided with the
12 | ** Software or, alternatively, in accordance with the terms contained in
13 | ** a written agreement between you and The Qt Company. For licensing terms
14 | ** and conditions see https://www.qt.io/terms-conditions. For further
15 | ** information use the contact form at https://www.qt.io/contact-us.
16 | **
17 | ** GNU Lesser General Public License Usage
18 | ** Alternatively, this file may be used under the terms of the GNU Lesser
19 | ** General Public License version 3 as published by the Free Software
20 | ** Foundation and appearing in the file LICENSE.LGPL3 included in the
21 | ** packaging of this file. Please review the following information to
22 | ** ensure the GNU Lesser General Public License version 3 requirements
23 | ** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
24 | **
25 | ** GNU General Public License Usage
26 | ** Alternatively, this file may be used under the terms of the GNU
27 | ** General Public License version 2.0 or (at your option) the GNU General
28 | ** Public license version 3 or any later version approved by the KDE Free
29 | ** Qt Foundation. The licenses are as published by the Free Software
30 | ** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
31 | ** included in the packaging of this file. Please review the following
32 | ** information to ensure the GNU General Public License requirements will
33 | ** be met: https://www.gnu.org/licenses/gpl-2.0.html and
34 | ** https://www.gnu.org/licenses/gpl-3.0.html.
35 | **
36 | ** $QT_END_LICENSE$
37 | **
38 | ****************************************************************************/
39 |
40 | #include
41 | #include
42 |
43 | #include "configutil.h"
44 |
45 | class ConfigTestCase: public QObject {
46 | Q_OBJECT
47 | private Q_SLOTS:
48 | void testResolveConfig();
49 | void testReadConfig();
50 | void testParseConfig();
51 | void testLoadConfig();
52 | };
53 |
54 | void ConfigTestCase::testResolveConfig()
55 | {
56 |
57 | QString path = ConfigUtil::resolvePath("analytics");
58 | QCOMPARE(path, ":/analytics.json");
59 | }
60 |
61 | void ConfigTestCase::testReadConfig()
62 | {
63 | QByteArray data = ConfigUtil::readJSON(":/analytics.json");
64 | QJsonDocument doc = QJsonDocument::fromJson(data);
65 | QVERIFY(doc.isObject());
66 | QCOMPARE(doc.object().value("service"), "matomo");
67 | }
68 |
69 | void ConfigTestCase::testParseConfig()
70 | {
71 | QString path = ConfigUtil::resolvePath("analytics");
72 | QByteArray data = ConfigUtil::readJSON(path);
73 | QJsonObject o = ConfigUtil::parseJSON(data);
74 | QCOMPARE(o.value("service"), "matomo");
75 | }
76 |
77 | void ConfigTestCase::testLoadConfig()
78 | {
79 | QJsonObject o = ConfigUtil::loadJSON("analytics");
80 | QCOMPARE(o.value("service"), "matomo");
81 | }
82 |
83 | QTEST_MAIN(ConfigTestCase)
84 |
85 | #include "tst_config.moc"
86 |
--------------------------------------------------------------------------------
/src/plugin/context.h:
--------------------------------------------------------------------------------
1 | /****************************************************************************
2 | **
3 | ** Copyright (C) 2019 Luxoft Sweden AB. All rights reserved.
4 | ** Contact: https://www.qt.io/licensing/
5 | **
6 | ** This file is part of the analytics module of the Qt Toolkit.
7 | **
8 | ** $QT_BEGIN_LICENSE:LGPL$
9 | ** Commercial License Usage
10 | ** Licensees holding valid commercial Qt licenses may use this file in
11 | ** accordance with the commercial license agreement provided with the
12 | ** Software or, alternatively, in accordance with the terms contained in
13 | ** a written agreement between you and The Qt Company. For licensing terms
14 | ** and conditions see https://www.qt.io/terms-conditions. For further
15 | ** information use the contact form at https://www.qt.io/contact-us.
16 | **
17 | ** GNU Lesser General Public License Usage
18 | ** Alternatively, this file may be used under the terms of the GNU Lesser
19 | ** General Public License version 3 as published by the Free Software
20 | ** Foundation and appearing in the file LICENSE.LGPL3 included in the
21 | ** packaging of this file. Please review the following information to
22 | ** ensure the GNU Lesser General Public License version 3 requirements
23 | ** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
24 | **
25 | ** GNU General Public License Usage
26 | ** Alternatively, this file may be used under the terms of the GNU
27 | ** General Public License version 2.0 or (at your option) the GNU General
28 | ** Public license version 3 or any later version approved by the KDE Free
29 | ** Qt Foundation. The licenses are as published by the Free Software
30 | ** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
31 | ** included in the packaging of this file. Please review the following
32 | ** information to ensure the GNU General Public License requirements will
33 | ** be met: https://www.gnu.org/licenses/gpl-2.0.html and
34 | ** https://www.gnu.org/licenses/gpl-3.0.html.
35 | **
36 | ** $QT_END_LICENSE$
37 | **
38 | ****************************************************************************/
39 | #pragma once
40 |
41 | #include
42 | #include
43 | #include
44 |
45 | class IContext {
46 | public:
47 | virtual ~IContext();
48 | virtual QVariant configValue(const QString &key, const QVariant &defaultValue) const = 0;
49 | virtual QNetworkReply* httpGet(const QNetworkRequest& request) const = 0;
50 | virtual QNetworkReply* httpPost(const QNetworkRequest& request, const QByteArray &data) const = 0;
51 | };
52 |
53 | class Context : public QObject, public IContext
54 | {
55 | Q_OBJECT
56 | public:
57 | Context(QObject *parent=nullptr);
58 | ~Context();
59 | void setConfig(const QVariantMap &config);
60 | void updateConfig(const QVariantMap &o);
61 | QVariantMap config() const;
62 | void setNetwork(QNetworkAccessManager *network);
63 | QNetworkAccessManager *network() const;
64 | bool hasNetwork() const;
65 | QVariant configValue(const QString &key, const QVariant &defaultValue=QVariant()) const;
66 | QString configString(const QString &key, const QString &defaultValue=QString()) const;
67 | QNetworkReply* httpGet(const QNetworkRequest& request) const;
68 | QNetworkReply* httpPost(const QNetworkRequest& request, const QByteArray &data) const;
69 | void discoverNetwork(QObject *object);
70 | void onReplyFinished(QNetworkReply *reply);
71 | private:
72 | QVariantMap m_config;
73 | QNetworkAccessManager *m_network;
74 | };
75 |
--------------------------------------------------------------------------------
/src/plugin/matomobuilder.cpp:
--------------------------------------------------------------------------------
1 | /****************************************************************************
2 | **
3 | ** Copyright (C) 2019 Luxoft Sweden AB. All rights reserved.
4 | ** Contact: https://www.qt.io/licensing/
5 | **
6 | ** This file is part of the analytics module of the Qt Toolkit.
7 | **
8 | ** $QT_BEGIN_LICENSE:LGPL$
9 | ** Commercial License Usage
10 | ** Licensees holding valid commercial Qt licenses may use this file in
11 | ** accordance with the commercial license agreement provided with the
12 | ** Software or, alternatively, in accordance with the terms contained in
13 | ** a written agreement between you and The Qt Company. For licensing terms
14 | ** and conditions see https://www.qt.io/terms-conditions. For further
15 | ** information use the contact form at https://www.qt.io/contact-us.
16 | **
17 | ** GNU Lesser General Public License Usage
18 | ** Alternatively, this file may be used under the terms of the GNU Lesser
19 | ** General Public License version 3 as published by the Free Software
20 | ** Foundation and appearing in the file LICENSE.LGPL3 included in the
21 | ** packaging of this file. Please review the following information to
22 | ** ensure the GNU Lesser General Public License version 3 requirements
23 | ** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
24 | **
25 | ** GNU General Public License Usage
26 | ** Alternatively, this file may be used under the terms of the GNU
27 | ** General Public License version 2.0 or (at your option) the GNU General
28 | ** Public license version 3 or any later version approved by the KDE Free
29 | ** Qt Foundation. The licenses are as published by the Free Software
30 | ** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
31 | ** included in the packaging of this file. Please review the following
32 | ** information to ensure the GNU General Public License requirements will
33 | ** be met: https://www.gnu.org/licenses/gpl-2.0.html and
34 | ** https://www.gnu.org/licenses/gpl-3.0.html.
35 | **
36 | ** $QT_END_LICENSE$
37 | **
38 | ****************************************************************************/
39 | #include "matomobuilder.h"
40 |
41 | #include "context.h"
42 |
43 | /*!
44 | * \class MatomoBuilder
45 | * \inmodule QtAnalytics
46 | * \brief Plugin for the matomo tracking platform.
47 | */
48 |
49 | // See https://developer.matomo.org/api-reference/tracking-api
50 | const QString MatomoBuilder::SITE_ID("idsite");
51 | const QString MatomoBuilder::ACTION_NAME("action_name");
52 | const QString MatomoBuilder::ACTION_URL("url");
53 | const QString MatomoBuilder::API_VERSION("apiv");
54 | const QString MatomoBuilder::EVENT_CATEGORY("e_c");
55 | const QString MatomoBuilder::EVENT_ACTION("e_a");
56 | const QString MatomoBuilder::EVENT_NAME("e_n");
57 | const QString MatomoBuilder::EVENT_VALUE("e_v");
58 | const QString MatomoBuilder::RECORDING("rec");
59 |
60 |
61 | MatomoBuilder::MatomoBuilder(Context *context, QObject *parent)
62 | : HitBuilder(context, parent)
63 | {
64 | }
65 |
66 | MatomoBuilder::~MatomoBuilder()
67 | {
68 | }
69 |
70 | void MatomoBuilder::initQuery()
71 | {
72 | HitBuilder::initQuery();
73 | addQueryItem(API_VERSION, "1");
74 | configQueryItem(SITE_ID);
75 | addQueryItem(RECORDING, "1");
76 | }
77 |
78 | void MatomoBuilder::trackPage(const QString &path, const QString &title)
79 | {
80 | QString domain = configString("domain");
81 | QString url = QString("%1/%2").arg(domain).arg(path);
82 | addQueryItem(ACTION_URL, url);
83 | addQueryItem(ACTION_NAME, title);
84 | }
85 |
86 | void MatomoBuilder::trackEvent(const QString &category, const QString &action, const QString &label, const QString &value)
87 | {
88 | addQueryItem(EVENT_CATEGORY, category);
89 | addQueryItem(EVENT_ACTION, action);
90 | if (!label.isNull()) {
91 | addQueryItem(EVENT_NAME, label);
92 | }
93 | if (!value.isNull()) {
94 | addQueryItem(EVENT_VALUE, value);
95 | }
96 | }
97 |
--------------------------------------------------------------------------------
/tests/auto/tst_matomo/tst_matomo.cpp:
--------------------------------------------------------------------------------
1 | /****************************************************************************
2 | **
3 | ** Copyright (C) 2019 Luxoft Sweden AB. All rights reserved.
4 | ** Contact: https://www.qt.io/licensing/
5 | **
6 | ** This file is part of the analytics module of the Qt Toolkit.
7 | **
8 | ** $QT_BEGIN_LICENSE:LGPL$
9 | ** Commercial License Usage
10 | ** Licensees holding valid commercial Qt licenses may use this file in
11 | ** accordance with the commercial license agreement provided with the
12 | ** Software or, alternatively, in accordance with the terms contained in
13 | ** a written agreement between you and The Qt Company. For licensing terms
14 | ** and conditions see https://www.qt.io/terms-conditions. For further
15 | ** information use the contact form at https://www.qt.io/contact-us.
16 | **
17 | ** GNU Lesser General Public License Usage
18 | ** Alternatively, this file may be used under the terms of the GNU Lesser
19 | ** General Public License version 3 as published by the Free Software
20 | ** Foundation and appearing in the file LICENSE.LGPL3 included in the
21 | ** packaging of this file. Please review the following information to
22 | ** ensure the GNU Lesser General Public License version 3 requirements
23 | ** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
24 | **
25 | ** GNU General Public License Usage
26 | ** Alternatively, this file may be used under the terms of the GNU
27 | ** General Public License version 2.0 or (at your option) the GNU General
28 | ** Public license version 3 or any later version approved by the KDE Free
29 | ** Qt Foundation. The licenses are as published by the Free Software
30 | ** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
31 | ** included in the packaging of this file. Please review the following
32 | ** information to ensure the GNU General Public License requirements will
33 | ** be met: https://www.gnu.org/licenses/gpl-2.0.html and
34 | ** https://www.gnu.org/licenses/gpl-3.0.html.
35 | **
36 | ** $QT_END_LICENSE$
37 | **
38 | ****************************************************************************/
39 |
40 | #include
41 | #include
42 |
43 | #include "matomobuilder.h"
44 | #include "context.h"
45 |
46 | class MatomoTestCase: public QObject {
47 | Q_OBJECT
48 | private slots:
49 | void init();
50 | void testRequired();
51 | void testTrackPage();
52 | void testTrackEvent();
53 |
54 | };
55 |
56 | void MatomoTestCase::init()
57 | {
58 | qDebug() << "init";
59 | }
60 |
61 | void MatomoTestCase::testRequired()
62 | {
63 | QVariantMap o{
64 | {"idsite", "123"},
65 | {"rec", "1"},
66 | };
67 | QScopedPointer ctx(new Context(this));
68 | ctx->setConfig(o);
69 | QScopedPointer b(new MatomoBuilder(ctx.data()));
70 | b->initQuery();
71 | QUrlQuery query = b->query();
72 | QCOMPARE("123", query.queryItemValue(MatomoBuilder::SITE_ID));
73 | QCOMPARE("1", query.queryItemValue(MatomoBuilder::RECORDING));
74 | }
75 |
76 | void MatomoTestCase::testTrackPage()
77 | {
78 | QScopedPointer ctx(new Context(this));
79 | QScopedPointer b(new MatomoBuilder(ctx.data()));
80 | b->initQuery();
81 | b->trackPage("/home", "click");
82 | QUrlQuery query = b->query();
83 | qDebug() << query.toString();
84 | QCOMPARE("/home", query.queryItemValue(MatomoBuilder::ACTION_URL));
85 | QCOMPARE("click", query.queryItemValue(MatomoBuilder::ACTION_NAME));
86 | }
87 |
88 | void MatomoTestCase::testTrackEvent()
89 | {
90 | QScopedPointer ctx(new Context(this));
91 | QScopedPointer b(new MatomoBuilder(ctx.data()));
92 | b->initQuery();
93 | b->trackEvent("category", "action", QString(), QString());
94 | QUrlQuery query = b->query();
95 | qDebug() << query.toString();
96 | QCOMPARE("category", query.queryItemValue(MatomoBuilder::EVENT_CATEGORY));
97 | QCOMPARE("action", query.queryItemValue(MatomoBuilder::EVENT_ACTION));
98 | }
99 |
100 | QTEST_MAIN(MatomoTestCase)
101 |
102 | #include "tst_matomo.moc"
103 |
--------------------------------------------------------------------------------
/src/plugin/googlebuilder.cpp:
--------------------------------------------------------------------------------
1 | /****************************************************************************
2 | **
3 | ** Copyright (C) 2019 Luxoft Sweden AB. All rights reserved.
4 | ** Contact: https://www.qt.io/licensing/
5 | **
6 | ** This file is part of the analytics module of the Qt Toolkit.
7 | **
8 | ** $QT_BEGIN_LICENSE:LGPL$
9 | ** Commercial License Usage
10 | ** Licensees holding valid commercial Qt licenses may use this file in
11 | ** accordance with the commercial license agreement provided with the
12 | ** Software or, alternatively, in accordance with the terms contained in
13 | ** a written agreement between you and The Qt Company. For licensing terms
14 | ** and conditions see https://www.qt.io/terms-conditions. For further
15 | ** information use the contact form at https://www.qt.io/contact-us.
16 | **
17 | ** GNU Lesser General Public License Usage
18 | ** Alternatively, this file may be used under the terms of the GNU Lesser
19 | ** General Public License version 3 as published by the Free Software
20 | ** Foundation and appearing in the file LICENSE.LGPL3 included in the
21 | ** packaging of this file. Please review the following information to
22 | ** ensure the GNU Lesser General Public License version 3 requirements
23 | ** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
24 | **
25 | ** GNU General Public License Usage
26 | ** Alternatively, this file may be used under the terms of the GNU
27 | ** General Public License version 2.0 or (at your option) the GNU General
28 | ** Public license version 3 or any later version approved by the KDE Free
29 | ** Qt Foundation. The licenses are as published by the Free Software
30 | ** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
31 | ** included in the packaging of this file. Please review the following
32 | ** information to ensure the GNU General Public License requirements will
33 | ** be met: https://www.gnu.org/licenses/gpl-2.0.html and
34 | ** https://www.gnu.org/licenses/gpl-3.0.html.
35 | **
36 | ** $QT_END_LICENSE$
37 | **
38 | ****************************************************************************/
39 | #include "googlebuilder.h"
40 |
41 | #include "context.h"
42 |
43 |
44 | /*!
45 | * \class GoogleBuilder
46 | * \inmodule QtAnalytics
47 | * \brief Plugin for the google tracking platform.
48 | */
49 |
50 | // See https://developers.google.com/analytics/devguides/collection/protocol/v1/
51 |
52 | const QString GoogleBuilder::TRACKER_ID("tid");
53 | const QString GoogleBuilder::VERSION("v");
54 | const QString GoogleBuilder::DATA_SOURCE("ds");
55 | const QString GoogleBuilder::DOCUMENT_PATH("dp");
56 | const QString GoogleBuilder::DOCUMENT_TITLE("dt");
57 | const QString GoogleBuilder::EVENT_CATEGORY("ec");
58 | const QString GoogleBuilder::EVENT_ACTION("ea");
59 | const QString GoogleBuilder::EVENT_LABEL("el");
60 | const QString GoogleBuilder::EVENT_VALUE("ev");
61 | const QString GoogleBuilder::HIT_TYPE("t");
62 | const QString GoogleBuilder::CLIENT_ID("cid");
63 |
64 | GoogleBuilder::GoogleBuilder(Context *context, QObject *parent)
65 | : HitBuilder(context, parent)
66 | {
67 | }
68 |
69 | GoogleBuilder::~GoogleBuilder()
70 | {
71 | }
72 |
73 | void GoogleBuilder::initQuery()
74 | {
75 | const QString& server = configString("server", "https://www.google-analytics.com/collect");
76 | m_url = QUrl(server);
77 | addQueryItem(VERSION, "1");
78 | configQueryItem(TRACKER_ID);
79 | configQueryItem(CLIENT_ID);
80 | }
81 |
82 | void GoogleBuilder::trackPage(const QString &path, const QString &title)
83 | {
84 | addQueryItem(HIT_TYPE, "pageview");
85 | addQueryItem(DOCUMENT_PATH, path);
86 | addQueryItem(DOCUMENT_TITLE, title);
87 | }
88 |
89 | void GoogleBuilder::trackEvent(const QString &category, const QString &action, const QString &label, const QString &value)
90 | {
91 | addQueryItem(EVENT_CATEGORY, category);
92 | addQueryItem(EVENT_ACTION, action);
93 | if (!label.isNull()) {
94 | addQueryItem(EVENT_LABEL, label);
95 | }
96 | if (!value.isNull()) {
97 | addQueryItem(EVENT_VALUE, value);
98 | }
99 | }
100 |
101 | QNetworkReply *GoogleBuilder::sendQuery()
102 | {
103 | return HitBuilder::sendQuery();
104 | }
105 |
--------------------------------------------------------------------------------
/tests/auto/tst_analytics/tst_analytics.cpp:
--------------------------------------------------------------------------------
1 | /****************************************************************************
2 | **
3 | ** Copyright (C) 2019 Luxoft Sweden AB. All rights reserved.
4 | ** Contact: https://www.qt.io/licensing/
5 | **
6 | ** This file is part of the analytics module of the Qt Toolkit.
7 | **
8 | ** $QT_BEGIN_LICENSE:LGPL$
9 | ** Commercial License Usage
10 | ** Licensees holding valid commercial Qt licenses may use this file in
11 | ** accordance with the commercial license agreement provided with the
12 | ** Software or, alternatively, in accordance with the terms contained in
13 | ** a written agreement between you and The Qt Company. For licensing terms
14 | ** and conditions see https://www.qt.io/terms-conditions. For further
15 | ** information use the contact form at https://www.qt.io/contact-us.
16 | **
17 | ** GNU Lesser General Public License Usage
18 | ** Alternatively, this file may be used under the terms of the GNU Lesser
19 | ** General Public License version 3 as published by the Free Software
20 | ** Foundation and appearing in the file LICENSE.LGPL3 included in the
21 | ** packaging of this file. Please review the following information to
22 | ** ensure the GNU Lesser General Public License version 3 requirements
23 | ** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
24 | **
25 | ** GNU General Public License Usage
26 | ** Alternatively, this file may be used under the terms of the GNU
27 | ** General Public License version 2.0 or (at your option) the GNU General
28 | ** Public license version 3 or any later version approved by the KDE Free
29 | ** Qt Foundation. The licenses are as published by the Free Software
30 | ** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
31 | ** included in the packaging of this file. Please review the following
32 | ** information to ensure the GNU General Public License requirements will
33 | ** be met: https://www.gnu.org/licenses/gpl-2.0.html and
34 | ** https://www.gnu.org/licenses/gpl-3.0.html.
35 | **
36 | ** $QT_END_LICENSE$
37 | **
38 | ****************************************************************************/
39 |
40 | #include
41 | #include
42 |
43 | #include "analytics.h"
44 | #include "hitbuilder.h"
45 | #include "googlebuilder.h"
46 | #include "matomobuilder.h"
47 | #include "context.h"
48 |
49 | class AnalyticsTestCase: public QObject {
50 | Q_OBJECT
51 | private slots:
52 | void testEmptyTracker();
53 | void testGoogleTracker();
54 | void testMatomoTracker();
55 | void testWrongTracker();
56 | void testServerConfig();
57 | };
58 |
59 | void AnalyticsTestCase::testEmptyTracker()
60 | {
61 | QScopedPointer a(new Analytics());
62 | HitBuilder * builder = a->getBuilder();
63 | QCOMPARE(nullptr, builder);
64 | }
65 |
66 | void AnalyticsTestCase::testGoogleTracker()
67 | {
68 | QScopedPointer a(new Analytics());
69 | QVariantMap o{
70 | {"tracker", "google"},
71 | };
72 | a->context()->updateConfig(o);
73 | HitBuilder * builder = a->getBuilder();
74 | QVERIFY(qobject_cast(builder));
75 | }
76 |
77 | void AnalyticsTestCase::testMatomoTracker()
78 | {
79 | QScopedPointer a(new Analytics());
80 | QVariantMap o{
81 | {"tracker", "matomo"},
82 | };
83 | a->context()->updateConfig(o);
84 | HitBuilder * builder = a->getBuilder();
85 | QVERIFY(qobject_cast(builder));
86 |
87 | }
88 |
89 | void AnalyticsTestCase::testWrongTracker()
90 | {
91 | QScopedPointer a(new Analytics());
92 | QVariantMap o{
93 | {"tracker", "unknown"},
94 | };
95 | a->context()->updateConfig(o);
96 | HitBuilder * builder = a->getBuilder();
97 | QCOMPARE(nullptr, builder);
98 |
99 | }
100 |
101 | void AnalyticsTestCase::testServerConfig()
102 | {
103 | QScopedPointer a(new Analytics());
104 | QVariantMap o{
105 | {"tracker", "matomo"},
106 | {"server", "http://localhost:8000"},
107 | };
108 | a->context()->updateConfig(o);
109 | HitBuilder *builder = a->getBuilder();
110 | QVERIFY(qobject_cast(builder));
111 | qDebug() << "003";
112 | QCOMPARE(builder->context()->configString("server"), "http://localhost:8000");
113 | }
114 |
115 |
116 | QTEST_MAIN(AnalyticsTestCase)
117 |
118 | #include "tst_analytics.moc"
119 |
--------------------------------------------------------------------------------
/src/plugin/analytics.h:
--------------------------------------------------------------------------------
1 | /****************************************************************************
2 | **
3 | ** Copyright (C) 2019 Luxoft Sweden AB. All rights reserved.
4 | ** Contact: https://www.qt.io/licensing/
5 | **
6 | ** This file is part of the analytics module of the Qt Toolkit.
7 | **
8 | ** $QT_BEGIN_LICENSE:LGPL$
9 | ** Commercial License Usage
10 | ** Licensees holding valid commercial Qt licenses may use this file in
11 | ** accordance with the commercial license agreement provided with the
12 | ** Software or, alternatively, in accordance with the terms contained in
13 | ** a written agreement between you and The Qt Company. For licensing terms
14 | ** and conditions see https://www.qt.io/terms-conditions. For further
15 | ** information use the contact form at https://www.qt.io/contact-us.
16 | **
17 | ** GNU Lesser General Public License Usage
18 | ** Alternatively, this file may be used under the terms of the GNU Lesser
19 | ** General Public License version 3 as published by the Free Software
20 | ** Foundation and appearing in the file LICENSE.LGPL3 included in the
21 | ** packaging of this file. Please review the following information to
22 | ** ensure the GNU Lesser General Public License version 3 requirements
23 | ** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
24 | **
25 | ** GNU General Public License Usage
26 | ** Alternatively, this file may be used under the terms of the GNU
27 | ** General Public License version 2.0 or (at your option) the GNU General
28 | ** Public license version 3 or any later version approved by the KDE Free
29 | ** Qt Foundation. The licenses are as published by the Free Software
30 | ** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
31 | ** included in the packaging of this file. Please review the following
32 | ** information to ensure the GNU General Public License requirements will
33 | ** be met: https://www.gnu.org/licenses/gpl-2.0.html and
34 | ** https://www.gnu.org/licenses/gpl-3.0.html.
35 | **
36 | ** $QT_END_LICENSE$
37 | **
38 | ****************************************************************************/
39 | #pragma once
40 |
41 | #include
42 | #include
43 | #include
44 |
45 | class Context;
46 | class HitBuilder;
47 | class Analytics;
48 |
49 | class AnalyticsAttached : public QObject
50 | {
51 | Q_OBJECT
52 |
53 | /**
54 | * In QML it shall look like
55 | * Analytics.customVariables: {
56 | * "myVariable1": "myValue1",
57 | * "myVariable2": "myValue2"
58 | * }
59 | */
60 | Q_PROPERTY(QVariantMap variables READ variables WRITE setVariables NOTIFY variablesChanged)
61 | public:
62 | AnalyticsAttached(QObject *parent = nullptr);
63 | virtual ~AnalyticsAttached();
64 |
65 | Q_INVOKABLE void sendPing();
66 | Q_INVOKABLE void sendVisit(const QString &path, const QString &name);
67 | Q_INVOKABLE void sendEvent(const QString &category, const QString &action, const QString &name, const QString &value);
68 |
69 | QVariantMap variables() const { return m_variables; }
70 |
71 | public slots:
72 | void setVariables(QVariantMap variables);
73 |
74 | signals:
75 | void variablesChanged();
76 |
77 | private:
78 | QVariantMap m_variables;
79 | };
80 |
81 |
82 | class Analytics : public QObject
83 | {
84 | Q_OBJECT
85 | Q_DISABLE_COPY(Analytics)
86 | public:
87 | explicit Analytics(QObject *parent = nullptr);
88 | virtual ~Analytics();
89 |
90 | static Analytics *instance(QObject *attached);
91 | static AnalyticsAttached* qmlAttachedProperties(QObject* );
92 | HitBuilder *getBuilder();
93 | void sendPing();
94 | void sendVisit(const QString &path, const QString &name);
95 | void sendEvent(const QString &category, const QString &action,
96 | const QString &name, const QString &value);
97 | Context *context() const;
98 |
99 | private:
100 | // QString userAgent() const;
101 | // QString userLanguage() const;
102 | void dispatch(HitBuilder *builder);
103 | void processQueue();
104 | void onReplyFinished(QNetworkReply* reply);
105 | signals:
106 | void sendHitRequest(const QUrl& url);
107 | void replyFinished(QNetworkReply* reply);
108 | private:
109 | static Analytics *s_instance;
110 | Context *m_context;
111 | HitBuilder *m_builder;
112 | };
113 |
114 |
115 |
116 | QML_DECLARE_TYPEINFO(Analytics, QML_HAS_ATTACHED_PROPERTIES)
117 |
--------------------------------------------------------------------------------
/tests/auto/tst_google/tst_google.cpp:
--------------------------------------------------------------------------------
1 | /****************************************************************************
2 | **
3 | ** Copyright (C) 2019 Luxoft Sweden AB. All rights reserved.
4 | ** Contact: https://www.qt.io/licensing/
5 | **
6 | ** This file is part of the analytics module of the Qt Toolkit.
7 | **
8 | ** $QT_BEGIN_LICENSE:LGPL$
9 | ** Commercial License Usage
10 | ** Licensees holding valid commercial Qt licenses may use this file in
11 | ** accordance with the commercial license agreement provided with the
12 | ** Software or, alternatively, in accordance with the terms contained in
13 | ** a written agreement between you and The Qt Company. For licensing terms
14 | ** and conditions see https://www.qt.io/terms-conditions. For further
15 | ** information use the contact form at https://www.qt.io/contact-us.
16 | **
17 | ** GNU Lesser General Public License Usage
18 | ** Alternatively, this file may be used under the terms of the GNU Lesser
19 | ** General Public License version 3 as published by the Free Software
20 | ** Foundation and appearing in the file LICENSE.LGPL3 included in the
21 | ** packaging of this file. Please review the following information to
22 | ** ensure the GNU Lesser General Public License version 3 requirements
23 | ** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
24 | **
25 | ** GNU General Public License Usage
26 | ** Alternatively, this file may be used under the terms of the GNU
27 | ** General Public License version 2.0 or (at your option) the GNU General
28 | ** Public license version 3 or any later version approved by the KDE Free
29 | ** Qt Foundation. The licenses are as published by the Free Software
30 | ** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
31 | ** included in the packaging of this file. Please review the following
32 | ** information to ensure the GNU General Public License requirements will
33 | ** be met: https://www.gnu.org/licenses/gpl-2.0.html and
34 | ** https://www.gnu.org/licenses/gpl-3.0.html.
35 | **
36 | ** $QT_END_LICENSE$
37 | **
38 | ****************************************************************************/
39 |
40 | #include
41 | #include
42 |
43 | #include "googlebuilder.h"
44 | #include "context.h"
45 |
46 | class GoogleTestCase: public QObject {
47 | Q_OBJECT
48 | private slots:
49 | void testEmpty();
50 | void testTrackPage();
51 | void testTrackEvent();
52 | };
53 |
54 |
55 | void GoogleTestCase::testEmpty()
56 | {
57 | QVariantMap o{
58 | {"tid", "12345"},
59 | };
60 | QScopedPointer ctx(new Context(this));
61 | ctx->setConfig(o);
62 | QScopedPointer b(new GoogleBuilder(ctx.data()));
63 | b->initQuery();
64 | QUrlQuery query = b->query();
65 | QCOMPARE("1", query.queryItemValue(GoogleBuilder::VERSION));
66 | QCOMPARE("12345", query.queryItemValue(GoogleBuilder::TRACKER_ID));
67 | ctx->deleteLater();
68 | }
69 |
70 | void GoogleTestCase::testTrackPage()
71 | {
72 | QScopedPointer ctx(new Context(this));
73 | QScopedPointer b(new GoogleBuilder(ctx.data()));
74 | QVariantMap o{
75 | {"tid", "12345"},
76 | {"cid", "44144"},
77 | };
78 | ctx->updateConfig(o);
79 | b->initQuery();
80 | b->trackPage("/home", "click");
81 | QUrlQuery query = b->query();
82 | QCOMPARE("12345", query.queryItemValue("tid"));
83 | QCOMPARE("44144", query.queryItemValue("cid"));
84 | QCOMPARE("1", query.queryItemValue("v"));
85 | QCOMPARE("pageview", query.queryItemValue("t"));
86 | QCOMPARE("/home", query.queryItemValue("dp"));
87 | QCOMPARE(b->url().toString(), "https://www.google-analytics.com/collect");
88 | }
89 |
90 | void GoogleTestCase::testTrackEvent()
91 | {
92 | QScopedPointer ctx(new Context(this));
93 | QVariantMap o{
94 | {"tid", "12345"},
95 | {"cid", "44144"},
96 | };
97 | ctx->updateConfig(o);
98 | QScopedPointer b(new GoogleBuilder(ctx.data()));
99 | b->trackEvent("cat", "click", QString(), QString());
100 | b->initQuery();
101 | QUrlQuery query = b->query();
102 | QCOMPARE("12345", query.queryItemValue("tid"));
103 | QCOMPARE("44144", query.queryItemValue("cid"));
104 | QCOMPARE("cat", query.queryItemValue("ec"));
105 | QCOMPARE("click", query.queryItemValue("ea"));
106 | QCOMPARE(b->url().toString(), "https://www.google-analytics.com/collect");
107 | }
108 |
109 | QTEST_MAIN(GoogleTestCase)
110 |
111 | #include "tst_google.moc"
112 |
--------------------------------------------------------------------------------
/src/plugin/hitbuilder.cpp:
--------------------------------------------------------------------------------
1 | /****************************************************************************
2 | **
3 | ** Copyright (C) 2019 Luxoft Sweden AB. All rights reserved.
4 | ** Contact: https://www.qt.io/licensing/
5 | **
6 | ** This file is part of the analytics module of the Qt Toolkit.
7 | **
8 | ** $QT_BEGIN_LICENSE:LGPL$
9 | ** Commercial License Usage
10 | ** Licensees holding valid commercial Qt licenses may use this file in
11 | ** accordance with the commercial license agreement provided with the
12 | ** Software or, alternatively, in accordance with the terms contained in
13 | ** a written agreement between you and The Qt Company. For licensing terms
14 | ** and conditions see https://www.qt.io/terms-conditions. For further
15 | ** information use the contact form at https://www.qt.io/contact-us.
16 | **
17 | ** GNU Lesser General Public License Usage
18 | ** Alternatively, this file may be used under the terms of the GNU Lesser
19 | ** General Public License version 3 as published by the Free Software
20 | ** Foundation and appearing in the file LICENSE.LGPL3 included in the
21 | ** packaging of this file. Please review the following information to
22 | ** ensure the GNU Lesser General Public License version 3 requirements
23 | ** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
24 | **
25 | ** GNU General Public License Usage
26 | ** Alternatively, this file may be used under the terms of the GNU
27 | ** General Public License version 2.0 or (at your option) the GNU General
28 | ** Public license version 3 or any later version approved by the KDE Free
29 | ** Qt Foundation. The licenses are as published by the Free Software
30 | ** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
31 | ** included in the packaging of this file. Please review the following
32 | ** information to ensure the GNU General Public License requirements will
33 | ** be met: https://www.gnu.org/licenses/gpl-2.0.html and
34 | ** https://www.gnu.org/licenses/gpl-3.0.html.
35 | **
36 | ** $QT_END_LICENSE$
37 | **
38 | ****************************************************************************/
39 |
40 | #include "hitbuilder.h"
41 | #include "context.h"
42 |
43 | /*!
44 | * \class HitBuilder
45 | * \inmodule QtAnalytics
46 | * \brief An abstract interface for tracking platforms.
47 | */
48 |
49 | HitBuilder::HitBuilder(Context *context, QObject *parent)
50 | : QObject(parent)
51 | , m_context(context)
52 | {
53 | }
54 |
55 | HitBuilder::~HitBuilder()
56 | {
57 | }
58 |
59 | void HitBuilder::initQuery()
60 | {
61 | m_url = QUrl(configString("server"));
62 | }
63 |
64 | void HitBuilder::trackPage(const QString &/*path*/, const QString &/*title*/)
65 | {
66 | }
67 |
68 | void HitBuilder::trackEvent(const QString &/*category*/, const QString &/*action*/, const QString &/*label*/, const QString &/*value*/)
69 | {
70 | }
71 |
72 | QNetworkReply *HitBuilder::sendQuery()
73 | {
74 | QUrl url(m_url);
75 | qDebug() << "url to request: " << url;
76 | url.setQuery(query());
77 | qDebug() << "url to request: " << url;
78 | QNetworkRequest request(url);
79 | // by default use http get requests
80 | return httpGet(request);
81 | }
82 |
83 | void HitBuilder::reset()
84 | {
85 | m_query.clear();
86 | m_url.clear();
87 | }
88 |
89 |
90 | void HitBuilder::addQueryItem(const QString &key, const QString &value)
91 | {
92 | if (value.isEmpty()) {
93 | return;
94 | }
95 | m_query.addQueryItem(key, value);
96 | }
97 |
98 | void HitBuilder::configQueryItem(const QString &key, const QString &defaultValue)
99 | {
100 | QString value = configString(key, defaultValue);
101 | if (value.isEmpty()) {
102 | return;
103 | }
104 | m_query.addQueryItem(key, value);
105 | }
106 |
107 | QVariant HitBuilder::configValue(const QString &key, const QVariant &defaultValue) const
108 | {
109 | return context()->configValue(key, defaultValue);
110 | }
111 |
112 | QString HitBuilder::configString(const QString &key, const QString &defaultValue) const
113 | {
114 | return context()->configString(key, defaultValue);
115 | }
116 |
117 | QNetworkReply *HitBuilder::httpGet(const QNetworkRequest &request)
118 | {
119 | return context()->httpGet(request);
120 | }
121 |
122 | QNetworkReply *HitBuilder::httpPost(const QNetworkRequest &request, const QByteArray &data)
123 | {
124 | return context()->httpPost(request, data);
125 | }
126 |
127 | Context *HitBuilder::context() const
128 | {
129 | return m_context;
130 | }
131 |
132 | QUrlQuery HitBuilder::query() const
133 | {
134 | return m_query;
135 | }
136 |
137 | QUrl HitBuilder::url() const
138 | {
139 | return m_url;
140 | }
141 |
142 |
--------------------------------------------------------------------------------
/doc/qtanalytics-concepts.qdoc:
--------------------------------------------------------------------------------
1 | /****************************************************************************
2 | **
3 | ** Copyright (C) 2019 Luxoft Sweden AB
4 | **
5 | ** Contact: https://www.qt.io/licensing/
6 | **
7 | ** This file is part of the QtAnalytics plugin.
8 | **
9 | ** $QT_BEGIN_LICENSE:GPL-QTAS$
10 | ** Commercial License Usage
11 | ** Licensees holding valid commercial Qt Automotive Suite licenses may use
12 | ** this file in accordance with the commercial license agreement provided
13 | ** with the Software or, alternatively, in accordance with the terms
14 | ** contained in a written agreement between you and The Qt Company. For
15 | ** licensing terms and conditions see https://www.qt.io/terms-conditions.
16 | ** For further information use the contact form at https://www.qt.io/contact-us.
17 | **
18 | ** GNU General Public License Usage
19 | ** Alternatively, this file may be used under the terms of the GNU
20 | ** General Public License version 3 or (at your option) any later version
21 | ** approved by the KDE Free Qt Foundation. The licenses are as published by
22 | ** the Free Software Foundation and appearing in the file LICENSE.GPL3
23 | ** included in the packaging of this file. Please review the following
24 | ** information to ensure the GNU General Public License requirements will
25 | ** be met: https://www.gnu.org/licenses/gpl-3.0.html.
26 | **
27 | ** $QT_END_LICENSE$
28 | **
29 | ** SPDX-License-Identifier: GPL-3.0
30 | **
31 | ****************************************************************************/
32 |
33 | /*!
34 |
35 | \page qtanalytics-concepts.html
36 | \title Concepts
37 |
38 | \section1 Tracking
39 |
40 | What do we want to track?
41 |
42 | We want mostly track page views and actions, as also general device
43 | information.
44 |
45 | \section1 ConfigUtil
46 |
47 | \l ConfigUtil provides utility function to load and parse JSON based
48 | configuration files. The file lookup is based on a given name (e.g.
49 | \c {analytics}) and the lookup looks first for an environment variable
50 | called \c {ANALYTICS_CONFIG}, and if exists will take that path. If not
51 | then a file will be looked in the resource file named \c {:/analytics.json}.
52 | If this also not exists a warning is printed and the configuration is
53 | not successful.
54 |
55 | \section1 \l {Context} {Context}
56 |
57 | The \l Context object provides the methods available to the builders. It is
58 | reused across all hits. It provides a configuration value access as also network
59 | HTTP GET/POST methods.
60 |
61 | In general it should be possible to have a Context interface which could
62 | then be used inside the hit builders and by this making them more
63 | testable.
64 |
65 | The configuration is stored into a JSON file (e.g. analytics.json) which
66 | is looked up using the ConfigUtil functions.
67 |
68 | \sa {Context}, {IContext}
69 |
70 | \section1 \l {HitBuilder} {Hit Builder}
71 |
72 | The hit builder is an interface used to collect the various tracking
73 | information and then send the information away using a network.
74 |
75 | The hit builder has a common high level API to be shared across specific
76 | builders.
77 |
78 | \list
79 | \li send build trackVisit trackEvent
80 | \endlist
81 |
82 | \sa {HitBuilder}, {MatomoBuilder}, {GoogleBuilder}
83 |
84 | \section1 \l {MatomoBuilder} {Matomo Hit Builder}
85 |
86 | \list
87 | \li \l {https://developer.matomo.org/api-reference/tracking-api}
88 | \endlist
89 |
90 | The Matomo hit builder is enabled by setting tracker to "matomo" in the
91 | configuration file. The builder support visit and event tracking. It
92 | uses a GET request to the server URL to send the tracking information.
93 |
94 | \section1 \l {GoogleBuilder} {Google Analytics Tracking}
95 |
96 | \list
97 | \li \l {https://developers.google.com/analytics/devguides/collection/protocol/v1/}
98 | \li \l {https://ga-dev-tools.appspot.com/hit-builder/}
99 | \endlist
100 |
101 | The Google hit builder is enabled by setting the tracker to "google". It
102 | uses the Google measurements protocol.
103 |
104 | \section1 Configuration Format
105 |
106 | The configuration is stored in JSON documents. The document keys change with the chosen \c tracker (e.g. \c matomo, \c google).
107 |
108 | \note It is not possible currently to support several trackers.
109 |
110 | \section2 Google Configuration
111 |
112 | \code
113 | {
114 | "tracker": "google"
115 | "tid": "UA-555555555-5",
116 | "cid": "555",
117 | "deviceResolution": "1280x800",
118 | "domain": "http://example.org",
119 | }
120 | \endcode
121 |
122 | \section2 Matomo Configuration
123 |
124 | \code
125 | {
126 | "tracker": "matomo",
127 | "server": "http://localhost:8000/piwik.php",
128 | "idsite": "1"
129 | }
130 | \endcode
131 |
132 |
133 | */
134 |
--------------------------------------------------------------------------------
/src/plugin/configutil.cpp:
--------------------------------------------------------------------------------
1 | /****************************************************************************
2 | **
3 | ** Copyright (C) 2019 Luxoft Sweden AB. All rights reserved.
4 | ** Contact: https://www.qt.io/licensing/
5 | **
6 | ** This file is part of the analytics module of the Qt Toolkit.
7 | **
8 | ** $QT_BEGIN_LICENSE:LGPL$
9 | ** Commercial License Usage
10 | ** Licensees holding valid commercial Qt licenses may use this file in
11 | ** accordance with the commercial license agreement provided with the
12 | ** Software or, alternatively, in accordance with the terms contained in
13 | ** a written agreement between you and The Qt Company. For licensing terms
14 | ** and conditions see https://www.qt.io/terms-conditions. For further
15 | ** information use the contact form at https://www.qt.io/contact-us.
16 | **
17 | ** GNU Lesser General Public License Usage
18 | ** Alternatively, this file may be used under the terms of the GNU Lesser
19 | ** General Public License version 3 as published by the Free Software
20 | ** Foundation and appearing in the file LICENSE.LGPL3 included in the
21 | ** packaging of this file. Please review the following information to
22 | ** ensure the GNU Lesser General Public License version 3 requirements
23 | ** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
24 | **
25 | ** GNU General Public License Usage
26 | ** Alternatively, this file may be used under the terms of the GNU
27 | ** General Public License version 2.0 or (at your option) the GNU General
28 | ** Public license version 3 or any later version approved by the KDE Free
29 | ** Qt Foundation. The licenses are as published by the Free Software
30 | ** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
31 | ** included in the packaging of this file. Please review the following
32 | ** information to ensure the GNU General Public License requirements will
33 | ** be met: https://www.gnu.org/licenses/gpl-2.0.html and
34 | ** https://www.gnu.org/licenses/gpl-3.0.html.
35 | **
36 | ** $QT_END_LICENSE$
37 | **
38 | ****************************************************************************/
39 | #include "configutil.h"
40 |
41 | /*!
42 | * \class ConfigUtil
43 | * \inmodule QtAnalytics
44 | * \brief A configuration utility.
45 | */
46 |
47 | ConfigUtil::ConfigUtil()
48 | {
49 |
50 | }
51 |
52 |
53 | QString ConfigUtil::resolvePath(const QString &name)
54 | {
55 | QString upper = name.toUpper();
56 | QString lower = name.toLower();
57 | QString path = qEnvironmentVariable(name.toUpper().toLatin1() + "_CONFIG", QString(":/%1.json").arg(name.toLower().data()));
58 | if (!QFile(path).exists()) {
59 | qWarning() << "No analytics configuration";
60 | return QString();
61 | }
62 | return path;
63 | }
64 |
65 | QByteArray ConfigUtil::readJSON(const QString &path)
66 | {
67 | if (path.isEmpty()) {
68 | qWarning() << "invalid config path";
69 | return QByteArray();
70 | }
71 | QFile device(path);
72 | if (!device.open(QIODevice::ReadOnly)) {
73 | qWarning() << "Can not open analytics config";
74 | return QByteArray();
75 | }
76 | return device.readAll();
77 | }
78 |
79 | QJsonObject ConfigUtil::parseJSON(const QByteArray &data)
80 | {
81 | if (data.isNull()) {
82 | qWarning() << "invalid config data";
83 | return QJsonObject();
84 | }
85 | QJsonParseError error;
86 | QJsonDocument doc = QJsonDocument::fromJson(data, &error);
87 | if (error.error != QJsonParseError::NoError) {
88 | qWarning() << "Error parsing analytics settings";
89 | qWarning() << error.errorString();
90 | return QJsonObject();
91 | }
92 | if (!doc.isObject()) {
93 | qWarning() << "settings must be a valid JSON object";
94 | return QJsonObject();
95 | }
96 | return doc.object();
97 | }
98 |
99 | QJsonObject ConfigUtil::loadJSON(const QString &name)
100 | {
101 | QString path = resolvePath(name);
102 | if (path.isEmpty()) {
103 | return QJsonObject();
104 | }
105 | QByteArray data = readJSON(path);
106 | return parseJSON(data);
107 | }
108 |
109 | QJsonObject ConfigUtil::mergeJSON(const QJsonObject &a, const QJsonObject &b)
110 | {
111 | QJsonObject result(a);
112 | for (auto key : b.keys()) {
113 | result.insert(key, b.value(key));
114 | }
115 | return result;
116 | }
117 |
118 | QVariantMap ConfigUtil::toVariantMap(const QJsonObject &o)
119 | {
120 | return o.toVariantMap();
121 | }
122 |
123 | QVariantMap ConfigUtil::mergeMap(const QVariantMap &a, const QVariantMap &b)
124 | {
125 | QVariantMap result(a);
126 | QMapIterator i(b);
127 | while (i.hasNext()) {
128 | i.next();
129 | result.insert(i.key(), i.value());
130 | }
131 | return result;
132 | }
133 |
134 |
--------------------------------------------------------------------------------
/examples/analytics_demo/Main.qml:
--------------------------------------------------------------------------------
1 | /****************************************************************************
2 | **
3 | ** Copyright (C) 2018, 2019 Luxoft Sweden AB. All rights reserved.
4 | ** Contact: https://www.qt.io/licensing/
5 | **
6 | ** This file is part of the analytics module of the Qt Toolkit.
7 | **
8 | ** $QT_BEGIN_LICENSE:BSD$
9 | ** Commercial License Usage
10 | ** Licensees holding valid commercial Qt licenses may use this file in
11 | ** accordance with the commercial license agreement provided with the
12 | ** Software or, alternatively, in accordance with the terms contained in
13 | ** a written agreement between you and The Qt Company. For licensing terms
14 | ** and conditions see https://www.qt.io/terms-conditions. For further
15 | ** information use the contact form at https://www.qt.io/contact-us.
16 | **
17 | ** BSD License Usage
18 | ** Alternatively, you may use this file under the terms of the BSD license
19 | ** as follows:
20 | **
21 | ** "Redistribution and use in source and binary forms, with or without
22 | ** modification, are permitted provided that the following conditions are
23 | ** met:
24 | ** * Redistributions of source code must retain the above copyright
25 | ** notice, this list of conditions and the following disclaimer.
26 | ** * Redistributions in binary form must reproduce the above copyright
27 | ** notice, this list of conditions and the following disclaimer in
28 | ** the documentation and/or other materials provided with the
29 | ** distribution.
30 | ** * Neither the name of The Qt Company Ltd nor the names of its
31 | ** contributors may be used to endorse or promote products derived
32 | ** from this software without specific prior written permission.
33 | **
34 | **
35 | ** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
36 | ** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
37 | ** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
38 | ** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
39 | ** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
40 | ** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
41 | ** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
42 | ** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
43 | ** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
44 | ** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
45 | ** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
46 | **
47 | ** $QT_END_LICENSE$
48 | **
49 | ****************************************************************************/
50 |
51 | import QtQuick 2.11
52 | import QtQuick.Controls 2.4
53 |
54 | import analytics 1.0
55 |
56 | ApplicationWindow {
57 | id: window
58 | visible: true
59 | width: 480
60 | height: 800
61 | title: qsTr("Analytics Demo")
62 |
63 | header: ToolBar {
64 | contentHeight: toolButton.implicitHeight
65 |
66 | ToolButton {
67 | id: toolButton
68 | text: stackView.depth > 1 ? "\u25C0" : "\u2630"
69 | font.pixelSize: Qt.application.font.pixelSize * 1.6
70 | onClicked: {
71 | if (stackView.depth > 1) {
72 | var url = stackView.currentItem.currentUrl
73 | stackView.pop()
74 | Analytics.sendEvent(url, "UserAction", "BackButton", "clicked", 0)
75 | } else {
76 | drawer.open()
77 | }
78 | }
79 | }
80 |
81 | Label {
82 | anchors.centerIn: parent
83 | font.pixelSize: 20
84 | text: stackView.currentItem.title
85 | }
86 | }
87 |
88 | Drawer {
89 | id: drawer
90 | width: window.width * 0.5
91 | height: window.height
92 |
93 | Column {
94 | anchors.fill: parent
95 |
96 | ItemDelegate {
97 | text: qsTr("Subscriptions")
98 | width: parent.width
99 | font.pixelSize: 20
100 | onClicked: {
101 | stackView.push("SubscriptionsPage.qml")
102 | drawer.close()
103 | }
104 | }
105 | ItemDelegate {
106 | text: qsTr("Info")
107 | width: parent.width
108 | font.pixelSize: 20
109 | onClicked: {
110 | stackView.push("InfoPage.qml")
111 | drawer.close()
112 | }
113 | }
114 | }
115 | }
116 |
117 | Pane {
118 | anchors.fill: parent
119 | anchors.margins: 7
120 | contentItem: StackView {
121 | id: stackView
122 | initialItem: "HomePage.qml"
123 | }
124 | }
125 | }
126 |
--------------------------------------------------------------------------------
/src/plugin/context.cpp:
--------------------------------------------------------------------------------
1 | /****************************************************************************
2 | **
3 | ** Copyright (C) 2019 Luxoft Sweden AB. All rights reserved.
4 | ** Contact: https://www.qt.io/licensing/
5 | **
6 | ** This file is part of the analytics module of the Qt Toolkit.
7 | **
8 | ** $QT_BEGIN_LICENSE:LGPL$
9 | ** Commercial License Usage
10 | ** Licensees holding valid commercial Qt licenses may use this file in
11 | ** accordance with the commercial license agreement provided with the
12 | ** Software or, alternatively, in accordance with the terms contained in
13 | ** a written agreement between you and The Qt Company. For licensing terms
14 | ** and conditions see https://www.qt.io/terms-conditions. For further
15 | ** information use the contact form at https://www.qt.io/contact-us.
16 | **
17 | ** GNU Lesser General Public License Usage
18 | ** Alternatively, this file may be used under the terms of the GNU Lesser
19 | ** General Public License version 3 as published by the Free Software
20 | ** Foundation and appearing in the file LICENSE.LGPL3 included in the
21 | ** packaging of this file. Please review the following information to
22 | ** ensure the GNU Lesser General Public License version 3 requirements
23 | ** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
24 | **
25 | ** GNU General Public License Usage
26 | ** Alternatively, this file may be used under the terms of the GNU
27 | ** General Public License version 2.0 or (at your option) the GNU General
28 | ** Public license version 3 or any later version approved by the KDE Free
29 | ** Qt Foundation. The licenses are as published by the Free Software
30 | ** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
31 | ** included in the packaging of this file. Please review the following
32 | ** information to ensure the GNU General Public License requirements will
33 | ** be met: https://www.gnu.org/licenses/gpl-2.0.html and
34 | ** https://www.gnu.org/licenses/gpl-3.0.html.
35 | **
36 | ** $QT_END_LICENSE$
37 | **
38 | ****************************************************************************/
39 | #include "context.h"
40 | #include "configutil.h"
41 |
42 |
43 | /*!
44 | * \class IContext
45 | * \inmodule QtAnalytics
46 | * \brief An interface to allow independent testing for builders.
47 | */
48 |
49 | /*!
50 | * \class Context
51 | * \inmodule QtAnalytics
52 | * \brief A set of operations exposed to builders.
53 | */
54 |
55 | IContext::~IContext()
56 | {
57 |
58 | }
59 |
60 |
61 | Context::Context(QObject *parent)
62 | : QObject (parent)
63 | , m_network(nullptr)
64 | {
65 | }
66 |
67 | Context::~Context()
68 | {
69 | }
70 |
71 | QVariantMap Context::config() const
72 | {
73 | return m_config;
74 | }
75 |
76 | // network provides access to the network manager
77 | // to send requests.
78 | QNetworkAccessManager *Context::network() const
79 | {
80 | qDebug() << Q_FUNC_INFO;
81 | return m_network;
82 | }
83 |
84 | bool Context::hasNetwork() const
85 | {
86 | return m_network != nullptr;
87 | }
88 |
89 | QVariant Context::configValue(const QString &key, const QVariant &defaultValue) const
90 | {
91 | return m_config.value(key, defaultValue);
92 | }
93 |
94 | QString Context::configString(const QString &key, const QString &defaultValue) const
95 | {
96 | return configValue(key, defaultValue).toString();
97 | }
98 |
99 | QNetworkReply *Context::httpGet(const QNetworkRequest &request) const
100 | {
101 | qDebug() << Q_FUNC_INFO << request.url();
102 | return network()->get(request);
103 | }
104 |
105 | QNetworkReply *Context::httpPost(const QNetworkRequest &request, const QByteArray &data) const
106 | {
107 | qDebug() << Q_FUNC_INFO << request.url() << data;
108 | return network()->post(request, data);
109 | }
110 |
111 | void Context::discoverNetwork(QObject *object)
112 | {
113 | qDebug() << Q_FUNC_INFO;
114 | if (m_network) {
115 | return;
116 | }
117 | if (object) {
118 | // try network via qmlengine
119 | QQmlEngine *engine = qmlEngine(object);
120 | if (engine) {
121 | m_network = engine->networkAccessManager();
122 | connect(m_network, &QNetworkAccessManager::finished, this, &Context::onReplyFinished);
123 | }
124 | }
125 | // create a custome network manager
126 | if (!m_network) {
127 | m_network = new QNetworkAccessManager(this);
128 | connect(m_network, &QNetworkAccessManager::finished, this, &Context::onReplyFinished);
129 | }
130 | }
131 |
132 | void Context::onReplyFinished(QNetworkReply *reply)
133 | {
134 | qDebug() << "reply finished: " << reply->url().toString();
135 | }
136 |
137 | void Context::setConfig(const QVariantMap &config)
138 | {
139 | m_config = config;
140 | }
141 |
142 | void Context::updateConfig(const QVariantMap &o)
143 | {
144 | setConfig(ConfigUtil::mergeMap(m_config, o));
145 | }
146 |
147 | void Context::setNetwork(QNetworkAccessManager *network)
148 | {
149 | m_network = network;
150 | }
151 |
152 |
--------------------------------------------------------------------------------
/examples/analytics_demo/SubscriptionsPage.qml:
--------------------------------------------------------------------------------
1 | /****************************************************************************
2 | **
3 | ** Copyright (C) 2018, 2019 Luxoft Sweden AB. All rights reserved.
4 | ** Contact: https://www.qt.io/licensing/
5 | **
6 | ** This file is part of the analytics module of the Qt Toolkit.
7 | **
8 | ** $QT_BEGIN_LICENSE:BSD$
9 | ** Commercial License Usage
10 | ** Licensees holding valid commercial Qt licenses may use this file in
11 | ** accordance with the commercial license agreement provided with the
12 | ** Software or, alternatively, in accordance with the terms contained in
13 | ** a written agreement between you and The Qt Company. For licensing terms
14 | ** and conditions see https://www.qt.io/terms-conditions. For further
15 | ** information use the contact form at https://www.qt.io/contact-us.
16 | **
17 | ** BSD License Usage
18 | ** Alternatively, you may use this file under the terms of the BSD license
19 | ** as follows:
20 | **
21 | ** "Redistribution and use in source and binary forms, with or without
22 | ** modification, are permitted provided that the following conditions are
23 | ** met:
24 | ** * Redistributions of source code must retain the above copyright
25 | ** notice, this list of conditions and the following disclaimer.
26 | ** * Redistributions in binary form must reproduce the above copyright
27 | ** notice, this list of conditions and the following disclaimer in
28 | ** the documentation and/or other materials provided with the
29 | ** distribution.
30 | ** * Neither the name of The Qt Company Ltd nor the names of its
31 | ** contributors may be used to endorse or promote products derived
32 | ** from this software without specific prior written permission.
33 | **
34 | **
35 | ** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
36 | ** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
37 | ** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
38 | ** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
39 | ** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
40 | ** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
41 | ** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
42 | ** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
43 | ** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
44 | ** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
45 | ** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
46 | **
47 | ** $QT_END_LICENSE$
48 | **
49 | ****************************************************************************/
50 |
51 | import QtQuick 2.11
52 | import QtQuick.Controls 2.4
53 |
54 | import analytics 1.0
55 |
56 | Page {
57 | id: root
58 | objectName: "subscriptions"
59 | title: qsTr("Subscriptions Page")
60 |
61 | property int activationIndex: -1
62 |
63 |
64 | ListModel {
65 | id: listModel
66 | ListElement {
67 | name: "Special offers"
68 | service: "offers"
69 | active: false
70 | }
71 | ListElement {
72 | name: "Company news"
73 | service: "news.company"
74 | active: false
75 | }
76 | ListElement {
77 | name: "Sales"
78 | service: "sales"
79 | active: false
80 | }
81 | ListElement {
82 | name: "Password expiration"
83 | service: "account.changes"
84 | active: false
85 | }
86 | ListElement {
87 | name: "Private messages"
88 | service: "account.message"
89 | active: false
90 | }
91 | ListElement {
92 | name: "New features"
93 | service: "news.features"
94 | active: false
95 | }
96 | }
97 |
98 | contentItem: ListView {
99 | model: listModel
100 | delegate: ItemDelegate {
101 | width: ListView.view.width
102 | height: 80
103 | contentItem: Item {
104 | Label {
105 | anchors.left: parent.left
106 | anchors.verticalCenter: parent.verticalCenter
107 | font.pixelSize: 26
108 | text: model.name
109 | }
110 | Button {
111 | anchors.right: parent.right
112 | anchors.verticalCenter: parent.verticalCenter
113 | width: 100
114 | checked: model.active
115 | text: model.active ? qsTr("Deactivate") : qsTr("Activate")
116 | enabled: activationIndex == -1
117 | onClicked: {
118 | Analytics.sendEvent(root.objectName, "UserAction", "Subscription Activation", model.service, (!model.active))
119 | activationIndex = index
120 | fakeActivation.start()
121 | labelError.visible = false
122 | }
123 | BusyIndicator {
124 | anchors.centerIn: parent
125 | visible: activationIndex == index
126 | }
127 | }
128 | }
129 | }
130 | }
131 |
132 | Label {
133 | id: labelError
134 | anchors.bottom: parent.bottom
135 | anchors.bottomMargin: 50
136 | anchors.horizontalCenter: parent.horizontalCenter
137 | visible: false
138 | text: "Error. Please, try again."
139 | }
140 |
141 | Timer {
142 | id: fakeActivation
143 | interval: 1500
144 | repeat: false
145 | triggeredOnStart: false
146 | onTriggered: {
147 | var success = Math.random()
148 | console.log(success)
149 | if (success > 0.4) {
150 | var active = listModel.get(activationIndex).active
151 | var service = listModel.get(activationIndex).service
152 | listModel.setProperty(activationIndex, "active", !active)
153 | Analytics.sendEvent(root.objectName, "ServerResponse", "Subscription Activation", service, 1)
154 | } else {
155 | labelError.visible = true
156 | Analytics.sendEvent(root.objectName, "ServerResponse", "Subscription Activation", service, 0)
157 | }
158 |
159 | activationIndex = -1
160 | }
161 | }
162 |
163 |
164 | Component.onCompleted: Analytics.sendVisit(objectName, "created")
165 | }
166 |
--------------------------------------------------------------------------------
/LICENSE.LGPL3:
--------------------------------------------------------------------------------
1 | GNU LESSER GENERAL PUBLIC LICENSE
2 | Version 3, 29 June 2007
3 |
4 | Copyright (C) 2007 Free Software Foundation, Inc.
5 | Everyone is permitted to copy and distribute verbatim copies
6 | of this license document, but changing it is not allowed.
7 |
8 |
9 | This version of the GNU Lesser General Public License incorporates
10 | the terms and conditions of version 3 of the GNU General Public
11 | License, supplemented by the additional permissions listed below.
12 |
13 | 0. Additional Definitions.
14 |
15 | As used herein, "this License" refers to version 3 of the GNU Lesser
16 | General Public License, and the "GNU GPL" refers to version 3 of the GNU
17 | General Public License.
18 |
19 | "The Library" refers to a covered work governed by this License,
20 | other than an Application or a Combined Work as defined below.
21 |
22 | An "Application" is any work that makes use of an interface provided
23 | by the Library, but which is not otherwise based on the Library.
24 | Defining a subclass of a class defined by the Library is deemed a mode
25 | of using an interface provided by the Library.
26 |
27 | A "Combined Work" is a work produced by combining or linking an
28 | Application with the Library. The particular version of the Library
29 | with which the Combined Work was made is also called the "Linked
30 | Version".
31 |
32 | The "Minimal Corresponding Source" for a Combined Work means the
33 | Corresponding Source for the Combined Work, excluding any source code
34 | for portions of the Combined Work that, considered in isolation, are
35 | based on the Application, and not on the Linked Version.
36 |
37 | The "Corresponding Application Code" for a Combined Work means the
38 | object code and/or source code for the Application, including any data
39 | and utility programs needed for reproducing the Combined Work from the
40 | Application, but excluding the System Libraries of the Combined Work.
41 |
42 | 1. Exception to Section 3 of the GNU GPL.
43 |
44 | You may convey a covered work under sections 3 and 4 of this License
45 | without being bound by section 3 of the GNU GPL.
46 |
47 | 2. Conveying Modified Versions.
48 |
49 | If you modify a copy of the Library, and, in your modifications, a
50 | facility refers to a function or data to be supplied by an Application
51 | that uses the facility (other than as an argument passed when the
52 | facility is invoked), then you may convey a copy of the modified
53 | version:
54 |
55 | a) under this License, provided that you make a good faith effort to
56 | ensure that, in the event an Application does not supply the
57 | function or data, the facility still operates, and performs
58 | whatever part of its purpose remains meaningful, or
59 |
60 | b) under the GNU GPL, with none of the additional permissions of
61 | this License applicable to that copy.
62 |
63 | 3. Object Code Incorporating Material from Library Header Files.
64 |
65 | The object code form of an Application may incorporate material from
66 | a header file that is part of the Library. You may convey such object
67 | code under terms of your choice, provided that, if the incorporated
68 | material is not limited to numerical parameters, data structure
69 | layouts and accessors, or small macros, inline functions and templates
70 | (ten or fewer lines in length), you do both of the following:
71 |
72 | a) Give prominent notice with each copy of the object code that the
73 | Library is used in it and that the Library and its use are
74 | covered by this License.
75 |
76 | b) Accompany the object code with a copy of the GNU GPL and this license
77 | document.
78 |
79 | 4. Combined Works.
80 |
81 | You may convey a Combined Work under terms of your choice that,
82 | taken together, effectively do not restrict modification of the
83 | portions of the Library contained in the Combined Work and reverse
84 | engineering for debugging such modifications, if you also do each of
85 | the following:
86 |
87 | a) Give prominent notice with each copy of the Combined Work that
88 | the Library is used in it and that the Library and its use are
89 | covered by this License.
90 |
91 | b) Accompany the Combined Work with a copy of the GNU GPL and this license
92 | document.
93 |
94 | c) For a Combined Work that displays copyright notices during
95 | execution, include the copyright notice for the Library among
96 | these notices, as well as a reference directing the user to the
97 | copies of the GNU GPL and this license document.
98 |
99 | d) Do one of the following:
100 |
101 | 0) Convey the Minimal Corresponding Source under the terms of this
102 | License, and the Corresponding Application Code in a form
103 | suitable for, and under terms that permit, the user to
104 | recombine or relink the Application with a modified version of
105 | the Linked Version to produce a modified Combined Work, in the
106 | manner specified by section 6 of the GNU GPL for conveying
107 | Corresponding Source.
108 |
109 | 1) Use a suitable shared library mechanism for linking with the
110 | Library. A suitable mechanism is one that (a) uses at run time
111 | a copy of the Library already present on the user's computer
112 | system, and (b) will operate properly with a modified version
113 | of the Library that is interface-compatible with the Linked
114 | Version.
115 |
116 | e) Provide Installation Information, but only if you would otherwise
117 | be required to provide such information under section 6 of the
118 | GNU GPL, and only to the extent that such information is
119 | necessary to install and execute a modified version of the
120 | Combined Work produced by recombining or relinking the
121 | Application with a modified version of the Linked Version. (If
122 | you use option 4d0, the Installation Information must accompany
123 | the Minimal Corresponding Source and Corresponding Application
124 | Code. If you use option 4d1, you must provide the Installation
125 | Information in the manner specified by section 6 of the GNU GPL
126 | for conveying Corresponding Source.)
127 |
128 | 5. Combined Libraries.
129 |
130 | You may place library facilities that are a work based on the
131 | Library side by side in a single library together with other library
132 | facilities that are not Applications and are not covered by this
133 | License, and convey such a combined library under terms of your
134 | choice, if you do both of the following:
135 |
136 | a) Accompany the combined library with a copy of the same work based
137 | on the Library, uncombined with any other library facilities,
138 | conveyed under the terms of this License.
139 |
140 | b) Give prominent notice with the combined library that part of it
141 | is a work based on the Library, and explaining where to find the
142 | accompanying uncombined form of the same work.
143 |
144 | 6. Revised Versions of the GNU Lesser General Public License.
145 |
146 | The Free Software Foundation may publish revised and/or new versions
147 | of the GNU Lesser General Public License from time to time. Such new
148 | versions will be similar in spirit to the present version, but may
149 | differ in detail to address new problems or concerns.
150 |
151 | Each version is given a distinguishing version number. If the
152 | Library as you received it specifies that a certain numbered version
153 | of the GNU Lesser General Public License "or any later version"
154 | applies to it, you have the option of following the terms and
155 | conditions either of that published version or of any later version
156 | published by the Free Software Foundation. If the Library as you
157 | received it does not specify a version number of the GNU Lesser
158 | General Public License, you may choose any version of the GNU Lesser
159 | General Public License ever published by the Free Software Foundation.
160 |
161 | If the Library as you received it specifies that a proxy can decide
162 | whether future versions of the GNU Lesser General Public License shall
163 | apply, that proxy's public statement of acceptance of any version is
164 | permanent authorization for you to choose that version for the
165 | Library.
166 |
--------------------------------------------------------------------------------
/src/plugin/analytics.cpp:
--------------------------------------------------------------------------------
1 | /****************************************************************************
2 | **
3 | ** Copyright (C) 2019 Luxoft Sweden AB. All rights reserved.
4 | ** Contact: https://www.qt.io/licensing/
5 | **
6 | ** This file is part of the analytics module of the Qt Toolkit.
7 | **
8 | ** $QT_BEGIN_LICENSE:LGPL$
9 | ** Commercial License Usage
10 | ** Licensees holding valid commercial Qt licenses may use this file in
11 | ** accordance with the commercial license agreement provided with the
12 | ** Software or, alternatively, in accordance with the terms contained in
13 | ** a written agreement between you and The Qt Company. For licensing terms
14 | ** and conditions see https://www.qt.io/terms-conditions. For further
15 | ** information use the contact form at https://www.qt.io/contact-us.
16 | **
17 | ** GNU Lesser General Public License Usage
18 | ** Alternatively, this file may be used under the terms of the GNU Lesser
19 | ** General Public License version 3 as published by the Free Software
20 | ** Foundation and appearing in the file LICENSE.LGPL3 included in the
21 | ** packaging of this file. Please review the following information to
22 | ** ensure the GNU Lesser General Public License version 3 requirements
23 | ** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
24 | **
25 | ** GNU General Public License Usage
26 | ** Alternatively, this file may be used under the terms of the GNU
27 | ** General Public License version 2.0 or (at your option) the GNU General
28 | ** Public license version 3 or any later version approved by the KDE Free
29 | ** Qt Foundation. The licenses are as published by the Free Software
30 | ** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
31 | ** included in the packaging of this file. Please review the following
32 | ** information to ensure the GNU General Public License requirements will
33 | ** be met: https://www.gnu.org/licenses/gpl-2.0.html and
34 | ** https://www.gnu.org/licenses/gpl-3.0.html.
35 | **
36 | ** $QT_END_LICENSE$
37 | **
38 | ****************************************************************************/
39 |
40 | #include "analytics.h"
41 | #include "hitbuilder.h"
42 | #include "matomobuilder.h"
43 | #include "googlebuilder.h"
44 | #include "configutil.h"
45 | #include "context.h"
46 |
47 | /*!
48 | * \qmlmodule Analytics
49 | */
50 |
51 | /*!
52 | * \qmltype Analytics
53 | * \inqmlmodule Analytics
54 | * \brief Provides tracking operations for visits and events.
55 |
56 | * To use this API you need to have an analytics.json configuration file located
57 | * either as resource file or in your home folder. The configuration file needs to provide the
58 | * server url, tracker id, client id as a minimum.
59 |
60 | * The API will send request to the Matomo server to track certain user interface statistics. You need to
61 | * place tracking code inside your user interface to track this behavior.
62 | */
63 |
64 | /*!
65 | * \class AnalyticsAttached
66 | * \inmodule QtAnalytics
67 | * \brief The attached object to the Analytics.
68 | */
69 |
70 | /*!
71 | * \class Analytics
72 | * \inmodule QtAnalytics
73 | * \brief Proxy class to access the selected tracker platform.
74 | */
75 |
76 | /*!
77 | * \brief Construct a new attached object.
78 | * \param parent Parent object
79 | */
80 | AnalyticsAttached::AnalyticsAttached(QObject *parent)
81 | : QObject(parent)
82 | {
83 | }
84 |
85 | AnalyticsAttached::~AnalyticsAttached()
86 | {
87 | }
88 |
89 | /*!
90 | * \qmlmethod void Analytics::sendPing()
91 | * Sends a heartbeat request to the tracking server
92 | *
93 | * A ping will only update the visit's total time.
94 | * It is used to provide accurate "visit duration" metrics.
95 | */
96 | void AnalyticsAttached::sendPing()
97 | {
98 | Analytics::instance(this)->sendPing();
99 | }
100 |
101 | /*!
102 | * \qmlmethod void Analytics::sendVisit(path, action, dimensions)
103 | *
104 | * Sends a visit request to the tracking server
105 | *
106 | * The visit location will be identified by the \a path. The optional \a action identifies what is happening. The optional \a dimensions allows you
107 | * to send further information as defined by the servers custom dimensions. Additional to this information also the
108 | * custom variables defined will be send to the server.
109 | *
110 | */
111 | void AnalyticsAttached::sendVisit(const QString &path, const QString &action)
112 | {
113 | Analytics::instance(this)->sendVisit(path, action);
114 | }
115 |
116 | /*!
117 | * \qmlmethod void Analytics::sendEvent(path, category, action, name, int value, dimensions)
118 | *
119 | * Sends an event request to the tracking server. The path provides the location inside the user interface.
120 | * The action what is happening. The event category where somethign is heppening (e.g. videos, music. games). The
121 | * name the event name to track. A value can be an additional information to track. Additional you can provide
122 | * a set of key/value pairs as defined on the Matamo server.
123 | */
124 | void AnalyticsAttached::sendEvent(const QString &category, const QString &action,
125 | const QString &name, const QString &value)
126 | {
127 | Analytics::instance(this)->sendEvent(category, action, name, value);
128 | }
129 |
130 | void AnalyticsAttached::setVariables(QVariantMap customVariables)
131 | {
132 | if (m_variables == customVariables) {
133 | return;
134 | }
135 | m_variables = customVariables;
136 | emit variablesChanged();
137 | }
138 |
139 |
140 | // Analytics
141 |
142 | Analytics* Analytics::s_instance = nullptr;
143 |
144 | Analytics::Analytics(QObject *parent)
145 | : QObject(parent)
146 | , m_context(new Context(this))
147 | , m_builder(nullptr)
148 | {
149 | const QJsonObject& data = ConfigUtil::loadJSON("analytics");
150 | const QVariantMap& o = ConfigUtil::toVariantMap(data);
151 | m_context->setConfig(o);
152 | }
153 |
154 | Analytics::~Analytics()
155 | {
156 | }
157 |
158 | Analytics *Analytics::instance(QObject *attached)
159 | {
160 | qDebug() << Q_FUNC_INFO;
161 | if (!Analytics::s_instance) {
162 | Analytics::s_instance = new Analytics(QCoreApplication::instance());
163 | }
164 | if (attached && !Analytics::s_instance->context()->hasNetwork()) {
165 | Analytics::s_instance->context()->discoverNetwork(attached->parent());
166 | }
167 | return Analytics::s_instance;
168 | }
169 |
170 | AnalyticsAttached *Analytics::qmlAttachedProperties(QObject* object)
171 | {
172 | return new AnalyticsAttached(object);
173 | }
174 |
175 | void Analytics::sendPing()
176 | {
177 | qDebug() << Q_FUNC_INFO;
178 | }
179 |
180 |
181 | void Analytics::sendVisit(const QString &path, const QString &action)
182 | {
183 | qDebug() << Q_FUNC_INFO << path << action;
184 | HitBuilder* builder = getBuilder();
185 | if (builder) {
186 | builder->initQuery();
187 | builder->trackPage(path, action);
188 | builder->sendQuery();
189 | builder->reset();
190 | }
191 | }
192 |
193 |
194 | void Analytics::sendEvent( const QString &category,
195 | const QString &action, const QString &name,
196 | const QString &value) {
197 |
198 | qDebug() << Q_FUNC_INFO << category << action;
199 | HitBuilder* builder = getBuilder();
200 | if (builder) {
201 | builder->initQuery();
202 | builder->trackEvent(category, action, name, value);
203 | builder->sendQuery();
204 | builder->reset();
205 | }
206 | }
207 |
208 |
209 | HitBuilder* Analytics::getBuilder()
210 | {
211 | if (!m_builder) {
212 | QString tracker = context()->configString("tracker");
213 | qDebug() << "found tracker " << tracker;
214 | if (tracker == "matomo") {
215 | m_builder = new MatomoBuilder(context(), this);
216 | } else if (tracker == "google") {
217 | m_builder = new GoogleBuilder(context(), this);
218 | } else {
219 | qWarning() << "not supported builder" << tracker;
220 | }
221 | }
222 | return m_builder;
223 | }
224 |
225 | void Analytics::onReplyFinished(QNetworkReply *reply)
226 | {
227 | emit replyFinished(reply);
228 | qDebug() << "network reply finished: " << reply->url();
229 | reply->deleteLater();
230 | }
231 |
232 | Context *Analytics::context() const
233 | {
234 | return m_context;
235 | }
236 |
237 | //QString Analytics::userAgent() const
238 | //{
239 | // const QString& name = settings()->value("applicationName").toString();
240 | // const QString& version = settings()->value("applicationVersion").toString();
241 | // const QString& lang = userLanguage();
242 | // const QString& os = settings()->value("os").toString();
243 | // return QString("%1/%2 (%3;%4) Analytics/1.0 (Qt/%5)").arg(name).arg(version).arg(os).arg(lang).arg(QT_VERSION_STR);
244 | //}
245 |
246 | //QString Analytics::userLanguage() const
247 | //{
248 | // return QLocale::system().name().toLower().replace("_", "-");
249 | //}
250 |
251 |
--------------------------------------------------------------------------------
/LICENSE.GPL2:
--------------------------------------------------------------------------------
1 | GNU GENERAL PUBLIC LICENSE
2 | Version 2, June 1991
3 |
4 | Copyright (C) 1989, 1991 Free Software Foundation, Inc.,
5 | 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
6 | Everyone is permitted to copy and distribute verbatim copies
7 | of this license document, but changing it is not allowed.
8 |
9 | Preamble
10 |
11 | The licenses for most software are designed to take away your
12 | freedom to share and change it. By contrast, the GNU General Public
13 | License is intended to guarantee your freedom to share and change free
14 | software--to make sure the software is free for all its users. This
15 | General Public License applies to most of the Free Software
16 | Foundation's software and to any other program whose authors commit to
17 | using it. (Some other Free Software Foundation software is covered by
18 | the GNU Lesser General Public License instead.) You can apply it to
19 | your programs, too.
20 |
21 | When we speak of free software, we are referring to freedom, not
22 | price. Our General Public Licenses are designed to make sure that you
23 | have the freedom to distribute copies of free software (and charge for
24 | this service if you wish), that you receive source code or can get it
25 | if you want it, that you can change the software or use pieces of it
26 | in new free programs; and that you know you can do these things.
27 |
28 | To protect your rights, we need to make restrictions that forbid
29 | anyone to deny you these rights or to ask you to surrender the rights.
30 | These restrictions translate to certain responsibilities for you if you
31 | distribute copies of the software, or if you modify it.
32 |
33 | For example, if you distribute copies of such a program, whether
34 | gratis or for a fee, you must give the recipients all the rights that
35 | you have. You must make sure that they, too, receive or can get the
36 | source code. And you must show them these terms so they know their
37 | rights.
38 |
39 | We protect your rights with two steps: (1) copyright the software, and
40 | (2) offer you this license which gives you legal permission to copy,
41 | distribute and/or modify the software.
42 |
43 | Also, for each author's protection and ours, we want to make certain
44 | that everyone understands that there is no warranty for this free
45 | software. If the software is modified by someone else and passed on, we
46 | want its recipients to know that what they have is not the original, so
47 | that any problems introduced by others will not reflect on the original
48 | authors' reputations.
49 |
50 | Finally, any free program is threatened constantly by software
51 | patents. We wish to avoid the danger that redistributors of a free
52 | program will individually obtain patent licenses, in effect making the
53 | program proprietary. To prevent this, we have made it clear that any
54 | patent must be licensed for everyone's free use or not licensed at all.
55 |
56 | The precise terms and conditions for copying, distribution and
57 | modification follow.
58 |
59 | GNU GENERAL PUBLIC LICENSE
60 | TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
61 |
62 | 0. This License applies to any program or other work which contains
63 | a notice placed by the copyright holder saying it may be distributed
64 | under the terms of this General Public License. The "Program", below,
65 | refers to any such program or work, and a "work based on the Program"
66 | means either the Program or any derivative work under copyright law:
67 | that is to say, a work containing the Program or a portion of it,
68 | either verbatim or with modifications and/or translated into another
69 | language. (Hereinafter, translation is included without limitation in
70 | the term "modification".) Each licensee is addressed as "you".
71 |
72 | Activities other than copying, distribution and modification are not
73 | covered by this License; they are outside its scope. The act of
74 | running the Program is not restricted, and the output from the Program
75 | is covered only if its contents constitute a work based on the
76 | Program (independent of having been made by running the Program).
77 | Whether that is true depends on what the Program does.
78 |
79 | 1. You may copy and distribute verbatim copies of the Program's
80 | source code as you receive it, in any medium, provided that you
81 | conspicuously and appropriately publish on each copy an appropriate
82 | copyright notice and disclaimer of warranty; keep intact all the
83 | notices that refer to this License and to the absence of any warranty;
84 | and give any other recipients of the Program a copy of this License
85 | along with the Program.
86 |
87 | You may charge a fee for the physical act of transferring a copy, and
88 | you may at your option offer warranty protection in exchange for a fee.
89 |
90 | 2. You may modify your copy or copies of the Program or any portion
91 | of it, thus forming a work based on the Program, and copy and
92 | distribute such modifications or work under the terms of Section 1
93 | above, provided that you also meet all of these conditions:
94 |
95 | a) You must cause the modified files to carry prominent notices
96 | stating that you changed the files and the date of any change.
97 |
98 | b) You must cause any work that you distribute or publish, that in
99 | whole or in part contains or is derived from the Program or any
100 | part thereof, to be licensed as a whole at no charge to all third
101 | parties under the terms of this License.
102 |
103 | c) If the modified program normally reads commands interactively
104 | when run, you must cause it, when started running for such
105 | interactive use in the most ordinary way, to print or display an
106 | announcement including an appropriate copyright notice and a
107 | notice that there is no warranty (or else, saying that you provide
108 | a warranty) and that users may redistribute the program under
109 | these conditions, and telling the user how to view a copy of this
110 | License. (Exception: if the Program itself is interactive but
111 | does not normally print such an announcement, your work based on
112 | the Program is not required to print an announcement.)
113 |
114 | These requirements apply to the modified work as a whole. If
115 | identifiable sections of that work are not derived from the Program,
116 | and can be reasonably considered independent and separate works in
117 | themselves, then this License, and its terms, do not apply to those
118 | sections when you distribute them as separate works. But when you
119 | distribute the same sections as part of a whole which is a work based
120 | on the Program, the distribution of the whole must be on the terms of
121 | this License, whose permissions for other licensees extend to the
122 | entire whole, and thus to each and every part regardless of who wrote it.
123 |
124 | Thus, it is not the intent of this section to claim rights or contest
125 | your rights to work written entirely by you; rather, the intent is to
126 | exercise the right to control the distribution of derivative or
127 | collective works based on the Program.
128 |
129 | In addition, mere aggregation of another work not based on the Program
130 | with the Program (or with a work based on the Program) on a volume of
131 | a storage or distribution medium does not bring the other work under
132 | the scope of this License.
133 |
134 | 3. You may copy and distribute the Program (or a work based on it,
135 | under Section 2) in object code or executable form under the terms of
136 | Sections 1 and 2 above provided that you also do one of the following:
137 |
138 | a) Accompany it with the complete corresponding machine-readable
139 | source code, which must be distributed under the terms of Sections
140 | 1 and 2 above on a medium customarily used for software interchange; or,
141 |
142 | b) Accompany it with a written offer, valid for at least three
143 | years, to give any third party, for a charge no more than your
144 | cost of physically performing source distribution, a complete
145 | machine-readable copy of the corresponding source code, to be
146 | distributed under the terms of Sections 1 and 2 above on a medium
147 | customarily used for software interchange; or,
148 |
149 | c) Accompany it with the information you received as to the offer
150 | to distribute corresponding source code. (This alternative is
151 | allowed only for noncommercial distribution and only if you
152 | received the program in object code or executable form with such
153 | an offer, in accord with Subsection b above.)
154 |
155 | The source code for a work means the preferred form of the work for
156 | making modifications to it. For an executable work, complete source
157 | code means all the source code for all modules it contains, plus any
158 | associated interface definition files, plus the scripts used to
159 | control compilation and installation of the executable. However, as a
160 | special exception, the source code distributed need not include
161 | anything that is normally distributed (in either source or binary
162 | form) with the major components (compiler, kernel, and so on) of the
163 | operating system on which the executable runs, unless that component
164 | itself accompanies the executable.
165 |
166 | If distribution of executable or object code is made by offering
167 | access to copy from a designated place, then offering equivalent
168 | access to copy the source code from the same place counts as
169 | distribution of the source code, even though third parties are not
170 | compelled to copy the source along with the object code.
171 |
172 | 4. You may not copy, modify, sublicense, or distribute the Program
173 | except as expressly provided under this License. Any attempt
174 | otherwise to copy, modify, sublicense or distribute the Program is
175 | void, and will automatically terminate your rights under this License.
176 | However, parties who have received copies, or rights, from you under
177 | this License will not have their licenses terminated so long as such
178 | parties remain in full compliance.
179 |
180 | 5. You are not required to accept this License, since you have not
181 | signed it. However, nothing else grants you permission to modify or
182 | distribute the Program or its derivative works. These actions are
183 | prohibited by law if you do not accept this License. Therefore, by
184 | modifying or distributing the Program (or any work based on the
185 | Program), you indicate your acceptance of this License to do so, and
186 | all its terms and conditions for copying, distributing or modifying
187 | the Program or works based on it.
188 |
189 | 6. Each time you redistribute the Program (or any work based on the
190 | Program), the recipient automatically receives a license from the
191 | original licensor to copy, distribute or modify the Program subject to
192 | these terms and conditions. You may not impose any further
193 | restrictions on the recipients' exercise of the rights granted herein.
194 | You are not responsible for enforcing compliance by third parties to
195 | this License.
196 |
197 | 7. If, as a consequence of a court judgment or allegation of patent
198 | infringement or for any other reason (not limited to patent issues),
199 | conditions are imposed on you (whether by court order, agreement or
200 | otherwise) that contradict the conditions of this License, they do not
201 | excuse you from the conditions of this License. If you cannot
202 | distribute so as to satisfy simultaneously your obligations under this
203 | License and any other pertinent obligations, then as a consequence you
204 | may not distribute the Program at all. For example, if a patent
205 | license would not permit royalty-free redistribution of the Program by
206 | all those who receive copies directly or indirectly through you, then
207 | the only way you could satisfy both it and this License would be to
208 | refrain entirely from distribution of the Program.
209 |
210 | If any portion of this section is held invalid or unenforceable under
211 | any particular circumstance, the balance of the section is intended to
212 | apply and the section as a whole is intended to apply in other
213 | circumstances.
214 |
215 | It is not the purpose of this section to induce you to infringe any
216 | patents or other property right claims or to contest validity of any
217 | such claims; this section has the sole purpose of protecting the
218 | integrity of the free software distribution system, which is
219 | implemented by public license practices. Many people have made
220 | generous contributions to the wide range of software distributed
221 | through that system in reliance on consistent application of that
222 | system; it is up to the author/donor to decide if he or she is willing
223 | to distribute software through any other system and a licensee cannot
224 | impose that choice.
225 |
226 | This section is intended to make thoroughly clear what is believed to
227 | be a consequence of the rest of this License.
228 |
229 | 8. If the distribution and/or use of the Program is restricted in
230 | certain countries either by patents or by copyrighted interfaces, the
231 | original copyright holder who places the Program under this License
232 | may add an explicit geographical distribution limitation excluding
233 | those countries, so that distribution is permitted only in or among
234 | countries not thus excluded. In such case, this License incorporates
235 | the limitation as if written in the body of this License.
236 |
237 | 9. The Free Software Foundation may publish revised and/or new versions
238 | of the General Public License from time to time. Such new versions will
239 | be similar in spirit to the present version, but may differ in detail to
240 | address new problems or concerns.
241 |
242 | Each version is given a distinguishing version number. If the Program
243 | specifies a version number of this License which applies to it and "any
244 | later version", you have the option of following the terms and conditions
245 | either of that version or of any later version published by the Free
246 | Software Foundation. If the Program does not specify a version number of
247 | this License, you may choose any version ever published by the Free Software
248 | Foundation.
249 |
250 | 10. If you wish to incorporate parts of the Program into other free
251 | programs whose distribution conditions are different, write to the author
252 | to ask for permission. For software which is copyrighted by the Free
253 | Software Foundation, write to the Free Software Foundation; we sometimes
254 | make exceptions for this. Our decision will be guided by the two goals
255 | of preserving the free status of all derivatives of our free software and
256 | of promoting the sharing and reuse of software generally.
257 |
258 | NO WARRANTY
259 |
260 | 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY
261 | FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN
262 | OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES
263 | PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED
264 | OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
265 | MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS
266 | TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE
267 | PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING,
268 | REPAIR OR CORRECTION.
269 |
270 | 12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
271 | WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR
272 | REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES,
273 | INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING
274 | OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED
275 | TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY
276 | YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER
277 | PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE
278 | POSSIBILITY OF SUCH DAMAGES.
279 |
280 | END OF TERMS AND CONDITIONS
281 |
282 | How to Apply These Terms to Your New Programs
283 |
284 | If you develop a new program, and you want it to be of the greatest
285 | possible use to the public, the best way to achieve this is to make it
286 | free software which everyone can redistribute and change under these terms.
287 |
288 | To do so, attach the following notices to the program. It is safest
289 | to attach them to the start of each source file to most effectively
290 | convey the exclusion of warranty; and each file should have at least
291 | the "copyright" line and a pointer to where the full notice is found.
292 |
293 |
294 | Copyright (C)
295 |
296 | This program is free software; you can redistribute it and/or modify
297 | it under the terms of the GNU General Public License as published by
298 | the Free Software Foundation; either version 2 of the License, or
299 | (at your option) any later version.
300 |
301 | This program is distributed in the hope that it will be useful,
302 | but WITHOUT ANY WARRANTY; without even the implied warranty of
303 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
304 | GNU General Public License for more details.
305 |
306 | You should have received a copy of the GNU General Public License along
307 | with this program; if not, write to the Free Software Foundation, Inc.,
308 | 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
309 |
310 | Also add information on how to contact you by electronic and paper mail.
311 |
312 | If the program is interactive, make it output a short notice like this
313 | when it starts in an interactive mode:
314 |
315 | Gnomovision version 69, Copyright (C) year name of author
316 | Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
317 | This is free software, and you are welcome to redistribute it
318 | under certain conditions; type `show c' for details.
319 |
320 | The hypothetical commands `show w' and `show c' should show the appropriate
321 | parts of the General Public License. Of course, the commands you use may
322 | be called something other than `show w' and `show c'; they could even be
323 | mouse-clicks or menu items--whatever suits your program.
324 |
325 | You should also get your employer (if you work as a programmer) or your
326 | school, if any, to sign a "copyright disclaimer" for the program, if
327 | necessary. Here is a sample; alter the names:
328 |
329 | Yoyodyne, Inc., hereby disclaims all copyright interest in the program
330 | `Gnomovision' (which makes passes at compilers) written by James Hacker.
331 |
332 | , 1 April 1989
333 | Ty Coon, President of Vice
334 |
335 | This General Public License does not permit incorporating your program into
336 | proprietary programs. If your program is a subroutine library, you may
337 | consider it more useful to permit linking proprietary applications with the
338 | library. If this is what you want to do, use the GNU Lesser General
339 | Public License instead of this License.
340 |
--------------------------------------------------------------------------------
/LICENSE.GPL3:
--------------------------------------------------------------------------------
1 | GNU GENERAL PUBLIC LICENSE
2 | Version 3, 29 June 2007
3 |
4 | Copyright (C) 2007 Free Software Foundation, Inc.
5 | Everyone is permitted to copy and distribute verbatim copies
6 | of this license document, but changing it is not allowed.
7 |
8 | Preamble
9 |
10 | The GNU General Public License is a free, copyleft license for
11 | software and other kinds of works.
12 |
13 | The licenses for most software and other practical works are designed
14 | to take away your freedom to share and change the works. By contrast,
15 | the GNU General Public License is intended to guarantee your freedom to
16 | share and change all versions of a program--to make sure it remains free
17 | software for all its users. We, the Free Software Foundation, use the
18 | GNU General Public License for most of our software; it applies also to
19 | any other work released this way by its authors. You can apply it to
20 | your programs, too.
21 |
22 | When we speak of free software, we are referring to freedom, not
23 | price. Our General Public Licenses are designed to make sure that you
24 | have the freedom to distribute copies of free software (and charge for
25 | them if you wish), that you receive source code or can get it if you
26 | want it, that you can change the software or use pieces of it in new
27 | free programs, and that you know you can do these things.
28 |
29 | To protect your rights, we need to prevent others from denying you
30 | these rights or asking you to surrender the rights. Therefore, you have
31 | certain responsibilities if you distribute copies of the software, or if
32 | you modify it: responsibilities to respect the freedom of others.
33 |
34 | For example, if you distribute copies of such a program, whether
35 | gratis or for a fee, you must pass on to the recipients the same
36 | freedoms that you received. You must make sure that they, too, receive
37 | or can get the source code. And you must show them these terms so they
38 | know their rights.
39 |
40 | Developers that use the GNU GPL protect your rights with two steps:
41 | (1) assert copyright on the software, and (2) offer you this License
42 | giving you legal permission to copy, distribute and/or modify it.
43 |
44 | For the developers' and authors' protection, the GPL clearly explains
45 | that there is no warranty for this free software. For both users' and
46 | authors' sake, the GPL requires that modified versions be marked as
47 | changed, so that their problems will not be attributed erroneously to
48 | authors of previous versions.
49 |
50 | Some devices are designed to deny users access to install or run
51 | modified versions of the software inside them, although the manufacturer
52 | can do so. This is fundamentally incompatible with the aim of
53 | protecting users' freedom to change the software. The systematic
54 | pattern of such abuse occurs in the area of products for individuals to
55 | use, which is precisely where it is most unacceptable. Therefore, we
56 | have designed this version of the GPL to prohibit the practice for those
57 | products. If such problems arise substantially in other domains, we
58 | stand ready to extend this provision to those domains in future versions
59 | of the GPL, as needed to protect the freedom of users.
60 |
61 | Finally, every program is threatened constantly by software patents.
62 | States should not allow patents to restrict development and use of
63 | software on general-purpose computers, but in those that do, we wish to
64 | avoid the special danger that patents applied to a free program could
65 | make it effectively proprietary. To prevent this, the GPL assures that
66 | patents cannot be used to render the program non-free.
67 |
68 | The precise terms and conditions for copying, distribution and
69 | modification follow.
70 |
71 | TERMS AND CONDITIONS
72 |
73 | 0. Definitions.
74 |
75 | "This License" refers to version 3 of the GNU General Public License.
76 |
77 | "Copyright" also means copyright-like laws that apply to other kinds of
78 | works, such as semiconductor masks.
79 |
80 | "The Program" refers to any copyrightable work licensed under this
81 | License. Each licensee is addressed as "you". "Licensees" and
82 | "recipients" may be individuals or organizations.
83 |
84 | To "modify" a work means to copy from or adapt all or part of the work
85 | in a fashion requiring copyright permission, other than the making of an
86 | exact copy. The resulting work is called a "modified version" of the
87 | earlier work or a work "based on" the earlier work.
88 |
89 | A "covered work" means either the unmodified Program or a work based
90 | on the Program.
91 |
92 | To "propagate" a work means to do anything with it that, without
93 | permission, would make you directly or secondarily liable for
94 | infringement under applicable copyright law, except executing it on a
95 | computer or modifying a private copy. Propagation includes copying,
96 | distribution (with or without modification), making available to the
97 | public, and in some countries other activities as well.
98 |
99 | To "convey" a work means any kind of propagation that enables other
100 | parties to make or receive copies. Mere interaction with a user through
101 | a computer network, with no transfer of a copy, is not conveying.
102 |
103 | An interactive user interface displays "Appropriate Legal Notices"
104 | to the extent that it includes a convenient and prominently visible
105 | feature that (1) displays an appropriate copyright notice, and (2)
106 | tells the user that there is no warranty for the work (except to the
107 | extent that warranties are provided), that licensees may convey the
108 | work under this License, and how to view a copy of this License. If
109 | the interface presents a list of user commands or options, such as a
110 | menu, a prominent item in the list meets this criterion.
111 |
112 | 1. Source Code.
113 |
114 | The "source code" for a work means the preferred form of the work
115 | for making modifications to it. "Object code" means any non-source
116 | form of a work.
117 |
118 | A "Standard Interface" means an interface that either is an official
119 | standard defined by a recognized standards body, or, in the case of
120 | interfaces specified for a particular programming language, one that
121 | is widely used among developers working in that language.
122 |
123 | The "System Libraries" of an executable work include anything, other
124 | than the work as a whole, that (a) is included in the normal form of
125 | packaging a Major Component, but which is not part of that Major
126 | Component, and (b) serves only to enable use of the work with that
127 | Major Component, or to implement a Standard Interface for which an
128 | implementation is available to the public in source code form. A
129 | "Major Component", in this context, means a major essential component
130 | (kernel, window system, and so on) of the specific operating system
131 | (if any) on which the executable work runs, or a compiler used to
132 | produce the work, or an object code interpreter used to run it.
133 |
134 | The "Corresponding Source" for a work in object code form means all
135 | the source code needed to generate, install, and (for an executable
136 | work) run the object code and to modify the work, including scripts to
137 | control those activities. However, it does not include the work's
138 | System Libraries, or general-purpose tools or generally available free
139 | programs which are used unmodified in performing those activities but
140 | which are not part of the work. For example, Corresponding Source
141 | includes interface definition files associated with source files for
142 | the work, and the source code for shared libraries and dynamically
143 | linked subprograms that the work is specifically designed to require,
144 | such as by intimate data communication or control flow between those
145 | subprograms and other parts of the work.
146 |
147 | The Corresponding Source need not include anything that users
148 | can regenerate automatically from other parts of the Corresponding
149 | Source.
150 |
151 | The Corresponding Source for a work in source code form is that
152 | same work.
153 |
154 | 2. Basic Permissions.
155 |
156 | All rights granted under this License are granted for the term of
157 | copyright on the Program, and are irrevocable provided the stated
158 | conditions are met. This License explicitly affirms your unlimited
159 | permission to run the unmodified Program. The output from running a
160 | covered work is covered by this License only if the output, given its
161 | content, constitutes a covered work. This License acknowledges your
162 | rights of fair use or other equivalent, as provided by copyright law.
163 |
164 | You may make, run and propagate covered works that you do not
165 | convey, without conditions so long as your license otherwise remains
166 | in force. You may convey covered works to others for the sole purpose
167 | of having them make modifications exclusively for you, or provide you
168 | with facilities for running those works, provided that you comply with
169 | the terms of this License in conveying all material for which you do
170 | not control copyright. Those thus making or running the covered works
171 | for you must do so exclusively on your behalf, under your direction
172 | and control, on terms that prohibit them from making any copies of
173 | your copyrighted material outside their relationship with you.
174 |
175 | Conveying under any other circumstances is permitted solely under
176 | the conditions stated below. Sublicensing is not allowed; section 10
177 | makes it unnecessary.
178 |
179 | 3. Protecting Users' Legal Rights From Anti-Circumvention Law.
180 |
181 | No covered work shall be deemed part of an effective technological
182 | measure under any applicable law fulfilling obligations under article
183 | 11 of the WIPO copyright treaty adopted on 20 December 1996, or
184 | similar laws prohibiting or restricting circumvention of such
185 | measures.
186 |
187 | When you convey a covered work, you waive any legal power to forbid
188 | circumvention of technological measures to the extent such circumvention
189 | is effected by exercising rights under this License with respect to
190 | the covered work, and you disclaim any intention to limit operation or
191 | modification of the work as a means of enforcing, against the work's
192 | users, your or third parties' legal rights to forbid circumvention of
193 | technological measures.
194 |
195 | 4. Conveying Verbatim Copies.
196 |
197 | You may convey verbatim copies of the Program's source code as you
198 | receive it, in any medium, provided that you conspicuously and
199 | appropriately publish on each copy an appropriate copyright notice;
200 | keep intact all notices stating that this License and any
201 | non-permissive terms added in accord with section 7 apply to the code;
202 | keep intact all notices of the absence of any warranty; and give all
203 | recipients a copy of this License along with the Program.
204 |
205 | You may charge any price or no price for each copy that you convey,
206 | and you may offer support or warranty protection for a fee.
207 |
208 | 5. Conveying Modified Source Versions.
209 |
210 | You may convey a work based on the Program, or the modifications to
211 | produce it from the Program, in the form of source code under the
212 | terms of section 4, provided that you also meet all of these conditions:
213 |
214 | a) The work must carry prominent notices stating that you modified
215 | it, and giving a relevant date.
216 |
217 | b) The work must carry prominent notices stating that it is
218 | released under this License and any conditions added under section
219 | 7. This requirement modifies the requirement in section 4 to
220 | "keep intact all notices".
221 |
222 | c) You must license the entire work, as a whole, under this
223 | License to anyone who comes into possession of a copy. This
224 | License will therefore apply, along with any applicable section 7
225 | additional terms, to the whole of the work, and all its parts,
226 | regardless of how they are packaged. This License gives no
227 | permission to license the work in any other way, but it does not
228 | invalidate such permission if you have separately received it.
229 |
230 | d) If the work has interactive user interfaces, each must display
231 | Appropriate Legal Notices; however, if the Program has interactive
232 | interfaces that do not display Appropriate Legal Notices, your
233 | work need not make them do so.
234 |
235 | A compilation of a covered work with other separate and independent
236 | works, which are not by their nature extensions of the covered work,
237 | and which are not combined with it such as to form a larger program,
238 | in or on a volume of a storage or distribution medium, is called an
239 | "aggregate" if the compilation and its resulting copyright are not
240 | used to limit the access or legal rights of the compilation's users
241 | beyond what the individual works permit. Inclusion of a covered work
242 | in an aggregate does not cause this License to apply to the other
243 | parts of the aggregate.
244 |
245 | 6. Conveying Non-Source Forms.
246 |
247 | You may convey a covered work in object code form under the terms
248 | of sections 4 and 5, provided that you also convey the
249 | machine-readable Corresponding Source under the terms of this License,
250 | in one of these ways:
251 |
252 | a) Convey the object code in, or embodied in, a physical product
253 | (including a physical distribution medium), accompanied by the
254 | Corresponding Source fixed on a durable physical medium
255 | customarily used for software interchange.
256 |
257 | b) Convey the object code in, or embodied in, a physical product
258 | (including a physical distribution medium), accompanied by a
259 | written offer, valid for at least three years and valid for as
260 | long as you offer spare parts or customer support for that product
261 | model, to give anyone who possesses the object code either (1) a
262 | copy of the Corresponding Source for all the software in the
263 | product that is covered by this License, on a durable physical
264 | medium customarily used for software interchange, for a price no
265 | more than your reasonable cost of physically performing this
266 | conveying of source, or (2) access to copy the
267 | Corresponding Source from a network server at no charge.
268 |
269 | c) Convey individual copies of the object code with a copy of the
270 | written offer to provide the Corresponding Source. This
271 | alternative is allowed only occasionally and noncommercially, and
272 | only if you received the object code with such an offer, in accord
273 | with subsection 6b.
274 |
275 | d) Convey the object code by offering access from a designated
276 | place (gratis or for a charge), and offer equivalent access to the
277 | Corresponding Source in the same way through the same place at no
278 | further charge. You need not require recipients to copy the
279 | Corresponding Source along with the object code. If the place to
280 | copy the object code is a network server, the Corresponding Source
281 | may be on a different server (operated by you or a third party)
282 | that supports equivalent copying facilities, provided you maintain
283 | clear directions next to the object code saying where to find the
284 | Corresponding Source. Regardless of what server hosts the
285 | Corresponding Source, you remain obligated to ensure that it is
286 | available for as long as needed to satisfy these requirements.
287 |
288 | e) Convey the object code using peer-to-peer transmission, provided
289 | you inform other peers where the object code and Corresponding
290 | Source of the work are being offered to the general public at no
291 | charge under subsection 6d.
292 |
293 | A separable portion of the object code, whose source code is excluded
294 | from the Corresponding Source as a System Library, need not be
295 | included in conveying the object code work.
296 |
297 | A "User Product" is either (1) a "consumer product", which means any
298 | tangible personal property which is normally used for personal, family,
299 | or household purposes, or (2) anything designed or sold for incorporation
300 | into a dwelling. In determining whether a product is a consumer product,
301 | doubtful cases shall be resolved in favor of coverage. For a particular
302 | product received by a particular user, "normally used" refers to a
303 | typical or common use of that class of product, regardless of the status
304 | of the particular user or of the way in which the particular user
305 | actually uses, or expects or is expected to use, the product. A product
306 | is a consumer product regardless of whether the product has substantial
307 | commercial, industrial or non-consumer uses, unless such uses represent
308 | the only significant mode of use of the product.
309 |
310 | "Installation Information" for a User Product means any methods,
311 | procedures, authorization keys, or other information required to install
312 | and execute modified versions of a covered work in that User Product from
313 | a modified version of its Corresponding Source. The information must
314 | suffice to ensure that the continued functioning of the modified object
315 | code is in no case prevented or interfered with solely because
316 | modification has been made.
317 |
318 | If you convey an object code work under this section in, or with, or
319 | specifically for use in, a User Product, and the conveying occurs as
320 | part of a transaction in which the right of possession and use of the
321 | User Product is transferred to the recipient in perpetuity or for a
322 | fixed term (regardless of how the transaction is characterized), the
323 | Corresponding Source conveyed under this section must be accompanied
324 | by the Installation Information. But this requirement does not apply
325 | if neither you nor any third party retains the ability to install
326 | modified object code on the User Product (for example, the work has
327 | been installed in ROM).
328 |
329 | The requirement to provide Installation Information does not include a
330 | requirement to continue to provide support service, warranty, or updates
331 | for a work that has been modified or installed by the recipient, or for
332 | the User Product in which it has been modified or installed. Access to a
333 | network may be denied when the modification itself materially and
334 | adversely affects the operation of the network or violates the rules and
335 | protocols for communication across the network.
336 |
337 | Corresponding Source conveyed, and Installation Information provided,
338 | in accord with this section must be in a format that is publicly
339 | documented (and with an implementation available to the public in
340 | source code form), and must require no special password or key for
341 | unpacking, reading or copying.
342 |
343 | 7. Additional Terms.
344 |
345 | "Additional permissions" are terms that supplement the terms of this
346 | License by making exceptions from one or more of its conditions.
347 | Additional permissions that are applicable to the entire Program shall
348 | be treated as though they were included in this License, to the extent
349 | that they are valid under applicable law. If additional permissions
350 | apply only to part of the Program, that part may be used separately
351 | under those permissions, but the entire Program remains governed by
352 | this License without regard to the additional permissions.
353 |
354 | When you convey a copy of a covered work, you may at your option
355 | remove any additional permissions from that copy, or from any part of
356 | it. (Additional permissions may be written to require their own
357 | removal in certain cases when you modify the work.) You may place
358 | additional permissions on material, added by you to a covered work,
359 | for which you have or can give appropriate copyright permission.
360 |
361 | Notwithstanding any other provision of this License, for material you
362 | add to a covered work, you may (if authorized by the copyright holders of
363 | that material) supplement the terms of this License with terms:
364 |
365 | a) Disclaiming warranty or limiting liability differently from the
366 | terms of sections 15 and 16 of this License; or
367 |
368 | b) Requiring preservation of specified reasonable legal notices or
369 | author attributions in that material or in the Appropriate Legal
370 | Notices displayed by works containing it; or
371 |
372 | c) Prohibiting misrepresentation of the origin of that material, or
373 | requiring that modified versions of such material be marked in
374 | reasonable ways as different from the original version; or
375 |
376 | d) Limiting the use for publicity purposes of names of licensors or
377 | authors of the material; or
378 |
379 | e) Declining to grant rights under trademark law for use of some
380 | trade names, trademarks, or service marks; or
381 |
382 | f) Requiring indemnification of licensors and authors of that
383 | material by anyone who conveys the material (or modified versions of
384 | it) with contractual assumptions of liability to the recipient, for
385 | any liability that these contractual assumptions directly impose on
386 | those licensors and authors.
387 |
388 | All other non-permissive additional terms are considered "further
389 | restrictions" within the meaning of section 10. If the Program as you
390 | received it, or any part of it, contains a notice stating that it is
391 | governed by this License along with a term that is a further
392 | restriction, you may remove that term. If a license document contains
393 | a further restriction but permits relicensing or conveying under this
394 | License, you may add to a covered work material governed by the terms
395 | of that license document, provided that the further restriction does
396 | not survive such relicensing or conveying.
397 |
398 | If you add terms to a covered work in accord with this section, you
399 | must place, in the relevant source files, a statement of the
400 | additional terms that apply to those files, or a notice indicating
401 | where to find the applicable terms.
402 |
403 | Additional terms, permissive or non-permissive, may be stated in the
404 | form of a separately written license, or stated as exceptions;
405 | the above requirements apply either way.
406 |
407 | 8. Termination.
408 |
409 | You may not propagate or modify a covered work except as expressly
410 | provided under this License. Any attempt otherwise to propagate or
411 | modify it is void, and will automatically terminate your rights under
412 | this License (including any patent licenses granted under the third
413 | paragraph of section 11).
414 |
415 | However, if you cease all violation of this License, then your
416 | license from a particular copyright holder is reinstated (a)
417 | provisionally, unless and until the copyright holder explicitly and
418 | finally terminates your license, and (b) permanently, if the copyright
419 | holder fails to notify you of the violation by some reasonable means
420 | prior to 60 days after the cessation.
421 |
422 | Moreover, your license from a particular copyright holder is
423 | reinstated permanently if the copyright holder notifies you of the
424 | violation by some reasonable means, this is the first time you have
425 | received notice of violation of this License (for any work) from that
426 | copyright holder, and you cure the violation prior to 30 days after
427 | your receipt of the notice.
428 |
429 | Termination of your rights under this section does not terminate the
430 | licenses of parties who have received copies or rights from you under
431 | this License. If your rights have been terminated and not permanently
432 | reinstated, you do not qualify to receive new licenses for the same
433 | material under section 10.
434 |
435 | 9. Acceptance Not Required for Having Copies.
436 |
437 | You are not required to accept this License in order to receive or
438 | run a copy of the Program. Ancillary propagation of a covered work
439 | occurring solely as a consequence of using peer-to-peer transmission
440 | to receive a copy likewise does not require acceptance. However,
441 | nothing other than this License grants you permission to propagate or
442 | modify any covered work. These actions infringe copyright if you do
443 | not accept this License. Therefore, by modifying or propagating a
444 | covered work, you indicate your acceptance of this License to do so.
445 |
446 | 10. Automatic Licensing of Downstream Recipients.
447 |
448 | Each time you convey a covered work, the recipient automatically
449 | receives a license from the original licensors, to run, modify and
450 | propagate that work, subject to this License. You are not responsible
451 | for enforcing compliance by third parties with this License.
452 |
453 | An "entity transaction" is a transaction transferring control of an
454 | organization, or substantially all assets of one, or subdividing an
455 | organization, or merging organizations. If propagation of a covered
456 | work results from an entity transaction, each party to that
457 | transaction who receives a copy of the work also receives whatever
458 | licenses to the work the party's predecessor in interest had or could
459 | give under the previous paragraph, plus a right to possession of the
460 | Corresponding Source of the work from the predecessor in interest, if
461 | the predecessor has it or can get it with reasonable efforts.
462 |
463 | You may not impose any further restrictions on the exercise of the
464 | rights granted or affirmed under this License. For example, you may
465 | not impose a license fee, royalty, or other charge for exercise of
466 | rights granted under this License, and you may not initiate litigation
467 | (including a cross-claim or counterclaim in a lawsuit) alleging that
468 | any patent claim is infringed by making, using, selling, offering for
469 | sale, or importing the Program or any portion of it.
470 |
471 | 11. Patents.
472 |
473 | A "contributor" is a copyright holder who authorizes use under this
474 | License of the Program or a work on which the Program is based. The
475 | work thus licensed is called the contributor's "contributor version".
476 |
477 | A contributor's "essential patent claims" are all patent claims
478 | owned or controlled by the contributor, whether already acquired or
479 | hereafter acquired, that would be infringed by some manner, permitted
480 | by this License, of making, using, or selling its contributor version,
481 | but do not include claims that would be infringed only as a
482 | consequence of further modification of the contributor version. For
483 | purposes of this definition, "control" includes the right to grant
484 | patent sublicenses in a manner consistent with the requirements of
485 | this License.
486 |
487 | Each contributor grants you a non-exclusive, worldwide, royalty-free
488 | patent license under the contributor's essential patent claims, to
489 | make, use, sell, offer for sale, import and otherwise run, modify and
490 | propagate the contents of its contributor version.
491 |
492 | In the following three paragraphs, a "patent license" is any express
493 | agreement or commitment, however denominated, not to enforce a patent
494 | (such as an express permission to practice a patent or covenant not to
495 | sue for patent infringement). To "grant" such a patent license to a
496 | party means to make such an agreement or commitment not to enforce a
497 | patent against the party.
498 |
499 | If you convey a covered work, knowingly relying on a patent license,
500 | and the Corresponding Source of the work is not available for anyone
501 | to copy, free of charge and under the terms of this License, through a
502 | publicly available network server or other readily accessible means,
503 | then you must either (1) cause the Corresponding Source to be so
504 | available, or (2) arrange to deprive yourself of the benefit of the
505 | patent license for this particular work, or (3) arrange, in a manner
506 | consistent with the requirements of this License, to extend the patent
507 | license to downstream recipients. "Knowingly relying" means you have
508 | actual knowledge that, but for the patent license, your conveying the
509 | covered work in a country, or your recipient's use of the covered work
510 | in a country, would infringe one or more identifiable patents in that
511 | country that you have reason to believe are valid.
512 |
513 | If, pursuant to or in connection with a single transaction or
514 | arrangement, you convey, or propagate by procuring conveyance of, a
515 | covered work, and grant a patent license to some of the parties
516 | receiving the covered work authorizing them to use, propagate, modify
517 | or convey a specific copy of the covered work, then the patent license
518 | you grant is automatically extended to all recipients of the covered
519 | work and works based on it.
520 |
521 | A patent license is "discriminatory" if it does not include within
522 | the scope of its coverage, prohibits the exercise of, or is
523 | conditioned on the non-exercise of one or more of the rights that are
524 | specifically granted under this License. You may not convey a covered
525 | work if you are a party to an arrangement with a third party that is
526 | in the business of distributing software, under which you make payment
527 | to the third party based on the extent of your activity of conveying
528 | the work, and under which the third party grants, to any of the
529 | parties who would receive the covered work from you, a discriminatory
530 | patent license (a) in connection with copies of the covered work
531 | conveyed by you (or copies made from those copies), or (b) primarily
532 | for and in connection with specific products or compilations that
533 | contain the covered work, unless you entered into that arrangement,
534 | or that patent license was granted, prior to 28 March 2007.
535 |
536 | Nothing in this License shall be construed as excluding or limiting
537 | any implied license or other defenses to infringement that may
538 | otherwise be available to you under applicable patent law.
539 |
540 | 12. No Surrender of Others' Freedom.
541 |
542 | If conditions are imposed on you (whether by court order, agreement or
543 | otherwise) that contradict the conditions of this License, they do not
544 | excuse you from the conditions of this License. If you cannot convey a
545 | covered work so as to satisfy simultaneously your obligations under this
546 | License and any other pertinent obligations, then as a consequence you may
547 | not convey it at all. For example, if you agree to terms that obligate you
548 | to collect a royalty for further conveying from those to whom you convey
549 | the Program, the only way you could satisfy both those terms and this
550 | License would be to refrain entirely from conveying the Program.
551 |
552 | 13. Use with the GNU Affero General Public License.
553 |
554 | Notwithstanding any other provision of this License, you have
555 | permission to link or combine any covered work with a work licensed
556 | under version 3 of the GNU Affero General Public License into a single
557 | combined work, and to convey the resulting work. The terms of this
558 | License will continue to apply to the part which is the covered work,
559 | but the special requirements of the GNU Affero General Public License,
560 | section 13, concerning interaction through a network will apply to the
561 | combination as such.
562 |
563 | 14. Revised Versions of this License.
564 |
565 | The Free Software Foundation may publish revised and/or new versions of
566 | the GNU General Public License from time to time. Such new versions will
567 | be similar in spirit to the present version, but may differ in detail to
568 | address new problems or concerns.
569 |
570 | Each version is given a distinguishing version number. If the
571 | Program specifies that a certain numbered version of the GNU General
572 | Public License "or any later version" applies to it, you have the
573 | option of following the terms and conditions either of that numbered
574 | version or of any later version published by the Free Software
575 | Foundation. If the Program does not specify a version number of the
576 | GNU General Public License, you may choose any version ever published
577 | by the Free Software Foundation.
578 |
579 | If the Program specifies that a proxy can decide which future
580 | versions of the GNU General Public License can be used, that proxy's
581 | public statement of acceptance of a version permanently authorizes you
582 | to choose that version for the Program.
583 |
584 | Later license versions may give you additional or different
585 | permissions. However, no additional obligations are imposed on any
586 | author or copyright holder as a result of your choosing to follow a
587 | later version.
588 |
589 | 15. Disclaimer of Warranty.
590 |
591 | THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY
592 | APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT
593 | HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY
594 | OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO,
595 | THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
596 | PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM
597 | IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF
598 | ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
599 |
600 | 16. Limitation of Liability.
601 |
602 | IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
603 | WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS
604 | THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY
605 | GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE
606 | USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF
607 | DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD
608 | PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS),
609 | EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF
610 | SUCH DAMAGES.
611 |
612 | 17. Interpretation of Sections 15 and 16.
613 |
614 | If the disclaimer of warranty and limitation of liability provided
615 | above cannot be given local legal effect according to their terms,
616 | reviewing courts shall apply local law that most closely approximates
617 | an absolute waiver of all civil liability in connection with the
618 | Program, unless a warranty or assumption of liability accompanies a
619 | copy of the Program in return for a fee.
620 |
621 | END OF TERMS AND CONDITIONS
622 |
623 | How to Apply These Terms to Your New Programs
624 |
625 | If you develop a new program, and you want it to be of the greatest
626 | possible use to the public, the best way to achieve this is to make it
627 | free software which everyone can redistribute and change under these terms.
628 |
629 | To do so, attach the following notices to the program. It is safest
630 | to attach them to the start of each source file to most effectively
631 | state the exclusion of warranty; and each file should have at least
632 | the "copyright" line and a pointer to where the full notice is found.
633 |
634 |
635 | Copyright (C)
636 |
637 | This program is free software: you can redistribute it and/or modify
638 | it under the terms of the GNU General Public License as published by
639 | the Free Software Foundation, either version 3 of the License, or
640 | (at your option) any later version.
641 |
642 | This program is distributed in the hope that it will be useful,
643 | but WITHOUT ANY WARRANTY; without even the implied warranty of
644 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
645 | GNU General Public License for more details.
646 |
647 | You should have received a copy of the GNU General Public License
648 | along with this program. If not, see .
649 |
650 | Also add information on how to contact you by electronic and paper mail.
651 |
652 | If the program does terminal interaction, make it output a short
653 | notice like this when it starts in an interactive mode:
654 |
655 | Copyright (C)
656 | This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
657 | This is free software, and you are welcome to redistribute it
658 | under certain conditions; type `show c' for details.
659 |
660 | The hypothetical commands `show w' and `show c' should show the appropriate
661 | parts of the General Public License. Of course, your program's commands
662 | might be different; for a GUI interface, you would use an "about box".
663 |
664 | You should also get your employer (if you work as a programmer) or school,
665 | if any, to sign a "copyright disclaimer" for the program, if necessary.
666 | For more information on this, and how to apply and follow the GNU GPL, see
667 | .
668 |
669 | The GNU General Public License does not permit incorporating your program
670 | into proprietary programs. If your program is a subroutine library, you
671 | may consider it more useful to permit linking proprietary applications with
672 | the library. If this is what you want to do, use the GNU Lesser General
673 | Public License instead of this License. But first, please read
674 | .
675 |
--------------------------------------------------------------------------------