File tree Expand file tree Collapse file tree 1 file changed +4
-11
lines changed
flags-sdk/experimentation-statsig Expand file tree Collapse file tree 1 file changed +4
-11
lines changed Original file line number Diff line number Diff line change @@ -6,7 +6,7 @@ import { getCartId } from './lib/get-cart-id'
6
6
import { HTMLRewriter } from 'htmlrewriter'
7
7
import { statsigAdapter } from '@flags-sdk/statsig'
8
8
import { identify } from './lib/identify'
9
- import { safeJsonStringify } from 'flags'
9
+ import { embedBootstrapData } from 'flags/next '
10
10
11
11
export const config = {
12
12
matcher : [ '/' , '/cart' ] ,
@@ -49,17 +49,10 @@ export async function middleware(request: NextRequest) {
49
49
{ hash : 'djb2' }
50
50
)
51
51
52
- const rewriter = new HTMLRewriter ( )
53
- rewriter . on ( 'script#embed' , {
54
- element ( element ) {
55
- element . setInnerContent (
56
- safeJsonStringify ( { clientInitializeResponse, statsigUser } ) ,
57
- { html : true }
58
- )
59
- // element.setAttribute('style', 'display: block')
60
- } ,
52
+ const modifiedResponse = embedBootstrapData ( response , {
53
+ clientInitializeResponse,
54
+ statsigUser,
61
55
} )
62
- const modifiedResponse = rewriter . transform ( response )
63
56
const h = new Headers ( modifiedResponse . headers )
64
57
h . append ( 'set-cookie' , `stable-id=${ stableId . value } ` )
65
58
h . append ( 'set-cookie' , `cart-id=${ cartId . value } ` )
You can’t perform that action at this time.
0 commit comments