Skip to content

Commit

Permalink
Release release-1_1_0
Browse files Browse the repository at this point in the history
  • Loading branch information
ThomasMcDonnell committed Nov 22, 2023
1 parent 11350f5 commit c4140ad
Show file tree
Hide file tree
Showing 5 changed files with 39 additions and 16 deletions.
6 changes: 3 additions & 3 deletions SwrveCoreSDK/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@swrve/web-core",
"version": "1.0.2",
"version": "1.1.0",
"description": "Swrve marketing engagement platform web core SDK",
"keywords": [
"swrve",
Expand Down Expand Up @@ -46,7 +46,7 @@
"worker-loader": "^2.0.0"
},
"dependencies": {
"@types/crypto-js": "4.0.2",
"crypto-js": "4.1.1"
"@types/crypto-js": "4.2.0",
"crypto-js": "4.2.0"
}
}
18 changes: 17 additions & 1 deletion SwrveCoreSDK/src/Swrve.ts
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ export class Swrve {
private campaignNetworkMonitorHandle?: NetworkListener;
private identifiedOnAnotherDevice: boolean = false;
private webPushApiKey: string = "";


public constructor(
config: Readonly<ISwrveConfig>,
Expand Down Expand Up @@ -326,6 +326,22 @@ export class Swrve {
this.qaLogging.userUpdateWithDate(evt);
}

public deviceUpdate(
attributes: IReadonlyDictionary<string | number>
): void {
if (this.pauseSDK) return;

const evt = this.eventFactory.getDeviceUpdate(
attributes,
this.profileManager.getNextSequenceNumber(),
DateHelper.nowInUtcTime(),
);

this.queueEvent(evt);

this.qaLogging.deviceUpdate(evt);
}

public userUpdate(
attributes: IReadonlyDictionary<string | number | boolean>
): void {
Expand Down
4 changes: 4 additions & 0 deletions SwrveCoreSDK/src/SwrveCoreSDK.ts
Original file line number Diff line number Diff line change
Expand Up @@ -174,6 +174,10 @@ export class SwrveCoreSDK {
SwrveCoreSDK.checkInstance().event(name, payload);
}

public static deviceUpdate(attributes: IReadonlyDictionary<string | number>): void {
SwrveCoreSDK.checkInstance().deviceUpdate(attributes);
}

public static userUpdate(
attributes: IReadonlyDictionary<string | number | boolean>
): void {
Expand Down
11 changes: 7 additions & 4 deletions SwrveCoreSDK/tests/Swrve.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -567,6 +567,7 @@ describe("SWRVE SDK TESTS", () => {
sdk.stop();

sdk.event("test", {});
sdk.deviceUpdate({web_push_token: "test"});
sdk.iap(1, "sword", 5, "gold");
sdk.userUpdate({ name: "test" });
sdk.userUpdateWithDate("test", new Date());
Expand Down Expand Up @@ -602,14 +603,15 @@ describe("SWRVE SDK TESTS", () => {

sdk.identify("", () => {}, () => {});
sdk.event("test", {});
sdk.deviceUpdate({web_push_token: "test"});
sdk.iap(1, "sword", 5, "gold");
sdk.userUpdate({ name: "test" });
sdk.userUpdateWithDate("test", new Date());
sdk.currencyGiven("gold", 10);
sdk.purchase("sword", "gold", 10, 10);

expect(sdk["pauseSDK"]).toBeFalsy;
expect(queueEvent.mock.calls.length).toBeGreaterThan(6);
expect(queueEvent.mock.calls.length).toBeGreaterThan(7);
expect(sdk["eventLoopTimer"]).toBeGreaterThan(0);

done();
Expand All @@ -631,16 +633,17 @@ describe("SWRVE SDK TESTS", () => {
evtMgr.queueEvent = queueEvent;

sdk.event("test", {});
sdk.deviceUpdate({web_push_token: "test"});
sdk.iap(1, "sword", 5, "gold");
sdk.userUpdate({ name: "test" });
sdk.userUpdateWithDate("test", new Date());
sdk.currencyGiven("gold", 10);
sdk.purchase("sword", "gold", 10, 10);

const qaQueue = sdk.getQALogging().getQueue();
expect(queueEvent.mock.calls.length).toBe(6);
expect(queueEvent.mock.calls.length).toBe(7);
// there will be more than 6 due to specific QA events.
expect(qaQueue.length).toBeGreaterThan(6);
expect(qaQueue.length).toBeGreaterThan(7);

done();
}, 1000);
Expand Down Expand Up @@ -886,7 +889,7 @@ describe("SWRVE SDK TESTS", () => {
const personalizationProvider = (
eventPayload: IDictionary<string>
): IDictionary<string> => {

expect(eventPayload).toBeDefined();
return eventPayload;
};
Expand Down
16 changes: 8 additions & 8 deletions SwrveCoreSDK/yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -544,10 +544,10 @@
dependencies:
"@babel/types" "^7.3.0"

"@types/crypto-js@^4.0.2":
version "4.0.2"
resolved "https://registry.yarnpkg.com/@types/crypto-js/-/crypto-js-4.0.2.tgz#4524325a175bf819fec6e42560c389ce1fb92c97"
integrity sha512-sCVniU+h3GcGqxOmng11BRvf9TfN9yIs8KKjB8C8d75W69cpTfZG80gau9yTx5SxF3gvHGbJhdESzzvnjtf3Og==
"@types/crypto-js@4.2.0":
version "4.2.0"
resolved "https://registry.yarnpkg.com/@types/crypto-js/-/crypto-js-4.2.0.tgz#01918d35ec66aa806887435c44a67d7a749cf545"
integrity sha512-LW9TlhpMeoQKOu6I6HvOp7eInNNnvd7B+ndAfZb826HUl7eHJJApofbHnlAxrIVS/uiCjkkHGNEaKHoGxB5IHw==

"@types/eslint-scope@^3.7.0":
version "3.7.1"
Expand Down Expand Up @@ -1189,10 +1189,10 @@ cross-spawn@^7.0.3:
shebang-command "^2.0.0"
which "^2.0.1"

crypto-js@^4.1.1:
version "4.1.1"
resolved "https://registry.yarnpkg.com/crypto-js/-/crypto-js-4.1.1.tgz#9e485bcf03521041bd85844786b83fb7619736cf"
integrity sha512-o2JlM7ydqd3Qk9CA0L4NL6mTzU2sdx96a+oOfPu8Mkl/PK51vSyoi8/rQ8NknZtk44vq15lmhAj9CIAGwgeWKw==
crypto-js@4.2.0:
version "4.2.0"
resolved "https://registry.yarnpkg.com/crypto-js/-/crypto-js-4.2.0.tgz#4d931639ecdfd12ff80e8186dba6af2c2e856631"
integrity sha512-KALDyEYgpY+Rlob/iriUtjV6d5Eq+Y191A5g4UqLAi8CyGP9N1+FdVbkc1SxKc2r4YAYqG8JzO2KGL+AizD70Q==

cssom@^0.4.4:
version "0.4.4"
Expand Down

0 comments on commit c4140ad

Please sign in to comment.