File tree Expand file tree Collapse file tree 1 file changed +15
-1
lines changed
app/code/Meta/Conversion/view/frontend/web/js Expand file tree Collapse file tree 1 file changed +15
-1
lines changed Original file line number Diff line number Diff line change @@ -3,10 +3,24 @@ define([
3
3
'jquery'
4
4
] , function ( $ ) {
5
5
'use strict' ;
6
+ function generateUUID ( ) {
7
+ if ( crypto . randomUUID ) {
8
+ return crypto . randomUUID ( ) ;
9
+ }
10
+ // crypto.randomUUID() was added to chrome in late 2021. This is a passable polyfill.
11
+ const buf = new Uint8Array ( 16 ) ;
12
+ crypto . getRandomValues ( buf ) ;
13
+ buf [ 6 ] = ( buf [ 6 ] & 0x0f ) | 0x40 ; // set version to 0100 (UUID version 4)
14
+ buf [ 8 ] = ( buf [ 8 ] & 0x3f ) | 0x80 ; // set variant to 10 (RFC4122 variant)
15
+ return Array . from ( buf ) . map ( ( b , i ) => {
16
+ const s = b . toString ( 16 ) . padStart ( 2 , '0' ) ;
17
+ return ( i === 4 || i === 6 || i === 8 || i === 10 ) ? '-' + s : s ;
18
+ } ) . join ( '' ) ;
19
+ }
6
20
7
21
return function ( config ) {
8
22
var browserEventData = config . browserEventData ,
9
- eventId = crypto . randomUUID ( ) ;
23
+ eventId = generateUUID ( ) ;
10
24
11
25
config . payload . eventId = eventId ;
12
26
You can’t perform that action at this time.
0 commit comments