@dpgradio/creative 7.6.0-beta.2 → 8.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -30,9 +30,9 @@ Example:
30
30
  @import "@dpgradio/creative/styles/fonts/qmusic";
31
31
 
32
32
  body, html {
33
- background-color: rgb(var(--q-teal));
33
+ background-color: rgb(var(--q-green));
34
34
  color: rgb(var(--q-grey) / 0.8);
35
- font-family: 'QMarkMyWords';
35
+ font-family: 'BlackBones';
36
36
  }
37
37
  ```
38
38
 
@@ -61,11 +61,11 @@ await configuration.retrieveConfigForDetectedStation(appId) // Default, by hostn
61
61
  // Or, if you want to retrieve the config by hostnames only.
62
62
  await configuration.retrieveConfigByHostname(appId)
63
63
  // Or, if you want to retrieve the config for a specific station:
64
- await configuration.retrieveConfigByStation(stationId, appId)
64
+ await configuration.retrieveConfigForStation(stationId, appId)
65
65
 
66
66
  // By default the first station ID (stationIdA) is used as the current station of the configuration.
67
67
  // If you want to use a different station, you can do so by calling setStation:
68
- await configuration.retrieveConfigByStations([stationIdA, stationIdB, stationIdC], appId)
68
+ await configuration.retrieveConfigForStations([stationIdA, stationIdB, stationIdC], appId)
69
69
  configuration.setStation(stationIdC)
70
70
  ```
71
71
  You can change the station later on at any time without having to retrieve the config again.
@@ -152,6 +152,18 @@ dataLayer.pushVirtualPageView(brand) // brand is not required when the config is
152
152
  dataLayer.pushEvent(event, data)
153
153
  ```
154
154
 
155
+ With Mixpanel
156
+ ```js
157
+ import { mixpanel } from '@dpgradio/creative'
158
+ import Mixpanel from 'mixpanel-browser'
159
+
160
+ mixpanel.initialize(Mixpanel, {
161
+ mixpanelId: 'MIXPANEL ID',
162
+ })
163
+
164
+ mixpanel.trackEvent(event, data)
165
+ ```
166
+
155
167
  ## API
156
168
 
157
169
  With an initialized [configuration](#config):
@@ -354,6 +366,25 @@ const image = new ImageGeneratorProperties('https://static.qmusic.be/acties/joe-
354
366
  (await shareable.generateUsingImage(image)).openWhatsappUrl()
355
367
  ```
356
368
 
369
+ ## CSP
370
+
371
+ Sometimes it's necessary to set strict Content Security Policy (CSP) headers. When that's the case a nicety of some of the methods in this package is that they support a random nonce to be passed in so extra sources (GTM, Privacy gate) don't need to be explicitly whitelisted (since they might be unknown at the time of development). Our datalayer and privacy gate initializers have an optional `nonce` parameter that can be passed in.
372
+
373
+ ```js
374
+ import { privacy, dataLayer } from '@dpgradio/creative'
375
+
376
+ privacy.initialize(privacyManagerId, websiteUrl, cmpCname, { nonce: "abc1234" })
377
+ dataLayer.initialize({ nonce: "abc1234" })
378
+ ```
379
+
380
+ Which then allows you to whitelist that nonce in your CSP header
381
+
382
+ ```
383
+ Content-Security-Policy: script-src 'nonce-abc1234'
384
+ ```
385
+
386
+ **!! Take note that this nonce need to be random on every request, as else this security is useless !!**
387
+
357
388
  ## Utilities
358
389
 
359
390
  This package provides a number of utility functions.