@uniformdev/optimize-tracker
Advanced tools
Comparing version 3.0.1-alpha.15 to 3.0.1-alpha.39
@@ -21,4 +21,4 @@ "use strict"; | ||
var scopeStorage = inMemory_1.inMemoryScopeStorage(); | ||
var activityStorage = inMemory_1.inMemoryActivityStorage(); | ||
var scoringStorage = inMemory_1.inMemoryScoringStorage(); | ||
var testStorage = inMemory_1.inMemoryTestStorage(); | ||
var tracker = new tracker_1.OptimizeTracker(__assign({ scopes: { | ||
@@ -28,3 +28,3 @@ visit: visitScopeStrategy_1.createVisitScopeStrategy(scopeStorage), | ||
}, storage: { | ||
activities: activityStorage, | ||
tests: testStorage, | ||
scopes: scopeStorage, | ||
@@ -31,0 +31,0 @@ scoring: scoringStorage, |
@@ -1,2 +0,7 @@ | ||
import { AnalyticsEventEmitter } from '@uniformdev/optimize-tracker-common'; | ||
export declare const AnalyticsEmitter: AnalyticsEventEmitter; | ||
import { AnalyticsEventEmitter, AnalyticsEventEmitterOptions } from '@uniformdev/optimize-tracker-common'; | ||
export declare const resolveAnalyticsEmitter: ({ active, options, }: { | ||
options: AnalyticsEventEmitterOptions; | ||
active: boolean; | ||
}) => AnalyticsEventEmitter; | ||
export declare const NoopAnalyticsEmitter: () => AnalyticsEventEmitter; | ||
export declare const AnalyticsEmitter: (options: AnalyticsEventEmitterOptions) => AnalyticsEventEmitter; |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.AnalyticsEmitter = void 0; | ||
exports.AnalyticsEmitter = exports.NoopAnalyticsEmitter = exports.resolveAnalyticsEmitter = void 0; | ||
var resolveAnalyticsEmitter = function (_a) { | ||
var active = _a.active, options = _a.options; | ||
if (!active || typeof window === 'undefined') { | ||
return exports.NoopAnalyticsEmitter(); | ||
} | ||
return exports.AnalyticsEmitter(options); | ||
}; | ||
exports.resolveAnalyticsEmitter = resolveAnalyticsEmitter; | ||
var NoopAnalyticsEmitter = function () { | ||
return { | ||
personalization: function () { | ||
return false; | ||
}, | ||
test: function () { | ||
return false; | ||
}, | ||
}; | ||
}; | ||
exports.NoopAnalyticsEmitter = NoopAnalyticsEmitter; | ||
var AnalyticsEmitter = function (_a) { | ||
var tracker = _a.tracker, name = _a.name; | ||
var PersonalizationCategory = 'Uniform Personalization'; | ||
var PersonalizationDefaultLabel = 'Default'; | ||
return { | ||
@@ -14,5 +31,5 @@ personalization: function (_a) { | ||
} | ||
var description = matches && matches.length ? matches.join(', ') : PersonalizationDefaultLabel; | ||
var description = matches && matches.length ? matches.join(', ') : 'Default'; | ||
tracker.trackPersonalization(name, { | ||
category: PersonalizationCategory, | ||
category: 'Uniform Personalization', | ||
label: description, | ||
@@ -24,4 +41,15 @@ value: includedInTest, | ||
}, | ||
test: function (_a) { | ||
var testName = _a.testName, testSelection = _a.testSelection, componentName = _a.componentName; | ||
if (!tracker || !tracker.isInitialized()) { | ||
return false; | ||
} | ||
tracker.trackPersonalization(testName + " | " + document.title + " | " + componentName, { | ||
category: 'Uniform AB Testing', | ||
label: !testSelection ? 'No Variant' : testSelection, | ||
}); | ||
return true; | ||
}, | ||
}; | ||
}; | ||
exports.AnalyticsEmitter = AnalyticsEmitter; |
import { TrackerLogLevels, TrackerPlugin } from '@uniformdev/optimize-tracker-common'; | ||
declare global { | ||
interface Window { | ||
__UNIFORM_APP_LISTENER__: ({ type, message }: { | ||
type: string; | ||
message: any; | ||
}) => void; | ||
} | ||
} | ||
declare type BrowserExtensionOptions = { | ||
disabled?: boolean; | ||
logLevelThreshold?: TrackerLogLevels; | ||
disableEventListeners?: boolean; | ||
interfaceObject?: Pick<Window, 'addEventListener' | 'postMessage'>; | ||
}; | ||
export declare const addBrowserExtension: (options?: BrowserExtensionOptions | undefined) => TrackerPlugin; | ||
export {}; |
"use strict"; | ||
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { | ||
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } | ||
return new (P || (P = Promise))(function (resolve, reject) { | ||
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } | ||
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } | ||
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); } | ||
step((generator = generator.apply(thisArg, _arguments || [])).next()); | ||
}); | ||
}; | ||
var __generator = (this && this.__generator) || function (thisArg, body) { | ||
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g; | ||
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g; | ||
function verb(n) { return function (v) { return step([n, v]); }; } | ||
function step(op) { | ||
if (f) throw new TypeError("Generator is already executing."); | ||
while (_) try { | ||
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t; | ||
if (y = 0, t) op = [op[0] & 2, t.value]; | ||
switch (op[0]) { | ||
case 0: case 1: t = op; break; | ||
case 4: _.label++; return { value: op[1], done: false }; | ||
case 5: _.label++; y = op[1]; op = [0]; continue; | ||
case 7: op = _.ops.pop(); _.trys.pop(); continue; | ||
default: | ||
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; } | ||
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; } | ||
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; } | ||
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; } | ||
if (t[2]) _.ops.pop(); | ||
_.trys.pop(); continue; | ||
} | ||
op = body.call(thisArg, _); | ||
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; } | ||
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true }; | ||
} | ||
}; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.addBrowserExtension = void 0; | ||
var optimize_common_1 = require("@uniformdev/optimize-common"); | ||
var optimize_tracker_common_1 = require("@uniformdev/optimize-tracker-common"); | ||
var utils_1 = require("../utils"); | ||
var addBrowserExtension = function (options) { | ||
var _a = options || {}, disabled = _a.disabled, _b = _a.logLevelThreshold, logLevelThreshold = _b === void 0 ? 'verbose' : _b; | ||
var trackerOptions; | ||
var _a = options || {}, disabled = _a.disabled, disableEventListeners = _a.disableEventListeners, interfaceObject = _a.interfaceObject, _b = _a.logLevelThreshold, logLevelThreshold = _b === void 0 ? 'verbose' : _b; | ||
var resolvedInterfaceObject = interfaceObject || (typeof window !== 'undefined' ? window : undefined); | ||
if (!disabled && !disableEventListeners) { | ||
if (typeof resolvedInterfaceObject !== 'undefined') { | ||
resolvedInterfaceObject.addEventListener('message', function (event) { return __awaiter(void 0, void 0, void 0, function () { | ||
var data, scores; | ||
return __generator(this, function (_a) { | ||
switch (_a.label) { | ||
case 0: | ||
data = event.data; | ||
if (!data) { | ||
return [2 /*return*/]; | ||
} | ||
if (!optimize_tracker_common_1.isExtensionSetScoreEvent(data)) return [3 /*break*/, 3]; | ||
scores = JSON.parse(data.scores); | ||
if (!scores) return [3 /*break*/, 3]; | ||
return [4 /*yield*/, (trackerOptions === null || trackerOptions === void 0 ? void 0 : trackerOptions.setIntentScores(optimize_common_1.Scope.Visit, {}))]; | ||
case 1: | ||
_a.sent(); | ||
return [4 /*yield*/, (trackerOptions === null || trackerOptions === void 0 ? void 0 : trackerOptions.setIntentScores(optimize_common_1.Scope.Visitor, scores))]; | ||
case 2: | ||
_a.sent(); | ||
_a.label = 3; | ||
case 3: return [2 /*return*/]; | ||
} | ||
}); | ||
}); }); | ||
} | ||
} | ||
return { | ||
name: 'browser-extension', | ||
initialize: function (options) { | ||
trackerOptions = options; | ||
}, | ||
onLogMessage: function (options) { | ||
if (!disabled && | ||
typeof window !== 'undefined' && | ||
typeof window.__UNIFORM_APP_LISTENER__ === 'function') { | ||
if (!disabled && typeof resolvedInterfaceObject !== 'undefined') { | ||
var level = options.level; | ||
@@ -18,6 +86,6 @@ var shouldOutput = utils_1.isLogLevelUnderThreshold(logLevelThreshold, level); | ||
} | ||
window.__UNIFORM_APP_LISTENER__({ | ||
resolvedInterfaceObject === null || resolvedInterfaceObject === void 0 ? void 0 : resolvedInterfaceObject.postMessage({ | ||
type: 'log', | ||
message: JSON.stringify(options), | ||
}); | ||
}, '*'); | ||
} | ||
@@ -24,0 +92,0 @@ }, |
@@ -23,1 +23,2 @@ export * from './tracker'; | ||
export * from './nesi/'; | ||
export * from './mvt/testList'; |
@@ -37,1 +37,2 @@ "use strict"; | ||
__exportStar(require("./nesi/"), exports); | ||
__exportStar(require("./mvt/testList"), exports); |
export * from './inMemoryScopeStorage'; | ||
export * from './inMemoryActivityStorage'; | ||
export * from './inMemoryScoringStorage'; | ||
export * from './inMemoryTestStorage'; |
@@ -14,3 +14,3 @@ "use strict"; | ||
__exportStar(require("./inMemoryScopeStorage"), exports); | ||
__exportStar(require("./inMemoryActivityStorage"), exports); | ||
__exportStar(require("./inMemoryScoringStorage"), exports); | ||
__exportStar(require("./inMemoryTestStorage"), exports); |
@@ -80,2 +80,3 @@ import { Tracker, TrackerOptions, LogMessageOptions, ListenerFunction, AnalyticsEventPayload, TrackerRequestContext, EvaluatedSignal, ReevaluateSignalsResults, TrackerEvent, TrackerPushEventOptions, TrackerScope, TrackerTestCheckOptions, SignalEvaluatorResult, TrackerAttribute } from '@uniformdev/optimize-tracker-common'; | ||
addIntentStrength(scope: Scope | string, valueToAdd: IntentVector): Promise<void>; | ||
setIntentScores(scope: Scope | string, valueToSet: IntentVector): Promise<void>; | ||
private applyScoring; | ||
@@ -99,3 +100,5 @@ private writeScoring; | ||
}): Promise<Record<string, number> | undefined>; | ||
getTestValue(testId: string): Promise<string | undefined>; | ||
setTestValue(testId: string, selectedVariantId: string | undefined): Promise<void>; | ||
} | ||
export {}; |
@@ -638,3 +638,5 @@ "use strict"; | ||
switch (_a.label) { | ||
case 0: return [4 /*yield*/, this.initializeScopes()]; | ||
case 0: | ||
this.log({ level: 'info', message: 'Received intent manifest', intents: this._intentManifest }); | ||
return [4 /*yield*/, this.initializeScopes()]; | ||
case 1: | ||
@@ -680,2 +682,3 @@ _a.sent(); | ||
return [4 /*yield*/, plugin.initialize({ | ||
setIntentScores: this.setIntentScores.bind(this), | ||
log: this.log.bind(this), | ||
@@ -714,3 +717,2 @@ })]; | ||
var _a; | ||
this.log({ level: 'info', message: 'Received intents', intents: intents }); | ||
var processedIntents = intents.map(function (intent) { | ||
@@ -857,2 +859,24 @@ var signals = intent.signals; | ||
}; | ||
OptimizeTracker.prototype.setIntentScores = function (scope, valueToSet) { | ||
return __awaiter(this, void 0, void 0, function () { | ||
var blankSlate; | ||
return __generator(this, function (_a) { | ||
switch (_a.label) { | ||
case 0: | ||
blankSlate = { | ||
strategy: 'blank', | ||
values: {}, | ||
updated: new Date().valueOf(), | ||
}; | ||
return [4 /*yield*/, this.applyScoring(scope, blankSlate, valueToSet, 1)]; | ||
case 1: | ||
_a.sent(); | ||
return [4 /*yield*/, this.broadcastScoring()]; | ||
case 2: | ||
_a.sent(); | ||
return [2 /*return*/]; | ||
} | ||
}); | ||
}); | ||
}; | ||
OptimizeTracker.prototype.applyScoring = function (scope, previousValue, valueToAdd, signalCount) { | ||
@@ -902,3 +926,3 @@ var scoring = this._scoringStrategy({ | ||
_a.sent(); | ||
return [4 /*yield*/, this._storage.activities.delete()]; | ||
return [4 /*yield*/, this._storage.tests.delete()]; | ||
case 2: | ||
@@ -1054,4 +1078,10 @@ _a.sent(); | ||
}; | ||
OptimizeTracker.prototype.getTestValue = function (testId) { | ||
return this._storage.tests.getTestSelection(testId); | ||
}; | ||
OptimizeTracker.prototype.setTestValue = function (testId, selectedVariantId) { | ||
return this._storage.tests.setTestSelection(testId, selectedVariantId); | ||
}; | ||
return OptimizeTracker; | ||
}()); | ||
exports.OptimizeTracker = OptimizeTracker; |
@@ -15,7 +15,7 @@ var __assign = (this && this.__assign) || function () { | ||
import { createVisitScopeStrategy } from '../scope/visitScopeStrategy'; | ||
import { inMemoryScopeStorage, inMemoryActivityStorage, inMemoryScoringStorage } from '../storage/inMemory'; | ||
import { inMemoryScopeStorage, inMemoryScoringStorage, inMemoryTestStorage } from '../storage/inMemory'; | ||
export var buildTestingTracker = function (options) { | ||
var scopeStorage = inMemoryScopeStorage(); | ||
var activityStorage = inMemoryActivityStorage(); | ||
var scoringStorage = inMemoryScoringStorage(); | ||
var testStorage = inMemoryTestStorage(); | ||
var tracker = new OptimizeTracker(__assign({ scopes: { | ||
@@ -25,3 +25,3 @@ visit: createVisitScopeStrategy(scopeStorage), | ||
}, storage: { | ||
activities: activityStorage, | ||
tests: testStorage, | ||
scopes: scopeStorage, | ||
@@ -28,0 +28,0 @@ scoring: scoringStorage, |
@@ -1,2 +0,7 @@ | ||
import { AnalyticsEventEmitter } from '@uniformdev/optimize-tracker-common'; | ||
export declare const AnalyticsEmitter: AnalyticsEventEmitter; | ||
import { AnalyticsEventEmitter, AnalyticsEventEmitterOptions } from '@uniformdev/optimize-tracker-common'; | ||
export declare const resolveAnalyticsEmitter: ({ active, options, }: { | ||
options: AnalyticsEventEmitterOptions; | ||
active: boolean; | ||
}) => AnalyticsEventEmitter; | ||
export declare const NoopAnalyticsEmitter: () => AnalyticsEventEmitter; | ||
export declare const AnalyticsEmitter: (options: AnalyticsEventEmitterOptions) => AnalyticsEventEmitter; |
@@ -0,5 +1,20 @@ | ||
export var resolveAnalyticsEmitter = function (_a) { | ||
var active = _a.active, options = _a.options; | ||
if (!active || typeof window === 'undefined') { | ||
return NoopAnalyticsEmitter(); | ||
} | ||
return AnalyticsEmitter(options); | ||
}; | ||
export var NoopAnalyticsEmitter = function () { | ||
return { | ||
personalization: function () { | ||
return false; | ||
}, | ||
test: function () { | ||
return false; | ||
}, | ||
}; | ||
}; | ||
export var AnalyticsEmitter = function (_a) { | ||
var tracker = _a.tracker, name = _a.name; | ||
var PersonalizationCategory = 'Uniform Personalization'; | ||
var PersonalizationDefaultLabel = 'Default'; | ||
return { | ||
@@ -11,5 +26,5 @@ personalization: function (_a) { | ||
} | ||
var description = matches && matches.length ? matches.join(', ') : PersonalizationDefaultLabel; | ||
var description = matches && matches.length ? matches.join(', ') : 'Default'; | ||
tracker.trackPersonalization(name, { | ||
category: PersonalizationCategory, | ||
category: 'Uniform Personalization', | ||
label: description, | ||
@@ -21,3 +36,14 @@ value: includedInTest, | ||
}, | ||
test: function (_a) { | ||
var testName = _a.testName, testSelection = _a.testSelection, componentName = _a.componentName; | ||
if (!tracker || !tracker.isInitialized()) { | ||
return false; | ||
} | ||
tracker.trackPersonalization(testName + " | " + document.title + " | " + componentName, { | ||
category: 'Uniform AB Testing', | ||
label: !testSelection ? 'No Variant' : testSelection, | ||
}); | ||
return true; | ||
}, | ||
}; | ||
}; |
import { TrackerLogLevels, TrackerPlugin } from '@uniformdev/optimize-tracker-common'; | ||
declare global { | ||
interface Window { | ||
__UNIFORM_APP_LISTENER__: ({ type, message }: { | ||
type: string; | ||
message: any; | ||
}) => void; | ||
} | ||
} | ||
declare type BrowserExtensionOptions = { | ||
disabled?: boolean; | ||
logLevelThreshold?: TrackerLogLevels; | ||
disableEventListeners?: boolean; | ||
interfaceObject?: Pick<Window, 'addEventListener' | 'postMessage'>; | ||
}; | ||
export declare const addBrowserExtension: (options?: BrowserExtensionOptions | undefined) => TrackerPlugin; | ||
export {}; |
@@ -0,10 +1,78 @@ | ||
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { | ||
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } | ||
return new (P || (P = Promise))(function (resolve, reject) { | ||
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } | ||
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } | ||
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); } | ||
step((generator = generator.apply(thisArg, _arguments || [])).next()); | ||
}); | ||
}; | ||
var __generator = (this && this.__generator) || function (thisArg, body) { | ||
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g; | ||
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g; | ||
function verb(n) { return function (v) { return step([n, v]); }; } | ||
function step(op) { | ||
if (f) throw new TypeError("Generator is already executing."); | ||
while (_) try { | ||
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t; | ||
if (y = 0, t) op = [op[0] & 2, t.value]; | ||
switch (op[0]) { | ||
case 0: case 1: t = op; break; | ||
case 4: _.label++; return { value: op[1], done: false }; | ||
case 5: _.label++; y = op[1]; op = [0]; continue; | ||
case 7: op = _.ops.pop(); _.trys.pop(); continue; | ||
default: | ||
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; } | ||
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; } | ||
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; } | ||
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; } | ||
if (t[2]) _.ops.pop(); | ||
_.trys.pop(); continue; | ||
} | ||
op = body.call(thisArg, _); | ||
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; } | ||
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true }; | ||
} | ||
}; | ||
import { Scope } from '@uniformdev/optimize-common'; | ||
import { isExtensionSetScoreEvent, } from '@uniformdev/optimize-tracker-common'; | ||
import { isLogLevelUnderThreshold } from '../utils'; | ||
export var addBrowserExtension = function (options) { | ||
var _a = options || {}, disabled = _a.disabled, _b = _a.logLevelThreshold, logLevelThreshold = _b === void 0 ? 'verbose' : _b; | ||
var trackerOptions; | ||
var _a = options || {}, disabled = _a.disabled, disableEventListeners = _a.disableEventListeners, interfaceObject = _a.interfaceObject, _b = _a.logLevelThreshold, logLevelThreshold = _b === void 0 ? 'verbose' : _b; | ||
var resolvedInterfaceObject = interfaceObject || (typeof window !== 'undefined' ? window : undefined); | ||
if (!disabled && !disableEventListeners) { | ||
if (typeof resolvedInterfaceObject !== 'undefined') { | ||
resolvedInterfaceObject.addEventListener('message', function (event) { return __awaiter(void 0, void 0, void 0, function () { | ||
var data, scores; | ||
return __generator(this, function (_a) { | ||
switch (_a.label) { | ||
case 0: | ||
data = event.data; | ||
if (!data) { | ||
return [2 /*return*/]; | ||
} | ||
if (!isExtensionSetScoreEvent(data)) return [3 /*break*/, 3]; | ||
scores = JSON.parse(data.scores); | ||
if (!scores) return [3 /*break*/, 3]; | ||
return [4 /*yield*/, (trackerOptions === null || trackerOptions === void 0 ? void 0 : trackerOptions.setIntentScores(Scope.Visit, {}))]; | ||
case 1: | ||
_a.sent(); | ||
return [4 /*yield*/, (trackerOptions === null || trackerOptions === void 0 ? void 0 : trackerOptions.setIntentScores(Scope.Visitor, scores))]; | ||
case 2: | ||
_a.sent(); | ||
_a.label = 3; | ||
case 3: return [2 /*return*/]; | ||
} | ||
}); | ||
}); }); | ||
} | ||
} | ||
return { | ||
name: 'browser-extension', | ||
initialize: function (options) { | ||
trackerOptions = options; | ||
}, | ||
onLogMessage: function (options) { | ||
if (!disabled && | ||
typeof window !== 'undefined' && | ||
typeof window.__UNIFORM_APP_LISTENER__ === 'function') { | ||
if (!disabled && typeof resolvedInterfaceObject !== 'undefined') { | ||
var level = options.level; | ||
@@ -15,6 +83,6 @@ var shouldOutput = isLogLevelUnderThreshold(logLevelThreshold, level); | ||
} | ||
window.__UNIFORM_APP_LISTENER__({ | ||
resolvedInterfaceObject === null || resolvedInterfaceObject === void 0 ? void 0 : resolvedInterfaceObject.postMessage({ | ||
type: 'log', | ||
message: JSON.stringify(options), | ||
}); | ||
}, '*'); | ||
} | ||
@@ -21,0 +89,0 @@ }, |
@@ -23,1 +23,2 @@ export * from './tracker'; | ||
export * from './nesi/'; | ||
export * from './mvt/testList'; |
@@ -23,1 +23,2 @@ export * from './tracker'; | ||
export * from './nesi/'; | ||
export * from './mvt/testList'; |
export * from './inMemoryScopeStorage'; | ||
export * from './inMemoryActivityStorage'; | ||
export * from './inMemoryScoringStorage'; | ||
export * from './inMemoryTestStorage'; |
export * from './inMemoryScopeStorage'; | ||
export * from './inMemoryActivityStorage'; | ||
export * from './inMemoryScoringStorage'; | ||
export * from './inMemoryTestStorage'; |
@@ -80,2 +80,3 @@ import { Tracker, TrackerOptions, LogMessageOptions, ListenerFunction, AnalyticsEventPayload, TrackerRequestContext, EvaluatedSignal, ReevaluateSignalsResults, TrackerEvent, TrackerPushEventOptions, TrackerScope, TrackerTestCheckOptions, SignalEvaluatorResult, TrackerAttribute } from '@uniformdev/optimize-tracker-common'; | ||
addIntentStrength(scope: Scope | string, valueToAdd: IntentVector): Promise<void>; | ||
setIntentScores(scope: Scope | string, valueToSet: IntentVector): Promise<void>; | ||
private applyScoring; | ||
@@ -99,3 +100,5 @@ private writeScoring; | ||
}): Promise<Record<string, number> | undefined>; | ||
getTestValue(testId: string): Promise<string | undefined>; | ||
setTestValue(testId: string, selectedVariantId: string | undefined): Promise<void>; | ||
} | ||
export {}; |
@@ -635,3 +635,5 @@ var __assign = (this && this.__assign) || function () { | ||
switch (_a.label) { | ||
case 0: return [4 /*yield*/, this.initializeScopes()]; | ||
case 0: | ||
this.log({ level: 'info', message: 'Received intent manifest', intents: this._intentManifest }); | ||
return [4 /*yield*/, this.initializeScopes()]; | ||
case 1: | ||
@@ -677,2 +679,3 @@ _a.sent(); | ||
return [4 /*yield*/, plugin.initialize({ | ||
setIntentScores: this.setIntentScores.bind(this), | ||
log: this.log.bind(this), | ||
@@ -711,3 +714,2 @@ })]; | ||
var _a; | ||
this.log({ level: 'info', message: 'Received intents', intents: intents }); | ||
var processedIntents = intents.map(function (intent) { | ||
@@ -854,2 +856,24 @@ var signals = intent.signals; | ||
}; | ||
OptimizeTracker.prototype.setIntentScores = function (scope, valueToSet) { | ||
return __awaiter(this, void 0, void 0, function () { | ||
var blankSlate; | ||
return __generator(this, function (_a) { | ||
switch (_a.label) { | ||
case 0: | ||
blankSlate = { | ||
strategy: 'blank', | ||
values: {}, | ||
updated: new Date().valueOf(), | ||
}; | ||
return [4 /*yield*/, this.applyScoring(scope, blankSlate, valueToSet, 1)]; | ||
case 1: | ||
_a.sent(); | ||
return [4 /*yield*/, this.broadcastScoring()]; | ||
case 2: | ||
_a.sent(); | ||
return [2 /*return*/]; | ||
} | ||
}); | ||
}); | ||
}; | ||
OptimizeTracker.prototype.applyScoring = function (scope, previousValue, valueToAdd, signalCount) { | ||
@@ -899,3 +923,3 @@ var scoring = this._scoringStrategy({ | ||
_a.sent(); | ||
return [4 /*yield*/, this._storage.activities.delete()]; | ||
return [4 /*yield*/, this._storage.tests.delete()]; | ||
case 2: | ||
@@ -1051,4 +1075,10 @@ _a.sent(); | ||
}; | ||
OptimizeTracker.prototype.getTestValue = function (testId) { | ||
return this._storage.tests.getTestSelection(testId); | ||
}; | ||
OptimizeTracker.prototype.setTestValue = function (testId, selectedVariantId) { | ||
return this._storage.tests.setTestSelection(testId, selectedVariantId); | ||
}; | ||
return OptimizeTracker; | ||
}()); | ||
export { OptimizeTracker }; |
{ | ||
"name": "@uniformdev/optimize-tracker", | ||
"version": "3.0.1-alpha.15+7686d68", | ||
"version": "3.0.1-alpha.39+f998cd5", | ||
"description": "Uniform Optimize tracker", | ||
@@ -29,4 +29,4 @@ "license": "Apache-2.0", | ||
"dependencies": { | ||
"@uniformdev/optimize-common": "^3.0.1-alpha.15+7686d68", | ||
"@uniformdev/optimize-tracker-common": "^3.0.1-alpha.15+7686d68", | ||
"@uniformdev/optimize-common": "^3.0.1-alpha.39+f998cd5", | ||
"@uniformdev/optimize-tracker-common": "^3.0.1-alpha.39+f998cd5", | ||
"parse5": "^6.0.1" | ||
@@ -59,3 +59,3 @@ }, | ||
}, | ||
"gitHead": "7686d68e51c838b622d3a84788dd33b73a3641b9" | ||
"gitHead": "f998cd51287c671c0a97298a1a0ad4c8605ec95c" | ||
} |
Manifest confusion
Supply chain riskThis package has inconsistent metadata. This could be malicious or caused by an error when publishing the package.
Found 1 instance in 1 package
Manifest confusion
Supply chain riskThis package has inconsistent metadata. This could be malicious or caused by an error when publishing the package.
Found 1 instance in 1 package
306556
128
6419