-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: enable eslint and follow it's errors
- Loading branch information
Showing
23 changed files
with
113 additions
and
110 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
/** @type {import('eslint').Linter.Config} */ | ||
const config = { | ||
parser: '@typescript-eslint/parser', | ||
extends: [ | ||
'eslint:recommended', | ||
'plugin:@typescript-eslint/recommended-type-checked', | ||
], | ||
plugins: ['@typescript-eslint'], | ||
ignorePatterns:[".eslintrc.cjs", "example"], | ||
parserOptions: { | ||
project:true, | ||
tsconfigRootDir: __dirname, | ||
}, | ||
} | ||
|
||
module.exports = config |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,7 @@ | ||
export interface PiwikProWindow extends Window { | ||
_paq?: any; | ||
dataLayer?: any; | ||
import { AnyData, QueueItem } from './utils'; | ||
|
||
export interface PiwikProWindow { | ||
_paq?: QueueItem[]; | ||
dataLayer?: AnyData[]; | ||
IS_DEBUG?: boolean; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
import { VisitorInfo } from "./visitorInfo"; | ||
|
||
export type Tracker = { | ||
hasCookies: () => boolean; | ||
getCustomDimensionValue: (id: string | number) => string | undefined; | ||
getLinkTrackingTimer: () => number; | ||
getEcommerceItems: () => object; | ||
getUserId: () => string; | ||
getVisitorId: () => string; | ||
getVisitorInfo:()=> VisitorInfo | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,11 @@ | ||
import { TRACK_EVENT } from "../constants/track-event.constant"; | ||
import { Tracker } from "./tracker"; | ||
|
||
export type LimitedArrayFiveStrings<T extends string[] = []> = [string, ...T] | [string, string, string, string, string]; | ||
|
||
// eslint-disable-next-line @typescript-eslint/no-explicit-any | ||
export type AnyData = any | ||
|
||
export type Dimensions = Record<`dimension${number}`,string> | ||
|
||
export type QueueItem =[TRACK_EVENT, ...unknown[]] | [(this: Tracker) => void] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
export type VisitorInfo = [ | ||
isNew: '0' | '1', | ||
visitorId: string, | ||
firstVisitTS: number, | ||
previousVisitCount: string | number, | ||
currentVisitTS: number, | ||
lastVisitTS: number | '', | ||
lastEcommerceOrderTS: number | '' | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,14 @@ | ||
import { TRACK_EVENT } from '../../constants/track-event.constant'; | ||
import { Dimensions } from '../../interfaces/utils'; | ||
import { PaqService } from '../paqService/paq.service'; | ||
|
||
export function trackEvent(category: string, action: string, name?: string, value?: number) { | ||
const eventArguments: any[] = [ | ||
export function trackEvent(category: string, action: string, name?: string, value?: number, dimensions?:Dimensions) { | ||
const eventArguments = [ | ||
category, | ||
action, | ||
...(name ? [name] : []), | ||
...(name ? [value] : []), | ||
...(dimensions ? [dimensions] : []), | ||
]; | ||
PaqService.push([TRACK_EVENT.CUSTOM_EVENT, ...eventArguments]) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,14 @@ | ||
import { PiwikProWindow } from '../../interfaces/piwikpro.window'; | ||
import { IS_DEBUG } from '../../core'; | ||
import { AnyData } from '../../interfaces/utils'; | ||
|
||
export function push(data: any) { | ||
if (!(window as PiwikProWindow).dataLayer) { | ||
(window as PiwikProWindow).dataLayer = []; | ||
|
||
export function push( | ||
data: AnyData | ||
) { | ||
if (!window.dataLayer) { | ||
window.dataLayer = []; | ||
} | ||
|
||
IS_DEBUG && console.log('DataLayer push', data); | ||
return (window as PiwikProWindow).dataLayer.push(data); | ||
return window.dataLayer.push(data); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,17 +1,20 @@ | ||
import { PiwikProWindow } from '../../interfaces/piwikpro.window'; | ||
import { TRACK_EVENT } from '../../constants/track-event.constant'; | ||
import { IS_DEBUG } from '../../core'; | ||
import { QueueItem } from '../../interfaces/utils'; | ||
|
||
function push(collection: any[]) { | ||
if (!(window as PiwikProWindow)._paq) { | ||
(window as PiwikProWindow)._paq = []; | ||
|
||
|
||
function push(collection: QueueItem) { | ||
if (!window._paq) { | ||
window._paq = []; | ||
} | ||
|
||
(window as PiwikProWindow)._paq.push(["setCustomUrl", window.location.href]); | ||
(window as PiwikProWindow)._paq.push(["setDocumentTitle", document.title]); | ||
window._paq.push([TRACK_EVENT.SET_CUSTOM_URL, window.location.href]); | ||
window._paq.push([TRACK_EVENT.SET_DOCUMENT_TITLE, document.title]); | ||
IS_DEBUG && console.log('Push', collection); | ||
return (window as PiwikProWindow)._paq.push(collection); | ||
return window._paq.push(collection); | ||
} | ||
|
||
export const PaqService = { | ||
push, | ||
} | ||
push | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.