@highfivve/ad-tag 5.11.6 → 5.11.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/ads/adPipeline.js +7 -1
- package/lib/console/components/globalConfig.js +37 -4
- package/lib/console/components/ui.js +1 -0
- package/lib/gen/packageJson.js +1 -1
- package/lib/util/browserStorageKeys.js +2 -1
- package/lib/util/debugLabels.js +40 -0
- package/lib/util/queryParameters.js +2 -1
- package/package.json +1 -1
package/lib/ads/adPipeline.js
CHANGED
|
@@ -5,6 +5,7 @@ var TCPurpose = tcfapi.responses.TCPurpose;
|
|
|
5
5
|
import { generateAdUnitPathVariables } from './adUnitPath';
|
|
6
6
|
import { createAssetLoaderService } from '../util/assetLoaderService';
|
|
7
7
|
import { uuidV4 } from '../util/uuid';
|
|
8
|
+
import { getMoliLabelsFromQueryParam, getMoliLabelsFromStorage } from '../util/debugLabels';
|
|
8
9
|
export const HIGH_PRIORITY = 100;
|
|
9
10
|
export const LOW_PRIORITY = 10;
|
|
10
11
|
export const mkInitStep = (name, fn) => {
|
|
@@ -83,7 +84,12 @@ export class AdPipeline {
|
|
|
83
84
|
? this.tcData
|
|
84
85
|
: consentReady(consentConfig, this.window, this.logger, runtimeConfig.environment);
|
|
85
86
|
return this.tcData.then(consentData => {
|
|
86
|
-
const extraLabels = [
|
|
87
|
+
const extraLabels = [
|
|
88
|
+
...(config.targeting?.labels || []),
|
|
89
|
+
...runtimeConfig.labels,
|
|
90
|
+
...getMoliLabelsFromQueryParam(this.window),
|
|
91
|
+
...getMoliLabelsFromStorage(this.window)
|
|
92
|
+
];
|
|
87
93
|
if (consentData.gdprApplies &&
|
|
88
94
|
consentData.purpose.consents[TCPurpose.STORE_INFORMATION_ON_DEVICE]) {
|
|
89
95
|
extraLabels.push('purpose-1');
|
|
@@ -21,6 +21,7 @@ import { BrowserStorageKeys } from 'ad-tag/util/browserStorageKeys';
|
|
|
21
21
|
import { calculateAdDensity } from 'ad-tag/console/util/calculateAdDensity';
|
|
22
22
|
import { extractPositionFromPath } from 'ad-tag/console/util/extractPositionFromPath';
|
|
23
23
|
import { getBrowserStorageValue, removeBrowserStorageValue, setBrowserStorageValue } from 'ad-tag/util/localStorage';
|
|
24
|
+
import { addMoliLabelToStorage, clearMoliLabelsFromStorage, getMoliLabelsFromStorage, removeMoliLabelFromStorage } from 'ad-tag/util/debugLabels';
|
|
24
25
|
const debugSidebarSelector = 'moli-debug-sidebar';
|
|
25
26
|
export class GlobalConfig extends Component {
|
|
26
27
|
constructor(props) {
|
|
@@ -75,6 +76,7 @@ export class GlobalConfig extends Component {
|
|
|
75
76
|
React.createElement(TagLabel, null, "Test mode"),
|
|
76
77
|
React.createElement(Toggle, { checked: isTestMode, title: isTestMode ? 'Switch back to production mode' : 'Override environment to test', onChange: checked => checked ? this.overrideEnvironmentToTest() : this.resetEnvironmentOverrides() }),
|
|
77
78
|
isTestMode && !isEnvironmentOverridden && (React.createElement(Tag, { variant: "yellow" }, "test environment set in config")))),
|
|
79
|
+
React.createElement(Block, { title: "Debug Labels", color: "debugLabels" }, this.renderDebugLabels()),
|
|
78
80
|
React.createElement(Block, { title: "Targeting", color: "targeting" },
|
|
79
81
|
config.targeting && (React.createElement("div", null,
|
|
80
82
|
React.createElement(SubHeadline, null, "Key/value pairs"),
|
|
@@ -100,6 +102,34 @@ export class GlobalConfig extends Component {
|
|
|
100
102
|
React.createElement("div", { className: "text-xs font-semibold opacity-60" }, this.requestedSizesLabel(slot))),
|
|
101
103
|
React.createElement("button", { className: "d-btn d-btn-ghost d-btn-sm font-normal normal-case", title: "Open in Ad Setup", onClick: () => this.openSlotInAdSetup(slot.domId) }, "details")))))))));
|
|
102
104
|
};
|
|
105
|
+
this.renderDebugLabels = () => {
|
|
106
|
+
const debugLabels = getMoliLabelsFromStorage(window);
|
|
107
|
+
return (React.createElement("div", null,
|
|
108
|
+
this.labels(debugLabels, {
|
|
109
|
+
onRemove: this.removeDebugLabel,
|
|
110
|
+
emptyMessage: 'No debug labels set.'
|
|
111
|
+
}),
|
|
112
|
+
React.createElement(TagContainer, null,
|
|
113
|
+
React.createElement(TextInput, { placeholder: "label", value: this.state.newDebugLabel, onChange: e => this.setState({ newDebugLabel: e.currentTarget.value }) }),
|
|
114
|
+
React.createElement(Btn, { onClick: () => this.addDebugLabel(this.state.newDebugLabel) }, "add"),
|
|
115
|
+
React.createElement(Btn, { variant: "red", onClick: this.clearDebugLabels, disabled: debugLabels.length === 0 }, "clear all"))));
|
|
116
|
+
};
|
|
117
|
+
this.addDebugLabel = (label) => {
|
|
118
|
+
const trimmed = label.trim();
|
|
119
|
+
if (trimmed.length === 0) {
|
|
120
|
+
return;
|
|
121
|
+
}
|
|
122
|
+
addMoliLabelToStorage(window, trimmed);
|
|
123
|
+
window.location.reload();
|
|
124
|
+
};
|
|
125
|
+
this.removeDebugLabel = (label) => {
|
|
126
|
+
removeMoliLabelFromStorage(window, label);
|
|
127
|
+
window.location.reload();
|
|
128
|
+
};
|
|
129
|
+
this.clearDebugLabels = () => {
|
|
130
|
+
clearMoliLabelsFromStorage(window);
|
|
131
|
+
window.location.reload();
|
|
132
|
+
};
|
|
103
133
|
this.renderAdSetup = (config) => {
|
|
104
134
|
const { modules, labelConfigService } = this.props;
|
|
105
135
|
const { showOnlyRenderedSlots, selectedSlotDomId } = this.state;
|
|
@@ -374,11 +404,13 @@ export class GlobalConfig extends Component {
|
|
|
374
404
|
: this.standardTagFromString(value))));
|
|
375
405
|
})))) : (React.createElement("span", null, "No key/values config present."));
|
|
376
406
|
};
|
|
377
|
-
this.labels = (labels) => {
|
|
407
|
+
this.labels = (labels, options) => {
|
|
378
408
|
return (React.createElement("div", { className: "mt-2 flex flex-wrap items-center gap-y-1" },
|
|
379
409
|
labels &&
|
|
380
|
-
labels.map((label, index) => (React.createElement(Tag, { key: index, variant: "grey", spacing: "medium" },
|
|
381
|
-
|
|
410
|
+
labels.map((label, index) => (React.createElement(Tag, { key: index, variant: "grey", spacing: "medium" },
|
|
411
|
+
label,
|
|
412
|
+
options?.onRemove && (React.createElement("button", { className: "ml-1 border-0 bg-transparent p-0 font-bold", title: `Remove ${label}`, onClick: () => options.onRemove(label) }, "\u2715"))))),
|
|
413
|
+
(!labels || labels.length === 0) && (React.createElement("span", null, options?.emptyMessage ?? 'No labels present.'))));
|
|
382
414
|
};
|
|
383
415
|
this.filterSetting = (name, filterSetting) => {
|
|
384
416
|
return (React.createElement("div", null,
|
|
@@ -505,7 +537,8 @@ export class GlobalConfig extends Component {
|
|
|
505
537
|
totalAdDensity: undefined,
|
|
506
538
|
percentagePerSlot: []
|
|
507
539
|
},
|
|
508
|
-
configVersion: 'not available'
|
|
540
|
+
configVersion: 'not available',
|
|
541
|
+
newDebugLabel: ''
|
|
509
542
|
};
|
|
510
543
|
if (!props.config) {
|
|
511
544
|
this.reportMissingConfig(this.state.messages);
|
package/lib/gen/packageJson.js
CHANGED
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import { parseQueryString } from './query';
|
|
2
|
+
import { getBrowserStorageValue, removeBrowserStorageValue, setBrowserStorageValue } from './localStorage';
|
|
3
|
+
import { QueryParameters } from './queryParameters';
|
|
4
|
+
import { BrowserStorageKeys } from './browserStorageKeys';
|
|
5
|
+
export const getMoliLabelsFromQueryParam = (window) => {
|
|
6
|
+
try {
|
|
7
|
+
return (parseQueryString(window.location.search).get(QueryParameters.moliLabels) ?? '')
|
|
8
|
+
.split(',')
|
|
9
|
+
.map(label => label.trim())
|
|
10
|
+
.filter(label => label.length > 0);
|
|
11
|
+
}
|
|
12
|
+
catch (e) {
|
|
13
|
+
return [];
|
|
14
|
+
}
|
|
15
|
+
};
|
|
16
|
+
const isStringArray = (value) => Array.isArray(value) && value.every(entry => typeof entry === 'string');
|
|
17
|
+
export const getMoliLabelsFromStorage = (window) => {
|
|
18
|
+
try {
|
|
19
|
+
const raw = getBrowserStorageValue(BrowserStorageKeys.moliLabels, window.localStorage);
|
|
20
|
+
if (!raw) {
|
|
21
|
+
return [];
|
|
22
|
+
}
|
|
23
|
+
const parsed = JSON.parse(raw);
|
|
24
|
+
return isStringArray(parsed) ? parsed : [];
|
|
25
|
+
}
|
|
26
|
+
catch (e) {
|
|
27
|
+
return [];
|
|
28
|
+
}
|
|
29
|
+
};
|
|
30
|
+
export const addMoliLabelToStorage = (window, label) => {
|
|
31
|
+
const labels = [...getMoliLabelsFromStorage(window), label];
|
|
32
|
+
setBrowserStorageValue(BrowserStorageKeys.moliLabels, JSON.stringify(labels), window.localStorage);
|
|
33
|
+
};
|
|
34
|
+
export const removeMoliLabelFromStorage = (window, label) => {
|
|
35
|
+
const labels = getMoliLabelsFromStorage(window).filter(entry => entry !== label);
|
|
36
|
+
setBrowserStorageValue(BrowserStorageKeys.moliLabels, JSON.stringify(labels), window.localStorage);
|
|
37
|
+
};
|
|
38
|
+
export const clearMoliLabelsFromStorage = (window) => {
|
|
39
|
+
removeBrowserStorageValue(BrowserStorageKeys.moliLabels, window.localStorage);
|
|
40
|
+
};
|