@adobe/alloy 2.32.1-beta.0 → 2.32.1-beta.1
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/components.json +4 -0
- package/dist/alloy.js +12561 -11149
- package/dist/alloy.min.js +1 -1
- package/dist/alloyServiceWorker.js +7 -19
- package/dist/alloyServiceWorker.min.js +1 -1
- package/dist/types/browser/src/allOptionalComponents.d.ts +2 -0
- package/dist/types/browser/src/components/componentCreators.d.ts +1 -0
- package/dist/types/browser/src/index.d.ts +4 -2
- package/dist/types/browser/src/initializeStandalone.d.ts +4 -0
- package/dist/types/core/src/components/MediaAnalyticsBridge/createGetInstance.d.ts +1 -1
- package/dist/types/core/src/components/MediaAnalyticsBridge/createMediaHelper.d.ts +7 -56
- package/dist/types/core/src/core/componentCreators.d.ts +0 -1
- package/dist/utils/createEventMergeId.js +38 -30
- package/dist/utils/deepAssign.js +10 -4
- package/package.json +9 -13
- package/rollup.config.js +9 -15
- package/scripts/alloyBuilder.js +34 -42
- package/scripts/helpers/componentMetadata.js +25 -0
- package/scripts/helpers/generateEntryPoint.js +29 -0
- package/src/allOptionalComponents.js +14 -0
- package/src/components/ActivityCollector/attachClickActivityCollector.js +55 -0
- package/src/components/ActivityCollector/configValidators.js +52 -0
- package/src/components/ActivityCollector/createClickActivityStorage.js +33 -0
- package/src/components/ActivityCollector/createClickedElementProperties.js +224 -0
- package/src/components/ActivityCollector/createGetClickedElementProperties.js +68 -0
- package/src/components/ActivityCollector/createInjectClickedElementProperties.js +80 -0
- package/src/components/ActivityCollector/createRecallAndInjectClickedElementProperties.js +45 -0
- package/src/components/ActivityCollector/createStorePageViewProperties.js +20 -0
- package/src/components/ActivityCollector/getLinkName.js +145 -0
- package/src/components/ActivityCollector/getLinkRegion.js +65 -0
- package/src/components/ActivityCollector/index.js +132 -0
- package/src/components/ActivityCollector/utils/activityMapExtensionEnabled.js +16 -0
- package/src/components/ActivityCollector/utils/createTransientStorage.js +26 -0
- package/src/components/ActivityCollector/utils/determineLinkType.js +27 -0
- package/src/components/ActivityCollector/utils/dom/elementHasClickHandler.js +15 -0
- package/src/components/ActivityCollector/utils/dom/extractDomain.js +20 -0
- package/src/components/ActivityCollector/utils/dom/findClickableElement.js +36 -0
- package/src/components/ActivityCollector/utils/dom/getAbsoluteUrlFromAnchorElement.js +25 -0
- package/src/components/ActivityCollector/utils/dom/isButtonSubmitElement.js +15 -0
- package/src/components/ActivityCollector/utils/dom/isDownloadLink.js +27 -0
- package/src/components/ActivityCollector/utils/dom/isExitLink.js +24 -0
- package/src/components/ActivityCollector/utils/dom/isInputSubmitElement.js +26 -0
- package/src/components/ActivityCollector/utils/dom/isSupportedAnchorElement.js +24 -0
- package/src/components/ActivityCollector/utils/dom/isSupportedTextNode.js +27 -0
- package/src/components/ActivityCollector/utils/hasPageName.js +23 -0
- package/src/components/ActivityCollector/utils/isDifferentDomains.js +19 -0
- package/src/components/ActivityCollector/utils/trimQueryFromUrl.js +31 -0
- package/src/components/ActivityCollector/utils/truncateWhiteSpace.js +22 -0
- package/src/components/ActivityCollector/validateClickCollectionConfig.js +47 -0
- package/src/components/componentCreators.js +13 -0
- package/src/index.js +10 -2
- package/src/initializeStandalone.js +34 -0
- package/src/standalone.js +3 -26
- package/.browserslistrc +0 -2
- package/babel.config.js +0 -76
- package/dist/types/core/src/constants/sessionDataKeys.d.ts +0 -1
- package/scripts/helpers/entryPointGeneratorBabelPlugin.js +0 -101
- /package/dist/types/{core → browser}/src/components/ActivityCollector/attachClickActivityCollector.d.ts +0 -0
- /package/dist/types/{core → browser}/src/components/ActivityCollector/configValidators.d.ts +0 -0
- /package/dist/types/{core → browser}/src/components/ActivityCollector/createClickActivityStorage.d.ts +0 -0
- /package/dist/types/{core → browser}/src/components/ActivityCollector/createClickedElementProperties.d.ts +0 -0
- /package/dist/types/{core → browser}/src/components/ActivityCollector/createGetClickedElementProperties.d.ts +0 -0
- /package/dist/types/{core → browser}/src/components/ActivityCollector/createInjectClickedElementProperties.d.ts +0 -0
- /package/dist/types/{core → browser}/src/components/ActivityCollector/createRecallAndInjectClickedElementProperties.d.ts +0 -0
- /package/dist/types/{core → browser}/src/components/ActivityCollector/createStorePageViewProperties.d.ts +0 -0
- /package/dist/types/{core → browser}/src/components/ActivityCollector/getLinkName.d.ts +0 -0
- /package/dist/types/{core → browser}/src/components/ActivityCollector/getLinkRegion.d.ts +0 -0
- /package/dist/types/{core → browser}/src/components/ActivityCollector/index.d.ts +0 -0
- /package/dist/types/{core → browser}/src/components/ActivityCollector/utils/activityMapExtensionEnabled.d.ts +0 -0
- /package/dist/types/{core → browser}/src/components/ActivityCollector/utils/createTransientStorage.d.ts +0 -0
- /package/dist/types/{core → browser}/src/components/ActivityCollector/utils/determineLinkType.d.ts +0 -0
- /package/dist/types/{core → browser}/src/components/ActivityCollector/utils/dom/elementHasClickHandler.d.ts +0 -0
- /package/dist/types/{core → browser}/src/components/ActivityCollector/utils/dom/extractDomain.d.ts +0 -0
- /package/dist/types/{core → browser}/src/components/ActivityCollector/utils/dom/findClickableElement.d.ts +0 -0
- /package/dist/types/{core → browser}/src/components/ActivityCollector/utils/dom/getAbsoluteUrlFromAnchorElement.d.ts +0 -0
- /package/dist/types/{core → browser}/src/components/ActivityCollector/utils/dom/isButtonSubmitElement.d.ts +0 -0
- /package/dist/types/{core → browser}/src/components/ActivityCollector/utils/dom/isDownloadLink.d.ts +0 -0
- /package/dist/types/{core → browser}/src/components/ActivityCollector/utils/dom/isExitLink.d.ts +0 -0
- /package/dist/types/{core → browser}/src/components/ActivityCollector/utils/dom/isInputSubmitElement.d.ts +0 -0
- /package/dist/types/{core → browser}/src/components/ActivityCollector/utils/dom/isSupportedAnchorElement.d.ts +0 -0
- /package/dist/types/{core → browser}/src/components/ActivityCollector/utils/dom/isSupportedTextNode.d.ts +0 -0
- /package/dist/types/{core → browser}/src/components/ActivityCollector/utils/hasPageName.d.ts +0 -0
- /package/dist/types/{core → browser}/src/components/ActivityCollector/utils/isDifferentDomains.d.ts +0 -0
- /package/dist/types/{core → browser}/src/components/ActivityCollector/utils/trimQueryFromUrl.d.ts +0 -0
- /package/dist/types/{core → browser}/src/components/ActivityCollector/utils/truncateWhiteSpace.d.ts +0 -0
- /package/dist/types/{core → browser}/src/components/ActivityCollector/validateClickCollectionConfig.d.ts +0 -0
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
/*
|
|
2
|
+
Copyright 2022 Adobe. All rights reserved.
|
|
3
|
+
This file is licensed to you under the Apache License, Version 2.0 (the "License");
|
|
4
|
+
you may not use this file except in compliance with the License. You may obtain a copy
|
|
5
|
+
of the License at http://www.apache.org/licenses/LICENSE-2.0
|
|
6
|
+
|
|
7
|
+
Unless required by applicable law or agreed to in writing, software distributed under
|
|
8
|
+
the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
|
|
9
|
+
OF ANY KIND, either express or implied. See the License for the specific language
|
|
10
|
+
governing permissions and limitations under the License.
|
|
11
|
+
*/
|
|
12
|
+
|
|
13
|
+
import { noop } from "@adobe/alloy-core/utils";
|
|
14
|
+
|
|
15
|
+
const createClickHandler = ({ eventManager, lifecycle, handleError }) => {
|
|
16
|
+
return (clickEvent) => {
|
|
17
|
+
// Ignore repropagated clicks from AppMeasurement
|
|
18
|
+
if (clickEvent.s_fe) {
|
|
19
|
+
return Promise.resolve();
|
|
20
|
+
}
|
|
21
|
+
// TODO: Consider safeguarding from the same object being clicked multiple times in rapid succession?
|
|
22
|
+
const clickedElement =
|
|
23
|
+
"composedPath" in clickEvent && clickEvent.composedPath().length > 0
|
|
24
|
+
? clickEvent.composedPath()[0]
|
|
25
|
+
: clickEvent.target;
|
|
26
|
+
const event = eventManager.createEvent();
|
|
27
|
+
// this is to make sure a exit link personalization metric use send beacon
|
|
28
|
+
event.documentMayUnload();
|
|
29
|
+
return (
|
|
30
|
+
lifecycle
|
|
31
|
+
.onClick({ event, clickedElement })
|
|
32
|
+
.then(() => {
|
|
33
|
+
if (event.isEmpty()) {
|
|
34
|
+
return Promise.resolve();
|
|
35
|
+
}
|
|
36
|
+
return eventManager.sendEvent(event);
|
|
37
|
+
})
|
|
38
|
+
// eventManager.sendEvent() will return a promise resolved to an
|
|
39
|
+
// object and we want to avoid returning any value to the customer
|
|
40
|
+
.then(noop)
|
|
41
|
+
.catch((error) => {
|
|
42
|
+
handleError(error, "click collection");
|
|
43
|
+
})
|
|
44
|
+
);
|
|
45
|
+
};
|
|
46
|
+
};
|
|
47
|
+
|
|
48
|
+
export default ({ eventManager, lifecycle, handleError }) => {
|
|
49
|
+
const clickHandler = createClickHandler({
|
|
50
|
+
eventManager,
|
|
51
|
+
lifecycle,
|
|
52
|
+
handleError,
|
|
53
|
+
});
|
|
54
|
+
document.addEventListener("click", clickHandler, true);
|
|
55
|
+
};
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
/*
|
|
2
|
+
Copyright 2019 Adobe. All rights reserved.
|
|
3
|
+
This file is licensed to you under the Apache License, Version 2.0 (the "License");
|
|
4
|
+
you may not use this file except in compliance with the License. You may obtain a copy
|
|
5
|
+
of the License at http://www.apache.org/licenses/LICENSE-2.0
|
|
6
|
+
|
|
7
|
+
Unless required by applicable law or agreed to in writing, software distributed under
|
|
8
|
+
the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
|
|
9
|
+
OF ANY KIND, either express or implied. See the License for the specific language
|
|
10
|
+
governing permissions and limitations under the License.
|
|
11
|
+
*/
|
|
12
|
+
|
|
13
|
+
import {
|
|
14
|
+
boolean,
|
|
15
|
+
callback,
|
|
16
|
+
objectOf,
|
|
17
|
+
string,
|
|
18
|
+
} from "@adobe/alloy-core/utils/validation";
|
|
19
|
+
|
|
20
|
+
const DEFAULT_DOWNLOAD_QUALIFIER =
|
|
21
|
+
"\\.(exe|zip|wav|mp3|mov|mpg|avi|wmv|pdf|doc|docx|xls|xlsx|ppt|pptx)$";
|
|
22
|
+
|
|
23
|
+
export const downloadLinkQualifier = string()
|
|
24
|
+
.regexp()
|
|
25
|
+
.default(DEFAULT_DOWNLOAD_QUALIFIER);
|
|
26
|
+
|
|
27
|
+
const validators = objectOf({
|
|
28
|
+
clickCollectionEnabled: boolean().default(true),
|
|
29
|
+
clickCollection: objectOf({
|
|
30
|
+
internalLinkEnabled: boolean().default(true),
|
|
31
|
+
externalLinkEnabled: boolean().default(true),
|
|
32
|
+
downloadLinkEnabled: boolean().default(true),
|
|
33
|
+
// TODO: Consider moving downloadLinkQualifier here.
|
|
34
|
+
sessionStorageEnabled: boolean().default(false),
|
|
35
|
+
eventGroupingEnabled: boolean().default(false),
|
|
36
|
+
filterClickProperties: callback(),
|
|
37
|
+
}).default({
|
|
38
|
+
internalLinkEnabled: true,
|
|
39
|
+
externalLinkEnabled: true,
|
|
40
|
+
downloadLinkEnabled: true,
|
|
41
|
+
sessionStorageEnabled: false,
|
|
42
|
+
eventGroupingEnabled: false,
|
|
43
|
+
}),
|
|
44
|
+
downloadLinkQualifier,
|
|
45
|
+
onBeforeLinkClickSend: callback().deprecated(
|
|
46
|
+
'The field "onBeforeLinkClickSend" has been deprecated. Use "clickCollection.filterClickDetails" instead.',
|
|
47
|
+
),
|
|
48
|
+
});
|
|
49
|
+
|
|
50
|
+
// Export both the validators and the default qualifier
|
|
51
|
+
export { DEFAULT_DOWNLOAD_QUALIFIER };
|
|
52
|
+
export default validators;
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
/*
|
|
2
|
+
Copyright 2024 Adobe. All rights reserved.
|
|
3
|
+
This file is licensed to you under the Apache License, Version 2.0 (the "License");
|
|
4
|
+
you may not use this file except in compliance with the License. You may obtain a copy
|
|
5
|
+
of the License at http://www.apache.org/licenses/LICENSE-2.0
|
|
6
|
+
|
|
7
|
+
Unless required by applicable law or agreed to in writing, software distributed under
|
|
8
|
+
the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
|
|
9
|
+
OF ANY KIND, either express or implied. See the License for the specific language
|
|
10
|
+
governing permissions and limitations under the License.
|
|
11
|
+
*/
|
|
12
|
+
|
|
13
|
+
const CLICK_ACTIVITY_DATA = "clickData";
|
|
14
|
+
|
|
15
|
+
export default ({ storage }) => {
|
|
16
|
+
return {
|
|
17
|
+
save: (data) => {
|
|
18
|
+
const jsonData = JSON.stringify(data);
|
|
19
|
+
storage.setItem(CLICK_ACTIVITY_DATA, jsonData);
|
|
20
|
+
},
|
|
21
|
+
load: () => {
|
|
22
|
+
let jsonData = null;
|
|
23
|
+
const data = storage.getItem(CLICK_ACTIVITY_DATA);
|
|
24
|
+
if (data) {
|
|
25
|
+
jsonData = JSON.parse(data);
|
|
26
|
+
}
|
|
27
|
+
return jsonData;
|
|
28
|
+
},
|
|
29
|
+
remove: () => {
|
|
30
|
+
storage.removeItem(CLICK_ACTIVITY_DATA);
|
|
31
|
+
},
|
|
32
|
+
};
|
|
33
|
+
};
|
|
@@ -0,0 +1,224 @@
|
|
|
1
|
+
/*
|
|
2
|
+
Copyright 2022 Adobe. All rights reserved.
|
|
3
|
+
This file is licensed to you under the Apache License, Version 2.0 (the "License");
|
|
4
|
+
you may not use this file except in compliance with the License. You may obtain a copy
|
|
5
|
+
of the License at http://www.apache.org/licenses/LICENSE-2.0
|
|
6
|
+
|
|
7
|
+
Unless required by applicable law or agreed to in writing, software distributed under
|
|
8
|
+
the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
|
|
9
|
+
OF ANY KIND, either express or implied. See the License for the specific language
|
|
10
|
+
governing permissions and limitations under the License.
|
|
11
|
+
*/
|
|
12
|
+
|
|
13
|
+
const buildXdmFromClickedElementProperties = (props) => {
|
|
14
|
+
return {
|
|
15
|
+
eventType: "web.webinteraction.linkClicks",
|
|
16
|
+
web: {
|
|
17
|
+
webInteraction: {
|
|
18
|
+
name: props.linkName,
|
|
19
|
+
region: props.linkRegion,
|
|
20
|
+
type: props.linkType,
|
|
21
|
+
URL: props.linkUrl,
|
|
22
|
+
linkClicks: {
|
|
23
|
+
value: 1,
|
|
24
|
+
},
|
|
25
|
+
},
|
|
26
|
+
},
|
|
27
|
+
};
|
|
28
|
+
};
|
|
29
|
+
|
|
30
|
+
const buildDataFromClickedElementProperties = (props) => {
|
|
31
|
+
return {
|
|
32
|
+
__adobe: {
|
|
33
|
+
analytics: {
|
|
34
|
+
contextData: {
|
|
35
|
+
a: {
|
|
36
|
+
activitymap: {
|
|
37
|
+
page: props.pageName,
|
|
38
|
+
link: props.linkName,
|
|
39
|
+
region: props.linkRegion,
|
|
40
|
+
pageIDType: props.pageIDType,
|
|
41
|
+
},
|
|
42
|
+
},
|
|
43
|
+
},
|
|
44
|
+
},
|
|
45
|
+
},
|
|
46
|
+
};
|
|
47
|
+
};
|
|
48
|
+
|
|
49
|
+
const populateClickedElementPropertiesFromOptions = (options, props) => {
|
|
50
|
+
const { xdm, data, clickedElement } = options;
|
|
51
|
+
props.clickedElement = clickedElement;
|
|
52
|
+
if (xdm && xdm.web && xdm.web.webInteraction) {
|
|
53
|
+
const { name, region, type, URL } = xdm.web.webInteraction;
|
|
54
|
+
props.linkName = name;
|
|
55
|
+
props.linkRegion = region;
|
|
56
|
+
props.linkType = type;
|
|
57
|
+
props.linkUrl = URL;
|
|
58
|
+
}
|
|
59
|
+
// DATA has priority over XDM
|
|
60
|
+
/* eslint no-underscore-dangle: 0 */
|
|
61
|
+
if (data && data.__adobe && data.__adobe.analytics) {
|
|
62
|
+
const { contextData } = data.__adobe.analytics;
|
|
63
|
+
if (contextData && contextData.a && contextData.a.activitymap) {
|
|
64
|
+
// Set the properties if they exists
|
|
65
|
+
const { page, link, region, pageIDType } = contextData.a.activitymap;
|
|
66
|
+
props.pageName = page || props.pageName;
|
|
67
|
+
props.linkName = link || props.linkName;
|
|
68
|
+
props.linkRegion = region || props.linkRegion;
|
|
69
|
+
if (pageIDType !== undefined) {
|
|
70
|
+
props.pageIDType = pageIDType;
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
};
|
|
75
|
+
|
|
76
|
+
export default ({ properties, logger } = {}) => {
|
|
77
|
+
let props = properties || {};
|
|
78
|
+
const clickedElementProperties = {
|
|
79
|
+
get pageName() {
|
|
80
|
+
return props.pageName;
|
|
81
|
+
},
|
|
82
|
+
set pageName(value) {
|
|
83
|
+
props.pageName = value;
|
|
84
|
+
},
|
|
85
|
+
get linkName() {
|
|
86
|
+
return props.linkName;
|
|
87
|
+
},
|
|
88
|
+
set linkName(value) {
|
|
89
|
+
props.linkName = value;
|
|
90
|
+
},
|
|
91
|
+
get linkRegion() {
|
|
92
|
+
return props.linkRegion;
|
|
93
|
+
},
|
|
94
|
+
set linkRegion(value) {
|
|
95
|
+
props.linkRegion = value;
|
|
96
|
+
},
|
|
97
|
+
get linkType() {
|
|
98
|
+
return props.linkType;
|
|
99
|
+
},
|
|
100
|
+
set linkType(value) {
|
|
101
|
+
props.linkType = value;
|
|
102
|
+
},
|
|
103
|
+
get linkUrl() {
|
|
104
|
+
return props.linkUrl;
|
|
105
|
+
},
|
|
106
|
+
set linkUrl(value) {
|
|
107
|
+
props.linkUrl = value;
|
|
108
|
+
},
|
|
109
|
+
get pageIDType() {
|
|
110
|
+
return props.pageIDType;
|
|
111
|
+
},
|
|
112
|
+
set pageIDType(value) {
|
|
113
|
+
props.pageIDType = value;
|
|
114
|
+
},
|
|
115
|
+
get clickedElement() {
|
|
116
|
+
return props.clickedElement;
|
|
117
|
+
},
|
|
118
|
+
set clickedElement(value) {
|
|
119
|
+
props.clickedElement = value;
|
|
120
|
+
},
|
|
121
|
+
get properties() {
|
|
122
|
+
return {
|
|
123
|
+
pageName: props.pageName,
|
|
124
|
+
linkName: props.linkName,
|
|
125
|
+
linkRegion: props.linkRegion,
|
|
126
|
+
linkType: props.linkType,
|
|
127
|
+
linkUrl: props.linkUrl,
|
|
128
|
+
pageIDType: props.pageIDType,
|
|
129
|
+
};
|
|
130
|
+
},
|
|
131
|
+
isValidLink() {
|
|
132
|
+
return (
|
|
133
|
+
!!props.linkUrl &&
|
|
134
|
+
!!props.linkType &&
|
|
135
|
+
!!props.linkName &&
|
|
136
|
+
!!props.linkRegion
|
|
137
|
+
);
|
|
138
|
+
},
|
|
139
|
+
isInternalLink() {
|
|
140
|
+
return this.isValidLink() && props.linkType === "other";
|
|
141
|
+
},
|
|
142
|
+
isValidActivityMapData() {
|
|
143
|
+
return (
|
|
144
|
+
!!props.pageName &&
|
|
145
|
+
!!props.linkName &&
|
|
146
|
+
!!props.linkRegion &&
|
|
147
|
+
props.pageIDType !== undefined
|
|
148
|
+
);
|
|
149
|
+
},
|
|
150
|
+
get xdm() {
|
|
151
|
+
if (props.filteredXdm) {
|
|
152
|
+
return props.filteredXdm;
|
|
153
|
+
}
|
|
154
|
+
return buildXdmFromClickedElementProperties(this);
|
|
155
|
+
},
|
|
156
|
+
get data() {
|
|
157
|
+
if (props.filteredData) {
|
|
158
|
+
return props.filteredData;
|
|
159
|
+
}
|
|
160
|
+
return buildDataFromClickedElementProperties(this);
|
|
161
|
+
},
|
|
162
|
+
applyPropertyFilter(filter) {
|
|
163
|
+
if (filter && filter(props) === false) {
|
|
164
|
+
if (logger) {
|
|
165
|
+
logger.info(
|
|
166
|
+
`Clicked element properties were rejected by filter function: ${JSON.stringify(
|
|
167
|
+
this.properties,
|
|
168
|
+
null,
|
|
169
|
+
2,
|
|
170
|
+
)}`,
|
|
171
|
+
);
|
|
172
|
+
}
|
|
173
|
+
props = {};
|
|
174
|
+
}
|
|
175
|
+
},
|
|
176
|
+
applyOptionsFilter(filter) {
|
|
177
|
+
const opts = this.options;
|
|
178
|
+
if (opts && opts.clickedElement && (opts.xdm || opts.data)) {
|
|
179
|
+
// Properties are rejected if filter is explicitly false.
|
|
180
|
+
if (filter && filter(opts) === false) {
|
|
181
|
+
if (logger) {
|
|
182
|
+
logger.info(
|
|
183
|
+
`Clicked element properties were rejected by filter function: ${JSON.stringify(
|
|
184
|
+
this.properties,
|
|
185
|
+
null,
|
|
186
|
+
2,
|
|
187
|
+
)}`,
|
|
188
|
+
);
|
|
189
|
+
}
|
|
190
|
+
this.options = undefined;
|
|
191
|
+
return;
|
|
192
|
+
}
|
|
193
|
+
this.options = opts;
|
|
194
|
+
// This is just to ensure that any fields outside clicked element properties
|
|
195
|
+
// set by the user filter persists.
|
|
196
|
+
props.filteredXdm = opts.xdm;
|
|
197
|
+
props.filteredData = opts.data;
|
|
198
|
+
}
|
|
199
|
+
},
|
|
200
|
+
get options() {
|
|
201
|
+
const opts = {};
|
|
202
|
+
if (this.isValidLink()) {
|
|
203
|
+
opts.xdm = this.xdm;
|
|
204
|
+
}
|
|
205
|
+
if (this.isValidActivityMapData()) {
|
|
206
|
+
opts.data = this.data;
|
|
207
|
+
}
|
|
208
|
+
if (this.clickedElement) {
|
|
209
|
+
opts.clickedElement = this.clickedElement;
|
|
210
|
+
}
|
|
211
|
+
if (!opts.xdm && !opts.data) {
|
|
212
|
+
return undefined;
|
|
213
|
+
}
|
|
214
|
+
return opts;
|
|
215
|
+
},
|
|
216
|
+
set options(value) {
|
|
217
|
+
props = {};
|
|
218
|
+
if (value) {
|
|
219
|
+
populateClickedElementPropertiesFromOptions(value, props);
|
|
220
|
+
}
|
|
221
|
+
},
|
|
222
|
+
};
|
|
223
|
+
return clickedElementProperties;
|
|
224
|
+
};
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
/*
|
|
2
|
+
Copyright 2022 Adobe. All rights reserved.
|
|
3
|
+
This file is licensed to you under the Apache License, Version 2.0 (the "License");
|
|
4
|
+
you may not use this file except in compliance with the License. You may obtain a copy
|
|
5
|
+
of the License at http://www.apache.org/licenses/LICENSE-2.0
|
|
6
|
+
|
|
7
|
+
Unless required by applicable law or agreed to in writing, software distributed under
|
|
8
|
+
the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
|
|
9
|
+
OF ANY KIND, either express or implied. See the License for the specific language
|
|
10
|
+
governing permissions and limitations under the License.
|
|
11
|
+
*/
|
|
12
|
+
|
|
13
|
+
import createClickedElementProperties from "./createClickedElementProperties.js";
|
|
14
|
+
|
|
15
|
+
export default ({
|
|
16
|
+
window,
|
|
17
|
+
getLinkName,
|
|
18
|
+
getLinkRegion,
|
|
19
|
+
getAbsoluteUrlFromAnchorElement,
|
|
20
|
+
findClickableElement,
|
|
21
|
+
determineLinkType,
|
|
22
|
+
}) => {
|
|
23
|
+
return ({ clickedElement, config, logger, clickActivityStorage }) => {
|
|
24
|
+
const {
|
|
25
|
+
onBeforeLinkClickSend: optionsFilter, // Deprecated
|
|
26
|
+
clickCollection,
|
|
27
|
+
} = config;
|
|
28
|
+
const { filterClickDetails: propertyFilter } = clickCollection;
|
|
29
|
+
const elementProperties = createClickedElementProperties({ logger });
|
|
30
|
+
if (clickedElement) {
|
|
31
|
+
const clickableElement = findClickableElement(clickedElement);
|
|
32
|
+
if (clickableElement) {
|
|
33
|
+
elementProperties.clickedElement = clickedElement;
|
|
34
|
+
elementProperties.linkUrl = getAbsoluteUrlFromAnchorElement(
|
|
35
|
+
window,
|
|
36
|
+
clickableElement,
|
|
37
|
+
);
|
|
38
|
+
elementProperties.linkType = determineLinkType(
|
|
39
|
+
window,
|
|
40
|
+
config,
|
|
41
|
+
elementProperties.linkUrl,
|
|
42
|
+
clickableElement,
|
|
43
|
+
);
|
|
44
|
+
elementProperties.linkRegion = getLinkRegion(clickableElement);
|
|
45
|
+
elementProperties.linkName = getLinkName(clickableElement);
|
|
46
|
+
elementProperties.pageIDType = 0;
|
|
47
|
+
elementProperties.pageName = window.location.href;
|
|
48
|
+
// Check if we have a page-name stored from an earlier page view event
|
|
49
|
+
const storedLinkData = clickActivityStorage.load();
|
|
50
|
+
if (storedLinkData && storedLinkData.pageName) {
|
|
51
|
+
elementProperties.pageName = storedLinkData.pageName;
|
|
52
|
+
// Perhaps pageIDType should be established after customer filter is applied
|
|
53
|
+
// Like if pageName starts with "http" then pageIDType = 0
|
|
54
|
+
elementProperties.pageIDType = 1;
|
|
55
|
+
}
|
|
56
|
+
// If defined, run user provided filter function
|
|
57
|
+
if (propertyFilter) {
|
|
58
|
+
// clickCollection.filterClickDetails
|
|
59
|
+
elementProperties.applyPropertyFilter(propertyFilter);
|
|
60
|
+
} else if (optionsFilter) {
|
|
61
|
+
// onBeforeLinkClickSend
|
|
62
|
+
elementProperties.applyOptionsFilter(optionsFilter);
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
return elementProperties;
|
|
67
|
+
};
|
|
68
|
+
};
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
/*
|
|
2
|
+
Copyright 2022 Adobe. All rights reserved.
|
|
3
|
+
This file is licensed to you under the Apache License, Version 2.0 (the "License");
|
|
4
|
+
you may not use this file except in compliance with the License. You may obtain a copy
|
|
5
|
+
of the License at http://www.apache.org/licenses/LICENSE-2.0
|
|
6
|
+
|
|
7
|
+
Unless required by applicable law or agreed to in writing, software distributed under
|
|
8
|
+
the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
|
|
9
|
+
OF ANY KIND, either express or implied. See the License for the specific language
|
|
10
|
+
governing permissions and limitations under the License.
|
|
11
|
+
*/
|
|
12
|
+
|
|
13
|
+
import activityMapExtensionEnabled from "./utils/activityMapExtensionEnabled.js";
|
|
14
|
+
import isDifferentDomains from "./utils/isDifferentDomains.js";
|
|
15
|
+
|
|
16
|
+
const isDissallowedLinkType = (clickCollection, linkType) => {
|
|
17
|
+
return (
|
|
18
|
+
linkType &&
|
|
19
|
+
((linkType === "download" && !clickCollection.downloadLinkEnabled) ||
|
|
20
|
+
(linkType === "exit" && !clickCollection.externalLinkEnabled) ||
|
|
21
|
+
(linkType === "other" && !clickCollection.internalLinkEnabled))
|
|
22
|
+
);
|
|
23
|
+
};
|
|
24
|
+
|
|
25
|
+
export default ({
|
|
26
|
+
config,
|
|
27
|
+
logger,
|
|
28
|
+
getClickedElementProperties,
|
|
29
|
+
clickActivityStorage,
|
|
30
|
+
}) => {
|
|
31
|
+
const { clickCollectionEnabled, clickCollection } = config;
|
|
32
|
+
if (!clickCollectionEnabled) {
|
|
33
|
+
return () => undefined;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
return ({ event, clickedElement }) => {
|
|
37
|
+
const elementProperties = getClickedElementProperties({
|
|
38
|
+
clickActivityStorage,
|
|
39
|
+
clickedElement,
|
|
40
|
+
config,
|
|
41
|
+
logger,
|
|
42
|
+
});
|
|
43
|
+
const linkType = elementProperties.linkType;
|
|
44
|
+
// Avoid clicks to be collected for the ActivityMap interface
|
|
45
|
+
if (activityMapExtensionEnabled()) {
|
|
46
|
+
return;
|
|
47
|
+
}
|
|
48
|
+
if (
|
|
49
|
+
elementProperties.isValidLink() &&
|
|
50
|
+
isDissallowedLinkType(clickCollection, linkType)
|
|
51
|
+
) {
|
|
52
|
+
logger.info(
|
|
53
|
+
`Cancelling link click event due to clickCollection.${linkType}LinkEnabled = false.`,
|
|
54
|
+
);
|
|
55
|
+
} else if (
|
|
56
|
+
// Determine if element properties should be sent with event now, or be saved
|
|
57
|
+
// and grouped with a future page view event.
|
|
58
|
+
// Event grouping is not supported for the deprecated onBeforeLinkClickSend callback
|
|
59
|
+
// because only click properties is saved and not XDM and DATA (which could have been modified).
|
|
60
|
+
// However, if the filterClickDetails callback is available we group events because it takes
|
|
61
|
+
// priority over onBeforeLinkClickSend and only supports processing click properties.
|
|
62
|
+
elementProperties.isInternalLink() &&
|
|
63
|
+
clickCollection.eventGroupingEnabled &&
|
|
64
|
+
(!config.onBeforeLinkClickSend || clickCollection.filterClickDetails) &&
|
|
65
|
+
!isDifferentDomains(window.location.hostname, elementProperties.linkUrl)
|
|
66
|
+
) {
|
|
67
|
+
clickActivityStorage.save(elementProperties.properties);
|
|
68
|
+
} else if (elementProperties.isValidLink()) {
|
|
69
|
+
// Event will be sent
|
|
70
|
+
event.mergeXdm(elementProperties.xdm);
|
|
71
|
+
event.mergeData(elementProperties.data);
|
|
72
|
+
clickActivityStorage.save({
|
|
73
|
+
pageName: elementProperties.pageName,
|
|
74
|
+
pageIDType: elementProperties.pageIDType,
|
|
75
|
+
});
|
|
76
|
+
} else if (elementProperties.isValidActivityMapData()) {
|
|
77
|
+
clickActivityStorage.save(elementProperties.properties);
|
|
78
|
+
}
|
|
79
|
+
};
|
|
80
|
+
};
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
/*
|
|
2
|
+
Copyright 2024 Adobe. All rights reserved.
|
|
3
|
+
This file is licensed to you under the Apache License, Version 2.0 (the "License");
|
|
4
|
+
you may not use this file except in compliance with the License. You may obtain a copy
|
|
5
|
+
of the License at http://www.apache.org/licenses/LICENSE-2.0
|
|
6
|
+
|
|
7
|
+
Unless required by applicable law or agreed to in writing, software distributed under
|
|
8
|
+
the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
|
|
9
|
+
OF ANY KIND, either express or implied. See the License for the specific language
|
|
10
|
+
governing permissions and limitations under the License.
|
|
11
|
+
*/
|
|
12
|
+
|
|
13
|
+
import createClickedElementProperties from "./createClickedElementProperties.js";
|
|
14
|
+
import activityMapExtensionEnabled from "./utils/activityMapExtensionEnabled.js";
|
|
15
|
+
|
|
16
|
+
export default ({ clickActivityStorage }) => {
|
|
17
|
+
return (event) => {
|
|
18
|
+
// Avoid clicks to be collected for the ActivityMap interface
|
|
19
|
+
if (activityMapExtensionEnabled()) {
|
|
20
|
+
return;
|
|
21
|
+
}
|
|
22
|
+
const properties = clickActivityStorage.load();
|
|
23
|
+
const elementProperties = createClickedElementProperties({ properties });
|
|
24
|
+
if (
|
|
25
|
+
elementProperties.isValidLink() ||
|
|
26
|
+
elementProperties.isValidActivityMapData()
|
|
27
|
+
) {
|
|
28
|
+
if (elementProperties.isValidLink()) {
|
|
29
|
+
const xdm = elementProperties.xdm;
|
|
30
|
+
// Have to delete the eventType not to override the page view
|
|
31
|
+
delete xdm.eventType;
|
|
32
|
+
event.mergeXdm(xdm);
|
|
33
|
+
}
|
|
34
|
+
if (elementProperties.isValidActivityMapData()) {
|
|
35
|
+
event.mergeData(elementProperties.data);
|
|
36
|
+
}
|
|
37
|
+
// NOTE: We can't clear out all the storage here because we might still need to
|
|
38
|
+
// keep a page-name for multiple link-clicks (e.g. downloads) on the same page.
|
|
39
|
+
clickActivityStorage.save({
|
|
40
|
+
pageName: elementProperties.pageName,
|
|
41
|
+
pageIDType: elementProperties.pageIDType,
|
|
42
|
+
});
|
|
43
|
+
}
|
|
44
|
+
};
|
|
45
|
+
};
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
/*
|
|
2
|
+
Copyright 2024 Adobe. All rights reserved.
|
|
3
|
+
This file is licensed to you under the Apache License, Version 2.0 (the "License");
|
|
4
|
+
you may not use this file except in compliance with the License. You may obtain a copy
|
|
5
|
+
of the License at http://www.apache.org/licenses/LICENSE-2.0
|
|
6
|
+
|
|
7
|
+
Unless required by applicable law or agreed to in writing, software distributed under
|
|
8
|
+
the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
|
|
9
|
+
OF ANY KIND, either express or implied. See the License for the specific language
|
|
10
|
+
governing permissions and limitations under the License.
|
|
11
|
+
*/
|
|
12
|
+
|
|
13
|
+
export default ({ clickActivityStorage }) => {
|
|
14
|
+
return (event) => {
|
|
15
|
+
clickActivityStorage.save({
|
|
16
|
+
pageName: event.getContent().xdm.web.webPageDetails.name,
|
|
17
|
+
pageIDType: 1, // 1 = name, 0 = URL
|
|
18
|
+
});
|
|
19
|
+
};
|
|
20
|
+
};
|