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
Original file line number Diff line number Diff line change
Expand Up @@ -950,7 +950,6 @@ height: 100%;
box-sizing: border-box;
border-radius: 13.667px;
overflow: hidden;
border: 2px solid #2680eb;
}

.pbu-preview.hidden {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,9 @@ export default class ActionBinder {
this.sendAnalyticsToSplunk?.(
eventName,
this.workflowCfg.productName,
{ ...data, operation: this.verb },
{ ...data,
operation: this.verb,
action: 'upload-generate' },
`${unityConfig.apiEndPoint}/log`,
true,
);
Expand Down Expand Up @@ -345,7 +347,11 @@ export default class ActionBinder {
}
this.serviceHandler.showErrorToast({ errorToastEl: this.errorToastEl, errorType: '.icon-error-request' }, e, this.lanaOptions);
this.logAnalytics('Upload server error|UnityWidget', {
errorData: { code: 'error-request', subCode: `uploadAsset ${e.status}`, desc: e.message },
errorData: {
code: 'error-request',
subCode: `uploadAsset ${e.status}`,
desc: e.message || undefined,
},
assetId: this.assetId,
});
return false;
Expand All @@ -356,12 +362,22 @@ export default class ActionBinder {
const maxCharLimit = this.limits?.['max-char-limit'] ?? 1024;
if (query.length > maxCharLimit) {
this.handleClientError('.icon-error-max-length', 'max-prompt-characters-exceeded', 'Prompt too long');
this.logAnalytics('generate', { errorData: { code: 'max-prompt-characters-exceeded' } });
return false;
}
return true;
}

async trackUploadFileAttempt(uploadMethod) {
try {
if (!this.analyticsModule) await this.initAnalytics();
const eventName = this.analyticsModule.PROMPT_BAR_EVENTS.UPLOAD_FILE_ATTEMPT;
sendAnalyticsEvent(new CustomEvent(eventName));
this.logAnalytics(eventName, { action: uploadMethod });
} catch (e) {
window.lana?.log(`Message: Upload file attempt analytics failed, Error: ${e}`, this.lanaOptions);
}
}

async ensureTransitionScreen() {
if (!this.transitionScreen) {
const { default: TransitionScreen } = await import(`${getUnityLibs()}/scripts/transition-screen.js`);
Expand Down Expand Up @@ -472,8 +488,12 @@ export default class ActionBinder {
if (err.message === 'Operation termination requested.') return;
await this.transitionScreen?.showSplashScreen();
this.serviceHandler.showErrorToast({ errorToastEl: this.errorToastEl, errorType: '.icon-error-request' }, err, this.lanaOptions);
this.logAnalytics('Generate Error|UnityWidget', {
errorData: { code: 'request-failed', subCode: err.status, desc: err.message },
this.logAnalytics('Upload server error|UnityWidget', {
errorData: {
code: 'error-request',
subCode: `continueInApp ${err.status}`,
desc: err.message || undefined,
},
assetId: this.assetId,
});
window.lana?.log(`Message: Connector call failed, Error: ${err}`, this.lanaOptions);
Expand Down Expand Up @@ -658,6 +678,7 @@ export default class ActionBinder {
e.preventDefault();
dragDepth = 0;
setDropzoneHighlight(false);
void this.trackUploadFileAttempt('drop');
sendAnalyticsEvent(new CustomEvent('Drag and drop|UnityWidget'));
const files = this.extractFiles(e);
await this.executeAction('file-selected', outerMarquee, files);
Expand All @@ -682,11 +703,15 @@ export default class ActionBinder {
el.addEventListener('drop', async (e) => {
e.preventDefault();
el.classList.remove('drag-over');
void this.trackUploadFileAttempt('drop');
sendAnalyticsEvent(new CustomEvent('Drag and drop|UnityWidget'));
const files = this.extractFiles(e);
await this.executeAction(primaryAction, el, files);
});
el.addEventListener('click', () => { this.block?.querySelector('#file-upload')?.click(); });
el.addEventListener('click', () => {
void this.trackUploadFileAttempt('drop-zone-click');
this.block?.querySelector('#file-upload')?.click();
});
break;
case 'INPUT':
el.addEventListener('change', async (e) => {
Expand Down
2 changes: 1 addition & 1 deletion unitylibs/core/workflow/workflow-upload/action-binder.js
Original file line number Diff line number Diff line change
Expand Up @@ -329,7 +329,7 @@ export default class ActionBinder {
}

getVerbFromDom() {
const verbEl = this.unityEl?.querySelector('[class*="icon-verb-"]');
const verbEl = this.unityEl?.querySelector('[class*="icon-verb-"]') || this.unityEl?.querySelector('[class*="icon-operation-"]');
if (!verbEl) return undefined;
const verbClass = Array.from(verbEl.classList).find((cls) => cls.startsWith('icon-verb-'));
return verbClass?.slice('icon-verb-'.length);
Expand Down
1 change: 1 addition & 0 deletions unitylibs/scripts/analytics.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ export const PROMPT_BAR_EVENTS = {
MODULE_PICKER: 'Module Picker Select Dropdown|UnityWidget',
RATIO_DROPDOWN: 'Ratio Dropdown Select|UnityWidget',
MORE: 'More|UnityWidget',
UPLOAD_FILE_ATTEMPT: 'Upload file attempt|UnityWidget',
UPLOAD_STARTED: 'Uploading started|UnityWidget',
UPLOAD_ERROR: 'Upload error|UnityWidget',
generateModel: (modelName) => `Generate ${modelName}|UnityWidget`,
Expand Down
Loading