Skip to content

Commit

Permalink
Removed raw counter options passage through the global storage
Browse files Browse the repository at this point in the history
commit_hash:ca51019e2beaf69ad40a3af5a42c8ed240ef8d75
  • Loading branch information
Stanislavsky34200 committed Nov 6, 2024
1 parent 17d77a0 commit 412abdc
Show file tree
Hide file tree
Showing 5 changed files with 0 additions and 55 deletions.
1 change: 0 additions & 1 deletion .mapping.json
Original file line number Diff line number Diff line change
Expand Up @@ -390,7 +390,6 @@
"src/utils/counterOptions/counterOptions.ts":"metrika/frontend/watch/public/src/utils/counterOptions/counterOptions.ts",
"src/utils/counterOptions/getCounterKey.ts":"metrika/frontend/watch/public/src/utils/counterOptions/getCounterKey.ts",
"src/utils/counterOptions/index.ts":"metrika/frontend/watch/public/src/utils/counterOptions/index.ts",
"src/utils/counterOptions/saveCounterOptions.ts":"metrika/frontend/watch/public/src/utils/counterOptions/saveCounterOptions.ts",
"src/utils/counterOptions/types.ts":"metrika/frontend/watch/public/src/utils/counterOptions/types.ts",
"src/utils/counterSettings/const.ts":"metrika/frontend/watch/public/src/utils/counterSettings/const.ts",
"src/utils/counterSettings/counterSettings.ts":"metrika/frontend/watch/public/src/utils/counterSettings/counterSettings.ts",
Expand Down
2 changes: 0 additions & 2 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,6 @@ import { throwFunction } from './utils/errorLogger/throwFunction';
import { yaNamespace, ASYNC_PROVIDERS_MAX_EXEC_TIME } from './const';
import { stackProxy } from './providers/stackProxy/stackProxy';
import { DUPLICATE_COUNTERS_CONSOLE_MESSAGE } from './providers/consoleRenderer/dictionary';
import { saveCounterOptions } from './utils/counterOptions/saveCounterOptions';
import { dispatchDebuggerEvent } from './utils/debugEvents';

type CounterMethod = keyof CounterObject;
Expand Down Expand Up @@ -191,7 +190,6 @@ const MetrikaCounter: MetrikaCounterConstructor = function MetrikaCounter(
return counters[counterKey];
}

saveCounterOptions(ctx, counterKey, counterOptions);
counters[counterKey] = this;
globalConfig.setVal(COUNTERS_GLOBAL_KEY, counters);
globalConfig.setSafe('counter', this);
Expand Down
14 changes: 0 additions & 14 deletions src/providers/destruct/__tests__/destruct.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,24 +2,15 @@ import * as chai from 'chai';
import * as sinon from 'sinon';
import * as globalStorage from 'src/storage/global';
import { CounterOptions } from 'src/utils/counterOptions';
import * as optionsUtils from 'src/utils/counterOptions/saveCounterOptions';
import { destruct } from '../destruct';

describe('destruct provider', () => {
const sandbox = sinon.createSandbox();
let deleteCounterOptions: sinon.SinonStub<
Parameters<typeof optionsUtils.deleteCounterOptions>,
ReturnType<typeof optionsUtils.deleteCounterOptions>
>;
const gs = {
getVal: sandbox.stub(),
};

beforeEach(() => {
deleteCounterOptions = sandbox.stub(
optionsUtils,
'deleteCounterOptions',
);
sandbox.stub(globalStorage, 'getGlobalStorage').returns(gs as any);
});

Expand Down Expand Up @@ -50,11 +41,6 @@ describe('destruct provider', () => {
const destructor = destruct(windowStub, counterOptions, callbacks);
destructor();

sinon.assert.calledOnceWithExactly(
deleteCounterOptions,
windowStub,
counterKey,
);
chai.expect(cb1.calledOnce).to.be.true;
chai.expect(cb2.calledOnce).to.be.true;
chai.expect(counters['100:0']).to.not.exist;
Expand Down
2 changes: 0 additions & 2 deletions src/providers/destruct/destruct.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import { CounterOptions, getCounterKey } from 'src/utils/counterOptions';
import { cForEach } from 'src/utils/array';
import type { AnyFunc } from 'src/utils/function/types';
import { isFunction } from 'src/utils/object';
import { deleteCounterOptions } from 'src/utils/counterOptions/saveCounterOptions';
import { DestructHandler } from './const';

type UnsubscribeCallbacks = (AnyFunc | undefined)[];
Expand Down Expand Up @@ -32,7 +31,6 @@ export const destruct = ctxErrorLogger(
errorLogger(ctx, `dest.fr.${index}`, cb)(),
unsubscribeMethods,
);
deleteCounterOptions(ctx, getCounterKey(counterOptions));
delete globalConfig.getVal<{ [key: string]: unknown }>('counters')[
getCounterKey(counterOptions)
];
Expand Down
36 changes: 0 additions & 36 deletions src/utils/counterOptions/saveCounterOptions.ts

This file was deleted.

0 comments on commit 412abdc

Please sign in to comment.