Skip to content

Commit

Permalink
Support staging env endpoint
Browse files Browse the repository at this point in the history
  • Loading branch information
jrlarano committed Apr 22, 2024
1 parent 1702e08 commit 8918901
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 0 deletions.
1 change: 1 addition & 0 deletions lib/config-defaults.ts
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
export const coreUrl = 'https://squid-api.tjek.com';
export const coreUrlStaging = 'https://squid-api.tjek-staging.com';
export const eventsTrackUrl = 'https://wolf-api.tjek.com/sync';
5 changes: 5 additions & 0 deletions lib/sgn-sdk.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ import {
import * as clientLocal from './storage/client-local';
import './stylus/sgn.styl';
import {error, isBrowser} from './util';
import {coreUrlStaging} from './config-defaults';

export const config = new Config();
config.bind('change', (changedAttributes) => {
Expand Down Expand Up @@ -55,15 +56,19 @@ if (isBrowser()) {
const apiKey = scriptEl.dataset.apiKey || scriptEl.dataset.appKey;
const trackId = scriptEl.dataset.trackId;
const component = scriptEl.dataset.component;
const env = scriptEl.dataset.environment;
const scriptConfig: {
apiKey?: string;
eventTracker?: Tracker;
coreUrl?: string;
} = {};

if (apiKey) scriptConfig.apiKey = apiKey;

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

if (env === 'test') scriptConfig.coreUrl = coreUrlStaging;

config.set(scriptConfig);

if (component === 'paged-publication-viewer') {
Expand Down

0 comments on commit 8918901

Please sign in to comment.