@croct/sdk 0.5.0 → 0.7.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/activeRecord.d.ts +1 -1
- package/activeRecord.js +15 -12
- package/base64Url.js +7 -2
- package/cache/cache.d.ts +12 -0
- package/cache/cache.js +2 -0
- package/cache/fallbackCache.d.ts +2 -2
- package/cache/fallbackCache.js +6 -3
- package/cache/inMemoryCache.d.ts +2 -2
- package/cache/inMemoryCache.js +5 -2
- package/cache/index.d.ts +4 -12
- package/cache/index.js +11 -0
- package/cache/localStorageCache.d.ts +2 -2
- package/cache/localStorageCache.js +4 -1
- package/channel/beaconSocketChannel.d.ts +3 -3
- package/channel/beaconSocketChannel.js +12 -9
- package/channel/channel.d.ts +15 -0
- package/channel/channel.js +2 -0
- package/channel/encodedChannel.d.ts +2 -2
- package/channel/encodedChannel.js +4 -1
- package/channel/guaranteedChannel.d.ts +1 -1
- package/channel/guaranteedChannel.js +10 -7
- package/channel/index.d.ts +8 -15
- package/channel/index.js +19 -0
- package/channel/queuedChannel.d.ts +2 -2
- package/channel/queuedChannel.js +10 -7
- package/channel/retryChannel.d.ts +3 -3
- package/channel/retryChannel.js +18 -15
- package/channel/sandboxChannel.d.ts +2 -2
- package/channel/sandboxChannel.js +4 -1
- package/channel/socketChannel.d.ts +1 -1
- package/channel/socketChannel.js +12 -9
- package/cid/assigner.d.ts +3 -0
- package/cid/assigner.js +2 -0
- package/cid/cachedAssigner.d.ts +5 -5
- package/cid/cachedAssigner.js +9 -6
- package/cid/fixedAssigner.d.ts +6 -0
- package/cid/fixedAssigner.js +13 -0
- package/cid/index.d.ts +4 -3
- package/cid/index.js +11 -0
- package/cid/remoteAssigner.d.ts +3 -3
- package/cid/remoteAssigner.js +11 -8
- package/constants.js +8 -5
- package/container.d.ts +5 -5
- package/container.js +49 -55
- package/context.d.ts +4 -4
- package/context.js +14 -13
- package/error.d.ts +1 -1
- package/error.js +7 -2
- package/evaluator.d.ts +2 -2
- package/evaluator.js +26 -23
- package/eventManager.d.ts +1 -1
- package/eventManager.js +5 -2
- package/facade/evaluatorFacade.d.ts +3 -3
- package/facade/evaluatorFacade.js +13 -10
- package/facade/index.d.ts +7 -0
- package/facade/index.js +19 -0
- package/facade/sdkFacade.d.ts +9 -9
- package/facade/sdkFacade.js +35 -32
- package/facade/sessionFacade.d.ts +3 -3
- package/facade/sessionFacade.js +6 -3
- package/facade/sessionPatch.d.ts +3 -3
- package/facade/sessionPatch.js +8 -5
- package/facade/trackerFacade.d.ts +2 -2
- package/facade/trackerFacade.js +21 -17
- package/facade/userFacade.d.ts +4 -4
- package/facade/userFacade.js +6 -3
- package/facade/userPatch.d.ts +3 -3
- package/facade/userPatch.js +8 -5
- package/index.d.ts +2 -2
- package/index.js +7 -3
- package/json.js +2 -0
- package/logging/consoleLogger.d.ts +2 -2
- package/logging/consoleLogger.js +8 -5
- package/logging/index.d.ts +4 -9
- package/logging/index.js +11 -0
- package/logging/logger.d.ts +9 -0
- package/logging/logger.js +2 -0
- package/logging/namespacedLogger.d.ts +2 -2
- package/logging/namespacedLogger.js +4 -1
- package/logging/nullLogger.d.ts +2 -2
- package/logging/nullLogger.js +4 -1
- package/namespacedStorage.d.ts +1 -1
- package/namespacedStorage.js +7 -4
- package/package.json +21 -18
- package/patch.js +2 -0
- package/queue/capacityRestrictedQueue.d.ts +2 -2
- package/queue/capacityRestrictedQueue.js +4 -1
- package/queue/inMemoryQueue.d.ts +2 -2
- package/queue/inMemoryQueue.js +6 -3
- package/queue/index.d.ts +5 -9
- package/queue/index.js +13 -0
- package/queue/monitoredQueue.d.ts +6 -6
- package/queue/monitoredQueue.js +6 -3
- package/queue/persistentQueue.d.ts +2 -2
- package/queue/persistentQueue.js +5 -2
- package/queue/queue.d.ts +9 -0
- package/queue/queue.js +2 -0
- package/retry/arbitraryPolicy.d.ts +2 -2
- package/retry/arbitraryPolicy.js +6 -3
- package/retry/backoffPolicy.d.ts +2 -2
- package/retry/backoffPolicy.js +4 -1
- package/retry/index.d.ts +5 -4
- package/retry/index.js +13 -0
- package/retry/maxAttemptsPolicy.d.ts +2 -2
- package/retry/maxAttemptsPolicy.js +4 -1
- package/retry/neverPolicy.d.ts +2 -2
- package/retry/neverPolicy.js +4 -1
- package/retry/policy.d.ts +4 -0
- package/retry/policy.js +2 -0
- package/schema/attributeSchema.d.ts +2 -0
- package/schema/attributeSchema.js +8 -0
- package/schema/contentSchemas.d.ts +2 -0
- package/schema/contentSchemas.js +46 -0
- package/schema/contextSchemas.d.ts +1 -1
- package/schema/contextSchemas.js +5 -2
- package/schema/ecommerceSchemas.d.ts +1 -1
- package/schema/ecommerceSchemas.js +60 -60
- package/schema/evaluationSchemas.d.ts +1 -1
- package/schema/evaluationSchemas.js +7 -6
- package/schema/eventSchemas.d.ts +3 -2
- package/schema/eventSchemas.js +53 -48
- package/schema/index.d.ts +10 -0
- package/schema/index.js +13 -0
- package/schema/loggerSchema.d.ts +1 -1
- package/schema/loggerSchema.js +9 -7
- package/schema/operationSchemas.d.ts +1 -1
- package/schema/operationSchemas.js +26 -24
- package/schema/sdkFacadeSchemas.d.ts +2 -2
- package/schema/sdkFacadeSchemas.js +22 -24
- package/schema/sdkSchemas.d.ts +2 -2
- package/schema/sdkSchemas.js +21 -22
- package/schema/tokenSchema.d.ts +2 -3
- package/schema/tokenSchema.js +18 -17
- package/schema/userSchema.d.ts +1 -1
- package/schema/userSchema.js +47 -61
- package/sdk.d.ts +5 -5
- package/sdk.js +27 -24
- package/sdkEvents.d.ts +2 -2
- package/sdkEvents.js +2 -0
- package/sourceLocation.js +12 -6
- package/tab.d.ts +2 -2
- package/tab.js +12 -9
- package/token/cachedTokenStore.d.ts +3 -3
- package/token/cachedTokenStore.js +6 -3
- package/token/inMemoryTokenStore.d.ts +2 -2
- package/token/inMemoryTokenStore.js +4 -1
- package/token/index.d.ts +4 -41
- package/token/index.js +11 -96
- package/token/replicatedTokenStore.d.ts +2 -2
- package/token/replicatedTokenStore.js +4 -1
- package/token/token.d.ts +41 -0
- package/token/token.js +99 -0
- package/tracker.d.ts +3 -3
- package/tracker.js +29 -26
- package/trackingEvents.d.ts +29 -14
- package/trackingEvents.js +20 -14
- package/transformer.js +5 -1
- package/utilityTypes.js +2 -0
- package/uuid.js +5 -1
- package/validation/arrayType.d.ts +2 -2
- package/validation/arrayType.js +13 -9
- package/validation/booleanType.d.ts +2 -2
- package/validation/booleanType.js +7 -3
- package/validation/functionType.d.ts +2 -2
- package/validation/functionType.js +7 -3
- package/validation/index.d.ts +12 -18
- package/validation/index.js +29 -30
- package/validation/jsonType.d.ts +2 -1
- package/validation/jsonType.js +25 -14
- package/validation/mixedSchema.d.ts +2 -2
- package/validation/mixedSchema.js +4 -1
- package/validation/nullType.d.ts +2 -2
- package/validation/nullType.js +7 -3
- package/validation/numberType.d.ts +2 -2
- package/validation/numberType.js +13 -9
- package/validation/objectType.d.ts +2 -2
- package/validation/objectType.js +23 -18
- package/validation/schema.d.ts +16 -0
- package/validation/schema.js +15 -0
- package/validation/stringType.d.ts +2 -2
- package/validation/stringType.js +16 -12
- package/validation/unionType.d.ts +2 -2
- package/validation/unionType.js +14 -10
- package/validation/violation.d.ts +2 -0
- package/validation/violation.js +24 -0
- package/cid/fixedCidAssigner.d.ts +0 -6
- package/cid/fixedCidAssigner.js +0 -10
package/tracker.d.ts
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { Logger } from './logging';
|
|
2
|
-
import Tab from './tab';
|
|
2
|
+
import { Tab } from './tab';
|
|
3
3
|
import { OutputChannel } from './channel';
|
|
4
|
-
import { Beacon, TrackingEvent, TrackingEventContext, PartialTrackingEvent } from './trackingEvents';
|
|
5
4
|
import { TokenProvider } from './token';
|
|
6
5
|
import { RetryPolicy } from './retry';
|
|
6
|
+
import { Beacon, TrackingEvent, TrackingEventContext, PartialTrackingEvent } from './trackingEvents';
|
|
7
7
|
declare type Options = {
|
|
8
8
|
eventMetadata?: {
|
|
9
9
|
[key: string]: string;
|
|
@@ -25,7 +25,7 @@ export declare type EventInfo<T extends TrackingEvent = TrackingEvent> = {
|
|
|
25
25
|
export interface EventListener {
|
|
26
26
|
(event: EventInfo): void;
|
|
27
27
|
}
|
|
28
|
-
export
|
|
28
|
+
export declare class Tracker {
|
|
29
29
|
private readonly options;
|
|
30
30
|
private tab;
|
|
31
31
|
private tokenProvider;
|
package/tracker.js
CHANGED
|
@@ -1,12 +1,15 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.Tracker = void 0;
|
|
4
|
+
var tslib_1 = require("tslib");
|
|
5
|
+
var logging_1 = require("./logging");
|
|
6
|
+
var error_1 = require("./error");
|
|
7
|
+
var trackingEvents_1 = require("./trackingEvents");
|
|
5
8
|
var trackedEvents = {};
|
|
6
9
|
var Tracker = /** @class */ (function () {
|
|
7
10
|
function Tracker(_a) {
|
|
8
11
|
var _b;
|
|
9
|
-
var tab = _a.tab, tokenProvider = _a.tokenProvider, channel = _a.channel, logger = _a.logger, inactivityRetryPolicy = _a.inactivityRetryPolicy, options = __rest(_a, ["tab", "tokenProvider", "channel", "logger", "inactivityRetryPolicy"]);
|
|
12
|
+
var tab = _a.tab, tokenProvider = _a.tokenProvider, channel = _a.channel, logger = _a.logger, inactivityRetryPolicy = _a.inactivityRetryPolicy, options = tslib_1.__rest(_a, ["tab", "tokenProvider", "channel", "logger", "inactivityRetryPolicy"]);
|
|
10
13
|
this.listeners = [];
|
|
11
14
|
this.pending = [];
|
|
12
15
|
this.state = {
|
|
@@ -21,8 +24,8 @@ var Tracker = /** @class */ (function () {
|
|
|
21
24
|
this.tokenProvider = tokenProvider;
|
|
22
25
|
this.inactivityRetryPolicy = inactivityRetryPolicy;
|
|
23
26
|
this.channel = channel;
|
|
24
|
-
this.logger =
|
|
25
|
-
this.options = __assign(__assign({}, options), { eventMetadata: (_b = options.eventMetadata
|
|
27
|
+
this.logger = logger !== null && logger !== void 0 ? logger : new logging_1.NullLogger();
|
|
28
|
+
this.options = tslib_1.__assign(tslib_1.__assign({}, options), { eventMetadata: (_b = options.eventMetadata) !== null && _b !== void 0 ? _b : {} });
|
|
26
29
|
this.enable = this.enable.bind(this);
|
|
27
30
|
this.disable = this.disable.bind(this);
|
|
28
31
|
this.suspend = this.suspend.bind(this);
|
|
@@ -49,7 +52,7 @@ var Tracker = /** @class */ (function () {
|
|
|
49
52
|
};
|
|
50
53
|
return Promise.all(this.pending).then(suppress, suppress);
|
|
51
54
|
},
|
|
52
|
-
enumerable:
|
|
55
|
+
enumerable: false,
|
|
53
56
|
configurable: true
|
|
54
57
|
});
|
|
55
58
|
Tracker.prototype.isEnabled = function () {
|
|
@@ -158,8 +161,8 @@ var Tracker = /** @class */ (function () {
|
|
|
158
161
|
return this.publish(this.enrichEvent(event, timestamp), timestamp).then(function () { return event; });
|
|
159
162
|
};
|
|
160
163
|
Tracker.prototype.trackPageOpen = function (_a) {
|
|
161
|
-
var referrer = _a.referrer, payload = __rest(_a, ["referrer"]);
|
|
162
|
-
this.enqueue(__assign(__assign({ type: 'pageOpened' }, payload), (referrer.length > 0 ? { referrer: referrer } : {})));
|
|
164
|
+
var referrer = _a.referrer, payload = tslib_1.__rest(_a, ["referrer"]);
|
|
165
|
+
this.enqueue(tslib_1.__assign(tslib_1.__assign({ type: 'pageOpened' }, payload), (referrer.length > 0 ? { referrer: referrer } : {})));
|
|
163
166
|
};
|
|
164
167
|
Tracker.prototype.trackPageLoad = function (_a) {
|
|
165
168
|
var tab = _a.detail.tab;
|
|
@@ -171,7 +174,7 @@ var Tracker = /** @class */ (function () {
|
|
|
171
174
|
});
|
|
172
175
|
};
|
|
173
176
|
Tracker.prototype.trackTabOpen = function (payload) {
|
|
174
|
-
this.enqueue(__assign({ type: 'tabOpened' }, payload));
|
|
177
|
+
this.enqueue(tslib_1.__assign({ type: 'tabOpened' }, payload));
|
|
175
178
|
};
|
|
176
179
|
Tracker.prototype.trackTabUrlChange = function (_a) {
|
|
177
180
|
var detail = _a.detail;
|
|
@@ -210,7 +213,7 @@ var Tracker = /** @class */ (function () {
|
|
|
210
213
|
this.stopInactivityTimer();
|
|
211
214
|
}
|
|
212
215
|
var metadata = this.options.eventMetadata;
|
|
213
|
-
var context = __assign({ tabId: this.tab.id, url: this.tab.url }, (Object.keys(metadata).length > 0 ? { metadata: metadata } : {}));
|
|
216
|
+
var context = tslib_1.__assign({ tabId: this.tab.id, url: this.tab.url }, (Object.keys(metadata).length > 0 ? { metadata: metadata } : {}));
|
|
214
217
|
var eventInfo = {
|
|
215
218
|
event: event,
|
|
216
219
|
context: context,
|
|
@@ -219,7 +222,7 @@ var Tracker = /** @class */ (function () {
|
|
|
219
222
|
};
|
|
220
223
|
if (this.state.suspended) {
|
|
221
224
|
this.logger.warn("Tracker is suspended, ignoring event \"" + event.type + "\"");
|
|
222
|
-
this.notifyEvent(__assign(__assign({}, eventInfo), { status: 'ignored' }));
|
|
225
|
+
this.notifyEvent(tslib_1.__assign(tslib_1.__assign({}, eventInfo), { status: 'ignored' }));
|
|
223
226
|
return Promise.reject(new Error('The tracker is suspended.'));
|
|
224
227
|
}
|
|
225
228
|
this.logger.info("Tracked event \"" + event.type + "\"");
|
|
@@ -227,11 +230,11 @@ var Tracker = /** @class */ (function () {
|
|
|
227
230
|
return new Promise(function (resolve, reject) {
|
|
228
231
|
var promise = _this.channel.publish(_this.createBeacon(event, timestamp, context)).then(function () {
|
|
229
232
|
_this.logger.debug("Successfully published event \"" + event.type + "\"");
|
|
230
|
-
_this.notifyEvent(__assign(__assign({}, eventInfo), { status: 'confirmed' }));
|
|
233
|
+
_this.notifyEvent(tslib_1.__assign(tslib_1.__assign({}, eventInfo), { status: 'confirmed' }));
|
|
231
234
|
resolve(event);
|
|
232
235
|
}, function (cause) {
|
|
233
|
-
_this.logger.error("Failed to publish event \"" + event.type + "\", reason: " + formatCause(cause));
|
|
234
|
-
_this.notifyEvent(__assign(__assign({}, eventInfo), { status: 'failed' }));
|
|
236
|
+
_this.logger.error("Failed to publish event \"" + event.type + "\", reason: " + error_1.formatCause(cause));
|
|
237
|
+
_this.notifyEvent(tslib_1.__assign(tslib_1.__assign({}, eventInfo), { status: 'failed' }));
|
|
235
238
|
reject(cause);
|
|
236
239
|
});
|
|
237
240
|
_this.pending.push(promise);
|
|
@@ -244,23 +247,23 @@ var Tracker = /** @class */ (function () {
|
|
|
244
247
|
});
|
|
245
248
|
};
|
|
246
249
|
Tracker.prototype.enrichEvent = function (event, timestamp) {
|
|
247
|
-
if (isCartPartialEvent(event)) {
|
|
248
|
-
var _a = event.cart, _b = _a.lastUpdateTime, lastUpdateTime = _b === void 0 ? timestamp : _b, cart = __rest(_a, ["lastUpdateTime"]), payload = __rest(event, ["cart"]);
|
|
249
|
-
return __assign(__assign({}, payload), { cart: __assign(__assign({}, cart), { lastUpdateTime: lastUpdateTime }) });
|
|
250
|
+
if (trackingEvents_1.isCartPartialEvent(event)) {
|
|
251
|
+
var _a = event.cart, _b = _a.lastUpdateTime, lastUpdateTime = _b === void 0 ? timestamp : _b, cart = tslib_1.__rest(_a, ["lastUpdateTime"]), payload = tslib_1.__rest(event, ["cart"]);
|
|
252
|
+
return tslib_1.__assign(tslib_1.__assign({}, payload), { cart: tslib_1.__assign(tslib_1.__assign({}, cart), { lastUpdateTime: lastUpdateTime }) });
|
|
250
253
|
}
|
|
251
254
|
return event;
|
|
252
255
|
};
|
|
253
256
|
Tracker.prototype.createBeacon = function (event, timestamp, context) {
|
|
254
257
|
var token = this.tokenProvider.getToken();
|
|
255
|
-
return __assign(__assign({ timestamp: timestamp }, (token !== null ? { token: token.toString() } : {})), { context: context, payload: this.createBeaconPayload(event) });
|
|
258
|
+
return tslib_1.__assign(tslib_1.__assign({ timestamp: timestamp }, (token !== null ? { token: token.toString() } : {})), { context: context, payload: this.createBeaconPayload(event) });
|
|
256
259
|
};
|
|
257
260
|
Tracker.prototype.createBeaconPayload = function (event) {
|
|
258
|
-
if (!isIdentifiedUserEvent(event)) {
|
|
261
|
+
if (!trackingEvents_1.isIdentifiedUserEvent(event)) {
|
|
259
262
|
return event;
|
|
260
263
|
}
|
|
261
264
|
if (event.type === 'userSignedUp' && event.profile !== undefined) {
|
|
262
|
-
var userId_1 = event.userId, profile = event.profile, payload_1 = __rest(event, ["userId", "profile"]);
|
|
263
|
-
return __assign(__assign({}, payload_1), { externalUserId: userId_1, patch: {
|
|
265
|
+
var userId_1 = event.userId, profile = event.profile, payload_1 = tslib_1.__rest(event, ["userId", "profile"]);
|
|
266
|
+
return tslib_1.__assign(tslib_1.__assign({}, payload_1), { externalUserId: userId_1, patch: {
|
|
264
267
|
operations: [
|
|
265
268
|
{
|
|
266
269
|
type: 'set',
|
|
@@ -270,9 +273,9 @@ var Tracker = /** @class */ (function () {
|
|
|
270
273
|
],
|
|
271
274
|
} });
|
|
272
275
|
}
|
|
273
|
-
var userId = event.userId, payload = __rest(event, ["userId"]);
|
|
274
|
-
return __assign(__assign({}, payload), { externalUserId: userId });
|
|
276
|
+
var userId = event.userId, payload = tslib_1.__rest(event, ["userId"]);
|
|
277
|
+
return tslib_1.__assign(tslib_1.__assign({}, payload), { externalUserId: userId });
|
|
275
278
|
};
|
|
276
279
|
return Tracker;
|
|
277
280
|
}());
|
|
278
|
-
|
|
281
|
+
exports.Tracker = Tracker;
|
package/trackingEvents.d.ts
CHANGED
|
@@ -68,11 +68,11 @@ export declare type Gender = 'male' | 'female' | 'neutral' | 'unknown';
|
|
|
68
68
|
export declare const pageEventTypes: readonly ["pageLoaded", "pageOpened"];
|
|
69
69
|
export declare const tabEventTypes: readonly ["tabOpened", "tabUrlChanged", "tabVisibilityChanged"];
|
|
70
70
|
export declare const cartEventTypes: readonly ["cartModified", "cartViewed", "checkoutStarted"];
|
|
71
|
-
export declare const ecommerceEventTypes: readonly
|
|
71
|
+
export declare const ecommerceEventTypes: readonly ["cartModified", "cartViewed", "checkoutStarted", "orderPlaced", "productViewed"];
|
|
72
72
|
export declare const identifiedUserEventTypes: string[];
|
|
73
|
-
export declare const userEventTypes: readonly string[];
|
|
74
|
-
export declare const miscEventTypes: readonly ["nothingChanged", "sessionAttributesChanged", "
|
|
75
|
-
export declare const eventTypes: readonly string[];
|
|
73
|
+
export declare const userEventTypes: readonly [...string[], "userProfileChanged"];
|
|
74
|
+
export declare const miscEventTypes: readonly ["nothingChanged", "sessionAttributesChanged", "goalCompleted", "interestShown", "postViewed", "eventOccurred"];
|
|
75
|
+
export declare const eventTypes: readonly ["pageLoaded", "pageOpened", "cartModified", "cartViewed", "checkoutStarted", "orderPlaced", "productViewed", ...string[], "userProfileChanged", "nothingChanged", "sessionAttributesChanged", "goalCompleted", "interestShown", "postViewed", "eventOccurred"];
|
|
76
76
|
interface BaseEvent {
|
|
77
77
|
type: string;
|
|
78
78
|
}
|
|
@@ -200,17 +200,30 @@ export interface SessionAttributesChanged extends BaseEvent {
|
|
|
200
200
|
type: 'sessionAttributesChanged';
|
|
201
201
|
patch: Patch;
|
|
202
202
|
}
|
|
203
|
-
export interface TestGroupAssigned extends BaseEvent {
|
|
204
|
-
type: 'testGroupAssigned';
|
|
205
|
-
testId: string;
|
|
206
|
-
groupId: string;
|
|
207
|
-
}
|
|
208
203
|
export interface GoalCompleted extends BaseEvent {
|
|
209
204
|
type: 'goalCompleted';
|
|
210
205
|
goalId: string;
|
|
211
206
|
value?: number;
|
|
212
207
|
currency?: string;
|
|
213
208
|
}
|
|
209
|
+
export interface InterestShown extends BaseEvent {
|
|
210
|
+
type: 'interestShown';
|
|
211
|
+
interests: string[];
|
|
212
|
+
}
|
|
213
|
+
export interface PostDetails {
|
|
214
|
+
postId: string;
|
|
215
|
+
url?: string;
|
|
216
|
+
title: string;
|
|
217
|
+
tags?: string[];
|
|
218
|
+
categories?: string[];
|
|
219
|
+
authors?: string[];
|
|
220
|
+
publishTime: number;
|
|
221
|
+
updateTime?: number;
|
|
222
|
+
}
|
|
223
|
+
export interface PostViewed extends BaseEvent {
|
|
224
|
+
type: 'postViewed';
|
|
225
|
+
post: PostDetails;
|
|
226
|
+
}
|
|
214
227
|
export interface EventOccurred extends BaseEvent {
|
|
215
228
|
type: 'eventOccurred';
|
|
216
229
|
name: string;
|
|
@@ -222,7 +235,7 @@ export interface EventOccurred extends BaseEvent {
|
|
|
222
235
|
[key: string]: string | number | boolean | null;
|
|
223
236
|
};
|
|
224
237
|
}
|
|
225
|
-
export declare type MiscEvent = NothingChanged | SessionAttributesChanged |
|
|
238
|
+
export declare type MiscEvent = NothingChanged | SessionAttributesChanged | EventOccurred | GoalCompleted | InterestShown | PostViewed;
|
|
226
239
|
declare type EventMap = {
|
|
227
240
|
tabVisibilityChanged: TabVisibilityChanged;
|
|
228
241
|
tabUrlChanged: TabUrlChanged;
|
|
@@ -240,8 +253,9 @@ declare type EventMap = {
|
|
|
240
253
|
orderPlaced: OrderPlaced;
|
|
241
254
|
nothingChanged: NothingChanged;
|
|
242
255
|
sessionAttributesChanged: SessionAttributesChanged;
|
|
243
|
-
testGroupAssigned: TestGroupAssigned;
|
|
244
256
|
goalCompleted: GoalCompleted;
|
|
257
|
+
interestShown: InterestShown;
|
|
258
|
+
postViewed: PostViewed;
|
|
245
259
|
eventOccurred: EventOccurred;
|
|
246
260
|
};
|
|
247
261
|
export declare type TrackingEventType = keyof EventMap;
|
|
@@ -261,8 +275,9 @@ declare type ExternalEventMap = {
|
|
|
261
275
|
orderPlaced: OrderPlaced;
|
|
262
276
|
productViewed: ProductViewed;
|
|
263
277
|
userSignedUp: UserSignedUp;
|
|
264
|
-
testGroupAssigned: TestGroupAssigned;
|
|
265
278
|
goalCompleted: GoalCompleted;
|
|
279
|
+
interestShown: InterestShown;
|
|
280
|
+
postViewed: PostViewed;
|
|
266
281
|
eventOccurred: EventOccurred;
|
|
267
282
|
};
|
|
268
283
|
export declare type ExternalTrackingEventType = keyof ExternalEventMap;
|
|
@@ -277,9 +292,9 @@ export declare type TrackingEventContext = {
|
|
|
277
292
|
[key: string]: string;
|
|
278
293
|
};
|
|
279
294
|
};
|
|
280
|
-
export declare type BeaconPayload = Exclude<TrackingEvent, IdentifiedUserEvent> |
|
|
295
|
+
export declare type BeaconPayload = Exclude<TrackingEvent, IdentifiedUserEvent> | DistributiveOmit<Exclude<IdentifiedUserEvent, UserSignedUp>, 'userId'> & Record<'externalUserId', IdentifiedUserEvent['userId']> | Omit<UserSignedUp, 'userId' | 'profile'> & Record<'externalUserId', IdentifiedUserEvent['userId']> & {
|
|
281
296
|
patch?: Patch;
|
|
282
|
-
}
|
|
297
|
+
};
|
|
283
298
|
export declare type Beacon = {
|
|
284
299
|
timestamp: number;
|
|
285
300
|
token?: string;
|
package/trackingEvents.js
CHANGED
|
@@ -1,47 +1,53 @@
|
|
|
1
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.isCartPartialEvent = exports.isIdentifiedUserEvent = exports.eventTypes = exports.miscEventTypes = exports.userEventTypes = exports.identifiedUserEventTypes = exports.ecommerceEventTypes = exports.cartEventTypes = exports.tabEventTypes = exports.pageEventTypes = void 0;
|
|
4
|
+
var tslib_1 = require("tslib");
|
|
2
5
|
/*
|
|
3
6
|
* Events
|
|
4
7
|
*/
|
|
5
|
-
|
|
8
|
+
exports.pageEventTypes = [
|
|
6
9
|
'pageLoaded',
|
|
7
10
|
'pageOpened',
|
|
8
11
|
];
|
|
9
|
-
|
|
12
|
+
exports.tabEventTypes = [
|
|
10
13
|
'tabOpened',
|
|
11
14
|
'tabUrlChanged',
|
|
12
15
|
'tabVisibilityChanged',
|
|
13
16
|
];
|
|
14
|
-
|
|
17
|
+
exports.cartEventTypes = [
|
|
15
18
|
'cartModified',
|
|
16
19
|
'cartViewed',
|
|
17
20
|
'checkoutStarted',
|
|
18
21
|
];
|
|
19
|
-
|
|
22
|
+
exports.ecommerceEventTypes = tslib_1.__spreadArray(tslib_1.__spreadArray([], tslib_1.__read(exports.cartEventTypes)), [
|
|
20
23
|
'orderPlaced',
|
|
21
24
|
'productViewed',
|
|
22
25
|
]);
|
|
23
|
-
|
|
26
|
+
exports.identifiedUserEventTypes = [
|
|
24
27
|
'userSignedIn',
|
|
25
28
|
'userSignedOut',
|
|
26
29
|
'userSignedUp',
|
|
27
30
|
];
|
|
28
|
-
|
|
31
|
+
exports.userEventTypes = tslib_1.__spreadArray(tslib_1.__spreadArray([], tslib_1.__read(exports.identifiedUserEventTypes)), [
|
|
29
32
|
'userProfileChanged',
|
|
30
33
|
]);
|
|
31
|
-
|
|
34
|
+
exports.miscEventTypes = [
|
|
32
35
|
'nothingChanged',
|
|
33
36
|
'sessionAttributesChanged',
|
|
34
|
-
'testGroupAssigned',
|
|
35
37
|
'goalCompleted',
|
|
38
|
+
'interestShown',
|
|
39
|
+
'postViewed',
|
|
36
40
|
'eventOccurred',
|
|
37
41
|
];
|
|
38
|
-
|
|
42
|
+
exports.eventTypes = tslib_1.__spreadArray(tslib_1.__spreadArray(tslib_1.__spreadArray(tslib_1.__spreadArray([], tslib_1.__read(exports.pageEventTypes)), tslib_1.__read(exports.ecommerceEventTypes)), tslib_1.__read(exports.userEventTypes)), tslib_1.__read(exports.miscEventTypes));
|
|
39
43
|
/*
|
|
40
44
|
* Type guards
|
|
41
45
|
*/
|
|
42
|
-
|
|
43
|
-
return identifiedUserEventTypes.includes(event.type);
|
|
46
|
+
function isIdentifiedUserEvent(event) {
|
|
47
|
+
return exports.identifiedUserEventTypes.includes(event.type);
|
|
44
48
|
}
|
|
45
|
-
|
|
46
|
-
|
|
49
|
+
exports.isIdentifiedUserEvent = isIdentifiedUserEvent;
|
|
50
|
+
function isCartPartialEvent(event) {
|
|
51
|
+
return exports.cartEventTypes.includes(event.type);
|
|
47
52
|
}
|
|
53
|
+
exports.isCartPartialEvent = isCartPartialEvent;
|
package/transformer.js
CHANGED
|
@@ -1,3 +1,7 @@
|
|
|
1
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.encodeJson = void 0;
|
|
4
|
+
var encodeJson = function encodeJson(input) {
|
|
2
5
|
return Promise.resolve(JSON.stringify(input));
|
|
3
6
|
};
|
|
7
|
+
exports.encodeJson = encodeJson;
|
package/utilityTypes.js
CHANGED
package/uuid.js
CHANGED
|
@@ -1,4 +1,7 @@
|
|
|
1
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.uuid4 = void 0;
|
|
4
|
+
function uuid4(sortable) {
|
|
2
5
|
if (sortable === void 0) { sortable = false; }
|
|
3
6
|
var uuid = '';
|
|
4
7
|
if (sortable) {
|
|
@@ -29,3 +32,4 @@ export function uuid4(sortable) {
|
|
|
29
32
|
}
|
|
30
33
|
return uuid;
|
|
31
34
|
}
|
|
35
|
+
exports.uuid4 = uuid4;
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import { Schema, TypeSchema } from './
|
|
1
|
+
import { Schema, TypeSchema } from './schema';
|
|
2
2
|
declare type ArrayDefinition = {
|
|
3
3
|
minItems: number;
|
|
4
4
|
maxItems: number;
|
|
5
5
|
items?: Schema;
|
|
6
6
|
};
|
|
7
|
-
export
|
|
7
|
+
export declare class ArrayType implements TypeSchema {
|
|
8
8
|
private readonly definition;
|
|
9
9
|
constructor(definition?: Partial<ArrayDefinition>);
|
|
10
10
|
getTypes(): string[];
|
package/validation/arrayType.js
CHANGED
|
@@ -1,10 +1,14 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ArrayType = void 0;
|
|
4
|
+
var tslib_1 = require("tslib");
|
|
5
|
+
var schema_1 = require("./schema");
|
|
6
|
+
var violation_1 = require("./violation");
|
|
3
7
|
var ArrayType = /** @class */ (function () {
|
|
4
8
|
function ArrayType(definition) {
|
|
5
9
|
if (definition === void 0) { definition = {}; }
|
|
6
10
|
var _a, _b;
|
|
7
|
-
this.definition = __assign(__assign({}, definition), { minItems: (_a = definition.minItems
|
|
11
|
+
this.definition = tslib_1.__assign(tslib_1.__assign({}, definition), { minItems: (_a = definition.minItems) !== null && _a !== void 0 ? _a : -1, maxItems: (_b = definition.maxItems) !== null && _b !== void 0 ? _b : -1 });
|
|
8
12
|
}
|
|
9
13
|
ArrayType.prototype.getTypes = function () {
|
|
10
14
|
return ['array'];
|
|
@@ -15,19 +19,19 @@ var ArrayType = /** @class */ (function () {
|
|
|
15
19
|
ArrayType.prototype.validate = function (value, path) {
|
|
16
20
|
if (path === void 0) { path = []; }
|
|
17
21
|
if (!this.isValidType(value)) {
|
|
18
|
-
throw new Violation("Expected value of type array at path '" + formatPath(path) + "', actual " + describe(value) + ".", path, { type: 'string' });
|
|
22
|
+
throw new schema_1.Violation("Expected value of type array at path '" + violation_1.formatPath(path) + "', actual " + violation_1.describe(value) + ".", path, { type: 'string' });
|
|
19
23
|
}
|
|
20
24
|
var _a = this.definition, minItems = _a.minItems, maxItems = _a.maxItems;
|
|
21
25
|
var length = value.length;
|
|
22
26
|
if (minItems >= 0 && minItems > length) {
|
|
23
|
-
throw new Violation("Expected " + (minItems === maxItems ? 'exactly' : 'at least') + " "
|
|
27
|
+
throw new schema_1.Violation("Expected " + (minItems === maxItems ? 'exactly' : 'at least') + " "
|
|
24
28
|
+ (minItems + " " + (minItems === 1 ? 'item' : 'items') + " ")
|
|
25
|
-
+ ("at path '" + formatPath(path) + "', actual " + length + "."), path, { limit: minItems });
|
|
29
|
+
+ ("at path '" + violation_1.formatPath(path) + "', actual " + length + "."), path, { limit: minItems });
|
|
26
30
|
}
|
|
27
31
|
if (maxItems >= 0 && maxItems < length) {
|
|
28
|
-
throw new Violation("Expected " + (minItems === maxItems ? 'exactly' : 'at most') + " "
|
|
32
|
+
throw new schema_1.Violation("Expected " + (minItems === maxItems ? 'exactly' : 'at most') + " "
|
|
29
33
|
+ (maxItems + " " + (maxItems === 1 ? 'item' : 'items') + " ")
|
|
30
|
-
+ ("at path '" + formatPath(path) + "', actual " + length + "."), path, { limit: maxItems });
|
|
34
|
+
+ ("at path '" + violation_1.formatPath(path) + "', actual " + length + "."), path, { limit: maxItems });
|
|
31
35
|
}
|
|
32
36
|
if (this.definition.items === undefined) {
|
|
33
37
|
return;
|
|
@@ -38,4 +42,4 @@ var ArrayType = /** @class */ (function () {
|
|
|
38
42
|
};
|
|
39
43
|
return ArrayType;
|
|
40
44
|
}());
|
|
41
|
-
|
|
45
|
+
exports.ArrayType = ArrayType;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { TypeSchema } from './
|
|
2
|
-
export
|
|
1
|
+
import { TypeSchema } from './schema';
|
|
2
|
+
export declare class BooleanType implements TypeSchema {
|
|
3
3
|
getTypes(): string[];
|
|
4
4
|
isValidType(value: unknown): value is boolean;
|
|
5
5
|
validate(value: unknown, path?: string[]): void;
|
|
@@ -1,4 +1,8 @@
|
|
|
1
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.BooleanType = void 0;
|
|
4
|
+
var schema_1 = require("./schema");
|
|
5
|
+
var violation_1 = require("./violation");
|
|
2
6
|
var BooleanType = /** @class */ (function () {
|
|
3
7
|
function BooleanType() {
|
|
4
8
|
}
|
|
@@ -11,9 +15,9 @@ var BooleanType = /** @class */ (function () {
|
|
|
11
15
|
BooleanType.prototype.validate = function (value, path) {
|
|
12
16
|
if (path === void 0) { path = []; }
|
|
13
17
|
if (!this.isValidType(value)) {
|
|
14
|
-
throw new Violation("Expected value of type boolean at path '" + formatPath(path) + "', actual " + describe(value) + ".", path, { type: 'boolean' });
|
|
18
|
+
throw new schema_1.Violation("Expected value of type boolean at path '" + violation_1.formatPath(path) + "', actual " + violation_1.describe(value) + ".", path, { type: 'boolean' });
|
|
15
19
|
}
|
|
16
20
|
};
|
|
17
21
|
return BooleanType;
|
|
18
22
|
}());
|
|
19
|
-
|
|
23
|
+
exports.BooleanType = BooleanType;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { TypeSchema } from './
|
|
2
|
-
export
|
|
1
|
+
import { TypeSchema } from './schema';
|
|
2
|
+
export declare class FunctionType implements TypeSchema {
|
|
3
3
|
getTypes(): string[];
|
|
4
4
|
isValidType(value: unknown): value is boolean;
|
|
5
5
|
validate(value: unknown, path?: string[]): void;
|
|
@@ -1,4 +1,8 @@
|
|
|
1
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.FunctionType = void 0;
|
|
4
|
+
var schema_1 = require("./schema");
|
|
5
|
+
var violation_1 = require("./violation");
|
|
2
6
|
var FunctionType = /** @class */ (function () {
|
|
3
7
|
function FunctionType() {
|
|
4
8
|
}
|
|
@@ -11,9 +15,9 @@ var FunctionType = /** @class */ (function () {
|
|
|
11
15
|
FunctionType.prototype.validate = function (value, path) {
|
|
12
16
|
if (path === void 0) { path = []; }
|
|
13
17
|
if (!this.isValidType(value)) {
|
|
14
|
-
throw new Violation("Expected value of type function at path '" + formatPath(path) + "', actual " + describe(value) + ".", path, { type: 'function' });
|
|
18
|
+
throw new schema_1.Violation("Expected value of type function at path '" + violation_1.formatPath(path) + "', actual " + violation_1.describe(value) + ".", path, { type: 'function' });
|
|
15
19
|
}
|
|
16
20
|
};
|
|
17
21
|
return FunctionType;
|
|
18
22
|
}());
|
|
19
|
-
|
|
23
|
+
exports.FunctionType = FunctionType;
|
package/validation/index.d.ts
CHANGED
|
@@ -1,18 +1,12 @@
|
|
|
1
|
-
export
|
|
2
|
-
export
|
|
3
|
-
export
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
}
|
|
12
|
-
export
|
|
13
|
-
validate(value: unknown, path?: string[]): void;
|
|
14
|
-
}
|
|
15
|
-
export interface TypeSchema extends Schema {
|
|
16
|
-
getTypes(): string[];
|
|
17
|
-
isValidType(value: unknown): boolean;
|
|
18
|
-
}
|
|
1
|
+
export * from './schema';
|
|
2
|
+
export * from './violation';
|
|
3
|
+
export { ArrayType } from './arrayType';
|
|
4
|
+
export { BooleanType } from './booleanType';
|
|
5
|
+
export { FunctionType } from './functionType';
|
|
6
|
+
export { JsonType, JsonArrayType, JsonObjectType, JsonPrimitiveType } from './jsonType';
|
|
7
|
+
export { MixedSchema } from './mixedSchema';
|
|
8
|
+
export { NullType } from './nullType';
|
|
9
|
+
export { NumberType } from './numberType';
|
|
10
|
+
export { ObjectType } from './objectType';
|
|
11
|
+
export { StringType } from './stringType';
|
|
12
|
+
export { UnionType } from './unionType';
|
package/validation/index.js
CHANGED
|
@@ -1,30 +1,29 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
}
|
|
20
|
-
var
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
export { Violation };
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.UnionType = exports.StringType = exports.ObjectType = exports.NumberType = exports.NullType = exports.MixedSchema = exports.JsonPrimitiveType = exports.JsonObjectType = exports.JsonArrayType = exports.JsonType = exports.FunctionType = exports.BooleanType = exports.ArrayType = void 0;
|
|
4
|
+
var tslib_1 = require("tslib");
|
|
5
|
+
tslib_1.__exportStar(require("./schema"), exports);
|
|
6
|
+
tslib_1.__exportStar(require("./violation"), exports);
|
|
7
|
+
var arrayType_1 = require("./arrayType");
|
|
8
|
+
Object.defineProperty(exports, "ArrayType", { enumerable: true, get: function () { return arrayType_1.ArrayType; } });
|
|
9
|
+
var booleanType_1 = require("./booleanType");
|
|
10
|
+
Object.defineProperty(exports, "BooleanType", { enumerable: true, get: function () { return booleanType_1.BooleanType; } });
|
|
11
|
+
var functionType_1 = require("./functionType");
|
|
12
|
+
Object.defineProperty(exports, "FunctionType", { enumerable: true, get: function () { return functionType_1.FunctionType; } });
|
|
13
|
+
var jsonType_1 = require("./jsonType");
|
|
14
|
+
Object.defineProperty(exports, "JsonType", { enumerable: true, get: function () { return jsonType_1.JsonType; } });
|
|
15
|
+
Object.defineProperty(exports, "JsonArrayType", { enumerable: true, get: function () { return jsonType_1.JsonArrayType; } });
|
|
16
|
+
Object.defineProperty(exports, "JsonObjectType", { enumerable: true, get: function () { return jsonType_1.JsonObjectType; } });
|
|
17
|
+
Object.defineProperty(exports, "JsonPrimitiveType", { enumerable: true, get: function () { return jsonType_1.JsonPrimitiveType; } });
|
|
18
|
+
var mixedSchema_1 = require("./mixedSchema");
|
|
19
|
+
Object.defineProperty(exports, "MixedSchema", { enumerable: true, get: function () { return mixedSchema_1.MixedSchema; } });
|
|
20
|
+
var nullType_1 = require("./nullType");
|
|
21
|
+
Object.defineProperty(exports, "NullType", { enumerable: true, get: function () { return nullType_1.NullType; } });
|
|
22
|
+
var numberType_1 = require("./numberType");
|
|
23
|
+
Object.defineProperty(exports, "NumberType", { enumerable: true, get: function () { return numberType_1.NumberType; } });
|
|
24
|
+
var objectType_1 = require("./objectType");
|
|
25
|
+
Object.defineProperty(exports, "ObjectType", { enumerable: true, get: function () { return objectType_1.ObjectType; } });
|
|
26
|
+
var stringType_1 = require("./stringType");
|
|
27
|
+
Object.defineProperty(exports, "StringType", { enumerable: true, get: function () { return stringType_1.StringType; } });
|
|
28
|
+
var unionType_1 = require("./unionType");
|
|
29
|
+
Object.defineProperty(exports, "UnionType", { enumerable: true, get: function () { return unionType_1.UnionType; } });
|
package/validation/jsonType.d.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
|
-
import { Schema, TypeSchema } from './
|
|
1
|
+
import { Schema, TypeSchema } from './schema';
|
|
2
2
|
declare type JsonObjectDefinition = {
|
|
3
3
|
properties?: Schema;
|
|
4
|
+
propertyNames?: Schema;
|
|
4
5
|
};
|
|
5
6
|
export declare class JsonObjectType implements TypeSchema {
|
|
6
7
|
private readonly definition;
|