@splitsoftware/splitio-commons 1.17.1-rc.4 → 2.0.0-rc.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/CHANGES.txt +4 -0
- package/cjs/evaluator/Engine.js +1 -1
- package/cjs/evaluator/index.js +1 -1
- 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/sdkClient/clientCS.js +5 -8
- package/cjs/sdkClient/sdkClientMethodCS.js +1 -1
- package/cjs/services/decorateHeaders.js +1 -2
- package/cjs/storages/KeyBuilderCS.js +0 -9
- package/cjs/storages/inLocalStorage/MySegmentsCacheInLocal.js +1 -21
- package/cjs/storages/inLocalStorage/SplitsCacheInLocal.js +4 -4
- package/cjs/storages/inLocalStorage/index.js +1 -1
- package/cjs/storages/inMemory/InMemoryStorageCS.js +1 -1
- package/cjs/storages/inMemory/SegmentsCacheInMemory.js +2 -3
- package/cjs/storages/inMemory/SplitsCacheInMemory.js +2 -3
- package/cjs/storages/inMemory/UniqueKeysCacheInMemory.js +2 -2
- package/cjs/storages/inMemory/UniqueKeysCacheInMemoryCS.js +2 -2
- package/cjs/storages/inRedis/RedisAdapter.js +2 -2
- package/cjs/storages/inRedis/SplitsCacheInRedis.js +1 -1
- package/cjs/storages/inRedis/TelemetryCacheInRedis.js +3 -4
- package/cjs/storages/inRedis/UniqueKeysCacheInRedis.js +1 -1
- package/cjs/storages/pluggable/SplitsCachePluggable.js +1 -1
- package/cjs/storages/pluggable/TelemetryCachePluggable.js +6 -7
- package/cjs/storages/pluggable/UniqueKeysCachePluggable.js +1 -1
- package/cjs/storages/pluggable/inMemoryWrapper.js +6 -6
- package/cjs/sync/polling/updaters/splitChangesUpdater.js +3 -3
- package/cjs/sync/streaming/parseUtils.js +0 -1
- package/cjs/sync/streaming/pushManager.js +2 -3
- 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 +10 -107
- package/cjs/utils/settingsValidation/index.js +0 -9
- package/cjs/utils/settingsValidation/logger/builtinLogger.js +1 -2
- package/esm/evaluator/Engine.js +1 -1
- package/esm/evaluator/index.js +2 -2
- 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/sdkClient/clientCS.js +5 -8
- package/esm/sdkClient/sdkClientMethodCS.js +1 -1
- package/esm/services/decorateHeaders.js +1 -2
- package/esm/storages/KeyBuilderCS.js +0 -9
- package/esm/storages/inLocalStorage/MySegmentsCacheInLocal.js +1 -21
- package/esm/storages/inLocalStorage/SplitsCacheInLocal.js +4 -4
- package/esm/storages/inLocalStorage/index.js +1 -1
- package/esm/storages/inMemory/InMemoryStorageCS.js +1 -1
- package/esm/storages/inMemory/SegmentsCacheInMemory.js +2 -3
- package/esm/storages/inMemory/SplitsCacheInMemory.js +2 -3
- package/esm/storages/inMemory/UniqueKeysCacheInMemory.js +2 -2
- package/esm/storages/inMemory/UniqueKeysCacheInMemoryCS.js +2 -2
- package/esm/storages/inRedis/RedisAdapter.js +2 -2
- package/esm/storages/inRedis/SplitsCacheInRedis.js +2 -2
- package/esm/storages/inRedis/TelemetryCacheInRedis.js +3 -4
- package/esm/storages/inRedis/UniqueKeysCacheInRedis.js +1 -1
- package/esm/storages/pluggable/SplitsCachePluggable.js +2 -2
- package/esm/storages/pluggable/TelemetryCachePluggable.js +6 -7
- package/esm/storages/pluggable/UniqueKeysCachePluggable.js +1 -1
- package/esm/storages/pluggable/inMemoryWrapper.js +7 -7
- package/esm/sync/polling/updaters/splitChangesUpdater.js +3 -3
- package/esm/sync/streaming/parseUtils.js +0 -1
- package/esm/sync/streaming/pushManager.js +2 -3
- 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 +9 -105
- package/esm/utils/settingsValidation/index.js +0 -9
- package/esm/utils/settingsValidation/logger/builtinLogger.js +1 -2
- package/package.json +2 -2
- package/src/evaluator/Engine.ts +1 -1
- package/src/evaluator/index.ts +4 -4
- 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/sdkClient/clientCS.ts +5 -8
- package/src/sdkClient/sdkClientMethodCS.ts +1 -1
- package/src/sdkFactory/types.ts +1 -1
- package/src/services/decorateHeaders.ts +1 -2
- package/src/storages/AbstractSplitsCacheAsync.ts +1 -2
- package/src/storages/AbstractSplitsCacheSync.ts +1 -2
- package/src/storages/KeyBuilderCS.ts +0 -13
- package/src/storages/inLocalStorage/MySegmentsCacheInLocal.ts +1 -21
- package/src/storages/inLocalStorage/SplitsCacheInLocal.ts +5 -5
- package/src/storages/inLocalStorage/index.ts +1 -1
- package/src/storages/inMemory/InMemoryStorageCS.ts +1 -1
- package/src/storages/inMemory/SegmentsCacheInMemory.ts +3 -4
- package/src/storages/inMemory/SplitsCacheInMemory.ts +4 -5
- package/src/storages/inMemory/UniqueKeysCacheInMemory.ts +4 -4
- package/src/storages/inMemory/UniqueKeysCacheInMemoryCS.ts +4 -4
- package/src/storages/inRedis/RedisAdapter.ts +3 -3
- package/src/storages/inRedis/SplitsCacheInRedis.ts +3 -3
- package/src/storages/inRedis/TelemetryCacheInRedis.ts +3 -4
- package/src/storages/inRedis/UniqueKeysCacheInRedis.ts +1 -1
- 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 -1
- package/src/storages/pluggable/inMemoryWrapper.ts +9 -9
- package/src/storages/types.ts +3 -4
- package/src/sync/polling/updaters/splitChangesUpdater.ts +4 -4
- 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/types.ts +1 -9
- 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 +10 -122
- package/src/utils/settingsValidation/index.ts +0 -10
- package/src/utils/settingsValidation/logger/builtinLogger.ts +1 -2
- package/src/utils/settingsValidation/types.ts +0 -2
- package/types/logger/index.d.ts +1 -2
- package/types/sdkClient/clientCS.d.ts +2 -3
- package/types/sdkFactory/types.d.ts +1 -1
- package/types/storages/AbstractSplitsCacheAsync.d.ts +1 -2
- package/types/storages/AbstractSplitsCacheSync.d.ts +1 -2
- package/types/storages/KeyBuilderCS.d.ts +0 -2
- package/types/storages/inLocalStorage/SplitsCacheInLocal.d.ts +1 -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 +3 -4
- package/types/sync/polling/updaters/splitChangesUpdater.d.ts +1 -2
- package/types/sync/submitters/types.d.ts +3 -4
- package/types/types.d.ts +1 -9
- 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 +2 -61
- package/types/utils/settingsValidation/index.d.ts +0 -1
- 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 -75
- 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 -71
- 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 -96
- package/src/utils/lang/maps.ts +0 -108
|
@@ -1,62 +1,3 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
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
|
-
export interface ISet<T> {
|
|
26
|
-
add(value: T): this;
|
|
27
|
-
clear(): void;
|
|
28
|
-
delete(value: T): boolean;
|
|
29
|
-
forEach(callbackfn: (value: T, value2: T, set: ISet<T>) => void, thisArg?: any): void;
|
|
30
|
-
has(value: T): boolean;
|
|
31
|
-
readonly size: number;
|
|
32
|
-
}
|
|
33
|
-
export declare class SetPoly<T> implements ISet<T> {
|
|
34
|
-
__setData__: T[];
|
|
35
|
-
constructor(values?: readonly T[] | null);
|
|
36
|
-
clear(): void;
|
|
37
|
-
add(value: T): this;
|
|
38
|
-
delete(value: T): boolean;
|
|
39
|
-
has(value: T): boolean;
|
|
40
|
-
forEach(callbackfn: (value: T, value2: T, set: SetPoly<T>) => void, thisArg?: any): void;
|
|
41
|
-
get size(): number;
|
|
42
|
-
}
|
|
43
|
-
/**
|
|
44
|
-
* return an array containing the items of the given set.
|
|
45
|
-
* @param set Set or SetPoly instance
|
|
46
|
-
*/
|
|
47
|
-
export declare function setToArray<T>(set: ISet<T>): T[];
|
|
48
|
-
interface ISetConstructor {
|
|
49
|
-
new <T = any>(values?: readonly T[] | null): ISet<T>;
|
|
50
|
-
readonly prototype: ISet<any>;
|
|
51
|
-
}
|
|
52
|
-
/**
|
|
53
|
-
* return the Set constructor to use. If `Array.from` built-in or native Set is not available or it doesn't support the required features,
|
|
54
|
-
* a ponyfill with minimal features is returned instead.
|
|
55
|
-
*
|
|
56
|
-
* Exported for testing purposes only.
|
|
57
|
-
*/
|
|
58
|
-
export declare function __getSetConstructor(): ISetConstructor;
|
|
59
|
-
export declare const _Set: ISetConstructor;
|
|
60
|
-
export declare function returnSetsUnion<T>(set: ISet<T>, set2: ISet<T>): ISet<T>;
|
|
1
|
+
export declare function setToArray<T>(set: Set<T>): T[];
|
|
2
|
+
export declare function returnSetsUnion<T>(set: Set<T>, set2: Set<T>): Set<T>;
|
|
61
3
|
export declare function returnDifference<T>(list?: T[], list2?: T[]): T[];
|
|
62
|
-
export {};
|
|
@@ -15,8 +15,6 @@ export interface ISettingsValidationParams {
|
|
|
15
15
|
};
|
|
16
16
|
/** If true, validates core.key */
|
|
17
17
|
acceptKey?: boolean;
|
|
18
|
-
/** If true, validates core.trafficType */
|
|
19
|
-
acceptTT?: boolean;
|
|
20
18
|
/** Define runtime values (`settings.runtime`) */
|
|
21
19
|
runtime: (settings: ISettings) => ISettings['runtime'];
|
|
22
20
|
/** Storage validator (`settings.storage`) */
|
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.integrationsManagerFactory = void 0;
|
|
4
|
-
var browser_1 = require("../utils/constants/browser");
|
|
5
|
-
var pluggable_1 = require("./pluggable");
|
|
6
|
-
var GoogleAnalyticsToSplit_1 = require("./ga/GoogleAnalyticsToSplit");
|
|
7
|
-
var SplitToGoogleAnalytics_1 = require("./ga/SplitToGoogleAnalytics");
|
|
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
|
-
function integrationsManagerFactory(integrations, params) {
|
|
18
|
-
// maps integration config items into integration factories to reuse the pluggable integration manager
|
|
19
|
-
var integrationFactories = integrations
|
|
20
|
-
.map(function (integrationOptions) {
|
|
21
|
-
switch (integrationOptions.type) {
|
|
22
|
-
case browser_1.GOOGLE_ANALYTICS_TO_SPLIT: return (0, GoogleAnalyticsToSplit_1.GoogleAnalyticsToSplit)(integrationOptions);
|
|
23
|
-
case browser_1.SPLIT_TO_GOOGLE_ANALYTICS: return (0, SplitToGoogleAnalytics_1.SplitToGoogleAnalytics)(integrationOptions);
|
|
24
|
-
}
|
|
25
|
-
})
|
|
26
|
-
.filter(function (integrationFactory) {
|
|
27
|
-
return integrationFactory && typeof integrationFactory === 'function';
|
|
28
|
-
});
|
|
29
|
-
return (0, pluggable_1.pluggableIntegrationsManagerFactory)(integrationFactories, params);
|
|
30
|
-
}
|
|
31
|
-
exports.integrationsManagerFactory = integrationsManagerFactory;
|
|
@@ -1,257 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.GaToSplit = exports.fixEventTypeId = exports.validateEventData = exports.validateIdentities = exports.defaultPrefix = exports.defaultMapper = void 0;
|
|
4
|
-
var objectAssign_1 = require("../../utils/lang/objectAssign");
|
|
5
|
-
var lang_1 = require("../../utils/lang");
|
|
6
|
-
var inputValidation_1 = require("../../utils/inputValidation");
|
|
7
|
-
var logPrefix = 'ga-to-split: ';
|
|
8
|
-
var logNameMapper = 'ga-to-split:mapper';
|
|
9
|
-
/**
|
|
10
|
-
* Provides a plugin to use with analytics.js, accounting for the possibility
|
|
11
|
-
* that the global command queue has been renamed or not yet defined.
|
|
12
|
-
* @param window Reference to global object.
|
|
13
|
-
* @param pluginName The plugin name identifier.
|
|
14
|
-
* @param pluginConstructor The plugin constructor function.
|
|
15
|
-
* @param log Logger instance.
|
|
16
|
-
* @param autoRequire If true, log error when auto-require script is not detected
|
|
17
|
-
*/
|
|
18
|
-
function providePlugin(window, pluginName, pluginConstructor, log, autoRequire, telemetryTracker) {
|
|
19
|
-
// get reference to global command queue. Init it if not defined yet.
|
|
20
|
-
var gaAlias = window.GoogleAnalyticsObject || 'ga';
|
|
21
|
-
window[gaAlias] = window[gaAlias] || function () {
|
|
22
|
-
(window[gaAlias].q = window[gaAlias].q || []).push(arguments);
|
|
23
|
-
};
|
|
24
|
-
// provides the plugin for use with analytics.js.
|
|
25
|
-
window[gaAlias]('provide', pluginName, pluginConstructor);
|
|
26
|
-
var hasAutoRequire = window[gaAlias].q && window[gaAlias].q.push !== [].push;
|
|
27
|
-
if (autoRequire && !hasAutoRequire) { // Expecting spy on ga.q push method but not found
|
|
28
|
-
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.');
|
|
29
|
-
}
|
|
30
|
-
if (telemetryTracker && hasAutoRequire) {
|
|
31
|
-
telemetryTracker.addTag('integration:ga-autorequire');
|
|
32
|
-
}
|
|
33
|
-
}
|
|
34
|
-
// Default mapping: object used for building the default mapper from hits to Split events
|
|
35
|
-
var defaultMapping = {
|
|
36
|
-
eventTypeId: {
|
|
37
|
-
event: 'eventAction',
|
|
38
|
-
social: 'socialAction',
|
|
39
|
-
},
|
|
40
|
-
eventValue: {
|
|
41
|
-
event: 'eventValue',
|
|
42
|
-
timing: 'timingValue',
|
|
43
|
-
},
|
|
44
|
-
eventProperties: {
|
|
45
|
-
pageview: ['page'],
|
|
46
|
-
screenview: ['screenName'],
|
|
47
|
-
event: ['eventCategory', 'eventLabel'],
|
|
48
|
-
social: ['socialNetwork', 'socialTarget'],
|
|
49
|
-
timing: ['timingCategory', 'timingVar', 'timingLabel'],
|
|
50
|
-
exception: ['exDescription', 'exFatal'],
|
|
51
|
-
}
|
|
52
|
-
};
|
|
53
|
-
/**
|
|
54
|
-
* Build a mapper function based on a mapping object
|
|
55
|
-
*
|
|
56
|
-
* @param {object} mapping
|
|
57
|
-
*/
|
|
58
|
-
function mapperBuilder(mapping) {
|
|
59
|
-
return function (model) {
|
|
60
|
-
var hitType = model.get('hitType');
|
|
61
|
-
// @ts-expect-error
|
|
62
|
-
var eventTypeId = model.get(mapping.eventTypeId[hitType] || 'hitType');
|
|
63
|
-
// @ts-expect-error
|
|
64
|
-
var value = model.get(mapping.eventValue[hitType]);
|
|
65
|
-
var properties = {}; // @ts-expect-error
|
|
66
|
-
var fields = mapping.eventProperties[hitType];
|
|
67
|
-
if (fields) {
|
|
68
|
-
for (var i = 0; i < fields.length; i++) {
|
|
69
|
-
var fieldValue = model.get(fields[i]);
|
|
70
|
-
if (fieldValue !== undefined)
|
|
71
|
-
properties[fields[i]] = fieldValue;
|
|
72
|
-
}
|
|
73
|
-
}
|
|
74
|
-
return {
|
|
75
|
-
eventTypeId: eventTypeId,
|
|
76
|
-
value: value,
|
|
77
|
-
properties: properties,
|
|
78
|
-
timestamp: Date.now(),
|
|
79
|
-
};
|
|
80
|
-
};
|
|
81
|
-
}
|
|
82
|
-
// exposed for unit testing purposses.
|
|
83
|
-
exports.defaultMapper = mapperBuilder(defaultMapping);
|
|
84
|
-
exports.defaultPrefix = 'ga';
|
|
85
|
-
/**
|
|
86
|
-
* Return a new list of identities removing invalid and duplicated ones.
|
|
87
|
-
*
|
|
88
|
-
* @param {Array} identities list of identities
|
|
89
|
-
* @returns list of valid and unique identities. The list might be empty if `identities` is not an array or all its elements are invalid.
|
|
90
|
-
*/
|
|
91
|
-
function validateIdentities(identities) {
|
|
92
|
-
if (!Array.isArray(identities))
|
|
93
|
-
return [];
|
|
94
|
-
// Remove duplicated identities
|
|
95
|
-
var uniqueIdentities = (0, lang_1.uniqAsStrings)(identities);
|
|
96
|
-
// Filter based on rum-agent identities validator
|
|
97
|
-
return uniqueIdentities.filter(function (identity) {
|
|
98
|
-
if (!identity)
|
|
99
|
-
return false;
|
|
100
|
-
var maybeKey = identity.key;
|
|
101
|
-
var maybeTT = identity.trafficType;
|
|
102
|
-
if (!(0, lang_1.isString)(maybeKey) && !(0, lang_1.isFiniteNumber)(maybeKey))
|
|
103
|
-
return false;
|
|
104
|
-
if (!(0, lang_1.isString)(maybeTT))
|
|
105
|
-
return false;
|
|
106
|
-
return true;
|
|
107
|
-
});
|
|
108
|
-
}
|
|
109
|
-
exports.validateIdentities = validateIdentities;
|
|
110
|
-
/**
|
|
111
|
-
* Checks if EventData fields (except EventTypeId) are valid, and logs corresponding warnings.
|
|
112
|
-
* EventTypeId is validated separately.
|
|
113
|
-
*
|
|
114
|
-
* @param {EventData} data event data instance to validate. Precondition: data != undefined
|
|
115
|
-
* @returns {boolean} Whether the data instance is a valid EventData or not.
|
|
116
|
-
*/
|
|
117
|
-
function validateEventData(log, eventData) {
|
|
118
|
-
if (!(0, inputValidation_1.validateEvent)(log, eventData.eventTypeId, logNameMapper))
|
|
119
|
-
return false;
|
|
120
|
-
if ((0, inputValidation_1.validateEventValue)(log, eventData.value, logNameMapper) === false)
|
|
121
|
-
return false;
|
|
122
|
-
var properties = (0, inputValidation_1.validateEventProperties)(log, eventData.properties, logNameMapper).properties;
|
|
123
|
-
if (properties === false)
|
|
124
|
-
return false;
|
|
125
|
-
if (eventData.timestamp && !(0, lang_1.isFiniteNumber)(eventData.timestamp))
|
|
126
|
-
return false;
|
|
127
|
-
if (eventData.key && (0, inputValidation_1.validateKey)(log, eventData.key, logNameMapper) === false)
|
|
128
|
-
return false;
|
|
129
|
-
if (eventData.trafficTypeName && (0, inputValidation_1.validateTrafficType)(log, eventData.trafficTypeName, logNameMapper) === false)
|
|
130
|
-
return false;
|
|
131
|
-
return true;
|
|
132
|
-
}
|
|
133
|
-
exports.validateEventData = validateEventData;
|
|
134
|
-
var INVALID_PREFIX_REGEX = /^[^a-zA-Z0-9]+/;
|
|
135
|
-
var INVALID_SUBSTRING_REGEX = /[^-_.:a-zA-Z0-9]+/g;
|
|
136
|
-
/**
|
|
137
|
-
* Fixes the passed string value to comply with EventTypeId format, by removing invalid characters and truncating if necessary.
|
|
138
|
-
*
|
|
139
|
-
* @param {object} log factory logger
|
|
140
|
-
* @param {string} eventTypeId string value to fix.
|
|
141
|
-
* @returns {string} Fixed version of `eventTypeId`.
|
|
142
|
-
*/
|
|
143
|
-
function fixEventTypeId(log, eventTypeId) {
|
|
144
|
-
// return the input eventTypeId if it cannot be fixed
|
|
145
|
-
if (!(0, lang_1.isString)(eventTypeId) || eventTypeId.length === 0) {
|
|
146
|
-
return eventTypeId;
|
|
147
|
-
}
|
|
148
|
-
// replace invalid substrings and truncate
|
|
149
|
-
var fixed = eventTypeId
|
|
150
|
-
.replace(INVALID_PREFIX_REGEX, '')
|
|
151
|
-
.replace(INVALID_SUBSTRING_REGEX, '_');
|
|
152
|
-
var truncated = fixed.slice(0, 80);
|
|
153
|
-
if (truncated.length < fixed.length)
|
|
154
|
-
log.warn(logPrefix + 'EventTypeId was truncated because it cannot be more than 80 characters long.');
|
|
155
|
-
return truncated;
|
|
156
|
-
}
|
|
157
|
-
exports.fixEventTypeId = fixEventTypeId;
|
|
158
|
-
/**
|
|
159
|
-
* GaToSplit integration.
|
|
160
|
-
* This function provides the SplitTracker plugin to ga command queue.
|
|
161
|
-
*
|
|
162
|
-
* @param {object} sdkOptions options passed at the SDK integrations settings (isomorphic SDK) or the GoogleAnalyticsToSplit plugin (pluggable browser SDK)
|
|
163
|
-
* @param {object} storage SDK storage passed to track events
|
|
164
|
-
* @param {object} coreSettings core settings used to define an identity if no one provided as SDK or plugin options
|
|
165
|
-
* @param {object} log factory logger
|
|
166
|
-
*/
|
|
167
|
-
function GaToSplit(sdkOptions, params) {
|
|
168
|
-
var storage = params.storage, _a = params.settings, coreSettings = _a.core, log = _a.log, telemetryTracker = params.telemetryTracker;
|
|
169
|
-
var defaultOptions = {
|
|
170
|
-
prefix: exports.defaultPrefix,
|
|
171
|
-
// We set default identities if key and TT are present in settings.core
|
|
172
|
-
identities: (coreSettings.key && coreSettings.trafficType) ?
|
|
173
|
-
[{ key: coreSettings.key, trafficType: coreSettings.trafficType }] :
|
|
174
|
-
undefined
|
|
175
|
-
};
|
|
176
|
-
var SplitTracker = /** @class */ (function () {
|
|
177
|
-
// Constructor for the SplitTracker plugin.
|
|
178
|
-
function SplitTracker(tracker, pluginOptions) {
|
|
179
|
-
// precedence of options: SDK options (config.integrations) overwrite pluginOptions (`ga('require', 'splitTracker', pluginOptions)`)
|
|
180
|
-
var opts = (0, objectAssign_1.objectAssign)({}, defaultOptions, sdkOptions, pluginOptions);
|
|
181
|
-
this.tracker = tracker;
|
|
182
|
-
// Validate identities
|
|
183
|
-
var validIdentities = validateIdentities(opts.identities);
|
|
184
|
-
if (validIdentities.length === 0) {
|
|
185
|
-
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.');
|
|
186
|
-
return;
|
|
187
|
-
}
|
|
188
|
-
var invalids = validIdentities.length - opts.identities.length;
|
|
189
|
-
if (invalids) {
|
|
190
|
-
log.warn(logPrefix + (invalids + " identities were discarded because they are invalid or duplicated. Identities must be an array of objects with key and trafficType."));
|
|
191
|
-
}
|
|
192
|
-
opts.identities = validIdentities;
|
|
193
|
-
// Validate prefix
|
|
194
|
-
if (!(0, lang_1.isString)(opts.prefix)) {
|
|
195
|
-
log.warn(logPrefix + 'The provided `prefix` was ignored since it is invalid. Please check that you are passing a string object as `prefix`.');
|
|
196
|
-
opts.prefix = undefined;
|
|
197
|
-
}
|
|
198
|
-
// Overwrite sendHitTask to perform plugin tasks:
|
|
199
|
-
// 1) filter hits
|
|
200
|
-
// 2) map hits to Split events
|
|
201
|
-
// 3) handle events, i.e., validate and send them to Split BE
|
|
202
|
-
var originalSendHitTask = tracker.get('sendHitTask');
|
|
203
|
-
tracker.set('sendHitTask', function (model) {
|
|
204
|
-
originalSendHitTask(model);
|
|
205
|
-
// filter hit if `hits` flag is false or if it comes from Split-to-GA integration
|
|
206
|
-
if (opts.hits === false || model.get('splitHit'))
|
|
207
|
-
return;
|
|
208
|
-
try {
|
|
209
|
-
if (opts.filter && !opts.filter(model))
|
|
210
|
-
return;
|
|
211
|
-
}
|
|
212
|
-
catch (err) {
|
|
213
|
-
log.warn(logPrefix + ("custom filter threw: " + err));
|
|
214
|
-
return;
|
|
215
|
-
}
|
|
216
|
-
// map hit into an EventData instance
|
|
217
|
-
var eventData = (0, exports.defaultMapper)(model);
|
|
218
|
-
if (opts.mapper) {
|
|
219
|
-
try {
|
|
220
|
-
eventData = opts.mapper(model, eventData);
|
|
221
|
-
}
|
|
222
|
-
catch (err) {
|
|
223
|
-
log.warn(logPrefix + ("custom mapper threw: " + err));
|
|
224
|
-
return;
|
|
225
|
-
}
|
|
226
|
-
if (!eventData)
|
|
227
|
-
return;
|
|
228
|
-
}
|
|
229
|
-
// Add prefix. Nothing is appended if the prefix is falsy, e.g. undefined or ''.
|
|
230
|
-
if (opts.prefix)
|
|
231
|
-
eventData.eventTypeId = opts.prefix + "." + eventData.eventTypeId;
|
|
232
|
-
eventData.eventTypeId = fixEventTypeId(log, eventData.eventTypeId);
|
|
233
|
-
if (!validateEventData(log, eventData))
|
|
234
|
-
return;
|
|
235
|
-
// Store the event
|
|
236
|
-
if (eventData.key && eventData.trafficTypeName) {
|
|
237
|
-
storage.events.track(eventData);
|
|
238
|
-
}
|
|
239
|
-
else { // Store the event for each Key-TT pair (identities), if key and TT is not present in eventData
|
|
240
|
-
opts.identities.forEach(function (identity) {
|
|
241
|
-
var event = (0, objectAssign_1.objectAssign)({
|
|
242
|
-
key: identity.key,
|
|
243
|
-
trafficTypeName: identity.trafficType,
|
|
244
|
-
}, eventData);
|
|
245
|
-
storage.events.track(event);
|
|
246
|
-
});
|
|
247
|
-
}
|
|
248
|
-
});
|
|
249
|
-
log.info(logPrefix + 'integration started');
|
|
250
|
-
}
|
|
251
|
-
return SplitTracker;
|
|
252
|
-
}());
|
|
253
|
-
// Register the plugin, even if config is invalid, since, if not provided, it will block `ga` command queue.
|
|
254
|
-
// eslint-disable-next-line no-undef
|
|
255
|
-
providePlugin(window, 'splitTracker', SplitTracker, log, sdkOptions.autoRequire === true, telemetryTracker);
|
|
256
|
-
}
|
|
257
|
-
exports.GaToSplit = GaToSplit;
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.GoogleAnalyticsToSplit = void 0;
|
|
4
|
-
var GaToSplit_1 = require("./GaToSplit");
|
|
5
|
-
function GoogleAnalyticsToSplit(options) {
|
|
6
|
-
if (options === void 0) { options = {}; }
|
|
7
|
-
// GaToSplit integration factory
|
|
8
|
-
function GoogleAnalyticsToSplitFactory(params) {
|
|
9
|
-
return (0, GaToSplit_1.GaToSplit)(options, params);
|
|
10
|
-
}
|
|
11
|
-
GoogleAnalyticsToSplitFactory.type = 'GOOGLE_ANALYTICS_TO_SPLIT';
|
|
12
|
-
return GoogleAnalyticsToSplitFactory;
|
|
13
|
-
}
|
|
14
|
-
exports.GoogleAnalyticsToSplit = GoogleAnalyticsToSplit;
|
|
@@ -1,123 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.SplitToGa = void 0;
|
|
4
|
-
/* eslint-disable no-undef */
|
|
5
|
-
var lang_1 = require("../../utils/lang");
|
|
6
|
-
var constants_1 = require("../../utils/constants");
|
|
7
|
-
var logPrefix = 'split-to-ga: ';
|
|
8
|
-
var noGaWarning = '`ga` command queue not found.';
|
|
9
|
-
var noHit = 'No hit was sent.';
|
|
10
|
-
var SplitToGa = /** @class */ (function () {
|
|
11
|
-
/**
|
|
12
|
-
* constructor description
|
|
13
|
-
* @param {object} options options passed at the SDK integrations settings (isomorphic SDK) or the SplitToGoogleAnalytics plugin (pluggable browser SDK)
|
|
14
|
-
*/
|
|
15
|
-
function SplitToGa(log, options) {
|
|
16
|
-
this.trackerNames = SplitToGa.defaultTrackerNames;
|
|
17
|
-
this.log = log;
|
|
18
|
-
if (options) {
|
|
19
|
-
if (typeof options.filter === 'function')
|
|
20
|
-
this.filter = options.filter;
|
|
21
|
-
if (typeof options.mapper === 'function')
|
|
22
|
-
this.mapper = options.mapper;
|
|
23
|
-
// We strip off duplicated values if we received a `trackerNames` param.
|
|
24
|
-
// We don't warn if a tracker does not exist, since the user might create it after the SDK is initialized.
|
|
25
|
-
// Note: GA allows to create and get trackers using a string or number as tracker name, and does nothing if other types are used.
|
|
26
|
-
if (Array.isArray(options.trackerNames))
|
|
27
|
-
this.trackerNames = (0, lang_1.uniq)(options.trackerNames);
|
|
28
|
-
// No need to validate `impressions` and `events` flags. Any other value than `false` is ignored (considered true by default).
|
|
29
|
-
this.impressions = options.impressions;
|
|
30
|
-
this.events = options.events;
|
|
31
|
-
}
|
|
32
|
-
log.info(logPrefix + 'integration started');
|
|
33
|
-
if (typeof SplitToGa.getGa() !== 'function')
|
|
34
|
-
log.warn(logPrefix + (noGaWarning + " No hits will be sent until it is available."));
|
|
35
|
-
}
|
|
36
|
-
// Default mapper function.
|
|
37
|
-
SplitToGa.defaultMapper = function (_a) {
|
|
38
|
-
var type = _a.type, payload = _a.payload;
|
|
39
|
-
switch (type) {
|
|
40
|
-
case constants_1.SPLIT_IMPRESSION:
|
|
41
|
-
return {
|
|
42
|
-
hitType: 'event',
|
|
43
|
-
eventCategory: 'split-impression',
|
|
44
|
-
eventAction: 'Evaluate ' + payload.impression.feature,
|
|
45
|
-
eventLabel: 'Treatment: ' + payload.impression.treatment + '. Targeting rule: ' + payload.impression.label + '.',
|
|
46
|
-
nonInteraction: true,
|
|
47
|
-
};
|
|
48
|
-
case constants_1.SPLIT_EVENT:
|
|
49
|
-
return {
|
|
50
|
-
hitType: 'event',
|
|
51
|
-
eventCategory: 'split-event',
|
|
52
|
-
eventAction: payload.eventTypeId,
|
|
53
|
-
eventValue: payload.value,
|
|
54
|
-
nonInteraction: true,
|
|
55
|
-
};
|
|
56
|
-
}
|
|
57
|
-
};
|
|
58
|
-
// Util to access ga command queue, accounting for the possibility that it has been renamed.
|
|
59
|
-
SplitToGa.getGa = function () {
|
|
60
|
-
return typeof window !== 'undefined' ? window[window['GoogleAnalyticsObject'] || 'ga'] : undefined;
|
|
61
|
-
};
|
|
62
|
-
/**
|
|
63
|
-
* Validates if a given object is a UniversalAnalytics.FieldsObject instance, and logs a warning if not.
|
|
64
|
-
* It checks that the object contains a `hitType`, since it is the minimal field required to send the hit
|
|
65
|
-
* and avoid the GA error `No hit type specified. Aborting hit.`.
|
|
66
|
-
* Other validations (e.g., an `event` hitType must have a `eventCategory` and `eventAction`) are handled
|
|
67
|
-
* and logged (as warnings or errors depending the case) by GA debugger, but the hit is sent anyway.
|
|
68
|
-
*
|
|
69
|
-
* @param {object} log factory logger
|
|
70
|
-
* @param {UniversalAnalytics.FieldsObject} fieldsObject object to validate.
|
|
71
|
-
* @returns {boolean} Whether the data instance is a valid FieldsObject or not.
|
|
72
|
-
*/
|
|
73
|
-
SplitToGa.validateFieldsObject = function (log, fieldsObject) {
|
|
74
|
-
if (fieldsObject && fieldsObject.hitType)
|
|
75
|
-
return true;
|
|
76
|
-
log.warn(logPrefix + 'your custom mapper returned an invalid FieldsObject instance. It must be an object with at least a `hitType` field.');
|
|
77
|
-
return false;
|
|
78
|
-
};
|
|
79
|
-
SplitToGa.prototype.queue = function (data) {
|
|
80
|
-
// access ga command queue via `getGa` method, accounting for the possibility that
|
|
81
|
-
// the global `ga` reference was not yet mutated by analytics.js.
|
|
82
|
-
var ga = SplitToGa.getGa();
|
|
83
|
-
if (ga) {
|
|
84
|
-
if (this.impressions === false && data.type === constants_1.SPLIT_IMPRESSION)
|
|
85
|
-
return;
|
|
86
|
-
if (this.events === false && data.type === constants_1.SPLIT_EVENT)
|
|
87
|
-
return;
|
|
88
|
-
var fieldsObject_1;
|
|
89
|
-
try { // only try/catch filter and mapper, which might be defined by the user
|
|
90
|
-
// filter
|
|
91
|
-
if (this.filter && !this.filter(data))
|
|
92
|
-
return;
|
|
93
|
-
// map data into a FieldsObject instance
|
|
94
|
-
fieldsObject_1 = SplitToGa.defaultMapper(data);
|
|
95
|
-
if (this.mapper) {
|
|
96
|
-
fieldsObject_1 = this.mapper(data, fieldsObject_1);
|
|
97
|
-
// don't send the hit if it is falsy or invalid
|
|
98
|
-
if (!fieldsObject_1 || !SplitToGa.validateFieldsObject(this.log, fieldsObject_1))
|
|
99
|
-
return;
|
|
100
|
-
}
|
|
101
|
-
}
|
|
102
|
-
catch (err) {
|
|
103
|
-
this.log.warn(logPrefix + ("queue method threw: " + err + ". " + noHit));
|
|
104
|
-
return;
|
|
105
|
-
}
|
|
106
|
-
// send the hit
|
|
107
|
-
this.trackerNames.forEach(function (trackerName) {
|
|
108
|
-
var sendCommand = trackerName ? trackerName + ".send" : 'send';
|
|
109
|
-
// mark the hit as a Split one to avoid the loop.
|
|
110
|
-
fieldsObject_1.splitHit = true;
|
|
111
|
-
// Send to GA using our reference to the GA object.
|
|
112
|
-
ga(sendCommand, fieldsObject_1);
|
|
113
|
-
});
|
|
114
|
-
}
|
|
115
|
-
else {
|
|
116
|
-
this.log.warn(logPrefix + (noGaWarning + " " + noHit));
|
|
117
|
-
}
|
|
118
|
-
};
|
|
119
|
-
// A falsy object represents the default tracker
|
|
120
|
-
SplitToGa.defaultTrackerNames = [''];
|
|
121
|
-
return SplitToGa;
|
|
122
|
-
}());
|
|
123
|
-
exports.SplitToGa = SplitToGa;
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.SplitToGoogleAnalytics = void 0;
|
|
4
|
-
var SplitToGa_1 = require("./SplitToGa");
|
|
5
|
-
function SplitToGoogleAnalytics(options) {
|
|
6
|
-
if (options === void 0) { options = {}; }
|
|
7
|
-
// SplitToGa integration factory
|
|
8
|
-
function SplitToGoogleAnalyticsFactory(params) {
|
|
9
|
-
return new SplitToGa_1.SplitToGa(params.settings.log, options);
|
|
10
|
-
}
|
|
11
|
-
SplitToGoogleAnalyticsFactory.type = 'SPLIT_TO_GOOGLE_ANALYTICS';
|
|
12
|
-
return SplitToGoogleAnalyticsFactory;
|
|
13
|
-
}
|
|
14
|
-
exports.SplitToGoogleAnalytics = SplitToGoogleAnalytics;
|
|
@@ -1,75 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.sdkClientMethodCSFactory = void 0;
|
|
4
|
-
var clientCS_1 = require("./clientCS");
|
|
5
|
-
var key_1 = require("../utils/inputValidation/key");
|
|
6
|
-
var trafficType_1 = require("../utils/inputValidation/trafficType");
|
|
7
|
-
var key_2 = require("../utils/key");
|
|
8
|
-
var sdkClient_1 = require("./sdkClient");
|
|
9
|
-
var objectAssign_1 = require("../utils/lang/objectAssign");
|
|
10
|
-
var constants_1 = require("../logger/constants");
|
|
11
|
-
var constants_2 = require("../readiness/constants");
|
|
12
|
-
var identity_1 = require("./identity");
|
|
13
|
-
/**
|
|
14
|
-
* Factory of client method for the client-side (browser) variant of the Isomorphic JS SDK,
|
|
15
|
-
* where clients can have a bound TT for the track method, which is provided via the settings
|
|
16
|
-
* (default client) or the client method (shared clients).
|
|
17
|
-
*/
|
|
18
|
-
function sdkClientMethodCSFactory(params) {
|
|
19
|
-
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;
|
|
20
|
-
var mainClientInstance = (0, clientCS_1.clientCSDecorator)(log, (0, sdkClient_1.sdkClientFactory)(params), key, trafficType);
|
|
21
|
-
var parsedDefaultKey = (0, key_2.keyParser)(key);
|
|
22
|
-
var defaultInstanceId = (0, identity_1.buildInstanceId)(parsedDefaultKey, trafficType);
|
|
23
|
-
// Cache instances created per factory.
|
|
24
|
-
clients[defaultInstanceId] = mainClientInstance;
|
|
25
|
-
return function client(key, trafficType) {
|
|
26
|
-
if (key === undefined) {
|
|
27
|
-
log.debug(constants_1.RETRIEVE_CLIENT_DEFAULT);
|
|
28
|
-
return mainClientInstance;
|
|
29
|
-
}
|
|
30
|
-
// Validate the key value
|
|
31
|
-
var validKey = (0, key_1.validateKey)(log, key, constants_1.LOG_PREFIX_CLIENT_INSTANTIATION);
|
|
32
|
-
if (validKey === false) {
|
|
33
|
-
throw new Error('Shared Client needs a valid key.');
|
|
34
|
-
}
|
|
35
|
-
var validTrafficType;
|
|
36
|
-
if (trafficType !== undefined) {
|
|
37
|
-
validTrafficType = (0, trafficType_1.validateTrafficType)(log, trafficType, constants_1.LOG_PREFIX_CLIENT_INSTANTIATION);
|
|
38
|
-
if (validTrafficType === false) {
|
|
39
|
-
throw new Error('Shared Client needs a valid traffic type or no traffic type at all.');
|
|
40
|
-
}
|
|
41
|
-
}
|
|
42
|
-
var instanceId = (0, identity_1.buildInstanceId)(validKey, validTrafficType);
|
|
43
|
-
if (!clients[instanceId]) {
|
|
44
|
-
var matchingKey = (0, key_2.getMatching)(validKey);
|
|
45
|
-
var sharedSdkReadiness_1 = sdkReadinessManager.shared();
|
|
46
|
-
var sharedStorage = storage.shared && storage.shared(matchingKey, function (err) {
|
|
47
|
-
if (err) {
|
|
48
|
-
sharedSdkReadiness_1.readinessManager.timeout();
|
|
49
|
-
return;
|
|
50
|
-
}
|
|
51
|
-
// Emit SDK_READY in consumer mode for shared clients
|
|
52
|
-
sharedSdkReadiness_1.readinessManager.segments.emit(constants_2.SDK_SEGMENTS_ARRIVED);
|
|
53
|
-
});
|
|
54
|
-
// 3 possibilities:
|
|
55
|
-
// - Standalone mode: both syncManager and sharedSyncManager are defined
|
|
56
|
-
// - Consumer mode: both syncManager and sharedSyncManager are undefined
|
|
57
|
-
// - Consumer partial mode: syncManager is defined (only for submitters) but sharedSyncManager is undefined
|
|
58
|
-
// @ts-ignore
|
|
59
|
-
var sharedSyncManager = syncManager && sharedStorage && syncManager.shared(matchingKey, sharedSdkReadiness_1.readinessManager, sharedStorage);
|
|
60
|
-
// As shared clients reuse all the storage information, we don't need to check here if we
|
|
61
|
-
// will use offline or online mode. We should stick with the original decision.
|
|
62
|
-
clients[instanceId] = (0, clientCS_1.clientCSDecorator)(log, (0, sdkClient_1.sdkClientFactory)((0, objectAssign_1.objectAssign)({}, params, {
|
|
63
|
-
sdkReadinessManager: sharedSdkReadiness_1,
|
|
64
|
-
storage: sharedStorage || storage,
|
|
65
|
-
syncManager: sharedSyncManager,
|
|
66
|
-
}), true), validKey, validTrafficType);
|
|
67
|
-
log.info(constants_1.NEW_SHARED_CLIENT);
|
|
68
|
-
}
|
|
69
|
-
else {
|
|
70
|
-
log.debug(constants_1.RETRIEVE_CLIENT_EXISTING);
|
|
71
|
-
}
|
|
72
|
-
return clients[instanceId];
|
|
73
|
-
};
|
|
74
|
-
}
|
|
75
|
-
exports.sdkClientMethodCSFactory = sdkClientMethodCSFactory;
|