@useblu/blu-lytics 1.3.0 → 1.4.0
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 +55 -1
- package/lib/dispatchers/index.d.ts +1 -1
- package/lib/dispatchers/index.d.ts.map +1 -1
- package/lib/dispatchers/index.js +22 -9
- package/lib/providers/provider.types.d.ts +1 -1
- package/lib/providers/provider.types.d.ts.map +1 -1
- package/lib/providers/setups/clarity/clarity.d.ts.map +1 -1
- package/lib/providers/setups/clarity/clarity.js +1 -1
- package/lib/providers/setups/fullstory/fullstory.d.ts.map +1 -1
- package/lib/providers/setups/fullstory/fullstory.js +2 -2
- package/lib/providers/setups/fullstory/fullstory.spec.js +6 -0
- package/lib/providers/setups/mixpanel/mixpanel.d.ts.map +1 -1
- package/lib/providers/setups/mixpanel/mixpanel.js +18 -2
- package/lib/providers/setups/mixpanel/mixpanel.spec.js +22 -0
- package/lib/providers/setups/sentry/sentry.d.ts.map +1 -1
- package/lib/providers/setups/sentry/sentry.js +2 -7
- package/lib/providers/setups/sentry/sentry.spec.js +12 -0
- package/package.json +1 -1
|
@@ -1,10 +1,12 @@
|
|
|
1
1
|
import { sendCustomEvent, sendScreenEvent, sendUserIdentification, } from './index';
|
|
2
|
+
import { providersList } from '../providers';
|
|
2
3
|
jest.mock('../initializers', function () { return ({
|
|
3
4
|
userSelectedEnvironment: 'development'
|
|
4
5
|
}); });
|
|
5
6
|
jest.mock('../providers', function () { return ({
|
|
6
7
|
providersList: [
|
|
7
8
|
{
|
|
9
|
+
name: 'FakeProvider',
|
|
8
10
|
screenEvent: jest.fn(),
|
|
9
11
|
customEvent: jest.fn(),
|
|
10
12
|
userIdentification: jest.fn()
|
|
@@ -12,7 +14,8 @@ jest.mock('../providers', function () { return ({
|
|
|
12
14
|
]
|
|
13
15
|
}); });
|
|
14
16
|
jest.mock('../utils', function () { return ({
|
|
15
|
-
isValidProvidersList: jest.fn(function () { return true; })
|
|
17
|
+
isValidProvidersList: jest.fn(function () { return true; }),
|
|
18
|
+
checkIfMixPanelIsInitialized: jest.fn()
|
|
16
19
|
}); });
|
|
17
20
|
describe('Event dispatching functions', function () {
|
|
18
21
|
afterEach(function () {
|
|
@@ -22,12 +25,63 @@ describe('Event dispatching functions', function () {
|
|
|
22
25
|
var providers = ['Sentry', 'MixPanel'];
|
|
23
26
|
beforeEach(function () {
|
|
24
27
|
localStorage.setItem(localStorageKey, JSON.stringify([providers]));
|
|
28
|
+
localStorage.setItem('_bl_props', JSON.stringify({}));
|
|
25
29
|
});
|
|
26
30
|
it('should be dispatch sendScreenEvent', function () {
|
|
27
31
|
var consoleLogSpy = jest.spyOn(console, 'log');
|
|
28
32
|
sendScreenEvent('TestScreen');
|
|
29
33
|
expect(consoleLogSpy).toHaveBeenCalledWith('[blu-lytics]: Screen event: TestScreen');
|
|
30
34
|
});
|
|
35
|
+
it('should dispatch sendScreenEvent without properties keeping the legacy log format when _bl_props is empty', function () {
|
|
36
|
+
var consoleLogSpy = jest.spyOn(console, 'log');
|
|
37
|
+
sendScreenEvent('TestScreen');
|
|
38
|
+
expect(consoleLogSpy).toHaveBeenCalledWith('[blu-lytics]: Screen event: TestScreen');
|
|
39
|
+
expect(consoleLogSpy).not.toHaveBeenCalledWith(expect.stringContaining('TestScreen - '));
|
|
40
|
+
});
|
|
41
|
+
it('should include defaultProperties in log when _bl_props has content and no explicit properties are passed', function () {
|
|
42
|
+
localStorage.setItem('_bl_props', JSON.stringify({ client_uuid: 'abc123' }));
|
|
43
|
+
var consoleLogSpy = jest.spyOn(console, 'log');
|
|
44
|
+
sendScreenEvent('home_view');
|
|
45
|
+
expect(consoleLogSpy).toHaveBeenCalledWith('[blu-lytics]: Screen event: home_view - {"client_uuid":"abc123"}');
|
|
46
|
+
});
|
|
47
|
+
it('should dispatch sendScreenEvent merging defaultProperties with the provided properties', function () {
|
|
48
|
+
localStorage.setItem('_bl_props', JSON.stringify({ origin: 'home' }));
|
|
49
|
+
var consoleLogSpy = jest.spyOn(console, 'log');
|
|
50
|
+
sendScreenEvent('credit_list_view', { campaign_name: 'black_friday' });
|
|
51
|
+
expect(consoleLogSpy).toHaveBeenCalledWith('[blu-lytics]: Screen event: credit_list_view - {"origin":"home","campaign_name":"black_friday"}');
|
|
52
|
+
});
|
|
53
|
+
describe('production dispatch (non-development)', function () {
|
|
54
|
+
beforeEach(function () {
|
|
55
|
+
localStorage.setItem('_bl_env', 'production');
|
|
56
|
+
// Remove the providers allow-list so the dispatcher falls back to the
|
|
57
|
+
// full (mocked) providersList instead of filtering by name.
|
|
58
|
+
localStorage.removeItem('_bl_providers');
|
|
59
|
+
});
|
|
60
|
+
afterEach(function () {
|
|
61
|
+
localStorage.removeItem('_bl_env');
|
|
62
|
+
});
|
|
63
|
+
it('should call provider.screenEvent with only the screen when no properties are provided and _bl_props is empty', function () {
|
|
64
|
+
sendScreenEvent('TestScreen');
|
|
65
|
+
expect(providersList[0].screenEvent).toHaveBeenCalledWith('TestScreen', undefined);
|
|
66
|
+
});
|
|
67
|
+
it('should call provider.screenEvent with defaultProperties when _bl_props has content and no explicit properties are passed', function () {
|
|
68
|
+
localStorage.setItem('_bl_props', JSON.stringify({ client_uuid: 'abc123', is_economic_group: false }));
|
|
69
|
+
sendScreenEvent('home_view');
|
|
70
|
+
expect(providersList[0].screenEvent).toHaveBeenCalledWith('home_view', { client_uuid: 'abc123', is_economic_group: false });
|
|
71
|
+
});
|
|
72
|
+
it('should call provider.screenEvent with the screen and merged properties', function () {
|
|
73
|
+
localStorage.setItem('_bl_props', JSON.stringify({ origin: 'home' }));
|
|
74
|
+
sendScreenEvent('credit_list_view', {
|
|
75
|
+
campaign_name: 'black_friday',
|
|
76
|
+
opportunities_pagblu_count: 3
|
|
77
|
+
});
|
|
78
|
+
expect(providersList[0].screenEvent).toHaveBeenCalledWith('credit_list_view', {
|
|
79
|
+
origin: 'home',
|
|
80
|
+
campaign_name: 'black_friday',
|
|
81
|
+
opportunities_pagblu_count: 3
|
|
82
|
+
});
|
|
83
|
+
});
|
|
84
|
+
});
|
|
31
85
|
it('should be dispatch sendCustomEvent', function () {
|
|
32
86
|
var consoleLogSpy = jest.spyOn(console, 'log');
|
|
33
87
|
sendCustomEvent('TestEvent', { prop1: 'value1' });
|
|
@@ -6,8 +6,8 @@ import { EventData, PropertiesType, UserPropertiesType } from './dispatchers.typ
|
|
|
6
6
|
* @returns {void}
|
|
7
7
|
*/
|
|
8
8
|
export declare const dispatchEventToAllProviders: (eventData: EventData) => void;
|
|
9
|
-
declare const sendScreenEvent: (screen: string) => void;
|
|
10
9
|
declare const setDefaultProperties: (properties: PropertiesType) => void;
|
|
10
|
+
declare const sendScreenEvent: (screen: string, properties?: PropertiesType) => void;
|
|
11
11
|
declare const sendCustomEvent: (event: string, properties: PropertiesType) => void;
|
|
12
12
|
declare const sendUserIdentification: (id: string, userProperties: UserPropertiesType) => void;
|
|
13
13
|
declare const resetMixpanel: () => void;
|
|
@@ -1 +1 @@
|
|
|
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;
|
|
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;AAoBF,QAAA,MAAM,oBAAoB,eAAgB,cAAc,KAAG,IAG1D,CAAC;AAEF,QAAA,MAAM,eAAe,WACX,MAAM,eACD,cAAc,KAC1B,IA0BF,CAAC;AAEF,QAAA,MAAM,eAAe,UAAW,MAAM,cAAc,cAAc,KAAG,IAyBpE,CAAC;AAEF,QAAA,MAAM,sBAAsB,OACtB,MAAM,kBACM,kBAAkB,KACjC,IAUF,CAAC;AAEF,QAAA,MAAM,aAAa,QAAO,IAUzB,CAAC;AAEF,OAAO,EACL,eAAe,EACf,eAAe,EACf,sBAAsB,EACtB,oBAAoB,EACpB,aAAa,GACd,CAAC"}
|
package/lib/dispatchers/index.js
CHANGED
|
@@ -32,7 +32,7 @@ export var dispatchEventToAllProviders = function (eventData) {
|
|
|
32
32
|
screenEvent: function () {
|
|
33
33
|
return provider.screenEvent &&
|
|
34
34
|
eventData.screen &&
|
|
35
|
-
provider.screenEvent(eventData.screen);
|
|
35
|
+
provider.screenEvent(eventData.screen, eventData.properties);
|
|
36
36
|
},
|
|
37
37
|
customEvent: function () {
|
|
38
38
|
return provider.customEvent &&
|
|
@@ -55,14 +55,6 @@ var getIsDevelopment = function () {
|
|
|
55
55
|
var currentEnvironment = localStorage.getItem('_bl_env') || 'development';
|
|
56
56
|
return currentEnvironment === 'development';
|
|
57
57
|
};
|
|
58
|
-
var sendScreenEvent = function (screen) {
|
|
59
|
-
if (getIsDevelopment()) {
|
|
60
|
-
console.log("[blu-lytics]: Screen event: ".concat(screen));
|
|
61
|
-
}
|
|
62
|
-
else {
|
|
63
|
-
dispatchEventToAllProviders({ screen: screen });
|
|
64
|
-
}
|
|
65
|
-
};
|
|
66
58
|
var saveDefaultPropertiesToLocalStorage = function (properties) {
|
|
67
59
|
localStorage.setItem('_bl_props', JSON.stringify(properties));
|
|
68
60
|
};
|
|
@@ -75,6 +67,27 @@ var setDefaultProperties = function (properties) {
|
|
|
75
67
|
defaultProperties = __assign({}, properties);
|
|
76
68
|
saveDefaultPropertiesToLocalStorage(defaultProperties);
|
|
77
69
|
};
|
|
70
|
+
var sendScreenEvent = function (screen, properties) {
|
|
71
|
+
var rawStoredProperties = localStorage.getItem('_bl_props');
|
|
72
|
+
if (rawStoredProperties) {
|
|
73
|
+
try {
|
|
74
|
+
defaultProperties = JSON.parse(rawStoredProperties);
|
|
75
|
+
}
|
|
76
|
+
catch (error) {
|
|
77
|
+
console.error('[blu-lytics] Failed to parse stored properties', error);
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
var mergedProperties = __assign(__assign({}, defaultProperties), properties);
|
|
81
|
+
var hasProperties = Object.keys(mergedProperties).length > 0;
|
|
82
|
+
if (getIsDevelopment()) {
|
|
83
|
+
console.log(hasProperties
|
|
84
|
+
? "[blu-lytics]: Screen event: ".concat(screen, " - ").concat(JSON.stringify(mergedProperties))
|
|
85
|
+
: "[blu-lytics]: Screen event: ".concat(screen));
|
|
86
|
+
}
|
|
87
|
+
else {
|
|
88
|
+
dispatchEventToAllProviders(__assign({ screen: screen }, (hasProperties ? { properties: mergedProperties } : {})));
|
|
89
|
+
}
|
|
90
|
+
};
|
|
78
91
|
var sendCustomEvent = function (event, properties) {
|
|
79
92
|
var rawStoredProperties = localStorage.getItem('_bl_props');
|
|
80
93
|
if (rawStoredProperties) {
|
|
@@ -3,7 +3,7 @@ export type ProviderType = {
|
|
|
3
3
|
name: 'Clarity' | 'Sentry' | 'FullStory' | 'MixPanel';
|
|
4
4
|
userIdentification: (id: string, userProperties: any) => void;
|
|
5
5
|
customEvent: (event: string, properties: PropertiesType) => void;
|
|
6
|
-
screenEvent: (screen: string) => void;
|
|
6
|
+
screenEvent: (screen: string, properties?: PropertiesType) => void;
|
|
7
7
|
reset?: () => void;
|
|
8
8
|
};
|
|
9
9
|
//# sourceMappingURL=provider.types.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"provider.types.d.ts","sourceRoot":"","sources":["../../src/providers/provider.types.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,kCAAkC,CAAC;AAElE,MAAM,MAAM,YAAY,GAAG;IACzB,IAAI,EAAE,SAAS,GAAG,QAAQ,GAAG,WAAW,GAAG,UAAU,CAAC;IACtD,kBAAkB,EAAE,CAAC,EAAE,EAAE,MAAM,EAAE,cAAc,EAAE,GAAG,KAAK,IAAI,CAAC;IAC9D,WAAW,EAAE,CAAC,KAAK,EAAE,MAAM,EAAE,UAAU,EAAE,cAAc,KAAK,IAAI,CAAC;IACjE,WAAW,EAAE,CAAC,MAAM,EAAE,MAAM,KAAK,IAAI,CAAC;
|
|
1
|
+
{"version":3,"file":"provider.types.d.ts","sourceRoot":"","sources":["../../src/providers/provider.types.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,kCAAkC,CAAC;AAElE,MAAM,MAAM,YAAY,GAAG;IACzB,IAAI,EAAE,SAAS,GAAG,QAAQ,GAAG,WAAW,GAAG,UAAU,CAAC;IACtD,kBAAkB,EAAE,CAAC,EAAE,EAAE,MAAM,EAAE,cAAc,EAAE,GAAG,KAAK,IAAI,CAAC;IAC9D,WAAW,EAAE,CAAC,KAAK,EAAE,MAAM,EAAE,UAAU,EAAE,cAAc,KAAK,IAAI,CAAC;IACjE,WAAW,EAAE,CAAC,MAAM,EAAE,MAAM,EAAE,UAAU,CAAC,EAAE,cAAc,KAAK,IAAI,CAAC;IACnE,KAAK,CAAC,EAAE,MAAM,IAAI,CAAC;CACpB,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"clarity.d.ts","sourceRoot":"","sources":["../../../../src/providers/setups/clarity/clarity.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,YAAY,EAAE,MAAM,sBAAsB,CAAC;
|
|
1
|
+
{"version":3,"file":"clarity.d.ts","sourceRoot":"","sources":["../../../../src/providers/setups/clarity/clarity.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,YAAY,EAAE,MAAM,sBAAsB,CAAC;AA4BpD,QAAA,MAAM,eAAe,EAAE,YAKtB,CAAC;AAEF,eAAe,eAAe,CAAC"}
|
|
@@ -5,7 +5,7 @@ var dispatchUserIdentification = function (id, userProperties) {
|
|
|
5
5
|
};
|
|
6
6
|
var dispatchCustomEvent = function (event, properties) {
|
|
7
7
|
};
|
|
8
|
-
var dispatchScreenEvent = function (screen) {
|
|
8
|
+
var dispatchScreenEvent = function (screen, properties) {
|
|
9
9
|
};
|
|
10
10
|
var ClarityProvider = {
|
|
11
11
|
name: 'Clarity',
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"fullstory.d.ts","sourceRoot":"","sources":["../../../../src/providers/setups/fullstory/fullstory.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,YAAY,EAAE,MAAM,sBAAsB,CAAC;
|
|
1
|
+
{"version":3,"file":"fullstory.d.ts","sourceRoot":"","sources":["../../../../src/providers/setups/fullstory/fullstory.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,YAAY,EAAE,MAAM,sBAAsB,CAAC;AA8BpD,QAAA,MAAM,iBAAiB,EAAE,YAKxB,CAAC;AAEF,eAAe,iBAAiB,CAAC"}
|
|
@@ -6,8 +6,8 @@ var dispatchUserIdentification = function (id, userProperties) {
|
|
|
6
6
|
var dispatchCustomEvent = function (event, properties) {
|
|
7
7
|
FullStory.event(event, { properties: properties });
|
|
8
8
|
};
|
|
9
|
-
var dispatchScreenEvent = function (screen) {
|
|
10
|
-
FullStory.event(screen, {});
|
|
9
|
+
var dispatchScreenEvent = function (screen, properties) {
|
|
10
|
+
FullStory.event(screen, properties ? { properties: properties } : {});
|
|
11
11
|
};
|
|
12
12
|
var FullStoryProvider = {
|
|
13
13
|
name: 'FullStory',
|
|
@@ -27,4 +27,10 @@ describe('FullStoryProvider', function () {
|
|
|
27
27
|
FullStoryProvider.screenEvent(screen);
|
|
28
28
|
expect(FullStory.event).toHaveBeenCalledWith(screen, {});
|
|
29
29
|
});
|
|
30
|
+
it('dispatchScreenEvent should call FullStory.event with properties when provided', function () {
|
|
31
|
+
var screen = 'credit_list_view';
|
|
32
|
+
var properties = { origin: 'home', campaign_name: 'black_friday' };
|
|
33
|
+
FullStoryProvider.screenEvent(screen, properties);
|
|
34
|
+
expect(FullStory.event).toHaveBeenCalledWith(screen, { properties: properties });
|
|
35
|
+
});
|
|
30
36
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"mixpanel.d.ts","sourceRoot":"","sources":["../../../../src/providers/setups/mixpanel/mixpanel.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,YAAY,EAAE,MAAM,sBAAsB,CAAC;
|
|
1
|
+
{"version":3,"file":"mixpanel.d.ts","sourceRoot":"","sources":["../../../../src/providers/setups/mixpanel/mixpanel.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,YAAY,EAAE,MAAM,sBAAsB,CAAC;AAyEpD,QAAA,MAAM,gBAAgB,EAAE,YAMvB,CAAC;AAEF,eAAe,gBAAgB,CAAC"}
|
|
@@ -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
|
var __rest = (this && this.__rest) || function (s, e) {
|
|
2
13
|
var t = {};
|
|
3
14
|
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
@@ -43,10 +54,15 @@ var dispatchCustomEvent = function (event, properties) {
|
|
|
43
54
|
console.error('Error tracking screen event:', error);
|
|
44
55
|
}
|
|
45
56
|
};
|
|
46
|
-
var dispatchScreenEvent = function (screen) {
|
|
57
|
+
var dispatchScreenEvent = function (screen, properties) {
|
|
47
58
|
try {
|
|
48
59
|
setTimeout(function () {
|
|
49
|
-
|
|
60
|
+
if (properties) {
|
|
61
|
+
mixpanel.track(screen, __assign({}, properties));
|
|
62
|
+
}
|
|
63
|
+
else {
|
|
64
|
+
mixpanel.track(screen);
|
|
65
|
+
}
|
|
50
66
|
}, 1000);
|
|
51
67
|
}
|
|
52
68
|
catch (error) {
|
|
@@ -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
|
var __rest = (this && this.__rest) || function (s, e) {
|
|
2
13
|
var t = {};
|
|
3
14
|
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
@@ -56,4 +67,15 @@ describe('MixPanelProvider', function () {
|
|
|
56
67
|
jest.runAllTimers();
|
|
57
68
|
expect(mixpanel.track).toHaveBeenCalledWith(screen);
|
|
58
69
|
});
|
|
70
|
+
test('dispatchScreenEvent should call mixpanel.track with screen and properties', function () {
|
|
71
|
+
var screen = 'credit_list_view';
|
|
72
|
+
var properties = {
|
|
73
|
+
origin: 'home',
|
|
74
|
+
campaign_name: 'black_friday',
|
|
75
|
+
opportunities_pagblu_count: 3
|
|
76
|
+
};
|
|
77
|
+
MixPanelProvider.screenEvent(screen, properties);
|
|
78
|
+
jest.runAllTimers();
|
|
79
|
+
expect(mixpanel.track).toHaveBeenCalledWith(screen, __assign({}, properties));
|
|
80
|
+
});
|
|
59
81
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sentry.d.ts","sourceRoot":"","sources":["../../../../src/providers/setups/sentry/sentry.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,YAAY,EAAE,MAAM,sBAAsB,CAAC;
|
|
1
|
+
{"version":3,"file":"sentry.d.ts","sourceRoot":"","sources":["../../../../src/providers/setups/sentry/sentry.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,YAAY,EAAE,MAAM,sBAAsB,CAAC;AAiDpD,QAAA,MAAM,cAAc,EAAE,YAKrB,CAAC;AAEF,eAAe,cAAc,CAAC"}
|
|
@@ -24,13 +24,8 @@ var dispatchCustomEvent = function (event, properties) {
|
|
|
24
24
|
};
|
|
25
25
|
Sentry.addBreadcrumb(breadcrumb);
|
|
26
26
|
};
|
|
27
|
-
var dispatchScreenEvent = function (screen) {
|
|
28
|
-
var breadcrumb = {
|
|
29
|
-
category: 'screen',
|
|
30
|
-
message: screen,
|
|
31
|
-
level: Sentry.Severity.Info,
|
|
32
|
-
type: 'info'
|
|
33
|
-
};
|
|
27
|
+
var dispatchScreenEvent = function (screen, properties) {
|
|
28
|
+
var breadcrumb = __assign({ category: 'screen', message: screen, level: Sentry.Severity.Info, type: 'info' }, (properties ? { data: properties } : {}));
|
|
34
29
|
Sentry.addBreadcrumb(breadcrumb);
|
|
35
30
|
};
|
|
36
31
|
var SentryProvider = {
|
|
@@ -53,4 +53,16 @@ describe('SentryProvider', function () {
|
|
|
53
53
|
type: 'info'
|
|
54
54
|
});
|
|
55
55
|
});
|
|
56
|
+
it('dispatchScreenEvent should add breadcrumb with data when properties are provided', function () {
|
|
57
|
+
var screenName = 'credit_list_view';
|
|
58
|
+
var properties = { origin: 'home', campaign_name: 'black_friday' };
|
|
59
|
+
SentryProvider.screenEvent(screenName, properties);
|
|
60
|
+
expect(Sentry.addBreadcrumb).toHaveBeenCalledWith({
|
|
61
|
+
category: 'screen',
|
|
62
|
+
message: screenName,
|
|
63
|
+
level: 'info',
|
|
64
|
+
type: 'info',
|
|
65
|
+
data: properties
|
|
66
|
+
});
|
|
67
|
+
});
|
|
56
68
|
});
|