private function registerJavascript()
    {
        $filePath = '//d2wy8f7a9ursnm.cloudfront.net/bugsnag-' . $this->version . '.js';
        if (!$this->useCdn)
        {
            $this->sourcePath = '@bower/bugsnag/src';
			$filePath = 'bugsnag.js';

			if (!file_exists(Yii::getAlias($this->sourcePath . '/' . $filePath)))
			{
				throw new InvalidConfigException('Cannot find Bugsnag.js source code.  Is bower-asset/bugsnag installed?');
			}
        }

        $this->js[] = [
            $filePath, 
            'data-apikey' => Yii::$app->bugsnag->bugsnag_api_key,
            'data-releasestage' => Yii::$app->bugsnag->releaseStage,
            'data-appversion' => Yii::$app->version,
            'position' => \yii\web\View::POS_HEAD,
        ];

        // Include this wrapper since bugsnag.js might be blocked by adblockers.  We don't want to completely die if so.
        $js = 'var Bugsnag = Bugsnag || {};';

        if (!Yii::$app->user->isGuest)
        {
            $userId = Json::htmlEncode(Yii::$app->user->id);
            $js .= "Bugsnag.user = { id: $userId };";
        }

        if (!empty(Yii::$app->bugsnag->notifyReleaseStages))
        {
            $releaseStages = Json::htmlEncode(Yii::$app->bugsnag->notifyReleaseStages);
            $js .= "Bugsnag.notifyReleaseStages = $releaseStages;";
        }

        Yii::$app->view->registerJs($js, \yii\web\View::POS_BEGIN);
    }