@pushwoosh/kit-helpers 4.8.8 → 4.8.9
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/analytics/identifyMixpanel.js +5 -2
- package/analytics/utils.d.ts +1 -0
- package/analytics/utils.js +14 -0
- package/package.json +3 -1
|
@@ -1,6 +1,9 @@
|
|
|
1
|
-
import { isProductionMode, isUserActionsTrackingOff } from './utils';
|
|
1
|
+
import { isProductionMode, isUserActionsTrackingOff, getMixpanelDistinctId } from './utils';
|
|
2
2
|
export const identifyMixpanel = properties => {
|
|
3
|
-
|
|
3
|
+
const distinctId = getMixpanelDistinctId();
|
|
4
|
+
const wasPushwooshUser = distinctId?.endsWith('@pushwoosh.com');
|
|
5
|
+
const isCurrentPushwooshUser = properties.$email.endsWith('@pushwoosh.com');
|
|
6
|
+
if (!isProductionMode() || isUserActionsTrackingOff() || wasPushwooshUser || isCurrentPushwooshUser) {
|
|
4
7
|
return;
|
|
5
8
|
}
|
|
6
9
|
if (!window.mixpanel) {
|
package/analytics/utils.d.ts
CHANGED
package/analytics/utils.js
CHANGED
|
@@ -1,7 +1,21 @@
|
|
|
1
|
+
import Cookies from 'js-cookie';
|
|
1
2
|
export const isProductionMode = () => process.env.NODE_ENV === 'production';
|
|
2
3
|
export const isUserActionsTrackingOff = () => {
|
|
3
4
|
const turnOffTracking = localStorage.getItem('pw_off_user_actions_tracking');
|
|
4
5
|
// Any value other than these specific "falsey" ones means tracking is off.
|
|
5
6
|
const trackingOnValues = [null, '', '0', 'false'];
|
|
6
7
|
return !trackingOnValues.includes(turnOffTracking);
|
|
8
|
+
};
|
|
9
|
+
const projectToken = '4169a4e38679ed49785b430a1049238e';
|
|
10
|
+
export const getMixpanelDistinctId = () => {
|
|
11
|
+
const mixpanelCookie = Cookies.get(`mp_${projectToken}_mixpanel`);
|
|
12
|
+
if (mixpanelCookie) {
|
|
13
|
+
try {
|
|
14
|
+
const mixpanelData = JSON.parse(mixpanelCookie);
|
|
15
|
+
return mixpanelData.distinct_id;
|
|
16
|
+
} catch (error) {
|
|
17
|
+
console.error('Error parsing Mixpanel cookie:', error);
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
return null;
|
|
7
21
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@pushwoosh/kit-helpers",
|
|
3
|
-
"version": "4.8.
|
|
3
|
+
"version": "4.8.9",
|
|
4
4
|
"description": "React component for build Pushwoosh products",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"module": "index.js",
|
|
@@ -16,12 +16,14 @@
|
|
|
16
16
|
},
|
|
17
17
|
"pre-commit": "check",
|
|
18
18
|
"dependencies": {
|
|
19
|
+
"js-cookie": "^3.0.5",
|
|
19
20
|
"mixpanel-browser": "^2.71.0",
|
|
20
21
|
"react-transition-group": "^4.4.5"
|
|
21
22
|
},
|
|
22
23
|
"devDependencies": {
|
|
23
24
|
"@pushwoosh/frontend-builder-engine": "^0.1.5",
|
|
24
25
|
"@pushwoosh/kit-constants": "^1.6.0",
|
|
26
|
+
"@types/js-cookie": "^3.0.6",
|
|
25
27
|
"@types/react": "^16.14.20",
|
|
26
28
|
"@types/react-dom": "^16.9.14",
|
|
27
29
|
"@types/react-transition-group": "^4.4.10",
|