generated from adobecom/milo-college
-
Notifications
You must be signed in to change notification settings - Fork 12
[Draft] [MWPW-179252] Add pageConfig call for optimal endpoint #569
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
Draft
vipu0303
wants to merge
12
commits into
stage
Choose a base branch
from
pageConfig
base: stage
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
Changes from all commits
Commits
Show all changes
12 commits
Select commit
Hold shift + click to select a range
e207af4
initial pageConfig changes
eda0c0f
moving pageConfig call to NetworkUtils
d06c44d
updates
5c4620b
minor update
dc8853c
passing logEndPoint in analytics event to slytherin
2b8696c
minor updates
a83defa
updating error/warn log
20b2848
implement analytics
0066bc6
updating analytics
90aac4c
sending pageConfig success analytics event
397fce2
review comments
e1e7082
review comments
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -109,6 +109,7 @@ export default class ActionBinder { | |
| upload_warn_delete_asset: -603, | ||
| validation_warn_validate_files: -604, | ||
| warn_fetch_experiment: -605, | ||
| warn_page_config_call_failed: -606, | ||
| }; | ||
|
|
||
| static NEW_TO_OLD_ERROR_KEY_MAP = { | ||
|
|
@@ -215,13 +216,17 @@ export default class ActionBinder { | |
| }); | ||
| } | ||
|
|
||
| getAcrobatApiConfig() { | ||
| unityConfig.acrobatEndpoint = { | ||
| createAsset: `${unityConfig.apiEndPoint}/asset`, | ||
| finalizeAsset: `${unityConfig.apiEndPoint}/asset/finalize`, | ||
| getMetadata: `${unityConfig.apiEndPoint}/asset/metadata`, | ||
| getAcrobatApiConfig(newAPIEndpoint) { | ||
| const apiEndPoint = newAPIEndpoint || unityConfig.apiEndPoint; | ||
| return { | ||
| acrobatEndpoint: { | ||
| createAsset: `${apiEndPoint}/asset`, | ||
| finalizeAsset: `${apiEndPoint}/asset/finalize`, | ||
| getMetadata: `${apiEndPoint}/asset/metadata`, | ||
| connector: `${apiEndPoint}/asset/connector`, | ||
| log: `${apiEndPoint}/log`, | ||
| }, | ||
| }; | ||
| return unityConfig; | ||
| } | ||
|
|
||
| getAdditionalHeaders() { | ||
|
|
@@ -281,6 +286,7 @@ export default class ActionBinder { | |
| subCode: ActionBinder.ERROR_MAP[errorMetaData.subCode] || errorMetaData.subCode || status, | ||
| desc: errorMetaData.desc || message || info || undefined, | ||
| }, | ||
| logEndPoint: this.acrobatApiConfig?.acrobatEndpoint?.log, | ||
|
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. slytherin (dc) side changes corresponding to this are in PR: |
||
| sendToSplunk, | ||
| }, | ||
| }, | ||
|
|
@@ -289,7 +295,7 @@ export default class ActionBinder { | |
|
|
||
| async dispatchAnalyticsEvent(eventName, data = null) { | ||
| const sendToSplunk = this.workflowCfg.targetCfg.sendSplunkAnalytics; | ||
| const detail = { event: eventName, ...(data && { data }), sendToSplunk }; | ||
| const detail = { event: eventName, ...(data && { data }), logEndPoint: this.acrobatApiConfig?.acrobatEndpoint?.log, sendToSplunk }; | ||
| this.block.dispatchEvent(new CustomEvent(unityConfig.trackAnalyticsEvent, { detail })); | ||
| } | ||
|
|
||
|
|
@@ -426,7 +432,7 @@ export default class ActionBinder { | |
| const postOpts = await getApiCallOptions('POST', unityConfig.apiKey, this.getAdditionalHeaders() || {}, { body: JSON.stringify(cOpts) }); | ||
| this.promiseStack.push( | ||
| this.networkUtils.fetchFromServiceWithRetry( | ||
| this.acrobatApiConfig.connectorApiEndPoint, | ||
| this.acrobatApiConfig.acrobatEndpoint.connector, | ||
| postOpts, | ||
| ), | ||
| ); | ||
|
|
@@ -511,6 +517,7 @@ export default class ActionBinder { | |
| const { isValid, validFiles } = await this.validateFiles(sanitizedFiles); | ||
| if (!isValid) return; | ||
| await this.initUploadHandler(); | ||
| await this.ensureOptimalEndpoint(); | ||
| if (files.length === 1 || (validFiles.length === 1 && !verbsWithoutFallback.includes(this.workflowCfg.enabledFeatures[0]))) { | ||
| await this.handleSingleFileUpload(validFiles); | ||
| } else { | ||
|
|
@@ -682,6 +689,28 @@ export default class ActionBinder { | |
| this.filesData.assetId = assetId; | ||
| } | ||
|
|
||
| async ensureOptimalEndpoint() { | ||
| if (this.pageConfigPromise) { | ||
| await this.pageConfigPromise; | ||
| } | ||
| } | ||
|
|
||
| async fetchPageConfig() { | ||
| const getOpts = await getApiCallOptions('GET', unityConfig.apiKey, {}, {}); | ||
| const pageConfigUrl = `${unityConfig.apiEndPoint}/pageConfig`; | ||
| await this.networkUtils.fetchPageConfig( | ||
| pageConfigUrl, | ||
| getOpts, | ||
| (newEndpoint) => { | ||
| this.dispatchAnalyticsEvent('pageConfigUpdated', { newEndpoint }); | ||
| this.acrobatApiConfig = this.getAcrobatApiConfig(newEndpoint); | ||
| }, | ||
| (failure) => { | ||
| this.dispatchErrorToast('warn_page_config_call_failed', null, null, true, true, { code: 'warn_page_config_call_failed', subCode: failure?.status, desc: failure?.type }); | ||
| }, | ||
| ); | ||
| } | ||
|
|
||
| async initActionListeners(b = this.block, actMap = this.actionMap) { | ||
| for (const [key, value] of Object.entries(actMap)) { | ||
| const el = b.querySelector(key); | ||
|
|
@@ -714,5 +743,8 @@ export default class ActionBinder { | |
| if (b === this.block) { | ||
| this.loadTransitionScreen(); | ||
| } | ||
| if (!this.pageConfigPromise) { | ||
| this.pageConfigPromise = this.fetchPageConfig(); | ||
| } | ||
| } | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
check if the dashboard query needs modification to start recording this. Actual modification to be done after the PR merge
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yes, it may need dashboard modifications.