Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: change host to new address. #234

Merged
merged 3 commits into from
May 29, 2024
Merged
Show file tree
Hide file tree
Changes from all 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
2 changes: 1 addition & 1 deletion examples/example_expo_rn_web/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { StyleSheet, Text, View } from 'react-native'
import PostHog from 'posthog-react-native'

export const posthog = new PostHog('phc_pQ70jJhZKHRvDIL5ruOErnPy6xiAiWCqlL4ayELj4X8', {
host: 'https://app.posthog.com',
host: 'https://us.i.posthog.com',
flushAt: 1,
captureNativeAppLifecycleEvents: false,
sendFeatureFlagEvent: false,
Expand Down
2 changes: 1 addition & 1 deletion examples/example_rn/posthog.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import React from 'react';
export const posthog = new PostHog(
'phc_pQ70jJhZKHRvDIL5ruOErnPy6xiAiWCqlL4ayELj4X8',
{
host: 'https://app.posthog.com',
// host: 'https://us.i.posthog.com',
// persistence: 'memory',
},
);
Expand Down
2 changes: 1 addition & 1 deletion examples/example_rn_macos/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ import PostHog from 'posthog-react-native';
export const posthog = new PostHog(
'phc_pQ70jJhZKHRvDIL5ruOErnPy6xiAiWCqlL4ayELj4X8',
{
host: 'https://app.posthog.com',
// host: 'https://us.i.posthog.com',
// persistence: 'memory',
},
);
Expand Down
2 changes: 1 addition & 1 deletion examples/example_rn_new_architecture/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ import PostHog from 'posthog-react-native';
export const posthog = new PostHog(
'phc_pQ70jJhZKHRvDIL5ruOErnPy6xiAiWCqlL4ayELj4X8',
{
host: 'https://app.posthog.com',
// host: 'https://us.i.posthog.com',
// persistence: 'memory',
},
);
Expand Down
2 changes: 1 addition & 1 deletion posthog-core/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ export abstract class PostHogCoreStateless {
assert(apiKey, "You must pass your PostHog project's api key.")

this.apiKey = apiKey
this.host = removeTrailingSlash(options?.host || 'https://app.posthog.com')
this.host = removeTrailingSlash(options?.host || 'https://us.i.posthog.com')
this.flushAt = options?.flushAt ? Math.max(options?.flushAt, 1) : 20
this.maxBatchSize = Math.max(this.flushAt, options?.maxBatchSize ?? 100)
this.maxQueueSize = Math.max(this.flushAt, options?.maxQueueSize ?? 1000)
Expand Down
2 changes: 1 addition & 1 deletion posthog-core/src/types.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
export type PostHogCoreOptions = {
/** PostHog API host, usually 'https://app.posthog.com' or 'https://eu.posthog.com' */
/** PostHog API host, usually 'https://us.i.posthog.com' or 'https://eu.i.posthog.com' */
host?: string
/** The number of events to queue before sending to PostHog (flushing) */
flushAt?: number
Expand Down
2 changes: 1 addition & 1 deletion posthog-core/test/posthog.capture.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ describe('PostHog Core', () => {
await waitForPromises()
expect(mocks.fetch).toHaveBeenCalledTimes(1)
const [url, options] = mocks.fetch.mock.calls[0]
expect(url).toMatch(/^https:\/\/app\.posthog\.com\/e\/\?ip=1&_=[0-9]+&v=[0-9.a-z-]+$/)
expect(url).toMatch(/^https:\/\/us\.i\.posthog\.com\/e\/\?ip=1&_=[0-9]+&v=[0-9.a-z-]+$/)
expect(options.method).toBe('POST')
const body = parseBody(mocks.fetch.mock.calls[0])

Expand Down
14 changes: 7 additions & 7 deletions posthog-core/test/posthog.featureflags.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ describe('PostHog Core', () => {
})

it('should return undefined', async () => {
expect(mocks.fetch).toHaveBeenCalledWith('https://app.posthog.com/decide/?v=3', {
expect(mocks.fetch).toHaveBeenCalledWith('https://us.i.posthog.com/decide/?v=3', {
body: JSON.stringify({
token: 'TEST_API_KEY',
distinct_id: posthog.getDistinctId(),
Expand Down Expand Up @@ -212,7 +212,7 @@ describe('PostHog Core', () => {
})

it('should return combined results', async () => {
expect(mocks.fetch).toHaveBeenCalledWith('https://app.posthog.com/decide/?v=3', {
expect(mocks.fetch).toHaveBeenCalledWith('https://us.i.posthog.com/decide/?v=3', {
body: JSON.stringify({
token: 'TEST_API_KEY',
distinct_id: posthog.getDistinctId(),
Expand All @@ -239,7 +239,7 @@ describe('PostHog Core', () => {
// now second call to feature flags
await posthog.reloadFeatureFlagsAsync(false)

expect(mocks.fetch).toHaveBeenCalledWith('https://app.posthog.com/decide/?v=3', {
expect(mocks.fetch).toHaveBeenCalledWith('https://us.i.posthog.com/decide/?v=3', {
body: JSON.stringify({
token: 'TEST_API_KEY',
distinct_id: posthog.getDistinctId(),
Expand Down Expand Up @@ -317,7 +317,7 @@ describe('PostHog Core', () => {
})

it('should return only latest results', async () => {
expect(mocks.fetch).toHaveBeenCalledWith('https://app.posthog.com/decide/?v=3', {
expect(mocks.fetch).toHaveBeenCalledWith('https://us.i.posthog.com/decide/?v=3', {
body: JSON.stringify({
token: 'TEST_API_KEY',
distinct_id: posthog.getDistinctId(),
Expand All @@ -344,7 +344,7 @@ describe('PostHog Core', () => {
// now second call to feature flags
await posthog.reloadFeatureFlagsAsync(false)

expect(mocks.fetch).toHaveBeenCalledWith('https://app.posthog.com/decide/?v=3', {
expect(mocks.fetch).toHaveBeenCalledWith('https://us.i.posthog.com/decide/?v=3', {
body: JSON.stringify({
token: 'TEST_API_KEY',
distinct_id: posthog.getDistinctId(),
Expand Down Expand Up @@ -537,7 +537,7 @@ describe('PostHog Core', () => {
})

it('should load new feature flags', async () => {
expect(mocks.fetch).toHaveBeenCalledWith('https://app.posthog.com/decide/?v=3', {
expect(mocks.fetch).toHaveBeenCalledWith('https://us.i.posthog.com/decide/?v=3', {
body: JSON.stringify({
token: 'TEST_API_KEY',
distinct_id: posthog.getDistinctId(),
Expand All @@ -563,7 +563,7 @@ describe('PostHog Core', () => {
})

it('should load new feature flag payloads', async () => {
expect(mocks.fetch).toHaveBeenCalledWith('https://app.posthog.com/decide/?v=3', {
expect(mocks.fetch).toHaveBeenCalledWith('https://us.i.posthog.com/decide/?v=3', {
body: JSON.stringify({
token: 'TEST_API_KEY',
distinct_id: posthog.getDistinctId(),
Expand Down
2 changes: 1 addition & 1 deletion posthog-core/test/posthog.init.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ describe('PostHog Core', () => {
it('should initialise default options', () => {
expect(posthog as any).toMatchObject({
apiKey: 'TEST_API_KEY',
host: 'https://app.posthog.com',
host: 'https://us.i.posthog.com',
flushAt: 20,
flushInterval: 10000,
})
Expand Down
3 changes: 3 additions & 0 deletions posthog-node/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
# Next

1. chore: change host to new address.

# 4.0.1 - 2024-04-25

Expand Down
2 changes: 1 addition & 1 deletion posthog-node/src/extensions/sentry-integration.ts
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ export class PostHogSentryIntegration implements _SentryIntegration {
private readonly organization?: string,
private readonly prefix?: string
) {
this.posthogHost = posthog.options.host ?? 'https://app.posthog.com'
this.posthogHost = posthog.options.host ?? 'https://us.i.posthog.com'
}

public setupOnce(
Expand Down
2 changes: 2 additions & 0 deletions posthog-react-native/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
# Next

1. chore: change host to new address.

# 3.1.1 - 2024-04-25

1. Prevent double JSON parsing of feature flag payloads, which would convert the payload [1] into 1.
Expand Down
4 changes: 4 additions & 0 deletions posthog-web/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
# Next

1. chore: change host to new address.

# 3.0.1 - 2024-04-25

1. Prevent double JSON parsing of feature flag payloads, which would convert the payload [1] into 1.
Expand Down
2 changes: 1 addition & 1 deletion posthog-web/test/posthog-web.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ describe('PostHogWeb', () => {

await waitForPromises()

expect(fetch).toHaveBeenCalledWith('https://app.posthog.com/decide/?v=3', {
expect(fetch).toHaveBeenCalledWith('https://us.i.posthog.com/decide/?v=3', {
body: JSON.stringify({
token: 'TEST_API_KEY',
distinct_id: posthog.getDistinctId(),
Expand Down