Skip to content
This repository has been archived by the owner on Apr 3, 2024. It is now read-only.

Add shouldReload on ConsentManagerBuilder like optional attribute #283

Merged
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
8 changes: 8 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -710,6 +710,7 @@ export default function() {
- [defaultDestinationBehavior](#defaultdestinationbehavior-1)
- [mapCustomPreferences](#mapcustompreferences)
- [cookieDomain](#cookiedomain-1)
- [shouldReload](#shouldReload-1)

##### children

Expand Down Expand Up @@ -777,6 +778,13 @@ Callback function allows you to use a custom preferences format (e.g: categories

The domain the `tracking-preferences` cookie should be scoped to.

##### shouldReload

**Type**: `boolean`
**Default**: `true`

Reload the page if the trackers have already been initialized so that the user's new preferences can take effect.

#### ConsentManagerBuilder Render Props

- [destinations](#destinations)
Expand Down
14 changes: 12 additions & 2 deletions src/consent-manager-builder/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,13 @@ interface Props {
* CDN to fetch list of integrations from
*/
cdnHost?: string

/**
* Default true
* Reload the page if the trackers have already been initialized so that
* the user's new preferences can take effect.
*/
shouldReload?: boolean
}

interface RenderProps {
Expand Down Expand Up @@ -118,7 +125,8 @@ export default class ConsentManagerBuilder extends Component<Props, State> {
onError: undefined,
shouldRequireConsent: () => true,
initialPreferences: {},
cdnHost: 'cdn.segment.com'
cdnHost: 'cdn.segment.com',
shouldReload: true
}

state = {
Expand Down Expand Up @@ -185,7 +193,8 @@ export default class ConsentManagerBuilder extends Component<Props, State> {
mapCustomPreferences,
defaultDestinationBehavior,
cookieName,
cdnHost = ConsentManagerBuilder.defaultProps.cdnHost
cdnHost = ConsentManagerBuilder.defaultProps.cdnHost,
shouldReload = ConsentManagerBuilder.defaultProps.shouldReload
} = this.props

// TODO: add option to run mapCustomPreferences on load so that the destination preferences automatically get updated
Expand Down Expand Up @@ -228,6 +237,7 @@ export default class ConsentManagerBuilder extends Component<Props, State> {
destinations,
destinationPreferences,
isConsentRequired,
shouldReload,
defaultDestinationBehavior,
categoryPreferences: preferences
})
Expand Down