File tree Expand file tree Collapse file tree 3 files changed +45
-0
lines changed
packages/cookie-consent/src/CookieConsentProvider Expand file tree Collapse file tree 3 files changed +45
-0
lines changed Original file line number Diff line number Diff line change 1+ ---
2+ ' @scaleway/cookie-consent ' : patch
3+ ---
4+
5+ Add a screen object from window into the context of segment
Original file line number Diff line number Diff line change @@ -47,6 +47,17 @@ export const SegmentConsentMiddleware = ({
4747 // https://segment.com/docs/privacy/consent-management/consent-in-segment-connections/#consent-object
4848 categoryPreferences : categoriesConsent ,
4949 }
50+ // eslint-disable-next-line @typescript-eslint/no-unnecessary-condition
51+ if ( window ) {
52+ const screen = {
53+ width : window . screen . width ,
54+ height : window . screen . height ,
55+ availHeight : window . screen . availHeight ,
56+ availWidth : window . screen . availWidth ,
57+ }
58+ // eslint-disable-next-line , no-param-reassign
59+ payload . obj . context [ 'screen' ] = screen
60+ }
5061
5162 // eslint-disable-next-line , no-param-reassign
5263 payload . obj . context [ 'consent' ] = consent
Original file line number Diff line number Diff line change 1+ // useSegmentIntegrations tests have been splitted in multiple files because of https://github.com/facebook/vi/issues/8987
2+ import SegmentProvider from '@scaleway/use-segment'
3+ import { render } from '@testing-library/react'
4+ import { describe , it } from 'vitest'
5+ import { CookieConsentProvider , SegmentConsentMiddleware } from '..'
6+
7+ const segmentSettings = {
8+ writeKey : 'writeKey' ,
9+ cdnURL : 'cdnURL' ,
10+ timeout : 300 ,
11+ }
12+
13+ describe ( 'CookieConsent - SegmentConsentMiddleware' , ( ) => {
14+ it ( 'should render correctly' , ( ) => {
15+ render (
16+ < CookieConsentProvider
17+ isConsentRequired
18+ essentialIntegrations = { [ 'Stripe' , 'Sentry' ] }
19+ config = { {
20+ segment : segmentSettings ,
21+ } }
22+ >
23+ < SegmentProvider settings = { segmentSettings } events = { { } } >
24+ < SegmentConsentMiddleware amplitudeIntegrationName = "Amplitude (Actions)" />
25+ </ SegmentProvider >
26+ </ CookieConsentProvider > ,
27+ )
28+ } )
29+ } )
You can’t perform that action at this time.
0 commit comments