@dpgradio/creative 7.0.6 → 7.0.7

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
@@ -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):
package/package-lock.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dpgradio/creative",
3
- "version": "5.9.0",
3
+ "version": "7.6.0-beta.2",
4
4
  "lockfileVersion": 1,
5
5
  "requires": true,
6
6
  "dependencies": {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dpgradio/creative",
3
- "version": "7.0.6",
3
+ "version": "7.0.7",
4
4
  "description": "Support package for standalone Javascript applications",
5
5
  "main": "src/index.js",
6
6
  "scripts": {
@@ -0,0 +1,37 @@
1
+ import privacy from '../privacy/privacy.js'
2
+
3
+ class Mixpanel {
4
+ constructor() {
5
+ this.trackingEvents = false
6
+ this.trackBacklog = []
7
+ this.mixpanel = null
8
+ }
9
+
10
+ initialize(Mixpanel, { mixpanelId, trackPageview = true }) {
11
+ this.mixpanel = Mixpanel
12
+ privacy.push('analytics', () => {
13
+ this.mixpanel.init(mixpanelId, {
14
+ track_pageview: trackPageview,
15
+ persistence: 'localStorage',
16
+ api_host: 'https://api-eu.mixpanel.com',
17
+ })
18
+
19
+ while (this.trackBacklog.length > 0) {
20
+ const { eventName, properties } = this.trackBacklog.shift()
21
+ this.mixpanel.track(eventName, properties)
22
+ }
23
+
24
+ this.trackingEvents = true
25
+ })
26
+ }
27
+
28
+ pushEvent(eventName, properties) {
29
+ if (this.trackingEvents) {
30
+ this.mixpanel.track(eventName, properties)
31
+ } else {
32
+ this.trackBacklog.push({ eventName, properties })
33
+ }
34
+ }
35
+ }
36
+
37
+ export default new Mixpanel()
@@ -18,10 +18,10 @@ class Configuration {
18
18
  /**
19
19
  * Retrieve the configuration for the current hostname or present query parameter and the given app (optional).
20
20
  */
21
- async retrieveConfigForDetectedStation(appId = null) {
21
+ async retrieveConfigForDetectedStation(appId = null, { parameterName = 'stationId' } = {}) {
22
22
  const parameters = new URLSearchParams(window.location.search)
23
- if (parameters.has('stationId')) {
24
- return this.retrieveConfigForStation(parameters.get('stationId'), appId)
23
+ if (parameters.has(parameterName)) {
24
+ return this.retrieveConfigForStation(parameters.get(parameterName), appId)
25
25
  }
26
26
  return this.retrieveConfigByHostname(appId)
27
27
  }
package/src/index.js CHANGED
@@ -1,8 +1,13 @@
1
1
  export { default as hybrid } from './app/hybrid.js'
2
2
 
3
+ // Privacy
3
4
  export { default as privacy } from './privacy/privacy.js'
4
- export { default as dataLayer } from './privacy/dataLayer.js'
5
5
 
6
+ // Analytics
7
+ export { default as dataLayer } from './analytics/dataLayer.js'
8
+ export { default as mixpanel } from './analytics/mixpanel.js'
9
+
10
+ // Websocket
6
11
  export { default as socket } from './socket/socket.js'
7
12
 
8
13
  export { default as configuration, config } from './config/config.js'
@@ -11,6 +16,7 @@ export { default as api } from './api/api.js'
11
16
 
12
17
  export { default as authentication } from './app/authentication.js'
13
18
 
19
+ // Utils
14
20
  export { default as loadScript } from './utils/loadScript.js'
15
21
  export { default as openLink } from './utils/openLink.js'
16
22
  export { default as openExternalUrl } from './utils/openExternalUrl.js'
File without changes