-
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.
Merge pull request #28 from PiwikPRO/fix/eslint-and-proper-types
fix: enable eslint and follow it's errors
- Loading branch information
Showing
32 changed files
with
162 additions
and
306 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
v18.19.0 |
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
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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
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,8 +1,8 @@ | ||
export type PaymentInformation = { | ||
orderId: string; | ||
grandTotal: number | string; | ||
subTotal?: number | string; | ||
tax?: number | string; | ||
shipping?: number | string; | ||
discount?: number | string; | ||
}; | ||
orderId: string | ||
grandTotal: number | string | ||
subTotal?: number | string | ||
tax?: number | string | ||
shipping?: number | string | ||
discount?: number | string | ||
} |
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; | ||
IS_DEBUG?: boolean; | ||
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 |
---|---|---|
@@ -1,14 +1,14 @@ | ||
import { LimitedArrayFiveStrings } from './utils' | ||
|
||
type DimensionId = number; | ||
type DimensionId = number | ||
|
||
export type Product = { | ||
sku: string, | ||
name?: string, | ||
category?: LimitedArrayFiveStrings<string[]>, | ||
price?: number, | ||
quantity?: number, | ||
brand?: string, | ||
variant?: string, | ||
customDimensions?: Record<DimensionId, string>, | ||
sku: string | ||
name?: string | ||
category?: LimitedArrayFiveStrings<string[]> | ||
price?: number | ||
quantity?: number | ||
brand?: string | ||
variant?: string | ||
customDimensions?: Record<DimensionId, string> | ||
} |
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,13 @@ | ||
export type LimitedArrayFiveStrings<T extends string[] = []> = [string, ...T] | [string, string, string, string, string]; | ||
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
Oops, something went wrong.