refactor(tealium): resolv lint issues

This commit is contained in:
Daniel Sogl 2021-12-25 20:47:29 +00:00 committed by GitHub
parent 104e66db28
commit 7d52794933

View File

@ -1,141 +1,148 @@
import { Injectable } from '@angular/core'; import { Injectable } from '@angular/core';
import { Plugin, Cordova, CordovaProperty, CordovaInstance, InstanceProperty, AwesomeCordovaNativePlugin } from '@awesome-cordova-plugins/core'; import {
Plugin,
Cordova,
CordovaProperty,
CordovaInstance,
InstanceProperty,
AwesomeCordovaNativePlugin,
} from '@awesome-cordova-plugins/core';
import { Observable } from 'rxjs'; import { Observable } from 'rxjs';
export enum Collectors { export enum Collectors {
AppData = 'AppData', AppData = 'AppData',
Connectivity = 'Connectivity', Connectivity = 'Connectivity',
DeviceData = 'DeviceData', DeviceData = 'DeviceData',
Lifecycle = 'Lifecycle', Lifecycle = 'Lifecycle',
} }
export enum Dispatchers { export enum Dispatchers {
Collect = 'Collect', Collect = 'Collect',
TagManagement = 'TagManagement', TagManagement = 'TagManagement',
RemoteCommands = 'RemoteCommands', RemoteCommands = 'RemoteCommands',
} }
export enum Expiry { export enum Expiry {
forever = 'forever', forever = 'forever',
untilRestart = 'untilRestart', untilRestart = 'untilRestart',
session = 'session', session = 'session',
} }
export enum ConsentPolicy { export enum ConsentPolicy {
ccpa = 'ccpa', ccpa = 'ccpa',
gdpr = 'gdpr', gdpr = 'gdpr',
} }
export interface TealiumDispatch { export interface TealiumDispatch {
dataLayer: Map<string, any>; dataLayer: Map<string, any>;
type: string; type: string;
toJson(): string; toJson(): string;
} }
export class TealiumView implements TealiumDispatch { export class TealiumView implements TealiumDispatch {
public type: string = 'view'; public type = 'view';
constructor(public viewName: string, public dataLayer: Map<string, any>) {} constructor(public viewName: string, public dataLayer: Map<string, any>) {}
toJson() { toJson() {
let dictionary: any = {}; const dictionary: any = {};
dictionary['type'] = this.type; dictionary['type'] = this.type;
dictionary['dataLayer'] = {}; dictionary['dataLayer'] = {};
this.dataLayer.forEach((k, v) => { this.dataLayer.forEach((k, v) => {
dictionary['dataLayer'][k] = v; dictionary['dataLayer'][k] = v;
}); });
dictionary['type'] = this.type; dictionary['type'] = this.type;
dictionary['viewName'] = this.viewName; dictionary['viewName'] = this.viewName;
return JSON.stringify(dictionary); return JSON.stringify(dictionary);
} }
} }
export class TealiumEvent implements TealiumDispatch { export class TealiumEvent implements TealiumDispatch {
public type: string = 'event'; public type = 'event';
constructor(public eventName: string, public dataLayer: Map<string, any>) {} constructor(public eventName: string, public dataLayer: Map<string, any>) {}
toJson() { toJson() {
let dictionary: any = {}; const dictionary: any = {};
dictionary['type'] = this.type; dictionary['type'] = this.type;
dictionary['dataLayer'] = {}; dictionary['dataLayer'] = {};
this.dataLayer.forEach((k, v) => { this.dataLayer.forEach((k, v) => {
dictionary['dataLayer'][k] = v; dictionary['dataLayer'][k] = v;
}); });
dictionary['type'] = this.type; dictionary['type'] = this.type;
dictionary['eventName'] = this.eventName; dictionary['eventName'] = this.eventName;
return JSON.stringify(dictionary); return JSON.stringify(dictionary);
} }
} }
export class ConsentExpiry { export class ConsentExpiry {
constructor(public time: number, public unit: TimeUnit) {} constructor(public time: number, public unit: TimeUnit) {}
} }
export enum TimeUnit { export enum TimeUnit {
minutes = 'minutes', minutes = 'minutes',
hours = 'hours', hours = 'hours',
days = 'days', days = 'days',
months = 'months', months = 'months',
} }
export enum ConsentStatus { export enum ConsentStatus {
consented = 'consented', consented = 'consented',
notConsented = 'notConsented', notConsented = 'notConsented',
unknown = 'unknown', unknown = 'unknown',
} }
export enum LogLevel { export enum LogLevel {
dev = 'dev', dev = 'dev',
qa = 'qa', qa = 'qa',
prod = 'prod', prod = 'prod',
silent = 'silent', silent = 'silent',
} }
export enum TealiumEnvironment { export enum TealiumEnvironment {
dev = 'dev', dev = 'dev',
qa = 'qa', qa = 'qa',
prod = 'prod', prod = 'prod',
} }
export enum ConsentCategories { export enum ConsentCategories {
analytics = 'analytics', analytics = 'analytics',
affiliates = 'affiliates', affiliates = 'affiliates',
displayAds = 'display_ads', displayAds = 'display_ads',
email = 'email', email = 'email',
personalization = 'personalization', personalization = 'personalization',
search = 'search', search = 'search',
social = 'social', social = 'social',
bigData = 'big_data', bigData = 'big_data',
mobile = 'mobile', mobile = 'mobile',
engagement = 'engagement', engagement = 'engagement',
monitoring = 'monitoring', monitoring = 'monitoring',
crm = 'crm', crm = 'crm',
cdp = 'cdp', cdp = 'cdp',
cookieMatch = 'cookiematch', cookieMatch = 'cookiematch',
misc = 'misc', misc = 'misc',
} }
export interface TealiumConfig { export interface TealiumConfig {
account: string; account: string;
profile: string; profile: string;
environment: TealiumEnvironment; environment: TealiumEnvironment;
dataSource?: string; dataSource?: string;
collectors: Collectors[]; collectors: Collectors[];
dispatchers: Dispatchers[]; dispatchers: Dispatchers[];
customVisitorId?: string; customVisitorId?: string;
memoryReportingEnabled?: boolean; memoryReportingEnabled?: boolean;
overrideCollectURL?: string; overrideCollectURL?: string;
overrideCollectBatchURL?: string; overrideCollectBatchURL?: string;
overrideCollectDomain?: string; overrideCollectDomain?: string;
overrideLibrarySettingsURL?: string; overrideLibrarySettingsURL?: string;
overrideTagManagementURL?: string; overrideTagManagementURL?: string;
deepLinkTrackingEnabled?: boolean; deepLinkTrackingEnabled?: boolean;
qrTraceEnabled?: boolean; qrTraceEnabled?: boolean;
loglevel?: LogLevel; loglevel?: LogLevel;
consentLoggingEnabled?: boolean; consentLoggingEnabled?: boolean;
consentPolicy?: ConsentPolicy; consentPolicy?: ConsentPolicy;
consentExpiry?: ConsentExpiry; consentExpiry?: ConsentExpiry;
lifecycleAutotrackingEnabled?: boolean; lifecycleAutotrackingEnabled?: boolean;
useRemoteLibrarySettings?: boolean; useRemoteLibrarySettings?: boolean;
visitorServiceEnabled?: boolean; visitorServiceEnabled?: boolean;
visitorServiceRefreshInterval?: string; visitorServiceRefreshInterval?: string;
} }
/** /**
@ -178,11 +185,10 @@ export interface TealiumConfig {
repo: 'https://github.com/Tealium/cordova-plugin', // the github repository URL for the plugin repo: 'https://github.com/Tealium/cordova-plugin', // the github repository URL for the plugin
install: '', // OPTIONAL install command, in case the plugin requires variables install: '', // OPTIONAL install command, in case the plugin requires variables
installVariables: [], // OPTIONAL the plugin requires variables installVariables: [], // OPTIONAL the plugin requires variables
platforms: ['Android', 'iOS'] // Array of platforms supported platforms: ['Android', 'iOS'], // Array of platforms supported
}) })
@Injectable() @Injectable()
export class Tealium extends AwesomeCordovaNativePlugin { export class Tealium extends AwesomeCordovaNativePlugin {
/** /**
* This function initializes the Tealium Cordova Plugin * This function initializes the Tealium Cordova Plugin
* @param config {TealiumConfig} * @param config {TealiumConfig}