fix instructions
This commit is contained in:
committed by
Carl-Gerhard Lindesvärd
parent
ccfddc215f
commit
e4eb697b47
@@ -64,16 +64,13 @@ const Instructions = ({ framework, client }: Props) => {
|
|||||||
<div className="flex flex-col gap-4">
|
<div className="flex flex-col gap-4">
|
||||||
<p>Copy the code below and insert it to you website</p>
|
<p>Copy the code below and insert it to you website</p>
|
||||||
<Syntax
|
<Syntax
|
||||||
code={`<script src="https://openpanel.dev/op1.js" defer async></script>
|
code={`window.op = window.op||function(...args){(window.op.q=window.op.q||[]).push(args);};
|
||||||
<script>
|
window.op('init', {
|
||||||
window.op = window.op || function (...args) { (window.op.q = window.op.q || []).push(args); };
|
|
||||||
window.op('ctor', {
|
|
||||||
clientId: '${clientId}',
|
clientId: '${clientId}',
|
||||||
trackScreenViews: true,
|
trackScreenViews: true,
|
||||||
trackOutgoingLinks: true,
|
trackOutgoingLinks: true,
|
||||||
trackAttributes: true,
|
trackAttributes: true,
|
||||||
});
|
});`}
|
||||||
</script>`}
|
|
||||||
/>
|
/>
|
||||||
<Alert>
|
<Alert>
|
||||||
<AlertDescription>
|
<AlertDescription>
|
||||||
@@ -89,14 +86,14 @@ const Instructions = ({ framework, client }: Props) => {
|
|||||||
<div className="flex flex-col gap-4">
|
<div className="flex flex-col gap-4">
|
||||||
<p>Install dependencies</p>
|
<p>Install dependencies</p>
|
||||||
<Syntax code={`pnpm install @openpanel/nextjs`} />
|
<Syntax code={`pnpm install @openpanel/nextjs`} />
|
||||||
<p>Add OpenpanelProvider to your root layout</p>
|
<p>Add OpenPanelComponent to your root layout</p>
|
||||||
<Syntax
|
<Syntax
|
||||||
code={`import { OpenpanelProvider } from '@openpanel/nextjs';
|
code={`import { OpenPanelComponent } from '@openpanel/nextjs';
|
||||||
|
|
||||||
export default RootLayout({ children }) {
|
export default RootLayout({ children }) {
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
<OpenpanelProvider
|
<OpenPanelComponent
|
||||||
clientId="${clientId}"
|
clientId="${clientId}"
|
||||||
trackScreenViews={true}
|
trackScreenViews={true}
|
||||||
trackAttributes={true}
|
trackAttributes={true}
|
||||||
@@ -114,10 +111,10 @@ const Instructions = ({ framework, client }: Props) => {
|
|||||||
track custom events.
|
track custom events.
|
||||||
</p>
|
</p>
|
||||||
<Syntax
|
<Syntax
|
||||||
code={`import { trackEvent } from '@openpanel/nextjs';
|
code={`import { useOpenPanel } from '@openpanel/nextjs';
|
||||||
|
|
||||||
// Sends an event with payload foo: bar
|
// Sends an event with payload foo: bar
|
||||||
trackEvent('my_event', { foo: 'bar' });
|
useOpenPanel().track('my_event', { foo: 'bar' });
|
||||||
`}
|
`}
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
@@ -182,19 +179,30 @@ $openpanel->event(
|
|||||||
<strong>Usage</strong>
|
<strong>Usage</strong>
|
||||||
<p>Create a custom event called "my_event".</p>
|
<p>Create a custom event called "my_event".</p>
|
||||||
<Syntax
|
<Syntax
|
||||||
code={`curl 'https://api.openpanel.dev/event' \\
|
code={`curl 'https://api.openpanel.dev/track' \\
|
||||||
-H 'content-type: application/json' \\
|
-H 'content-type: application/json' \\
|
||||||
-H 'openpanel-client-id: ${clientId}' \\
|
-H 'openpanel-client-id: ${clientId}' \\
|
||||||
-H 'openpanel-client-secret: ${clientSecret}' \\
|
-H 'openpanel-client-secret: ${clientSecret}' \\
|
||||||
--data-raw '{"name":"my_event","properties":{"foo":"bar"},"timestamp":"2024-03-28T08:42:54.319Z"}'`}
|
--data-raw '{
|
||||||
|
"type": "track",
|
||||||
|
"payload": {
|
||||||
|
"name": "my_event",
|
||||||
|
"properties": {
|
||||||
|
"foo": "bar"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}'`}
|
||||||
/>
|
/>
|
||||||
<p>The payload should be a JSON object with the following fields:</p>
|
<p>The payload should be a JSON object with the following fields:</p>
|
||||||
<ul className="list-inside list-disc">
|
<ul className="list-inside list-disc">
|
||||||
<li>"name" (string): The name of the event.</li>
|
|
||||||
<li>"properties" (object): The properties of the event.</li>
|
|
||||||
<li>
|
<li>
|
||||||
"timestamp" (string): The timestamp of the event in ISO
|
"type" (string): track | identify | alias | increment |
|
||||||
8601 format.
|
decrement
|
||||||
|
</li>
|
||||||
|
<li>"payload.name" (string): The name of the event.</li>
|
||||||
|
<li>
|
||||||
|
"payload.properties" (object): The properties of the
|
||||||
|
event.
|
||||||
</li>
|
</li>
|
||||||
</ul>
|
</ul>
|
||||||
</div>
|
</div>
|
||||||
@@ -230,7 +238,7 @@ app.use(
|
|||||||
|
|
||||||
app.get('/sign-up', (req, res) => {
|
app.get('/sign-up', (req, res) => {
|
||||||
// track sign up events
|
// track sign up events
|
||||||
req.op.event('sign-up', {
|
req.op.track('sign-up', {
|
||||||
email: req.body.email,
|
email: req.body.email,
|
||||||
});
|
});
|
||||||
res.send('Hello World');
|
res.send('Hello World');
|
||||||
@@ -269,13 +277,13 @@ const op = new OpenPanel({
|
|||||||
code={`import { op } from './openpanel';
|
code={`import { op } from './openpanel';
|
||||||
|
|
||||||
// Sends an event with payload foo: bar
|
// Sends an event with payload foo: bar
|
||||||
op.event('my_event', { foo: 'bar' });
|
op.track('my_event', { foo: 'bar' });
|
||||||
|
|
||||||
// Identify with profile id
|
// Identify with profile id
|
||||||
op.setProfileId('123');
|
op.identify({ profileId: '123' });
|
||||||
|
|
||||||
// or with additional data
|
// or with additional data
|
||||||
op.setProfile({
|
op.identify({
|
||||||
profileId: '123',
|
profileId: '123',
|
||||||
firstName: 'John',
|
firstName: 'John',
|
||||||
lastName: 'Doe',
|
lastName: 'Doe',
|
||||||
@@ -283,12 +291,12 @@ op.setProfile({
|
|||||||
});
|
});
|
||||||
|
|
||||||
// Increment a property
|
// Increment a property
|
||||||
op.increment('app_opened'); // increment by 1
|
op.increment({ name: 'app_opened', profile_id: '123' }); // increment by 1
|
||||||
op.increment('app_opened', 5); // increment by 5
|
op.increment({ name: 'app_opened', profile_id: '123', value: 5 }); // increment by 5
|
||||||
|
|
||||||
// Decrement a property
|
// Decrement a property
|
||||||
op.decrement('app_opened'); // decrement by 1
|
op.decrement({ name: 'app_opened', profile_id: '123' }); // decrement by 1
|
||||||
op.decrement('app_opened', 5); // decrement by 5`}
|
op.decrement({ name: 'app_opened', profile_id: '123', value: 5 }); // decrement by 5`}
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
@@ -309,9 +317,9 @@ npx expo install --pnpm expo-application expo-constants`}
|
|||||||
environment. You should omit clientSecret if you use this on web!
|
environment. You should omit clientSecret if you use this on web!
|
||||||
</p>
|
</p>
|
||||||
<Syntax
|
<Syntax
|
||||||
code={`import { Openpanel } from '@openpanel/react-native';
|
code={`import { OpenPanel } from '@openpanel/react-native';
|
||||||
|
|
||||||
const op = new Openpanel({
|
const op = new OpenPanel({
|
||||||
clientId: '${clientId}',
|
clientId: '${clientId}',
|
||||||
clientSecret: '${clientSecret}',
|
clientSecret: '${clientSecret}',
|
||||||
});`}
|
});`}
|
||||||
@@ -321,13 +329,13 @@ const op = new Openpanel({
|
|||||||
code={`import { op } from './openpanel';
|
code={`import { op } from './openpanel';
|
||||||
|
|
||||||
// Sends an event with payload foo: bar
|
// Sends an event with payload foo: bar
|
||||||
op.event('my_event', { foo: 'bar' });
|
op.track('my_event', { foo: 'bar' });
|
||||||
|
|
||||||
// Identify with profile id
|
// Identify with profile id
|
||||||
op.setProfileId('123');
|
op.identify({ profileId: '123' });
|
||||||
|
|
||||||
// or with additional data
|
// or with additional data
|
||||||
op.setProfile({
|
op.identify({
|
||||||
profileId: '123',
|
profileId: '123',
|
||||||
firstName: 'John',
|
firstName: 'John',
|
||||||
lastName: 'Doe',
|
lastName: 'Doe',
|
||||||
@@ -335,12 +343,12 @@ op.setProfile({
|
|||||||
});
|
});
|
||||||
|
|
||||||
// Increment a property
|
// Increment a property
|
||||||
op.increment('app_opened'); // increment by 1
|
op.increment({ name: 'app_opened', profile_id: '123' }); // increment by 1
|
||||||
op.increment('app_opened', 5); // increment by 5
|
op.increment({ name: 'app_opened', profile_id: '123', value: 5 }); // increment by 5
|
||||||
|
|
||||||
// Decrement a property
|
// Decrement a property
|
||||||
op.decrement('app_opened'); // decrement by 1
|
op.decrement({ name: 'app_opened', profile_id: '123' }); // decrement by 1
|
||||||
op.decrement('app_opened', 5); // decrement by 5`}
|
op.decrement({ name: 'app_opened', profile_id: '123', value: 5 }); // decrement by 5`}
|
||||||
/>
|
/>
|
||||||
<strong>Navigation</strong>
|
<strong>Navigation</strong>
|
||||||
<p>
|
<p>
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
##### Web options
|
##### Web options
|
||||||
|
|
||||||
- `trackScreenViews` - If true, the library will automatically track screen views
|
- `trackScreenViews` - If true, the library will automatically track screen views (default: false)
|
||||||
- `trackOutgoingLinks` - If true, the library will automatically track outgoing links
|
- `trackOutgoingLinks` - If true, the library will automatically track outgoing links (default: false)
|
||||||
- `trackAttributes` - If true, the library will automatically track attributes
|
- `trackAttributes` - If true, you can trigger events by using html attributes (`<button data-track="your_event" />`) (default: false)
|
||||||
|
|
||||||
|
|||||||
@@ -30,6 +30,7 @@ op.screenView({ title: 'Home' }); // path will be what ever window.location.path
|
|||||||
## Script tag
|
## Script tag
|
||||||
|
|
||||||
- New: `https://openpanel.dev/op1.js` should be used instead of `op.js` (note the filename)
|
- New: `https://openpanel.dev/op1.js` should be used instead of `op.js` (note the filename)
|
||||||
|
- Renamed: Tracking with attributes have changed. Use `data-track="my_event"` instead of `data-event="my_event"`
|
||||||
|
|
||||||
## @openpanel/nextjs
|
## @openpanel/nextjs
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user