refactor(tealium): resolv lint issues
This commit is contained in:
parent
104e66db28
commit
7d52794933
@ -1,148 +1,155 @@
|
|||||||
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;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @name Tealium
|
* @name Tealium
|
||||||
* @description
|
* @description
|
||||||
* This plugin does provides a wrapper around the Tealium Cordova Plugin for Ionic Native.
|
* This plugin does provides a wrapper around the Tealium Cordova Plugin for Ionic Native.
|
||||||
*
|
*
|
||||||
* For full documentation, see [https://docs.tealium.com/platforms/cordova/](https://docs.tealium.com/platforms/cordova/)
|
* For full documentation, see [https://docs.tealium.com/platforms/cordova/](https://docs.tealium.com/platforms/cordova/)
|
||||||
*
|
*
|
||||||
* @usage
|
* @usage
|
||||||
@ -166,7 +173,7 @@ export interface TealiumConfig {
|
|||||||
* // visitorServiceRefreshInterval: '1',
|
* // visitorServiceRefreshInterval: '1',
|
||||||
* consentExpiry: new ConsentExpiry(3, TimeUnit.minutes),
|
* consentExpiry: new ConsentExpiry(3, TimeUnit.minutes),
|
||||||
* };
|
* };
|
||||||
*
|
*
|
||||||
* Tealium.initialize(config);
|
* Tealium.initialize(config);
|
||||||
*
|
*
|
||||||
* ```
|
* ```
|
||||||
@ -178,15 +185,14 @@ 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}
|
||||||
* @param callback
|
* @param callback
|
||||||
* @return {Promise<any>} Returns a promise that resolves when something happens
|
* @return {Promise<any>} Returns a promise that resolves when something happens
|
||||||
*/
|
*/
|
||||||
@Cordova()
|
@Cordova()
|
||||||
@ -195,7 +201,7 @@ export class Tealium extends AwesomeCordovaNativePlugin {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This function tracks an event
|
* This function tracks an event
|
||||||
* @param dispatch {TealiumDispatch} Dispatch containing event data
|
* @param dispatch {TealiumDispatch} Dispatch containing event data
|
||||||
* @return {Promise<any>} Returns a promise that resolves when something happens
|
* @return {Promise<any>} Returns a promise that resolves when something happens
|
||||||
*/
|
*/
|
||||||
@ -215,7 +221,7 @@ export class Tealium extends AwesomeCordovaNativePlugin {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Adds data to data layer
|
* Adds data to data layer
|
||||||
* @param data A map containing the key-value pairs to be added to data layer
|
* @param data A map containing the key-value pairs to be added to data layer
|
||||||
* @param expiry When the data should expire. Choose `Expiry.session` if unsure.
|
* @param expiry When the data should expire. Choose `Expiry.session` if unsure.
|
||||||
* @return {Promise<any>} Returns a promise that resolves when something happens
|
* @return {Promise<any>} Returns a promise that resolves when something happens
|
||||||
*/
|
*/
|
||||||
@ -225,7 +231,7 @@ export class Tealium extends AwesomeCordovaNativePlugin {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* @param key The key of the data to retrieve from the data layer
|
* @param key The key of the data to retrieve from the data layer
|
||||||
* @param callback
|
* @param callback
|
||||||
* @return {Promise<any>} Returns a promise that resolves when something happens
|
* @return {Promise<any>} Returns a promise that resolves when something happens
|
||||||
@ -247,7 +253,7 @@ export class Tealium extends AwesomeCordovaNativePlugin {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Retrieves the user's consent status
|
* Retrieves the user's consent status
|
||||||
* @param callback
|
* @param callback
|
||||||
* @return {Promise<any>} Returns a promise that resolves when something happens
|
* @return {Promise<any>} Returns a promise that resolves when something happens
|
||||||
*/
|
*/
|
||||||
@Cordova()
|
@Cordova()
|
||||||
@ -257,7 +263,7 @@ export class Tealium extends AwesomeCordovaNativePlugin {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Sets the user's consent status
|
* Sets the user's consent status
|
||||||
* @param consentStatus
|
* @param consentStatus
|
||||||
* @return {Promise<any>} Returns a promise that resolves when something happens
|
* @return {Promise<any>} Returns a promise that resolves when something happens
|
||||||
*/
|
*/
|
||||||
@Cordova()
|
@Cordova()
|
||||||
@ -267,7 +273,7 @@ export class Tealium extends AwesomeCordovaNativePlugin {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Retrieves the user's consent categories
|
* Retrieves the user's consent categories
|
||||||
* @param callback
|
* @param callback
|
||||||
* @return {Promise<any>} Returns a promise that resolves when something happens
|
* @return {Promise<any>} Returns a promise that resolves when something happens
|
||||||
*/
|
*/
|
||||||
@Cordova()
|
@Cordova()
|
||||||
@ -277,7 +283,7 @@ export class Tealium extends AwesomeCordovaNativePlugin {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Sets the user's consent categories
|
* Sets the user's consent categories
|
||||||
* @param categories
|
* @param categories
|
||||||
* @return {Promise<any>} Returns a promise that resolves when something happens
|
* @return {Promise<any>} Returns a promise that resolves when something happens
|
||||||
*/
|
*/
|
||||||
@Cordova()
|
@Cordova()
|
||||||
@ -306,7 +312,7 @@ export class Tealium extends AwesomeCordovaNativePlugin {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Retrieves the Tealium Visitor ID
|
* Retrieves the Tealium Visitor ID
|
||||||
* @param callback
|
* @param callback
|
||||||
* @return {Promise<any>} Returns a promise that resolves when something happens
|
* @return {Promise<any>} Returns a promise that resolves when something happens
|
||||||
*/
|
*/
|
||||||
@Cordova()
|
@Cordova()
|
||||||
@ -316,7 +322,7 @@ export class Tealium extends AwesomeCordovaNativePlugin {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Sets a listener to be called when the AudienceStream visitor profile is updated
|
* Sets a listener to be called when the AudienceStream visitor profile is updated
|
||||||
* @param callback
|
* @param callback
|
||||||
* @return {Promise<any>} Returns a promise that resolves when something happens
|
* @return {Promise<any>} Returns a promise that resolves when something happens
|
||||||
*/
|
*/
|
||||||
@Cordova()
|
@Cordova()
|
||||||
@ -326,7 +332,7 @@ export class Tealium extends AwesomeCordovaNativePlugin {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Sets a listener to be called when the consent has expired
|
* Sets a listener to be called when the consent has expired
|
||||||
* @param callback
|
* @param callback
|
||||||
* @return {Promise<any>} Returns a promise that resolves when something happens
|
* @return {Promise<any>} Returns a promise that resolves when something happens
|
||||||
*/
|
*/
|
||||||
@Cordova()
|
@Cordova()
|
||||||
@ -337,7 +343,7 @@ export class Tealium extends AwesomeCordovaNativePlugin {
|
|||||||
/**
|
/**
|
||||||
* Adds a remote command for later execution
|
* Adds a remote command for later execution
|
||||||
* @param id The ID used to invoke the remote command
|
* @param id The ID used to invoke the remote command
|
||||||
* @param callback
|
* @param callback
|
||||||
* @return {Promise<any>} Returns a promise that resolves when something happens
|
* @return {Promise<any>} Returns a promise that resolves when something happens
|
||||||
*/
|
*/
|
||||||
@Cordova()
|
@Cordova()
|
||||||
|
Loading…
Reference in New Issue
Block a user