@adobe/react-native-aepedge
Version:
Adobe Experience Platform Edge Network extension for Adobe Experience Platform Mobile SDK. Written and maintained by Adobe.
78 lines (77 loc) • 3.68 kB
JavaScript
;
/*
Copyright 2022 Adobe. All rights reserved.
This file is licensed to you under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License. You may obtain a copy
of the License at http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software distributed under
the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
OF ANY KIND, either express or implied. See the License for the specific language
governing permissions and limitations under the License.
*/
Object.defineProperty(exports, "__esModule", { value: true });
const tslib_1 = require("tslib");
const react_native_1 = require("react-native");
const EdgeEventHandle_1 = tslib_1.__importDefault(require("./models/EdgeEventHandle"));
const RCTAEPEdge = react_native_1.NativeModules.AEPEdge;
const Edge = {
/**
* Returns the version of the Edge extension
* @return {string} Promise that resolves with the extension version
*/
extensionVersion() {
return Promise.resolve(RCTAEPEdge.extensionVersion());
},
/**
* Send an Experience Event to Adobe Experience Edge
*
* @param experienceEvent Event to be sent to Adobe Experience Edge
* @return Promise fulfilled when the request is complete, returning the associated
* response handles received from the Adobe Experience Edge or rejected
* if an unexpected error occured; it may return an empty array
* if no handles were returned for the given experienceEvent
*/
sendEvent(experienceEvent) {
const sentEventPromise = new Promise((resolve, reject) => {
RCTAEPEdge.sendEvent(experienceEvent)
.then((eventHandles) => {
let eventHandlesPromise = toEventHandle(eventHandles);
resolve(eventHandlesPromise);
})
.catch((error) => {
reject(error);
});
});
return sentEventPromise;
},
/**
* Set the Edge Network location hint used in requests to the Adobe Experience Platform Edge Network.
* Sets the Edge Network location hint used in requests to the AEP Edge Network causing requests to "stick" to a specific server cluster.
* Passing null or an empty string will clear the existing location hint. Edge Network responses may overwrite the location hint to a new value when necessary to manage network traffic.
* Use caution when setting the location hint. Only use location hints for the 'EdgeNetwork' scope. An incorrect location hint value will cause all Edge Network requests to fail.
* @param {string?} hint the Edge Network location hint to use when connecting to the Adobe Experience Platform Edge Network
*/
setLocationHint(hint) {
RCTAEPEdge.setLocationHint(hint);
},
/**
* Gets the Edge Network location hint used in requests to the Adobe Experience Platform Edge Network.
* The Edge Network location hint may be used when building the URL for Adobe Experience Platform Edge Network
* requests to hint at the server cluster to use.
* @return the Edge Network location hint, or null if the location hint expired or is not set.
*/
getLocationHint() {
return RCTAEPEdge.getLocationHint();
}
};
function toEventHandle(eventArray) {
let edgeEventArray = [];
if (eventArray) {
for (let prop of eventArray) {
edgeEventArray.push(new EdgeEventHandle_1.default(prop.type, prop.payload));
}
}
return edgeEventArray;
}
exports.default = Edge;
//# sourceMappingURL=Edge.js.map