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

New analytics #4163

Merged
merged 34 commits into from
Feb 8, 2022
Merged
Changes from all commits
Commits
Show all changes
34 commits
Select commit Hold shift + click to select a range
8c2ca3a
changes to android build files
kneth Dec 6, 2021
3353c04
Initial version of postinstall script for node.js/electron
kneth Dec 7, 2021
dcb30d7
wip
kneth Dec 14, 2021
6d49410
No more analytics code in Android
kneth Dec 20, 2021
05d4971
wip
kneth Dec 21, 2021
255ca52
Check for React Native and Electron
kneth Jan 7, 2022
096d0f3
Update changelog
kneth Jan 7, 2022
66e0733
Remove unused tests
kneth Jan 21, 2022
7ddd92e
Fixing CI issues
kneth Jan 21, 2022
47c490c
PR feedback
kneth Jan 26, 2022
46aee8e
Add path delimiter
kneth Jan 27, 2022
6d16e09
Try to test analytics code
kneth Jan 27, 2022
787062a
wip
kneth Jan 28, 2022
84a56cf
GHA debugging
kneth Jan 28, 2022
6d8beac
Move CI check a bit
kneth Jan 28, 2022
48676c4
Clean up
kneth Jan 28, 2022
4f696dc
PR feedback
kneth Feb 2, 2022
c98e4ed
refactoring
kneth Feb 3, 2022
d9c8516
wip
kneth Feb 3, 2022
9a0f9f8
fix typo
kneth Feb 3, 2022
fafe4fa
Fix lint error
kneth Feb 4, 2022
929c758
New analytics extended (#4312)
kraenhansen Feb 4, 2022
fba05a2
Add testing to integration-tests
kneth Feb 5, 2022
d084a6e
PR fixes
kneth Feb 6, 2022
90ee8b5
Fix tests
kneth Feb 7, 2022
28ee2dd
Fix reading files
kneth Feb 7, 2022
d398d75
Remove iOS analytics code
kneth Feb 7, 2022
541a266
wip
kneth Feb 7, 2022
32a6f2f
wip
kneth Feb 7, 2022
02253e7
debug test
kneth Feb 8, 2022
d20ff59
debug test
kneth Feb 8, 2022
4b55684
Resolve path of test files
kneth Feb 8, 2022
34d2799
Resolve path of root package.json
kneth Feb 8, 2022
0ba677f
Fix test
kneth Feb 8, 2022
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
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -20,6 +20,7 @@ x.x.x Release notes (yyyy-MM-dd)
* Fixed documentation publishing ([#4276](https://github.com/realm/realm-js/pull/4276))
* Enabled mixed tests for flexible sync ([#4279](https://github.com/realm/realm-js/pull/4279))
* Fixed an issue where some references were not updated from `Subscriptions` to `SubscriptionSet` ([#4298](https://github.com/realm/realm-js/pull/4298))
* Submitting [analytics](https://github.com/realm/realm-js/blob/master/README.md#analytics) as a postinstall script.

10.12.0 Release notes (2022-1-24)
=============================================================
4 changes: 3 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -91,7 +91,9 @@ Currently the following information is reported:

* What version of Realm is being installed.
* The OS platform and version which is being used.
* Node.js, v8, libuv, OpenSSL version numbers.
* If a JavaScript framework (currently React Native and Electron) is used and its version.
* Which JavaScript engine is being used.
* Node.js version number.
* An anonymous machine identifier and hashed application path to aggregate the other information on.

## Code of Conduct
2 changes: 2 additions & 0 deletions integration-tests/environments/node/index.js
Original file line number Diff line number Diff line change
@@ -30,6 +30,8 @@ global.client = new Client({
// Add the integration test suite (in TypeScript)
require("ts-node/register/transpile-only");
require("@realm/integration-tests");
// Load the Node.js specific part of the integration tests
require("@realm/integration-tests/src/node");
},
});

88 changes: 88 additions & 0 deletions integration-tests/tests/src/node/analytics.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,88 @@
////////////////////////////////////////////////////////////////////////////
//
// Copyright 2022 Realm Inc.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//
////////////////////////////////////////////////////////////////////////////

import * as os from "os";
import * as process from "process";
import * as path from "path";
import { expect } from "chai";
import { collectPlatformData } from "realm/scripts/submit-analytics";
import { readJsonSync } from "fs-extra";

describe("Analytics", () => {
function resolvePath(fileName: string) {
// tests are executed in directory `environments/node`
return ["..", "..", "tests", "src", "node", fileName].join(path.sep);
}

function getRealmVersion() {
// tests are executed in directory `environments/node`
const rootPath = ["..", "..", "..", "package.json"].join(path.sep);
const realmPackageJson = readJsonSync(rootPath);
return realmPackageJson["version"];
}

it("returns the expected version", async () => {
const packageJson = { version: "1.2.3" };
const data = await collectPlatformData(packageJson);

// common to all cases
expect(data["JS Analytics Version"]).equals(2);
expect(data.Binding).equals("javascript");
expect(data.Language).equals("javascript");
expect(data["Host OS Type"]).equals(os.platform());
expect(data["Host OS Version"]).equals(os.release());
expect(data["Node.js version"]).equals(process.version);
expect(data.token).equals("aab85907a13e1ff44a95be539d9942a9");

// specific to package.json
expect(data.Version).equals("1.2.3");
});

it("parses node.js package.json", async () => {
const packageJson = readJsonSync(resolvePath("node-package.json"));

const data = await collectPlatformData(packageJson);
expect(data.Version).equals("1.11.1");
expect(data.Framework).equals("node.js");
expect(data["Framework Version"]).equals(process.version);
expect(data["JavaScript Engine"]).equals("v8");
expect(data["Realm Version"]).equals(getRealmVersion());
});

it("parses electron package.json", async () => {
const packageJson = readJsonSync(resolvePath("electron-package.json"));

const data = await collectPlatformData(packageJson);
expect(data.Version).equals("11.1.1");
expect(data.Framework).equals("electron");
expect(data["Framework Version"]).equals("^16.0.4");
expect(data["JavaScript Engine"]).equals("v8");
expect(data["Realm Version"]).equals(getRealmVersion());
});

it("parses rn package.json", async () => {
const packageJson = readJsonSync(resolvePath("rn-package.json"));

const data = await collectPlatformData(packageJson);
expect(data.Version).equals("0.0.1");
expect(data.Framework).equals("react-native");
expect(data["Framework Version"]).equals("0.64.2");
expect(data["JavaScript Engine"]).equals("unknown");
expect(data["Realm Version"]).equals(getRealmVersion());
});
});
244 changes: 244 additions & 0 deletions integration-tests/tests/src/node/electron-package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,244 @@
{
"name": "realm-studio",
"productName": "MongoDB Realm Studio",
"version": "11.1.1",
"description": "A tool for everything MongoDB Realm!",
"author": {
"name": "Realm",
"email": "[email protected]",
"url": "https://realm.io"
},
"repository": "https://github.com/realm/realm-studio",
"license": "Apache-2.0",
"main": "./build/main.bundle.js",
"build": {
"appId": "com.mongodb.realm-studio",
"directories": {
"buildResources": "./resources"
},
"files": [
"./build/**/*",
"./node_modules/**/*",
"./package.json",
"./static/**/*",
"!node_modules/realm/android${/*}",
"!node_modules/realm/react-native${/*}",
"!node_modules/realm/scripts${/*}",
"!node_modules/realm/src${/*}",
"!node_modules/realm/vendor${/*}"
],
"afterSign": "./scripts/afterSign",
"mac": {
"hardenedRuntime": true,
"gatekeeperAssess": false,
"category": "public.app-category.developer-tools",
"target": [
"dmg",
"zip"
]
},
"dmg": {
"iconSize": 90,
"contents": [
{
"x": 95,
"y": 200
},
{
"x": 430,
"y": 200,
"type": "link",
"path": "/Applications"
}
]
},
"linux": {
"target": [
"AppImage",
"tar.gz"
]
},
"win": {
"target": [
"nsis",
"portable",
"zip"
],
"icon": "resources/icon.ico"
},
"nsis": {
"installerIcon": "resources/icon.ico",
"perMachine": true
},
"protocols": [
{
"name": "Realm Studio",
"schemes": [
"x-realm-cloud",
"x-realm-studio"
]
}
],
"fileAssociations": {
"ext": "realm",
"name": "Realm",
"isPackage": true
},
"publish": [
{
"provider": "s3",
"bucket": "static.realm.io",
"region": "us-east-1",
"path": "downloads/realm-studio",
"channel": "major-11"
}
],
"npmArgs": [
"--fallback-to-build=false"
]
},
"scripts": {
"build": "webpack --mode production --config=configs/webpack.js",
"check:package-lock": "node ./scripts/check-package-lock.js",
"check:auto-update-files": "node ./scripts/check-auto-update-files.js",
"dev:ros-https": "ros start --https --https-key ./data/keys/server.key --https-cert ./data/keys/server.crt",
"dev:ros-unreliable": "node ./scripts/unreliable-ros.js",
"dev:ros": "ros start",
"dev": "rm -rf ./build && concurrently --names \"WEBPACK:M,WEBPACK:R,ELECTRON\" \"npm run webpack:main\" \"npm run webpack:renderer\" \"npm run wait-for-bundle && ELECTRON_ENABLE_LOGGING=1 electron .\"",
"fix-headers": "node ./scripts/fix-headers.js",
"lint:sass": "sass-lint --max-warnings=0 -c .sass-lint.yml 'src/**/*.scss' -v",
"lint:es": "eslint --ext .ts,.tsx src",
"lint": "npm run lint:es && npm run lint:sass && echo 'Everything looks good!'",
"package": "electron-builder --publish=never",
"postinstall": "electron-builder install-app-deps",
"prepackage": "rm -rf ./build && npm run build",
"generate-https-certificate": "openssl req -x509 -newkey rsa:4096 -keyout data/keys/server.key -out data/keys/server.crt -days 365 -nodes",
"generate-all-types-realm": "node ./scripts/generate-realm.js",
"start": "electron .",
"sentry:upload-symbols": "node ./scripts/sentry-symbols.js",
"test": "mochapack --mode development --webpack-config configs/webpack.test.js 'src/**/*.test.ts' 'src/**/*.test.tsx'",
"test:post-package": "mochapack --mode development --webpack-config configs/webpack.test.js src/testing/post-packaging/index.ts",
"wait-for-bundle": "node ./scripts/wait-for-bundle.js",
"webpack:main": "webpack --mode development --config configs/webpack.main.js",
"webpack:renderer": "webpack serve --mode development --config configs/webpack.renderer.js",
"notarize": "node ./scripts/notarize"
},
"dependencies": {
"@contentful/rich-text-html-renderer": "^15.8.0",
"@contentful/rich-text-types": "^15.7.0",
"@electron/remote": "^2.0.1",
"@sentry/electron": "^2.5.4",
"classnames": "^2.3.1",
"contentful": "^9.1.5",
"electron-store": "^8.0.1",
"electron-updater": "4.6.1",
"font-awesome": "^4.7.0",
"fs-extra": "^10.0.0",
"graphiql": "^1.5.8",
"graphql": "^16.0.1",
"isomorphic-fetch": "^3.0.0",
"json5": "^2.2.0",
"jwt-decode": "^3.1.2",
"keytar": "^7.7.0",
"memoize-one": "^6.0.0",
"mixpanel-browser": "^2.42.0",
"mochapack": "^2.1.2",
"moment": "^2.29.1",
"papaparse": "^5.3.1",
"raven": "^2.6.2",
"react": "^17.0.2",
"react-dom": "^17.0.2",
"react-draggable": "^4.4.4",
"react-inspector": "^5.1.1",
"react-realm-context": "^0.3.0",
"react-sortable-hoc": "^2.0.0",
"react-virtualized": "^9.22.3",
"reactstrap": "^9.0.1",
"realm": "^10.6.0",
"semver": "^7.3.5",
"subscriptions-transport-ws": "^0.11.0",
"uuid": "^8.3.2"
},
"devDependencies": {
"@octokit/rest": "^18.12.0",
"@sentry/cli": "^1.71.0",
"@sentry/webpack-plugin": "^1.18.3",
"@types/classnames": "^2.3.1",
"@types/electron-store": "^3.2.0",
"@types/faker": "^5.5.9",
"@types/fs-extra": "^9.0.13",
"@types/graphql": "^14.5.0",
"@types/isomorphic-fetch": "0.0.35",
"@types/jsdom": "^16.2.13",
"@types/json5": "2.2.0",
"@types/jwt-decode": "^3.1.0",
"@types/keytar": "^4.4.2",
"@types/mixpanel": "^2.14.3",
"@types/mocha": "^9.0.0",
"@types/node": "^16.11.11",
"@types/papaparse": "^5.3.1",
"@types/react": "^17.0.37",
"@types/react-dom": "^17.0.11",
"@types/react-sortable-hoc": "^0.7.1",
"@types/react-virtualized": "^9.21.15",
"@types/reactstrap": "^8.7.2",
"@types/semver": "^7.3.9",
"@types/source-map-support": "^0.5.4",
"@types/tmp": "^0.2.2",
"@types/uuid": "^8.3.3",
"@types/webpack": "^5.28.0",
"@types/webpack-env": "^1.16.3",
"@typescript-eslint/eslint-plugin": "^5.5.0",
"@typescript-eslint/parser": "^5.5.0",
"bootstrap": "^5.1.3",
"commander": "^8.3.0",
"concurrently": "^6.4.0",
"css-loader": "^6.5.1",
"electron": "^16.0.4",
"electron-builder": "^22.14.10",
"electron-download": "^4.1.1",
"electron-notarize": "^1.1.1",
"electron-publisher-s3": "^20.17.2",
"eslint": "^8.4.0",
"eslint-config-prettier": "^8.3.0",
"eslint-plugin-prettier": "^4.0.0",
"eslint-plugin-react": "^7.27.1",
"faker": "^5.5.3",
"file-loader": "^6.2.0",
"js-yaml": "^4.1.0",
"jsdom": "^19.0.0",
"mocha": "^9.1.3",
"mocha-github-actions-reporter": "^0.2.4",
"mocha-junit-reporter": "^2.0.2",
"mocha-loader": "^5.1.5",
"node-sass": "^6.0.1",
"null-loader": "^4.0.1",
"prettier": "^2.5.0",
"react-hot-loader": "^4.13.0",
"remark": "^14.0.2",
"resolve-url-loader": "^4.0.0",
"sass-lint": "^1.13.1",
"sass-loader": "^12.3.0",
"simple-git": "^2.48.0",
"source-map-support": "^0.5.21",
"spectron": "^15.0.0",
"spectron-fake-dialog": "0.0.1",
"style-loader": "^3.3.1",
"svg-sprite-loader": "^6.0.11",
"tmp": "^0.2.1",
"ts-loader": "^9.2.6",
"typescript": "^4.5.2",
"url-loader": "^4.1.1",
"webpack": "^5.64.4",
"webpack-cli": "^4.9.1",
"webpack-dev-server": "^4.6.0",
"webpack-merge": "^5.8.0",
"webpack-node-externals": "^3.0.0",
"webpack-visualizer-plugin": "^0.1.11",
"why-did-you-update": "^1.0.8",
"xvfb-maybe": "^0.2.1"
},
"engines": {
"node": "^16"
}
}
21 changes: 21 additions & 0 deletions integration-tests/tests/src/node/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
////////////////////////////////////////////////////////////////////////////
//
// Copyright 2022 Realm Inc.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//
////////////////////////////////////////////////////////////////////////////

// NOTE: This file is only supposed to be imported from a Node.js environment

import "./analytics";
Loading