@useblu/blu-lytics 1.0.0 → 1.0.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/lib/dispatchers/dispatchers.spec.js +3 -3
- package/lib/dispatchers/index.js +3 -3
- package/lib/initializers/index.js +1 -1
- package/lib/initializers/initializers.spec.js +1 -1
- package/lib/providers/setups/clarity/clarity.js +1 -1
- package/lib/providers/setups/clarity/clarity.spec.d.ts +2 -0
- package/lib/providers/setups/clarity/clarity.spec.d.ts.map +1 -0
- package/lib/providers/setups/clarity/clarity.spec.js +26 -0
- package/package.json +1 -1
|
@@ -21,16 +21,16 @@ describe('Event dispatching functions', function () {
|
|
|
21
21
|
it('should be dispatch sendScreenEvent', function () {
|
|
22
22
|
var consoleLogSpy = jest.spyOn(console, 'log');
|
|
23
23
|
sendScreenEvent('TestScreen');
|
|
24
|
-
expect(consoleLogSpy).toHaveBeenCalledWith('[
|
|
24
|
+
expect(consoleLogSpy).toHaveBeenCalledWith('[blu-lytics]: Screen event: TestScreen');
|
|
25
25
|
});
|
|
26
26
|
it('should be dispatch sendCustomEvent', function () {
|
|
27
27
|
var consoleLogSpy = jest.spyOn(console, 'log');
|
|
28
28
|
sendCustomEvent('TestEvent', { prop1: 'value1' });
|
|
29
|
-
expect(consoleLogSpy).toHaveBeenCalledWith('[
|
|
29
|
+
expect(consoleLogSpy).toHaveBeenCalledWith('[blu-lytics]: Custom event: TestEvent - {"prop1":"value1"}');
|
|
30
30
|
});
|
|
31
31
|
it('should be dispatch sendUserIdentification', function () {
|
|
32
32
|
var consoleLogSpy = jest.spyOn(console, 'log');
|
|
33
33
|
sendUserIdentification('123', { name: 'Name' });
|
|
34
|
-
expect(consoleLogSpy).toHaveBeenCalledWith('[
|
|
34
|
+
expect(consoleLogSpy).toHaveBeenCalledWith('[blu-lytics]: User identification: 123 - {"name":"Name"}');
|
|
35
35
|
});
|
|
36
36
|
});
|
package/lib/dispatchers/index.js
CHANGED
|
@@ -31,7 +31,7 @@ export var dispatchEventToAllProviders = function (eventData) {
|
|
|
31
31
|
};
|
|
32
32
|
var sendScreenEvent = function (screen) {
|
|
33
33
|
if (userSelectedEnvironment === 'development') {
|
|
34
|
-
console.log("[
|
|
34
|
+
console.log("[blu-lytics]: Screen event: ".concat(screen));
|
|
35
35
|
}
|
|
36
36
|
else {
|
|
37
37
|
dispatchEventToAllProviders({ screen: screen });
|
|
@@ -39,7 +39,7 @@ var sendScreenEvent = function (screen) {
|
|
|
39
39
|
};
|
|
40
40
|
var sendCustomEvent = function (event, properties) {
|
|
41
41
|
if (userSelectedEnvironment === 'development') {
|
|
42
|
-
console.log("[
|
|
42
|
+
console.log("[blu-lytics]: Custom event: ".concat(event, " - ").concat(JSON.stringify(properties)));
|
|
43
43
|
}
|
|
44
44
|
else {
|
|
45
45
|
dispatchEventToAllProviders({ event: event, properties: properties });
|
|
@@ -47,7 +47,7 @@ var sendCustomEvent = function (event, properties) {
|
|
|
47
47
|
};
|
|
48
48
|
var sendUserIdentification = function (id, userProperties) {
|
|
49
49
|
if (userSelectedEnvironment === 'development') {
|
|
50
|
-
console.log("[
|
|
50
|
+
console.log("[blu-lytics]: User identification: ".concat(id, " - ").concat(JSON.stringify(userProperties)));
|
|
51
51
|
}
|
|
52
52
|
else {
|
|
53
53
|
dispatchEventToAllProviders({ id: id, userProperties: userProperties });
|
|
@@ -124,7 +124,7 @@ export var initializeProviders = function (paramsArray, options) {
|
|
|
124
124
|
initialize(paramsArray);
|
|
125
125
|
}
|
|
126
126
|
if (initializedProviders.length > 0) {
|
|
127
|
-
console.log('[
|
|
127
|
+
console.log('[blu-lytics] Initialized providers:', initializedProviders);
|
|
128
128
|
}
|
|
129
129
|
};
|
|
130
130
|
export { userSelectedEnvironment };
|
|
@@ -15,7 +15,7 @@ describe('Initializers', function () {
|
|
|
15
15
|
var logSpy = jest.spyOn(console, 'log').mockImplementation(function () { });
|
|
16
16
|
initializeProviders(paramsArray, { environment: 'production' });
|
|
17
17
|
expect(userSelectedEnvironment).toBe('production');
|
|
18
|
-
expect(logSpy).toHaveBeenCalledWith('[
|
|
18
|
+
expect(logSpy).toHaveBeenCalledWith('[blu-lytics] Initialized providers:', expect.arrayContaining(['Mixpanel', 'Sentry']));
|
|
19
19
|
logSpy.mockRestore();
|
|
20
20
|
});
|
|
21
21
|
it('should throw an error when initializing Sentry with an invalid tracesSampleRate', function () {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { clarity } from 'react-microsoft-clarity';
|
|
2
2
|
var dispatchUserIdentification = function (id, userProperties) {
|
|
3
|
-
clarity.identify(id, { userProperties:
|
|
3
|
+
clarity.identify(id, { userProperties: 'id' });
|
|
4
4
|
};
|
|
5
5
|
var dispatchCustomEvent = function (event, properties) {
|
|
6
6
|
clarity.setTag(event, 'customEvent');
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"clarity.spec.d.ts","sourceRoot":"","sources":["../../../../src/providers/setups/clarity/clarity.spec.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { clarity } from 'react-microsoft-clarity';
|
|
2
|
+
import ClarityProvider from './clarity';
|
|
3
|
+
jest.mock('react-microsoft-clarity', function () { return ({
|
|
4
|
+
clarity: {
|
|
5
|
+
identify: jest.fn(),
|
|
6
|
+
setTag: jest.fn()
|
|
7
|
+
}
|
|
8
|
+
}); });
|
|
9
|
+
describe('ClarityProvider', function () {
|
|
10
|
+
it('dispatchUserIdentification should call clarity.identify with correct arguments', function () {
|
|
11
|
+
var userId = 'user123';
|
|
12
|
+
ClarityProvider.userIdentification(userId, { userProperties: 'id' });
|
|
13
|
+
expect(clarity.identify).toHaveBeenCalledWith(userId, { userProperties: 'id' });
|
|
14
|
+
});
|
|
15
|
+
it('dispatchCustomEvent should call clarity.setTag with correct arguments', function () {
|
|
16
|
+
var eventName = 'clickEvent';
|
|
17
|
+
var properties = { key: 'value' };
|
|
18
|
+
ClarityProvider.customEvent(eventName, properties);
|
|
19
|
+
expect(clarity.setTag).toHaveBeenCalledWith(eventName, 'customEvent');
|
|
20
|
+
});
|
|
21
|
+
it('dispatchScreenEvent should call clarity.setTag with correct arguments', function () {
|
|
22
|
+
var screenName = 'HomeScreen';
|
|
23
|
+
ClarityProvider.screenEvent(screenName);
|
|
24
|
+
expect(clarity.setTag).toHaveBeenCalledWith(screenName, 'screen');
|
|
25
|
+
});
|
|
26
|
+
});
|