@useblu/blu-lytics 1.0.14 → 1.0.15
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/lib/dispatchers/index.d.ts +2 -1
- package/lib/dispatchers/index.d.ts.map +1 -1
- package/lib/dispatchers/index.js +60 -18
- package/lib/index.d.ts +1 -1
- package/lib/index.d.ts.map +1 -1
- package/lib/index.js +1 -1
- package/package.json +2 -2
|
@@ -7,7 +7,8 @@ import { EventData, PropertiesType, UserPropertiesType } from './dispatchers.typ
|
|
|
7
7
|
*/
|
|
8
8
|
export declare const dispatchEventToAllProviders: (eventData: EventData) => void;
|
|
9
9
|
declare const sendScreenEvent: (screen: string) => void;
|
|
10
|
+
declare const setDefaultProperties: (properties: PropertiesType) => void;
|
|
10
11
|
declare const sendCustomEvent: (event: string, properties: PropertiesType) => void;
|
|
11
12
|
declare const sendUserIdentification: (id: string, userProperties: UserPropertiesType) => void;
|
|
12
|
-
export { sendCustomEvent, sendScreenEvent, sendUserIdentification };
|
|
13
|
+
export { sendCustomEvent, sendScreenEvent, sendUserIdentification, setDefaultProperties, };
|
|
13
14
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/dispatchers/index.ts"],"names":[],"mappings":"AAEA,OAAO,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/dispatchers/index.ts"],"names":[],"mappings":"AAEA,OAAO,EACL,SAAS,EACT,cAAc,EACd,kBAAkB,EACnB,MAAM,qBAAqB,CAAC;AAG7B;;;;;GAKG;AACH,eAAO,MAAM,2BAA2B,cAAe,SAAS,KAAG,IAkClE,CAAC;AAIF,QAAA,MAAM,eAAe,WAAY,MAAM,KAAG,IAMzC,CAAC;AAeF,QAAA,MAAM,oBAAoB,eAAgB,cAAc,KAAG,IAG1D,CAAC;AAEF,QAAA,MAAM,eAAe,UAAW,MAAM,cAAc,cAAc,KAAG,IAyBpE,CAAC;AAEF,QAAA,MAAM,sBAAsB,OACtB,MAAM,kBACM,kBAAkB,KACjC,IAUF,CAAC;AAEF,OAAO,EACL,eAAe,EACf,eAAe,EACf,sBAAsB,EACtB,oBAAoB,GACrB,CAAC"}
|
package/lib/dispatchers/index.js
CHANGED
|
@@ -1,3 +1,14 @@
|
|
|
1
|
+
var __assign = (this && this.__assign) || function () {
|
|
2
|
+
__assign = Object.assign || function(t) {
|
|
3
|
+
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
4
|
+
s = arguments[i];
|
|
5
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
6
|
+
t[p] = s[p];
|
|
7
|
+
}
|
|
8
|
+
return t;
|
|
9
|
+
};
|
|
10
|
+
return __assign.apply(this, arguments);
|
|
11
|
+
};
|
|
1
12
|
/* eslint-disable @typescript-eslint/explicit-module-boundary-types */
|
|
2
13
|
import { providersList } from '../providers';
|
|
3
14
|
import { checkIfMixPanelIsInitialized } from '../utils';
|
|
@@ -10,51 +21,82 @@ import { checkIfMixPanelIsInitialized } from '../utils';
|
|
|
10
21
|
export var dispatchEventToAllProviders = function (eventData) {
|
|
11
22
|
var localStorageProvidersList = JSON.parse(localStorage === null || localStorage === void 0 ? void 0 : localStorage.getItem('_bl_providers'));
|
|
12
23
|
var providersFiltered = localStorageProvidersList
|
|
13
|
-
? providersList.filter(function (item) {
|
|
24
|
+
? providersList.filter(function (item) {
|
|
25
|
+
return localStorageProvidersList.includes(item.name);
|
|
26
|
+
})
|
|
14
27
|
: providersList;
|
|
15
28
|
if (providersFiltered.length > 0) {
|
|
16
29
|
providersFiltered.forEach(function (provider) {
|
|
17
30
|
checkIfMixPanelIsInitialized(provider.name);
|
|
18
31
|
var actions = {
|
|
19
|
-
screenEvent: function () {
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
32
|
+
screenEvent: function () {
|
|
33
|
+
return provider.screenEvent &&
|
|
34
|
+
eventData.screen &&
|
|
35
|
+
provider.screenEvent(eventData.screen);
|
|
36
|
+
},
|
|
37
|
+
customEvent: function () {
|
|
38
|
+
return provider.customEvent &&
|
|
39
|
+
eventData.event &&
|
|
40
|
+
eventData.properties &&
|
|
41
|
+
provider.customEvent(eventData.event, eventData.properties);
|
|
42
|
+
},
|
|
43
|
+
userIdentification: function () {
|
|
44
|
+
return provider.userIdentification &&
|
|
45
|
+
eventData.id &&
|
|
46
|
+
eventData.userProperties &&
|
|
47
|
+
provider.userIdentification(eventData.id, eventData.userProperties);
|
|
48
|
+
}
|
|
30
49
|
};
|
|
31
50
|
Object.values(actions).forEach(function (action) { return action(); });
|
|
32
51
|
});
|
|
33
52
|
}
|
|
34
53
|
};
|
|
35
54
|
var currentEnvironment = localStorage.getItem('_bl_env') || 'development';
|
|
55
|
+
var isDevelopment = currentEnvironment === 'development';
|
|
36
56
|
var sendScreenEvent = function (screen) {
|
|
37
|
-
if (
|
|
57
|
+
if (isDevelopment) {
|
|
38
58
|
console.log("[blu-lytics]: Screen event: ".concat(screen));
|
|
39
59
|
}
|
|
40
60
|
else {
|
|
41
61
|
dispatchEventToAllProviders({ screen: screen });
|
|
42
62
|
}
|
|
43
63
|
};
|
|
64
|
+
var saveDefaultPropertiesToLocalStorage = function (properties) {
|
|
65
|
+
localStorage.setItem('_bl_props', JSON.stringify(properties));
|
|
66
|
+
};
|
|
67
|
+
var loadDefaultPropertiesFromLocalStorage = function () {
|
|
68
|
+
var storedProperties = localStorage.getItem('_bl_props');
|
|
69
|
+
return storedProperties ? JSON.parse(storedProperties) : {};
|
|
70
|
+
};
|
|
71
|
+
var defaultProperties = loadDefaultPropertiesFromLocalStorage();
|
|
72
|
+
var setDefaultProperties = function (properties) {
|
|
73
|
+
defaultProperties = __assign({}, properties);
|
|
74
|
+
saveDefaultPropertiesToLocalStorage(defaultProperties);
|
|
75
|
+
};
|
|
44
76
|
var sendCustomEvent = function (event, properties) {
|
|
45
|
-
|
|
46
|
-
|
|
77
|
+
var rawStoredProperties = localStorage.getItem('_bl_props');
|
|
78
|
+
if (rawStoredProperties) {
|
|
79
|
+
try {
|
|
80
|
+
defaultProperties = JSON.parse(rawStoredProperties);
|
|
81
|
+
}
|
|
82
|
+
catch (error) {
|
|
83
|
+
console.error('[blu-lytics] Failed to parse stored properties', error);
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
var mergedProperties = __assign(__assign({}, defaultProperties), properties);
|
|
87
|
+
if (isDevelopment) {
|
|
88
|
+
console.log("[blu-lytics]: Custom event: ".concat(event, " - ").concat(JSON.stringify(mergedProperties)));
|
|
47
89
|
}
|
|
48
90
|
else {
|
|
49
|
-
dispatchEventToAllProviders({ event: event, properties:
|
|
91
|
+
dispatchEventToAllProviders({ event: event, properties: mergedProperties });
|
|
50
92
|
}
|
|
51
93
|
};
|
|
52
94
|
var sendUserIdentification = function (id, userProperties) {
|
|
53
|
-
if (
|
|
95
|
+
if (isDevelopment) {
|
|
54
96
|
console.log("[blu-lytics]: User identification: ".concat(id, " - ").concat(JSON.stringify(userProperties)));
|
|
55
97
|
}
|
|
56
98
|
else {
|
|
57
99
|
dispatchEventToAllProviders({ id: id, userProperties: userProperties });
|
|
58
100
|
}
|
|
59
101
|
};
|
|
60
|
-
export { sendCustomEvent, sendScreenEvent, sendUserIdentification };
|
|
102
|
+
export { sendCustomEvent, sendScreenEvent, sendUserIdentification, setDefaultProperties, };
|
package/lib/index.d.ts
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
export { initializeProviders } from './initializers';
|
|
2
|
-
export { sendCustomEvent, sendScreenEvent, sendUserIdentification } from './dispatchers';
|
|
2
|
+
export { sendCustomEvent, sendScreenEvent, sendUserIdentification, setDefaultProperties, } from './dispatchers';
|
|
3
3
|
//# sourceMappingURL=index.d.ts.map
|
package/lib/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,mBAAmB,EAAE,MAAM,gBAAgB,CAAC;AACrD,OAAO,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,mBAAmB,EAAE,MAAM,gBAAgB,CAAC;AACrD,OAAO,EACL,eAAe,EAAE,eAAe,EAAE,sBAAsB,EAAE,oBAAoB,GAC/E,MAAM,eAAe,CAAC"}
|
package/lib/index.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
export { initializeProviders } from './initializers';
|
|
2
|
-
export { sendCustomEvent, sendScreenEvent, sendUserIdentification } from './dispatchers';
|
|
2
|
+
export { sendCustomEvent, sendScreenEvent, sendUserIdentification, setDefaultProperties, } from './dispatchers';
|