This repository was archived by the owner on Mar 31, 2026. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathApp.tsx
More file actions
73 lines (68 loc) · 2.82 KB
/
App.tsx
File metadata and controls
73 lines (68 loc) · 2.82 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
import React from 'react';
import logo from './assets/amplitude_logo.png';
import './App.css';
/**
* Import strongly typed SDKs for convenience
*/
import { amplitude, user, analytics, experiment, UserLoggedIn, Logger, NoLogger } from './amplitude';
import { getProductConfigurationFromEnv } from "@amplitude/util";
const { REACT_APP_LOGGING_DISABLED } = process.env;
const useLogger = REACT_APP_LOGGING_DISABLED !== 'true';
amplitude.typed.load({
environment: 'development',
logger: useLogger ? new Logger() : new NoLogger(),
// Try reading in ApiKeys from .env file
...getProductConfigurationFromEnv(true),
})
function App() {
return (
<div className="App">
<header className="App-header">
<img src={logo} className="App-logo" alt="logo" />
<p>
Unified SDK - Proof of Concept
</p>
<div className="section-group">
<div className="section">
<span>User</span>
<button onClick={() => user.setUserId('alpha-user-id')}>Set User Id (generic)</button>
<button onClick={() => user.setUserId('alpha-codegen-user-id')}>Set User Id (codegen)</button>
<button onClick={() => user.typed.setUserProperties({
favoriteSongCount: 1,
referralSource: 'twitter'
})}>Set User Properties</button>
</div>
<div className="section">
<span>Analytics</span>
<button onClick={() => analytics.typed.userLoggedIn({
method: 'email'
})}>Login (with Event method)</button>
<button onClick={() => analytics.track(new UserLoggedIn({
method: 'google'
}))}>Login (with Event class)</button>
<button onClick={() => analytics.typed.userSignedUp()}>Sign Up</button>
</div>
<div className="section">
<span>Experiment</span>
<button onClick={() => experiment.fetch()}>experiment.fetch()</button>
<button onClick={() => experiment.exposure()}>experiment.exposure()</button>
<button onClick={() => {
console.log(`${
experiment.typed.codegenBooleanExperiment().key
} is ${
experiment.typed.codegenBooleanExperiment().on ? 'on' : 'off'
}`)
}}>experiment.typed.codegenBooleanExperiment()</button>
<button onClick={() => {
console.log(experiment.typed.codegenArrayExperiment().generic?.payload);
}}>experiment.typed.codegenArrayExperiment().generic.payload</button>
<button onClick={() => {
console.log(experiment.typed.codegenArrayExperiment().ampli?.payload);
}}>experiment.typed.codegenArrayExperiment().ampli.payload</button>
</div>
</div>
</header>
</div>
);
}
export default App;