Skip to content

Commit 140ab8e

Browse files
Add default options override
1 parent 470e983 commit 140ab8e

File tree

1 file changed

+24
-0
lines changed

1 file changed

+24
-0
lines changed

audienceproject-data-web.js

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,29 @@ export const fetch = (customerId, customerOptions, callback) => {
7777
throw new Error('Invalid customer ID');
7878
}
7979

80+
const getUserOptions = () => {
81+
const key = '__audienceProjectDataFetchOptions=';
82+
83+
const parts = window.location.search.split(/[?&]/);
84+
let data;
85+
86+
parts.some((part) => {
87+
const matches = part.indexOf(key) === 0;
88+
89+
if (matches) {
90+
const value = part.slice(key.length);
91+
92+
try {
93+
data = JSON.parse(decodeURIComponent(value));
94+
} catch (error) {} // eslint-disable-line no-empty
95+
}
96+
97+
return matches;
98+
});
99+
100+
return data;
101+
};
102+
80103
const options = {
81104
allowStorageAccess: true,
82105
allowPersonalisation: true,
@@ -104,6 +127,7 @@ export const fetch = (customerId, customerOptions, callback) => {
104127
debug: false,
105128

106129
...customerOptions,
130+
...getUserOptions(),
107131
};
108132

109133
const debugInfo = (...args) => options.debug && console?.log(`[${moduleName}]`, ...args); // eslint-disable-line no-console, compat/compat

0 commit comments

Comments
 (0)