Skip to content
This repository has been archived by the owner on Sep 22, 2023. It is now read-only.

Javascriptsdk #7

Merged
merged 15 commits into from
Mar 24, 2022
Merged
Show file tree
Hide file tree
Changes from 6 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
66 changes: 66 additions & 0 deletions docs/analytics/dynamic-configuration.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
---
title: Dynamic Configuration
description: Use dynamic configuration to find the best server URLs based on a user's location.
---

Some Amplitude SDK versions (iOS 5.3.0+, Android 2.28.0+, and JavaScript 8.9.0+) let you set your apps to use dynamic configuration.
Dynamic configuration finds the best Amplitude server URL based on app users' location.

## Considerations

- If you have your own proxy server and use `setServerUrl` API, don't use dynamic configuration.
- If you have users in Mainland China, we recommend that you use dynamic configuration.
- By default, this feature is off. You must explicitly set it to `true` to use it.

## Use cases

### Region-based

Send users from different regions to the server for their region.

``` mermaid
stateDiagram-v2
s1: Dynamic Config Server
cn_user: User in China
us_user: User in United States
s1 --> cn_user : api2.amplitude.com
s1 --> us_user : api.amplitude.com

```

### Dynamically adjust server URLs

If a server URL becomes unreachable for some reason, Amplitude can change the address in the dynamic configuration server.
This makes the ingestion endpoint dynamic, so you don't need to release a new version of your app.

``` mermaid
stateDiagram-v2
s1: Dynamic Config Server
user: User
s1 --> user : new.amplitude.com (new URL)
s1 --> user : old.amplitude.com (broken URL)
```

## Usage

Set the `useDynamicConfig` flag to `true`.
caseyamp marked this conversation as resolved.
Show resolved Hide resolved

=== "iOS"

```obj-c
[Amplitude instance].useDynamicConfig = YES;
```

=== "Android"

```java
AmplitudeClient.getInstance().setUseDynamicConfig(true);
```

=== "JavaScript"

```js
amplitude.getInstance().init(euApiKey, null, {
useDynamicConfig: true,
});
```
38 changes: 9 additions & 29 deletions docs/analytics/sdks/android-sdk.md
Original file line number Diff line number Diff line change
Expand Up @@ -473,12 +473,7 @@ You can also use `logEventWithGroups` to set event-level groups, meaning the gro

--8<-- "includes/editions-growth-enterprise-with-accounts.md"

Use the Group Identify API to set or update properties of particular groups. Keep these considerations in mind:

- Updates affect only future events, and don't update historical events.
- You can track up to 5 unique group types and 10 total groups.

The `groupIdentify` method accepts a group type string parameter and group name object parameter, and an Identify object that's applied to the group.
--8<-- "includes/group-identify-considerations.md"

=== "Java"

Expand Down Expand Up @@ -513,15 +508,7 @@ Amplitude can track revenue generated by a user. Revenue is tracked through dist

Revenue objects support the following special properties, as well as user-defined properties through the `eventProperties` field.

| <div class="big-column">Name</div> | Description |
| --- | --- |
| `productId` | Optional. String. An identifier for the product. Amplitude recommends something like the "Google Play Store product ID". Defaults to `null`. |
| `quantity`| Required. Integer. The quantity of products purchased. Note: revenue = quantity * price. Defaults to 1. |
| `price` | Required. Double. The price of the products purchased, and this can be negative. Note: revenue = quantity * price. Defaults to `null`.|
| `revenueType` | Optional, but required for revenue verification. String. The type of revenue (e.g. tax, refund, income). Defaults to `null`. |
| `receipt` | Optional. String. The type of revenue (e.g. tax, refund, income). Defaults to `null` |
| `receiptSignature` | Optional, but required for revenue verification. The type of revenue (e.g. tax, refund, income). | null |
| `eventProperties`| Optional. JSONObject. An object of event properties to include in the revenue event. Defaults to `null`. |
--8<-- "includes/track-revenue-properties-table.md"

!!!note "Notes about tracking revenue"

Expand Down Expand Up @@ -773,15 +760,7 @@ You can set the log level by calling the following on Android:

## Logged out and anonymous users

Amplitude [merges user data](https://help.amplitude.com/hc/en-us/articles/115003135607#h_c323d7e5-4662-4a36-b0a1-5110a341e80c), so any events associated with a known `userId` or `deviceId` are linked the existing user.
If a user logs out, Amplitude can merge that user's logged-out events to the user's record. You can change this behavior and log those events to an anonymous user instead.

To log events to an anonymous user:

1. Set the `userId` to null.
2. Generate a new `deviceId`.

Events coming from the current user or device appear as a new user in Amplitude. Note: If you do this, you can't see that the two users were using the same device.
--8<-- "includes/logged-out-and-anonymous-users.md"

=== "Java"

Expand Down Expand Up @@ -983,12 +962,13 @@ Second, add the following code in your root activity's onCreate life cycle.

### Dynamic Configuration

Android SDK allows users to configure their apps to use [dynamic configuration](https://developers.amplitude.com/docs/dynamic-configuration). This feature finds the best server URL automatically based on app users' location.
Android SDK allows users to configure their apps to use [dynamic configuration](analytics/dynamic-configuration). This feature finds the best server URL automatically based on app users' location.

- If you have your own proxy server and use `setServerUrl` API, leave dynamic configuration off.
- If you have users in China Mainland, then we recommend using dynamic configuration.
- By default, this feature returns server URL of Amplitude's US servers, if you need to send data to Amplitude's EU servers, use `setServerZone` to set it to EU zone.

- If you have your own proxy server and use `setServerUrl` API, please leave this OFF.
- If you have users in China Mainland, we suggest you turn this on.
- By default, this feature is OFF. You must explicitly set it to ON to use it.
- By default, this feature returns server URL for Amplitude's US servers, if you need to send data to Amplitude's EU servers, please use `setServerZone` to set it to EU zone.
To use, set `setUseDynamicConfig` to `true`.

=== "Java"

Expand Down
Loading