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

feat: pass web app version to snjs application #623

Merged
merged 12 commits into from
Sep 6, 2021
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
8 changes: 3 additions & 5 deletions app/assets/javascripts/app.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,5 @@
'use strict';

declare const __VERSION__: string;
declare const __WEB__: boolean;

import { SNLog } from '@standardnotes/snjs';
import angular from 'angular';
import { configRoutes } from './routes';
Expand Down Expand Up @@ -66,6 +63,7 @@ import { NotesOptionsPanelDirective } from './components/NotesOptionsPanel';
import { IconDirective } from './components/Icon';
import { NoteTagsContainerDirective } from './components/NoteTagsContainer';
import { PreferencesDirective } from './preferences';
import { AppVersion, IsWebPlatform } from '@/version';

function reloadHiddenFirefoxTab(): boolean {
/**
Expand Down Expand Up @@ -191,10 +189,10 @@ const startApplication: StartApplication = async function startApplication(
});
};

if (__WEB__) {
if (IsWebPlatform) {
startApplication(
(window as any)._default_sync_server,
new BrowserBridge(__VERSION__),
new BrowserBridge(AppVersion),
(window as any)._websocket_url,
);
} else {
Expand Down
4 changes: 2 additions & 2 deletions app/assets/javascripts/services/errorReporting.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ import { isDesktopApplication, isDev } from '@/utils';
import { storage, StorageKey } from './localStorage';
import Bugsnag from '@bugsnag/js';
import { WebCrypto } from '../crypto';
import { AppVersion } from '@/version';

declare const __VERSION__: string;
declare global {
interface Window {
// eslint-disable-next-line camelcase
Expand Down Expand Up @@ -50,7 +50,7 @@ export function startErrorReporting(): void {
Bugsnag.start({
apiKey: window._bugsnag_api_key,
appType: isDesktopApplication() ? 'desktop' : 'web',
appVersion: __VERSION__,
appVersion: AppVersion,
collectUserIp: false,
autoTrackSessions: false,
releaseStage: isDev ? 'development' : undefined,
Expand Down
2 changes: 2 additions & 0 deletions app/assets/javascripts/ui_models/application.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ import { IOService } from '@/services/ioService';
import { NativeExtManager } from '@/services/nativeExtManager';
import { StatusManager } from '@/services/statusManager';
import { ThemeManager } from '@/services/themeManager';
import { AppVersion } from '@/version';

type WebServices = {
appState: AppState;
Expand Down Expand Up @@ -63,6 +64,7 @@ export class WebApplication extends SNApplication {
identifier,
[],
defaultSyncServerHost,
AppVersion
);
this.$compile = $compile;
this.scope = scope;
Expand Down
9 changes: 3 additions & 6 deletions app/assets/javascripts/utils.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { Platform, platformFromString } from '@standardnotes/snjs';
import { IsDesktopPlatform, IsWebPlatform } from '@/version';

declare const process: {
env: {
Expand Down Expand Up @@ -160,16 +161,12 @@ export async function preventRefreshing(
}
}

/** Platform-detection functions */
declare const __WEB__: boolean;
declare const __DESKTOP__: boolean;

if (!__WEB__ && !__DESKTOP__) {
if (!IsWebPlatform && !IsDesktopPlatform) {
throw Error(
'Neither __WEB__ nor __DESKTOP__ is true. Check your configuration files.'
);
}

export function isDesktopApplication() {
return __DESKTOP__;
return IsDesktopPlatform;
}
8 changes: 8 additions & 0 deletions app/assets/javascripts/version.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
/** Declared in webpack config */
declare const __VERSION__: string;
declare const __DESKTOP__: boolean;
declare const __WEB__: boolean;

export const AppVersion = __VERSION__;
export const IsDesktopPlatform = __DESKTOP__;
export const IsWebPlatform = __WEB__;
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@
"@reach/checkbox": "^0.13.2",
"@reach/dialog": "^0.13.0",
"@standardnotes/sncrypto-web": "1.5.2",
"@standardnotes/snjs": "2.11.2",
"@standardnotes/snjs": "2.12.1",
"mobx": "^6.3.2",
"mobx-react-lite": "^3.2.0",
"preact": "^10.5.12"
Expand Down
22 changes: 11 additions & 11 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -2023,7 +2023,7 @@
dependencies:
"@standardnotes/common" "^1.0.0"

"@standardnotes/[email protected]", "@standardnotes/common@^1.0.0":
"@standardnotes/[email protected]", "@standardnotes/common@^1.0.0", "@standardnotes/common@^1.1.0":
version "1.1.0"
resolved "https://registry.yarnpkg.com/@standardnotes/common/-/common-1.1.0.tgz#5ffb0a50f9947471e236bb66d097f153ad9a148f"
integrity sha512-Nm2IFWbMSfZDD7cnKtN+Gjic0f+PhPq/da/o4eOoUKg21VeOaQkTn+jlQKraKIs6Lmf+w9mmPNAgMc5o4hj7Lg==
Expand All @@ -2035,12 +2035,12 @@
dependencies:
"@standardnotes/auth" "^3.2.0"

"@standardnotes/features@1.4.0":
version "1.4.0"
resolved "https://registry.yarnpkg.com/@standardnotes/features/-/features-1.4.0.tgz#64f0149eb94bee8cb7e748ad2dc2f94f5c2932f3"
integrity sha512-PQEjDdFjJ+hvGz6rD6LATtlICxNr2YKKwht69qGlDqMPSXQaljrq9bocAdGKuy+YOu+aKFvrmRbezsBK9rRIdw==
"@standardnotes/features@1.6.0":
version "1.6.0"
resolved "https://registry.yarnpkg.com/@standardnotes/features/-/features-1.6.0.tgz#91317255bbad376670fd81fa445abc2d14fd43d9"
integrity sha512-0gN1UKpX0LZxOk7HlnLxbl7N8Drvyw36zRErFn3pSetUNQpr92Pd6qTTNNflBBtY2pwzqoP4XVB/2kZRJFAo8w==
dependencies:
"@standardnotes/common" "^1.0.0"
"@standardnotes/common" "^1.1.0"

"@standardnotes/[email protected]":
version "1.2.0"
Expand All @@ -2060,15 +2060,15 @@
"@standardnotes/sncrypto-common" "^1.5.2"
libsodium-wrappers "^0.7.8"

"@standardnotes/snjs@2.11.2":
version "2.11.2"
resolved "https://registry.yarnpkg.com/@standardnotes/snjs/-/snjs-2.11.2.tgz#2ae172950316ee3aa7ad95d4fec4dc85d7ac1269"
integrity sha512-49NPflKrBcAkVcs7nGf7D/oatcPRPZz7+TKyi4s9Xsxf69EmHIQhVu9u+sCUCaUTq2j1sjQt9tyCacjche7p4w==
"@standardnotes/snjs@2.12.1":
version "2.12.1"
resolved "https://registry.yarnpkg.com/@standardnotes/snjs/-/snjs-2.12.1.tgz#4c2cac0e9f87d55d7d24a30f0fbe90d878869c7b"
integrity sha512-4ehV9Nviko0yLs8NUToSXQvOTcQs4XlU2e1sfSkvZZ+Z+iQZo/gR/Xc9gXhr/PvJpahecJIAnbcLpPlJ/DU9MQ==
dependencies:
"@standardnotes/auth" "3.1.1"
"@standardnotes/common" "1.1.0"
"@standardnotes/domain-events" "2.0.0"
"@standardnotes/features" "1.4.0"
"@standardnotes/features" "1.6.0"
"@standardnotes/settings" "1.2.0"
"@standardnotes/sncrypto-common" "1.5.2"

Expand Down