Skip to content
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
3 changes: 2 additions & 1 deletion packages/browser/src/profiling/utils.ts
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
import { DEFAULT_ENVIRONMENT } from '@sentry/core';
import type {
DsnComponents,
DynamicSamplingContext,
Expand DownExpand Up@@ -222,7 +223,7 @@ export function createProfilingEventEnvelope(
platform: 'javascript',
version: '1',
release: event.release || '',
environment: event.environment || '',
environment: event.environment || DEFAULT_ENVIRONMENT,
runtime: {
name: 'javascript',
version: WINDOW.navigator.userAgent,
Expand Down
1 change: 1 addition & 0 deletions packages/core/src/constants.ts
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
export const DEFAULT_ENVIRONMENT = 'production';
3 changes: 2 additions & 1 deletion packages/core/src/hub.ts
Original file line numberDiff line numberDiff line change
Expand Up@@ -30,6 +30,7 @@ import {
uuid4,
} from '@sentry/utils';

import { DEFAULT_ENVIRONMENT } from './constants';
import { Scope } from './scope';
import { closeSession, makeSession, updateSession } from './session';

Expand DownExpand Up@@ -409,7 +410,7 @@ export class Hub implements HubInterface {
*/
public startSession(context?: SessionContext): Session {
const { scope, client } = this.getStackTop();
const { release, environment } = (client && client.getOptions()) || {};
const { release, environment = DEFAULT_ENVIRONMENT } = (client && client.getOptions()) || {};

// Will fetch userAgent if called from browser sdk
const { userAgent } = GLOBAL_OBJ.navigator || {};
Expand Down
1 change: 1 addition & 0 deletions packages/core/src/index.ts
Original file line numberDiff line numberDiff line change
Expand Up@@ -31,6 +31,7 @@ export { getIntegrationsToSetup } from './integration';
export { FunctionToString, InboundFilters } from './integrations';
export { prepareEvent } from './utils/prepareEvent';
export { hasTracingEnabled } from './utils/hasTracingEnabled';
export { DEFAULT_ENVIRONMENT } from './constants';

import * as Integrations from './integrations';

Expand Down
3 changes: 2 additions & 1 deletion packages/core/src/utils/prepareEvent.ts
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
import type { ClientOptions, Event, EventHint, StackParser } from '@sentry/types';
import { dateTimestampInSeconds, GLOBAL_OBJ, normalize, resolvedSyncPromise, truncate, uuid4 } from '@sentry/utils';

import { DEFAULT_ENVIRONMENT } from '../constants';
import { Scope } from '../scope';

/**
Expand DownExpand Up@@ -87,7 +88,7 @@ function applyClientOptions(event: Event, options: ClientOptions): void {
const { environment, release, dist, maxValueLength = 250 } = options;

if (!('environment' in event)) {
event.environment = 'environment' in options ? environment : 'production';
event.environment = 'environment' in options ? environment : DEFAULT_ENVIRONMENT;
}

if (event.release === undefined && release !== undefined) {
Expand Down
4 changes: 2 additions & 2 deletions packages/tracing/src/transaction.ts
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
import type { Hub } from '@sentry/core';
import { getCurrentHub } from '@sentry/core';
import { DEFAULT_ENVIRONMENT, getCurrentHub } from '@sentry/core';
import type {
Context,
Contexts,
Expand DownExpand Up@@ -260,7 +260,7 @@ export class Transaction extends SpanClass implements TransactionInterface {
const transaction = source && source !== 'url' ? this.name : undefined;

const dsc = dropUndefinedKeys({
environment,
environment: environment || DEFAULT_ENVIRONMENT,
release,
transaction,
user_segment,
Expand Down