Giter VIP home page Giter VIP logo

react-twa-boilerplate's Introduction

Cute little React TWA boilerpate with Telemetree analytics pre-installed.

Static Badge GitHub top language GitHub commit activity

No backend integration, mocked interactions.

As app will not render several elements and components that are dependant on Telegram specific functions and user settings passed in runtime, native components (eg. MainButton) are replaced or backed by static UI but kept in the code for reference.

Live TWA: @ton_solutions_waitlist_bot.

To run locally:


git clone https://github.com/TONSolutions/react-twa-boilerplate.git
cd react-twa-boilerplate
npm i
npm run dev

Quick routes to bypass validation:

/signup

/success

/error

5 steps to integrate (as in the boilerplate):

Install the package: npm install @tonsolutions/telemetree-react --save or yarn add @tonsolutions/telemetree-react

import the lib and wrap your app with the provider (How to get your keys):

import { TwaAnalyticsProvider } from '@tonsolutions/telemetree-react'

<TwaAnalyticsProvider
      projectId='YOUR_PROJECT_ID'
      apiKey='YOUR_API_KEY'
      appName='YOUR_APPLICATION_NAME'
    >
{/_ Rest of your app components _/}
</TwaAnalyticsProvider>

(working "Boilerplate" project is set in the code but it will not send events β€” user is not set error β€” unless being wrapped as an actual TWA)

Import in the target component: import { useTWAEvent } from '@tonsolutions/telemetree-react';

Initialize the event builder: const eventBuilder = useTWAEvent();

And track an event:

const handleButtonClick = () => {
  eventBuilder.track('Button Clicked');
  // ... rest of your click handling logic
};

Documentation

Full integration documentation incl data enrichment and wallet events is available in the React SDK reference.


Kudos to KonstaUI for dynamic iOS/Android context switching.

Built with passion by TON Solutions in New York City, USA πŸ‡ΊπŸ‡Έ

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    πŸ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. πŸ“ŠπŸ“ˆπŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❀️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.