Skip to content

Commit

Permalink
Add eventsTracker staging url (#253)
Browse files Browse the repository at this point in the history
* Add eventsTracker staging url

* Refactor

* minor refactor

* Add curly brackets
  • Loading branch information
jrlarano authored Sep 18, 2024
1 parent 65e49f1 commit 286e9e5
Showing 1 changed file with 10 additions and 4 deletions.
14 changes: 10 additions & 4 deletions lib/sgn-sdk.ts
Original file line number Diff line number Diff line change
Expand Up @@ -56,18 +56,24 @@ if (isBrowser()) {
const apiKey = scriptEl.dataset.apiKey || scriptEl.dataset.appKey;
const trackId = scriptEl.dataset.trackId;
const component = scriptEl.dataset.component;
const environment = scriptEl.dataset.environment;
const isStaging = scriptEl.dataset.environment === 'staging';
const scriptConfig: {
apiKey?: string;
eventTracker?: Tracker;
coreUrl?: string;
} = {};

if (apiKey) scriptConfig.apiKey = apiKey;
if (apiKey) {
scriptConfig.apiKey = apiKey;
}

if (trackId) scriptConfig.eventTracker = new Tracker({trackId});
if (isStaging) {
scriptConfig.coreUrl = coreUrlStaging;
}

if (environment === 'staging') scriptConfig.coreUrl = coreUrlStaging;
if (trackId && !isStaging) {
scriptConfig.eventTracker = new Tracker({trackId});
}

config.set(scriptConfig);

Expand Down

0 comments on commit 286e9e5

Please sign in to comment.