From 6bc9fc5ab2fd9530c82e980d0fe61005b34913c9 Mon Sep 17 00:00:00 2001 From: Marcos Passos Date: Wed, 22 Jul 2020 10:15:10 -0300 Subject: [PATCH] Bump SDK version from to 0.2 from 0.3 --- package-lock.json | 6 +++--- package.json | 2 +- src/plug.ts | 13 +++++++++---- src/sdk/event.ts | 1 - src/sdk/index.ts | 1 + src/sdk/tracking.ts | 7 +++++++ test/plug.test.ts | 13 +++++++------ 7 files changed, 28 insertions(+), 15 deletions(-) delete mode 100644 src/sdk/event.ts diff --git a/package-lock.json b/package-lock.json index e6c1bc80f..eb16c68e5 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1066,9 +1066,9 @@ } }, "@croct/sdk": { - "version": "0.2.0", - "resolved": "https://registry.npmjs.org/@croct/sdk/-/sdk-0.2.0.tgz", - "integrity": "sha512-wErkcIGwOAjnpvI5fAvX6YyvrUkFZY+V7n98o0vupveqQc3C5jvxFoZoizScK/eVLCxc11MvJdErK8XDkc/X2w==", + "version": "0.3.1", + "resolved": "https://registry.npmjs.org/@croct/sdk/-/sdk-0.3.1.tgz", + "integrity": "sha512-6WagD+0bNnErJ/KI7JfARsRUpdifOaoDqAsejYF0kCOCC6LjMs9qmMtWwhrvL49+muPNnaXJQnTi3bxyV//vUw==", "requires": { "tslib": "^2.0.0" } diff --git a/package.json b/package.json index cb6e498ae..394e9fbe3 100644 --- a/package.json +++ b/package.json @@ -33,7 +33,7 @@ "bundle": "rollup -c rollup.config.js" }, "dependencies": { - "@croct/sdk": "^0.2.0", + "@croct/sdk": "^0.3.1", "tslib": "^2.0.0" }, "devDependencies": { diff --git a/src/plug.ts b/src/plug.ts index 09928a511..3df1d65ab 100644 --- a/src/plug.ts +++ b/src/plug.ts @@ -1,4 +1,3 @@ -import {ExternalEvent, ExternalEventPayload, ExternalEventType} from '@croct/sdk/event'; import {Logger} from '@croct/sdk/logging'; import {JsonValue} from '@croct/sdk/json'; import SessionFacade from '@croct/sdk/facade/sessionFacade'; @@ -9,6 +8,12 @@ import Sdk, {Configuration as SdkFacadeConfiguration} from '@croct/sdk/facade/sd import {formatCause} from '@croct/sdk/error'; import {describe} from '@croct/sdk/validation'; import {Optional} from '@croct/sdk/utilityTypes'; +import Token from '@croct/sdk/token'; +import { + ExternalTrackingEvent as ExternalEvent, + ExternalTrackingEventPayload as ExternalEventPayload, + ExternalTrackingEventType as ExternalEventType, +} from '@croct/sdk/trackingEvents'; import {Plugin, PluginArguments, PluginFactory} from './plugin'; import {CDN_URL} from './constants'; @@ -265,7 +270,7 @@ export class GlobalPlug implements Plug { } public setToken(token: string): void { - this.sdk.setToken(token); + this.sdk.setToken(Token.parse(token)); } public unsetToken(): void { @@ -273,11 +278,11 @@ export class GlobalPlug implements Plug { } public track(type: T, payload: ExternalEventPayload): Promise> { - return this.sdk.track(type, payload); + return this.sdk.tracker.track(type, payload); } public evaluate(expression: string, options: EvaluationOptions = {}): Promise { - return this.sdk.evaluate(expression, options); + return this.sdk.evaluator.evaluate(expression, options); } public test(expression: string, options: EvaluationOptions = {}): Promise { diff --git a/src/sdk/event.ts b/src/sdk/event.ts deleted file mode 100644 index c3605967e..000000000 --- a/src/sdk/event.ts +++ /dev/null @@ -1 +0,0 @@ -export {Event, EventType, ExternalEvent, ExternalEventPayload, ExternalEventType} from '@croct/sdk/event'; diff --git a/src/sdk/index.ts b/src/sdk/index.ts index 9513607e3..4452fcc51 100644 --- a/src/sdk/index.ts +++ b/src/sdk/index.ts @@ -2,3 +2,4 @@ export {Logger} from '@croct/sdk/logging'; export {default as SessionFacade} from '@croct/sdk/facade/sessionFacade'; export {default as UserFacade} from '@croct/sdk/facade/userFacade'; export {default as Tab} from '@croct/sdk/tab'; +export {SdkEventType, SdkEvent} from '@croct/sdk/sdkEvents'; diff --git a/src/sdk/tracking.ts b/src/sdk/tracking.ts index 533451e82..d94653461 100644 --- a/src/sdk/tracking.ts +++ b/src/sdk/tracking.ts @@ -1,2 +1,9 @@ export {default as Tracker} from '@croct/sdk/facade/trackerFacade'; export {EventInfo, EventListener} from '@croct/sdk/tracker'; +export { + TrackingEvent, + TrackingEventType, + ExternalTrackingEvent, + ExternalTrackingEventPayload, + ExternalTrackingEventType, +} from '@croct/sdk/trackingEvents'; diff --git a/test/plug.test.ts b/test/plug.test.ts index a038200da..93b81a06e 100644 --- a/test/plug.test.ts +++ b/test/plug.test.ts @@ -1,4 +1,5 @@ import SdkFacade, {Configuration as SdkFacadeConfiguration} from '@croct/sdk/facade/sdkFacade'; +import Token from '@croct/sdk/token'; import {Logger} from '../src/sdk'; import {Plugin, PluginFactory} from '../src/plugin'; import {GlobalPlug} from '../src/plug'; @@ -527,7 +528,7 @@ describe('The Croct plug', () => { croct.setToken(token); - expect(setToken).toBeCalledWith(token); + expect(setToken).toBeCalledWith(Token.parse(token)); }); test('should not allow to set a user token if unplugged', () => { @@ -565,7 +566,7 @@ describe('The Croct plug', () => { expect(initialize).toBeCalledWith(config); - const track = jest.spyOn(sdkFacade, 'track').mockResolvedValue({ + const track = jest.spyOn(sdkFacade.tracker, 'track').mockResolvedValue({ type: 'userSignedUp', userId: 'c4r0l', }); @@ -589,7 +590,7 @@ describe('The Croct plug', () => { expect(initialize).toBeCalledWith(config); - const evaluate = jest.spyOn(sdkFacade, 'evaluate').mockResolvedValue('carol'); + const evaluate = jest.spyOn(sdkFacade.evaluator, 'evaluate').mockResolvedValue('carol'); const promise = croct.evaluate('user\'s name', {timeout: 5}); @@ -612,7 +613,7 @@ describe('The Croct plug', () => { expect(initialize).toBeCalledWith(config); - const evaluate = jest.spyOn(sdkFacade, 'evaluate').mockResolvedValue(true); + const evaluate = jest.spyOn(sdkFacade.evaluator, 'evaluate').mockResolvedValue(true); const promise = croct.test('user\'s name is "Carol"', {timeout: 5}); @@ -631,7 +632,7 @@ describe('The Croct plug', () => { expect(initialize).toBeCalledWith(config); - const evaluate = jest.spyOn(sdkFacade, 'evaluate').mockResolvedValue('foo'); + const evaluate = jest.spyOn(sdkFacade.evaluator, 'evaluate').mockResolvedValue('foo'); const promise = croct.test('user\'s name is "Carol"', {timeout: 5}); @@ -650,7 +651,7 @@ describe('The Croct plug', () => { expect(initialize).toBeCalledWith(config); - const evaluate = jest.spyOn(sdkFacade, 'evaluate').mockRejectedValue(undefined); + const evaluate = jest.spyOn(sdkFacade.evaluator, 'evaluate').mockRejectedValue(undefined); const promise = croct.test('user\'s name is "Carol"', {timeout: 5});