@pushwoosh/kit-helpers 4.8.5 → 4.8.7
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/{ai-documentation.mdx → ai-documentation.md} +1 -1
- package/analytics/identifyMixpanel.d.ts +1 -0
- package/analytics/identifyMixpanel.js +16 -0
- package/analytics/identifyOpenReplay.d.ts +1 -0
- package/analytics/identifyOpenReplay.js +13 -0
- package/analytics/trackMixpanel.d.ts +2 -0
- package/analytics/trackMixpanel.js +13 -0
- package/analytics/utils.d.ts +20 -0
- package/analytics/utils.js +7 -0
- package/index.d.ts +3 -0
- package/index.js +3 -0
- package/package.json +3 -2
|
@@ -600,7 +600,7 @@ const cleanup = elementAddListeners(
|
|
|
600
600
|
- **Path:** `~/src/hooks/useClickAway`
|
|
601
601
|
- **Description:** Subscribes to clicks outside an element
|
|
602
602
|
- **Signature:**
|
|
603
|
-
```
|
|
603
|
+
```typescript
|
|
604
604
|
subscribeClickAway<T extends HTMLElement>(
|
|
605
605
|
element: T,
|
|
606
606
|
callback: (event: MouseEvent | TouchEvent) => void
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const identifyMixpanel: (email: string) => void;
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { isProductionMode, isUserActionsTrackingOff } from './utils';
|
|
2
|
+
export const identifyMixpanel = email => {
|
|
3
|
+
if (!isProductionMode() || isUserActionsTrackingOff()) {
|
|
4
|
+
return;
|
|
5
|
+
}
|
|
6
|
+
if (!window.mixpanel) {
|
|
7
|
+
const store = window.pwMixpanelIdentifyStore || [];
|
|
8
|
+
store.push(email);
|
|
9
|
+
window.pwMixpanelIdentifyStore = store;
|
|
10
|
+
} else {
|
|
11
|
+
window.mixpanel?.identify(email);
|
|
12
|
+
window.mixpanel?.people?.set({
|
|
13
|
+
$email: email
|
|
14
|
+
});
|
|
15
|
+
}
|
|
16
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const identifyOpenReplaySession: (email: string) => void;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { isProductionMode, isUserActionsTrackingOff } from './utils';
|
|
2
|
+
export const identifyOpenReplaySession = email => {
|
|
3
|
+
if (!isProductionMode() || isUserActionsTrackingOff()) {
|
|
4
|
+
return;
|
|
5
|
+
}
|
|
6
|
+
if (!window.OpenReplay) {
|
|
7
|
+
const store = window.pwOpenReplayIdentifyStore || [];
|
|
8
|
+
store.push(email);
|
|
9
|
+
window.pwOpenReplayIdentifyStore = store;
|
|
10
|
+
} else {
|
|
11
|
+
window.OpenReplay?.setUserID(email);
|
|
12
|
+
}
|
|
13
|
+
};
|
|
@@ -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,20 @@
|
|
|
1
|
+
import { type Mixpanel } from 'mixpanel-browser';
|
|
2
|
+
interface IOpenReplay {
|
|
3
|
+
setUserID(id: string): void;
|
|
4
|
+
}
|
|
5
|
+
export type Event = {
|
|
6
|
+
readonly name: string;
|
|
7
|
+
readonly properties?: Record<string, unknown>;
|
|
8
|
+
};
|
|
9
|
+
declare global {
|
|
10
|
+
interface Window {
|
|
11
|
+
mixpanel?: Mixpanel;
|
|
12
|
+
OpenReplay?: IOpenReplay;
|
|
13
|
+
pwMixpanelIdentifyStore?: string[];
|
|
14
|
+
pwOpenReplayIdentifyStore?: string[];
|
|
15
|
+
pwMixpanelTrackingEventsStore?: Event[];
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
export declare const isProductionMode: () => boolean;
|
|
19
|
+
export declare const isUserActionsTrackingOff: () => boolean;
|
|
20
|
+
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.7",
|
|
4
4
|
"description": "React component for build Pushwoosh products",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"module": "index.js",
|
|
@@ -8,7 +8,7 @@
|
|
|
8
8
|
"sideEffects": false,
|
|
9
9
|
"scripts": {
|
|
10
10
|
"start": "npm run playground",
|
|
11
|
-
"build": "pushwoosh-engine lib:build && cp ai-documentation.
|
|
11
|
+
"build": "pushwoosh-engine lib:build && cp ai-documentation.md dist/ai-documentation.md",
|
|
12
12
|
"playground": "pushwoosh-engine lib:playground",
|
|
13
13
|
"check": "npm run check:lint && npm run check:types",
|
|
14
14
|
"check:lint": "echo \"Run check:lint\" && eslint .",
|
|
@@ -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": {
|