1.30.9 • Published 2 days ago

@ketch-sdk/ketch-tag v1.30.9

Weekly downloads
88
License
MIT
Repository
github
Last release
2 days ago

ketch-tag

Ketch web infrastructure tag!

Prerequisites

  • NCC npm i -g @vercel/ncc

Local DX

  1. npm install
  2. npm run build
  3. docker compose -f base.yml -f docker-compose.yml up --build
  4. Navigate to https://localhost:8080/ketchtag/test/?swb_debug

Optional

You can test ketch-plugins or lanyard locally by including the following in ./docker-compose.yml under volumes.

- "{path-to-local-directory}/dist/plugins.js:/ketch/public/plugins.js"

Then update ./test/fixtures/index.html to point to the new file:

<script src="../plugins.js"></script>

Querystring parameters

The following querystring parameters are checked at various points during the initialization and operation of the Ketch tag.

parameterallowed valuesdescription
ketch_log (swb_log)trace, debug, info, warn, errorenables console logging by Ketch components
ketch_env (swb_env)staging, productionoverrides environment detection and uses a specific environment
ketch_region (swb_region)ISO-3166 country codeoverrides region detection and uses a specific region
ketch_jurisdiction (swb_p)jurisdiction codeoverrides jurisdiction detection and uses a specific jurisdiction
ketch_lang (lang, swb_l)ISO 639-1 language code, with optional regional extensionoverrides language detection and uses a specific language
ketch_show (swb_show)cd, preferencesforces an experience to show
ketch_preferences_tab (swb_preferences_tab)overviewTab, rightsTab, consentsTabforces a particular tab of the preferences experience to show

Ketch function

Newer bootstrap tags include the definition of a ketch function that should be the primary entrypoint into the Ketch Tag API. The old semaphore.push will still be supported until the next major release.

ketch('on', 'consent', consent => {
  console.log('consent updated', consent)
})

The equivalent using semaphore.push is as follows:

semaphore.push(['on', 'consent', consent => {
  console.log('consent updated', consent)
}])

The remainder of the examples will use the ketch function, but the equivalent semaphore.push can be used.

Showing Consent Experience

The consent experience can be shown to a data subject using the following:

ketch('showConsent', {
  // options
})

Showing Preferences Experience

The preferences experience can be shown to a data subject using the following:

ketch('showPreferences', {
  // options
})

Events

The Ketch tag will emit a variety of events to allow integrating into a site and extending functionality.

on

To handle every occurrence of an event (consent in this example), use the following:

function handleConsentChange(consent: Consent) {
  // TODO - do something with the consent
}

ketch('on', 'consent', handleConsentChange)

once

To handle just a single occurrence of an event, use the following:

ketch('once', 'consent', handleConsentChange)

off

To stop handling events, use the following:

ketch('off', 'consent', handleConsentChange)

consent

The consent event is emitted whenever consent is resolved, either by loading from local storage, remote storage or by prompting the user. The argument to the event is a consent object, where the keys are the purposes and the value is a boolean denoting whether the user has consented to the purpose.

environment

The environment event is emitted whenever the environment is resolved from configuration.

geoip

The geoip event is emitted whenever the location has been resolved from the IP address.

identities

The identities event is emitted whenever the identities collected about the user have changed.

jurisdiction

The jurisdiction event is emitted whenever the jurisdiction of the user has resolved or changed.

regionInfo

The regionInfo event is emitted whenever the region information about the user has resolved or changed.

willShowExperience

The willShowExperience event is emitted when an experience is shown to the user.

hideExperience

The hideExperience event is emitted when an experience is hidden from the user.

Properties

The Ketch tag exposes several properties available to interrogate.

config

To get the current configuration, use the following:

ketch('getConfig', handleConfig)

Plugins

The Ketch Tag allows extending functionality by registering plugins. The plugin is a function that receives an instance of the Ketch Tag and the configuration of the plugin.

function myPlugin(host: Ketch, _config: any) {
  host.on('consent', consent => {
    console.log('consent changed to: ', consent)
  })
}

ketch('registerPlugin', myPlugin)

Testing

To test the tag locally, run the following:

npm run all
docker compose --file base.yml up -d
docker compose up -d
open https://localhost:8080/ketchtag/test/

The test page is located in ./test/fixtures/index.html. The configuration is in ./test/fixtues/boot.js.

1.30.9

2 days ago

1.30.8

3 days ago

1.30.7

4 days ago

1.30.6

9 days ago

1.30.4

9 days ago

1.30.5

9 days ago

1.30.3

25 days ago

1.30.2

1 month ago

1.30.1

1 month ago

1.29.1

1 month ago

1.29.2

1 month ago

1.29.3

1 month ago

1.30.0

1 month ago

1.29.0

2 months ago

1.28.5

2 months ago

1.28.3

2 months ago

1.28.4

2 months ago

1.28.1

2 months ago

1.28.2

2 months ago

1.28.0

2 months ago

1.27.14

2 months ago

1.27.13

3 months ago

1.27.12

3 months ago

1.27.11

3 months ago

1.27.10

3 months ago

1.27.9

3 months ago

1.27.8

3 months ago

1.27.6

3 months ago

1.27.7

3 months ago

1.27.5

4 months ago

1.27.4

4 months ago

1.27.2

4 months ago

1.27.3

4 months ago

1.27.1

4 months ago

1.27.0

4 months ago

1.26.4

4 months ago

1.26.5

4 months ago

1.26.3

4 months ago

1.26.2

4 months ago

1.26.1

4 months ago

1.25.1

4 months ago

1.26.0

4 months ago

1.25.0

4 months ago

1.24.3

5 months ago

1.24.2

5 months ago

1.24.1

5 months ago

1.24.0

5 months ago

1.21.4

11 months ago

1.21.5

10 months ago

1.21.8

9 months ago

1.21.9

9 months ago

1.21.6

10 months ago

1.21.7

9 months ago

1.22.0

7 months ago

1.22.1

7 months ago

1.23.0

7 months ago

1.23.1

7 months ago

1.21.1

11 months ago

1.21.2

11 months ago

1.21.3

11 months ago

1.21.0

11 months ago

1.19.3

1 year ago

1.19.2

1 year ago

1.19.1

1 year ago

1.20.1

12 months ago

1.20.0

1 year ago

1.18.1

1 year ago

1.18.0

1 year ago

1.18.4

1 year ago

1.18.3

1 year ago

1.18.2

1 year ago

1.19.0

1 year ago

1.16.3

1 year ago

1.16.2

1 year ago

1.16.1

1 year ago

1.16.0

1 year ago

1.17.2

1 year ago

1.17.1

1 year ago

1.17.0

1 year ago

1.17.4

1 year ago

1.17.3

1 year ago

1.15.0

1 year ago

1.15.4

1 year ago

1.15.3

1 year ago

1.15.2

1 year ago

1.15.1

1 year ago

1.15.7

1 year ago

1.15.6

1 year ago

1.15.5

1 year ago

1.14.1

1 year ago

1.14.0

1 year ago

1.10.8

2 years ago

1.10.7

2 years ago

1.14.2

1 year ago

1.11.14

1 year ago

1.11.12

1 year ago

1.11.13

1 year ago

1.11.10

1 year ago

1.11.11

1 year ago

1.11.4

1 year ago

1.11.3

1 year ago

1.11.2

1 year ago

1.11.1

1 year ago

1.11.8

1 year ago

1.11.7

1 year ago

1.11.6

1 year ago

1.11.5

1 year ago

1.11.9

1 year ago

1.12.3

1 year ago

1.12.2

1 year ago

1.12.1

1 year ago

1.12.0

1 year ago

1.12.5

1 year ago

1.12.4

1 year ago

1.11.0

2 years ago

1.13.2

1 year ago

1.13.1

1 year ago

1.13.0

1 year ago

1.13.4

1 year ago

1.13.3

1 year ago

1.10.5

2 years ago

1.10.4

2 years ago

1.10.3

2 years ago

1.10.2

2 years ago

1.10.6

2 years ago

1.6.0

2 years ago

1.9.0

2 years ago

1.5.0

2 years ago

1.10.1

2 years ago

1.10.0

2 years ago

1.8.1

2 years ago

1.8.0

2 years ago

1.4.1

2 years ago

1.4.0

2 years ago

1.7.2

2 years ago

1.3.6

2 years ago

1.7.1

2 years ago

1.3.5

2 years ago

1.7.0

2 years ago

1.2.8

2 years ago

1.2.5

2 years ago

1.2.10

2 years ago

1.3.4

2 years ago

1.3.3

2 years ago

1.3.2

2 years ago

1.3.1

2 years ago

1.3.0

2 years ago

1.2.9

2 years ago

1.2.4

2 years ago

1.2.3

2 years ago

1.2.0

2 years ago

1.2.2

2 years ago

1.2.1

2 years ago

1.1.6

2 years ago

1.1.5

2 years ago

1.1.4

2 years ago

1.1.1

2 years ago

1.1.0

2 years ago

1.1.3

2 years ago

1.1.2

2 years ago

1.0.2

2 years ago

1.0.3

2 years ago

0.3.1

3 years ago

1.0.1

3 years ago

1.0.0

3 years ago

0.3.0

3 years ago

0.2.43

3 years ago

0.2.41

3 years ago

0.2.42

3 years ago

0.2.40

3 years ago

0.2.39

3 years ago

0.2.38

3 years ago

0.2.37

3 years ago

0.2.35

3 years ago

0.2.34

3 years ago

0.2.33

3 years ago

0.2.32

3 years ago

0.2.31

3 years ago

0.2.30

3 years ago

0.2.29

3 years ago

0.2.27

3 years ago

0.2.28

3 years ago

0.2.26

3 years ago

0.2.25

3 years ago

0.2.24

3 years ago

0.2.23

3 years ago

0.2.22

3 years ago

0.2.21

3 years ago

0.2.20

3 years ago

0.2.19

3 years ago

0.2.18

3 years ago

0.2.17

3 years ago

0.2.16

3 years ago

0.2.15

3 years ago

0.2.14

3 years ago

0.2.13

3 years ago

0.2.12

3 years ago

0.2.11

3 years ago

0.2.10

3 years ago

0.2.7

3 years ago

0.2.9

3 years ago

0.2.8

3 years ago

0.2.1

3 years ago

0.2.0

3 years ago

0.2.6

3 years ago

0.2.3

3 years ago

0.2.2

3 years ago

0.2.5

3 years ago

0.2.4

3 years ago

0.1.15

3 years ago

0.1.10

3 years ago

0.1.11

3 years ago

0.1.12

3 years ago

0.1.13

3 years ago

0.1.14

3 years ago

0.1.2

3 years ago

0.1.8

3 years ago

0.1.7

3 years ago

0.1.9

3 years ago

0.1.4

3 years ago

0.1.3

3 years ago

0.1.6

3 years ago

0.1.5

3 years ago

0.1.0

3 years ago

0.1.1

3 years ago