@dpgradio/creative 5.8.1 → 5.9.0
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/package.json +1 -1
- package/src/privacy/dataLayer.js +37 -18
- package/src/socket/SocketConnection.js +1 -1
- package/package-lock.json +0 -3891
package/package.json
CHANGED
package/src/privacy/dataLayer.js
CHANGED
|
@@ -5,6 +5,8 @@ import loadScript from '../utils/loadScript.js'
|
|
|
5
5
|
class DataLayer {
|
|
6
6
|
constructor() {
|
|
7
7
|
window.dataLayer = window.dataLayer || []
|
|
8
|
+
this.campaignDetails = {}
|
|
9
|
+
this.userInformation = {}
|
|
8
10
|
}
|
|
9
11
|
|
|
10
12
|
initialize(gtmId = 'GTM-TW99VZN') {
|
|
@@ -12,6 +14,14 @@ class DataLayer {
|
|
|
12
14
|
|
|
13
15
|
this.pushGtmStart()
|
|
14
16
|
this.pushUserWhenAuthenticated()
|
|
17
|
+
this._getUserInformationOnLoad()
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
setCampaignDetails(details) {
|
|
21
|
+
this.campaignDetails = {
|
|
22
|
+
inApp: hybrid.isNativeApp,
|
|
23
|
+
...details,
|
|
24
|
+
}
|
|
15
25
|
}
|
|
16
26
|
|
|
17
27
|
push(data) {
|
|
@@ -26,16 +36,29 @@ class DataLayer {
|
|
|
26
36
|
this.push({ event, ...data })
|
|
27
37
|
}
|
|
28
38
|
|
|
39
|
+
async pushCampaignAction(action, data) {
|
|
40
|
+
this.push({
|
|
41
|
+
event: 'campaign_action',
|
|
42
|
+
campaign: {
|
|
43
|
+
...this.campaignDetails,
|
|
44
|
+
action,
|
|
45
|
+
...data,
|
|
46
|
+
},
|
|
47
|
+
...this.userInformation,
|
|
48
|
+
})
|
|
49
|
+
}
|
|
50
|
+
|
|
29
51
|
pushUserWhenAuthenticated() {
|
|
30
52
|
hybrid.on('authenticated', ({ radioToken }) => {
|
|
31
53
|
if (radioToken) {
|
|
32
|
-
this.
|
|
54
|
+
this.setUserInformation(radioToken)
|
|
55
|
+
this.pushEvent('account_id', this.userInformation)
|
|
33
56
|
}
|
|
34
57
|
})
|
|
35
58
|
}
|
|
36
59
|
|
|
37
60
|
async pushVirtualPageView(brand = config('gtm_brand')) {
|
|
38
|
-
|
|
61
|
+
await this._getUserInformationOnLoad()
|
|
39
62
|
|
|
40
63
|
this.pushEvent('VirtualPageView', {
|
|
41
64
|
virtualPageURL: {
|
|
@@ -43,29 +66,25 @@ class DataLayer {
|
|
|
43
66
|
platform: 'browser',
|
|
44
67
|
brand,
|
|
45
68
|
},
|
|
46
|
-
|
|
69
|
+
user: this.userInformation,
|
|
47
70
|
})
|
|
48
71
|
}
|
|
49
72
|
|
|
50
73
|
async _getUserInformationOnLoad() {
|
|
51
|
-
if (
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
console.error('User information could not be loaded:', error)
|
|
59
|
-
return {}
|
|
74
|
+
if (hybrid.isNativeApp()) {
|
|
75
|
+
try {
|
|
76
|
+
const radioToken = await hybrid.appLoaded()
|
|
77
|
+
this.setUserInformation(radioToken)
|
|
78
|
+
} catch (error) {
|
|
79
|
+
console.error('User information could not be loaded:', error)
|
|
80
|
+
}
|
|
60
81
|
}
|
|
61
82
|
}
|
|
62
83
|
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
loggedIn: true,
|
|
68
|
-
},
|
|
84
|
+
setUserInformation(radioToken) {
|
|
85
|
+
this.userInformation = {
|
|
86
|
+
account_id: hybrid.decodeRadioToken(radioToken).uid,
|
|
87
|
+
loggedIn: true,
|
|
69
88
|
}
|
|
70
89
|
}
|
|
71
90
|
}
|