Skip to content

Commit

Permalink
Jl/staging endpoint (#229)
Browse files Browse the repository at this point in the history
* Support staging env endpoint

* [Embed] support staging endpoint

* Rename to staging
  • Loading branch information
jrlarano authored Apr 22, 2024
1 parent 1702e08 commit c16c32e
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 0 deletions.
4 changes: 4 additions & 0 deletions embeds/publication-viewer.html
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
businessId: urlParams.get('businessId'),
apiKey: urlParams.get('apiKey') ?? '',
trackId: urlParams.get('trackId') ?? '',
environment: urlParams.get('environment') ?? '',
localeCode: urlParams.get('localeCode'),
componentType:
urlParams.get('componentType') || 'list-publications',
Expand Down Expand Up @@ -189,6 +190,9 @@
if (data.publicationId) {
scriptEl.dataset.componentPublicationId = data.publicationId;
}
if (data.environment) {
scriptEl.dataset.environment = data.environment;
}
if (data.tags?.length) {
scriptEl.dataset.componentListPublicationsRequestFilter = `tags:${data.tags.join()};`;
}
Expand Down
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 environment = scriptEl.dataset.environment;
const scriptConfig: {
apiKey?: string;
eventTracker?: Tracker;
coreUrl?: string;
} = {};

if (apiKey) scriptConfig.apiKey = apiKey;

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

if (environment === 'staging') scriptConfig.coreUrl = coreUrlStaging;

config.set(scriptConfig);

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

0 comments on commit c16c32e

Please sign in to comment.