@coveo/relay 1.1.2 → 1.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/npm/client-id/client-id.d.ts.map +1 -1
- package/lib/npm/config/config.d.ts +3 -1
- package/lib/npm/config/config.d.ts.map +1 -1
- package/lib/npm/constants.d.ts +2 -0
- package/lib/npm/constants.d.ts.map +1 -0
- package/lib/npm/environment/manager/manager.d.ts.map +1 -1
- package/lib/npm/relay.cjs +14 -6
- package/lib/npm/relay.d.ts +2 -0
- package/lib/npm/relay.d.ts.map +1 -1
- package/lib/npm/relay.mjs +13 -7
- package/package.json +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"client-id.d.ts","sourceRoot":"","sources":["../../../src/client-id/client-id.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,kBAAkB,EAAE,MAAM,gCAAgC,CAAC;
|
|
1
|
+
{"version":3,"file":"client-id.d.ts","sourceRoot":"","sources":["../../../src/client-id/client-id.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,kBAAkB,EAAE,MAAM,gCAAgC,CAAC;AAGpE,MAAM,WAAW,eAAe;IAC9B,WAAW,EAAE,MAAM,MAAM,CAAC;CAC3B;AAED,wBAAgB,qBAAqB,CACnC,kBAAkB,EAAE,kBAAkB,GACrC,eAAe,CAejB"}
|
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
import { Environment } from "../environment/environment";
|
|
2
|
-
export type CustomEnvironment = Pick<Environment, "generateUUID" | "getLocation" | "getReferrer" | "getUserAgent" | "send"
|
|
2
|
+
export type CustomEnvironment = Pick<Environment, "generateUUID" | "getLocation" | "getReferrer" | "getUserAgent" | "send"> & {
|
|
3
|
+
storage?: Environment["storage"];
|
|
4
|
+
};
|
|
3
5
|
/**
|
|
4
6
|
* The `RelayConfig` object defines the configuration options for initializing a Relay instance.
|
|
5
7
|
*/
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../../../src/config/config.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,4BAA4B,CAAC;AAEzD,MAAM,MAAM,iBAAiB,GAAG,IAAI,CAClC,WAAW,
|
|
1
|
+
{"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../../../src/config/config.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,4BAA4B,CAAC;AAEzD,MAAM,MAAM,iBAAiB,GAAG,IAAI,CAClC,WAAW,EACX,cAAc,GAAG,aAAa,GAAG,aAAa,GAAG,cAAc,GAAG,MAAM,CACzE,GAAG;IACF,OAAO,CAAC,EAAE,WAAW,CAAC,SAAS,CAAC,CAAC;CAClC,CAAC;AAEF;;GAEG;AACH,MAAM,WAAW,WAAW;IAC1B;;OAEG;IACH,GAAG,EAAE,MAAM,CAAC;IAEZ;;OAEG;IACH,KAAK,EAAE,MAAM,CAAC;IAEd;;OAEG;IACH,UAAU,EAAE,MAAM,CAAC;IAEnB;;;;;OAKG;IACH,IAAI,CAAC,EAAE,MAAM,GAAG,UAAU,CAAC;IAE3B;;;;OAIG;IACH,MAAM,CAAC,EAAE,MAAM,EAAE,CAAC;IAElB;;;OAGG;IACH,WAAW,CAAC,EAAE,iBAAiB,CAAC;CACjC;AAED,MAAM,WAAW,aAAa;IAC5B,GAAG,EAAE,MAAM,QAAQ,CAAC,WAAW,CAAC,CAAC;IACjC,MAAM,EAAE,CAAC,aAAa,EAAE,OAAO,CAAC,WAAW,CAAC,KAAK,IAAI,CAAC;CACvD;AAkBD,wBAAgB,mBAAmB,CACjC,aAAa,EAAE,WAAW,GACzB,QAAQ,CAAC,aAAa,CAAC,CASzB"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["../../src/constants.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,WAAW,cAAc,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"manager.d.ts","sourceRoot":"","sources":["../../../../src/environment/manager/manager.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AAGpD,OAAO,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAE7C,MAAM,WAAW,kBAAkB;IACjC,GAAG,EAAE,MAAM,QAAQ,CAAC,WAAW,CAAC,CAAC;CAClC;
|
|
1
|
+
{"version":3,"file":"manager.d.ts","sourceRoot":"","sources":["../../../../src/environment/manager/manager.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AAGpD,OAAO,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAE7C,MAAM,WAAW,kBAAkB;IACjC,GAAG,EAAE,MAAM,QAAQ,CAAC,WAAW,CAAC,CAAC;CAClC;AA+BD,wBAAgB,wBAAwB,CACtC,aAAa,EAAE,aAAa,GAC3B,QAAQ,CAAC,kBAAkB,CAAC,CAI9B"}
|
package/lib/npm/relay.cjs
CHANGED
|
@@ -12,23 +12,24 @@ function emit({ config, environment, event, listenerManager, }) {
|
|
|
12
12
|
}
|
|
13
13
|
}
|
|
14
14
|
|
|
15
|
+
const clientIdKey = "visitorId";
|
|
16
|
+
|
|
15
17
|
function createClientIdManager(environmentManager) {
|
|
16
18
|
return {
|
|
17
19
|
getClientId: () => {
|
|
18
|
-
const key = "visitorId";
|
|
19
20
|
const environment = environmentManager.get();
|
|
20
21
|
const storage = environment.storage;
|
|
21
|
-
const existingClientId = storage.getItem(
|
|
22
|
+
const existingClientId = storage.getItem(clientIdKey);
|
|
22
23
|
const clientId = existingClientId && uuid.validate(existingClientId)
|
|
23
24
|
? existingClientId
|
|
24
25
|
: environment.generateUUID();
|
|
25
|
-
storage.setItem(
|
|
26
|
+
storage.setItem(clientIdKey, clientId);
|
|
26
27
|
return clientId;
|
|
27
28
|
},
|
|
28
29
|
};
|
|
29
30
|
}
|
|
30
31
|
|
|
31
|
-
const version = "1.
|
|
32
|
+
const version = "1.2.0";
|
|
32
33
|
|
|
33
34
|
function getEventConfig(config) {
|
|
34
35
|
const { trackingId } = config;
|
|
@@ -259,13 +260,18 @@ function buildNullEnvironment() {
|
|
|
259
260
|
function buildEnvironment(configManager) {
|
|
260
261
|
const active = configManager.get().mode !== "disabled";
|
|
261
262
|
const environmentFromConfig = configManager.get().environment;
|
|
263
|
+
const nullEnvironment = buildNullEnvironment();
|
|
262
264
|
if (active && environmentFromConfig) {
|
|
263
|
-
return {
|
|
265
|
+
return {
|
|
266
|
+
storage: nullEnvironment.storage,
|
|
267
|
+
...environmentFromConfig,
|
|
268
|
+
runtime: "custom",
|
|
269
|
+
};
|
|
264
270
|
}
|
|
265
271
|
if (active && isBrowser() && localStorageAvailable()) {
|
|
266
272
|
return buildBrowserEnvironment();
|
|
267
273
|
}
|
|
268
|
-
return
|
|
274
|
+
return nullEnvironment;
|
|
269
275
|
}
|
|
270
276
|
function isBrowser() {
|
|
271
277
|
try {
|
|
@@ -311,4 +317,6 @@ function createRelay(initialConfig) {
|
|
|
311
317
|
};
|
|
312
318
|
}
|
|
313
319
|
|
|
320
|
+
exports.buildBrowserEnvironment = buildBrowserEnvironment;
|
|
321
|
+
exports.clientIdKey = clientIdKey;
|
|
314
322
|
exports.createRelay = createRelay;
|
package/lib/npm/relay.d.ts
CHANGED
|
@@ -3,6 +3,8 @@ import { Meta, EventConfig } from "./event/meta/meta";
|
|
|
3
3
|
import { EventCallback } from "./listener/listener";
|
|
4
4
|
import { RelayConfig, CustomEnvironment } from "./config/config";
|
|
5
5
|
import { RelayPayload } from "./relay-payload";
|
|
6
|
+
export { buildBrowserEnvironment } from "./environment/browser/browser";
|
|
7
|
+
export { clientIdKey } from "./constants";
|
|
6
8
|
/**
|
|
7
9
|
* Function that detaches an event callback.
|
|
8
10
|
* @typedef {function} Off
|
package/lib/npm/relay.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"relay.d.ts","sourceRoot":"","sources":["../../src/relay.ts"],"names":[],"mappings":"AAEA,OAAO,EAAoB,UAAU,EAAE,MAAM,qBAAqB,CAAC;AAEnE,OAAO,EAAc,IAAI,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAClE,OAAO,EAAyB,aAAa,EAAE,MAAM,qBAAqB,CAAC;AAC3E,OAAO,EAEL,WAAW,EACX,iBAAiB,EAClB,MAAM,iBAAiB,CAAC;AAEzB,OAAO,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC;
|
|
1
|
+
{"version":3,"file":"relay.d.ts","sourceRoot":"","sources":["../../src/relay.ts"],"names":[],"mappings":"AAEA,OAAO,EAAoB,UAAU,EAAE,MAAM,qBAAqB,CAAC;AAEnE,OAAO,EAAc,IAAI,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAClE,OAAO,EAAyB,aAAa,EAAE,MAAM,qBAAqB,CAAC;AAC3E,OAAO,EAEL,WAAW,EACX,iBAAiB,EAClB,MAAM,iBAAiB,CAAC;AAEzB,OAAO,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC;AAC/C,OAAO,EAAE,uBAAuB,EAAE,MAAM,+BAA+B,CAAC;AACxE,OAAO,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAE1C;;;;GAIG;AACH,MAAM,MAAM,GAAG,GAAG,MAAM,IAAI,CAAC;AAE7B;;;GAGG;AACH,UAAU,KAAK;IACb;;;;;OAKG;IACH,IAAI,EAAE,CAAC,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,KAAK,IAAI,CAAC;IAE3D;;;;OAIG;IACH,OAAO,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,IAAI,CAAC;IAEhC;;;;;;;;;OASG;IACH,EAAE,EAAE,CAAC,IAAI,EAAE,MAAM,EAAE,QAAQ,EAAE,aAAa,KAAK,GAAG,CAAC;IAEnD;;;;;;OAMG;IACH,GAAG,EAAE,CAAC,IAAI,EAAE,MAAM,EAAE,QAAQ,CAAC,EAAE,aAAa,KAAK,IAAI,CAAC;IAEtD;;;;OAIG;IACH,YAAY,EAAE,CAAC,MAAM,EAAE,OAAO,CAAC,WAAW,CAAC,KAAK,IAAI,CAAC;IAErD;;OAEG;IACH,OAAO,EAAE,MAAM,CAAC;CACjB;AAED;;;;GAIG;AACH,wBAAgB,WAAW,CAAC,aAAa,EAAE,WAAW,GAAG,KAAK,CAyC7D;AAED,YAAY,EACV,KAAK,EACL,IAAI,EACJ,WAAW,EACX,aAAa,EACb,WAAW,EACX,YAAY,EACZ,UAAU,EACV,iBAAiB,GAClB,CAAC"}
|
package/lib/npm/relay.mjs
CHANGED
|
@@ -10,23 +10,24 @@ function emit({ config, environment, event, listenerManager, }) {
|
|
|
10
10
|
}
|
|
11
11
|
}
|
|
12
12
|
|
|
13
|
+
const clientIdKey = "visitorId";
|
|
14
|
+
|
|
13
15
|
function createClientIdManager(environmentManager) {
|
|
14
16
|
return {
|
|
15
17
|
getClientId: () => {
|
|
16
|
-
const key = "visitorId";
|
|
17
18
|
const environment = environmentManager.get();
|
|
18
19
|
const storage = environment.storage;
|
|
19
|
-
const existingClientId = storage.getItem(
|
|
20
|
+
const existingClientId = storage.getItem(clientIdKey);
|
|
20
21
|
const clientId = existingClientId && validate(existingClientId)
|
|
21
22
|
? existingClientId
|
|
22
23
|
: environment.generateUUID();
|
|
23
|
-
storage.setItem(
|
|
24
|
+
storage.setItem(clientIdKey, clientId);
|
|
24
25
|
return clientId;
|
|
25
26
|
},
|
|
26
27
|
};
|
|
27
28
|
}
|
|
28
29
|
|
|
29
|
-
const version = "1.
|
|
30
|
+
const version = "1.2.0";
|
|
30
31
|
|
|
31
32
|
function getEventConfig(config) {
|
|
32
33
|
const { trackingId } = config;
|
|
@@ -257,13 +258,18 @@ function buildNullEnvironment() {
|
|
|
257
258
|
function buildEnvironment(configManager) {
|
|
258
259
|
const active = configManager.get().mode !== "disabled";
|
|
259
260
|
const environmentFromConfig = configManager.get().environment;
|
|
261
|
+
const nullEnvironment = buildNullEnvironment();
|
|
260
262
|
if (active && environmentFromConfig) {
|
|
261
|
-
return {
|
|
263
|
+
return {
|
|
264
|
+
storage: nullEnvironment.storage,
|
|
265
|
+
...environmentFromConfig,
|
|
266
|
+
runtime: "custom",
|
|
267
|
+
};
|
|
262
268
|
}
|
|
263
269
|
if (active && isBrowser() && localStorageAvailable()) {
|
|
264
270
|
return buildBrowserEnvironment();
|
|
265
271
|
}
|
|
266
|
-
return
|
|
272
|
+
return nullEnvironment;
|
|
267
273
|
}
|
|
268
274
|
function isBrowser() {
|
|
269
275
|
try {
|
|
@@ -309,4 +315,4 @@ function createRelay(initialConfig) {
|
|
|
309
315
|
};
|
|
310
316
|
}
|
|
311
317
|
|
|
312
|
-
export { createRelay };
|
|
318
|
+
export { buildBrowserEnvironment, clientIdKey, createRelay };
|