Merge pull request #258 from wakatime/fix-251
fix: strip hash and search from project name #251
This commit is contained in:
@@ -1,7 +1,7 @@
|
|||||||
@import 'node_modules/bootswatch/dist/materia/_variables';
|
@import 'bootswatch/dist/materia/_variables';
|
||||||
@import 'node_modules/bootstrap/scss/bootstrap';
|
@import 'bootstrap/scss/bootstrap';
|
||||||
@import 'node_modules/bootswatch/dist/materia/_bootswatch';
|
@import 'bootswatch/dist/materia/_bootswatch';
|
||||||
@import 'node_modules/font-awesome/scss/font-awesome';
|
@import 'font-awesome/scss/font-awesome';
|
||||||
@import 'variables';
|
@import 'variables';
|
||||||
@import 'partials/_animations';
|
@import 'partials/_animations';
|
||||||
|
|
||||||
|
|||||||
2873
package-lock.json
generated
2873
package-lock.json
generated
File diff suppressed because it is too large
Load Diff
@@ -102,12 +102,11 @@
|
|||||||
"lint-staged": "^13.1.0",
|
"lint-staged": "^13.1.0",
|
||||||
"mocha": "^10.2.0",
|
"mocha": "^10.2.0",
|
||||||
"mocha-sinon": "^2.1.2",
|
"mocha-sinon": "^2.1.2",
|
||||||
"node-gyp": "^8.3.0",
|
|
||||||
"node-sass": "^8.0.0",
|
|
||||||
"prettier": "^2.8.2",
|
"prettier": "^2.8.2",
|
||||||
"prettier-plugin-packagejson": "^2.3.0",
|
"prettier-plugin-packagejson": "^2.3.0",
|
||||||
"prettier-plugin-sort-json": "1.0.0",
|
"prettier-plugin-sort-json": "1.0.0",
|
||||||
"rimraf": "^3.0.2",
|
"rimraf": "^3.0.2",
|
||||||
|
"sass": "^1.77.8",
|
||||||
"shelljs": "^0.8.5",
|
"shelljs": "^0.8.5",
|
||||||
"sinon": "^15.0.1",
|
"sinon": "^15.0.1",
|
||||||
"sinon-chai": "^3.7.0",
|
"sinon-chai": "^3.7.0",
|
||||||
|
|||||||
@@ -8,7 +8,7 @@ import config from '../config/config';
|
|||||||
import { SendHeartbeat } from '../types/heartbeats';
|
import { SendHeartbeat } from '../types/heartbeats';
|
||||||
import { GrandTotal, SummariesPayload } from '../types/summaries';
|
import { GrandTotal, SummariesPayload } from '../types/summaries';
|
||||||
import { ApiKeyPayload, AxiosUserResponse, User } from '../types/user';
|
import { ApiKeyPayload, AxiosUserResponse, User } from '../types/user';
|
||||||
import { IS_FIREFOX, IS_EDGE, generateProjectFromDevSites } from '../utils';
|
import { IS_EDGE, IS_FIREFOX, generateProjectFromDevSites } from '../utils';
|
||||||
import { getApiKey } from '../utils/apiKey';
|
import { getApiKey } from '../utils/apiKey';
|
||||||
import changeExtensionState from '../utils/changeExtensionState';
|
import changeExtensionState from '../utils/changeExtensionState';
|
||||||
import contains from '../utils/contains';
|
import contains from '../utils/contains';
|
||||||
@@ -170,6 +170,7 @@ class WakaTimeCore {
|
|||||||
if (!contains(url, items.blacklist as string)) {
|
if (!contains(url, items.blacklist as string)) {
|
||||||
await this.sendHeartbeat(
|
await this.sendHeartbeat(
|
||||||
{
|
{
|
||||||
|
branch: null,
|
||||||
hostname: items.hostname as string,
|
hostname: items.hostname as string,
|
||||||
project,
|
project,
|
||||||
url,
|
url,
|
||||||
@@ -189,6 +190,7 @@ class WakaTimeCore {
|
|||||||
await this.sendHeartbeat(
|
await this.sendHeartbeat(
|
||||||
{
|
{
|
||||||
...heartbeat,
|
...heartbeat,
|
||||||
|
branch: null,
|
||||||
hostname: items.hostname as string,
|
hostname: items.hostname as string,
|
||||||
project: heartbeat.project ?? project,
|
project: heartbeat.project ?? project,
|
||||||
},
|
},
|
||||||
@@ -285,6 +287,7 @@ class WakaTimeCore {
|
|||||||
apiKey: string,
|
apiKey: string,
|
||||||
navigationPayload: Record<string, unknown>,
|
navigationPayload: Record<string, unknown>,
|
||||||
): Promise<void> {
|
): Promise<void> {
|
||||||
|
console.log('Sending Heartbeat', heartbeat);
|
||||||
let payload;
|
let payload;
|
||||||
|
|
||||||
const loggingType = await this.getLoggingType();
|
const loggingType = await this.getLoggingType();
|
||||||
@@ -339,12 +342,12 @@ class WakaTimeCore {
|
|||||||
let userAgent;
|
let userAgent;
|
||||||
if (IS_FIREFOX) {
|
if (IS_FIREFOX) {
|
||||||
browserName = 'firefox';
|
browserName = 'firefox';
|
||||||
userAgent = navigator.userAgent.match(/Firefox\/\S+/g)![0];
|
userAgent = navigator.userAgent.match(/Firefox\/\S+/g)?.[0];
|
||||||
} else if (IS_EDGE) {
|
} else if (IS_EDGE) {
|
||||||
browserName = 'edge';
|
browserName = 'edge';
|
||||||
userAgent = navigator.userAgent;
|
userAgent = navigator.userAgent;
|
||||||
} else {
|
} else {
|
||||||
userAgent = navigator.userAgent.match(/Chrome\/\S+/g)![0];
|
userAgent = navigator.userAgent.match(/Chrome\/\S+/g)?.[0];
|
||||||
}
|
}
|
||||||
const payload: Record<string, unknown> = {
|
const payload: Record<string, unknown> = {
|
||||||
entity: heartbeat.url,
|
entity: heartbeat.url,
|
||||||
|
|||||||
@@ -2,12 +2,14 @@ export const IS_EDGE = navigator.userAgent.includes('Edg');
|
|||||||
export const IS_FIREFOX = navigator.userAgent.includes('Firefox');
|
export const IS_FIREFOX = navigator.userAgent.includes('Firefox');
|
||||||
export const IS_CHROME = IS_EDGE === false && IS_FIREFOX === false;
|
export const IS_CHROME = IS_EDGE === false && IS_FIREFOX === false;
|
||||||
|
|
||||||
export const generateProjectFromDevSites = (url: string): string | null => {
|
export const generateProjectFromDevSites = (siteUrl: string): string | null => {
|
||||||
const githubUrls = ['https://github.com/', 'https://github.dev/'];
|
const url = new URL(siteUrl);
|
||||||
|
const githubUrls = ['github.com', 'github.dev'];
|
||||||
for (const githubUrl of githubUrls) {
|
for (const githubUrl of githubUrls) {
|
||||||
if (url.startsWith(githubUrl)) {
|
if (url.host === githubUrl) {
|
||||||
const newUrl = url.replace(githubUrl, '');
|
// input: https://github.com/wakatime/browser-wakatime?tab=readme-ov-file#development-instructions
|
||||||
return newUrl.split('/')[1] || null;
|
// output: browser-wakatime
|
||||||
|
return url.pathname.split('/')[2] || null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
|
|||||||
4
xclap.ts
4
xclap.ts
@@ -78,15 +78,15 @@ load({
|
|||||||
),
|
),
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
|
'build-sass': exec('sass assets/sass/app.scss public/css/app.css --load-path=node_modules'),
|
||||||
clean: [exec('rimraf public coverage vendor web-ext-artifacts'), 'clean:webpack'],
|
clean: [exec('rimraf public coverage vendor web-ext-artifacts'), 'clean:webpack'],
|
||||||
'clean:webpack': exec('rimraf dist'),
|
'clean:webpack': exec('rimraf dist'),
|
||||||
dev: ['clean', 'postinstall', concurrent('watch', 'web-ext:run:firefox', 'web-ext:run:chrome')],
|
dev: ['clean', 'postinstall', concurrent('watch', 'web-ext:run:firefox', 'web-ext:run:chrome')],
|
||||||
eslint: exec('eslint src . --fix'),
|
eslint: exec('eslint src . --fix'),
|
||||||
lint: ['prettier', 'eslint'],
|
lint: ['prettier', 'eslint'],
|
||||||
postinstall: ['clean', makePublicFolder, copyFromNodeModules, 'sass'],
|
postinstall: ['clean', makePublicFolder, copyFromNodeModules, 'build-sass'],
|
||||||
prettier: [exec('prettier --write .')],
|
prettier: [exec('prettier --write .')],
|
||||||
'remotedev-server': exec('remotedev --hostname=localhost --port=8000'),
|
'remotedev-server': exec('remotedev --hostname=localhost --port=8000'),
|
||||||
sass: exec('node-sass assets/sass/app.scss public/css/app.css'),
|
|
||||||
test: ['build', 'lint', 'test-jest'],
|
test: ['build', 'lint', 'test-jest'],
|
||||||
'test-jest': [exec('jest --clearCache'), exec('jest --verbose --coverage')],
|
'test-jest': [exec('jest --clearCache'), exec('jest --verbose --coverage')],
|
||||||
watch: concurrent('watch-jest', 'webpack:watch'),
|
watch: concurrent('watch-jest', 'webpack:watch'),
|
||||||
|
|||||||
Reference in New Issue
Block a user