Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions lib/addons/try-identify.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ describe("tryIdentifyFromParams", () => {

const expected = "e:a665a45920422f9d417e4867efdc4fb8a04a1f3fff1fa07e998e86f7f7a27ae3";
expect(SDK.identify.mock.calls.length).toBe(1);
expect(SDK.identify.mock.calls[0][0]).toEqual(expected);
expect(SDK.identify.mock.calls[0][0].toLowerCase()).toEqual(expected);
});

test("doesnt call identify when default oeid param is absent", () => {
Expand All @@ -52,7 +52,7 @@ describe("tryIdentifyFromParams", () => {

const expected = "e:a665a45920422f9d417e4867efdc4fb8a04a1f3fff1fa07e998e86f7f7a27ae3";
expect(SDK.identify.mock.calls.length).toBe(1);
expect(SDK.identify.mock.calls[0][0]).toEqual(expected);
expect(SDK.identify.mock.calls[0][0].toLowerCase()).toEqual(expected);
});

test("matches custom param regardless of its case", () => {
Expand All @@ -63,7 +63,7 @@ describe("tryIdentifyFromParams", () => {

const expected = "e:a665a45920422f9d417e4867efdc4fb8a04a1f3fff1fa07e998e86f7f7a27ae3";
expect(SDK.identify.mock.calls.length).toBe(1);
expect(SDK.identify.mock.calls[0][0]).toEqual(expected);
expect(SDK.identify.mock.calls[0][0].toLowerCase()).toEqual(expected);
});

test("doesnt call identify when custom param is absent", () => {
Expand Down
2 changes: 1 addition & 1 deletion lib/addons/try-identify.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,5 +26,5 @@ OptableSDK.prototype.tryIdentifyFromParams = function (key?: string, prefix?: st
return;
}

this.identify((prefix || "e") + ":" + eid.toLowerCase());
this.identify((prefix || "e") + ":" + eid);
};
15 changes: 13 additions & 2 deletions lib/edge/profile.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,20 @@ type ProfileTraits = {
[key: string]: string | number | boolean;
};

function Profile(config: ResolvedConfig, traits: ProfileTraits): Promise<void> {
const profile = {
function Profile(
config: ResolvedConfig,
traits: ProfileTraits,
id: string | null = null,
neighbors: string[] | null = null
): Promise<void> {
const profile: {
traits: ProfileTraits;
id?: string;
neighbors?: string[];
} = {
traits: traits,
...(id && { id: id }),
...(neighbors && { neighbors: neighbors }),
};

return fetch("/profile", config, {
Expand Down
4 changes: 2 additions & 2 deletions lib/sdk.ts
Original file line number Diff line number Diff line change
Expand Up @@ -102,9 +102,9 @@ class OptableSDK {
return Witness(this.dcn, event, properties);
}

async profile(traits: ProfileTraits): Promise<void> {
async profile(traits: ProfileTraits, id: string | null = null, neighbors: string[] | null = null): Promise<void> {
await this.init;
return Profile(this.dcn, traits);
return Profile(this.dcn, traits, id, neighbors);
}

async tokenize(id: string): Promise<TokenizeResponse> {
Expand Down