From e04898d28b8d8e18f3083112499bd5b90050b388 Mon Sep 17 00:00:00 2001
From: Nandiheath
Date: Thu, 17 Jan 2019 23:54:22 +0800
Subject: [PATCH 1/3] remove unused components
---
web/src/components/VueLayerMap.vue | 3 ---
1 file changed, 3 deletions(-)
diff --git a/web/src/components/VueLayerMap.vue b/web/src/components/VueLayerMap.vue
index 55c5d09..dcdc6ed 100644
--- a/web/src/components/VueLayerMap.vue
+++ b/web/src/components/VueLayerMap.vue
@@ -47,9 +47,6 @@
import Address from './../lib/models/address';
import ResultCard from "./ResultCard";
export default {
- components: {
- ResultCard,
- },
props: {
markers: Array,
filterOptions: Array
From a066d5528eb73f49469ec6904645f01e6d6463cf Mon Sep 17 00:00:00 2001
From: Nandiheath
Date: Thu, 17 Jan 2019 23:56:11 +0800
Subject: [PATCH 2/3] update GA codes
---
web/src/pages/MapAddressSearcher.vue | 9 ++--
web/src/pages/TableAddressSearcher.vue | 20 +++++----
web/src/utils/ga-helper.js | 60 ++++++++++++--------------
3 files changed, 44 insertions(+), 45 deletions(-)
diff --git a/web/src/pages/MapAddressSearcher.vue b/web/src/pages/MapAddressSearcher.vue
index 2e4c6cf..41d557d 100644
--- a/web/src/pages/MapAddressSearcher.vue
+++ b/web/src/pages/MapAddressSearcher.vue
@@ -57,15 +57,13 @@ import asyncLib from "async";
import asyncify from "async/asyncify";
import dclookup from "./../utils/dclookup";
import ogcioHelper from "./../utils/ogcio-helper";
-import SearchFilter from "./../components/SearchFilter";
import VueLayerMap from "./../components/VueLayerMap";
import ResultCard from "./../components/ResultCard";
-import { trackBatchSearch, trackBatchSearchResult } from "./../utils/ga-helper";
+import { trackMapSearch, trackPinSelected } from "./../utils/ga-helper";
const SEARCH_LIMIT = 200;
export default {
components: {
- SearchFilter,
VueLayerMap,
ResultCard
},
@@ -103,8 +101,8 @@ export default {
this.errorMessage = "請輸入地址";
return;
}
- this.addressesToSearch = this.addressString.split("\n");
- trackBatchSearch(this, this.addressesToSearch);
+ this.addressesToSearch = this.addressString.split("\n").filter(address => address !== undefined && address.length > 0);
+ trackMapSearch(this, this.addressesToSearch.length);
const self = this;
asyncLib.eachOfLimit(
this.addressesToSearch,
@@ -124,6 +122,7 @@ export default {
if (feature !== null) {
const index = feature.properties.index;
this.setSelectedFeature(index);
+ trackPinSelected(this, this.results[index][0]);
} else {
this.selectedFeature = null;
}
diff --git a/web/src/pages/TableAddressSearcher.vue b/web/src/pages/TableAddressSearcher.vue
index a520314..2edc37e 100644
--- a/web/src/pages/TableAddressSearcher.vue
+++ b/web/src/pages/TableAddressSearcher.vue
@@ -11,9 +11,7 @@
為何要拆解地址?假設你在找尋
灣仔富德樓 的位置,你會用Google地圖搜尋,然後得出地址全名、座標等資料。但如果你分析過千,甚至過萬個文字地址,又要顯示在地圖上,當中格式不統一、中英混雜,難道你要逐一搜尋?
-
- 香港地址解析器(Hong Kong Address Parser, HKAP)運用政府部門開放數據,比較輸入地址與搜尋結果的相似度,將香港文字地址拆解成地區、街道、門牌、大廈、座標、甚至區議會選區,方便港人分析地址資料,製作地圖。
-
+ 香港地址解析器(Hong Kong Address Parser, HKAP)運用政府部門開放數據,比較輸入地址與搜尋結果的相似度,將香港文字地址拆解成地區、街道、門牌、大廈、座標、甚至區議會選區,方便港人分析地址資料,製作地圖。
三大功能
@@ -156,7 +154,7 @@
拆地址
下載 CSV
@@ -196,8 +194,9 @@ import dclookup from "./../utils/dclookup";
import ogcioHelper from "./../utils/ogcio-helper";
import SearchFilter from "./../components/SearchFilter";
import asyncify from "async/asyncify";
-import { trackBatchSearch, trackBatchSearchResult } from "./../utils/ga-helper";
+import { trackTableSearch, trackDownloadCSV } from "./../utils/ga-helper";
const SEARCH_LIMIT = 200;
+var asde = 200;
export default {
components: {
@@ -306,6 +305,10 @@ export default {
// }
},
methods: {
+ prepareDownloadCSV: function() {
+ trackDownloadCSV(this, this.normalizedResults.length);
+ return this.normalizedResults;
+ },
/**
* Return an array of distinct headers from all of the ogcio results
*/
@@ -336,8 +339,10 @@ export default {
this.errorMessage = "請輸入地址";
return;
}
- this.addressesToSearch = this.addressString.split("\n");
- trackBatchSearch(this, this.addressesToSearch);
+ this.addressesToSearch = this.addressString
+ .split("\n")
+ .filter(address => address !== undefined && address.length > 0);
+ trackTableSearch(this, this.addressesToSearch.length);
const self = this;
asyncLib.eachOfLimit(
this.addressesToSearch,
@@ -372,7 +377,6 @@ async function searchSingleResult(address, key) {
const result = records[0];
// ! cant do the batch result here as it will exceeds the rate of GA
// https://developers.google.com/analytics/devguides/collection/analyticsjs/limits-quotas
- // trackBatchSearchResult(this, address, result.score | 0);
}
return records;
}
diff --git a/web/src/utils/ga-helper.js b/web/src/utils/ga-helper.js
index f0b42f5..e0bd2ab 100644
--- a/web/src/utils/ga-helper.js
+++ b/web/src/utils/ga-helper.js
@@ -1,9 +1,10 @@
-const GA_CATEGORY_SINGLE_SEARCH = 'single_search';
-const GA_CATEGORY_BATCH_SEARCH = 'batch_search';
+const GA_CATEGORY_MAP_SEARCH = 'map_search';
+const GA_CATEGORY_TABLE_SEARCH = 'table_search';
const GA_ACTION_SEARCH = 'search';
const GA_ACTION_SEARCH_SATISFIED = 'search_satisfied';
const GA_ACTION_SEARCH_UNSATISFIED = 'search_unsatisfied';
-const GA_ACTION_SEARCH_RESULT = 'search_result';
+const GA_ACTION_DOWNLOAD_CSV = 'download_csv';
+const GA_ACTION_SELECT_PIN = 'select_pin';
const GA_ACTION_SATISFICATION = 'rating';
const GA_ACTION_TOGGLE_FILTER = 'toogle_filter';
@@ -21,25 +22,24 @@ function trackEvent(component, param) {
* @param {Component} component
* @param {String} address
*/
-export const trackSingleSearch = function (component, address) {
+export const trackMapSearch = function (component, searchSize) {
trackEvent(component, {
- eventCategory: GA_CATEGORY_SINGLE_SEARCH,
+ eventCategory: GA_CATEGORY_MAP_SEARCH,
eventAction: GA_ACTION_SEARCH,
- eventLabel: address
+ eventValue: searchSize
})
}
/**
- * Track the user has initialize a single search
- * @param {Component} component
- * @param {String} address
+ * Track the user has selected the pin in map mode
+ * @param {*} component
+ * @param {*} address
*/
-export const trackSingleSearchResult = function (component, address, score) {
+export const trackPinSelected = function (component, address) {
trackEvent(component, {
- eventCategory: GA_CATEGORY_SINGLE_SEARCH,
- eventAction: GA_ACTION_SEARCH_RESULT,
- eventLabel: address,
- eventValue: score
+ eventCategory: GA_CATEGORY_MAP_SEARCH,
+ eventAction: GA_ACTION_SELECT_PIN,
+ eventLabel: address
})
}
@@ -62,33 +62,29 @@ export const trackSingleSearchSatisfication = function (component, address, sati
* @param {*} component
* @param {*} addresses
*/
-export const trackBatchSearch = function (component, addresses) {
- addresses.forEach(address => {
- trackEvent(component, {
- eventCategory: GA_CATEGORY_BATCH_SEARCH,
- eventAction: GA_ACTION_SEARCH,
- eventLabel: address
- })
- });
+export const trackTableSearch = function (component, batchSize) {
+ trackEvent(component, {
+ eventCategory: GA_CATEGORY_TABLE_SEARCH,
+ eventAction: GA_ACTION_SEARCH,
+ eventValue: batchSize
+ })
}
-
-
/**
- * Track the batch search result
- * @param {Component} component
- * @param {String} address
+ * Track the user has clicked on the download button
+ * @param {*} component
+ * @param {*} batchSize
*/
-export const trackBatchSearchResult = function (component, address, score) {
+export const trackDownloadCSV = function (component, batchSize) {
trackEvent(component, {
- eventCategory: GA_CATEGORY_BATCH_SEARCH,
- eventAction: GA_ACTION_SEARCH_RESULT,
- eventLabel: address,
- eventValue: score
+ eventCategory: GA_CATEGORY_TABLE_SEARCH,
+ eventAction: GA_ACTION_DOWNLOAD_CSV,
+ eventValue: batchSize
})
}
+
export const trackToggleFilterOption = function (component, optionKey, isOn) {
trackEvent(component, {
eventCategory: GA_CATEGORY_SINGLE_SEARCH,
From 34a1005549a15e26224c3c8531e64573f0f1e49b Mon Sep 17 00:00:00 2001
From: Nandiheath
Date: Thu, 17 Jan 2019 23:57:34 +0800
Subject: [PATCH 3/3] update travis to deploy only on tags
---
.travis.yml | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/.travis.yml b/.travis.yml
index c94e467..f831d7c 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -50,4 +50,4 @@ jobs:
keep-history: true
local-dir: web/dist # the local dir is relative to root and ignoring the one set with before_install
on:
- branch: master
+ tags: true