@adobe/alloy 2.34.1 → 2.34.2-beta.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.
Files changed (47) hide show
  1. package/dist/alloy.js +329 -436
  2. package/dist/alloy.min.js +2 -2
  3. package/dist/types/browser/src/components/Advertising/index.d.ts +2 -1
  4. package/dist/types/browser/src/components/Advertising/utils/advertisingCookieManager.d.ts +2 -1
  5. package/dist/types/browser/src/components/PushNotifications/index.d.ts +4 -4
  6. package/dist/types/browser/src/index.d.ts +2 -1
  7. package/dist/types/browser/src/services/createBrowserGlobalsService.d.ts +0 -1
  8. package/dist/types/browser/src/services/createBrowserNetworkService.d.ts +1 -1
  9. package/dist/types/browser/src/services/createBrowserPlatformServices.d.ts +1 -4
  10. package/dist/types/core/src/components/Audiences/index.d.ts +2 -1
  11. package/dist/types/core/src/components/BrandConcierge/createSendConversationEvent.d.ts +2 -1
  12. package/dist/types/core/src/components/BrandConcierge/index.d.ts +2 -1
  13. package/dist/types/core/src/components/BrandConcierge/utils.d.ts +1 -1
  14. package/dist/types/core/src/components/Consent/createConsentHashStore.d.ts +2 -2
  15. package/dist/types/core/src/components/Consent/index.d.ts +2 -2
  16. package/dist/types/core/src/components/Identity/index.d.ts +2 -1
  17. package/dist/types/core/src/components/RulesEngine/createContextProvider.d.ts +2 -2
  18. package/dist/types/core/src/components/RulesEngine/index.d.ts +2 -2
  19. package/dist/types/core/src/components/RulesEngine/utils/storage.d.ts +1 -1
  20. package/dist/types/core/src/core/createLogController.d.ts +4 -4
  21. package/dist/types/core/src/core/index.d.ts +1 -3
  22. package/dist/types/core/src/index.d.ts +1 -4
  23. package/dist/types/core/src/services/types.d.ts +23 -3
  24. package/dist/types/core/src/utils/index.d.ts +2 -3
  25. package/dist/types/core/src/utils/injectDoesIdentityCookieExist.d.ts +2 -1
  26. package/dist/types/core/src/utils/request/createGetAssuranceValidationTokenParams.d.ts +2 -2
  27. package/package.json +3 -2
  28. package/src/components/Advertising/index.js +2 -0
  29. package/src/components/Advertising/utils/advertisingCookieManager.js +2 -2
  30. package/src/components/PushNotifications/index.js +4 -4
  31. package/src/components/PushNotifications/request/makeSendPushSubscriptionRequest.js +2 -1
  32. package/src/index.js +6 -1
  33. package/src/services/createBrowserCookieService.js +3 -2
  34. package/src/services/createBrowserGlobalsService.js +14 -0
  35. package/src/services/createBrowserNetworkService.js +3 -4
  36. package/src/services/createBrowserPlatformServices.js +2 -3
  37. package/src/services/injectSendBeaconRequest.js +32 -0
  38. package/src/services/injectSendFetchRequest.js +37 -0
  39. package/dist/types/core/src/components/Identity/visitorService/awaitVisitorOptIn.d.ts +0 -4
  40. package/dist/types/core/src/components/Identity/visitorService/getVisitor.d.ts +0 -2
  41. package/dist/types/core/src/components/Identity/visitorService/injectGetEcidFromVisitor.d.ts +0 -6
  42. package/dist/types/core/src/core/getMonitors.d.ts +0 -3
  43. package/dist/types/core/src/utils/cookieJar.d.ts +0 -7
  44. /package/dist/types/{core/src/core/network/requestMethods → browser/src/services}/injectSendBeaconRequest.d.ts +0 -0
  45. /package/dist/types/{core/src/core/network/requestMethods → browser/src/services}/injectSendFetchRequest.d.ts +0 -0
  46. /package/dist/types/core/src/utils/{fireImage.d.ts → dom/fireImage.d.ts} +0 -0
  47. /package/dist/types/core/src/utils/{injectFireReferrerHideableImage.d.ts → dom/injectFireReferrerHideableImage.d.ts} +0 -0
@@ -1,11 +1,12 @@
1
1
  export default createAdvertising;
2
- declare function createAdvertising({ logger, config, eventManager, sendEdgeNetworkRequest, consent, getBrowser, }: {
2
+ declare function createAdvertising({ logger, config, eventManager, sendEdgeNetworkRequest, consent, getBrowser, platformServices, }: {
3
3
  logger: any;
4
4
  config: any;
5
5
  eventManager: any;
6
6
  sendEdgeNetworkRequest: any;
7
7
  consent: any;
8
8
  getBrowser: any;
9
+ platformServices: any;
9
10
  }): {
10
11
  lifecycle: {
11
12
  onComponentsRegistered(): void;
@@ -1,6 +1,7 @@
1
- declare function _default({ orgId, logger }: {
1
+ declare function _default({ orgId, logger, cookieJar }: {
2
2
  orgId: any;
3
3
  logger: any;
4
+ cookieJar: any;
4
5
  }): {
5
6
  setValue: (key: any, value: any, options?: {}) => boolean;
6
7
  getValue: (key: any) => any;
@@ -4,16 +4,16 @@ export default createPushNotifications;
4
4
  *
5
5
  * @param {Object} options
6
6
  * @param {{ orgId: string, datastreamId: string, edgeDomain: string, edgeBasePath: string, pushNotifications: { vapidPublicKey: string, appId: string, trackingDatasetId: string }}} options.config
7
- * @param {StorageCreator} options.createNamespacedStorage
8
7
  * @param {EventManager} options.eventManager
9
8
  * @param {Logger} options.logger
10
9
  * @param {ConsentManager} options.consent
11
10
  * @param {IdentityManager} options.identity
12
11
  * @param {function(): string} options.getBrowser
13
12
  * @param {EdgeRequestExecutor} options.sendEdgeNetworkRequest
13
+ * @param {PlatformServices} options.platformServices
14
14
  * @returns {{ lifecycle: object, commands: { sendPushSubscription: object } }}
15
15
  */
16
- declare function createPushNotifications({ createNamespacedStorage, eventManager, config, logger, consent, identity, getBrowser, sendEdgeNetworkRequest, }: {
16
+ declare function createPushNotifications({ eventManager, config, logger, consent, identity, getBrowser, sendEdgeNetworkRequest, platformServices, }: {
17
17
  config: {
18
18
  orgId: string;
19
19
  datastreamId: string;
@@ -25,13 +25,13 @@ declare function createPushNotifications({ createNamespacedStorage, eventManager
25
25
  trackingDatasetId: string;
26
26
  };
27
27
  };
28
- createNamespacedStorage: StorageCreator;
29
28
  eventManager: EventManager;
30
29
  logger: Logger;
31
30
  consent: ConsentManager;
32
31
  identity: IdentityManager;
33
32
  getBrowser: () => string;
34
33
  sendEdgeNetworkRequest: EdgeRequestExecutor;
34
+ platformServices: PlatformServices;
35
35
  }): {
36
36
  lifecycle: object;
37
37
  commands: {
@@ -42,9 +42,9 @@ declare namespace createPushNotifications {
42
42
  let namespace: string;
43
43
  let configValidators: Function;
44
44
  }
45
- import type { StorageCreator } from '@adobe/alloy-core/utils/types.js';
46
45
  import type { EventManager } from '@adobe/alloy-core/core/types.js';
47
46
  import type { Logger } from '@adobe/alloy-core/core/types.js';
48
47
  import type { ConsentManager } from '@adobe/alloy-core/core/consent/types.js';
49
48
  import type { IdentityManager } from '@adobe/alloy-core/core/identity/types.js';
50
49
  import type { EdgeRequestExecutor } from '@adobe/alloy-core/core/edgeNetwork/types.js';
50
+ import type { PlatformServices } from '@adobe/alloy-core/services';
@@ -1,5 +1,6 @@
1
- export function createCustomInstance({ components, ...options }?: {
1
+ export function createCustomInstance({ components, monitors, ...options }?: {
2
2
  components?: never[] | undefined;
3
+ monitors?: never[] | undefined;
3
4
  }): (commandName: string, options?: Object) => Promise<any>;
4
5
  export function createInstance(options?: {}): (commandName: string, options?: Object) => Promise<any>;
5
6
  export { allOptionalComponents as components };
@@ -1,5 +1,4 @@
1
1
  export default createBrowserGlobalsService;
2
- /** @import { GlobalsService } from "@adobe/alloy-core/services" */
3
2
  /** @returns {GlobalsService} */
4
3
  declare function createBrowserGlobalsService(): GlobalsService;
5
4
  import type { GlobalsService } from "@adobe/alloy-core/services";
@@ -1,6 +1,6 @@
1
1
  export default createBrowserNetworkService;
2
2
  /**
3
- * @param {{ logger: import('@adobe/alloy-core/core/types.js').Logger }} dependencies
3
+ * @param {{ logger: import("@adobe/alloy-core/core/types.js").Logger }} params
4
4
  * @returns {NetworkService}
5
5
  */
6
6
  declare function createBrowserNetworkService({ logger }: {
@@ -1,9 +1,6 @@
1
1
  export default createBrowserPlatformServices;
2
2
  /**
3
- * @param {{ logger: import('@adobe/alloy-core/core/types.js').Logger }} dependencies
4
3
  * @returns {PlatformServices}
5
4
  */
6
- declare function createBrowserPlatformServices({ logger }: {
7
- logger: import("@adobe/alloy-core/core/types.js").Logger;
8
- }): PlatformServices;
5
+ declare function createBrowserPlatformServices(): PlatformServices;
9
6
  import type { PlatformServices } from "@adobe/alloy-core/services";
@@ -1,7 +1,8 @@
1
1
  export default createAudiences;
2
- declare function createAudiences({ logger, fireReferrerHideableImage }: {
2
+ declare function createAudiences({ logger, fireReferrerHideableImage, platformServices, }: {
3
3
  logger: any;
4
4
  fireReferrerHideableImage: any;
5
+ platformServices: any;
5
6
  }): {
6
7
  lifecycle: {
7
8
  onResponse: ({ response }: {
@@ -1,4 +1,4 @@
1
- declare function _default({ eventManager, config, logger, sendConversationServiceRequest, buildEndpointUrl, cookieTransfer, createResponse, decodeKndctrCookie, lifecycle, consent, session, }: {
1
+ declare function _default({ eventManager, config, logger, sendConversationServiceRequest, buildEndpointUrl, cookieTransfer, createResponse, decodeKndctrCookie, lifecycle, consent, session, getPageLocation, }: {
2
2
  eventManager: any;
3
3
  config: any;
4
4
  logger: any;
@@ -10,5 +10,6 @@ declare function _default({ eventManager, config, logger, sendConversationServic
10
10
  lifecycle: any;
11
11
  consent: any;
12
12
  session: any;
13
+ getPageLocation: any;
13
14
  }): (options: any) => any;
14
15
  export default _default;
@@ -1,5 +1,5 @@
1
1
  export default createConciergeComponent;
2
- declare function createConciergeComponent({ loggingCookieJar, logger, eventManager, consent, instanceName, sendEdgeNetworkRequest, config, lifecycle, cookieTransfer, createResponse, }: {
2
+ declare function createConciergeComponent({ loggingCookieJar, logger, eventManager, consent, instanceName, sendEdgeNetworkRequest, config, lifecycle, cookieTransfer, createResponse, platformServices, }: {
3
3
  loggingCookieJar: any;
4
4
  logger: any;
5
5
  eventManager: any;
@@ -10,6 +10,7 @@ declare function createConciergeComponent({ loggingCookieJar, logger, eventManag
10
10
  lifecycle: any;
11
11
  cookieTransfer: any;
12
12
  createResponse: any;
13
+ platformServices: any;
13
14
  }): {
14
15
  lifecycle: {
15
16
  onBeforeEvent({ event }: {
@@ -1,4 +1,4 @@
1
- export function getPageSurface(): string;
1
+ export function getPageSurface(getLocation: any): string;
2
2
  export function getConciergeSessionCookie({ loggingCookieJar, config }: {
3
3
  loggingCookieJar: any;
4
4
  config: any;
@@ -3,8 +3,8 @@ declare function _default({ storage }: {
3
3
  }): {
4
4
  clear(): void;
5
5
  lookup(consentObjects: any): {
6
- isNew(): any;
7
- save(): void;
6
+ isNew(): Promise<boolean>;
7
+ save(): Promise<void>;
8
8
  };
9
9
  };
10
10
  export default _default;
@@ -1,9 +1,9 @@
1
1
  export default createConsent;
2
- declare function createConsent({ config, consent, sendEdgeNetworkRequest, createNamespacedStorage, }: {
2
+ declare function createConsent({ config, consent, sendEdgeNetworkRequest, platformServices, }: {
3
3
  config: any;
4
4
  consent: any;
5
5
  sendEdgeNetworkRequest: any;
6
- createNamespacedStorage: any;
6
+ platformServices: any;
7
7
  }): {
8
8
  commands: {
9
9
  setConsent: {
@@ -1,5 +1,5 @@
1
1
  export default createIdentity;
2
- declare function createIdentity({ config, logger, consent, fireReferrerHideableImage, sendEdgeNetworkRequest, apexDomain, getBrowser, identity, }: {
2
+ declare function createIdentity({ config, logger, consent, fireReferrerHideableImage, sendEdgeNetworkRequest, apexDomain, getBrowser, identity, platformServices, }: {
3
3
  config: any;
4
4
  logger: any;
5
5
  consent: any;
@@ -8,6 +8,7 @@ declare function createIdentity({ config, logger, consent, fireReferrerHideableI
8
8
  apexDomain: any;
9
9
  getBrowser: any;
10
10
  identity: any;
11
+ platformServices: any;
11
12
  }): {
12
13
  lifecycle: {
13
14
  onBeforeRequest({ request, onResponse, onRequestFailure }: {
@@ -1,6 +1,6 @@
1
- declare function _default({ eventRegistry, window, getBrowser }: {
1
+ declare function _default({ eventRegistry, getWindowContext, getBrowser }: {
2
2
  eventRegistry: any;
3
- window: any;
3
+ getWindowContext: any;
4
4
  getBrowser: any;
5
5
  }): {
6
6
  getContext: (addedContext?: {}) => any;
@@ -1,11 +1,11 @@
1
1
  export default createRulesEngine;
2
- declare function createRulesEngine({ config, eventManager, createNamespacedStorage, consent, getBrowser, logger, }: {
2
+ declare function createRulesEngine({ config, eventManager, consent, getBrowser, logger, platformServices, }: {
3
3
  config: any;
4
4
  eventManager: any;
5
- createNamespacedStorage: any;
6
5
  consent: any;
7
6
  getBrowser: any;
8
7
  logger: any;
8
+ platformServices: any;
9
9
  }): {
10
10
  lifecycle: {
11
11
  onDecision({ propositions }: {
@@ -1,4 +1,4 @@
1
- export function createRestoreStorage(storage: any, storageKey: any): (defaultValue: any) => any[];
1
+ export function createRestoreStorage(storage: any, storageKey: any): (defaultValue: any) => Promise<any[]>;
2
2
  export function createSaveStorage(storage: any, storageKey: any): (value: any) => void;
3
3
  export function createInMemoryStorage(): {
4
4
  getItem: (key: any) => any;
@@ -1,12 +1,12 @@
1
- declare function _default({ console, createLogger, instanceName, createNamespacedStorage, getMonitors, }: {
1
+ declare function _default({ console, createLogger, instanceName, getMonitors, storage, }: {
2
2
  console: any;
3
3
  createLogger: any;
4
4
  instanceName: any;
5
- createNamespacedStorage: any;
6
5
  getMonitors: any;
6
+ storage: any;
7
7
  }): {
8
- setDebugEnabled: (value: any, { fromConfig }: {
9
- fromConfig: any;
8
+ setDebugEnabled: (value: any, { fromConfig }?: {
9
+ fromConfig?: boolean | undefined;
10
10
  }) => void;
11
11
  logger: any;
12
12
  createComponentLogger(componentName: any): any;
@@ -2,7 +2,5 @@ export function createExecuteCommand({ instanceName, monitors, components, creat
2
2
  instanceName: string;
3
3
  monitors?: import("./types.js").AlloyMonitor[] | undefined;
4
4
  components: Array<Function>;
5
- createPlatformServices: (deps: {
6
- logger: import("./types.js").Logger;
7
- }) => import("../services/index.js").PlatformServices;
5
+ createPlatformServices: () => import("../services/index.js").PlatformServices;
8
6
  }): (commandName: any, options?: {}) => Promise<any>;
@@ -7,8 +7,5 @@ export function createInstance(options?: {
7
7
  name?: string | undefined;
8
8
  monitors?: import("./core/types.js").AlloyMonitor[] | undefined;
9
9
  }, createPlatformServices?: CreatePlatformServices): (commandName: string, options?: Object) => Promise<any>;
10
- export type CreatePlatformServices = (deps: {
11
- logger: Logger;
12
- }) => PlatformServices;
13
- import type { Logger } from './core/types.js';
10
+ export type CreatePlatformServices = () => PlatformServices;
14
11
  import type { PlatformServices } from './services/index.js';
@@ -11,8 +11,7 @@ export type NetworkService = {
11
11
  */
12
12
  sendFetchRequest: SendFetchRequest;
13
13
  /**
14
- * May fall back to `sendFetchRequest` when the underlying transport is
15
- * unavailable.
14
+ * Falls back to `sendFetchRequest` when the underlying transport is unavailable.
16
15
  */
17
16
  sendBeaconRequest: SendBeaconRequest;
18
17
  };
@@ -42,6 +41,7 @@ export type CookieConverter = {
42
41
  };
43
42
  export type CookieService = {
44
43
  get: (name: string) => (string | undefined);
44
+ getAll: () => Record<string, string>;
45
45
  set: (name: string, value: string, options?: CookieAttributes) => (string | undefined);
46
46
  remove: (name: string, options?: CookieAttributes) => void;
47
47
  withConverter: (converter: CookieConverter) => CookieService;
@@ -73,16 +73,36 @@ export type LegacyService = {
73
73
  logger: import("../core/types.js").Logger;
74
74
  }) => Promise<void>;
75
75
  };
76
+ export type WindowContext = {
77
+ title: string;
78
+ url: string;
79
+ referrer: string;
80
+ height: number;
81
+ width: number;
82
+ scrollY: number;
83
+ scrollX: number;
84
+ };
76
85
  export type GlobalsService = {
77
86
  getInstanceNames: () => string[];
78
87
  getInstanceQueue: (instanceName: string) => any[];
79
88
  getMonitors: () => import("../core/types.js").AlloyMonitor[];
80
89
  getLocationSearch: () => string;
90
+ getLocationHash: () => string;
81
91
  getUserAgent: () => string;
82
92
  getHostname: () => string;
93
+ getPageLocation: () => {
94
+ host: string;
95
+ pathname: string;
96
+ };
97
+ isPageSsl: () => boolean;
98
+ fireReferrerHideableImage: (request: {
99
+ hideReferrer: boolean;
100
+ url: string;
101
+ }) => Promise<void>;
102
+ getWindowContext: () => WindowContext;
83
103
  };
84
104
  export type PlatformServices = {
85
- network: NetworkService;
105
+ createNetworkService: (logger: import("../core/types.js").Logger) => NetworkService;
86
106
  storage: StorageService;
87
107
  cookie: CookieService;
88
108
  runtime: RuntimeService;
@@ -1,6 +1,5 @@
1
1
  export { default as assignConcatArrayValues } from "./assignConcatArrayValues.js";
2
2
  export { default as clone } from "./clone.js";
3
- export { default as cookieJar } from "./cookieJar.js";
4
3
  export { default as createMerger } from "./createMerger.js";
5
4
  export { default as createCallbackAggregator } from "./createCallbackAggregator.js";
6
5
  export { default as createLoggingCookieJar } from "./createLoggingCookieJar.js";
@@ -8,8 +7,8 @@ export { default as createTaskQueue } from "./createTaskQueue.js";
8
7
  export { default as defer } from "./defer.js";
9
8
  export { default as deduplicateArray } from "./deduplicateArray.js";
10
9
  export { default as deepAssign } from "./deepAssign.js";
11
- export { default as fireImage } from "./fireImage.js";
12
- export { default as injectFireReferrerHideableImage } from "./injectFireReferrerHideableImage.js";
10
+ export { default as fireImage } from "./dom/fireImage.js";
11
+ export { default as injectFireReferrerHideableImage } from "./dom/injectFireReferrerHideableImage.js";
13
12
  export { default as filterObject } from "./filterObject.js";
14
13
  export { default as fnv1a32Hex } from "./fnv1a32Hex.js";
15
14
  export { default as getApexDomain } from "./getApexDomain.js";
@@ -1,4 +1,5 @@
1
- declare function _default({ orgId }: {
1
+ declare function _default({ orgId, cookieJar }: {
2
2
  orgId: any;
3
+ cookieJar: any;
3
4
  }): () => boolean;
4
5
  export default _default;
@@ -1,5 +1,5 @@
1
- declare function _default({ getLocationSearch, createNamespacedStorage }: {
1
+ declare function _default({ getLocationSearch, storage }: {
2
2
  getLocationSearch: any;
3
- createNamespacedStorage: any;
3
+ storage: any;
4
4
  }): () => string;
5
5
  export default _default;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@adobe/alloy",
3
- "version": "2.34.1",
3
+ "version": "2.34.2-beta.1",
4
4
  "description": "Adobe Experience Platform Web SDK",
5
5
  "type": "module",
6
6
  "repository": {
@@ -60,6 +60,7 @@
60
60
  "./components.json": "./components.json"
61
61
  },
62
62
  "dependencies": {
63
+ "js-cookie": "3.0.7",
63
64
  "@inquirer/prompts": "^7.9.0",
64
65
  "@rollup/plugin-commonjs": "^29.0.2",
65
66
  "@rollup/plugin-node-resolve": "^16.0.3",
@@ -68,7 +69,7 @@
68
69
  "commander": "^14.0.2",
69
70
  "rollup": "^4.60.3",
70
71
  "rollup-plugin-license": "^3.7.1",
71
- "@adobe/alloy-core": "^1.2.1"
72
+ "@adobe/alloy-core": "^1.2.2-beta.0"
72
73
  },
73
74
  "devDependencies": {
74
75
  "glob": "^13.0.6",
@@ -40,11 +40,13 @@ const createAdvertising = ({
40
40
  sendEdgeNetworkRequest,
41
41
  consent,
42
42
  getBrowser,
43
+ platformServices,
43
44
  }) => {
44
45
  const componentConfig = config.advertising;
45
46
  const cookieManager = createCookieManager({
46
47
  orgId: config.orgId,
47
48
  logger,
49
+ cookieJar: platformServices.cookie,
48
50
  });
49
51
 
50
52
  // One shared iframe call — both collectSurferId and hashedIpHandler use it
@@ -10,7 +10,7 @@ OF ANY KIND, either express or implied. See the License for the specific languag
10
10
  governing permissions and limitations under the License.
11
11
  */
12
12
 
13
- import { getNamespacedCookieName, cookieJar } from "@adobe/alloy-core/utils";
13
+ import { getNamespacedCookieName } from "@adobe/alloy-core/utils";
14
14
  import createLoggingCookieJar from "@adobe/alloy-core/utils/createLoggingCookieJar.js";
15
15
  import {
16
16
  ADVERTISING_COOKIE_KEY,
@@ -18,7 +18,7 @@ import {
18
18
  DEFAULT_THROTTLE_MINUTES,
19
19
  } from "../constants/index.js";
20
20
 
21
- export default ({ orgId, logger }) => {
21
+ export default ({ orgId, logger, cookieJar }) => {
22
22
  const loggingCookieJar = createLoggingCookieJar({ logger, cookieJar });
23
23
 
24
24
  const getCookieName = (key, useNamespace = true) =>
@@ -10,11 +10,11 @@ OF ANY KIND, either express or implied. See the License for the specific languag
10
10
  governing permissions and limitations under the License.
11
11
  */
12
12
 
13
- /** @import { StorageCreator } from '@adobe/alloy-core/utils/types.js' */
14
13
  /** @import { EventManager, Logger } from '@adobe/alloy-core/core/types.js' */
15
14
  /** @import { IdentityManager } from '@adobe/alloy-core/core/identity/types.js' */
16
15
  /** @import { ConsentManager } from '@adobe/alloy-core/core/consent/types.js' */
17
16
  /** @import { EdgeRequestExecutor } from '@adobe/alloy-core/core/edgeNetwork/types.js' */
17
+ /** @import { PlatformServices } from '@adobe/alloy-core/services' */
18
18
 
19
19
  import { objectOf, string } from "@adobe/alloy-core/utils/validation";
20
20
  import { sanitizeOrgIdForCookieName } from "@adobe/alloy-core/utils";
@@ -35,17 +35,16 @@ const isComponentConfigured = ({
35
35
  *
36
36
  * @param {Object} options
37
37
  * @param {{ orgId: string, datastreamId: string, edgeDomain: string, edgeBasePath: string, pushNotifications: { vapidPublicKey: string, appId: string, trackingDatasetId: string }}} options.config
38
- * @param {StorageCreator} options.createNamespacedStorage
39
38
  * @param {EventManager} options.eventManager
40
39
  * @param {Logger} options.logger
41
40
  * @param {ConsentManager} options.consent
42
41
  * @param {IdentityManager} options.identity
43
42
  * @param {function(): string} options.getBrowser
44
43
  * @param {EdgeRequestExecutor} options.sendEdgeNetworkRequest
44
+ * @param {PlatformServices} options.platformServices
45
45
  * @returns {{ lifecycle: object, commands: { sendPushSubscription: object } }}
46
46
  */
47
47
  const createPushNotifications = ({
48
- createNamespacedStorage,
49
48
  eventManager,
50
49
  config,
51
50
  logger,
@@ -53,6 +52,7 @@ const createPushNotifications = ({
53
52
  identity,
54
53
  getBrowser,
55
54
  sendEdgeNetworkRequest,
55
+ platformServices,
56
56
  }) => {
57
57
  return {
58
58
  lifecycle: {
@@ -92,7 +92,7 @@ const createPushNotifications = ({
92
92
  },
93
93
  } = config || {};
94
94
 
95
- const storage = createNamespacedStorage(
95
+ const storage = platformServices.storage.createNamespacedStorage(
96
96
  `${sanitizeOrgIdForCookieName(orgId)}.pushNotifications.`,
97
97
  );
98
98
 
@@ -69,8 +69,9 @@ export default async ({
69
69
  );
70
70
 
71
71
  const cacheValue = `${ecid}${serializedPushSubscriptionDetails}`;
72
+ const storedValue = await storage.getItem(SUBSCRIPTION_DETAILS);
72
73
 
73
- if (cacheValue === storage.getItem(SUBSCRIPTION_DETAILS)) {
74
+ if (cacheValue === storedValue) {
74
75
  logger.info(
75
76
  "Subscription details have not changed. Not sending to the server.",
76
77
  );
package/src/index.js CHANGED
@@ -14,10 +14,15 @@ import * as allOptionalComponents from "./allOptionalComponents.js";
14
14
  import * as allRequiredComponents from "./components/requiredComponentCreators.js";
15
15
  import createBrowserPlatformServices from "./services/createBrowserPlatformServices.js";
16
16
 
17
- export const createCustomInstance = ({ components = [], ...options } = {}) =>
17
+ export const createCustomInstance = ({
18
+ components = [],
19
+ monitors = [],
20
+ ...options
21
+ } = {}) =>
18
22
  createCoreCustomInstance(
19
23
  {
20
24
  ...options,
25
+ monitors,
21
26
  components: [...Object.values(allRequiredComponents), ...components],
22
27
  },
23
28
  createBrowserPlatformServices,
@@ -12,7 +12,7 @@ governing permissions and limitations under the License.
12
12
 
13
13
  /** @import { CookieService } from "@adobe/alloy-core/services" */
14
14
 
15
- import cookieJar from "@adobe/alloy-core/utils/cookieJar.js";
15
+ import Cookies from "js-cookie";
16
16
 
17
17
  /**
18
18
  * The optional `jar` parameter is the recursion seam for `withConverter` —
@@ -21,8 +21,9 @@ import cookieJar from "@adobe/alloy-core/utils/cookieJar.js";
21
21
  * @param {{ get: Function, set: Function, remove: Function, withConverter: Function }} [jar]
22
22
  * @returns {CookieService}
23
23
  */
24
- const createBrowserCookieService = (jar = cookieJar) => ({
24
+ const createBrowserCookieService = (jar = Cookies) => ({
25
25
  get: (name) => jar.get(name),
26
+ getAll: () => jar.get(),
26
27
  set: (name, value, options) => jar.set(name, value, options),
27
28
  remove: (name, options) => {
28
29
  jar.remove(name, options);
@@ -13,6 +13,7 @@ governing permissions and limitations under the License.
13
13
  /* eslint-disable dot-notation */
14
14
 
15
15
  /** @import { GlobalsService } from "@adobe/alloy-core/services" */
16
+ import injectFireReferrerHideableImage from "@adobe/alloy-core/utils/dom/injectFireReferrerHideableImage.js";
16
17
 
17
18
  /** @returns {GlobalsService} */
18
19
  const createBrowserGlobalsService = () => ({
@@ -23,8 +24,21 @@ const createBrowserGlobalsService = () => ({
23
24
  },
24
25
  getMonitors: () => window["__alloyMonitors"] || [],
25
26
  getLocationSearch: () => window.location.search,
27
+ getLocationHash: () => window.location.hash,
26
28
  getUserAgent: () => window.navigator.userAgent,
27
29
  getHostname: () => window.location.hostname,
30
+ getPageLocation: () => window.location,
31
+ isPageSsl: () => window.location.protocol === "https:",
32
+ fireReferrerHideableImage: injectFireReferrerHideableImage(),
33
+ getWindowContext: () => ({
34
+ title: document.title,
35
+ url: window.location.href,
36
+ referrer: document.referrer,
37
+ height: window.innerHeight,
38
+ width: window.innerWidth,
39
+ scrollY: window.scrollY,
40
+ scrollX: window.scrollX,
41
+ }),
28
42
  });
29
43
 
30
44
  export default createBrowserGlobalsService;
@@ -12,11 +12,11 @@ governing permissions and limitations under the License.
12
12
 
13
13
  /** @import { NetworkService } from "@adobe/alloy-core/services" */
14
14
 
15
- import injectSendFetchRequest from "@adobe/alloy-core/core/network/requestMethods/injectSendFetchRequest.js";
16
- import injectSendBeaconRequest from "@adobe/alloy-core/core/network/requestMethods/injectSendBeaconRequest.js";
15
+ import injectSendFetchRequest from "./injectSendFetchRequest.js";
16
+ import injectSendBeaconRequest from "./injectSendBeaconRequest.js";
17
17
 
18
18
  /**
19
- * @param {{ logger: import('@adobe/alloy-core/core/types.js').Logger }} dependencies
19
+ * @param {{ logger: import("@adobe/alloy-core/core/types.js").Logger }} params
20
20
  * @returns {NetworkService}
21
21
  */
22
22
  const createBrowserNetworkService = ({ logger }) => {
@@ -25,7 +25,6 @@ const createBrowserNetworkService = ({ logger }) => {
25
25
  const sendBeaconRequest =
26
26
  typeof navigator.sendBeacon === "function"
27
27
  ? injectSendBeaconRequest({
28
- // bind() avoids "illegal invocation" when sendBeacon loses its receiver.
29
28
  sendBeacon: navigator.sendBeacon.bind(navigator),
30
29
  sendFetchRequest,
31
30
  logger,
@@ -20,11 +20,10 @@ import createBrowserLegacyService from "./createBrowserLegacyService.js";
20
20
  import createBrowserGlobalsService from "./createBrowserGlobalsService.js";
21
21
 
22
22
  /**
23
- * @param {{ logger: import('@adobe/alloy-core/core/types.js').Logger }} dependencies
24
23
  * @returns {PlatformServices}
25
24
  */
26
- const createBrowserPlatformServices = ({ logger }) => ({
27
- network: createBrowserNetworkService({ logger }),
25
+ const createBrowserPlatformServices = () => ({
26
+ createNetworkService: (logger) => createBrowserNetworkService({ logger }),
28
27
  storage: createBrowserStorageService(),
29
28
  cookie: createBrowserCookieService(),
30
29
  runtime: createBrowserRuntimeService(),
@@ -0,0 +1,32 @@
1
+ /*
2
+ Copyright 2019 Adobe. All rights reserved.
3
+ This file is licensed to you under the Apache License, Version 2.0 (the "License");
4
+ you may not use this file except in compliance with the License. You may obtain a copy
5
+ of the License at http://www.apache.org/licenses/LICENSE-2.0
6
+
7
+ Unless required by applicable law or agreed to in writing, software distributed under
8
+ the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
9
+ OF ANY KIND, either express or implied. See the License for the specific language
10
+ governing permissions and limitations under the License.
11
+ */
12
+
13
+ export default ({ sendBeacon, sendFetchRequest, logger }) => {
14
+ return (url, body) => {
15
+ const blob = new Blob([body], { type: "text/plain; charset=UTF-8" });
16
+ if (!sendBeacon(url, blob)) {
17
+ logger.info("Unable to use `sendBeacon`; falling back to `fetch`.");
18
+ return sendFetchRequest(url, body);
19
+ }
20
+
21
+ // Using sendBeacon, we technically don't get a response back from
22
+ // the server, but we'll resolve the promise with an object to maintain
23
+ // consistency with other network strategies.
24
+ return Promise.resolve({
25
+ statusCode: 204,
26
+ getHeader() {
27
+ return null;
28
+ },
29
+ body: "",
30
+ });
31
+ };
32
+ };