Skip to content

Commit

Permalink
SHOTS-4476: allow caller to set device ID
Browse files Browse the repository at this point in the history
SHOTS-4476: allow caller to set device ID
  • Loading branch information
kkanwar authored Nov 8, 2023
2 parents 6ae7009 + b78a2e7 commit 49774cc
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 4 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "spresso-sdk-tracking-web",
"version": "4.6.1",
"version": "4.6.2",
"description": "Spresso Analytics Web SDK",
"main": "index.js",
"scripts": {
Expand Down
3 changes: 2 additions & 1 deletion src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ class SpressoSdk {
init(options: IOptions) {
this.options = options;
this.orgId = options?.orgId;
this.deviceId = initDeviceId();
this.deviceId = initDeviceId(options.deviceId);
this.errorCallback = options?.errorCallback;

addBeforeUnloadListener(this.executeNow.bind(this));
Expand Down Expand Up @@ -318,6 +318,7 @@ class SpressoSdk {

interface IOptions {
orgId: string;
deviceId?: string;
userId?: string;
postalCode?: string;
remoteAddress?: string;
Expand Down
4 changes: 2 additions & 2 deletions src/utils/properties/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,11 @@ export function getDeviceId() {
return readCookie('spressoDeviceId');
}

export function initDeviceId() {
export function initDeviceId(id?: string) {
let deviceId = getDeviceId();

if (!deviceId || deviceId === '') {
deviceId = setDeviceId();
deviceId = setDeviceId(id);
}

return deviceId;
Expand Down

0 comments on commit 49774cc

Please sign in to comment.