Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions apps/AEPSampleApp/App.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ function HomeScreen({ navigation }) {
/>
<Button
onPress={() => navigation.navigate('MessagingView')}
title="Messaging"/>
title="Messaging" />
<Button
onPress={() => navigation.navigate('EdgeView')}
title="Edge"
Expand Down Expand Up @@ -64,7 +64,7 @@ export default function App() {
<Drawer.Screen name="EdgeIdentity" component={EdgeIdentity} />
<Drawer.Screen name="ConsentView" component={ConsentView} />
<Drawer.Screen name="Assurance" component={Assurance} />
</Drawer.Navigator>
</NavigationContainer>
</Drawer.Navigator >
</NavigationContainer >
);
}
9 changes: 0 additions & 9 deletions packages/core/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -91,15 +91,6 @@ var event = new Event("eventName", "eventType", "eventSource", {"testDataKey": "
MobileCore.dispatchEventWithResponseCallback(event).then(responseEvent => console.log("AdobeExperienceSDK: responseEvent = " + responseEvent));
```

##### Dispatching an Event Hub response event (Android Only):
```javascript
import {Event} from '@adobe/react-native-aepcore';

var responseEvent = new Event("responseEvent", "eventType", "eventSource", {"testDataKey": "testDataValue"});
var requestEvent = new Event("requestEvent", "eventType", "eventSource", {"testDataKey": "testDataValue"});
MobileCore.dispatchResponseEvent(responseEvent, requestEvent);
```

##### Collecting PII:
```javascript
MobileCore.collectPii({"myPii": "data"});
Expand Down
4 changes: 2 additions & 2 deletions packages/core/__tests__/IdentityTests.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ describe('Identity', () => {
let identifiers = {"testKey": "testValue"};
let authState = MobileVisitorAuthenticationState.LOGGED_OUT;
await Identity.syncIdentifiersWithAuthState(identifiers, authState);
expect(spy).toHaveBeenCalledWith(identifiers, authState);
expect(spy).toHaveBeenCalledWith(identifiers, 'VISITOR_AUTH_STATE_LOGGED_OUT');
});

test('syncIdentifier is called with correct parameters', async () => {
Expand All @@ -45,7 +45,7 @@ describe('Identity', () => {
let identifierType = "testIdType"
let authState = MobileVisitorAuthenticationState.AUTHENTICATED;
await Identity.syncIdentifier(identifier, identifierType, authState);
expect(spy).toHaveBeenCalledWith(identifier, identifierType, authState);
expect(spy).toHaveBeenCalledWith(identifier, identifierType, 'VISITOR_AUTH_STATE_AUTHENTICATED');
});

test('appendVisitorInfoForURL is called with correct parameters', async () => {
Expand Down
18 changes: 6 additions & 12 deletions packages/core/__tests__/MobileCoreTests.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,13 +41,14 @@ describe('MobileCore', () => {
const spy = jest.spyOn(NativeModules.AEPCore, 'setLogLevel');
let logLevel = LogLevel.DEBUG;
await MobileCore.setLogLevel(logLevel);
expect(spy).toHaveBeenCalledWith(logLevel);
expect(spy).toHaveBeenCalledWith("DEBUG");
});

it('getLogLevel is called', async () => {
const spy = jest.spyOn(NativeModules.AEPCore, 'getLogLevel');
await MobileCore.getLogLevel();
const logLevel = await MobileCore.getLogLevel();
expect(spy).toHaveBeenCalled();
expect(logLevel).toEqual(LogLevel.DEBUG);
});

it('log is called with correct parameters', async () => {
Expand All @@ -63,13 +64,14 @@ describe('MobileCore', () => {
const spy = jest.spyOn(NativeModules.AEPCore, 'setPrivacyStatus');
let privacyStatus = PrivacyStatus.UNKNOWN;
await MobileCore.setPrivacyStatus(privacyStatus);
expect(spy).toHaveBeenCalledWith(privacyStatus);
expect(spy).toHaveBeenCalledWith("UNKNOWN");
});

it('getPrivacyStatus is called', async () => {
const spy = jest.spyOn(NativeModules.AEPCore, 'getPrivacyStatus');
await MobileCore.getPrivacyStatus();
const privacyStatus = await MobileCore.getPrivacyStatus();
expect(spy).toHaveBeenCalled();
expect(privacyStatus).toEqual(PrivacyStatus.OPT_OUT);
});

it('getSdkIdentities is called', async () => {
Expand All @@ -92,14 +94,6 @@ describe('MobileCore', () => {
expect(spy).toHaveBeenCalledWith(testEvent);
});

it('dispatchResponseEvent is called with correct parameters', async () => {
const spy = jest.spyOn(NativeModules.AEPCore, 'dispatchResponseEvent');
let testEvent = new Event("eventName", "eventType", "eventSource", {"testDataKey": "testDataValue"});
let testEvent1 = new Event("eventName1", "eventType1", "eventSource1", {"testDataKey1": "testDataValue1"});
await MobileCore.dispatchResponseEvent(testEvent, testEvent1);
expect(spy).toHaveBeenCalledWith(testEvent, testEvent1);
});

it('trackAction is called with correct parameters', async () => {
const spy = jest.spyOn(NativeModules.AEPCore, 'trackAction');
let actionName = "testAction";
Expand Down
21 changes: 1 addition & 20 deletions packages/core/js/MobileCore.js
Original file line number Diff line number Diff line change
Expand Up @@ -142,36 +142,17 @@ module.exports = {

/**
* This method will be used when the provided {@code Event} is used as a trigger and a response event
* is expected in return. The returned event needs to be sent using
* {@link #dispatchResponseEvent(Event, Event, ExtensionErrorCallback)}.
* is expected in return.
* <p>
*
* @param event required parameter, {@link Event} instance to be dispatched, used as a trigger
* @param responseCallback required parameters, {@link Promise} to be called with the response event received
*
* @see AEPCore#dispatchResponseEvent(Event, Event, ExtensionErrorCallback)
*/
dispatchEventWithResponseCallback(event: Event): Promise<Event> {
return RCTAEPCore.dispatchEventWithResponseCallback(event);
},

/**
* Android Only
* Dispatches a response event for a paired event that was sent to {@code dispatchEventWithResponseCallback}
* and received by an extension listener {@code hear} method.
*
* @param responseEvent required parameter, {@link Event} instance to be dispatched as a response for the
* event sent using {@link AEPCore#dispatchEventWithResponseCallback(Event)}
* @param requestEvent required parameter, the event sent using
* {@link AEPCore#dispatchEventWithResponseCallback(Event)}
* @return {@code boolean} indicating if the the event dispatching operation succeeded
*
* @see AEPCore#dispatchEventWithResponseCallback(Event)
*/
dispatchResponseEvent(responseEvent: Event, requestEvent: Event): Promise<boolean> {
return RCTAEPCore.dispatchResponseEvent(responseEvent, requestEvent);
},

/**
* This method sends a generic Analytics action tracking hit with context data.
*
Expand Down
39 changes: 19 additions & 20 deletions packages/core/js/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,15 +14,14 @@ export class MobileCore{
static extensionVersion(): Promise<string>;
static configureWithAppId(appId?: string);
static updateConfiguration(configMap?: Map);
static setLogLevel(mode: string);
static getLogLevel(): Promise<string>;
static setLogLevel(mode: LogLevel);
static getLogLevel(): Promise<LogLevel>;
static log(logLevel: string, tag: string, message: string);
static setPrivacyStatus(privacyStatus: string);
static getPrivacyStatus(): Promise<string>;
static setPrivacyStatus(privacyStatus: PrivacyStatus);
static getPrivacyStatus(): Promise<PrivacyStatus>;
static getSdkIdentities(): Promise<?string>;
static dispatchEvent(event: Event): Promise<boolean>;
static dispatchEventWithResponseCallback(event: Event): Promise<Event>;
static dispatchResponseEvent(responseEvent: Event, requestEvent: Event): Promise<boolean>;
static trackAction(action?: string, contextData?: Map);
static trackState(state?: string, contextData?: Map);
static setAdvertisingIdentifier(advertisingIdentifier?: string);
Expand All @@ -39,8 +38,8 @@ export class Lifecycle{
export class Identity{
static extensionVersion(): Promise<string>;
static syncIdentifiers(identifiers?: Map);
static syncIdentifiersWithAuthState(identifiers?: Map, authenticationState: string);
static syncIdentifier(identifierType: string, identifier: string, authenticationState: string);
static syncIdentifiersWithAuthState(identifiers?: Map, authenticationState: MobileVisitorAuthenticationState);
static syncIdentifier(identifierType: string, identifier: string, authenticationState: MobileVisitorAuthenticationState);
static appendVisitorInfoForURL(baseURL?: string): Promise<?string>;
static getUrlVariables(): Promise<?string>;
static getIdentifiers(): Promise<Array<?VisitorID>>;
Expand All @@ -50,21 +49,21 @@ export class Signal{
static extensionVersion(): Promise<string>;
}

export class PrivacyStatus{
static OPT_IN: string;
static OPT_OUT: string;
static UNKNOWN: string;
export enum PrivacyStatus{
OPT_IN = "OPT_IN",
OPT_OUT = "OPT_OUT",
UNKNOWN = "UNKNOWN",
}
export class LogLevel{
static ERROR: string;
static WARNING: string;
static DEBUG: string;
static VERBOSE: string;
export enum LogLevel{
ERROR = "ERROR",
WARNING = "WARNING",
DEBUG = "DEBUG",
VERBOSE = "VERBOSE",
}
export class MobileVisitorAuthenticationState{
static AUTHENTICATED: string;
static LOGGED_OUT: string;
static UNKNOWN: string;
export enum MobileVisitorAuthenticationState{
AUTHENTICATED = "VISITOR_AUTH_STATE_AUTHENTICATED",
LOGGED_OUT = "VISITOR_AUTH_STATE_LOGGED_OUT",
UNKNOWN = "VISITOR_AUTH_STATE_UNKNOWN",
}
export class VisitorID{
idOrigin: string;
Expand Down
5 changes: 2 additions & 3 deletions tests/jest/setup.ts
Original file line number Diff line number Diff line change
Expand Up @@ -51,14 +51,13 @@ jest.doMock('react-native', () => {
configureWithAppId: jest.fn(),
updateConfiguration: jest.fn(),
setLogLevel: jest.fn(),
getLogLevel: jest.fn(() => new Promise(resolve => resolve(''))),
getLogLevel: jest.fn(() => new Promise(resolve => resolve('DEBUG'))),
log: jest.fn(),
setPrivacyStatus: jest.fn(),
getPrivacyStatus: jest.fn(() => new Promise(resolve => resolve(''))),
getPrivacyStatus: jest.fn(() => new Promise(resolve => resolve('OPT_OUT'))),
getSdkIdentities: jest.fn(() => new Promise(resolve => resolve(''))),
dispatchEvent: jest.fn(),
dispatchEventWithResponseCallback: jest.fn(() => new Promise(resolve => resolve(null))),
dispatchResponseEvent: jest.fn(() => new Promise(resolve => resolve(false))),
trackAction: jest.fn(),
trackState: jest.fn(),
setAdvertisingIdentifier: jest.fn(),
Expand Down
24 changes: 12 additions & 12 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -4669,9 +4669,9 @@ [email protected]:
integrity sha1-WQxhFWsK4vTwJVcyoViyZrxWsh0=

electron-to-chromium@^1.3.896:
version "1.4.8"
resolved "https://registry.yarnpkg.com/electron-to-chromium/-/electron-to-chromium-1.4.8.tgz#e1b7752ac1a75e39b5dd90cc7e29ea08b351c484"
integrity sha512-Cu5+dbg55+1E3ohlsa8HT0s4b8D0gBewXEGG8s5wBl8ynWv60VuvYW25GpsOeTVXpulhyU/U8JYZH+yxASSJBQ==
version "1.4.7"
resolved "https://registry.yarnpkg.com/electron-to-chromium/-/electron-to-chromium-1.4.7.tgz#58e0b4ec9096ee1422e4d9e83ceeb05b0cf076eb"
integrity sha512-UPy2MsQw1OdcbxR7fvwWZH/rXcv+V26+uvQVHx0fGa1kqRfydtfOw+NMGAvZJ63hyaH4aEBxbhSEtqbpliSNWA==

emittery@^0.8.1:
version "0.8.1"
Expand Down Expand Up @@ -5107,9 +5107,9 @@ [email protected]:
integrity sha512-3ErXSAXZZlLV5/QPlaUDCWlDUXop1SiH32ifXL3SEiBwsmGbudCLim+HFVZfkegrn1nB4TcNSkMWtW8SnMPyAQ==

flow-parser@0.*:
version "0.166.0"
resolved "https://registry.yarnpkg.com/flow-parser/-/flow-parser-0.166.0.tgz#0c0998af887e9476ef742fad94b7d32da6c7be24"
integrity sha512-YZCDEORZNCp0wTPSqcuYSg7W4cwWdVpArjAiy0tgY712oJvWiKAxaoSp+64GQmycDUpQiq1gtbupBdGg8Mp3bA==
version "0.165.1"
resolved "https://registry.yarnpkg.com/flow-parser/-/flow-parser-0.165.1.tgz#e420c560d0c9bd0e546b9f1b79afed37174298c5"
integrity sha512-vz/5MZIePDCZO9FfnRaH398cc+XSwtgoUzR6pC5zbekpk5ttCaXOnxypho+hb0NzUyQNFV+6vpU8joRZ1llrCw==

flow-parser@^0.121.0:
version "0.121.0"
Expand Down Expand Up @@ -6238,9 +6238,9 @@ istanbul-lib-source-maps@^4.0.0:
source-map "^0.6.1"

istanbul-reports@^3.0.2:
version "3.1.1"
resolved "https://registry.yarnpkg.com/istanbul-reports/-/istanbul-reports-3.1.1.tgz#7085857f17d2441053c6ce5c3b8fdf6882289397"
integrity sha512-q1kvhAXWSsXfMjCdNHNPKZZv94OlspKnoGv+R9RGbnqOOQ0VbNfLFgQDVgi7hHenKsndGq3/o0OBdzDXthWcNw==
version "3.1.0"
resolved "https://registry.yarnpkg.com/istanbul-reports/-/istanbul-reports-3.1.0.tgz#57a32bff7ab4b315e401daa08fe2934e0c0b1ec2"
integrity sha512-rgeP8yMlXeH4mfd9K/sQXZv1lvcS7xo379zntcotPDdMwkcGYwMxGHGZYo0/+YW5B/nor2YGKz2BH5ume405ow==
dependencies:
html-escaper "^2.0.0"
istanbul-lib-report "^3.0.0"
Expand Down Expand Up @@ -6742,9 +6742,9 @@ jetifier@^1.6.2:
integrity sha512-3Zi16h6L5tXDRQJTb221cnRoVG9/9OvreLdLU2/ZjRv/GILL+2Cemt0IKvkowwkDpvouAU1DQPOJ7qaiHeIdrw==

joi@^17.2.1:
version "17.5.0"
resolved "https://registry.yarnpkg.com/joi/-/joi-17.5.0.tgz#7e66d0004b5045d971cf416a55fb61d33ac6e011"
integrity sha512-R7hR50COp7StzLnDi4ywOXHrBrgNXuUUfJWIR5lPY5Bm/pOD3jZaTwpluUXVLRWcoWZxkrHBBJ5hLxgnlehbdw==
version "17.4.3"
resolved "https://registry.yarnpkg.com/joi/-/joi-17.4.3.tgz#462941fd994f11fcb92f59ba9f004706b9a45d17"
integrity sha512-8W3oOogFRuy2aLAdlhMpzS4fNBIMiyIa3xBaBYMFgA272/d5sob1DAth6jjo+5VrOlzbEgmbBGbU4cLrffPKog==
dependencies:
"@hapi/hoek" "^9.0.0"
"@hapi/topo" "^5.0.0"
Expand Down