diff options
author | Fred Carlsen <fred@sjelfull.no> | 2018-12-05 23:15:44 +0800 |
---|---|---|
committer | Fred Carlsen <fred@sjelfull.no> | 2018-12-05 23:15:44 +0800 |
commit | 00dbddc1aafd56c352e7a8905338d81e236b1fa1 (patch) | |
tree | c8462eb4e6882a39dec601b990f75761b4897ce8 /packages/instant/src/index.umd.ts | |
parent | b552c2bd0c5090629a96bc6b0e032cb85d9c52b3 (diff) | |
parent | b411e2250aed82b87d1cbebf5cf805d794ddbdb7 (diff) | |
download | dexon-sol-tools-00dbddc1aafd56c352e7a8905338d81e236b1fa1.tar dexon-sol-tools-00dbddc1aafd56c352e7a8905338d81e236b1fa1.tar.gz dexon-sol-tools-00dbddc1aafd56c352e7a8905338d81e236b1fa1.tar.bz2 dexon-sol-tools-00dbddc1aafd56c352e7a8905338d81e236b1fa1.tar.lz dexon-sol-tools-00dbddc1aafd56c352e7a8905338d81e236b1fa1.tar.xz dexon-sol-tools-00dbddc1aafd56c352e7a8905338d81e236b1fa1.tar.zst dexon-sol-tools-00dbddc1aafd56c352e7a8905338d81e236b1fa1.zip |
Merge remote-tracking branch 'upstream/development' into website
# Conflicts:
# packages/website/package.json
# packages/website/ts/style/colors.ts
Diffstat (limited to 'packages/instant/src/index.umd.ts')
-rw-r--r-- | packages/instant/src/index.umd.ts | 27 |
1 files changed, 21 insertions, 6 deletions
diff --git a/packages/instant/src/index.umd.ts b/packages/instant/src/index.umd.ts index 3a8694d6a..d172f4145 100644 --- a/packages/instant/src/index.umd.ts +++ b/packages/instant/src/index.umd.ts @@ -2,8 +2,15 @@ import * as _ from 'lodash'; import * as React from 'react'; import * as ReactDOM from 'react-dom'; -import { DEFAULT_ZERO_EX_CONTAINER_SELECTOR, INJECTED_DIV_CLASS, INJECTED_DIV_ID } from './constants'; +import { + DEFAULT_ZERO_EX_CONTAINER_SELECTOR, + GIT_SHA as GIT_SHA_FROM_CONSTANT, + INJECTED_DIV_CLASS, + INJECTED_DIV_ID, + NPM_PACKAGE_VERSION, +} from './constants'; import { ZeroExInstantOverlay, ZeroExInstantOverlayProps } from './index'; +import { analytics } from './util/analytics'; import { assert } from './util/assert'; import { util } from './util/util'; @@ -38,6 +45,9 @@ const validateInstantRenderConfig = (config: ZeroExInstantConfig, selector: stri if (!_.isUndefined(config.provider)) { assert.isWeb3Provider('provider', config.provider); } + if (!_.isUndefined(config.walletDisplayName)) { + assert.isString('walletDisplayName', config.walletDisplayName); + } if (!_.isUndefined(config.shouldDisablePushToHistory)) { assert.isBoolean('shouldDisablePushToHistory', config.shouldDisablePushToHistory); } @@ -57,6 +67,7 @@ const renderInstant = (config: ZeroExInstantConfig, selector: string) => { injectedDiv.setAttribute('class', INJECTED_DIV_CLASS); appendTo.appendChild(injectedDiv); const closeInstant = () => { + analytics.trackInstantClosed(); if (!_.isUndefined(config.onClose)) { config.onClose(); } @@ -89,12 +100,12 @@ export const render = (config: ZeroExInstantConfig, selector: string = DEFAULT_Z // If the integrator defined a popstate handler, save it to __zeroExInstantIntegratorsPopStateHandler // unless we have already done so on a previous render. const anyWindow = window as any; - if (window.onpopstate && !anyWindow.__zeroExInstantIntegratorsPopStateHandler) { - anyWindow.__zeroExInstantIntegratorsPopStateHandler = window.onpopstate.bind(window); - } - const integratorsOnPopStateHandler = anyWindow.__zeroExInstantIntegratorsPopStateHandler || util.boundNoop; + const popStateExistsAndNotSetPreviously = window.onpopstate && !anyWindow.__zeroExInstantIntegratorsPopStateHandler; + anyWindow.__zeroExInstantIntegratorsPopStateHandler = popStateExistsAndNotSetPreviously + ? anyWindow.onpopstate.bind(window) + : util.boundNoop; const onPopStateHandler = (e: PopStateEvent) => { - integratorsOnPopStateHandler(e); + anyWindow.__zeroExInstantIntegratorsPopStateHandler(e); const newState = e.state; if (newState && newState.zeroExInstantShowing) { // We have returned to a history state that expects instant to be rendered. @@ -110,3 +121,7 @@ export const render = (config: ZeroExInstantConfig, selector: string = DEFAULT_Z }; window.onpopstate = onPopStateHandler; }; + +// Write version info to the exported object for debugging +export const GIT_SHA = GIT_SHA_FROM_CONSTANT; +export const NPM_VERSION = NPM_PACKAGE_VERSION; |