Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/chatty-ladybugs-rhyme.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@scaleway/cookie-consent': patch
---

Add a screen object from window into the context of segment
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,17 @@ export const SegmentConsentMiddleware = ({
// https://segment.com/docs/privacy/consent-management/consent-in-segment-connections/#consent-object
categoryPreferences: categoriesConsent,
}
// eslint-disable-next-line @typescript-eslint/no-unnecessary-condition
if (window) {
const screen = {
width: window.screen.width,
height: window.screen.height,
availHeight: window.screen.availHeight,
availWidth: window.screen.availWidth,
}
// eslint-disable-next-line , no-param-reassign
payload.obj.context['screen'] = screen
}

// eslint-disable-next-line , no-param-reassign
payload.obj.context['consent'] = consent
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
// useSegmentIntegrations tests have been splitted in multiple files because of https://github.com/facebook/vi/issues/8987
import SegmentProvider from '@scaleway/use-segment'
import { render } from '@testing-library/react'
import { describe, it } from 'vitest'
import { CookieConsentProvider, SegmentConsentMiddleware } from '..'

const segmentSettings = {
writeKey: 'writeKey',
cdnURL: 'cdnURL',
timeout: 300,
}

describe('CookieConsent - SegmentConsentMiddleware', () => {
it('should render correctly', () => {
render(
<CookieConsentProvider
isConsentRequired
essentialIntegrations={['Stripe', 'Sentry']}
config={{
segment: segmentSettings,
}}
>
<SegmentProvider settings={segmentSettings} events={{}}>
<SegmentConsentMiddleware amplitudeIntegrationName="Amplitude (Actions)" />
</SegmentProvider>
</CookieConsentProvider>,
)
})
})