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