@mparticle/web-mixpanel-kit 2.1.2 → 3.2.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.
@@ -46,7 +46,7 @@ var renderSnippet = function() {
46
46
  /* eslint-enable */
47
47
 
48
48
  // eslint-disable-next-line no-redeclare
49
- var constructor = function () {
49
+ var constructor = function() {
50
50
  var self = this,
51
51
  isInitialized = false,
52
52
  forwarderSettings = null,
@@ -64,13 +64,74 @@ var constructor = function () {
64
64
  if (!testMode) {
65
65
  renderSnippet();
66
66
  }
67
- mixpanel.init(
68
- settings.token,
67
+ // Build init options object
68
+ var initOptions = {
69
+ api_host: forwarderSettings.baseUrl,
70
+ };
71
+
72
+ // Session Replay boolean settings
73
+ var boolSettings = [
74
+ { key: 'recordHeatmapData', mappedKey: 'record_heatmap_data' },
75
+ { key: 'autocapture', mappedKey: 'autocapture' },
76
+ { key: 'recordCanvas', mappedKey: 'record_canvas' },
77
+ ];
78
+
79
+ // Session Replay numeric settings
80
+ var numericSettings = [
69
81
  {
70
- api_host: forwarderSettings.baseUrl,
82
+ key: 'recordSessionsPercent',
83
+ mappedKey: 'record_sessions_percent',
71
84
  },
72
- 'mparticle'
73
- );
85
+ {
86
+ key: 'recordIdleTimeoutMs',
87
+ mappedKey: 'record_idle_timeout_ms',
88
+ },
89
+ { key: 'recordMaxMs', mappedKey: 'record_max_ms' },
90
+ { key: 'recordMinMs', mappedKey: 'record_min_ms' },
91
+ ];
92
+
93
+ // Session Replay string settings
94
+ var stringSettings = [
95
+ {
96
+ key: 'recordMaskTextSelector',
97
+ mappedKey: 'record_mask_text_selector',
98
+ },
99
+ {
100
+ key: 'recordBlockSelector',
101
+ mappedKey: 'record_block_selector',
102
+ },
103
+ { key: 'recordBlockClass', mappedKey: 'record_block_class' },
104
+ {
105
+ key: 'recordMaskTextClass',
106
+ mappedKey: 'record_mask_text_class',
107
+ },
108
+ ];
109
+
110
+ // Process boolean settings
111
+ boolSettings.forEach(function(setting) {
112
+ if (forwarderSettings[setting.key] != null) {
113
+ initOptions[setting.mappedKey] =
114
+ forwarderSettings[setting.key] === 'True';
115
+ }
116
+ });
117
+
118
+ // Process numeric settings
119
+ numericSettings.forEach(function(setting) {
120
+ var numericValue = parseIntSafe(forwarderSettings[setting.key]);
121
+ if (numericValue !== undefined) {
122
+ initOptions[setting.mappedKey] = numericValue;
123
+ }
124
+ });
125
+
126
+ // Process string settings
127
+ stringSettings.forEach(function(setting) {
128
+ if (forwarderSettings[setting.key]) {
129
+ initOptions[setting.mappedKey] =
130
+ forwarderSettings[setting.key];
131
+ }
132
+ });
133
+
134
+ mixpanel.init(settings.token, initOptions, 'mparticle');
74
135
 
75
136
  isInitialized = true;
76
137
 
@@ -195,7 +256,7 @@ var constructor = function () {
195
256
  // When mParticle identifies a user, because the user might
196
257
  // actually be anonymous, we only want to send an
197
258
  // identify request to Mixpanel if the user is
198
- // actually known. If a user has any user identities, they are
259
+ // actually known. If a user has any user identities, they are
199
260
  // considered to be "known" users.
200
261
  var userIdentities = getUserIdentities(user);
201
262
 
@@ -396,6 +457,11 @@ function isObject(val) {
396
457
  );
397
458
  }
398
459
 
460
+ function parseIntSafe(value) {
461
+ var n = parseInt(value, 10);
462
+ return isNaN(n) ? undefined : n;
463
+ }
464
+
399
465
  if (typeof window !== 'undefined') {
400
466
  if (window && window.mParticle && window.mParticle.addForwarder) {
401
467
  window.mParticle.addForwarder({
package/package.json CHANGED
@@ -1,14 +1,23 @@
1
1
  {
2
2
  "name": "@mparticle/web-mixpanel-kit",
3
- "version": "2.1.2",
3
+ "version": "3.2.0",
4
4
  "author": "mParticle Developers <developers@mparticle.com> (https://www.mparticle.com)",
5
5
  "description": "mParticle integration sdk for Mixpanel",
6
6
  "browser": "dist/MixpanelEventForwarder.common.js",
7
7
  "files": [
8
8
  "dist/MixpanelEventForwarder.common.js"
9
9
  ],
10
+ "publishConfig": {
11
+ "access": "public",
12
+ "provenance": true,
13
+ "registry": "https://registry.npmjs.org"
14
+ },
10
15
  "main": "dist/MixpanelEventForwarder.common.js",
11
- "repository": "https://github.com/mparticle-integrations/mparticle-javascript-integration-mixpanel",
16
+ "repository": {
17
+ "type": "git",
18
+ "url": "https://github.com/mParticle/mparticle-web-sdk",
19
+ "directory": "kits/mixpanel/mixpanel-2"
20
+ },
12
21
  "scripts": {
13
22
  "build": "rollup --config rollup.config.js",
14
23
  "build:test": "rollup --config rollup.test.config.js",
@@ -17,10 +26,12 @@
17
26
  "test:debug": "npm run build && npm run build:test && DEBUG=true karma start test/karma.config.js"
18
27
  },
19
28
  "devDependencies": {
20
- "@mparticle/web-sdk": "^2.23.7",
21
- "@semantic-release/changelog": "^5.0.1",
22
- "@semantic-release/exec": "^5.0.0",
23
- "@semantic-release/git": "^9.0.0",
29
+ "@mparticle/web-sdk": "^3.0.0",
30
+ "@semantic-release/changelog": "^6.0.3",
31
+ "@semantic-release/exec": "^6.0.3",
32
+ "@semantic-release/git": "^10.0.1",
33
+ "@semantic-release/npm": "^13.1.2",
34
+ "semantic-release": "^24.2.0",
24
35
  "chai": "^4.2.0",
25
36
  "eslint-config-prettier": "9.0.0",
26
37
  "eslint-plugin-prettier": "5.0.1",
@@ -38,5 +49,6 @@
38
49
  "should": "^7.1.0",
39
50
  "watchify": "^3.11.1"
40
51
  },
41
- "license": "Apache-2.0"
52
+ "license": "Apache-2.0",
53
+ "homepage": "https://github.com/mParticle/mparticle-web-sdk/tree/main/kits/mixpanel/mixpanel-2#readme"
42
54
  }