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

Add honeybadger support #17

Merged
merged 1 commit into from Jan 5, 2020
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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
7 changes: 6 additions & 1 deletion src/bookmarklets/copy-record-id.js
Expand Up @@ -12,5 +12,10 @@ try {
}
}
catch(er) {
alert('Error occurred while retrieving record id. '+ er.message);
alert('Error occurred while retrieving record id. ' + er.message);
Honeybadger && Honeybadger.notify && Honeybadger.notify(e, {
action: 'copy-record-id',
component: 'bookmarklets',
context: { version: config.version }
});
}
7 changes: 6 additions & 1 deletion src/bookmarklets/copy-record-link.js
Expand Up @@ -16,5 +16,10 @@ try {
}
}
catch(er) {
alert('Error occurred while retrieving record url. '+ er.message);
alert('Error occurred while retrieving record url. ' + er.message);
Honeybadger && Honeybadger.notify && Honeybadger.notify(e, {
action: 'copy-record-link',
component: 'bookmarklets',
context: { version: config.version }
});
}
29 changes: 19 additions & 10 deletions src/bookmarklets/enable-all-fields.js
@@ -1,11 +1,20 @@
formContext.Xrm.Page.ui.controls.forEach(function(c, i){
if (c && c.setDisabled) {
c.setDisabled(false);
}
});
try {
formContext.Xrm.Page.ui.controls.forEach(function(c, i){
if (c && c.setDisabled) {
c.setDisabled(false);
}
});

formContext.Xrm.Page.data.entity.attributes.forEach(function(c, i){
if (c && c.setSubmitMode) {
c.setSubmitMode('always');
}
});
formContext.Xrm.Page.data.entity.attributes.forEach(function(c, i){
if (c && c.setSubmitMode) {
c.setSubmitMode('always');
}
});
}
catch (e) {
Honeybadger && Honeybadger.notify && Honeybadger.notify(e, {
action: 'enable-all-fields',
component: 'bookmarklets',
context: { version: config.version }
});
}
5 changes: 5 additions & 0 deletions src/bookmarklets/focus-field.js
Expand Up @@ -24,4 +24,9 @@ try {
}
catch(er) {
alert('Error occurred set focus to desired field. '+ er.message);
Honeybadger && Honeybadger.notify && Honeybadger.notify(e, {
action: 'focus-field',
component: 'bookmarklets',
context: { version: config.version }
});
}
5 changes: 5 additions & 0 deletions src/bookmarklets/launch-gotdibbs-toolkit.js
Expand Up @@ -40,4 +40,9 @@ try {
}
catch(er) {
alert('Error occurred while opening the toolkit. ' + er.message);
Honeybadger && Honeybadger.notify && Honeybadger.notify(e, {
action: 'launch-gotdibbs-toolkit',
component: 'bookmarklets',
context: { version: config.version }
});
}
7 changes: 6 additions & 1 deletion src/bookmarklets/open-performance-report.js
Expand Up @@ -16,5 +16,10 @@ try {
}
}
catch(er) {
alert('Error occurred opening performance report. '+ er.message);
alert('Error occurred opening performance report. ' + er.message);
Honeybadger && Honeybadger.notify && Honeybadger.notify(e, {
action: 'open-performance-report',
component: 'bookmarklets',
context: { version: config.version }
});
}
26 changes: 26 additions & 0 deletions src/bookmarklets/outro.js
Expand Up @@ -13,6 +13,12 @@
}
}
else if (global.APPLICATION_VERSION) {
Honeybadger && Honeybadger.notify && Honeybadger.notify(e, {
message: 'Unsupported CRM Version Detected',
action: 'outro',
component: 'bookmarklets',
context: { version: global.APPLICATION_VERSION }
});
return alert([
'Unsupported CRM Version Detected: ', global.APPLICATION_VERSION, '.',
' Please check https://gotdibbs.com/crm/help/ for an updated version of this bookmarklet',
Expand All @@ -25,7 +31,27 @@
/^[9]\./.test(global.Xrm.Utility.getGlobalContext().getVersion())) {
return { context: global, version: global.Xrm.Utility.getGlobalContext().getVersion().slice(0, 3) };
}
else if (global.Xrm && global.Xrm.Utility && global.Xrm.Utility.getGlobalContext &&
global.Xrm.Utility.getGlobalContext() && global.Xrm.Utility.getGlobalContext().getVersion()) {
Honeybadger && Honeybadger.notify && Honeybadger.notify(e, {
message: 'Unsupported D365 Version Detected',
action: 'outro',
component: 'bookmarklets',
context: { version: global.Xrm.Utility.getGlobalContext().getVersion() }
});
return alert([
'Unsupported CRM Version Detected: ', global.APPLICATION_VERSION, '.',
' Please check https://gotdibbs.com/crm/help/ for an updated version of this bookmarklet',
' or email webmaster@gotdibbs.net and let us know that this version of CRM',
' isn\'t working.'
].join(''));
}
else {
Honeybadger && Honeybadger.notify && Honeybadger.notify('Failed to detect current CRM version', { context: {
xrm: !!global.Xrm,
xrmPage: !!global.Xrm.Page,
xrmUtility: !!global.Xrm.Utility
} });
return alert('Unable to detect current CRM Version. Please ensure you\'re viewing a record in Dynamics CRM.');
}
}(window)));
35 changes: 22 additions & 13 deletions src/bookmarklets/show-all-fields.js
@@ -1,16 +1,25 @@
formContext.Xrm.Page.ui.controls.forEach(function(c, i){
c.setVisible(true);
});
try {
formContext.Xrm.Page.ui.controls.forEach(function(c, i){
c.setVisible(true);
});

formContext.Xrm.Page.ui.tabs.forEach(function(c, i){
// Show the tab
c.setVisible(true);

// Expand the tab
c.setDisplayState('expanded');
formContext.Xrm.Page.ui.tabs.forEach(function(c, i){
// Show the tab
c.setVisible(true);
// Expand the tab
c.setDisplayState('expanded');

// Show all the sections contained in the tab
c.sections.forEach(function(sc, si){
sc.setVisible(true);
// Show all the sections contained in the tab
c.sections.forEach(function(sc, si){
sc.setVisible(true);
});
});
}
catch (e) {
Honeybadger && Honeybadger.notify && Honeybadger.notify(e, {
action: 'show-all-fields',
component: 'bookmarklets',
context: { version: config.version }
});
});
}
31 changes: 20 additions & 11 deletions src/bookmarklets/show-dirty-fields.js
@@ -1,15 +1,24 @@
var dirtyAttributes = [];
try {
var dirtyAttributes = [];

formContext.Xrm.Page.data.entity.attributes.forEach(function(c, i){
if (c && c.getIsDirty && c.getIsDirty()) {
dirtyAttributes.push(c.getName());
}
});
formContext.Xrm.Page.data.entity.attributes.forEach(function(c, i){
if (c && c.getIsDirty && c.getIsDirty()) {
dirtyAttributes.push(c.getName());
}
});

if (!dirtyAttributes || !dirtyAttributes.length) {
alert('No attributes appear to be dirty on the current form.');
if (!dirtyAttributes || !dirtyAttributes.length) {
alert('No attributes appear to be dirty on the current form.');
}
else {
alert(['The following attributes are currently dirty: \n',
dirtyAttributes.join(', ')].join(''));
}
}
else {
alert(['The following attributes are currently dirty: \n',
dirtyAttributes.join(', ')].join(''));
catch (e) {
Honeybadger && Honeybadger.notify && Honeybadger.notify(e, {
action: 'show-dirty-fields',
component: 'bookmarklets',
context: { version: config.version }
});
}
33 changes: 21 additions & 12 deletions src/bookmarklets/show-record-properties.js
@@ -1,16 +1,25 @@
var id,
typeCode;
try {
var id,
typeCode;

if (Mscrm && Mscrm.RibbonActions && Mscrm.RibbonActions.openFormProperties) {
id = formContext.Xrm.Page.data.entity.getId()
typeCode = formContext.Xrm.Page.context.getQueryStringParameters().etc;

if (!typeCode) {
return alert('Could not locate the current record type.');
}
if (Mscrm && Mscrm.RibbonActions && Mscrm.RibbonActions.openFormProperties) {
id = formContext.Xrm.Page.data.entity.getId()
typeCode = formContext.Xrm.Page.context.getQueryStringParameters().etc;
if (!typeCode) {
return alert('Could not locate the current record type.');
}

Mscrm.RibbonActions.openFormProperties(id, typeCode);
Mscrm.RibbonActions.openFormProperties(id, typeCode);
}
else {
alert('This action is not supported in the current version of Dynamics CRM.');
}
}
else {
alert('This action is not supported in the current version of Dynamics CRM.');
catch (e) {
Honeybadger && Honeybadger.notify && Honeybadger.notify(e, {
action: 'show-record-properties',
component: 'bookmarklets',
context: { version: config.version }
});
}
29 changes: 19 additions & 10 deletions src/bookmarklets/toggle-schema-names.js
@@ -1,10 +1,19 @@
formContext.Xrm.Page.ui.controls.forEach(function(c, i){
if (!c.__label) {
c.__label = c.getLabel();
c.setLabel(c.getName());
}
else {
c.setLabel(c.__label);
c.__label = null;
}
});
try {
formContext.Xrm.Page.ui.controls.forEach(function(c, i){
if (!c.__label) {
c.__label = c.getLabel();
c.setLabel(c.getName());
}
else {
c.setLabel(c.__label);
c.__label = null;
}
});
}
catch (e) {
Honeybadger && Honeybadger.notify && Honeybadger.notify(e, {
action: 'toggle-schema-names',
component: 'bookmarklets',
context: { version: config.version }
});
}
22 changes: 19 additions & 3 deletions src/chromeExtension/app.js
Expand Up @@ -29,7 +29,6 @@
return;
}


if (document.querySelector('[data-hook="gotdibbs-toolbox"]')) {
return;
}
Expand All @@ -51,6 +50,9 @@
.catch(e => {
console.error('Failed to load toolkit HTML');
console.error(e);
Honeybadger.notify(e, {
message: 'Failed to load toolkit HTML'
})
});
}
else {
Expand All @@ -59,6 +61,7 @@
}

function loadDependencies() {
injectScript(chrome.extension.getURL('honeybadger.min.js'));
injectScript(chrome.extension.getURL('contextCommunicator.js'));
}

Expand Down Expand Up @@ -104,8 +107,21 @@
}

function load() {
loadDependencies();
attachListeners();
Honeybadger.configure({
apiKey: '3783205f',
environment: 'development',
revision: '1.1',
onerror: false
});

Honeybadger.setContext({
source: 'chrome_extension'
});

Honeybadger.wrap(function () {
loadDependencies();
attachListeners();
})();
}

global.addEventListener('load', load);
Expand Down
Binary file modified src/chromeExtension/chromeExtension.zip
Binary file not shown.