@dpgradio/creative 7.0.6 → 7.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 +12 -0
- package/package.json +1 -1
- package/src/analytics/mixpanel.js +37 -0
- package/src/index.js +7 -1
- package/package-lock.json +0 -3891
- /package/src/{privacy → analytics}/dataLayer.js +0 -0
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.json
CHANGED
|
@@ -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()
|
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'
|