Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
ogptoolbox-ui
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
53
Issues
53
List
Boards
Labels
Service Desk
Milestones
Merge Requests
0
Merge Requests
0
Operations
Operations
Incidents
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
ogptoolbox
ogptoolbox-ui
Commits
198a0b45
Commit
198a0b45
authored
Feb 23, 2017
by
Emmanuel Raviart
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add preliminary support for Piwik analytics.
parent
5f23897d
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
72 additions
and
26 deletions
+72
-26
src/Analytics.elm
src/Analytics.elm
+7
-0
src/Configuration.elm
src/Configuration.elm
+6
-0
src/Ports.elm
src/Ports.elm
+8
-0
src/Root/State.elm
src/Root/State.elm
+36
-26
static/js/index.js
static/js/index.js
+15
-0
No files found.
src/Analytics.elm
0 → 100644
View file @
198a0b45
module
Analytics
exposing
(
..
)
type
alias
PiwikConfiguration
=
{
piwikDomain
:
String
,
siteId
:
String
}
src/Configuration.elm
View file @
198a0b45
module
Configuration
exposing
(
..
)
import
Analytics
import
Dict
exposing
(
Dict
)
...
...
@@ -14,6 +15,11 @@ appUrl =
"
http://localhost:3011/"
piwik
:
Maybe
Analytics
.
PiwikConfiguration
piwik
=
Nothing
twitterName
:
String
twitterName
=
"
@OGPToolbox"
...
...
src/Ports.elm
View file @
198a0b45
port
module
Ports
exposing
(
..
)
import
Analytics
import
Configuration
import
Types
exposing
(
DocumentMetadata
,
PopularTag
,
User
)
import
Urls
...
...
@@ -77,6 +78,13 @@ port fileContentRead : (ImagePortData -> msg) -> Sub msg
-- PIWIK
port
initPiwikAnalytics
:
Analytics
.
PiwikConfiguration
->
Cmd
msg
-- SHARERS
...
...
src/Root/State.elm
View file @
198a0b45
...
...
@@ -9,6 +9,7 @@ import Collections.Item.State
import
Collections
.
Edit
.
State
import
Collections
.
Index
.
State
import
Collections
.
Index
.
Types
import
Configuration
import
Decoders
import
Dict
exposing
(
Dict
)
import
Dom
.
Scroll
...
...
@@ -30,32 +31,41 @@ import Urls
init
:
Flags
->
Navigation
.
Location
->
(
Model
,
Cmd
Msg
)
init
flags
location
=
{
authentication
=
Json
.
Decode
.
decodeValue
Decoders
.
userDecoder
flags
.
authentication
|>
Result
.
toMaybe
,
authenticatorCancelMsg
=
Nothing
,
authenticatorCompletionMsg
=
Nothing
,
authenticatorModel
=
Authenticator
.
State
.
init
,
authenticatorRoute
=
Nothing
,
cardModel
=
Cards
.
Item
.
State
.
init
,
cardNewModel
=
Cards
.
New
.
State
.
init
,
collectionEditModel
=
Collections
.
Edit
.
State
.
init
,
collectionModel
=
Collections
.
Item
.
State
.
init
,
collectionsModel
=
Collections
.
Index
.
State
.
init
,
displayNewCardModal
=
False
,
location
=
location
,
navigatorLanguage
=
flags
.
language
|>
String
.
left
2
|>
String
.
toLower
|>
I18n
.
languageFromIso639_1
,
route
=
I18nRouteWithoutLanguage
"
"
,
searchInputValue
=
"
"
,
searchModel
=
Search
.
State
.
init
,
signOutMsg
=
Nothing
,
userProfileModel
=
UserProfile
.
State
.
init
}
|>
update
(
LocationChanged
location
)
let
(
model
,
cmd
)
=
{
authentication
=
Json
.
Decode
.
decodeValue
Decoders
.
userDecoder
flags
.
authentication
|>
Result
.
toMaybe
,
authenticatorCancelMsg
=
Nothing
,
authenticatorCompletionMsg
=
Nothing
,
authenticatorModel
=
Authenticator
.
State
.
init
,
authenticatorRoute
=
Nothing
,
cardModel
=
Cards
.
Item
.
State
.
init
,
cardNewModel
=
Cards
.
New
.
State
.
init
,
collectionEditModel
=
Collections
.
Edit
.
State
.
init
,
collectionModel
=
Collections
.
Item
.
State
.
init
,
collectionsModel
=
Collections
.
Index
.
State
.
init
,
displayNewCardModal
=
False
,
location
=
location
,
navigatorLanguage
=
flags
.
language
|>
String
.
left
2
|>
String
.
toLower
|>
I18n
.
languageFromIso639_1
,
route
=
I18nRouteWithoutLanguage
"
"
,
searchInputValue
=
"
"
,
searchModel
=
Search
.
State
.
init
,
signOutMsg
=
Nothing
,
userProfileModel
=
UserProfile
.
State
.
init
}
|>
update
(
LocationChanged
location
)
in
case
Configuration
.
piwik
of
Just
piwik
->
model
!
[
cmd
,
Ports
.
initPiwikAnalytics
piwik
]
Nothing
->
(
model
,
cmd
)
navigate
:
String
->
String
->
Cmd
msg
...
...
static/js/index.js
View file @
198a0b45
...
...
@@ -75,6 +75,21 @@ main.ports.fileSelected.subscribe(function (id) {
});
main
.
ports
.
initPiwikAnalytics
.
subscribe
(
function
(
configuration
)
{
var
_paq
=
_paq
||
[];
// Tracker methods like "setCustomDimension" should be called before "trackPageView".
_paq
.
push
([
'
trackPageView
'
]);
_paq
.
push
([
'
enableLinkTracking
'
]);
(
function
()
{
var
u
=
"
//
"
+
configuration
.
piwikDomain
+
"
/
"
;
_paq
.
push
([
'
setTrackerUrl
'
,
u
+
'
piwik.php
'
]);
_paq
.
push
([
'
setSiteId
'
,
configuration
.
siteId
]);
var
d
=
document
,
g
=
d
.
createElement
(
'
script
'
),
s
=
d
.
getElementsByTagName
(
'
script
'
)[
0
];
g
.
type
=
'
text/javascript
'
;
g
.
async
=
true
;
g
.
defer
=
true
;
g
.
src
=
u
+
'
piwik.js
'
;
s
.
parentNode
.
insertBefore
(
g
,
s
);
})();
});
main
.
ports
.
mountd3bubbles
.
subscribe
(
function
(
data
)
{
// Remove previous D3 bubbles instances if present in the DOM.
Array
.
prototype
.
forEach
.
call
(
document
.
querySelectorAll
(
"
svg.D3Bubbles
"
),
function
(
node
)
{
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment