Skip to content

Commit

Permalink
Merge branch 'develop' into feature/GH-10903
Browse files Browse the repository at this point in the history
  • Loading branch information
tobi-or-not-tobi committed Feb 3, 2021
2 parents e4ac86f + bd70ab9 commit 299db83
Show file tree
Hide file tree
Showing 7 changed files with 28 additions and 16 deletions.
2 changes: 1 addition & 1 deletion .env-cmdrc
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"CX_BASE_URL": "https://localhost:9002"
},
"ci": {
"CX_BASE_URL": "https://spartacus-devci767.eastus.cloudapp.azure.com:9002"
"CX_BASE_URL": "https://spartacus-dev0.eastus.cloudapp.azure.com:9002"
},
"b2c": {
"CX_B2B": "false"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
import { isPlatformBrowser } from '@angular/common';
import {
Inject,
Injectable,
isDevMode,
OnDestroy,
PLATFORM_ID,
Renderer2,
RendererFactory2,
} from '@angular/core';
Expand All @@ -11,6 +14,10 @@ import { filter, map, switchMap, tap } from 'rxjs/operators';

export const QUALTRICS_EVENT_NAME = 'qsi_js_loaded';

interface QualtricsWindow extends Window {
QSI?: any;
}

/**
* Service to integration Qualtrics.
*
Expand Down Expand Up @@ -38,9 +45,10 @@ export class QualtricsLoaderService implements OnDestroy {
/**
* QSI load event that happens when the QSI JS file is loaded.
*/
private qsiLoaded$: Observable<any> = this.winRef?.nativeWindow
? fromEvent(this.winRef.nativeWindow, QUALTRICS_EVENT_NAME)
: of();
private qsiLoaded$: Observable<any> =
isPlatformBrowser(this.platformId) && this.window
? fromEvent(this.window, QUALTRICS_EVENT_NAME)
: of();

/**
* Emits the Qualtrics Site Intercept (QSI) JavaScript API whenever available.
Expand All @@ -50,16 +58,19 @@ export class QualtricsLoaderService implements OnDestroy {
*/
protected qsi$: Observable<any> = this.qsiLoaded$.pipe(
switchMap(() => this.isDataLoaded()),
map((dataLoaded) =>
dataLoaded ? this.winRef?.nativeWindow['QSI'] : EMPTY
),
filter((api) => Boolean(api)),
tap((qsi) => (this.qsiApi = qsi))
map((dataLoaded: boolean) => (dataLoaded ? this.window?.QSI : EMPTY)),
filter((qsi: any) => Boolean(qsi)),
tap((qsi: any) => (this.qsiApi = qsi))
);

get window(): QualtricsWindow | undefined {
return this.winRef.nativeWindow;
}

constructor(
protected winRef: WindowRef,
protected rendererFactory: RendererFactory2
protected rendererFactory: RendererFactory2,
@Inject(PLATFORM_ID) protected platformId: any
) {
this.initialize();
}
Expand Down Expand Up @@ -94,7 +105,7 @@ export class QualtricsLoaderService implements OnDestroy {
* Qualtrics specific event (`qsi_js_loaded`). As soon as this events happens,
* we run the API.
*/
protected initialize() {
protected initialize(): void {
this.subscription.add(this.qsi$.subscribe(() => this.run()));
}

Expand Down Expand Up @@ -136,7 +147,7 @@ export class QualtricsLoaderService implements OnDestroy {
return this.rendererFactory.createRenderer(null, null);
}

ngOnDestroy() {
ngOnDestroy(): void {
this.subscription?.unsubscribe();
}
}
1 change: 1 addition & 0 deletions feature-libs/qualtrics/tsconfig.lib.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
"moduleResolution": "node",
"declaration": true,
"sourceMap": true,
"strict": true,
"inlineSources": true,
"experimentalDecorators": true,
"importHelpers": true,
Expand Down
2 changes: 1 addition & 1 deletion projects/storefrontapp-e2e-cypress/cypress.ci.b2b.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
"env": {
"CLIENT_ID": "mobile_android",
"CLIENT_SECRET": "secret",
"API_URL": "https://spartacus-devci767.eastus.cloudapp.azure.com:9002",
"API_URL": "https://spartacus-dev0.eastus.cloudapp.azure.com:9002",
"OCC_PREFIX": "/occ/v2",
"OCC_PREFIX_USER_ENDPOINT": "orgUsers",
"OCC_PREFIX_ORDER_ENDPOINT": "orders",
Expand Down
2 changes: 1 addition & 1 deletion projects/storefrontapp-e2e-cypress/cypress.ci.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
"env": {
"CLIENT_ID": "mobile_android",
"CLIENT_SECRET": "secret",
"API_URL": "https://spartacus-devci767.eastus.cloudapp.azure.com:9002",
"API_URL": "https://spartacus-dev0.eastus.cloudapp.azure.com:9002",
"OCC_PREFIX": "/occ/v2",
"OCC_PREFIX_USER_ENDPOINT": "users",
"OCC_PREFIX_ORDER_ENDPOINT": "orders",
Expand Down
2 changes: 1 addition & 1 deletion projects/storefrontapp-e2e-cypress/cypress.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
"env": {
"CLIENT_ID": "mobile_android",
"CLIENT_SECRET": "secret",
"API_URL": "https://spartacus-devci767.eastus.cloudapp.azure.com:9002",
"API_URL": "https://spartacus-dev0.eastus.cloudapp.azure.com:9002",
"OCC_PREFIX": "/occ/v2",
"OCC_PREFIX_USER_ENDPOINT": "users",
"OCC_PREFIX_ORDER_ENDPOINT": "orders",
Expand Down
2 changes: 1 addition & 1 deletion projects/vendor/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
"peerDependencies": {
"@angular/common": "^10.1.0",
"@angular/core": "^10.1.0",
"@spartacus/core": "3.0.0",
"@spartacus/core": "3.1.0-next.0",
"rxjs": "^6.6.0"
}
}

0 comments on commit 299db83

Please sign in to comment.