Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

FIRECERT-2148: Implementation ticket for 1.2.0 - In-App User interests' behavioral scenarios #150

Merged
merged 9 commits into from
Jun 28, 2024
9 changes: 8 additions & 1 deletion src/App.js
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,7 @@ export default class App extends Base {
process.env.REPORTINGID = reportingId;
process.env.STANDALONE = standalone;
process.env.STANDALONE_PREFIX = standalonePrefix;
process.env.REGISTERPROVIDER = true;

// Set the pubSub URL if present
process.env.PUB_SUB_URL = new URLSearchParams(window.location.search).get('pubSubUrl');
Expand Down Expand Up @@ -209,7 +210,9 @@ export default class App extends Base {
Keyboard.provide('xrn:firebolt:capability:input:keyboard', new KeyboardProviderDelegater(this));
PinChallenge.provide('xrn:firebolt:capability:usergrant:pinchallenge', new PinChallengeProviderDelegater(this));
} else {
Discovery.provide('xrn:firebolt:capability:discovery:interest', new UserInterestDelegater(this));
if (process.env.REGISTERPROVIDER) {
neeradanelxsi marked this conversation as resolved.
Show resolved Hide resolved
Discovery.provide('xrn:firebolt:capability:discovery:interest', new UserInterestDelegater(this));
}
}
} catch (err) {
logger.error('Could not set up providers' + err, 'LoadedState');
Expand Down Expand Up @@ -414,6 +417,10 @@ export default class App extends Base {
logger.error('No Mac Address Found in Parameter Initialization response...', 'getParameterInitializationValues');
}

if (query.params.hasOwnProperty(CONSTANTS.REGISTERPROVIDER)) {
process.env.REGISTERPROVIDER = query.params.registerprovider;
}

// Set the pubSub URL if present
if (query.params.pubSubUrl) {
process.env.PUB_SUB_URL = query.params.pubSubUrl;
Expand Down
1 change: 1 addition & 0 deletions src/constant.js
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,7 @@ export const CONSTANTS = {
WRONG_RESPONSE_MESSAGE_FORMAT: 'Unexpected error format encountered in the response',
EXCLUDED_METHODS_FOR_SDK: [],
EXCLUDED_METHODS_FOR_TRANSPORT: [],
REGISTERPROVIDER: 'registerprovider',
defaultSDKs: [
{
name: 'Core',
Expand Down
18 changes: 12 additions & 6 deletions src/providers/UserInterestProvider.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,18 @@
export default class UserIntrestProvider {
userInterest() {
try {
const USERINTERESTDATA = require('../source/userInterest.json');
if (USERINTERESTDATA.hasOwnProperty(process.env.userInterestKey)) {
const data = USERINTERESTDATA[process.env.userInterestKey];
return Promise.resolve(data);
} else {
return Promise.resolve(null);
if (process.env.userInterestError == null || process.env.userInterestError.toLowerCase() != 'timeout') {
if (process.env.userInterestError && process.env.userInterestError.toLowerCase() == 'error') {
return Promise.reject({ code: 1000, message: 'Custom error from provider' });
} else {
const USERINTERESTDATA = require('../source/userInterest.json');
if (USERINTERESTDATA.hasOwnProperty(process.env.userInterestKey)) {
const data = USERINTERESTDATA[process.env.userInterestKey];
return Promise.resolve(data);
} else {
return Promise.resolve(null);
}
}
}
} catch (err) {
logger.error('Error in userInterest provider: ', err.message);
Expand Down
1 change: 1 addition & 0 deletions src/pubsub/handlers/setApiResponseHandler.js
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,7 @@ export default class SetApiResponseHandler extends BaseHandler {
setResponseUserInterestChallenge(message) {
const userInterestData = message.params.apiResponse.attributes[0];
process.env.userInterestKey = userInterestData.userInterestKey;
process.env.userInterestError = userInterestData.userInterestError;
const reportIdString = JSON.stringify({ report: 'Received UserInterest apiResponse parameters' });
return reportIdString;
}
Expand Down