Skip to content

Commit 48e24a7

Browse files
authored
Merge pull request #13 from ety001/3.0.4
3.0.4
2 parents 59676dd + 0da0913 commit 48e24a7

File tree

4 files changed

+22
-16
lines changed

4 files changed

+22
-16
lines changed

package-lock.json

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "review-bookmark",
3-
"version": "3.0.3",
3+
"version": "3.0.4",
44
"description": "A bookmark manager for Chrome.",
55
"author": "ETY001 <[email protected]>",
66
"license": "MIT",
@@ -15,7 +15,7 @@
1515
"build-firefox": "cross-env NODE_ENV=production BROWSER_PROTO=firefox webpack --hide-modules",
1616
"build:dev": "cross-env NODE_ENV=development BROWSER_PROTO=chrome webpack --hide-modules",
1717
"build-firefox:dev": "cross-env NODE_ENV=development BROWSER_PROTO=firefox webpack --hide-modules",
18-
"build-zip": "node scripts/build-zip.js",
18+
"build-zip": "find dist | xargs touch -mt 202002110000 && cd dist && zip -r -X dist.zip . && mv dist.zip ..",
1919
"watch": "npm run build -- --watch",
2020
"watch-firefox": "npm run build-firefox -- --watch",
2121
"watch:dev": "cross-env HMR=true npm run build:dev -- --watch",

src/background.js

+17-11
Original file line numberDiff line numberDiff line change
@@ -7,13 +7,16 @@ global.browser = require('webextension-polyfill');
77

88
const isFirefox = navigator.userAgent.toUpperCase().indexOf('Firefox') ? true : false;
99
const isChrome = window.navigator.userAgent.indexOf('Chrome') !== -1;
10+
const isEdge = navigator.userAgent.indexOf('Edg') !== -1;
1011

1112
//清空之前版本的数据
1213
if (window.localStorage.curt_index === undefined) {
1314
window.localStorage.clear();
1415
indexedDB.deleteDatabase('bookmarks');
1516
}
1617

18+
const debug = process.env.NODE_ENV === 'development';
19+
1720
// 检测新标签页,控制迷你和full版本
1821
chrome.tabs.onUpdated.addListener((tabId, changeInfo, tab) => {
1922
if (isChrome) {
@@ -34,10 +37,12 @@ chrome.tabs.onUpdated.addListener((tabId, changeInfo, tab) => {
3437
}
3538
}
3639
}
37-
if (tab.url === 'edge://newtab/') {
38-
if (store.getters.config.mini === false) {
39-
const url = chrome.runtime.getURL('tab/tab.html');
40-
chrome.tabs.update(tabId, { url });
40+
if (isEdge) {
41+
if (tab.url === 'edge://newtab/') {
42+
if (store.getters.config.mini === false) {
43+
const url = chrome.runtime.getURL('tab/tab.html');
44+
chrome.tabs.update(tabId, { url });
45+
}
4146
}
4247
}
4348
});
@@ -68,16 +73,17 @@ const GetUid = {
6873
const uid = GetUid.get();
6974

7075
//google analytics
71-
let currentVersion = '3_0_3';
76+
let currentVersion = '3_0_4';
7277
if (isChrome) {
7378
currentVersion = `chrome_${currentVersion}`;
74-
}
75-
if (isFirefox) {
79+
} else if (isFirefox) {
7680
currentVersion = `firefox_${currentVersion}`;
81+
} else if (isEdge) {
82+
currentVersion = `edge_${currentVersion}`;
7783
}
7884
const gaID = 'UA-64832923-4';
79-
const gaObj = new GA(gaID, uid);
80-
function sendEvent(eventCategory, eventAction, eventLabel = '', eventValue = '') {
85+
const gaObj = new GA(gaID, uid, debug);
86+
function sendEvent(eventCategory, eventAction, eventLabel = '', eventValue = 1) {
8187
if (store.getters.config.ga === false) return;
8288
gaObj.ga('event', eventCategory, eventAction, eventLabel, eventValue);
8389
}
@@ -253,7 +259,7 @@ chrome.bookmarks.onRemoved.addListener((id, removeInfo) => {
253259
// 安装/升级检测
254260
chrome.runtime.onInstalled.addListener(detail => {
255261
if (detail.reason == 'update') {
256-
sendEvent(currentVersion, 'update_extension', uid, '');
262+
sendEvent(currentVersion, 'update_extension', uid, 1);
257263
// 弹出推广页面
258264
window.open('https://creatorsdaily.com/9999e88d-0b00-46dc-8ff1-e1d311695324');
259265
return;
@@ -268,7 +274,7 @@ chrome.runtime.onInstalled.addListener(detail => {
268274
);
269275
}
270276
if (detail.reason === 'install') {
271-
sendEvent(currentVersion, 'install_extension', uid, '');
277+
sendEvent(currentVersion, 'install_extension', uid, 1);
272278
console.log('installed');
273279
// 初始化数据
274280
BookmarkLib.init();

src/libs/GA.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
export class GA {
2-
constructor(ua, cid) {
2+
constructor(ua, cid, debug = false) {
33
this.ua = ua;
44
this.cid = cid; // client id
5-
this.gaApi = 'https://www.google-analytics.com/collect';
5+
this.gaApi = debug ? 'https://www.google-analytics.com/debug/collect' : 'https://www.google-analytics.com/collect';
66
this.version = '1';
77
}
88
ga(t, ...items) {

0 commit comments

Comments
 (0)