Skip to content

Commit

Permalink
Bump SDK version from to 0.2 from 0.3
Browse files Browse the repository at this point in the history
  • Loading branch information
marcospassos committed Jul 22, 2020
1 parent 59b3bee commit 6bc9fc5
Show file tree
Hide file tree
Showing 7 changed files with 28 additions and 15 deletions.
6 changes: 3 additions & 3 deletions package-lock.json

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

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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": {
Expand Down
13 changes: 9 additions & 4 deletions src/plug.ts
Original file line number Diff line number Diff line change
@@ -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';
Expand All @@ -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';

Expand Down Expand Up @@ -265,19 +270,19 @@ export class GlobalPlug implements Plug {
}

public setToken(token: string): void {
this.sdk.setToken(token);
this.sdk.setToken(Token.parse(token));
}

public unsetToken(): void {
this.sdk.unsetToken();
}

public track<T extends ExternalEventType>(type: T, payload: ExternalEventPayload<T>): Promise<ExternalEvent<T>> {
return this.sdk.track(type, payload);
return this.sdk.tracker.track(type, payload);
}

public evaluate(expression: string, options: EvaluationOptions = {}): Promise<JsonValue> {
return this.sdk.evaluate(expression, options);
return this.sdk.evaluator.evaluate(expression, options);
}

public test(expression: string, options: EvaluationOptions = {}): Promise<boolean> {
Expand Down
1 change: 0 additions & 1 deletion src/sdk/event.ts

This file was deleted.

1 change: 1 addition & 0 deletions src/sdk/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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';
7 changes: 7 additions & 0 deletions src/sdk/tracking.ts
Original file line number Diff line number Diff line change
@@ -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';
13 changes: 7 additions & 6 deletions test/plug.test.ts
Original file line number Diff line number Diff line change
@@ -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';
Expand Down Expand Up @@ -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', () => {
Expand Down Expand Up @@ -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',
});
Expand All @@ -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});

Expand All @@ -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});

Expand All @@ -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});

Expand All @@ -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});

Expand Down

0 comments on commit 6bc9fc5

Please sign in to comment.