@pushwoosh/kit-helpers 4.8.9 → 4.9.1
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/trackEvent.d.ts +2 -0
- package/analytics/trackEvent.js +4 -0
- package/analytics/utils.d.ts +8 -15
- package/analytics/utils.js +0 -14
- package/index.d.ts +1 -2
- package/index.js +1 -2
- package/package.json +1 -4
- package/analytics/identifyMixpanel.d.ts +0 -2
- package/analytics/identifyMixpanel.js +0 -17
- package/analytics/trackMixpanel.d.ts +0 -2
- package/analytics/trackMixpanel.js +0 -13
package/analytics/utils.d.ts
CHANGED
|
@@ -1,32 +1,25 @@
|
|
|
1
|
-
import { type Mixpanel } from 'mixpanel-browser';
|
|
2
1
|
interface IOpenReplay {
|
|
3
2
|
setUserID(id: string): void;
|
|
4
3
|
setMetadata(key: string, value: string): void;
|
|
5
4
|
}
|
|
6
|
-
export
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
}
|
|
10
|
-
export
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
AccountID?: string;
|
|
14
|
-
Restriction?: string;
|
|
15
|
-
};
|
|
5
|
+
export interface PWTrackingEvent {
|
|
6
|
+
name: string;
|
|
7
|
+
properties?: Record<string, unknown>;
|
|
8
|
+
}
|
|
9
|
+
export interface PWTrackingEventsStoreAPI {
|
|
10
|
+
push(event: PWTrackingEvent): void;
|
|
11
|
+
}
|
|
16
12
|
export type OpenReplayProperties = {
|
|
17
13
|
email: string;
|
|
18
14
|
accountID?: string;
|
|
19
15
|
};
|
|
20
16
|
declare global {
|
|
21
17
|
interface Window {
|
|
22
|
-
mixpanel?: Mixpanel;
|
|
23
18
|
OpenReplay?: IOpenReplay;
|
|
24
|
-
pwMixpanelIdentifyStore?: MixpanelProperties[];
|
|
25
19
|
pwOpenReplayIdentifyStore?: OpenReplayProperties[];
|
|
26
|
-
|
|
20
|
+
pwTrackingEventsStore?: PWTrackingEventsStoreAPI | Array<PWTrackingEvent>;
|
|
27
21
|
}
|
|
28
22
|
}
|
|
29
23
|
export declare const isProductionMode: () => boolean;
|
|
30
24
|
export declare const isUserActionsTrackingOff: () => boolean;
|
|
31
|
-
export declare const getMixpanelDistinctId: () => string | null;
|
|
32
25
|
export {};
|
package/analytics/utils.js
CHANGED
|
@@ -1,21 +1,7 @@
|
|
|
1
|
-
import Cookies from 'js-cookie';
|
|
2
1
|
export const isProductionMode = () => process.env.NODE_ENV === 'production';
|
|
3
2
|
export const isUserActionsTrackingOff = () => {
|
|
4
3
|
const turnOffTracking = localStorage.getItem('pw_off_user_actions_tracking');
|
|
5
4
|
// Any value other than these specific "falsey" ones means tracking is off.
|
|
6
5
|
const trackingOnValues = [null, '', '0', 'false'];
|
|
7
6
|
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;
|
|
21
7
|
};
|
package/index.d.ts
CHANGED
|
@@ -1,9 +1,8 @@
|
|
|
1
1
|
export * from './grid';
|
|
2
2
|
export * from './expand';
|
|
3
3
|
export * from './hooks/useClickAway';
|
|
4
|
-
export { trackMixpanelEvent } from './analytics/trackMixpanel';
|
|
5
|
-
export { identifyMixpanel } from './analytics/identifyMixpanel';
|
|
6
4
|
export { identifyOpenReplaySession } from './analytics/identifyOpenReplay';
|
|
5
|
+
export { trackEvent } from './analytics/trackEvent';
|
|
7
6
|
export { formatNumber } from './formatNumber';
|
|
8
7
|
export { default as usePersistentFunction } from './hooks/usePersistentFunction';
|
|
9
8
|
export { default as useEffectOnce } from './hooks/useEffectOnce';
|
package/index.js
CHANGED
|
@@ -1,9 +1,8 @@
|
|
|
1
1
|
export * from './grid';
|
|
2
2
|
export * from './expand';
|
|
3
3
|
export * from './hooks/useClickAway';
|
|
4
|
-
export { trackMixpanelEvent } from './analytics/trackMixpanel';
|
|
5
|
-
export { identifyMixpanel } from './analytics/identifyMixpanel';
|
|
6
4
|
export { identifyOpenReplaySession } from './analytics/identifyOpenReplay';
|
|
5
|
+
export { trackEvent } from './analytics/trackEvent';
|
|
7
6
|
export { formatNumber } from './formatNumber';
|
|
8
7
|
export { default as usePersistentFunction } from './hooks/usePersistentFunction';
|
|
9
8
|
export { default as useEffectOnce } from './hooks/useEffectOnce';
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@pushwoosh/kit-helpers",
|
|
3
|
-
"version": "4.
|
|
3
|
+
"version": "4.9.1",
|
|
4
4
|
"description": "React component for build Pushwoosh products",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"module": "index.js",
|
|
@@ -16,14 +16,11 @@
|
|
|
16
16
|
},
|
|
17
17
|
"pre-commit": "check",
|
|
18
18
|
"dependencies": {
|
|
19
|
-
"js-cookie": "^3.0.5",
|
|
20
|
-
"mixpanel-browser": "^2.71.0",
|
|
21
19
|
"react-transition-group": "^4.4.5"
|
|
22
20
|
},
|
|
23
21
|
"devDependencies": {
|
|
24
22
|
"@pushwoosh/frontend-builder-engine": "^0.1.5",
|
|
25
23
|
"@pushwoosh/kit-constants": "^1.6.0",
|
|
26
|
-
"@types/js-cookie": "^3.0.6",
|
|
27
24
|
"@types/react": "^16.14.20",
|
|
28
25
|
"@types/react-dom": "^16.9.14",
|
|
29
26
|
"@types/react-transition-group": "^4.4.10",
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
import { isProductionMode, isUserActionsTrackingOff, getMixpanelDistinctId } from './utils';
|
|
2
|
-
export const identifyMixpanel = properties => {
|
|
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) {
|
|
7
|
-
return;
|
|
8
|
-
}
|
|
9
|
-
if (!window.mixpanel) {
|
|
10
|
-
const store = window.pwMixpanelIdentifyStore || [];
|
|
11
|
-
store.push(properties);
|
|
12
|
-
window.pwMixpanelIdentifyStore = store;
|
|
13
|
-
} else {
|
|
14
|
-
window.mixpanel?.identify(properties?.$email);
|
|
15
|
-
window.mixpanel?.people?.set(properties);
|
|
16
|
-
}
|
|
17
|
-
};
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
import { isProductionMode, isUserActionsTrackingOff } from './utils';
|
|
2
|
-
export function trackMixpanelEvent(event) {
|
|
3
|
-
if (!isProductionMode() || isUserActionsTrackingOff()) {
|
|
4
|
-
return;
|
|
5
|
-
}
|
|
6
|
-
if (!window.mixpanel) {
|
|
7
|
-
const store = window.pwMixpanelTrackingEventsStore || [];
|
|
8
|
-
store.push(event);
|
|
9
|
-
window.pwMixpanelTrackingEventsStore = store;
|
|
10
|
-
} else {
|
|
11
|
-
window.mixpanel?.track(event.name, event.properties);
|
|
12
|
-
}
|
|
13
|
-
}
|