@dpgradio/creative 7.1.1 → 7.2.2
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/analytics/dataLayer.js +4 -0
- package/src/app/hybrid.js +4 -0
- package/src/privacy/privacy.js +47 -12
- package/src/share/ShareResult.js +4 -4
- package/src/share/Shareable.js +12 -17
- package/package-lock.json +0 -3891
package/package.json
CHANGED
package/src/app/hybrid.js
CHANGED
package/src/privacy/privacy.js
CHANGED
|
@@ -3,6 +3,10 @@ import loadScript from '../utils/loadScript.js'
|
|
|
3
3
|
|
|
4
4
|
class Privacy {
|
|
5
5
|
constructor() {
|
|
6
|
+
if (typeof window === 'undefined') {
|
|
7
|
+
return
|
|
8
|
+
}
|
|
9
|
+
|
|
6
10
|
window._privacy = window._privacy || []
|
|
7
11
|
|
|
8
12
|
this.consent = undefined
|
|
@@ -52,10 +56,39 @@ class Privacy {
|
|
|
52
56
|
this.consentSubscribers.forEach((subscriber) => subscriber(null))
|
|
53
57
|
}, timeoutTime)
|
|
54
58
|
|
|
55
|
-
this.
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
+
this.pushConsentGiven((consentData) => {
|
|
60
|
+
let updatedConsentData = {
|
|
61
|
+
consentString: consentData.tcString,
|
|
62
|
+
purposes: new Set(consentData.dpgConsentString.split('|')),
|
|
63
|
+
}
|
|
64
|
+
const iabPurposePromises = []
|
|
65
|
+
|
|
66
|
+
// We have 10 IAB purposes, so we create 10 promises that resolve with the purpose number or null if the purpose is not given.
|
|
67
|
+
for (let i = 1; i < 11; i++) {
|
|
68
|
+
iabPurposePromises.push(
|
|
69
|
+
new Promise((resolve) => {
|
|
70
|
+
this.push(
|
|
71
|
+
i,
|
|
72
|
+
() => resolve(i), // Resolve with the purpose number
|
|
73
|
+
() => resolve(null) // Resolve without a value, indicating that the purpose is not given
|
|
74
|
+
)
|
|
75
|
+
})
|
|
76
|
+
)
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
Promise.all(iabPurposePromises).then((purposeConsents) => {
|
|
80
|
+
updatedConsentData = purposeConsents.reduce((acc, purpose) => {
|
|
81
|
+
if (purpose) {
|
|
82
|
+
acc.purposes.add(purpose)
|
|
83
|
+
}
|
|
84
|
+
return acc
|
|
85
|
+
}, updatedConsentData)
|
|
86
|
+
|
|
87
|
+
this.consent = new Consent(updatedConsentData)
|
|
88
|
+
this.consentSubscribers.forEach((subscriber) => subscriber(this.consent))
|
|
89
|
+
|
|
90
|
+
clearTimeout(timeout)
|
|
91
|
+
})
|
|
59
92
|
})
|
|
60
93
|
}
|
|
61
94
|
|
|
@@ -78,8 +111,12 @@ class Privacy {
|
|
|
78
111
|
})
|
|
79
112
|
}
|
|
80
113
|
|
|
81
|
-
push(type,
|
|
82
|
-
window._privacy.push([type,
|
|
114
|
+
push(type, successCallback, failCallback = () => {}) {
|
|
115
|
+
window._privacy.push([type, successCallback, failCallback])
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
pushConsentGiven(callback) {
|
|
119
|
+
this.push('consentgiven', callback)
|
|
83
120
|
}
|
|
84
121
|
|
|
85
122
|
pushFunctional(callback) {
|
|
@@ -87,16 +124,14 @@ class Privacy {
|
|
|
87
124
|
}
|
|
88
125
|
}
|
|
89
126
|
|
|
90
|
-
const targetedAdvertisingPurposes = [3, 4]
|
|
91
|
-
|
|
92
127
|
class Consent {
|
|
93
|
-
constructor(
|
|
94
|
-
this.consentString = consentString
|
|
95
|
-
this.purposes = purposes
|
|
128
|
+
constructor(consentData) {
|
|
129
|
+
this.consentString = consentData.consentString
|
|
130
|
+
this.purposes = consentData.purposes
|
|
96
131
|
}
|
|
97
132
|
|
|
98
133
|
allowsTargetedAdvertising() {
|
|
99
|
-
return
|
|
134
|
+
return this.purposes.has('targeted_advertising')
|
|
100
135
|
}
|
|
101
136
|
}
|
|
102
137
|
|
package/src/share/ShareResult.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import
|
|
1
|
+
import openExternalUrl from '../utils/openExternalUrl.js'
|
|
2
2
|
|
|
3
3
|
export default class ShareResult {
|
|
4
4
|
constructor(shareable, { url, image }) {
|
|
@@ -20,14 +20,14 @@ export default class ShareResult {
|
|
|
20
20
|
}
|
|
21
21
|
|
|
22
22
|
openFacebookUrl() {
|
|
23
|
-
|
|
23
|
+
openExternalUrl(this.facebookUrl())
|
|
24
24
|
}
|
|
25
25
|
|
|
26
26
|
openWhatsappUrl() {
|
|
27
|
-
|
|
27
|
+
openExternalUrl(this.whatsappUrl())
|
|
28
28
|
}
|
|
29
29
|
|
|
30
30
|
openInstagramUrl() {
|
|
31
|
-
|
|
31
|
+
openExternalUrl(this.instagramUrl())
|
|
32
32
|
}
|
|
33
33
|
}
|
package/src/share/Shareable.js
CHANGED
|
@@ -1,5 +1,3 @@
|
|
|
1
|
-
// eslint-disable-next-line import/no-unresolved -- TODO: Needs a rewrite to fetch
|
|
2
|
-
import axios from 'axios'
|
|
3
1
|
import ShareResult from './ShareResult.js'
|
|
4
2
|
|
|
5
3
|
export default class Shareable {
|
|
@@ -36,21 +34,18 @@ export default class Shareable {
|
|
|
36
34
|
return this
|
|
37
35
|
}
|
|
38
36
|
|
|
39
|
-
generateUsingImage(imageGeneratorProperties) {
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
domain: this.domain,
|
|
50
|
-
},
|
|
51
|
-
})
|
|
52
|
-
.then((response) => resolve(new ShareResult(this, response.data)))
|
|
53
|
-
.catch(reject)
|
|
37
|
+
async generateUsingImage(imageGeneratorProperties) {
|
|
38
|
+
const response = await fetch('https://dba1du5ckc.execute-api.eu-west-3.amazonaws.com/prod/', {
|
|
39
|
+
method: 'POST',
|
|
40
|
+
body: JSON.stringify({
|
|
41
|
+
title: this.title,
|
|
42
|
+
description: this.description,
|
|
43
|
+
image_generator: imageGeneratorProperties.toJson(),
|
|
44
|
+
redirect_url: this.redirectUrl,
|
|
45
|
+
domain: this.domain,
|
|
46
|
+
}),
|
|
54
47
|
})
|
|
48
|
+
const data = await response.json()
|
|
49
|
+
return new ShareResult(this, data)
|
|
55
50
|
}
|
|
56
51
|
}
|