gtm-event-tracker
Advanced tools
Comparing version 1.7.0-beta.5 to 1.7.0-beta.6
@@ -0,1 +1,2 @@ | ||
import type { EventProperties } from '../shared/data-layer'; | ||
/** | ||
@@ -5,13 +6,21 @@ * Available options for the logger. | ||
*/ | ||
export declare type LoggerConfigurations = Partial<{ | ||
export declare type LoggerConfigurations = { | ||
debugAll: boolean; | ||
debugEvents: boolean; | ||
debugContext: boolean; | ||
}>; | ||
}; | ||
/** | ||
* Available options for events. | ||
* @public | ||
*/ | ||
export declare type EventsConfigurations = { | ||
targetProperty: EventProperties[]; | ||
}; | ||
/** | ||
* All available configuration options. | ||
* @public | ||
*/ | ||
export declare type Configurations = Partial<{ | ||
export declare type Configurations = { | ||
logger: LoggerConfigurations; | ||
}>; | ||
events: EventsConfigurations; | ||
}; |
import type { Configurations } from './configuration-types'; | ||
import type { PartialDeep } from 'type-fest'; | ||
export declare function createConfiguration(): { | ||
get: () => Partial<{ | ||
logger: Partial<{ | ||
debugAll: boolean; | ||
debugEvents: boolean; | ||
debugContext: boolean; | ||
}>; | ||
}>; | ||
get: () => Configurations; | ||
defaults: () => Configurations; | ||
configure: (customConfigs: Configurations) => void; | ||
configure: (customConfigs: PartialDeep<Configurations>) => void; | ||
}; | ||
export declare const configuration: { | ||
get: () => Partial<{ | ||
logger: Partial<{ | ||
debugAll: boolean; | ||
debugEvents: boolean; | ||
debugContext: boolean; | ||
}>; | ||
}>; | ||
get: () => Configurations; | ||
defaults: () => Configurations; | ||
configure: (customConfigs: Configurations) => void; | ||
configure: (customConfigs: PartialDeep<Configurations>) => void; | ||
}; | ||
@@ -28,2 +17,2 @@ /** | ||
*/ | ||
export declare const configure: (customConfigs: Configurations) => void; | ||
export declare const configure: (customConfigs: PartialDeep<Configurations>) => void; |
@@ -15,2 +15,5 @@ "use strict"; | ||
}, | ||
events: { | ||
targetProperty: window.dataLayer, | ||
}, | ||
}; | ||
@@ -17,0 +20,0 @@ } |
export { configuration, configure } from './configuration'; | ||
export type { Configurations, LoggerConfigurations, } from './configuration-types'; | ||
export type { Configurations, LoggerConfigurations, EventsConfigurations, } from './configuration-types'; |
@@ -0,1 +1,3 @@ | ||
import type { PartialDeep } from 'type-fest'; | ||
/** | ||
@@ -5,5 +7,6 @@ * All available configuration options. | ||
*/ | ||
export declare type Configurations = Partial<{ | ||
export declare type Configurations = { | ||
logger: LoggerConfigurations; | ||
}>; | ||
events: EventsConfigurations; | ||
}; | ||
@@ -14,3 +17,3 @@ /** | ||
*/ | ||
export declare const configure: (customConfigs: Configurations) => void; | ||
export declare const configure: (customConfigs: PartialDeep<Configurations>) => void; | ||
@@ -42,2 +45,10 @@ /** | ||
/** | ||
* Available options for events. | ||
* @public | ||
*/ | ||
export declare type EventsConfigurations = { | ||
targetProperty: EventProperties[]; | ||
}; | ||
/** | ||
* Available method for logs. | ||
@@ -72,7 +83,7 @@ * @public | ||
*/ | ||
export declare type LoggerConfigurations = Partial<{ | ||
export declare type LoggerConfigurations = { | ||
debugAll: boolean; | ||
debugEvents: boolean; | ||
debugContext: boolean; | ||
}>; | ||
}; | ||
@@ -79,0 +90,0 @@ /** |
@@ -5,2 +5,2 @@ export { createTrackerContext, TrackerContext, TrackerContextOptions, } from './tracker-context'; | ||
export { setLogger, Logger, LoggerAction } from './logger'; | ||
export { configure, Configurations, LoggerConfigurations, } from './configuration'; | ||
export { configure, Configurations, LoggerConfigurations, EventsConfigurations, } from './configuration'; |
@@ -1,4 +0,5 @@ | ||
import type { EventProperties, DataLayer } from './data-layer-types'; | ||
import { Configurations } from '../../configuration'; | ||
import type { DataLayer } from './data-layer-types'; | ||
declare type DataLayerOptions = Partial<{ | ||
targetProperty: EventProperties[]; | ||
configurations: Configurations; | ||
}>; | ||
@@ -5,0 +6,0 @@ export declare function createDataLayer(options?: DataLayerOptions): DataLayer; |
@@ -5,8 +5,12 @@ "use strict"; | ||
const data_layer_error_1 = require("./data-layer-error"); | ||
const configuration_1 = require("../../configuration"); | ||
function createDataLayer(options = {}) { | ||
function getTargetProperty() { | ||
function getConfiguration() { | ||
var _a; | ||
const defaultTarget = window.dataLayer; | ||
return (_a = options.targetProperty) !== null && _a !== void 0 ? _a : defaultTarget; | ||
return (_a = options.configurations) !== null && _a !== void 0 ? _a : configuration_1.configuration.get(); | ||
} | ||
function getTargetProperty() { | ||
const configurations = getConfiguration(); | ||
return configurations.events.targetProperty; | ||
} | ||
function addEvent(payload) { | ||
@@ -19,3 +23,3 @@ checkTargetPropertyAvailability(); | ||
const isServer = () => typeof window === 'undefined'; | ||
const isDefined = () => typeof getTargetProperty() !== 'undefined'; | ||
const isDefined = () => Boolean(getTargetProperty()); | ||
const isArray = () => Array.isArray(getTargetProperty()); | ||
@@ -22,0 +26,0 @@ if (isServer()) |
@@ -5,3 +5,3 @@ { | ||
"license": "MIT", | ||
"version": "1.7.0-beta.5", | ||
"version": "1.7.0-beta.6", | ||
"description": "A type-safe, reusable, and flexible way for triggering Google Tag Manager track events.", | ||
@@ -72,4 +72,5 @@ "keywords": [ | ||
"tsc-alias": "^1.6.7", | ||
"type-fest": "^2.13.0", | ||
"typescript": "^4.6.4" | ||
} | ||
} |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
41442
788
34