Skip to content

Commit

Permalink
Removing all firebase and gtag references
Browse files Browse the repository at this point in the history
Removing ability to shorten link
  • Loading branch information
Tyler Gottfredsen committed Jan 2, 2025
1 parent c268254 commit 3ded996
Show file tree
Hide file tree
Showing 12 changed files with 10 additions and 148 deletions.
5 changes: 0 additions & 5 deletions .firebaserc

This file was deleted.

7 changes: 0 additions & 7 deletions .github/workflows/deploy-preview.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,3 @@ jobs:
env:
VITE_BRANCH: ${{ github.ref_name }}
VITE_PREVIEW: 1
- uses: FirebaseExtended/action-hosting-deploy@v0
with:
repoToken: "${{ secrets.GITHUB_TOKEN }}"
firebaseServiceAccount: "${{ secrets.FIREBASE_SERVICE_ACCOUNT_KYSELY_PLAYGROUND }}"
channelId: preview
expires: 7d
projectId: kysely-playground
6 changes: 0 additions & 6 deletions .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,3 @@ jobs:
- run: npm run build
env:
VITE_BRANCH: ${{ github.ref_name }}
- uses: FirebaseExtended/action-hosting-deploy@v0
with:
repoToken: '${{ secrets.GITHUB_TOKEN }}'
firebaseServiceAccount: '${{ secrets.FIREBASE_SERVICE_ACCOUNT_KYSELY_PLAYGROUND }}'
channelId: live
projectId: kysely-playground
1 change: 0 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -23,5 +23,4 @@ dist-ssr
*.sln
*.sw?

.firebase/*
stats.html
16 changes: 0 additions & 16 deletions firebase.json

This file was deleted.

6 changes: 0 additions & 6 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 0 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
"test": "vitest"
},
"dependencies": {
"firebase-firestore-lite": "^1.0.3",
"highlight.js": "^11.9.0",
"lz-string": "^1.5.0",
"monaco-editor": "^0.50.0-dev-20240525",
Expand Down
29 changes: 5 additions & 24 deletions src/bootstrap.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ import { EditorController } from "./controllers/editor-controller";
import { ElementController } from "./controllers/element-controller";
import { CssUtils } from "./lib/utility/css-utils";
import { StateManager } from "./lib/state/state-manager";
import { FirestoreStateRepository } from "./lib/state/firestore-state-repository";
import { SelectController } from "./controllers/select-controller";
import { KyselyManager } from "./lib/kysely/kysely-manager";
import { State } from "./lib/state/state";
Expand All @@ -24,7 +23,6 @@ import { DEBUG, SETTING_KEYS } from "./lib/constants";
import { SettingsUtils } from "./lib/utility/settings-utils";
import { PanelContainerController } from "./controllers/panel-container-controller";
import { DomUtils } from "./lib/utility/dom-utils";
import { GtagUtils } from "./lib/utility/gtag-utils";
import { AsyncUtils } from "./lib/utility/async-utils.js";

const lazy = null as unknown;
Expand Down Expand Up @@ -73,7 +71,7 @@ async function init() {

D.resultController = new ResultController(e`result`);
setupResultController();
D.stateManager = new StateManager(new FirestoreStateRepository());
D.stateManager = new StateManager();
D.versionController = new SelectController(e`version`);
D.dialectController = new SelectController(e`dialect`);
D.switchThemeController = new ElementController(e`switch-theme`);
Expand Down Expand Up @@ -122,7 +120,6 @@ async function setup() {
setupMobileModeController();
setLoading(false);
setupOpenInNewTabController();
setupGtag();
}

function setLoading(v: boolean) {
Expand Down Expand Up @@ -193,8 +190,7 @@ async function setupMoreController() {

const actionKey = DomUtils.isMac() ? "Cmd" : "Ctrl";
D.morePopupController.appendHint("To share a playground, press 'Save'");
D.morePopupController.appendButton("Save", `${actionKey}-S`, save.bind(null, false));
D.morePopupController.appendButton("Save and shorten link", `${actionKey}-Shift-S`, save.bind(null, true));
D.morePopupController.appendButton("Save", `${actionKey}-S`, save.bind(null));
D.morePopupController.appendButton("Toggle type-editor", `F2`, toggleTypeEditor);
D.morePopupController.appendText(" ");

Expand Down Expand Up @@ -259,7 +255,6 @@ function setupResultController() {
if (e.message && e.message.trim().startsWith("ResizeObserver")) {
return;
}
GtagUtils.event("exception", { description: e, fatal: true });
D.resultController.appendMessage(
"error",
`ERROR: There is an unexpected error. Checkout the developer console.`,
Expand All @@ -270,7 +265,6 @@ function setupResultController() {
D.resultController.clear();
D.resultController.appendMessage("info", "Loading...");
D.resultController.onClickCode = (v) => {
GtagUtils.event("click_result_code");
copyText(v, "Code copied");
};
}
Expand Down Expand Up @@ -313,7 +307,6 @@ function setupSwitchThemeController() {

function toggleTypeEditor() {
const hidden = D.panel0.isHidden();
GtagUtils.event("toggle_type_editor", { on: !hidden });
D.panel0.setHidden(!hidden);
if (hidden) {
D.panelContainerController.resetSizes();
Expand Down Expand Up @@ -424,19 +417,17 @@ function setupHotKeys() {
if (DomUtils.hasSearchParam("nohotkey")) {
return;
}
HotkeyUtils.register(["ctrl"], "s", save.bind(null, false));
HotkeyUtils.register(["ctrl", "shift"], "s", save.bind(null, true));
HotkeyUtils.register(["ctrl"], "s", save.bind(null));
HotkeyUtils.register([], "f1", D.morePopupController.toggle.bind(D.morePopupController));
HotkeyUtils.register([], "f2", toggleTypeEditor);
}

async function save(shorten: boolean) {
GtagUtils.event("save", { shorten });
async function save() {
await useLoading(async () => {
if (SettingsUtils.get("save:format-before-save")) {
await formatEditors();
}
await D.stateManager.save(makeState(), shorten);
await D.stateManager.save(makeState());
if (SettingsUtils.get("save:copy-url-after-save")) {
await ClipboardUtils.writeText(window.location.toString());
ToastUtils.show("info", "URL copied");
Expand All @@ -445,7 +436,6 @@ async function save(shorten: boolean) {
}

async function formatEditors() {
GtagUtils.event("format");
await useLoading(async () => {
try {
const printWidth = SettingsUtils.get("ts-format:wider-width") ? 100 : 70;
Expand Down Expand Up @@ -488,7 +478,6 @@ function makeState(): State {
}

async function reloadState(s: State) {
await D.stateManager.save(s, false);
window.location.reload();
}

Expand Down Expand Up @@ -516,11 +505,3 @@ async function copyText(v: string, msg: string) {
ToastUtils.show("error", e.message ?? e.toString());
}
}

function setupGtag() {
const params = { dialect: D.state.dialect, version: D.state.kysely?.name } as any;
if (DEBUG) {
params.debug_mode = true;
}
GtagUtils.init(params);
}
3 changes: 0 additions & 3 deletions src/lib/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,6 @@ export const GITHUB_MINIFIED_KYSELY_MAIN_BRANCH = "main";

export const GITHUB_API_MINIFIED_KYSELY_MAIN_REFS = `https://api.github.com/repos/${GITHUB_MINIFIED_KYSELY_OWNER}/${GITHUB_MINIFIED_KYSELY_REPO}/git/refs/heads/${GITHUB_MINIFIED_KYSELY_MAIN_BRANCH}`;

export const FIRESTORE_PROJECT_ID = "kysely-playground";
export const FIRESTORE_COLLECTION_FRAGMENTS = "states";

export const CSS_MIN_WIDE_WIDTH = 650;
export const CSS_MIN_DESKTOP_WIDTH = 500;

Expand Down
53 changes: 0 additions & 53 deletions src/lib/state/firestore-state-repository.ts

This file was deleted.

15 changes: 5 additions & 10 deletions src/lib/state/state-manager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,23 +3,17 @@ import { logger } from "../utility/logger";
import { StringUtils } from "../utility/string-utils";
import { ValidateUtils } from "../utility/validate-utils";
import { State } from "./state";
import { FirestoreStateRepository } from "./firestore-state-repository";

export class StateManager {
constructor(private readonly firestoreStateRepository: FirestoreStateRepository) {}
constructor() {}

/**
* Encode the state and update url.
*/
async save(state: State, shorten: boolean) {
async save(state: State) {
validate(state);
logger.debug("encode state");
const encoded = await lzEncode(JSON.stringify(state));
if (shorten) {
const id = await this.firestoreStateRepository.add(encoded);
window.history.replaceState(null, "", window.location.origin + "/" + id + window.location.search);
return;
}
const header: FragmentHeader = "c";
window.history.replaceState(null, "", window.location.origin + window.location.search);
window.location.hash = header + encoded;
Expand Down Expand Up @@ -69,9 +63,10 @@ export class StateManager {
}

private async loadPath(path: string) {
logger.debug(`load path ${path}`);
const id = path;
logger.debug(`get firestore state by id ${id}`);
return JSON.parse(await lzDecode(await this.firestoreStateRepository.get(id)));
logger.debug(`get state by id ${id}`);
return JSON.parse(await lzDecode(id));
}
}

Expand Down
16 changes: 0 additions & 16 deletions src/lib/utility/gtag-utils.ts

This file was deleted.

0 comments on commit 3ded996

Please sign in to comment.