@@ -109,26 +109,35 @@ export const spec = {
109
109
const syncs = [ ] ;
110
110
if ( syncOptions . pixelEnabled ) {
111
111
resps . forEach ( ( ) => {
112
- const uuid = getUserID ( ) ;
113
- const syncUrl = SYNC_URL ;
114
- let params = '' ;
115
- if ( gdprConsent && typeof gdprConsent . consentString === 'string' ) {
116
- if ( typeof gdprConsent . gdprApplies === 'boolean' ) {
117
- params += `?gdpr=${ Number ( gdprConsent . gdprApplies ) } &gdpr_consent=${ gdprConsent . consentString } ` ;
118
- } else {
119
- params += `?gdpr_consent=${ gdprConsent . consentString } ` ;
120
- }
121
- }
122
- syncs . push ( {
123
- type : 'image' ,
124
- url : syncUrl . replace ( '{UUID}' , uuid ) + params ,
125
- } ) ;
112
+ syncs . push ( getSync ( 'image' , gdprConsent ) ) ;
113
+ } ) ;
114
+ }
115
+ if ( syncOptions . iframeEnabled ) {
116
+ resps . forEach ( ( ) => {
117
+ syncs . push ( getSync ( 'iframe' , gdprConsent ) ) ;
126
118
} ) ;
127
119
}
128
120
return syncs ;
129
121
}
130
122
}
131
123
124
+ const getSync = ( type , gdprConsent ) => {
125
+ const uuid = getUserID ( ) ;
126
+ const syncUrl = SYNC_URL ;
127
+ let params = '&type=' + type ;
128
+ if ( gdprConsent && typeof gdprConsent . consentString === 'string' ) {
129
+ if ( typeof gdprConsent . gdprApplies === 'boolean' ) {
130
+ params += `&gdpr=${ Number ( gdprConsent . gdprApplies ) } &gdpr_consent=${ gdprConsent . consentString } ` ;
131
+ } else {
132
+ params += `&gdpr_consent=${ gdprConsent . consentString } ` ;
133
+ }
134
+ }
135
+ return {
136
+ type : type ,
137
+ url : syncUrl . replace ( '{UUID}' , uuid ) + params ,
138
+ } ;
139
+ }
140
+
132
141
const getUserID = ( ) => {
133
142
const cookieName = COOKIE_NAME ;
134
143
const uuidLen = UUID_LEN ;
0 commit comments