[RN Library ๐Ÿ“š] react native ํ”„๋กœ์ ํŠธ์— firebase๋กœ A/B ํ…Œ์ŠคํŠธ๋ฅผ ํ•ด๋ณด์ž. - 1 (Firebase Remote Config)

๋„๋””ยท2020๋…„ 11์›” 24์ผ
2

RN Library ๐Ÿ“š

๋ชฉ๋ก ๋ณด๊ธฐ
9/12

์‚ฌ์šฉ์ž๋Š” ๊ณผ์—ฐ ์–ด๋–ค UI์—์„œ ์ฐธ์—ฌ๋„, ๋งŒ์กฑ๋„๊ฐ€ ๋†’์„๊นŒ?

์šฐ๋ฆฌ ํŒ€์—์„œ ์ •๋ง ๋งŽ์ด ๊ณ ๋ฏผํ•ด๋ณด๋Š” ์‚ฌํ•ญ์ด๋‹ค. ๊ทธ๋Ÿฐ๋ฐ ๊ณ ๋ฏผํ•ด๋ณธ๋“ค ๋‹ต์„ ์•Œ ์ˆ˜๊ฐ€ ์—†์ง€.
A/B ํ…Œ์ŠคํŠธ๋ฅผ ๋„์ž…ํ•ด์„œ ์œ ์ €์˜ ํ–‰๋™์„ ์ง์ ‘์ ์œผ๋กœ ๊ด€์ฐฐํ•ด๋ณด๊ธฐ๋กœ ํ–ˆ๋‹ค.

์•„์ง ๋ฒ ํƒ€ ๋ฒ„์ „์ด๋ผ๊ณ  ํ•˜๋Š” Fifebase์˜ A/B Testing๊ณผ Config Remote๋ฅผ ์ด์šฉํ•ด๋ณธ๋‹ค.
Firebase A/B ํ…Œ์ŠคํŠธ์—๋Š” ์„ธ๊ฐ€์ง€ ํ˜•์‹์ด ์žˆ๋‹ค. ( ์•Œ๋ฆผ, ์›๊ฒฉ๊ตฌ์„ฑ, ์ธ์•ฑ๋ฉ”์‹œ์ง€ )

์•Œ๋ฆผ

์ ์ ˆํ•œ ์ˆœ๊ฐ„์— ์ ์ ˆํ•œ ์‚ฌ์šฉ์ž์™€ ์†Œํ†ตํ•˜๊ธฐ ์œ„ํ•ด ๋ฉ”์‹œ์ง€ ์ „์†ก์„ ์‹คํ—˜ํ•œ๋‹ค.
Firebase์˜ Cloud Messaging์œผ๋กœ ์—ฐ๊ฒฐํ•œ๋‹ค.

์›๊ฒฉ ๊ตฌ์„ฑ

์„œ๋ฒ„์ธก ๊ตฌ์„ฑ ๋งค๊ฐœ๋ณ€์ˆ˜๋ฅผ ์‚ฌ์šฉํ•˜์—ฌ ์•ฑ ๋™์ž‘์„ ์‹คํ–‰ํ•œ๋‹ค.
Firebase์˜ Remote Config๋กœ ์—ฐ๊ฒฐํ•œ๋‹ค.

์ธ์•ฑ ๋ฉ”์‹œ์ง€

์ฐธ์—ฌ ์œ ๋„๋ฅผ ๊ทน๋Œ€ํ™” ํ•˜๊ธฐ ์œ„ํ•ด ์„œ๋กœ ๋‹ค๋ฅธ ์ธ์•ฑ ๋ฉ”์‹œ์ง€๋ฅผ ๋ณด๋‚ด๋Š” ์‹คํ—˜์ด๋‹ค.
Firebase์˜ In-App Messaging์œผ๋กœ ์—ฐ๊ฒฐํ•œ๋‹ค.

์ด ์ค‘ ์˜ค๋Š˜์€ Remote Config๋ฅผ ์„ธํŒ…ํ•˜๋Š” ์ž‘์—…์„ ํ•ด๋ณด์ž.
RN remote config ๋ฌธ์„œ ๋ฐ”๋กœ๊ฐ€๊ธฐ

Remote Config ์…‹ํŒ…ํ•˜์ž

1. ๋ผ์ด๋ธŒ๋Ÿฌ๋ฆฌ๋ฅผ ์„ค์น˜ํ•˜์ž

npm install @react-native-firebase/app
npm install @react-native-firebase/remote-config

cd ios/ && pod install

2. ์ฝ”๋“œ์—์„œ ๋งค๊ฐœ๋ณ€์ˆ˜ ๋ถˆ๋Ÿฌ์˜ค๊ธฐ

๋งค๊ฐœ๋ณ€์ˆ˜๋ฅผ ์–ด๋–ป๊ฒŒ ๋ถˆ๋Ÿฌ์˜ค์ง€? ์•„์ง ๋งค๊ฐœ๋ณ€์ˆ˜ ์ •์˜๋ฅผ ํ•˜์ง€ ์•Š์•˜๋Š”๋ฐ?
๋„ค ์•„์ง ์ •์˜ํ•˜์ง€ ์•Š์•˜์ง€.
์ด๋ ‡๊ฒŒ ๋„คํŠธ์›Œํฌ๊ฐ€ ์—†๊ฑฐ๋‚˜, ์•„์ง ์ฝ”๋“œ์—์„œ ๋งค๊ฐœ๋ณ€์ˆ˜๋ฅผ ๋ถˆ๋Ÿฌ์˜ค์ง€ ๋ชปํ•œ ๊ฒฝ์šฐ๋ฅผ ์œ„ํ•ด default ๊ฐ’์„ ์„ค์ •ํ•ด์ฃผ๋Š” ์ž‘์—…์„ ๋จผ์ € ํ•ด์ฃผ์ž.

setDefault()๋กœ ๊ธฐ๋ณธ๊ฐ’ ์„ธํŒ…

์ €๋Š” ๋งค๊ฐœ๋ณ€์ˆ˜ ๋ช…์„ dody_says๋กœ ํ• ๊ฑฐ๊ตฌ์š”. ๋งค๊ฐœ๋ณ€์ˆ˜๋ฅผ ๋ถˆ๋Ÿฌ์˜ค์ง€ ๋ชปํ•œ ๊ฒฝ์šฐ default hello๋กœ ์ถœ๋ ฅ๋˜๊ฒŒ ํ• ๊ฑฐ๋‹ค.

import React, { useEffect } from 'react';
import remoteConfig from '@react-native-firebase/remote-config';

function App() {
  useEffect(() => {
    remoteConfig()
      .setDefaults({ dody_says: 'default hello' }) // here
      .then(() => { console.log('Default values set.') });
  }, []);
}

์ž, default hello๋กœ default ๊ฐ’์ด ์ž˜ ๋“ค์–ด๊ฐ”๋Š”์ง€ ํ™•์ธ์„ ํ•ด๋ณด์ž.

Remote Config Fetch ๋ฐ Activating

ํ™•์ธ์„ ์œ„ํ•ด์„  fetchAndActivate() ๋‚ด์žฅํ•จ์ˆ˜๋ฅผ ์ด์šฉํ•ด
Firebase Remote Config๋ฅผ fetch ํ•˜๊ณ , ํ”„๋กœ์ ํŠธ์—์„œ ํ™œ์„ฑํ™”ํ•˜๋Š” ์ž‘์—…์ด ํ•„์š”ํ•˜๋‹ค.

๊ทธ์ œ์„œ์•ผ getValue()๋กœ ๋งค๊ฐœ๋ณ€์ˆ˜ ๊ฐ’ ํ™•์ธ์ด ๊ฐ€๋Šฅํ•˜๋‹ค.

import React, { useEffect } from 'react';
import remoteConfig from '@react-native-firebase/remote-config';

function App() {
  useEffect(() => {
    remoteConfig()
      .setDefaults({ dody_says: 'default hello' })
      
      // add here
      .then(() => remoteConfig().fetchAndActivate())
      .then((fetchedRemotely) => {
      	if (fetchedRemotely) {
          console.log(
            remoteConfig().getValue('dody_says');
          );
        }
        else {console.log('์‹คํŒจ');
      });
  }, []);
}

์œ„์™€ ๊ฐ™์ด getValue()๋กœ dody_says ๊ฐ’์„ ์กฐํšŒํ•˜๋ฉด ์•„๊นŒ ์„ธํŒ…ํ•ด์คฌ๋˜ 'default hello' ๊ฐ€ ์ถœ๋ ฅ๋œ๋‹ค.

3. Firebase Console์—์„œ ๋งค๊ฐœ๋ณ€์ˆ˜ ์ •์˜ํ•˜๊ธฐ

Firebase Remote Config Console๋กœ ๋“ค์–ด๊ฐ€ ๋งค๊ฐœ๋ณ€์ˆ˜ ์ถ”๊ฐ€๋ฅผ ๋ˆ„๋ฅด๋ฉด ์•„๋ž˜์™€ ๊ฐ™์ด ๋‚˜์˜จ๋‹ค.

๋งค๊ฐœ๋ณ€์ˆ˜ ํ‚ค๋กœ ๋ฏธ๋ฆฌ ์ •ํ•ด๋†“์€ dody_says๋ฅผ ๋„ฃ๊ณ  ๊ธฐ๋ณธ๊ฐ’์— ํ•„์š”ํ•œ ๊ฐ’์„ ๋„ฃ๋Š”๋‹ค.

์ด๋ ‡๊ฒŒ ๊ฐ’์„ ๋„ฃ๊ณ  ์—…๋ฐ์ดํŠธํ•˜๊ณ  ๋ณ€๊ฒฝ์‚ฌํ•ญ์„ ๊ฒŒ์‹œํ•˜๊ฒŒ ๋˜๋ฉด
์ถœ๋ ฅ๊ฐ’์ด default hello์—์„œ configured hello ๊ฐ€ ๋‚˜์˜ค๊ฒŒ ๋œ๋‹ค.

์ด๋ ‡๊ฒŒ Firebase Config Remote ์„ธํŒ…์€ ๋์ด๋‹ค.
๋งค๊ฐœ๋ณ€์ˆ˜ ๊ฐ’์€ Firebase Console์—์„œ ์‰ฝ๊ฒŒ ๋ฐ”๊ฟ€ ์ˆ˜ ์žˆ๊ธฐ ๋•Œ๋ฌธ์—
์ด๋ฒคํŠธ๋ฐฐ๋„ˆ ๊ฐ™์€ ์ƒํ™ฉ์„ ํ‚ค๊ณ  ๋„๋Š”๋ฐ ๋งŽ์ด ์‚ฌ์šฉ๋˜๊ธฐ๋„ ํ•œ๋‹ค๊ณ  ํ•œ๋‹ค.
codepush๋กœ ์ด๋ฒคํŠธ ๋„๊ณ  ํ‚ค๊ณ  ํ•˜๋ ค ํ–ˆ๋Š”๋ฐ, Remote Config๊ฐ€ ๋” ์ ์ ˆํ•œ๊ฑฐ๊ฐ™๋‹ค ใ…‹ใ…‹ใ…‹

๋‹ค์Œ ๊ธ€์—์„œ๋Š” A/B Testing ์‹คํ—˜์„ ๋งŒ๋“ค์–ด๋ณด๊ณ  ํ…Œ์ŠคํŠธํ•ด๋ณด์ž

profile
์ถฉ์ „์ค‘..๐Ÿค”

0๊ฐœ์˜ ๋Œ“๊ธ€