Skip to content

Commit

Permalink
Merge pull request #24 from ngageoint/matomo
Browse files Browse the repository at this point in the history
Adding Matomo
  • Loading branch information
jclark118 authored Oct 17, 2024
2 parents bd564f1 + 2aabc87 commit 333a129
Show file tree
Hide file tree
Showing 28 changed files with 690 additions and 428 deletions.
14 changes: 8 additions & 6 deletions BUILD.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
### Windows
* Install Visual Studio 19 w/ Desktop development with C++ workload
* Install Python 2.7
* Install Node 18.13.0
* Install Node 18.17.0
* Install Git for windows
* Install GTK+ (version 2.22.1, do NOT get version 3)
* Install libjpeg-turbo64
Expand Down Expand Up @@ -184,8 +184,10 @@ Software source code previously released under an open source license and then m
# Releasing a New Version
1. Update package.json version
2. Add a changelog file for the version describing new features added and bugs fixed
3. Commit changes
4. Tag version
5. Build windows, linux and mac installers
6. Notarize mac installers
7. Create release on github for the new version and upload all the installer files
3. Enable Matomo in env
4. Commit changes
5. Tag version
6. Build windows, linux and mac installers
7. Notarize mac installers
8. Create release on github for the new version and upload all the installer files
9. You'll need to generate builds for all different environments in order to have the correct matomo urls
30 changes: 30 additions & 0 deletions changelog/v1.6.2.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
# MapCache Desktop - v1.6.2

Patch release 1.6.2

## New Features
* Matomo user metrics logging added'
* Consent banner added


## Bug Fixes
* Fixed shp file import'

## Previous Versions
* [v1.6.1](https://github.com/ngageoint/mapcache-electron/blob/v1.6.1/changelog/v1.6.1.md)
* [v1.6.0](https://github.com/ngageoint/mapcache-electron/blob/v1.6.0/changelog/v1.6.0.md)
* [v1.5.1](https://github.com/ngageoint/mapcache-electron/blob/v1.5.1/changelog/v1.5.1.md)
* [v1.5.0](https://github.com/ngageoint/mapcache-electron/blob/v1.5.0/changelog/v1.5.0.md)
* [v1.4.0](https://github.com/ngageoint/mapcache-electron/blob/v1.4.0/changelog/v1.4.0.md)
* [v1.3.1](https://github.com/ngageoint/mapcache-electron/blob/v1.3.1/changelog/v1.3.1.md)
* [v1.3.0](https://github.com/ngageoint/mapcache-electron/blob/v1.3.0/changelog/v1.3.0.md)
* [v1.2.0](https://github.com/ngageoint/mapcache-electron/blob/v1.2.0/changelog/v1.2.0.md)
* [v1.1.1](https://github.com/ngageoint/mapcache-electron/blob/v1.1.1/changelog/v1.1.1.md)
* [v1.1.0](https://github.com/ngageoint/mapcache-electron/blob/v1.1.0/changelog/v1.1.0.md)
* [v1.0.9](https://github.com/ngageoint/mapcache-electron/blob/v1.0.9/changelog/v1.0.9.md)
* [v1.0.8](https://github.com/ngageoint/mapcache-electron/blob/v1.0.8/changelog/v1.0.8.md)
* [v1.0.7](https://github.com/ngageoint/mapcache-electron/blob/v1.0.7/changelog/v1.0.7.md)
* [v1.0.6](https://github.com/ngageoint/mapcache-electron/blob/v1.0.6/changelog/v1.0.6.md)
* [v1.0.5](https://github.com/ngageoint/mapcache-electron/blob/v1.0.5/changelog/v1.0.5.md)
* [v1.0.4](https://github.com/ngageoint/mapcache-electron/blob/v1.0.5/changelog/v1.0.4.md)
* [v1.0.3](https://github.com/ngageoint/mapcache-electron/blob/v1.0.5/changelog/v1.0.3.md)
7 changes: 5 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "mapcache",
"version": "1.6.1",
"version": "1.6.2",
"description": "Desktop Electron app to create GeoPackages from geospatial data sources.",
"author": "Christopher Caldwell <[email protected]> (https://github.com/caldwellc)",
"scripts": {
Expand Down Expand Up @@ -67,6 +67,7 @@
"sanitize-html": "^2.7.0",
"sax": "^1.2.4",
"sharp": "0.32.6",
"shpjs": "4.0.4",
"sortablejs": "^1.15.0",
"stream-chain": "^2.2.5",
"stream-json": "^1.8.0",
Expand All @@ -75,6 +76,7 @@
"uuid": "^9.0.0",
"vector-tile": "^1.3.0",
"vue": "^3.3.4",
"vue-matomo": "^4.2.0",
"vue-observe-visibility": "^1.0.0",
"vue-router": "^4.2.2",
"vuetify": "3.5.12",
Expand All @@ -97,7 +99,8 @@
"better-sqlite3": "8.4.0",
"bindings": "git://github.com/caldwellc/node-bindings.git#master",
"canvas": "git://github.com/jclark118/empty-module.git#main",
"minimatch": "9.0.5"
"minimatch": "9.0.5",
"rollup": "^3.29.5"
},
"contributors": [
{
Expand Down
4 changes: 4 additions & 0 deletions src/lib/env/env.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,10 @@ const environment = {
geopackageLibrariesUrl: 'https://ngageoint.github.io/GeoPackage',
eventkitUrl: 'https://eventkit.gs.mil',
surveyUrl: 'https://portal.geo.nga.mil/survey123/share/93444389134845e79d79f18a11ab17d3',
matomoUrl: 'https://webanalytics.nga.mil/',
matomoJsUrl: 'https://webanalytics.nga.mil//matomo.js',
matomoSiteId: '',
matomoEnabled: false,
preloadedDataSources: []
}

Expand Down
8 changes: 5 additions & 3 deletions src/lib/source/shapefile/ShapeFileSource.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import fs from 'node:fs'
import path from 'node:path'
import AdmZip from 'adm-zip'
// import shp from 'shpjs'
import shpjs from 'shpjs'

import Source from '../Source'
import GeoTIFFSource from '../geotiff/GeoTIFFSource'
Expand Down Expand Up @@ -86,16 +86,18 @@ export default class ShapeFileSource extends Source {
await sleep(250)

if (isZip) {
const result = await shp.parseZip(fs.readFileSync(this.filePath))
let fileBuffer = Buffer.from(fs.readFileSync(this.filePath))
const result = await shpjs.parseZip(fileBuffer)
if (result.length == null) {
featureCollections.push(result)
} else {
featureCollections = result
}
} else {
const result = await shpjs.parseShp(fs.readFileSync(this.filePath))
featureCollections.push({
type: 'FeatureCollection',
features: shp.parseShp(fs.readFileSync(this.filePath)),
features: result,
fileName: name
})
}
Expand Down
5 changes: 5 additions & 0 deletions src/lib/vue/vuex/ProjectActions.js
Original file line number Diff line number Diff line change
Expand Up @@ -553,6 +553,10 @@ function setActiveGeoPackageFeatureLayer (projectId, geopackageId, tableName) {
}
}

function setConsent (consent) {
return store.dispatch('UIState/setConsent', {consent})
}

function setDarkTheme (projectId, enabled) {
return store.dispatch('UIState/setDarkTheme', { projectId, enabled })
}
Expand Down Expand Up @@ -724,6 +728,7 @@ export {
setActiveGeoPackage,
setActiveGeoPackageFeatureLayer,
updateStyleKey,
setConsent,
setDarkTheme,
notifyTab,
clearNotification,
Expand Down
7 changes: 6 additions & 1 deletion src/main/lib/MapCacheWindowManager.js
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,8 @@ import {
UNDO,
REQUEST_TILE_COMPILATION,
REQUEST_TILE_COMPILATION_COMPLETED,
CANCEL_TILE_COMPILATION_REQUEST, WEB_VIEW_AUTH_REQUEST, WEB_VIEW_AUTH_CANCEL
CANCEL_TILE_COMPILATION_REQUEST, WEB_VIEW_AUTH_REQUEST, WEB_VIEW_AUTH_CANCEL,
CLOSE_APP
} from './ipc/MapCacheIPC'
import windowStateKeeper from 'electron-window-state'
import WebViewAuth from './auth/WebViewAuth'
Expand Down Expand Up @@ -541,6 +542,10 @@ class MapCacheWindowManager {
const taskId = payload.id
await this.mapcacheThreadHelper.cancelTask(taskId, false)
})

ipcMain.on(CLOSE_APP, () => {
app.quit()
})
}
}

Expand Down
8 changes: 6 additions & 2 deletions src/main/lib/ipc/MapCacheIPC.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ const SHOW_PROJECT = 'show-project'
const CLOSE_PROJECT = 'close-project'
const CLOSING_PROJECT_WINDOW = 'closing-project-window'
const PROCESS_SOURCE = 'process-source'
const CLOSE_APP = 'close-app'


function PROCESS_SOURCE_COMPLETED (id) {
return 'process-source-completed-' + id
Expand Down Expand Up @@ -169,7 +171,8 @@ const MAIN_CHANNELS = [
BUILD_TILE_LAYER,
CANCEL_BUILD_TILE_LAYER,
WORKER_READY,
LAUNCH_USER_GUIDE
LAUNCH_USER_GUIDE,
CLOSE_APP
]

const WORKER_CHANNELS = [
Expand Down Expand Up @@ -267,5 +270,6 @@ export {
REDO,
WEB_VIEW_AUTH_REQUEST,
WEB_VIEW_AUTH_RESPONSE,
WEB_VIEW_AUTH_CANCEL
WEB_VIEW_AUTH_CANCEL,
CLOSE_APP
}
5 changes: 4 additions & 1 deletion src/preload/mainPreload.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import path from 'path'
import { deleteProjectFolder } from '../lib/vue/vuex/CommonPreloadFunctions'
import { createNextAvailableLayerDirectory, createNextAvailableProjectDirectory, createNextAvailableSourceDirectory } from '../lib/util/file/FileUtilities'
import { createUniqueID } from '../lib/util/UniqueIDUtilities'
import { GET_APP_VERSION, GET_USER_DATA_DIRECTORY, LAUNCH_WITH_GEOPACKAGE_FILES, OPEN_EXTERNAL, SHOW_PROJECT } from '../main/lib/ipc/MapCacheIPC'
import { GET_APP_VERSION, GET_USER_DATA_DIRECTORY, LAUNCH_WITH_GEOPACKAGE_FILES, OPEN_EXTERNAL, SHOW_PROJECT, CLOSE_APP } from '../main/lib/ipc/MapCacheIPC'
import { Context, HtmlCanvasAdapter, SqliteAdapter } from '@ngageoint/geopackage'
import { environment } from '../lib/env/env'
import { vuexElectronAPI } from './vuexPreload'
Expand Down Expand Up @@ -45,6 +45,9 @@ contextBridge.exposeInMainWorld('mapcache', {
ipcRenderer.send(OPEN_EXTERNAL, link)
}
},
closeApp: () => {
ipcRenderer.send(CLOSE_APP)
},
setupGeoPackageContext: () => {
Context.setupCustomContext(SqliteAdapter, HtmlCanvasAdapter)
},
Expand Down
2 changes: 1 addition & 1 deletion src/renderer/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<meta name="viewport" content="width=device-width,initial-scale=1.0">
<link rel="icon" href="/favicon.ico">
<title>MapCache</title>
<meta http-equiv="Content-Security-Policy" content="default-src * blob: 'unsafe-inline'; frame-src blob: 'unsafe-inline'; script-src 'self' 'unsafe-inline'; style-src * 'unsafe-inline'; img-src * http: https: data: file: mapcache: blob:">
<meta http-equiv="Content-Security-Policy" content="default-src * blob: 'unsafe-inline'; frame-src blob: 'unsafe-inline'; script-src 'self' 'unsafe-inline' https://webanalytics.nga.mil/; style-src * 'unsafe-inline'; img-src * http: https: data: file: mapcache: blob:">
</head>
<body class="noselect">
<noscript>
Expand Down
8 changes: 8 additions & 0 deletions src/renderer/src/main.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { createApp, isProxy, toRaw } from 'vue'
import VueMatomo from 'vue-matomo'
import App from './views/App.vue'
import router from './router'
import vuetify from '../../lib/vue/vuetify/vuetify' // path to vuetify export
Expand All @@ -16,6 +17,7 @@ import modules from './store/modules'
import { ObserveVisibility } from 'vue-observe-visibility'
import sanitizeHTML from 'sanitize-html'
import Sortable from 'sortablejs'
import { environment } from '../../lib/env/env'

if (window && window.log) {
// update console log functions to utilize the window's log functions. Also, make sure we don't send anything too complicated otherwise it will error out.
Expand Down Expand Up @@ -140,6 +142,12 @@ window.deproxy = (obj) => {

/* eslint-disable no-new */
const app = createApp(App).use(vuetify).use(router).use(store)
if(environment.matomoEnabled){
app.use(VueMatomo, {
host: environment.matomoUrl,
siteId: environment.matomoSiteId
})
}
app.config.globalProperties.$sanitize = sanitizeHTML
app.config.globalProperties.showToolTips = false
app.config.productionTip = false
Expand Down
10 changes: 9 additions & 1 deletion src/renderer/src/store/modules/UIState.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
const getDefaultState = () => {
return {}
return {
consent: false
}
}

const state = getDefaultState()
Expand Down Expand Up @@ -28,6 +30,9 @@ const mutations = {
deleteProject (state, { projectId }) {
delete state[projectId]
},
setConsent (state, consent) {
state.consent = consent
},
setDarkTheme (state, { projectId, enabled }) {
state[projectId].dark = enabled
},
Expand Down Expand Up @@ -77,6 +82,9 @@ const actions = {
deleteProject ({ commit }, { projectId }) {
commit('deleteProject', { projectId })
},
setConsent ({ commit }, consent) {
commit('setConsent', consent)
},
setDarkTheme ({ commit }, { projectId, enabled }) {
commit('setDarkTheme', { projectId, enabled })
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -248,6 +248,9 @@ export default {
this.featureLayerField.name = name
},
addField () {
if(this.$matomo){
this.$matomo.trackEvent("GPKG modified", "Created feature field");
}
this.addFieldDialog = false
addGeoPackageFeatureTableColumn(this.projectId, this.id, this.isGeoPackage, this.tableName, this.addFieldValue, this.addFieldType).then(() => {
this.addFieldValue = ''
Expand Down
3 changes: 3 additions & 0 deletions src/renderer/src/views/DataSources/AddDataSourceUrl.vue
Original file line number Diff line number Diff line change
Expand Up @@ -479,6 +479,9 @@ export default {
}
},
async addLayer () {
if(this.$matomo){
this.$matomo.trackEvent("Data Source", "Data Source URL added");
}
if (this.selectedServiceType === SERVICE_TYPE.XYZ) {
await this.processXYZUrl(window.mapcache.fixXYZTileServerUrlForLeaflet(this.dataSourceUrl), this.xyzProjection)
} else {
Expand Down
3 changes: 3 additions & 0 deletions src/renderer/src/views/DataSources/DataSources.vue
Original file line number Diff line number Diff line change
Expand Up @@ -201,6 +201,9 @@ export default {
properties: ['openFile', 'multiSelections']
}).then((result) => {
if (result.filePaths && !isEmpty(result.filePaths)) {
if(this.$matomo){
this.$matomo.trackEvent("Data Source", "Data Source File added");
}
this.processFiles(window.mapcache.getFileListInfo(result.filePaths))
}
})
Expand Down
8 changes: 8 additions & 0 deletions src/renderer/src/views/Documentation/ReleaseNotes.vue
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,14 @@ export default {
return {
releaseNotes: [
{
title: 'MapCache 1.6.2',
releaseDate: 'Oct 21, 2024',
bugFixes: [
'Fixed shp file import',
'Matomo user metrics logging added',
'Consent banner added'
]
},{
title: 'MapCache 1.6.1',
releaseDate: 'Sept 30, 2024',
bugFixes: [
Expand Down
4 changes: 4 additions & 0 deletions src/renderer/src/views/Documentation/UserGuide.vue
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ import GettingStarted from './UserGuide/GettingStarted.vue'
import UsingMapCache from './UserGuide/UsingMapCache.vue'
import Settings from './UserGuide/Settings.vue'
import FrequentlyAskedQuestions from './UserGuide/FrequentlyAskedQuestions.vue'
import VueMatomo from 'vue-matomo'
export default {
components: { FrequentlyAskedQuestions, Settings, GettingStarted, UsingMapCache },
Expand Down Expand Up @@ -93,6 +94,9 @@ export default {
mounted () {
this.toTop(false)
this.loaded = true
if(this.$matomo){
this.$matomo.trackEvent("Page Load", "Loaded user guide");
}
},
watch: {
tab: {
Expand Down
5 changes: 5 additions & 0 deletions src/renderer/src/views/FeatureTable/FeatureTables.vue
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,11 @@ export default {
return {
tab: null
}
},
mounted () {
if(this.$matomo){
this.$matomo.trackEvent("Page Load", "Loaded feature tables");
}
}
}
</script>
Expand Down
3 changes: 3 additions & 0 deletions src/renderer/src/views/GeoPackage/AddFeatureLayer.vue
Original file line number Diff line number Diff line change
Expand Up @@ -358,6 +358,9 @@ export default {
}
if (this.configuration.sourceLayers.length === 0 && this.configuration.geopackageLayers.length === 0) {
if(this.$matomo){
this.$matomo.trackEvent("GPKG modified", "Created Feature Layer");
}
await addFeatureTableToGeoPackage(this.project.id,this.geopackage.id, this.layerName)
this.done = true
await synchronizeGeoPackage(this.project.id, this.geopackage.id)
Expand Down
4 changes: 3 additions & 1 deletion src/renderer/src/views/GeoPackage/AddTileLayer.vue
Original file line number Diff line number Diff line change
Expand Up @@ -583,7 +583,9 @@ export default {
targetProjection: this.targetProjection,
size: {x: DEFAULT_TILE_SIZE, y: DEFAULT_TILE_SIZE}
}
if(this.$matomo){
this.$matomo.trackEvent("GPKG modified", "Created Tile Layer");
}
window.mapcache.addTileLayer(window.deproxy(this.configuration), (status) => {
if (!this.done) {
this.status = status
Expand Down
Loading

0 comments on commit 333a129

Please sign in to comment.