rozmova-analytics 1.0.4 → 1.0.5

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.
@@ -1,6 +1,11 @@
1
- import { AnalyticsCommonParams } from "./types";
1
+ import { AnalyticsCommonParams, EventParams } from "./types";
2
2
  export declare const generateUserId: () => string;
3
3
  export declare const getUserId: () => string;
4
4
  export declare const getCommonParams: () => AnalyticsCommonParams;
5
- export declare const init: (additionalParams?: Record<string, string>) => void;
6
- export declare const trackEvent: (eventName: string, properties?: {}) => void;
5
+ export declare const init: (additionalParams?: EventParams) => void;
6
+ export declare const trackEvent: (eventName: string, properties?: EventParams) => void;
7
+ export declare const setUser: (userId: string, userParams: {
8
+ email: string;
9
+ name: string;
10
+ }) => void;
11
+ export declare const resetUser: () => void;
package/dist/analytics.js CHANGED
@@ -3,7 +3,7 @@
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
- exports.trackEvent = exports.init = exports.getUserId = exports.getCommonParams = exports.generateUserId = void 0;
6
+ exports.trackEvent = exports.setUser = exports.resetUser = exports.init = exports.getUserId = exports.getCommonParams = exports.generateUserId = void 0;
7
7
  var _jsCookie = _interopRequireDefault(require("js-cookie"));
8
8
  var _mixpanelBrowser = _interopRequireDefault(require("mixpanel-browser"));
9
9
  var _nanoid = require("nanoid");
@@ -104,4 +104,21 @@ var trackEvent = exports.trackEvent = function trackEvent(eventName) {
104
104
  console.log(e);
105
105
  }
106
106
  });
107
+ };
108
+ var setUser = exports.setUser = function setUser(userId, userParams) {
109
+ _mixpanelBrowser["default"].identify(userId);
110
+ _mixpanelBrowser["default"].people.set({
111
+ $email: userParams.email,
112
+ name: userParams.name
113
+ });
114
+ gtag("config", _constants.GOOGLE_ANALYTICS_ID, {
115
+ user_properties: getCommonParams(),
116
+ user_id: userId,
117
+ server_container_url: _constants.GA_SERVER_CONTAINER_URL
118
+ });
119
+ };
120
+ var resetUser = exports.resetUser = function resetUser() {
121
+ _mixpanelBrowser["default"].reset();
122
+ generateUserId();
123
+ init();
107
124
  };
package/dist/index.d.ts CHANGED
@@ -1,7 +1,12 @@
1
1
  export declare const Analytics: {
2
2
  getUserId: () => string;
3
3
  generateUserId: () => string;
4
- init: (additionalParams?: Record<string, string>) => void;
4
+ init: (additionalParams?: import("./types").EventParams) => void;
5
5
  getCommonParams: () => import("./types").AnalyticsCommonParams;
6
- trackEvent: (eventName: string, properties?: {}) => void;
6
+ trackEvent: (eventName: string, properties?: import("./types").EventParams) => void;
7
+ setUser: (userId: string, userParams: {
8
+ email: string;
9
+ name: string;
10
+ }) => void;
11
+ resetUser: () => void;
7
12
  };
package/dist/index.js CHANGED
@@ -10,5 +10,7 @@ var Analytics = exports.Analytics = {
10
10
  generateUserId: _analytics.generateUserId,
11
11
  init: _analytics.init,
12
12
  getCommonParams: _analytics.getCommonParams,
13
- trackEvent: _analytics.trackEvent
13
+ trackEvent: _analytics.trackEvent,
14
+ setUser: _analytics.setUser,
15
+ resetUser: _analytics.resetUser
14
16
  };
package/dist/types.d.ts CHANGED
@@ -26,3 +26,4 @@ export type AnalyticsCommonParams = {
26
26
  system: string;
27
27
  rid: string;
28
28
  };
29
+ export type EventParams = Record<string, string | boolean | number>;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "rozmova-analytics",
3
- "version": "1.0.4",
3
+ "version": "1.0.5",
4
4
  "description": "A collection of JavaScript functions for Rozmova analytics",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",