travel with Angular and - Okko.fi the world of travel... · travel with Angular and measuring along...

51

Transcript of travel with Angular and - Okko.fi the world of travel... · travel with Angular and measuring along...

Page 1: travel with Angular and - Okko.fi the world of travel... · travel with Angular and measuring along the way Oskari Okko Ojala Olli Leskinen 2018-03-01. 3 Beta.finnair.com 3 ... using
Page 2: travel with Angular and - Okko.fi the world of travel... · travel with Angular and measuring along the way Oskari Okko Ojala Olli Leskinen 2018-03-01. 3 Beta.finnair.com 3 ... using

Changing the world of travel with Angular and

measuring along the wayOskari Okko Ojala

Olli Leskinen2018-03-01

Page 3: travel with Angular and - Okko.fi the world of travel... · travel with Angular and measuring along the way Oskari Okko Ojala Olli Leskinen 2018-03-01. 3 Beta.finnair.com 3 ... using

3

Beta.finnair.com

3

Built with Angular

Decoupled CMS

Microservice architecture

55 language variants

AWS Cloud

Amadeus

GitHub, Node, Java, Travis,Jenkins, Akamai...

Page 4: travel with Angular and - Okko.fi the world of travel... · travel with Angular and measuring along the way Oskari Okko Ojala Olli Leskinen 2018-03-01. 3 Beta.finnair.com 3 ... using

4

Beta.finnair.com

4

Hypothesis driven design

Multi-vendor team

● Finnair● Frantic● Nitor● Houston Inc● CGI● Nextage Design

Page 5: travel with Angular and - Okko.fi the world of travel... · travel with Angular and measuring along the way Oskari Okko Ojala Olli Leskinen 2018-03-01. 3 Beta.finnair.com 3 ... using

55

CMS CLIENT-SIDE APPApproaches

CMS-generated page

CMS-generated page with an in-page app

Client-side app with included CMS content

App only

Page 6: travel with Angular and - Okko.fi the world of travel... · travel with Angular and measuring along the way Oskari Okko Ojala Olli Leskinen 2018-03-01. 3 Beta.finnair.com 3 ... using

Seamless UX flow

Page 7: travel with Angular and - Okko.fi the world of travel... · travel with Angular and measuring along the way Oskari Okko Ojala Olli Leskinen 2018-03-01. 3 Beta.finnair.com 3 ... using

77

CMS CLIENT-SIDE APPApproaches

CMS-generated page

CMS-generated page with an in-page app

Client-side app with included CMS content

App only

Page 8: travel with Angular and - Okko.fi the world of travel... · travel with Angular and measuring along the way Oskari Okko Ojala Olli Leskinen 2018-03-01. 3 Beta.finnair.com 3 ... using

“Beta means we’re now confident that most

developers can be successful building large applications

using Angular 2.”

8

-Angular 2 Beta announcement, December 2015

Page 9: travel with Angular and - Okko.fi the world of travel... · travel with Angular and measuring along the way Oskari Okko Ojala Olli Leskinen 2018-03-01. 3 Beta.finnair.com 3 ... using

“Beta means the best developers can start building

large applications using Angular 2.”

9

-There, fixed it for ya

Page 10: travel with Angular and - Okko.fi the world of travel... · travel with Angular and measuring along the way Oskari Okko Ojala Olli Leskinen 2018-03-01. 3 Beta.finnair.com 3 ... using

10

Angular 2 (early 2016)

● SPEED & PERFORMANCE

● SIMPLE & EXPRESSIVE

● CROSS-PLATFORM

● FLEXIBLE DEVELOPMENT: THE CHOICE OF LANGUAGE IS UP TO YOU

● COMPREHENSIVE ROUTING

● DEPENDENCY INJECTION

● LEGACY BROWSER SUPPORT

● ANIMATIONS (LATER)

● INTERNATIONALIZATION (I18N) & ACCESSIBILITY (LATER)

10

Page 11: travel with Angular and - Okko.fi the world of travel... · travel with Angular and measuring along the way Oskari Okko Ojala Olli Leskinen 2018-03-01. 3 Beta.finnair.com 3 ... using

SPEED&

PERFORMANCE

Page 12: travel with Angular and - Okko.fi the world of travel... · travel with Angular and measuring along the way Oskari Okko Ojala Olli Leskinen 2018-03-01. 3 Beta.finnair.com 3 ... using

...once you’ve gotten it loaded

Page 13: travel with Angular and - Okko.fi the world of travel... · travel with Angular and measuring along the way Oskari Okko Ojala Olli Leskinen 2018-03-01. 3 Beta.finnair.com 3 ... using

NOAngular Universal

Page 14: travel with Angular and - Okko.fi the world of travel... · travel with Angular and measuring along the way Oskari Okko Ojala Olli Leskinen 2018-03-01. 3 Beta.finnair.com 3 ... using

SIMPLE &EXPRESSIVE

Page 15: travel with Angular and - Okko.fi the world of travel... · travel with Angular and measuring along the way Oskari Okko Ojala Olli Leskinen 2018-03-01. 3 Beta.finnair.com 3 ... using

NOdocumentation

Page 16: travel with Angular and - Okko.fi the world of travel... · travel with Angular and measuring along the way Oskari Okko Ojala Olli Leskinen 2018-03-01. 3 Beta.finnair.com 3 ... using

FALSEdocumentation

Page 17: travel with Angular and - Okko.fi the world of travel... · travel with Angular and measuring along the way Oskari Okko Ojala Olli Leskinen 2018-03-01. 3 Beta.finnair.com 3 ... using

STEEPlearning curve

Page 18: travel with Angular and - Okko.fi the world of travel... · travel with Angular and measuring along the way Oskari Okko Ojala Olli Leskinen 2018-03-01. 3 Beta.finnair.com 3 ... using

EFFORTto create

new components

Page 19: travel with Angular and - Okko.fi the world of travel... · travel with Angular and measuring along the way Oskari Okko Ojala Olli Leskinen 2018-03-01. 3 Beta.finnair.com 3 ... using

COMPREHEN-SIVE ROUTING

Page 20: travel with Angular and - Okko.fi the world of travel... · travel with Angular and measuring along the way Oskari Okko Ojala Olli Leskinen 2018-03-01. 3 Beta.finnair.com 3 ... using

AOT & huuuuge site

Page 21: travel with Angular and - Okko.fi the world of travel... · travel with Angular and measuring along the way Oskari Okko Ojala Olli Leskinen 2018-03-01. 3 Beta.finnair.com 3 ... using

LEGACY BROWSER SUPPORT

Page 22: travel with Angular and - Okko.fi the world of travel... · travel with Angular and measuring along the way Oskari Okko Ojala Olli Leskinen 2018-03-01. 3 Beta.finnair.com 3 ... using

BYGONES‘cause

PCI & IE EOL

Page 23: travel with Angular and - Okko.fi the world of travel... · travel with Angular and measuring along the way Oskari Okko Ojala Olli Leskinen 2018-03-01. 3 Beta.finnair.com 3 ... using

23

Our current challenges

● Async dynamic routing because of CMS content<-> Angular Router-based routing <-> AOT <-> lazy loading

● Unzipped 2MB of JS is not small● Learning curve is still steep● Zone.js issues are painful to debug

23

Page 24: travel with Angular and - Okko.fi the world of travel... · travel with Angular and measuring along the way Oskari Okko Ojala Olli Leskinen 2018-03-01. 3 Beta.finnair.com 3 ... using

(Sou

rce:

Img

ur)

Page 25: travel with Angular and - Okko.fi the world of travel... · travel with Angular and measuring along the way Oskari Okko Ojala Olli Leskinen 2018-03-01. 3 Beta.finnair.com 3 ... using

25

Timeline

2017

First public beta: New flight search, 2 languages

SearchSelect flightSelect ticket type

Mobile booking flow + top destinations,2 languages

SearchSelect flightSelect ticket typePassenger detailsSelect seatReview purchase & accept termsPaymentBooking confirmation> Production use for mobile users

2016

CMS and vendor evaluation

Extensive POC process to choose the CMS solution, consultants selected June

2016

Private Beta, 2 languages

Mobile Destinations

Project start

Created practices, started building first functional prototype on the stack

Digital Service Blueprint, Customer Journey

Mock-up design prototype of the mobile booking user experience

June2017

All languages + all destinations

> 55 country&language variations> Production usefor mobile users inall markets

2018

Bags + meals +content areas

β 2 54RC

Page 26: travel with Angular and - Okko.fi the world of travel... · travel with Angular and measuring along the way Oskari Okko Ojala Olli Leskinen 2018-03-01. 3 Beta.finnair.com 3 ... using

Whywe<3

Angular

Page 27: travel with Angular and - Okko.fi the world of travel... · travel with Angular and measuring along the way Oskari Okko Ojala Olli Leskinen 2018-03-01. 3 Beta.finnair.com 3 ... using

27

Why we <3 Angular in a large team

● Expressive - less loc = less bugs● TypeScript’s typing prevents errors● Encourages modular components● Automated testing of components is built-in● Angular 2 templates● SCSS styles isolation per-component● Dependency injections● Rxjs

27

Page 28: travel with Angular and - Okko.fi the world of travel... · travel with Angular and measuring along the way Oskari Okko Ojala Olli Leskinen 2018-03-01. 3 Beta.finnair.com 3 ... using

TAKEAWAYS

Page 29: travel with Angular and - Okko.fi the world of travel... · travel with Angular and measuring along the way Oskari Okko Ojala Olli Leskinen 2018-03-01. 3 Beta.finnair.com 3 ... using

Validate designs with real users

Page 30: travel with Angular and - Okko.fi the world of travel... · travel with Angular and measuring along the way Oskari Okko Ojala Olli Leskinen 2018-03-01. 3 Beta.finnair.com 3 ... using

Framework

saves time when creating the conventions

Page 31: travel with Angular and - Okko.fi the world of travel... · travel with Angular and measuring along the way Oskari Okko Ojala Olli Leskinen 2018-03-01. 3 Beta.finnair.com 3 ... using

Do fat microservices

Page 32: travel with Angular and - Okko.fi the world of travel... · travel with Angular and measuring along the way Oskari Okko Ojala Olli Leskinen 2018-03-01. 3 Beta.finnair.com 3 ... using

Give thin responses

Page 33: travel with Angular and - Okko.fi the world of travel... · travel with Angular and measuring along the way Oskari Okko Ojala Olli Leskinen 2018-03-01. 3 Beta.finnair.com 3 ... using

Minimizethe client-side business

logic

Page 34: travel with Angular and - Okko.fi the world of travel... · travel with Angular and measuring along the way Oskari Okko Ojala Olli Leskinen 2018-03-01. 3 Beta.finnair.com 3 ... using

Writetests

Page 35: travel with Angular and - Okko.fi the world of travel... · travel with Angular and measuring along the way Oskari Okko Ojala Olli Leskinen 2018-03-01. 3 Beta.finnair.com 3 ... using

PR PRs

Page 36: travel with Angular and - Okko.fi the world of travel... · travel with Angular and measuring along the way Oskari Okko Ojala Olli Leskinen 2018-03-01. 3 Beta.finnair.com 3 ... using

TypeScriptis awesome

Page 37: travel with Angular and - Okko.fi the world of travel... · travel with Angular and measuring along the way Oskari Okko Ojala Olli Leskinen 2018-03-01. 3 Beta.finnair.com 3 ... using

Abandonvi and emacs

- you need an IDE

Page 38: travel with Angular and - Okko.fi the world of travel... · travel with Angular and measuring along the way Oskari Okko Ojala Olli Leskinen 2018-03-01. 3 Beta.finnair.com 3 ... using

Tracking & Analytics

Page 39: travel with Angular and - Okko.fi the world of travel... · travel with Angular and measuring along the way Oskari Okko Ojala Olli Leskinen 2018-03-01. 3 Beta.finnair.com 3 ... using

39

Tracking

39

Page views Custom events Business stuff

Page 40: travel with Angular and - Okko.fi the world of travel... · travel with Angular and measuring along the way Oskari Okko Ojala Olli Leskinen 2018-03-01. 3 Beta.finnair.com 3 ... using

4040

Page views Custom events Business stuffRouter Directives Store

Page 41: travel with Angular and - Okko.fi the world of travel... · travel with Angular and measuring along the way Oskari Okko Ojala Olli Leskinen 2018-03-01. 3 Beta.finnair.com 3 ... using

4141

Page views Custom events Business stuffRouter Directives Store

Tracking Service

Page 42: travel with Angular and - Okko.fi the world of travel... · travel with Angular and measuring along the way Oskari Okko Ojala Olli Leskinen 2018-03-01. 3 Beta.finnair.com 3 ... using

4242

Page views Custom events Business stuffRouter Directives Store

Tracking Service

Page 43: travel with Angular and - Okko.fi the world of travel... · travel with Angular and measuring along the way Oskari Okko Ojala Olli Leskinen 2018-03-01. 3 Beta.finnair.com 3 ... using

43

Tracking service

43

● Does nothing

Page 44: travel with Angular and - Okko.fi the world of travel... · travel with Angular and measuring along the way Oskari Okko Ojala Olli Leskinen 2018-03-01. 3 Beta.finnair.com 3 ... using

44

Tracking service

44

Does:

● Provide event specific functions● Formatting and data minimisation● Push to a global array created by GTM

this.dataLayer = this.windowRef.nativeWindow['dataLayer'] = this.windowRef.nativeWindow['dataLayer'] || [];

checkoutFlights(cart: CartData): void {

// Privacy filtering, manipulate & format

this.pushEventToDataLayer(GtmEvent.CART_CHECKOUT, formattedCart);

}

private pushEventToDataLayer(event: GtmEvent, eventData: GtmEventData): void {

this.dataLayer.push({ event, [event]: eventData });

}

Page 45: travel with Angular and - Okko.fi the world of travel... · travel with Angular and measuring along the way Oskari Okko Ojala Olli Leskinen 2018-03-01. 3 Beta.finnair.com 3 ... using

45

The router

45

● No page refreshes in a SPA Use router!● You can subscribe to router’s events

this.router.events

.filter((event: Event) => event instanceof NavigationEnd)

.throttleTime(200)

.subscribe((event: NavigationEnd) => {

this.trackingService.pageView(event.urlAfterRedirects);

});

Page 46: travel with Angular and - Okko.fi the world of travel... · travel with Angular and measuring along the way Oskari Okko Ojala Olli Leskinen 2018-03-01. 3 Beta.finnair.com 3 ... using

46

The store - we use ngrx/store

46

● Good place for following business relevant stuff, like the payment process

● Access store as observables using .let operator (and now also: .pipe)

or

● Know when to call tracking service functions using ngrx @effect -side effects

Page 47: travel with Angular and - Okko.fi the world of travel... · travel with Angular and measuring along the way Oskari Okko Ojala Olli Leskinen 2018-03-01. 3 Beta.finnair.com 3 ... using

47

The store

47

this.store

.let(cartData())

.filter(Boolean)

.subscribe(cart => {

this.checkoutFlights(cart);

});

--- OR ---

@Effect cartCheckout$: Observable<Action> = this.actions$

.ofType(CartAtions.SET_CART_DATA)

Page 48: travel with Angular and - Okko.fi the world of travel... · travel with Angular and measuring along the way Oskari Okko Ojala Olli Leskinen 2018-03-01. 3 Beta.finnair.com 3 ... using

48

Attribute directives

48

● Not everything happening in the UI is changes the app state to store.● Attribute directive can easily:

○ Utilise component’s existing event bindings○ Utilise stuff existing in the template

Page 49: travel with Angular and - Okko.fi the world of travel... · travel with Angular and measuring along the way Oskari Okko Ojala Olli Leskinen 2018-03-01. 3 Beta.finnair.com 3 ... using

49

Attribute directives

49

<li *ngFor="let flights of flightList; let i = index">

<button (click)="clickFlight(flight)"

[elemTracker]="'flight-selection-item'"

[elemIndex]="(i+1)"

[elemModifier]="flight.stops + ' stops'"

[elemType]="ElementTypes.BUTTON">

</li>

Template Directive

@Input('elemTracker') trackingId: string;

@Input('elemIndex') trackingIndex: number;

@Input('elemModifier') trackingModifier: string;

@Input('elemType') trackingElemType: ElementTypes;

@HostListener('click', ['$event'])

onClick(event) {

this.trackingService.trackElement(

this.trackingId,

this.trackingIndex,

this.trackingModifier,

this.trackingElemType.

);

}

Page 50: travel with Angular and - Okko.fi the world of travel... · travel with Angular and measuring along the way Oskari Okko Ojala Olli Leskinen 2018-03-01. 3 Beta.finnair.com 3 ... using

50

Tracking conclusions

50

● Router● @ngrx/store if you are using it ● Directives can be used for UI tracking● Service to format and push data forwards● Easy data layer specs based on your event interfaces

Page 51: travel with Angular and - Okko.fi the world of travel... · travel with Angular and measuring along the way Oskari Okko Ojala Olli Leskinen 2018-03-01. 3 Beta.finnair.com 3 ... using

beta.finnair.com

frantic.com/jobsfinnair.com/jobs