-
Notifications
You must be signed in to change notification settings - Fork 214
Expand file tree
/
Copy pathhead-active_data.js
More file actions
49 lines (49 loc) · 1.51 KB
/
head-active_data.js
File metadata and controls
49 lines (49 loc) · 1.51 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
/*
* Copyright (c) 2024, Salesforce, Inc.
* All rights reserved.
* SPDX-License-Identifier: BSD-3-Clause
* For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/BSD-3-Clause
*/
var dw = window.dw || {}
dw.ac = {
_analytics: null,
_events: [],
_category: '',
_searchData: '',
_anact: '',
_anact_nohit_tag: '',
_analytics_enabled: 'true',
_timeZone: Intl.DateTimeFormat().resolvedOptions().timeZone,
_capture: function (configs) {
if (Object.prototype.toString.call(configs) === '[object Array]') {
configs.forEach(captureObject)
return
}
dw.ac._events.push(configs)
},
capture: function () {
dw.ac._capture(arguments)
// send to CQ as well:
if (window.CQuotient) {
window.CQuotient.trackEventsFromAC(arguments)
}
},
EV_PRD_SEARCHHIT: 'searchhit',
EV_PRD_DETAIL: 'detail',
EV_PRD_RECOMMENDATION: 'recommendation',
EV_PRD_SETPRODUCT: 'setproduct',
applyContext: function (context) {
if (typeof context === 'object' && context.hasOwnProperty('category')) {
dw.ac._category = context.category
}
if (typeof context === 'object' && context.hasOwnProperty('searchData')) {
dw.ac._searchData = context.searchData
}
},
setDWAnalytics: function (analytics) {
dw.ac._analytics = analytics
},
eventsIsEmpty: function () {
return 0 == dw.ac._events.length
}
}