@splitsoftware/splitio-commons 1.17.1-rc.3 → 2.0.0-rc.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/CHANGES.txt +7 -3
- package/cjs/evaluator/index.js +2 -2
- package/cjs/evaluator/matchers/semver_inlist.js +1 -2
- package/cjs/evaluator/matchers/whitelist.js +1 -2
- package/cjs/listeners/browser.js +1 -2
- package/cjs/logger/browser/DebugLogger.js +1 -2
- package/cjs/logger/browser/ErrorLogger.js +1 -2
- package/cjs/logger/browser/InfoLogger.js +1 -2
- package/cjs/logger/browser/WarnLogger.js +1 -2
- package/cjs/logger/index.js +1 -2
- package/cjs/readiness/readinessManager.js +5 -7
- package/cjs/sdkClient/clientCS.js +5 -8
- package/cjs/sdkClient/sdkClientMethodCS.js +5 -8
- package/cjs/sdkFactory/index.js +10 -33
- package/cjs/services/decorateHeaders.js +1 -2
- package/cjs/storages/AbstractSplitsCacheAsync.js +7 -0
- package/cjs/storages/AbstractSplitsCacheSync.js +7 -0
- package/cjs/storages/KeyBuilderCS.js +0 -9
- package/cjs/storages/dataLoader.js +32 -64
- package/cjs/storages/inLocalStorage/MySegmentsCacheInLocal.js +1 -21
- package/cjs/storages/inLocalStorage/SplitsCacheInLocal.js +14 -7
- package/cjs/storages/inLocalStorage/index.js +1 -6
- package/cjs/storages/inMemory/InMemoryStorageCS.js +4 -16
- package/cjs/storages/inMemory/SegmentsCacheInMemory.js +3 -4
- package/cjs/storages/inMemory/SplitsCacheInMemory.js +2 -3
- package/cjs/storages/inMemory/UniqueKeysCacheInMemory.js +2 -3
- package/cjs/storages/inMemory/UniqueKeysCacheInMemoryCS.js +2 -3
- package/cjs/storages/inRedis/RedisAdapter.js +3 -4
- package/cjs/storages/inRedis/SplitsCacheInRedis.js +1 -1
- package/cjs/storages/inRedis/TelemetryCacheInRedis.js +3 -4
- package/cjs/storages/inRedis/UniqueKeysCacheInRedis.js +1 -2
- package/cjs/storages/pluggable/SplitsCachePluggable.js +1 -1
- package/cjs/storages/pluggable/TelemetryCachePluggable.js +6 -7
- package/cjs/storages/pluggable/UniqueKeysCachePluggable.js +1 -2
- package/cjs/storages/pluggable/inMemoryWrapper.js +7 -8
- package/cjs/storages/pluggable/index.js +32 -37
- package/cjs/sync/offline/syncTasks/fromObjectSyncTask.js +7 -2
- package/cjs/sync/polling/pollingManagerSS.js +3 -3
- package/cjs/sync/polling/updaters/splitChangesUpdater.js +13 -5
- package/cjs/sync/streaming/parseUtils.js +0 -1
- package/cjs/sync/streaming/pushManager.js +2 -3
- package/cjs/trackers/eventTracker.js +9 -11
- package/cjs/trackers/impressionsTracker.js +13 -15
- package/cjs/trackers/uniqueKeysTracker.js +3 -5
- package/cjs/utils/LRUCache/index.js +1 -2
- package/cjs/utils/constants/browser.js +1 -4
- package/cjs/utils/lang/index.js +6 -9
- package/cjs/utils/lang/objectAssign.js +12 -77
- package/cjs/utils/lang/sets.js +3 -110
- package/cjs/utils/settingsValidation/index.js +0 -9
- package/cjs/utils/settingsValidation/logger/builtinLogger.js +1 -2
- package/cjs/utils/settingsValidation/storage/storageCS.js +12 -1
- package/esm/evaluator/index.js +3 -3
- package/esm/evaluator/matchers/semver_inlist.js +1 -2
- package/esm/evaluator/matchers/whitelist.js +1 -2
- package/esm/listeners/browser.js +1 -2
- package/esm/logger/browser/DebugLogger.js +1 -2
- package/esm/logger/browser/ErrorLogger.js +1 -2
- package/esm/logger/browser/InfoLogger.js +1 -2
- package/esm/logger/browser/WarnLogger.js +1 -2
- package/esm/logger/index.js +1 -2
- package/esm/readiness/readinessManager.js +5 -7
- package/esm/sdkClient/clientCS.js +5 -8
- package/esm/sdkClient/sdkClientMethodCS.js +5 -8
- package/esm/sdkFactory/index.js +11 -34
- package/esm/services/decorateHeaders.js +1 -2
- package/esm/storages/AbstractSplitsCacheAsync.js +7 -0
- package/esm/storages/AbstractSplitsCacheSync.js +7 -0
- package/esm/storages/KeyBuilderCS.js +0 -9
- package/esm/storages/dataLoader.js +30 -61
- package/esm/storages/inLocalStorage/MySegmentsCacheInLocal.js +1 -21
- package/esm/storages/inLocalStorage/SplitsCacheInLocal.js +14 -7
- package/esm/storages/inLocalStorage/index.js +2 -7
- package/esm/storages/inMemory/InMemoryStorageCS.js +4 -16
- package/esm/storages/inMemory/SegmentsCacheInMemory.js +3 -4
- package/esm/storages/inMemory/SplitsCacheInMemory.js +2 -3
- package/esm/storages/inMemory/UniqueKeysCacheInMemory.js +2 -3
- package/esm/storages/inMemory/UniqueKeysCacheInMemoryCS.js +2 -3
- package/esm/storages/inRedis/RedisAdapter.js +3 -4
- package/esm/storages/inRedis/SplitsCacheInRedis.js +2 -2
- package/esm/storages/inRedis/TelemetryCacheInRedis.js +3 -4
- package/esm/storages/inRedis/UniqueKeysCacheInRedis.js +1 -2
- package/esm/storages/pluggable/SplitsCachePluggable.js +2 -2
- package/esm/storages/pluggable/TelemetryCachePluggable.js +6 -7
- package/esm/storages/pluggable/UniqueKeysCachePluggable.js +1 -2
- package/esm/storages/pluggable/inMemoryWrapper.js +7 -8
- package/esm/storages/pluggable/index.js +32 -37
- package/esm/sync/offline/syncTasks/fromObjectSyncTask.js +8 -3
- package/esm/sync/polling/pollingManagerSS.js +3 -3
- package/esm/sync/polling/updaters/splitChangesUpdater.js +14 -6
- package/esm/sync/streaming/parseUtils.js +0 -1
- package/esm/sync/streaming/pushManager.js +2 -3
- package/esm/trackers/eventTracker.js +9 -11
- package/esm/trackers/impressionsTracker.js +13 -15
- package/esm/trackers/uniqueKeysTracker.js +3 -5
- package/esm/utils/LRUCache/index.js +1 -2
- package/esm/utils/constants/browser.js +0 -3
- package/esm/utils/lang/index.js +6 -9
- package/esm/utils/lang/objectAssign.js +12 -77
- package/esm/utils/lang/sets.js +2 -107
- package/esm/utils/settingsValidation/index.js +0 -9
- package/esm/utils/settingsValidation/logger/builtinLogger.js +1 -2
- package/esm/utils/settingsValidation/storage/storageCS.js +10 -0
- package/package.json +2 -2
- package/src/evaluator/index.ts +5 -5
- package/src/evaluator/matchers/semver_inlist.ts +1 -2
- package/src/evaluator/matchers/whitelist.ts +1 -3
- package/src/listeners/browser.ts +1 -2
- package/src/logger/browser/DebugLogger.ts +1 -2
- package/src/logger/browser/ErrorLogger.ts +1 -2
- package/src/logger/browser/InfoLogger.ts +1 -2
- package/src/logger/browser/WarnLogger.ts +1 -2
- package/src/logger/index.ts +3 -4
- package/src/readiness/readinessManager.ts +7 -9
- package/src/readiness/types.ts +0 -1
- package/src/sdkClient/clientCS.ts +5 -8
- package/src/sdkClient/sdkClientMethodCS.ts +3 -6
- package/src/sdkFactory/index.ts +12 -37
- package/src/sdkFactory/types.ts +1 -4
- package/src/services/decorateHeaders.ts +1 -2
- package/src/storages/AbstractSplitsCacheAsync.ts +9 -2
- package/src/storages/AbstractSplitsCacheSync.ts +9 -2
- package/src/storages/KeyBuilderCS.ts +0 -13
- package/src/storages/dataLoader.ts +32 -62
- package/src/storages/inLocalStorage/MySegmentsCacheInLocal.ts +1 -21
- package/src/storages/inLocalStorage/SplitsCacheInLocal.ts +16 -8
- package/src/storages/inLocalStorage/index.ts +2 -8
- package/src/storages/inMemory/InMemoryStorageCS.ts +4 -19
- package/src/storages/inMemory/SegmentsCacheInMemory.ts +4 -5
- package/src/storages/inMemory/SplitsCacheInMemory.ts +4 -5
- package/src/storages/inMemory/UniqueKeysCacheInMemory.ts +4 -5
- package/src/storages/inMemory/UniqueKeysCacheInMemoryCS.ts +4 -5
- package/src/storages/inRedis/RedisAdapter.ts +4 -5
- package/src/storages/inRedis/SplitsCacheInRedis.ts +3 -3
- package/src/storages/inRedis/TelemetryCacheInRedis.ts +3 -4
- package/src/storages/inRedis/UniqueKeysCacheInRedis.ts +1 -2
- package/src/storages/pluggable/SegmentsCachePluggable.ts +0 -1
- package/src/storages/pluggable/SplitsCachePluggable.ts +3 -3
- package/src/storages/pluggable/TelemetryCachePluggable.ts +6 -7
- package/src/storages/pluggable/UniqueKeysCachePluggable.ts +1 -2
- package/src/storages/pluggable/inMemoryWrapper.ts +8 -9
- package/src/storages/pluggable/index.ts +33 -38
- package/src/storages/types.ts +9 -6
- package/src/sync/offline/syncTasks/fromObjectSyncTask.ts +7 -3
- package/src/sync/polling/pollingManagerSS.ts +2 -3
- package/src/sync/polling/updaters/splitChangesUpdater.ts +15 -8
- package/src/sync/streaming/parseUtils.ts +0 -1
- package/src/sync/streaming/pushManager.ts +3 -4
- package/src/sync/submitters/types.ts +3 -4
- package/src/trackers/eventTracker.ts +7 -10
- package/src/trackers/impressionsTracker.ts +9 -12
- package/src/trackers/types.ts +0 -1
- package/src/trackers/uniqueKeysTracker.ts +4 -6
- package/src/types.ts +9 -18
- package/src/utils/LRUCache/index.ts +2 -3
- package/src/utils/constants/browser.ts +0 -4
- package/src/utils/lang/index.ts +6 -7
- package/src/utils/lang/objectAssign.ts +13 -92
- package/src/utils/lang/sets.ts +3 -125
- package/src/utils/settingsValidation/index.ts +0 -10
- package/src/utils/settingsValidation/logger/builtinLogger.ts +1 -2
- package/src/utils/settingsValidation/storage/storageCS.ts +13 -0
- package/src/utils/settingsValidation/types.ts +0 -2
- package/types/logger/index.d.ts +1 -2
- package/types/readiness/types.d.ts +0 -1
- package/types/sdkClient/clientCS.d.ts +2 -3
- package/types/sdkFactory/types.d.ts +1 -3
- package/types/storages/AbstractSplitsCacheAsync.d.ts +6 -2
- package/types/storages/AbstractSplitsCacheSync.d.ts +6 -2
- package/types/storages/KeyBuilderCS.d.ts +0 -2
- package/types/storages/dataLoader.d.ts +6 -17
- package/types/storages/inLocalStorage/SplitsCacheInLocal.d.ts +7 -2
- package/types/storages/inMemory/SplitsCacheInMemory.d.ts +1 -2
- package/types/storages/inMemory/UniqueKeysCacheInMemory.d.ts +2 -3
- package/types/storages/inRedis/SplitsCacheInRedis.d.ts +1 -2
- package/types/storages/pluggable/SplitsCachePluggable.d.ts +1 -2
- package/types/storages/pluggable/inMemoryWrapper.d.ts +1 -2
- package/types/storages/types.d.ts +7 -6
- package/types/sync/polling/updaters/splitChangesUpdater.d.ts +1 -2
- package/types/sync/submitters/types.d.ts +3 -4
- package/types/trackers/eventTracker.d.ts +1 -1
- package/types/trackers/impressionsTracker.d.ts +1 -1
- package/types/trackers/types.d.ts +0 -1
- package/types/types.d.ts +9 -17
- package/types/utils/LRUCache/index.d.ts +1 -2
- package/types/utils/constants/browser.d.ts +0 -2
- package/types/utils/lang/objectAssign.d.ts +3 -0
- package/types/utils/lang/sets.d.ts +1 -61
- package/types/utils/settingsValidation/index.d.ts +0 -1
- package/types/utils/settingsValidation/storage/storageCS.d.ts +5 -0
- package/types/utils/settingsValidation/types.d.ts +0 -2
- package/cjs/integrations/browser.js +0 -31
- package/cjs/integrations/ga/GaToSplit.js +0 -257
- package/cjs/integrations/ga/GoogleAnalyticsToSplit.js +0 -14
- package/cjs/integrations/ga/SplitToGa.js +0 -123
- package/cjs/integrations/ga/SplitToGoogleAnalytics.js +0 -14
- package/cjs/integrations/ga/types.js +0 -2
- package/cjs/sdkClient/sdkClientMethodCSWithTT.js +0 -79
- package/cjs/utils/lang/maps.js +0 -96
- package/esm/integrations/browser.js +0 -27
- package/esm/integrations/ga/GaToSplit.js +0 -250
- package/esm/integrations/ga/GoogleAnalyticsToSplit.js +0 -10
- package/esm/integrations/ga/SplitToGa.js +0 -120
- package/esm/integrations/ga/SplitToGoogleAnalytics.js +0 -10
- package/esm/integrations/ga/types.js +0 -1
- package/esm/sdkClient/sdkClientMethodCSWithTT.js +0 -75
- package/esm/utils/lang/maps.js +0 -92
- package/src/integrations/browser.ts +0 -35
- package/src/integrations/ga/GaToSplit.ts +0 -299
- package/src/integrations/ga/GoogleAnalyticsToSplit.ts +0 -14
- package/src/integrations/ga/SplitToGa.ts +0 -135
- package/src/integrations/ga/SplitToGoogleAnalytics.ts +0 -14
- package/src/integrations/ga/autoRequire.js +0 -33
- package/src/integrations/ga/types.ts +0 -153
- package/src/sdkClient/sdkClientMethodCSWithTT.ts +0 -101
- package/src/utils/lang/maps.ts +0 -108
|
@@ -1,250 +0,0 @@
|
|
|
1
|
-
import { objectAssign } from '../../utils/lang/objectAssign';
|
|
2
|
-
import { isString, isFiniteNumber, uniqAsStrings } from '../../utils/lang';
|
|
3
|
-
import { validateEvent, validateEventValue, validateEventProperties, validateKey, validateTrafficType } from '../../utils/inputValidation';
|
|
4
|
-
var logPrefix = 'ga-to-split: ';
|
|
5
|
-
var logNameMapper = 'ga-to-split:mapper';
|
|
6
|
-
/**
|
|
7
|
-
* Provides a plugin to use with analytics.js, accounting for the possibility
|
|
8
|
-
* that the global command queue has been renamed or not yet defined.
|
|
9
|
-
* @param window Reference to global object.
|
|
10
|
-
* @param pluginName The plugin name identifier.
|
|
11
|
-
* @param pluginConstructor The plugin constructor function.
|
|
12
|
-
* @param log Logger instance.
|
|
13
|
-
* @param autoRequire If true, log error when auto-require script is not detected
|
|
14
|
-
*/
|
|
15
|
-
function providePlugin(window, pluginName, pluginConstructor, log, autoRequire, telemetryTracker) {
|
|
16
|
-
// get reference to global command queue. Init it if not defined yet.
|
|
17
|
-
var gaAlias = window.GoogleAnalyticsObject || 'ga';
|
|
18
|
-
window[gaAlias] = window[gaAlias] || function () {
|
|
19
|
-
(window[gaAlias].q = window[gaAlias].q || []).push(arguments);
|
|
20
|
-
};
|
|
21
|
-
// provides the plugin for use with analytics.js.
|
|
22
|
-
window[gaAlias]('provide', pluginName, pluginConstructor);
|
|
23
|
-
var hasAutoRequire = window[gaAlias].q && window[gaAlias].q.push !== [].push;
|
|
24
|
-
if (autoRequire && !hasAutoRequire) { // Expecting spy on ga.q push method but not found
|
|
25
|
-
log.error(logPrefix + 'integration is configured to autorequire the splitTracker plugin, but the necessary script does not seem to have run. Please check the docs.');
|
|
26
|
-
}
|
|
27
|
-
if (telemetryTracker && hasAutoRequire) {
|
|
28
|
-
telemetryTracker.addTag('integration:ga-autorequire');
|
|
29
|
-
}
|
|
30
|
-
}
|
|
31
|
-
// Default mapping: object used for building the default mapper from hits to Split events
|
|
32
|
-
var defaultMapping = {
|
|
33
|
-
eventTypeId: {
|
|
34
|
-
event: 'eventAction',
|
|
35
|
-
social: 'socialAction',
|
|
36
|
-
},
|
|
37
|
-
eventValue: {
|
|
38
|
-
event: 'eventValue',
|
|
39
|
-
timing: 'timingValue',
|
|
40
|
-
},
|
|
41
|
-
eventProperties: {
|
|
42
|
-
pageview: ['page'],
|
|
43
|
-
screenview: ['screenName'],
|
|
44
|
-
event: ['eventCategory', 'eventLabel'],
|
|
45
|
-
social: ['socialNetwork', 'socialTarget'],
|
|
46
|
-
timing: ['timingCategory', 'timingVar', 'timingLabel'],
|
|
47
|
-
exception: ['exDescription', 'exFatal'],
|
|
48
|
-
}
|
|
49
|
-
};
|
|
50
|
-
/**
|
|
51
|
-
* Build a mapper function based on a mapping object
|
|
52
|
-
*
|
|
53
|
-
* @param {object} mapping
|
|
54
|
-
*/
|
|
55
|
-
function mapperBuilder(mapping) {
|
|
56
|
-
return function (model) {
|
|
57
|
-
var hitType = model.get('hitType');
|
|
58
|
-
// @ts-expect-error
|
|
59
|
-
var eventTypeId = model.get(mapping.eventTypeId[hitType] || 'hitType');
|
|
60
|
-
// @ts-expect-error
|
|
61
|
-
var value = model.get(mapping.eventValue[hitType]);
|
|
62
|
-
var properties = {}; // @ts-expect-error
|
|
63
|
-
var fields = mapping.eventProperties[hitType];
|
|
64
|
-
if (fields) {
|
|
65
|
-
for (var i = 0; i < fields.length; i++) {
|
|
66
|
-
var fieldValue = model.get(fields[i]);
|
|
67
|
-
if (fieldValue !== undefined)
|
|
68
|
-
properties[fields[i]] = fieldValue;
|
|
69
|
-
}
|
|
70
|
-
}
|
|
71
|
-
return {
|
|
72
|
-
eventTypeId: eventTypeId,
|
|
73
|
-
value: value,
|
|
74
|
-
properties: properties,
|
|
75
|
-
timestamp: Date.now(),
|
|
76
|
-
};
|
|
77
|
-
};
|
|
78
|
-
}
|
|
79
|
-
// exposed for unit testing purposses.
|
|
80
|
-
export var defaultMapper = mapperBuilder(defaultMapping);
|
|
81
|
-
export var defaultPrefix = 'ga';
|
|
82
|
-
/**
|
|
83
|
-
* Return a new list of identities removing invalid and duplicated ones.
|
|
84
|
-
*
|
|
85
|
-
* @param {Array} identities list of identities
|
|
86
|
-
* @returns list of valid and unique identities. The list might be empty if `identities` is not an array or all its elements are invalid.
|
|
87
|
-
*/
|
|
88
|
-
export function validateIdentities(identities) {
|
|
89
|
-
if (!Array.isArray(identities))
|
|
90
|
-
return [];
|
|
91
|
-
// Remove duplicated identities
|
|
92
|
-
var uniqueIdentities = uniqAsStrings(identities);
|
|
93
|
-
// Filter based on rum-agent identities validator
|
|
94
|
-
return uniqueIdentities.filter(function (identity) {
|
|
95
|
-
if (!identity)
|
|
96
|
-
return false;
|
|
97
|
-
var maybeKey = identity.key;
|
|
98
|
-
var maybeTT = identity.trafficType;
|
|
99
|
-
if (!isString(maybeKey) && !isFiniteNumber(maybeKey))
|
|
100
|
-
return false;
|
|
101
|
-
if (!isString(maybeTT))
|
|
102
|
-
return false;
|
|
103
|
-
return true;
|
|
104
|
-
});
|
|
105
|
-
}
|
|
106
|
-
/**
|
|
107
|
-
* Checks if EventData fields (except EventTypeId) are valid, and logs corresponding warnings.
|
|
108
|
-
* EventTypeId is validated separately.
|
|
109
|
-
*
|
|
110
|
-
* @param {EventData} data event data instance to validate. Precondition: data != undefined
|
|
111
|
-
* @returns {boolean} Whether the data instance is a valid EventData or not.
|
|
112
|
-
*/
|
|
113
|
-
export function validateEventData(log, eventData) {
|
|
114
|
-
if (!validateEvent(log, eventData.eventTypeId, logNameMapper))
|
|
115
|
-
return false;
|
|
116
|
-
if (validateEventValue(log, eventData.value, logNameMapper) === false)
|
|
117
|
-
return false;
|
|
118
|
-
var properties = validateEventProperties(log, eventData.properties, logNameMapper).properties;
|
|
119
|
-
if (properties === false)
|
|
120
|
-
return false;
|
|
121
|
-
if (eventData.timestamp && !isFiniteNumber(eventData.timestamp))
|
|
122
|
-
return false;
|
|
123
|
-
if (eventData.key && validateKey(log, eventData.key, logNameMapper) === false)
|
|
124
|
-
return false;
|
|
125
|
-
if (eventData.trafficTypeName && validateTrafficType(log, eventData.trafficTypeName, logNameMapper) === false)
|
|
126
|
-
return false;
|
|
127
|
-
return true;
|
|
128
|
-
}
|
|
129
|
-
var INVALID_PREFIX_REGEX = /^[^a-zA-Z0-9]+/;
|
|
130
|
-
var INVALID_SUBSTRING_REGEX = /[^-_.:a-zA-Z0-9]+/g;
|
|
131
|
-
/**
|
|
132
|
-
* Fixes the passed string value to comply with EventTypeId format, by removing invalid characters and truncating if necessary.
|
|
133
|
-
*
|
|
134
|
-
* @param {object} log factory logger
|
|
135
|
-
* @param {string} eventTypeId string value to fix.
|
|
136
|
-
* @returns {string} Fixed version of `eventTypeId`.
|
|
137
|
-
*/
|
|
138
|
-
export function fixEventTypeId(log, eventTypeId) {
|
|
139
|
-
// return the input eventTypeId if it cannot be fixed
|
|
140
|
-
if (!isString(eventTypeId) || eventTypeId.length === 0) {
|
|
141
|
-
return eventTypeId;
|
|
142
|
-
}
|
|
143
|
-
// replace invalid substrings and truncate
|
|
144
|
-
var fixed = eventTypeId
|
|
145
|
-
.replace(INVALID_PREFIX_REGEX, '')
|
|
146
|
-
.replace(INVALID_SUBSTRING_REGEX, '_');
|
|
147
|
-
var truncated = fixed.slice(0, 80);
|
|
148
|
-
if (truncated.length < fixed.length)
|
|
149
|
-
log.warn(logPrefix + 'EventTypeId was truncated because it cannot be more than 80 characters long.');
|
|
150
|
-
return truncated;
|
|
151
|
-
}
|
|
152
|
-
/**
|
|
153
|
-
* GaToSplit integration.
|
|
154
|
-
* This function provides the SplitTracker plugin to ga command queue.
|
|
155
|
-
*
|
|
156
|
-
* @param {object} sdkOptions options passed at the SDK integrations settings (isomorphic SDK) or the GoogleAnalyticsToSplit plugin (pluggable browser SDK)
|
|
157
|
-
* @param {object} storage SDK storage passed to track events
|
|
158
|
-
* @param {object} coreSettings core settings used to define an identity if no one provided as SDK or plugin options
|
|
159
|
-
* @param {object} log factory logger
|
|
160
|
-
*/
|
|
161
|
-
export function GaToSplit(sdkOptions, params) {
|
|
162
|
-
var storage = params.storage, _a = params.settings, coreSettings = _a.core, log = _a.log, telemetryTracker = params.telemetryTracker;
|
|
163
|
-
var defaultOptions = {
|
|
164
|
-
prefix: defaultPrefix,
|
|
165
|
-
// We set default identities if key and TT are present in settings.core
|
|
166
|
-
identities: (coreSettings.key && coreSettings.trafficType) ?
|
|
167
|
-
[{ key: coreSettings.key, trafficType: coreSettings.trafficType }] :
|
|
168
|
-
undefined
|
|
169
|
-
};
|
|
170
|
-
var SplitTracker = /** @class */ (function () {
|
|
171
|
-
// Constructor for the SplitTracker plugin.
|
|
172
|
-
function SplitTracker(tracker, pluginOptions) {
|
|
173
|
-
// precedence of options: SDK options (config.integrations) overwrite pluginOptions (`ga('require', 'splitTracker', pluginOptions)`)
|
|
174
|
-
var opts = objectAssign({}, defaultOptions, sdkOptions, pluginOptions);
|
|
175
|
-
this.tracker = tracker;
|
|
176
|
-
// Validate identities
|
|
177
|
-
var validIdentities = validateIdentities(opts.identities);
|
|
178
|
-
if (validIdentities.length === 0) {
|
|
179
|
-
log.warn(logPrefix + 'No valid identities were provided. Please check that you are passing a valid list of identities or providing a traffic type at the SDK configuration.');
|
|
180
|
-
return;
|
|
181
|
-
}
|
|
182
|
-
var invalids = validIdentities.length - opts.identities.length;
|
|
183
|
-
if (invalids) {
|
|
184
|
-
log.warn(logPrefix + (invalids + " identities were discarded because they are invalid or duplicated. Identities must be an array of objects with key and trafficType."));
|
|
185
|
-
}
|
|
186
|
-
opts.identities = validIdentities;
|
|
187
|
-
// Validate prefix
|
|
188
|
-
if (!isString(opts.prefix)) {
|
|
189
|
-
log.warn(logPrefix + 'The provided `prefix` was ignored since it is invalid. Please check that you are passing a string object as `prefix`.');
|
|
190
|
-
opts.prefix = undefined;
|
|
191
|
-
}
|
|
192
|
-
// Overwrite sendHitTask to perform plugin tasks:
|
|
193
|
-
// 1) filter hits
|
|
194
|
-
// 2) map hits to Split events
|
|
195
|
-
// 3) handle events, i.e., validate and send them to Split BE
|
|
196
|
-
var originalSendHitTask = tracker.get('sendHitTask');
|
|
197
|
-
tracker.set('sendHitTask', function (model) {
|
|
198
|
-
originalSendHitTask(model);
|
|
199
|
-
// filter hit if `hits` flag is false or if it comes from Split-to-GA integration
|
|
200
|
-
if (opts.hits === false || model.get('splitHit'))
|
|
201
|
-
return;
|
|
202
|
-
try {
|
|
203
|
-
if (opts.filter && !opts.filter(model))
|
|
204
|
-
return;
|
|
205
|
-
}
|
|
206
|
-
catch (err) {
|
|
207
|
-
log.warn(logPrefix + ("custom filter threw: " + err));
|
|
208
|
-
return;
|
|
209
|
-
}
|
|
210
|
-
// map hit into an EventData instance
|
|
211
|
-
var eventData = defaultMapper(model);
|
|
212
|
-
if (opts.mapper) {
|
|
213
|
-
try {
|
|
214
|
-
eventData = opts.mapper(model, eventData);
|
|
215
|
-
}
|
|
216
|
-
catch (err) {
|
|
217
|
-
log.warn(logPrefix + ("custom mapper threw: " + err));
|
|
218
|
-
return;
|
|
219
|
-
}
|
|
220
|
-
if (!eventData)
|
|
221
|
-
return;
|
|
222
|
-
}
|
|
223
|
-
// Add prefix. Nothing is appended if the prefix is falsy, e.g. undefined or ''.
|
|
224
|
-
if (opts.prefix)
|
|
225
|
-
eventData.eventTypeId = opts.prefix + "." + eventData.eventTypeId;
|
|
226
|
-
eventData.eventTypeId = fixEventTypeId(log, eventData.eventTypeId);
|
|
227
|
-
if (!validateEventData(log, eventData))
|
|
228
|
-
return;
|
|
229
|
-
// Store the event
|
|
230
|
-
if (eventData.key && eventData.trafficTypeName) {
|
|
231
|
-
storage.events.track(eventData);
|
|
232
|
-
}
|
|
233
|
-
else { // Store the event for each Key-TT pair (identities), if key and TT is not present in eventData
|
|
234
|
-
opts.identities.forEach(function (identity) {
|
|
235
|
-
var event = objectAssign({
|
|
236
|
-
key: identity.key,
|
|
237
|
-
trafficTypeName: identity.trafficType,
|
|
238
|
-
}, eventData);
|
|
239
|
-
storage.events.track(event);
|
|
240
|
-
});
|
|
241
|
-
}
|
|
242
|
-
});
|
|
243
|
-
log.info(logPrefix + 'integration started');
|
|
244
|
-
}
|
|
245
|
-
return SplitTracker;
|
|
246
|
-
}());
|
|
247
|
-
// Register the plugin, even if config is invalid, since, if not provided, it will block `ga` command queue.
|
|
248
|
-
// eslint-disable-next-line no-undef
|
|
249
|
-
providePlugin(window, 'splitTracker', SplitTracker, log, sdkOptions.autoRequire === true, telemetryTracker);
|
|
250
|
-
}
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
import { GaToSplit } from './GaToSplit';
|
|
2
|
-
export function GoogleAnalyticsToSplit(options) {
|
|
3
|
-
if (options === void 0) { options = {}; }
|
|
4
|
-
// GaToSplit integration factory
|
|
5
|
-
function GoogleAnalyticsToSplitFactory(params) {
|
|
6
|
-
return GaToSplit(options, params);
|
|
7
|
-
}
|
|
8
|
-
GoogleAnalyticsToSplitFactory.type = 'GOOGLE_ANALYTICS_TO_SPLIT';
|
|
9
|
-
return GoogleAnalyticsToSplitFactory;
|
|
10
|
-
}
|
|
@@ -1,120 +0,0 @@
|
|
|
1
|
-
/* eslint-disable no-undef */
|
|
2
|
-
import { uniq } from '../../utils/lang';
|
|
3
|
-
import { SPLIT_IMPRESSION, SPLIT_EVENT } from '../../utils/constants';
|
|
4
|
-
var logPrefix = 'split-to-ga: ';
|
|
5
|
-
var noGaWarning = '`ga` command queue not found.';
|
|
6
|
-
var noHit = 'No hit was sent.';
|
|
7
|
-
var SplitToGa = /** @class */ (function () {
|
|
8
|
-
/**
|
|
9
|
-
* constructor description
|
|
10
|
-
* @param {object} options options passed at the SDK integrations settings (isomorphic SDK) or the SplitToGoogleAnalytics plugin (pluggable browser SDK)
|
|
11
|
-
*/
|
|
12
|
-
function SplitToGa(log, options) {
|
|
13
|
-
this.trackerNames = SplitToGa.defaultTrackerNames;
|
|
14
|
-
this.log = log;
|
|
15
|
-
if (options) {
|
|
16
|
-
if (typeof options.filter === 'function')
|
|
17
|
-
this.filter = options.filter;
|
|
18
|
-
if (typeof options.mapper === 'function')
|
|
19
|
-
this.mapper = options.mapper;
|
|
20
|
-
// We strip off duplicated values if we received a `trackerNames` param.
|
|
21
|
-
// We don't warn if a tracker does not exist, since the user might create it after the SDK is initialized.
|
|
22
|
-
// Note: GA allows to create and get trackers using a string or number as tracker name, and does nothing if other types are used.
|
|
23
|
-
if (Array.isArray(options.trackerNames))
|
|
24
|
-
this.trackerNames = uniq(options.trackerNames);
|
|
25
|
-
// No need to validate `impressions` and `events` flags. Any other value than `false` is ignored (considered true by default).
|
|
26
|
-
this.impressions = options.impressions;
|
|
27
|
-
this.events = options.events;
|
|
28
|
-
}
|
|
29
|
-
log.info(logPrefix + 'integration started');
|
|
30
|
-
if (typeof SplitToGa.getGa() !== 'function')
|
|
31
|
-
log.warn(logPrefix + (noGaWarning + " No hits will be sent until it is available."));
|
|
32
|
-
}
|
|
33
|
-
// Default mapper function.
|
|
34
|
-
SplitToGa.defaultMapper = function (_a) {
|
|
35
|
-
var type = _a.type, payload = _a.payload;
|
|
36
|
-
switch (type) {
|
|
37
|
-
case SPLIT_IMPRESSION:
|
|
38
|
-
return {
|
|
39
|
-
hitType: 'event',
|
|
40
|
-
eventCategory: 'split-impression',
|
|
41
|
-
eventAction: 'Evaluate ' + payload.impression.feature,
|
|
42
|
-
eventLabel: 'Treatment: ' + payload.impression.treatment + '. Targeting rule: ' + payload.impression.label + '.',
|
|
43
|
-
nonInteraction: true,
|
|
44
|
-
};
|
|
45
|
-
case SPLIT_EVENT:
|
|
46
|
-
return {
|
|
47
|
-
hitType: 'event',
|
|
48
|
-
eventCategory: 'split-event',
|
|
49
|
-
eventAction: payload.eventTypeId,
|
|
50
|
-
eventValue: payload.value,
|
|
51
|
-
nonInteraction: true,
|
|
52
|
-
};
|
|
53
|
-
}
|
|
54
|
-
};
|
|
55
|
-
// Util to access ga command queue, accounting for the possibility that it has been renamed.
|
|
56
|
-
SplitToGa.getGa = function () {
|
|
57
|
-
return typeof window !== 'undefined' ? window[window['GoogleAnalyticsObject'] || 'ga'] : undefined;
|
|
58
|
-
};
|
|
59
|
-
/**
|
|
60
|
-
* Validates if a given object is a UniversalAnalytics.FieldsObject instance, and logs a warning if not.
|
|
61
|
-
* It checks that the object contains a `hitType`, since it is the minimal field required to send the hit
|
|
62
|
-
* and avoid the GA error `No hit type specified. Aborting hit.`.
|
|
63
|
-
* Other validations (e.g., an `event` hitType must have a `eventCategory` and `eventAction`) are handled
|
|
64
|
-
* and logged (as warnings or errors depending the case) by GA debugger, but the hit is sent anyway.
|
|
65
|
-
*
|
|
66
|
-
* @param {object} log factory logger
|
|
67
|
-
* @param {UniversalAnalytics.FieldsObject} fieldsObject object to validate.
|
|
68
|
-
* @returns {boolean} Whether the data instance is a valid FieldsObject or not.
|
|
69
|
-
*/
|
|
70
|
-
SplitToGa.validateFieldsObject = function (log, fieldsObject) {
|
|
71
|
-
if (fieldsObject && fieldsObject.hitType)
|
|
72
|
-
return true;
|
|
73
|
-
log.warn(logPrefix + 'your custom mapper returned an invalid FieldsObject instance. It must be an object with at least a `hitType` field.');
|
|
74
|
-
return false;
|
|
75
|
-
};
|
|
76
|
-
SplitToGa.prototype.queue = function (data) {
|
|
77
|
-
// access ga command queue via `getGa` method, accounting for the possibility that
|
|
78
|
-
// the global `ga` reference was not yet mutated by analytics.js.
|
|
79
|
-
var ga = SplitToGa.getGa();
|
|
80
|
-
if (ga) {
|
|
81
|
-
if (this.impressions === false && data.type === SPLIT_IMPRESSION)
|
|
82
|
-
return;
|
|
83
|
-
if (this.events === false && data.type === SPLIT_EVENT)
|
|
84
|
-
return;
|
|
85
|
-
var fieldsObject_1;
|
|
86
|
-
try { // only try/catch filter and mapper, which might be defined by the user
|
|
87
|
-
// filter
|
|
88
|
-
if (this.filter && !this.filter(data))
|
|
89
|
-
return;
|
|
90
|
-
// map data into a FieldsObject instance
|
|
91
|
-
fieldsObject_1 = SplitToGa.defaultMapper(data);
|
|
92
|
-
if (this.mapper) {
|
|
93
|
-
fieldsObject_1 = this.mapper(data, fieldsObject_1);
|
|
94
|
-
// don't send the hit if it is falsy or invalid
|
|
95
|
-
if (!fieldsObject_1 || !SplitToGa.validateFieldsObject(this.log, fieldsObject_1))
|
|
96
|
-
return;
|
|
97
|
-
}
|
|
98
|
-
}
|
|
99
|
-
catch (err) {
|
|
100
|
-
this.log.warn(logPrefix + ("queue method threw: " + err + ". " + noHit));
|
|
101
|
-
return;
|
|
102
|
-
}
|
|
103
|
-
// send the hit
|
|
104
|
-
this.trackerNames.forEach(function (trackerName) {
|
|
105
|
-
var sendCommand = trackerName ? trackerName + ".send" : 'send';
|
|
106
|
-
// mark the hit as a Split one to avoid the loop.
|
|
107
|
-
fieldsObject_1.splitHit = true;
|
|
108
|
-
// Send to GA using our reference to the GA object.
|
|
109
|
-
ga(sendCommand, fieldsObject_1);
|
|
110
|
-
});
|
|
111
|
-
}
|
|
112
|
-
else {
|
|
113
|
-
this.log.warn(logPrefix + (noGaWarning + " " + noHit));
|
|
114
|
-
}
|
|
115
|
-
};
|
|
116
|
-
// A falsy object represents the default tracker
|
|
117
|
-
SplitToGa.defaultTrackerNames = [''];
|
|
118
|
-
return SplitToGa;
|
|
119
|
-
}());
|
|
120
|
-
export { SplitToGa };
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
import { SplitToGa } from './SplitToGa';
|
|
2
|
-
export function SplitToGoogleAnalytics(options) {
|
|
3
|
-
if (options === void 0) { options = {}; }
|
|
4
|
-
// SplitToGa integration factory
|
|
5
|
-
function SplitToGoogleAnalyticsFactory(params) {
|
|
6
|
-
return new SplitToGa(params.settings.log, options);
|
|
7
|
-
}
|
|
8
|
-
SplitToGoogleAnalyticsFactory.type = 'SPLIT_TO_GOOGLE_ANALYTICS';
|
|
9
|
-
return SplitToGoogleAnalyticsFactory;
|
|
10
|
-
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1,75 +0,0 @@
|
|
|
1
|
-
import { clientCSDecorator } from './clientCS';
|
|
2
|
-
import { validateKey } from '../utils/inputValidation/key';
|
|
3
|
-
import { validateTrafficType } from '../utils/inputValidation/trafficType';
|
|
4
|
-
import { getMatching, keyParser } from '../utils/key';
|
|
5
|
-
import { sdkClientFactory } from './sdkClient';
|
|
6
|
-
import { objectAssign } from '../utils/lang/objectAssign';
|
|
7
|
-
import { RETRIEVE_CLIENT_DEFAULT, NEW_SHARED_CLIENT, RETRIEVE_CLIENT_EXISTING, LOG_PREFIX_CLIENT_INSTANTIATION } from '../logger/constants';
|
|
8
|
-
import { SDK_SEGMENTS_ARRIVED } from '../readiness/constants';
|
|
9
|
-
import { buildInstanceId } from './identity';
|
|
10
|
-
/**
|
|
11
|
-
* Factory of client method for the client-side (browser) variant of the Isomorphic JS SDK,
|
|
12
|
-
* where clients can have a bound TT for the track method, which is provided via the settings
|
|
13
|
-
* (default client) or the client method (shared clients).
|
|
14
|
-
*/
|
|
15
|
-
export function sdkClientMethodCSFactory(params) {
|
|
16
|
-
var clients = params.clients, storage = params.storage, syncManager = params.syncManager, sdkReadinessManager = params.sdkReadinessManager, _a = params.settings, _b = _a.core, key = _b.key, trafficType = _b.trafficType, log = _a.log, whenInit = params.whenInit;
|
|
17
|
-
var mainClientInstance = clientCSDecorator(log, sdkClientFactory(params), key, trafficType);
|
|
18
|
-
var parsedDefaultKey = keyParser(key);
|
|
19
|
-
var defaultInstanceId = buildInstanceId(parsedDefaultKey, trafficType);
|
|
20
|
-
// Cache instances created per factory.
|
|
21
|
-
clients[defaultInstanceId] = mainClientInstance;
|
|
22
|
-
return function client(key, trafficType) {
|
|
23
|
-
if (key === undefined) {
|
|
24
|
-
log.debug(RETRIEVE_CLIENT_DEFAULT);
|
|
25
|
-
return mainClientInstance;
|
|
26
|
-
}
|
|
27
|
-
// Validate the key value
|
|
28
|
-
var validKey = validateKey(log, key, LOG_PREFIX_CLIENT_INSTANTIATION);
|
|
29
|
-
if (validKey === false) {
|
|
30
|
-
throw new Error('Shared Client needs a valid key.');
|
|
31
|
-
}
|
|
32
|
-
var validTrafficType;
|
|
33
|
-
if (trafficType !== undefined) {
|
|
34
|
-
validTrafficType = validateTrafficType(log, trafficType, LOG_PREFIX_CLIENT_INSTANTIATION);
|
|
35
|
-
if (validTrafficType === false) {
|
|
36
|
-
throw new Error('Shared Client needs a valid traffic type or no traffic type at all.');
|
|
37
|
-
}
|
|
38
|
-
}
|
|
39
|
-
var instanceId = buildInstanceId(validKey, validTrafficType);
|
|
40
|
-
if (!clients[instanceId]) {
|
|
41
|
-
var matchingKey = getMatching(validKey);
|
|
42
|
-
var sharedSdkReadiness_1 = sdkReadinessManager.shared();
|
|
43
|
-
var sharedStorage = storage.shared && storage.shared(matchingKey, function (err) {
|
|
44
|
-
if (err) {
|
|
45
|
-
sharedSdkReadiness_1.readinessManager.timeout();
|
|
46
|
-
return;
|
|
47
|
-
}
|
|
48
|
-
// Emit SDK_READY in consumer mode for shared clients
|
|
49
|
-
sharedSdkReadiness_1.readinessManager.segments.emit(SDK_SEGMENTS_ARRIVED);
|
|
50
|
-
});
|
|
51
|
-
// 3 possibilities:
|
|
52
|
-
// - Standalone mode: both syncManager and sharedSyncManager are defined
|
|
53
|
-
// - Consumer mode: both syncManager and sharedSyncManager are undefined
|
|
54
|
-
// - Consumer partial mode: syncManager is defined (only for submitters) but sharedSyncManager is undefined
|
|
55
|
-
// @ts-ignore
|
|
56
|
-
var sharedSyncManager_1 = syncManager && sharedStorage && syncManager.shared(matchingKey, sharedSdkReadiness_1.readinessManager, sharedStorage);
|
|
57
|
-
// As shared clients reuse all the storage information, we don't need to check here if we
|
|
58
|
-
// will use offline or online mode. We should stick with the original decision.
|
|
59
|
-
clients[instanceId] = clientCSDecorator(log, sdkClientFactory(objectAssign({}, params, {
|
|
60
|
-
sdkReadinessManager: sharedSdkReadiness_1,
|
|
61
|
-
storage: sharedStorage || storage,
|
|
62
|
-
syncManager: sharedSyncManager_1,
|
|
63
|
-
}), true), validKey, validTrafficType);
|
|
64
|
-
whenInit(function () {
|
|
65
|
-
sharedSdkReadiness_1.readinessManager.init();
|
|
66
|
-
sharedSyncManager_1 && sharedSyncManager_1.start();
|
|
67
|
-
});
|
|
68
|
-
log.info(NEW_SHARED_CLIENT);
|
|
69
|
-
}
|
|
70
|
-
else {
|
|
71
|
-
log.debug(RETRIEVE_CLIENT_EXISTING);
|
|
72
|
-
}
|
|
73
|
-
return clients[instanceId];
|
|
74
|
-
};
|
|
75
|
-
}
|
package/esm/utils/lang/maps.js
DELETED
|
@@ -1,92 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Map implementation based on es6-map polyfill (https://github.com/medikoo/es6-map/blob/master/polyfill.js),
|
|
3
|
-
* with the minimal features used by the SDK.
|
|
4
|
-
|
|
5
|
-
Copyright (C) 2013 Mariusz Nowak (www.medikoo.com)
|
|
6
|
-
|
|
7
|
-
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
8
|
-
of this software and associated documentation files (the "Software"), to deal
|
|
9
|
-
in the Software without restriction, including without limitation the rights
|
|
10
|
-
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
11
|
-
copies of the Software, and to permit persons to whom the Software is
|
|
12
|
-
furnished to do so, subject to the following conditions:
|
|
13
|
-
|
|
14
|
-
The above copyright notice and this permission notice shall be included in
|
|
15
|
-
all copies or substantial portions of the Software.
|
|
16
|
-
|
|
17
|
-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
18
|
-
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
19
|
-
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
20
|
-
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
21
|
-
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
22
|
-
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
|
23
|
-
THE SOFTWARE.
|
|
24
|
-
**/
|
|
25
|
-
var MapPoly = /** @class */ (function () {
|
|
26
|
-
// unlike ES6 `Map`, it only accepts an array as first argument iterable
|
|
27
|
-
function MapPoly(entries) {
|
|
28
|
-
var _this = this;
|
|
29
|
-
this.__mapKeysData__ = [];
|
|
30
|
-
this.__mapValuesData__ = [];
|
|
31
|
-
if (Array.isArray(entries))
|
|
32
|
-
entries.forEach(function (entry) { _this.set(entry[0], entry[1]); });
|
|
33
|
-
}
|
|
34
|
-
MapPoly.prototype.clear = function () {
|
|
35
|
-
if (!this.__mapKeysData__.length)
|
|
36
|
-
return;
|
|
37
|
-
this.__mapKeysData__.length = 0;
|
|
38
|
-
this.__mapValuesData__.length = 0;
|
|
39
|
-
};
|
|
40
|
-
MapPoly.prototype.delete = function (key) {
|
|
41
|
-
var index = this.__mapKeysData__.indexOf(key);
|
|
42
|
-
if (index === -1)
|
|
43
|
-
return false;
|
|
44
|
-
this.__mapKeysData__.splice(index, 1);
|
|
45
|
-
this.__mapValuesData__.splice(index, 1);
|
|
46
|
-
return true;
|
|
47
|
-
};
|
|
48
|
-
MapPoly.prototype.forEach = function (callbackfn, thisArg) {
|
|
49
|
-
for (var i = 0; i < this.__mapKeysData__.length; i++) {
|
|
50
|
-
callbackfn.call(thisArg, this.__mapValuesData__[i], this.__mapKeysData__[i], this);
|
|
51
|
-
}
|
|
52
|
-
};
|
|
53
|
-
MapPoly.prototype.get = function (key) {
|
|
54
|
-
var index = this.__mapKeysData__.indexOf(key);
|
|
55
|
-
if (index === -1)
|
|
56
|
-
return;
|
|
57
|
-
return this.__mapValuesData__[index];
|
|
58
|
-
};
|
|
59
|
-
MapPoly.prototype.has = function (key) {
|
|
60
|
-
return this.__mapKeysData__.indexOf(key) !== -1;
|
|
61
|
-
};
|
|
62
|
-
MapPoly.prototype.set = function (key, value) {
|
|
63
|
-
var index = this.__mapKeysData__.indexOf(key);
|
|
64
|
-
if (index === -1)
|
|
65
|
-
index = this.__mapKeysData__.push(key) - 1;
|
|
66
|
-
this.__mapValuesData__[index] = value;
|
|
67
|
-
return this;
|
|
68
|
-
};
|
|
69
|
-
Object.defineProperty(MapPoly.prototype, "size", {
|
|
70
|
-
get: function () {
|
|
71
|
-
return this.__mapKeysData__.length;
|
|
72
|
-
},
|
|
73
|
-
enumerable: false,
|
|
74
|
-
configurable: true
|
|
75
|
-
});
|
|
76
|
-
return MapPoly;
|
|
77
|
-
}());
|
|
78
|
-
export { MapPoly };
|
|
79
|
-
/**
|
|
80
|
-
* return the Map constructor to use. If native Map is not available or it doesn't support the required features (e.g., IE11),
|
|
81
|
-
* a ponyfill with minimal features is returned instead.
|
|
82
|
-
*
|
|
83
|
-
* Exported for testing purposes only.
|
|
84
|
-
*/
|
|
85
|
-
export function __getMapConstructor() {
|
|
86
|
-
// eslint-disable-next-line compat/compat
|
|
87
|
-
if (typeof Array.from === 'function' && typeof Map === 'function' && Map.prototype && Map.prototype.values) {
|
|
88
|
-
return Map;
|
|
89
|
-
}
|
|
90
|
-
return MapPoly;
|
|
91
|
-
}
|
|
92
|
-
export var _Map = __getMapConstructor();
|
|
@@ -1,35 +0,0 @@
|
|
|
1
|
-
import { GOOGLE_ANALYTICS_TO_SPLIT, SPLIT_TO_GOOGLE_ANALYTICS } from '../utils/constants/browser';
|
|
2
|
-
import { IIntegration, IIntegrationManager, IIntegrationFactoryParams } from './types';
|
|
3
|
-
import { BrowserIntegration } from './ga/types';
|
|
4
|
-
import { pluggableIntegrationsManagerFactory } from './pluggable';
|
|
5
|
-
import { GoogleAnalyticsToSplit } from './ga/GoogleAnalyticsToSplit';
|
|
6
|
-
import { SplitToGoogleAnalytics } from './ga/SplitToGoogleAnalytics';
|
|
7
|
-
|
|
8
|
-
/**
|
|
9
|
-
* IntegrationsManager factory for the browser variant of the isomorphic JS SDK.
|
|
10
|
-
* The integrations manager instantiates integration modules, and bypass tracked events and impressions to them.
|
|
11
|
-
*
|
|
12
|
-
* @param integrations valid integration settings object for browser sdk
|
|
13
|
-
* @param params information of the Sdk factory instance that integrations can access to
|
|
14
|
-
*
|
|
15
|
-
* @returns integration manager or undefined if `integrations` are not present in settings.
|
|
16
|
-
*/
|
|
17
|
-
export function integrationsManagerFactory(
|
|
18
|
-
integrations: BrowserIntegration[],
|
|
19
|
-
params: IIntegrationFactoryParams
|
|
20
|
-
): IIntegrationManager | undefined {
|
|
21
|
-
|
|
22
|
-
// maps integration config items into integration factories to reuse the pluggable integration manager
|
|
23
|
-
const integrationFactories: Array<(params: IIntegrationFactoryParams) => IIntegration | void> = integrations
|
|
24
|
-
.map(integrationOptions => {
|
|
25
|
-
switch (integrationOptions.type) {
|
|
26
|
-
case GOOGLE_ANALYTICS_TO_SPLIT: return GoogleAnalyticsToSplit(integrationOptions);
|
|
27
|
-
case SPLIT_TO_GOOGLE_ANALYTICS: return SplitToGoogleAnalytics(integrationOptions);
|
|
28
|
-
}
|
|
29
|
-
})
|
|
30
|
-
.filter(integrationFactory => {
|
|
31
|
-
return integrationFactory && typeof integrationFactory === 'function';
|
|
32
|
-
});
|
|
33
|
-
|
|
34
|
-
return pluggableIntegrationsManagerFactory(integrationFactories, params);
|
|
35
|
-
}
|