Skip to content

Latest commit

 

History

History
104 lines (73 loc) · 2.39 KB

File metadata and controls

104 lines (73 loc) · 2.39 KB

Back to overview

Step-by-Step Example Integration

This walkthrough wires the SDK into a small Expo game from scratch. By the end you are tracking sessions, screens, a purchase, and a custom event.

1. Install and initialise

npm install @keewano/react-native-expo-sdk

Initialise once in your root component:

import { useEffect } from 'react';
import { Keewano } from '@keewano/react-native-expo-sdk';

export default function App() {
  useEffect(() => {
    void Keewano.init({ apiKey: 'your-project-api-key' });
  }, []);

  return <RootNavigator />;
}

At this point session context, button taps, and errors are already being captured.

2. Track screens

Add the navigation hook so screen changes become SCENE_LOADED / SCENE_UNLOADED:

import { usePathname } from 'expo-router';
import { useKeewanoNavigation } from '@keewano/react-native-expo-sdk';

function RootLayout() {
  useKeewanoNavigation(usePathname);
  // ...
}

3. Report a purchase

In your buy handler, report the purchase once the store confirms it:

async function onBuyGems() {
  const result = await store.purchase('gem_pack_large');
  if (result.ok) {
    Keewano.reportInAppPurchase({
      productName: 'gem_pack_large',
      price: { priceUsdCents: 499 },
    });
    Keewano.reportInAppPurchaseItemsGranted({
      productName: 'gem_pack_large',
      items: [{ name: 'gems', count: 500 }],
    });
  }
}

4. Track progression

Report onboarding milestones as the player advances:

Keewano.reportOnboardingMilestone('TutorialComplete');

5. Add a custom event

Declare your own events, generate typed helpers, and call them:

npx keewano-codegen --input keewano-custom-events
import { customEventSet, reportGameScore } from '../keewano-custom-events/keewano-events.generated';

// pass the schema at init
Keewano.init({ apiKey: '...', customEventSet });

// report it anywhere, fully typed
reportGameScore(13050);

See Custom Events for the full workflow.

6. Verify

Mark your own session as a test user and check the events arrive - see Integration Testing.

Keewano.markAsTestUser('dev');

Related: Getting Started | Integration Testing | Existing App Integration